• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Unintentional Self-Damage and, Death Condition

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
The problems I'm currently facing is, the spell (1) damages the caster, which should not be, and (2) still executes after death, even though I put a condition beforehand.

Help?



  • For each (Integer ER_CurrentIndex) from 1 to ER_MaxIndex, do (Actions)
    • Loop - Actions
      • Set ER_Counter[ER_CurrentIndex] = (ER_Counter[ER_CurrentIndex] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ER_Counter[ER_CurrentIndex] Equal to 33
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (ER_Caster[ER_CurrentIndex] is Sleeping) Equal to True
                  • (ER_Caster[ER_CurrentIndex] is Stunned) Equal to True
                  • (ER_Caster[ER_CurrentIndex] is dead) Equal to True
            • Then - Actions
              • -------- Recycling --------
              • Custom script: call RemoveLocation(udg_ER_SomePoint)
              • Set ER_Caster[ER_CurrentIndex] = ER_Caster[ER_MaxIndex]
              • Set ER_ControlPlayer[ER_CurrentIndex] = ER_ControlPlayer[ER_MaxIndex]
              • Set ER_Counter[ER_CurrentIndex] = ER_Counter[ER_MaxIndex]
              • Set ER_Counter2[ER_CurrentIndex] = ER_Counter2[ER_MaxIndex]
              • Set ER_Level[ER_CurrentIndex] = ER_Level[ER_MaxIndex]
              • Set ER_MaxIndex = (ER_MaxIndex - 1)
              • Set ER_CurrentIndex = (ER_CurrentIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ER_MaxIndex Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Set ER_Facing[ER_CurrentIndex] = (Facing of ER_Caster[ER_CurrentIndex])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ER_Counter2[ER_CurrentIndex] Equal to ER_StompWaveNumber[ER_Level[ER_CurrentIndex]]
                • Then - Actions
                  • Set ER_SomePoint = (Position of ER_Caster[ER_CurrentIndex])
                  • -------- Once the set number of waves occur, the final stomp happens. --------
                  • For each (Integer ER_TempInt2[1]) from 1 to ER_SpireElementNum[ER_Level[ER_CurrentIndex]], do (Actions)
                    • Loop - Actions
                      • For each (Integer ER_TempInt2[2]) from 1 to ER_SpireNum[ER_Level[ER_CurrentIndex]], do (Actions)
                        • Loop - Actions
                          • Set ER_Tempoffsetpoint = (ER_SomePoint offset by (ER_SpiralDistance[ER_Level[ER_CurrentIndex]] + (ER_SpiralDistance[ER_Level[ER_CurrentIndex]] x (Real(ER_TempInt2[1])))) towards (((360.00 / (Real(ER_SpireNum[ER_Level[ER_CurrentIndex]]))) x (Real(ER_TempInt2[2]))) + (ER_SpireCurve[ER_
                          • Special Effect - Create a special effect at ER_Tempoffsetpoint using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
                          • Special Effect - Destroy (Last created special effect)
                          • Set ER_DummyGroup = (Units within ER_SpiralRangeDamage[ER_Level[ER_CurrentIndex]] of ER_Tempoffsetpoint matching (((Matching unit) belongs to an enemy of ER_ControlPlayer[ER_CurrentIndex]) Equal to True))
                          • Unit Group - Pick every unit in ER_DummyGroup and do (Actions)
                            • Loop - Actions
                              • Game - Display to (All players) the text: (String((Unit-type of (Picked unit))))
                              • Unit - Cause ER_Caster[ER_CurrentIndex] to damage (Picked unit), dealing ER_SpireDamage[ER_Level[ER_CurrentIndex]] damage of attack type Normal and damage type Normal
                          • Custom script: call RemoveLocation(udg_ER_DummyPoint)
                          • Custom script: call DestroyGroup(udg_ER_DummyGroup)
                          • Custom script: call RemoveLocation(udg_ER_Tempoffsetpoint)
                  • -------- Recycling --------
                  • Custom script: call RemoveLocation(udg_ER_SomePoint)
                  • Set ER_Caster[ER_CurrentIndex] = ER_Caster[ER_MaxIndex]
                  • Set ER_ControlPlayer[ER_CurrentIndex] = ER_ControlPlayer[ER_MaxIndex]
                  • Set ER_Counter[ER_CurrentIndex] = ER_Counter[ER_MaxIndex]
                  • Set ER_Counter2[ER_CurrentIndex] = ER_Counter2[ER_MaxIndex]
                  • Set ER_Level[ER_CurrentIndex] = ER_Level[ER_MaxIndex]
                  • Set ER_MaxIndex = (ER_MaxIndex - 1)
                  • Set ER_CurrentIndex = (ER_CurrentIndex - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ER_MaxIndex Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
                  • -------- Every second until the last wave number is reached, a stream of stomps is created. --------
                  • For each (Integer ER_TempInt) from 1 to ER_StompNumber[ER_Level[ER_CurrentIndex]], do (Actions)
                    • Loop - Actions
                      • Set ER_SomePoint = (Position of ER_Caster[ER_CurrentIndex])
                      • Set ER_TempReal = (ER_TempReal + ER_StompIncrementDist[ER_Level[ER_CurrentIndex]])
                      • Set ER_TempPoint = (ER_SomePoint offset by ER_TempReal towards ER_Facing[ER_CurrentIndex] degrees)
                      • Special Effect - Create a special effect at ER_TempPoint using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Set ER_AoE = ER_StompAoE[ER_Level[ER_CurrentIndex]]
                      • Set ER_DummyGroup = (Units within ER_AoE of ER_TempPoint matching (((Matching unit) belongs to an enemy of ER_ControlPlayer[ER_CurrentIndex]) Equal to True))
                      • Unit Group - Pick every unit in ER_DummyGroup and do (Actions)
                        • Loop - Actions
                          • Game - Display to (All players) the text: (String((Unit-type of (Picked unit))))
                          • Unit - Cause ER_Caster[ER_CurrentIndex] to damage (Picked unit), dealing ER_StompDamage[ER_Level[ER_CurrentIndex]] damage of attack type Chaos and damage type Divine
                      • Custom script: call RemoveLocation(udg_ER_TempPoint)
                      • Custom script: call RemoveLocation(udg_ER_DummyPoint)
                      • Custom script: call RemoveLocation(udg_ER_SomePoint)
                      • Custom script: call DestroyGroup(udg_ER_DummyGroup)
              • Set ER_TempReal = 0.00
              • Set ER_Counter[ER_CurrentIndex] = 0
              • Set ER_Counter2[ER_CurrentIndex] = (ER_Counter2[ER_CurrentIndex] + 1)
        • Else - Actions
 
Last edited:
Level 20
Joined
Apr 14, 2012
Messages
2,901
I am sure it is self harm, as both enemy units and the caster are affected. Although I made in the trigger such that it only affects enemies of the controlling player.

I made it show a message. All seems to be in order. Though the damage to the caster caused by the spell is waaay smaller than it does on the normal units, so the caster barely dies, until the 5th or 6th casting.
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
By the lucky glance I saw this line:
  • Set ER_DummyGroup = (Units within ER_AoE of ER_TempPoint matching (((Matching unit) belongs to an enemy of ER_ControlPlayer[ER_Level[ER_CurrentIndex]]) Equal to True))
ER_ControlPlayer[ER_Level[ER_CurrentIndex]] ... well, now the caster isn't getting damaged, but his name still shows up in the Picked Unit list.

Oh well.

Edit:

Updated the loop trigger.

While on the topic, is there anything else leaking or fatally wrong with the code? I really wanna upload it... it has been two years since the initial review.
 
Hello MasterTrainer ! Off first glance, I'm a little concerned with how big your loop timer is. Is it set to 1? Here are some other things:

  • I see you removing a location at the very top of the loop, but I never see it being used. If ER_SomePoint is used on Cast, just remove it there and not periodically in the loop
    • Custom script: call RemoveLocation(udg_ER_SomePoint)
  • Is this a channel spell? If so, instead of checking to see if the caster is stunned or sleeping, you can just check if their current order ID matches the order ID of the channel spell
    • (Current order of ER_Caster[ER_CurrentIndex]) Not equal to (Order(channel))
  • I really recommend not using unit groups like this. It makes it extremely hard and tedious to read your filters
    • Set ER_DummyGroup = (Units within ER_SpiralRangeDamage[ER_Level[ER_CurrentIndex]] of ER_Tempoffsetpoint matching (((Matching unit) belongs to an enemy of ER_ControlPlayer[ER_CurrentIndex]) Equal to True))
    • Unit Group - Pick every unit in ER_DummyGroup and do (Actions)
      • Loop - Actions
        • Unit - Cause ER_Caster[ER_CurrentIndex] to damage (Picked unit), dealing ER_SpireDamage[ER_Level[ER_CurrentIndex]] damage of attack type Normal and damage type Normal
    Instead, just filter things out like this:
    • Set ER_DummyGroup = (Units withn ER_SpiralRangeDamage[ER_Level[ER_CurrentIndex]] of ER_Tempoffsetpoint)
    • Unit Group - Pick every unit in ER_DummyGroup and do (Actions)
      • Loop - Actions
        • Set tempUnit = (Picked unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (tempUnit is alive) Equal to True
            • (tempUnit belongs to an enemy of ER_ControlPlayer[ER_CurrentIndex]) Equal to True
            • (tempUnit is Magic Immune) Equal to False
            • (tempUnit is A structure) Equal to False
          • Then - Actions
            • -------- deal damage --------
          • Else - Actions
            • -------- unit did not match filters, do nothing --------
    • Custom script: call RemoveLocation(udg_ER_Tempoffsetpoint)
    • Custom script: call DestroyGroup(udg_ER_DummyGroup)
    You can even go as far as saving yourself a variable and using bj_wantDestroyGroup for this unit group since you're immediately destroying it right after creating it.

  • Remember to get rid of this debug message before you upload it!
    • Game - Display to (All players) the text: (String((Unit-type of (Picked unit))))
  • You should always put (Picked unit) into a variable
  • Make attack type and damage type configurable
 
Status
Not open for further replies.
Top