Skip to content

Commit

Permalink
Aktualizace komponenty combat
Browse files Browse the repository at this point in the history
- Útok může zasáhnout libovolný počet předmětů.
- Opraveny chyby v rendrování animace / skutečný konec útoku.
  • Loading branch information
lofcz committed Dec 18, 2016
1 parent f89ed8b commit 23e233f
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 22 deletions.
2 changes: 2 additions & 0 deletions SimplexRPGEngine/Engine source/DragonRise3.project.gmx
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,8 @@
<script>scripts\combatHandle.gml</script>
<script>scripts\combatSetUp.gml</script>
<script>scripts\combatGetParry.gml</script>
<script>scripts\combatCanBeHit.gml</script>
<script>scripts\combatMarkAsHit.gml</script>
<script>scripts\combatGetCriticalHit.gml</script>
</scripts>
<scripts name="MapIntro">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ if (tA == 1 &amp;&amp; hp != -1)

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

hp -= dmg;
other.can_damage = -2;
combatMarkAsHit();
global.tX = x;
global.tY = y;
with(oPlayer) {effectShardDrop(global.tX, global.tY, irandom_range(3,6));}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,16 @@ if (hp &lt; 0.5 &amp;&amp; flag2) {flag2 = false; event_user(3);}
<kind>1</kind>
<string>/// Handle onHit event


if (hitType == "breakableGrass")
{
if (other.attack &amp;&amp; other.can_damage = -1 &amp;&amp; mode == 0)
if (other.attack &amp;&amp; combatCanBeHit() &amp;&amp; mode == 0)
{
dmg = 0;
dmg += oPlayer.vlastnost[vlastnost_poskozeni];

hp -= dmg;
other.can_damage = -2;
combatMarkAsHit();
global.tX = x;
global.tY = y;
with(oPlayer) {effectGrass(global.tX, global.tY, irandom_range(3,6));}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ else
<arguments>
<argument>
<kind>1</kind>
<string>instance_destroy();
<string>// Destroy self

oPlayerCombat.tick = 1;
instance_destroy();
</string>
</argument>
</arguments>
Expand Down
5 changes: 5 additions & 0 deletions SimplexRPGEngine/Engine source/scripts/combatCanBeHit.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// combatCanBeHit()

var z = ds_list_find_index(oPlayerCombat.hitList, id);
if (z == -1) {return true;}
return false;
15 changes: 7 additions & 8 deletions SimplexRPGEngine/Engine source/scripts/combatHandle.gml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/// combatHandle()

x = oPlayer.x;
y = oPlayer.y;
image_speed = 0;

if (instance_number(oPlayer) > 0)
{
sprite_index = sWeaponCollision;
image_index = 0;

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

if (sprite != 0)
{
Expand Down Expand Up @@ -41,7 +40,7 @@ if ((keyboard_check_released(vk_space) && chargeMode) || (keyboard_check_pressed
k = 0;
can_damage = -1;
oPlayer.vlastnost[vlastnost_stamina] -= oPlayer.vlastnost[vlastnost_stamina_cost];
ss = instance_create(x, y, oSwordSwing);
ss = instance_create(xx, yy, oSwordSwing);
ss.dir = oPlayer.last_dir;
attackMode = "attack";
oPlayer.currentAnimation = animationEnum.slash;
Expand Down Expand Up @@ -74,7 +73,7 @@ if (tick > 0)
{
tick -= tick_rate;
}
else {if (untick = 1) {attack = 0; untick = 0;}}
else {if (untick = 1) {attack = 0; untick = 0; ds_list_clear(hitList);}}
}
}

Expand Down
11 changes: 11 additions & 0 deletions SimplexRPGEngine/Engine source/scripts/combatMarkAsHit.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// combatMarkAsHit(hit)

var h;
h = true;

if (argument_count > 0) {h = argument[0];}

if (h) {ds_list_add(oPlayerCombat.hitList, id); return true}

ds_list_delete(oPlayerCombat.hitList, ds_list_find_index(oPlayerCombat.hitList, id));
return true;
1 change: 1 addition & 0 deletions SimplexRPGEngine/Engine source/scripts/combatSetUp.gml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ maxCharge = 100;
chargeMode = 0;
sprite_index = sprite;
image_speed = 0;
hitList = ds_list_create();
5 changes: 2 additions & 3 deletions SimplexRPGEngine/Engine source/scripts/enemyAPI.gml
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,12 @@ return false;
#define scrEnemyGetDamage
/// scrEnemyGetDamage()
if (other.attack && other.can_damage = -1)
if (other.attack && combatCanBeHit())
{
//forcedBaseX = 50;
//forcedX = 50;
combatMarkAsHit();
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ě!");
apiPlayerSay(text);
apiPlayerSayNext();
Expand Down
8 changes: 4 additions & 4 deletions SimplexRPGEngine/Engine source/scripts/scrItemInstantiate.gml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ else

if (p)
{
p.drawDrop = true;
p.direction = random(360);
p.speed = random_range(2, 4);
p.friction = 0.15;
b.drawDrop = true;
b.direction = random(360);
b.speed = random_range(2, 4);
b.friction = 0.15;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (s == -1)
m = ((((power(xx, 1)) + (log10(xx))) * 1) + 111.5);
for (var i = 0; i < celkem_vlastnosti; i++)
{
if (i != vlastnost_reinforcementCostBase && i != vlastnost_reinforcementCostInc && i != vlastnost_reinforcementCostIncM && i != vlastnost_reinforcementIs && i != vlastnost_reinforcementLevel && i != vlastnost_bodyCanvasIndex && i != vlastnost_bodyCanvasSprite && i != vlastnost_bodyCanvasSlashSprite && i != vlastnost_stamina_cost)
if (i != vlastnost_reinforcementCostBase && i != vlastnost_reinforcementCostInc && i != vlastnost_reinforcementCostIncM && i != vlastnost_reinforcementIs && i != vlastnost_reinforcementLevel && i != vlastnost_bodyCanvasIndex && i != vlastnost_bodyCanvasSprite && i != vlastnost_bodyCanvasSlashSprite && i != vlastnost_stamina_cost && i != vlastnost_upgradeSloty && i != vlastnost_maxUpgrade && i != vlastnost_upgradeMaterial1 && i != vlastnost_upgradeMaterial2 && i != vlastnost_upgradeMaterial3 && i != vlastnost_upgradeSprite1 && i != vlastnost_upgradeSprite2 && i != vlastnost_upgradeSprite3 && i != vlastnost_upgradeText1 && i != vlastnost_upgradeText2 && i != vlastnost_upgradeText3 && i != vlastnost_upgradeID1 && i != vlastnost_upgradeID2 && i != vlastnost_upgradeID3 && i != vlastnost_upgradeBaked1 && i != vlastnost_upgradeBaked2 && i != vlastnost_upgradeBaked3 && i != vlastnost_parry_cost)
{
vlastnost[i] = round((vlastnost[i] / 100) * m);
}
Expand All @@ -29,7 +29,7 @@ else
m = ((((power(xx, 1)) + (log10(xx))) * 1) + 111.5);
for (var i = 0; i < celkem_vlastnosti; i++)
{
if (i != vlastnost_reinforcementCostBase && i != vlastnost_reinforcementCostInc && i != vlastnost_reinforcementCostIncM && i != vlastnost_reinforcementIs && i != vlastnost_reinforcementLevel && i != vlastnost_bodyCanvasIndex && i != vlastnost_bodyCanvasSprite && i != vlastnost_bodyCanvasSlashSprite && i != vlastnost_stamina_cost)
if (i != vlastnost_reinforcementCostBase && i != vlastnost_reinforcementCostInc && i != vlastnost_reinforcementCostIncM && i != vlastnost_reinforcementIs && i != vlastnost_reinforcementLevel && i != vlastnost_bodyCanvasIndex && i != vlastnost_bodyCanvasSprite && i != vlastnost_bodyCanvasSlashSprite && i != vlastnost_stamina_cost && i != vlastnost_upgradeSloty && i != vlastnost_maxUpgrade && i != vlastnost_upgradeMaterial1 && i != vlastnost_upgradeMaterial2 && i != vlastnost_upgradeMaterial3 && i != vlastnost_upgradeSprite1 && i != vlastnost_upgradeSprite2 && i != vlastnost_upgradeSprite3 && i != vlastnost_upgradeText1 && i != vlastnost_upgradeText2 && i != vlastnost_upgradeText3 && i != vlastnost_upgradeID1 && i != vlastnost_upgradeID2 && i != vlastnost_upgradeID3 && i != vlastnost_upgradeBaked1 && i != vlastnost_upgradeBaked2 && i != vlastnost_upgradeBaked3 && i != vlastnost_parry_cost)
{
oInventory.slot_vlastnosti[s, i] = round((oInventory.slot_vlastnosti[s, i] / 100) * m);
}
Expand Down

0 comments on commit 23e233f

Please sign in to comment.