Skip to content

Commit 23e233f

Browse files
author
lofcz
committed
Aktualizace komponenty combat
- Útok může zasáhnout libovolný počet předmětů. - Opraveny chyby v rendrování animace / skutečný konec útoku.
1 parent f89ed8b commit 23e233f

11 files changed

+43
-22
lines changed

SimplexRPGEngine/Engine source/DragonRise3.project.gmx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,8 @@
912912
<script>scripts\combatHandle.gml</script>
913913
<script>scripts\combatSetUp.gml</script>
914914
<script>scripts\combatGetParry.gml</script>
915+
<script>scripts\combatCanBeHit.gml</script>
916+
<script>scripts\combatMarkAsHit.gml</script>
915917
<script>scripts\combatGetCriticalHit.gml</script>
916918
</scripts>
917919
<scripts name="MapIntro">

SimplexRPGEngine/Engine source/objects/oAdvancedCollision.object.gmx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ if (tA == 1 &amp;&amp; hp != -1)
172172

173173
if (string_count("breakable", hitType) &gt; 0)
174174
{
175-
if (other.attack &amp;&amp; other.can_damage = -1 &amp;&amp; mode == 0)
175+
if (other.attack &amp;&amp; combatCanBeHit() &amp;&amp; mode == 0)
176176
{
177177
dmg = 0;
178178
dmg += oPlayer.vlastnost[vlastnost_poskozeni];
179179
if (hitType == "breakableStone") {dmg = round(dmg / 3);}
180180

181181
hp -= dmg;
182-
other.can_damage = -2;
182+
combatMarkAsHit();
183183
global.tX = x;
184184
global.tY = y;
185185
with(oPlayer) {effectShardDrop(global.tX, global.tY, irandom_range(3,6));}

SimplexRPGEngine/Engine source/objects/oNonsolidCollision.object.gmx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,16 @@ if (hp &lt; 0.5 &amp;&amp; flag2) {flag2 = false; event_user(3);}
200200
<kind>1</kind>
201201
<string>/// Handle onHit event
202202

203+
203204
if (hitType == "breakableGrass")
204205
{
205-
if (other.attack &amp;&amp; other.can_damage = -1 &amp;&amp; mode == 0)
206+
if (other.attack &amp;&amp; combatCanBeHit() &amp;&amp; mode == 0)
206207
{
207208
dmg = 0;
208209
dmg += oPlayer.vlastnost[vlastnost_poskozeni];
209210

210211
hp -= dmg;
211-
other.can_damage = -2;
212+
combatMarkAsHit();
212213
global.tX = x;
213214
global.tY = y;
214215
with(oPlayer) {effectGrass(global.tX, global.tY, irandom_range(3,6));}

SimplexRPGEngine/Engine source/objects/oSwordSwing.object.gmx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ else
8989
<arguments>
9090
<argument>
9191
<kind>1</kind>
92-
<string>instance_destroy();
92+
<string>// Destroy self
93+
94+
oPlayerCombat.tick = 1;
95+
instance_destroy();
9396
</string>
9497
</argument>
9598
</arguments>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// combatCanBeHit()
2+
3+
var z = ds_list_find_index(oPlayerCombat.hitList, id);
4+
if (z == -1) {return true;}
5+
return false;

SimplexRPGEngine/Engine source/scripts/combatHandle.gml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/// combatHandle()
22

3-
x = oPlayer.x;
4-
y = oPlayer.y;
5-
image_speed = 0;
6-
73
if (instance_number(oPlayer) > 0)
84
{
95
sprite_index = sWeaponCollision;
6+
image_index = 0;
107

11-
//sprite = oPlayer.draw_equ[id_Mec,0];
12-
//index = oPlayer.draw_equ[id_Mec,1];
8+
if (oPlayer.last_dir == "d") {x = oPlayer.x + 16; y = oPlayer.y - 16;}
9+
if (oPlayer.last_dir == "a") {x = oPlayer.x - 64; y = oPlayer.y - 16;}
10+
if (oPlayer.last_dir == "w") {x = oPlayer.x - 24; y = oPlayer.y - 64;}
11+
if (oPlayer.last_dir == "s") {x = oPlayer.x - 24; y = oPlayer.y + 32;}
1312

1413
if (sprite != 0)
1514
{
@@ -41,7 +40,7 @@ if ((keyboard_check_released(vk_space) && chargeMode) || (keyboard_check_pressed
4140
k = 0;
4241
can_damage = -1;
4342
oPlayer.vlastnost[vlastnost_stamina] -= oPlayer.vlastnost[vlastnost_stamina_cost];
44-
ss = instance_create(x, y, oSwordSwing);
43+
ss = instance_create(xx, yy, oSwordSwing);
4544
ss.dir = oPlayer.last_dir;
4645
attackMode = "attack";
4746
oPlayer.currentAnimation = animationEnum.slash;
@@ -74,7 +73,7 @@ if (tick > 0)
7473
{
7574
tick -= tick_rate;
7675
}
77-
else {if (untick = 1) {attack = 0; untick = 0;}}
76+
else {if (untick = 1) {attack = 0; untick = 0; ds_list_clear(hitList);}}
7877
}
7978
}
8079

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// combatMarkAsHit(hit)
2+
3+
var h;
4+
h = true;
5+
6+
if (argument_count > 0) {h = argument[0];}
7+
8+
if (h) {ds_list_add(oPlayerCombat.hitList, id); return true}
9+
10+
ds_list_delete(oPlayerCombat.hitList, ds_list_find_index(oPlayerCombat.hitList, id));
11+
return true;

SimplexRPGEngine/Engine source/scripts/combatSetUp.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ maxCharge = 100;
4343
chargeMode = 0;
4444
sprite_index = sprite;
4545
image_speed = 0;
46+
hitList = ds_list_create();

SimplexRPGEngine/Engine source/scripts/enemyAPI.gml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,12 @@ return false;
238238
#define scrEnemyGetDamage
239239
/// scrEnemyGetDamage()
240240
241-
242-
if (other.attack && other.can_damage = -1)
241+
if (other.attack && combatCanBeHit())
243242
{
244243
//forcedBaseX = 50;
245244
//forcedX = 50;
246245
247-
246+
combatMarkAsHit();
248247
text = choose("Ve jménu Demacie!", "Odporná zhoubo!", "Prolomím jejich řady!", "Nemějte slitování!", "Přímo do černého!", "Překvapení, jsem zpátky!", "Za krále a Demacii!", "Valore, na ně!");
249248
apiPlayerSay(text);
250249
apiPlayerSayNext();

SimplexRPGEngine/Engine source/scripts/scrItemInstantiate.gml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ else
5151

5252
if (p)
5353
{
54-
p.drawDrop = true;
55-
p.direction = random(360);
56-
p.speed = random_range(2, 4);
57-
p.friction = 0.15;
54+
b.drawDrop = true;
55+
b.direction = random(360);
56+
b.speed = random_range(2, 4);
57+
b.friction = 0.15;
5858
}
5959
}

0 commit comments

Comments
 (0)