Can a trigger in progress get overwritten? Paranoia level increased!

Solu9

You can change this now in User CP.
Reaction score
216
I think I know the answer to this question but as the title says, I'm growing more paranoid and insecure.

I'll post an ability trigger and the actual damage calculation trigger:

Cleave:
Trigger:
  • Cleave
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Cleaving Strike
    • Actions
      • Set uDMGUnit = (Triggering unit)
      • Set pCleave = (Position of uDMGUnit)
      • -------- ---------- --------
      • -------- Set Ability used --------
      • Set abilAbilityCasted[(Player number of (Owner of uDMGUnit))] = (Ability being cast)
      • -------- ---------- --------
      • -------- Set Ability multiplier --------
      • Set rAbilityMultiplier[(Player number of (Owner of uDMGUnit))] = 0.25
      • -------- ---------- --------
      • -------- Set damage type --------
      • Set booDmgType_Physical[(Player number of (Owner of uDMGUnit))] = True
      • Set booDmgType_Fire[(Player number of (Owner of uDMGUnit))] = False
      • Set booDmgType_Ice[(Player number of (Owner of uDMGUnit))] = False
      • Set booDmgType_Light[(Player number of (Owner of uDMGUnit))] = False
      • Set booDmgType_Poison[(Player number of (Owner of uDMGUnit))] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Cleaving Strike for uDMGUnit) Greater than or equal to 10
        • Then - Actions
          • Unit - Create 1 Dummy Unit Cleave - Armor Break for (Owner of uDMGUnit) at pCleave facing Default building facing degrees
          • Unit - Set level of Dummy Cleave - Armor Break for (Last created unit) to (Level of Cleaving Strike for uDMGUnit)
          • Unit - Order (Last created unit) to Night Elf Druid Of The Claw - Roar
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
        • Else - Actions
      • Set ugCleave = (Units within 200.00 of pCleave matching ((((Matching unit) belongs to an enemy of (Owner of uDMGUnit)) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in ugCleave and do (Actions)
        • Loop - Actions
          • Set uAttackedUnit[(Player number of (Owner of uDMGUnit))] = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Cleaving Strike for uDMGUnit) Greater than or equal to 20
              • (Percentage life of uAttackedUnit[(Player number of (Owner of uDMGUnit))]) Less than or equal to 20.00
            • Then - Actions
              • Unit - Kill uAttackedUnit[(Player number of (Owner of uDMGUnit))]
              • Special Effect - Create a special effect attached to the origin of uAttackedUnit[(Player number of (Owner of uDMGUnit))] using Objects\Spawnmodels\Orc\Orcblood\BattrollBlood.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit Group - Remove uAttackedUnit[(Player number of (Owner of uDMGUnit))] from ugCleave
            • Else - Actions
              • Trigger - Run Damage Calculation <gen> (checking conditions)
              • Trigger - Run Damage Calculation Copy <gen> (checking conditions)
              • Unit - Cause uDMGUnit to damage uAttackedUnit[(Player number of (Owner of uDMGUnit))], dealing (Real(iAttackDamage[(Player number of (Owner of uDMGUnit))])) damage of attack type Chaos and damage type Normal
              • Special Effect - Create a special effect attached to the origin of uAttackedUnit[(Player number of (Owner of uDMGUnit))] using Objects\Spawnmodels\Orc\Orcblood\BattrollBlood.mdl
              • Special Effect - Destroy (Last created special effect)
      • Custom script: call DestroyGroup (udg_ugCleave)
      • Custom script: call RemoveLocation (udg_pCleave)



Damage calculation:
Trigger:
  • Damage Calculation
    • Events
    • Conditions
    • Actions
      • -------- Check Dodge --------
      • Set booDodge[(Player number of (Owner of uDMGUnit))] = False
      • Set iGameVari_Dodge_Enemy[(Player number of (Owner of uDMGUnit))] = (Level of Dodge for uAttackedUnit[(Player number of (Owner of uDMGUnit))])
      • Set iRandomNumber[(Player number of (Owner of uDMGUnit))] = (Random integer number between 1 and 100)
      • Trigger - Run Check Dodge <gen> (checking conditions)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • booDodge[(Player number of (Owner of uDMGUnit))] Equal to True
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Set Stat based damage --------
      • Set iGameVari_Strength[1] = (Strength of uDamagingUnit[1] (Include bonuses))
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Set Weapon based damage --------
      • Set iWeaponDamage_Random[1] = (Random integer number between iGameVari_Damage_Min[1] and iGameVari_Damage_Max[1])
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Calculate raw damage --------
      • Set iGameVari_ActualDamage[1] = (iGameVari_Strength[1] + iWeaponDamage_Random[1])
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Set standard damage calculation --------
      • Set rAttackDamage[1] = ((Real(iGameVari_ActualDamage[1])) x (1.00 + ((Real((Level of abilAbilityCasted[1] for uDamagingUnit[1]))) x rAbilityMultiplier[1])))
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Apply resistance (hvis "Enemy Resistance - XXXX" er level 1 gives der 0 skade, altsÃ¥ immunitet) --------
      • Trigger - Run Check Physical Resistance <gen> (checking conditions)
      • Trigger - Run Check Fire Resistance <gen> (checking conditions)
      • Trigger - Run Check Ice Resistance <gen> (checking conditions)
      • Trigger - Run Check Lightning Resistance <gen> (checking conditions)
      • Trigger - Run Check Poison Resistance <gen> (checking conditions)
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Check Critical Strike --------
      • Set booCriticalStrike[1] = False
      • Set iRandomNumber[1] = (Random integer number between 1 and 100)
      • Trigger - Run Check Critical Strike <gen> (checking conditions)
      • -------- ---------- --------
      • -------- ---------- --------
      • -------- Convert damage to integer --------
      • Set iAttackDamage[1] = (Integer(rAttackDamage[1]))
      • -------- ---------- --------
      • -------- Apply damage --------
      • -------- ---------- --------


As you can see I was in the middle of changing all conditions/actions arrays from [1] to [(Player number of (Owner of uDMGUnit))].
The reason was because I thought I was being clever by storing all data in arrays linked to the casting player. That way, I thought, I was completely sure that when another player used an ability at the same time nothing would overlap.
So far so good.
Then I to think, if I just use the array number of the owner of "uDMGUnit" in all of my spells it would be redundant to make arrays in the first place since they would all be linked to uDMGUnit through the trigger.
Suddenly the paranoia stoke again. So if two players use two different abilities, both of which refers back to uDMGUnit, can they possibly overlap if cast almost at the same time?

My initial answer is no. Everything happens in orders. Nothing can happen at the exact same time.
But I'm paranoid so I would like to have this confirmed.
Furthermore. If it is indeed true that I'm just freaking out and even though every spell refers back to uDMGUnit, can I just scratch all of my arrays and make them none arrays?

Sorry for the long post.

The paranoid.

P.s. Thanks for a great magazine.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Everything happens in a sequence on a computer. There is no true parallelism in a video game like wc3.
So there is no problem.
 

Solu9

You can change this now in User CP.
Reaction score
216
Everything happens in a sequence on a computer. There is no true parallelism in a video game like wc3.
So there is no problem.


Phew!

So for the array part. Would you suggest to just scratch them?

Edit:
And to be completely sure! Even when the damage calculation trigger runs (checks) fx. the "Check Dodge" trigger. It will all happen before another ability is cast by another player?
 

thorhunter

You can change this now in User CP.
Reaction score
32
Suddenly the paranoia stoke again. So if two players use two different abilities, both of which refers back to uDMGUnit, can they possibly overlap if cast almost at the same time?
Technically, it could be possible, though very unlikely. The problem with Wc3 mechanics is that events expropriate currently proccessed triggers, though there must be some event queuing mechanism that prevents it as I've never seen this happening to events occuring naturally (read: not induced by trigger actions). However, if you for example call 'kill unit' action, it will inevitably bring about all triggers that have 'A unit is killed' events in them that will be processed before the rest of calling trigger. Soltuion to this is to not ever use any variable that is shared between triggers in trigger that may interrupt others.

Interrupting trigger examples: 'Unit Dies, takes damage, etc., Unit acquires/loses item etc.
Variables that are commonly shared among triggers: widely prefered global temp_x variables, 'Integer A' and 'Integer B' variables.
 

Solu9

You can change this now in User CP.
Reaction score
216
Yeah so if a unit is killed because of the damage caused by fx. Cleave, and I have a "unit is killed" trigger event somewhere. That trigger will be executed before the Cleave trigger continues.

Am I right?
 

thorhunter

You can change this now in User CP.
Reaction score
32
I am not sure whether applying deadly amount of damage will call unqueued kill trigger but it will defineately call 'unit takes damage' one should that unit be linked with it. If you apply 'kill unit' action to an unit, it will defineately interrupt further actions with all 'A unit dies' triggers.
 

Solu9

You can change this now in User CP.
Reaction score
216
I am not sure whether applying deadly amount of damage will call unqueued kill trigger but it will defineately call 'unit takes damage' one should that unit be linked with it. If you apply 'kill unit' action to an unit, it will defineately interrupt further actions with all 'A unit dies' triggers.


It's funny you mention "applying deadly amount of damage". I was actually about to write that in my last post, but thought it didn't make any sense since the unit is still killed and thus would still trigger an "a unit is dies" event.
I don't think it matters if a unit dies one way or the other to be honest.
 

thorhunter

You can change this now in User CP.
Reaction score
32
If you're going for sophisticated systems it may be best to scrap the warcraft interface and just make your own, but then again what would be the point of staying with wc3 editor and its limitations and not move to more powerful platform.
 

Solu9

You can change this now in User CP.
Reaction score
216
If you're going for sophisticated systems it may be best to scrap the warcraft interface and just make your own, but then again what would be the point of staying with wc3 editor and its limitations and not move to more powerful platform.


Did you reply in the right post?
If not then I'm confused. I use the WC3 editor because I find it fun and I have no idea how to code "in real life" so to speak ;)
 

thorhunter

You can change this now in User CP.
Reaction score
32
I map that uses custom resistance/critical/evasion systems is well outside of what most of the custom maps represent. As it will grow with complexity, the editor will cause more and more problems :) .
 

Solu9

You can change this now in User CP.
Reaction score
216
I map that uses custom resistance/critical/evasion systems is well outside of what most of the custom maps represent. As it will grow with complexity, the editor will cause more and more problems :) .


My trust in the editor is strong! The editor will prevail!

Edit:
No really. I'm not going to implement much more than what you see in the damage calculation trigger. I don't know. It should be able to hold water.
If not... well I will go down with the sinking ship! Or actually find a tutorial on basic coding and create some crazy mini-game and sell for millions. Millions!
 

Solu9

You can change this now in User CP.
Reaction score
216
Mu trust has been shaken though.

I did some testing with an ability and a custom item drop system:

Flamestorm:
Trigger:
  • Cast Flamestorm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flamestorm
    • Actions
      • Set uFlamestorm_Caster = (Triggering unit)
      • Set iFlamestorm_Timer = 10
      • Special Effect - Create a special effect attached to the origin of uFlamestorm_Caster using FireTornado.mdx
      • Set speceffect_Flamestorm = (Last created special effect)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Flamestorm for uFlamestorm_Caster) Greater than or equal to 20
        • Then - Actions
          • Unit - Set uFlamestorm_Caster movement speed to ((Current movement speed of uFlamestorm_Caster) + 500.00)
        • Else - Actions
      • Trigger - Turn on Execute Flamestorm <gen>


Trigger:
  • Execute Flamestorm
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set iFlamestorm_Timer = (iFlamestorm_Timer - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • iFlamestorm_Timer Less than or equal to 0
              • (uFlamestorm_Caster is alive) Equal to False
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Special Effect - Destroy speceffect_Flamestorm
          • Unit - Set uFlamestorm_Caster movement speed to (Default movement speed of uFlamestorm_Caster)
        • Else - Actions
          • Set uDMGUnit = uFlamestorm_Caster
          • Set pFlamestorm = (Position of uFlamestorm_Caster)
          • -------- ---------- --------
          • -------- Set Ability used --------
          • Set abilAbilityCasted[1] = Flamestorm
          • -------- ---------- --------
          • -------- Set Ability multiplier --------
          • Set rAbilityMultiplier[1] = 0.15
          • -------- ---------- --------
          • -------- Set damage type --------
          • Set booDmgType_Physical[1] = False
          • Set booDmgType_Fire[1] = True
          • Set booDmgType_Ice[1] = False
          • Set booDmgType_Light[1] = False
          • Set booDmgType_Poison[1] = False
          • Set ugFlamestorm_1 = (Units within 200.00 of pFlamestorm matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of uFlamestorm_Caster)) Equal to True)))
          • Unit Group - Pick every unit in ugFlamestorm_1 and do (Actions)
            • Loop - Actions
              • Set uAttackedUnit[1] = (Picked unit)
              • Trigger - Run Damage Calculation <gen> (checking conditions)
              • Unit - Cause uDMGUnit to damage uAttackedUnit[1], dealing (Real(iAttackDamage[1])) damage of attack type Chaos and damage type Normal
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Flamestorm for uFlamestorm_Caster) Greater than or equal to 10
            • Then - Actions
              • Set ugFlamestorm_2 = (Units within 600.00 of pFlamestorm matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of uFlamestorm_Caster)) Equal to True)))
              • For each (Integer A) from 1 to 3, do (Actions)
                • Loop - Actions
                  • Set uFlamestorm_Target2 = (Random unit from ugFlamestorm_2)
                  • Unit - Create 1 Dummy Unit Flamestorm - Fireball Cast for (Owner of uFlamestorm_Caster) at pFlamestorm facing Default building facing degrees
                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike uFlamestorm_Target2
                  • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
            • Else - Actions
          • Custom script: call DestroyGroup (udg_ugFlamestorm_1)
          • Custom script: call DestroyGroup (udg_ugFlamestorm_2)
          • Custom script: call RemoveLocation (udg_pFlamestorm)


Trigger:
  • Flamestorm Fireball Damage
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Dummy Flamestorm - Fireball Cast
    • Actions
      • Set uDMGUnit = uFlamestorm_Caster
      • -------- ---------- --------
      • -------- Set Ability used --------
      • Set abilAbilityCasted[1] = Flamestorm
      • -------- ---------- --------
      • -------- Set Ability multiplier --------
      • Set rAbilityMultiplier[1] = 0.15
      • -------- ---------- --------
      • -------- Set damage type --------
      • Set booDmgType_Physical[1] = False
      • Set booDmgType_Fire[1] = True
      • Set booDmgType_Ice[1] = False
      • Set booDmgType_Light[1] = False
      • Set booDmgType_Poison[1] = False
      • Set uAttackedUnit[1] = (Target unit of ability being cast)
      • Trigger - Run Damage Calculation <gen> (checking conditions)
      • Unit - Cause uDMGUnit to damage uAttackedUnit[1], dealing (Real(iAttackDamage[1])) damage of attack type Chaos and damage type Normal


Custom drop system (simplified):

Trigger:
  • Set Test Drop Table
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ItemType_DropTest[1] = Claws of Attack +3
      • Set ItemType_DropTest[2] = Claws of Attack +6
      • Set ItemType_DropTest[3] = Claws of Attack +9
      • Set ItemType_DropTest[4] = Ring of Protection +2
      • Set ItemType_DropTest[5] = Ring of Protection +3
      • Set ItemType_DropTest[6] = Ring of Protection +4
      • Set ItemType_DropTest[7] = Ring of the Archmagi
      • Set ItemType_DropTest[8] = Ring of the Archmagi
      • Set ItemType_DropTest[9] = Ring of the Archmagi
      • Set ItemType_DropTest[10] = Frostguard


Trigger:
  • Chance to drop at all
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Dying unit)) Equal to Player 12 (Brown)
          • ((Dying unit) is A Hero) Equal to False
    • Actions
      • Set Item_DropAtAll = (Random integer number between 1 and 10)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item_DropAtAll Equal to 10
        • Then - Actions
          • Set Point_Drop = (Position of (Dying unit))
          • Item - Create ItemType_DropTest[(Random integer number between 1 and (Level of (Dying unit)))] at Point_Drop
          • Custom script: call RemoveLocation (udg_Point_Drop)
        • Else - Actions


To my fear I experienced while testing the Flamestorm ablity, that the "Life (+4)" that is created in the Level Up trigger in my initial post, was left on the ground while Flamestorm was active killing enemies and the character using the ability gained a level.

I conclude that the Level Up trigger got overwritten by the Drop Item Trigger in some way.
I have tried to replicate the bug but everything has worked since. But the problem is of course still there.

Can anyone explain why this happened?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top