• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Spell Doesn't Deal Damage

Status
Not open for further replies.
Level 6
Joined
Dec 6, 2009
Messages
168
Hello! I have 2 questions. Why doesn't my spell deal damage to every unit? And does it leak?

Here are the triggers:

  • Stone Throw
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Stone Throw
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SH_Size Equal to 0
        • Then - Actions
          • Trigger - Turn on Stone Throw Loop <gen>
        • Else - Actions
      • Set SH_Size = (SH_Size + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SH_Size Greater than SH_MaxSize
        • Then - Actions
          • Set SH_Index[SH_Size] = SH_Size
          • Set SH_MaxSize = SH_Size
        • Else - Actions
      • Set TempInt = SH_Index[SH_Size]
      • Set TempLoc = (Position of (Triggering unit))
      • Set TempLoc2 = (Target point of ability being cast)
      • Set SH_Caster[TempInt] = (Triggering unit)
      • Unit - Create 1 SH_Dummy for (Owner of SH_Caster[TempInt]) at (Position of SH_Caster[TempInt]) facing (Angle from TempLoc to TempLoc2) degrees
      • Set SH_Dummy[TempInt] = (Last created unit)
      • Set SH_Angle[TempInt] = (Angle from TempLoc to TempLoc2)
      • Set SH_Dur[TempInt] = 5.00
      • Set SH_Damage[TempInt] = ((Real((Level of Stone Throw for SH_Caster[TempInt]))) x 200.00)
      • Set SH_Speed[TempInt] = 10.00
      • Set SH_AOE[TempInt] = 200.00
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
Loop:

  • Stone Throw Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SH_Loop) from 1 to SH_Size, do (Actions)
        • Loop - Actions
          • Set TempInt = SH_Index[SH_Loop]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SH_Dur[TempInt] Greater than 0.00
            • Then - Actions
              • Set TempLoc = ((Position of SH_Dummy[TempInt]) offset by SH_Speed[TempInt] towards SH_Angle[TempInt] degrees)
              • Unit - Move SH_Dummy[TempInt] instantly to TempLoc, facing SH_Angle[TempInt] degrees
              • Special Effect - Create a special effect at TempLoc using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at TempLoc of type Walkability is off) Equal to True
                • Then - Actions
                  • Unit Group - Pick every unit in (Units within SH_AOE[TempInt] of TempLoc) and do (Actions)
                    • Loop - Actions
                      • Set SH_TempUnit[TempInt] = (Picked unit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (SH_TempUnit[TempInt] belongs to an enemy of (Owner of SH_Caster[TempInt])) Equal to True
                          • (SH_TempUnit[TempInt] is alive) Equal to True
                          • (SH_TempUnit[TempInt] is A structure) Equal to False
                          • (SH_TempUnit[TempInt] is A flying unit) Equal to False
                        • Then - Actions
                          • Unit - Cause SH_Caster[TempInt] to damage SH_TempUnit[TempInt], dealing SH_Damage[TempInt] damage of attack type Chaos and damage type Normal
                        • Else - Actions
                  • Set SH_Dur[TempInt] = 0.00
                • Else - Actions
              • Custom script: set bj_wantDestroyGroup=true
              • Unit Group - Pick every unit in (Units within SH_AOE[TempInt] of TempLoc) and do (Actions)
                • Loop - Actions
                  • Set SH_TempUnit[TempInt] = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (SH_TempUnit[TempInt] belongs to an enemy of (Owner of SH_Caster[TempInt])) Equal to True
                      • (SH_TempUnit[TempInt] is alive) Equal to True
                      • (SH_TempUnit[TempInt] is A structure) Equal to False
                      • (SH_TempUnit[TempInt] is A flying unit) Equal to False
                    • Then - Actions
                      • Unit - Cause SH_Caster[TempInt] to damage SH_TempUnit[TempInt], dealing SH_Damage[TempInt] damage of attack type Chaos and damage type Normal
                      • Set SH_Dur[TempInt] = 0.00
                    • Else - Actions
              • Set SH_Dur[TempInt] = (SH_Dur[TempInt] - 0.03)
              • Custom script: call RemoveLocation(udg_TempLoc)
            • Else - Actions
              • Unit - Kill SH_Dummy[TempInt]
              • Set SH_Index[SH_Loop] = SH_Index[SH_Size]
              • Set SH_Index[SH_Size] = TempInt
              • Set SH_Size = (SH_Size - 1)
              • Set SH_Loop = (SH_Loop - 1)
              • -------- Turn the trigger again off if the index_size is below 0... --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SH_Size Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                  • Skip remaining actions
                • Else - Actions
  • Unit - Cause SH_Caster[TempInt] to damage SH_TempUnit[TempInt], dealing SH_Damage[TempInt] damage of attack type Chaos and damage type Normal
This should deal damage to every unit withing 200 range but it only does damage to the closest unit, unless they are all around the caster, then it deals damage within a 200 aoe.

Thanks!
 
Level 6
Joined
Dec 6, 2009
Messages
168
yes, but if I increase it the missile will end sooner aswell, and it still doesn't deal dmg to more than 1 target.

apparently this worked but I feel like it's very ineffecient and do I have to put
  • Custom script: set bj_wantDestroyGroup=true
everytime I use the Pick every unit trigger?

  • Unit Group - Pick every unit in (Units within SH_AOE[TempInt] of TempLoc) and do (Actions)
    • Loop - Actions
      • Set SH_TempUnit[TempInt] = (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SH_TempUnit[TempInt] belongs to an enemy of (Owner of SH_Caster[TempInt])) Equal to True
          • (SH_TempUnit[TempInt] is alive) Equal to True
          • (SH_TempUnit[TempInt] is A structure) Equal to False
          • (SH_TempUnit[TempInt] is A flying unit) Equal to False
        • Then - Actions
          • Set SH_Dur[TempInt] = 0.00
          • Custom script: set bj_wantDestroyGroup=true
          • Unit Group - Pick every unit in (Units within 500.00 of TempLoc) and do (Actions)
            • Loop - Actions
              • Set SH_TempUnit[TempInt] = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SH_TempUnit[TempInt] belongs to an enemy of (Owner of SH_Caster[TempInt])) Equal to True
                  • (SH_TempUnit[TempInt] is alive) Equal to True
                  • (SH_TempUnit[TempInt] is A structure) Equal to False
                  • (SH_TempUnit[TempInt] is A flying unit) Equal to False
                • Then - Actions
                  • Unit - Cause SH_Caster[TempInt] to damage SH_TempUnit[TempInt], dealing SH_Damage[TempInt] damage of attack type Chaos and damage type Normal
                • Else - Actions
        • Else - Actions
 
Last edited by a moderator:
Level 29
Joined
Oct 24, 2012
Messages
6,543
This is not needed.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • SH_Size Greater than SH_MaxSize
  • Then - Actions
  • Set SH_Index[SH_Size] = SH_Size
  • Set SH_MaxSize = SH_Size
  • Else - Actions
You leak locations and unit groups.

Your de-indexing should be in your then block not in the else block.

As for no damage display game messages to see if the damage is running.
If it is displaying then one of your variables is bad.
If it is not then move the messages to see where the trigger stops running at.
 
Level 13
Joined
Dec 21, 2010
Messages
541
You really need to learn how to use matching units when using unit group.. this will help you reduce conditions..and why do u still use TempInt when you're using SH_Loop
  • ?
    • Actions
      • For each (Integer SH_Loop) from 1 to SH_Size, do (Actions)
        • Loop - Actions

  • Unit Groups
    • Actions
      • Set TempLoc[0] = (Position of SH_Dummy[SH_Loop])
      • Set TempLoc[1] = (TempLoc[0] offset by SH_Speed[SH_Loop] towards SH_Angle[SH_Loop] degrees)
      • Set Group[SH_Loop] = (Units within 500 of TempLoc[1] matching (((((Matching unit) is A structure) Not equal to True) and Matching unit) is Magic Immune) Not equal to True)) and ((((Matching unit is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of SH_Caster[SH_Loop])) Equal to True))
      • Unit Group - Pick every unit in Group[SH_Loop] and do (Actions)
        • Loop - Actions
          • Unit - Cause SH_Caster[SH_Loop] to damage SH_TempUnit[SH_Loop], dealing SH_Damage[SH_Loop] damage of attack type Chaos and damage type Normal
      • Custom script: call DestroyGroup (udg_Group[udg_SH_Loop])
      • Custom script: call RemoveLocation (udg_TempLoc[0])
      • Custom script: call RemoveLocation (udg_TempLoc[1])


*edit Temploc and hidden tag
 
Last edited:
Level 13
Joined
Dec 21, 2010
Messages
541
  • Set TempLoc = ((Position of SH_Dummy[SH_Loop]) offset by SH_Speed[SH_Loop] towards SH_Angle[SH_Loop] degrees)

Position of is one point and the offset point is aother, so you leak here.

Oh yeah ... I didn't noticed that he created an offset xD


@Venger07

Using matching unit is inefficient compared to using conditions. It is also a lot harder to read.

Use hidden tags when stretching the page. thanks.

..ok maybe it's upto the spell maker.. but I use matching units to shorten my triggers..
 
Status
Not open for further replies.
Top