[Spell] Is there anything wrong with 2 spells?

Level 16
Joined
Jul 19, 2007
Messages
942
I have 2 spells in my map that sometimes bugs the kill-credit. The first spell is a "Charge" ability and sometimes when using it and the caster dies during it, the kill-credit goes to the caster that it has killed itself :-/

  • Charge Init
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- ------------------------- --------
      • -------- Create hashtable for storing data --------
      • -------- ------------------------- --------
      • Hashtable - Create a hashtable
      • Set VariableSet EC_Hash = (Last created hashtable)
      • -------- ------------------------- --------
      • -------- Base damage --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[0] = 20.00
      • -------- ------------------------- --------
      • -------- Level bonus damage --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[1] = 55.00
      • -------- ------------------------- --------
      • -------- Initial speed of the charge --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[2] = 8.00
      • -------- ------------------------- --------
      • -------- Max speed of the charge --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[3] = 25.00
      • -------- ------------------------- --------
      • -------- Knockback range --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[4] = 192.00
      • -------- ------------------------- --------
      • -------- Knockback max speed --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[5] = 30.00
      • -------- ------------------------- --------
      • -------- Charge acceleration multiplier ( 1 = no acceleration) --------
      • -------- ------------------------- --------
      • Set VariableSet EC_Reals[6] = 1.20
      • -------- ------------------------- --------
  • Charge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charge
    • Actions
      • Set VariableSet Temp_Unit_1 = (Triggering unit)
      • Set VariableSet Temp_Loc_1 = (Position of Temp_Unit_1)
      • Set VariableSet Temp_Loc_2 = (Target point of ability being cast)
      • -------- ------------------------- --------
      • Unit - Turn collision for Temp_Unit_1 Off.
      • -------- ------------------------- --------
      • Set VariableSet Temp_Real_1 = (Distance between Temp_Loc_1 and Temp_Loc_2)
      • Set VariableSet Temp_Real_2 = (EC_Reals[0] + (EC_Reals[1] x (Real((Level of (Ability being cast) for Temp_Unit_1)))))
      • -------- ------------------------- --------
      • Special Effect - Create a special effect attached to the left foot of Temp_Unit_1 using Abilities\Weapons\Bolt\BoltImpact.mdl
      • Hashtable - Save Handle Of(Last created special effect) as (Key effect_1.) of (Key (Triggering unit).) in EC_Hash.
      • Special Effect - Create a special effect attached to the right foot of Temp_Unit_1 using Abilities\Weapons\Bolt\BoltImpact.mdl
      • Hashtable - Save Handle Of(Last created special effect) as (Key effect_2.) of (Key (Triggering unit).) in EC_Hash.
      • Special Effect - Create a special effect attached to the left hand of Temp_Unit_1 using Abilities\Weapons\Bolt\BoltImpact.mdl
      • Hashtable - Save Handle Of(Last created special effect) as (Key effect_3.) of (Key (Triggering unit).) in EC_Hash.
      • Special Effect - Create a special effect attached to the right hand of Temp_Unit_1 using Abilities\Weapons\Bolt\BoltImpact.mdl
      • Hashtable - Save Handle Of(Last created special effect) as (Key effect_4.) of (Key (Triggering unit).) in EC_Hash.
      • -------- ------------------------- --------
      • Hashtable - Save 0.00 as (Key distance.) of (Key (Triggering unit).) in EC_Hash.
      • Hashtable - Save EC_Reals[2] as (Key speed.) of (Key (Triggering unit).) in EC_Hash.
      • Hashtable - Save Temp_Real_2 as (Key damage.) of (Key (Triggering unit).) in EC_Hash.
      • Hashtable - Save Temp_Real_1 as (Key distance_max.) of (Key (Triggering unit).) in EC_Hash.
      • Hashtable - Save (Angle from Temp_Loc_1 to Temp_Loc_2) as (Key angle.) of (Key (Triggering unit).) in EC_Hash.
      • -------- ------------------------- --------
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
      • Custom script: call RemoveLocation(udg_Temp_Loc_2)
      • -------- ------------------------- --------
      • Unit Group - Add Temp_Unit_1 to EC_Group
      • -------- ------------------------- --------
      • Trigger - Turn on Charge Loop <gen>
  • Charge Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in EC_Group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in EC_Group and do (Actions)
            • Loop - Actions
              • Set VariableSet Temp_Unit_1 = (Picked unit)
              • Set VariableSet Temp_Real_1 = (Load (Key distance.) of (Key (Picked unit).) from EC_Hash.)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Unit_1 is alive) Equal to True
                  • Temp_Real_1 Less than (Load (Key distance_max.) of (Key (Picked unit).) from EC_Hash.)
                • Then - Actions
                  • Set VariableSet Temp_Loc_1 = (Position of Temp_Unit_1)
                  • -------- -------------------- --------
                  • Set VariableSet Temp_Real_2 = (Load (Key angle.) of (Key (Picked unit).) from EC_Hash.)
                  • Set VariableSet Temp_Real_3 = ((Load (Key speed.) of (Key (Picked unit).) from EC_Hash.) x EC_Reals[6])
                  • -------- -------------------- --------
                  • Set VariableSet Temp_Real_4 = ((X of Temp_Loc_1) + (Temp_Real_3 x (Cos(Temp_Real_2))))
                  • Set VariableSet Temp_Real_5 = ((Y of Temp_Loc_1) + (Temp_Real_3 x (Sin(Temp_Real_2))))
                  • -------- -------------------- --------
                  • Set VariableSet Temp_Loc_2 = (Point(Temp_Real_4, Temp_Real_5))
                  • -------- -------------------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain pathing at Temp_Loc_2 of type Walkability is off) Equal to False
                    • Then - Actions
                      • Custom script: call SetUnitX(udg_Temp_Unit_1, udg_Temp_Real_4)
                      • Custom script: call SetUnitY(udg_Temp_Unit_1, udg_Temp_Real_5)
                      • Set VariableSet Temp_Real_4 = (Distance between Temp_Loc_1 and Temp_Loc_2)
                    • Else - Actions
                      • Hashtable - Save Temp_Real_3 as (Key speed.) of (Key (Picked unit).) in EC_Hash.
                      • Set VariableSet Temp_Real_4 = 5000.00
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Temp_Real_3 Less than EC_Reals[5]
                    • Then - Actions
                      • Hashtable - Save Temp_Real_3 as (Key speed.) of (Key (Picked unit).) in EC_Hash.
                    • Else - Actions
                  • Hashtable - Save (Temp_Real_1 + Temp_Real_4) as (Key distance.) of (Key (Picked unit).) in EC_Hash.
                  • -------- -------------------- --------
                  • Set VariableSet Temp_Real_3 = (Load (Key damage.) of (Key (Picked unit).) from EC_Hash.)
                  • -------- -------------------- --------
                  • Set VariableSet Temp_Group_1 = (Units within EC_Reals[4] of Temp_Loc_2 matching ((((Matching unit) is alive) Equal to True) and (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is in Knockback_Group.) Equal to False)) and ((((Matching unit) is Magic Immune) Equal t
                  • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
                    • Loop - Actions
                      • Set VariableSet Temp_Real_1 = (Facing of Temp_Unit_1)
                      • Set VariableSet Temp_Unit_2 = (Picked unit)
                      • Set VariableSet Temp_Loc_3 = (Position of Temp_Unit_2)
                      • -------- -------------------- --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Cos((Temp_Real_1 - (Angle from Temp_Loc_2 to Temp_Loc_3)))) Greater than (Cos(90.00))
                        • Then - Actions
                          • Set VariableSet Temp_Real_1 = (Temp_Real_1 - 90.00)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Cos((Temp_Real_1 - (Angle from Temp_Loc_2 to Temp_Loc_3)))) Greater than (Cos(90.00))
                            • Then - Actions
                              • Set VariableSet Temp_Real_4 = -30.00
                            • Else - Actions
                              • Set VariableSet Temp_Real_4 = 30.00
                          • Special Effect - Create a special effect attached to the chest of Temp_Unit_2 using Abilities\Weapons\ChimaeraLightningMissile\ChimaeraLightningMissile.mdl
                          • Special Effect - Destroy (Last created special effect)
                          • Special Effect - Create a special effect attached to the origin of Temp_Unit_2 using Abilities\Spells\Other\Tornado\Tornado_Target.mdl
                          • -------- -------------------- --------
                          • Unit - Cause Temp_Unit_1 to damage Temp_Unit_2, dealing Temp_Real_3 damage of attack type Spells and damage type Magic
                          • -------- -------------------- --------
                          • Hashtable - Save 1.00 as (Key loop.) of (Key (Picked unit).) in Knockback_Hash.
                          • Hashtable - Save EC_Reals[5] as (Key speed.) of (Key (Picked unit).) in Knockback_Hash.
                          • Hashtable - Save Handle Of(Last created special effect) as (Key effect_1.) of (Key (Picked unit).) in Knockback_Hash.
                          • Hashtable - Save ((Angle from Temp_Loc_1 to Temp_Loc_2) + Temp_Real_4) as (Key angle.) of (Key (Picked unit).) in Knockback_Hash.
                          • -------- -------------------- --------
                          • Unit Group - Add Temp_Unit_2 to Knockback_Group
                          • -------- -------------------- --------
                          • Custom script: call RemoveLocation(udg_Temp_Loc_3)
                        • Else - Actions
                  • Trigger - Turn on Knockback <gen>
                  • Custom script: call DestroyGroup(udg_Temp_Group_1)
                  • Custom script: call RemoveLocation(udg_Temp_Loc_1)
                  • Custom script: call RemoveLocation(udg_Temp_Loc_2)
                • Else - Actions
                  • Special Effect - Destroy (Load (Key effect_1.) of (Key (Picked unit).) in EC_Hash.)
                  • Special Effect - Destroy (Load (Key effect_2.) of (Key (Picked unit).) in EC_Hash.)
                  • Special Effect - Destroy (Load (Key effect_3.) of (Key (Picked unit).) in EC_Hash.)
                  • Special Effect - Destroy (Load (Key effect_4.) of (Key (Picked unit).) in EC_Hash.)
                  • -------- -------------------- --------
                  • Unit - Turn collision for Temp_Unit_1 On.
                  • -------- -------------------- --------
                  • Unit Group - Remove Temp_Unit_1 from EC_Group.
                  • -------- -------------------- --------
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in EC_Hash.
                  • -------- -------------------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (EC_Group is empty) Equal to True
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
        • Else - Actions
The second spell is just a simple triggered "Stomp" ability but it seems to sometimes give the kill-credit to the Heroes that dies of this ability, like it has killed itself!

  • Reverse Polarity
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Reverse Polarity
    • Actions
      • Set VariableSet TempUnit = (Triggering unit)
      • Set VariableSet TempLoc = (Position of TempUnit)
      • Set VariableSet TempReal = (0.00 + (50.00 x (Real((Level of Reverse Polarity for TempUnit)))))
      • Set VariableSet TempReal2 = (Facing of TempUnit)
      • Set VariableSet RPGroup = (Units within 350.00 of TempLoc matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of TempUnit).) Equal to True))).)
      • Unit Group - Pick every unit in RPGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet TempUnit2 = (Picked unit)
          • Unit - Turn collision for TempUnit2 Off.
          • Set VariableSet TempLoc2 = (TempLoc offset by (Random real number between 120.00 and 170.00) towards TempReal2 degrees.)
          • Unit - Move TempUnit2 instantly to TempLoc2
          • Unit - Cause TempUnit to damage TempUnit2, dealing TempReal damage of attack type Spells and damage type Normal
          • Custom script: call RemoveLocation( udg_TempLoc2 )
      • Countdown Timer - Start RPTime as a One-shot timer that will expire in 0.00 seconds
      • Custom script: call RemoveLocation( udg_TempLoc )
  • Reverse Polarity off
    • Events
      • Time - RPTime expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RPGroup and do (Actions)
        • Loop - Actions
          • Unit - Turn collision for (Picked unit) On.
      • Custom script: call DestroyGroup( udg_RPGroup )
I'm starting to think that there might be something wrong with my kill-credit trigger that I didn't create by myself and I don't remember who helped me to make it.

  • Pwning Notice CHANGED
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is An Ancient) Not equal to True
      • ((Triggering unit) is an illusion) Not equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Killing unit)) Equal to Neutral Hostile
        • Then - Actions
          • Game - Display to (All players) the text: (|cFF000000Neutral Creeps|r + ( has just killed + ((ColorCodes[TempInt1] + ((Name of (Owner of (Triggering unit))) + |r)) + .)))
          • Set VariableSet unit = (Triggering unit)
          • Set VariableSet unit2 = (Killing unit)
          • Custom script: set udg_integer = GetHandleIdBJ( udg_unit )
          • Hashtable - Clear all child hashtables of child integer in HASHASSIST.
        • Else - Actions
          • Set VariableSet TempInt1 = (Player number of (Owner of (Triggering unit)))
          • Set VariableSet TempInt2 = (Player number of (Owner of (Killing unit)))
          • Set VariableSet PlayerConcecutiveDeath[TempInt1] = (PlayerConcecutiveDeath[TempInt1] + 1)
          • Set VariableSet PlayerConcecutiveDeath[TempInt2] = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PlayerConcecutiveDeath[TempInt1] Less than or equal to 2
            • Then - Actions
              • Set VariableSet Reward = 300
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PlayerConcecutiveDeath[TempInt1] Equal to 3
                • Then - Actions
                  • Set VariableSet Reward = 200
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • PlayerConcecutiveDeath[TempInt1] Equal to 4
                    • Then - Actions
                      • Set VariableSet Reward = 150
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • PlayerConcecutiveDeath[TempInt1] Greater than or equal to 5
                        • Then - Actions
                          • Set VariableSet Reward = 100
                        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Owner of (Killing unit)) Equal to Player 10 (Light Blue)
                  • (Owner of (Killing unit)) Equal to Player 12 (Brown)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Killing unit)) Equal to Player 12 (Brown)
                • Then - Actions
                  • Game - Display to (All players) the text: ((The |cffFF0000 + (Evil + |r)) + ( forces has just killed + ((ColorCodes[TempInt1] + ((Name of (Owner of (Triggering unit))) + |r)) + .)))
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Killing unit)) Equal to Player 10 (Light Blue)
                • Then - Actions
                  • Game - Display to (All players) the text: ((The |cff0080FF + (Good + |r)) + ( forces has just killed + ((ColorCodes[TempInt1] + ((Name of (Owner of (Triggering unit))) + |r)) + .)))
                • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: ((ColorCodes[TempInt2] + ((Name of (Owner of (Killing unit))) + |r)) + ( has just killed + ((ColorCodes[TempInt1] + ((Name of (Owner of (Triggering unit))) + |r)) + ( and gains + ((String(Reward)) + gold.)))))
          • Set VariableSet unit = (Triggering unit)
          • Set VariableSet unit2 = (Killing unit)
          • Custom script: set udg_integer = GetHandleIdBJ( udg_unit )
          • Custom script: set udg_integer2 = GetHandleIdBJ( udg_unit2 )
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (unit belongs to an enemy of (Owner of unit2).) Equal to True
            • Then - Actions
              • Set VariableSet player = (Owner of unit2)
              • Set VariableSet integer3 = 0
              • Trigger - Run REWARD FOR KILL <gen> (checking conditions)
              • Set VariableSet string2 = Assist:
              • For each (Integer LOOP) from 1 to 12, do (Actions)
                • Loop - Actions
                  • Set VariableSet player = (Player(LOOP))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (player is in player_force.) Not equal to True
                      • player Not equal to (Owner of unit)
                      • player Not equal to (Owner of (Killing unit))
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (unit belongs to an enemy of player.) Equal to True
                          • (Load LOOP of integer from HASHASSIST.) Greater than 0
                        • Then - Actions
                          • Set VariableSet integer3 = (integer3 + 1)
                          • Player Group - Add player to player_force
                          • Set VariableSet string2 = (string2 + ColorCodes[(Player number of player)])
                          • Set VariableSet string2 = (string2 + ((Name of player) + |r, ))
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (unit2 belongs to an enemy of player.) Not equal to True
                          • (Load LOOP of integer2 from HASHASSIST.) Greater than 0
                        • Then - Actions
                          • Set VariableSet integer3 = (integer3 + 1)
                          • Player Group - Add player to player_force
                          • Set VariableSet string2 = (string2 + ColorCodes[(Player number of player)])
                          • Set VariableSet string2 = (string2 + ((Name of player) + |r, ))
                        • Else - Actions
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • integer3 Greater than 0
                • Then - Actions
                  • Game - Display to (All players) the text: string2
                  • Trigger - Run REWARD FOR ASSIST <gen> (checking conditions)
                • Else - Actions
            • Else - Actions
          • Hashtable - Clear all child hashtables of child integer in HASHASSIST.
          • Set VariableSet unit = No unit
          • Set VariableSet unit2 = No unit
Please if someone has any idéa what could cause these kill-credit to be bugged then I would be happy...
 
Without taking a deeper look into the code, i assume that it is a global variable problem. Having globals as temp variables is dangerous, as they might be overwritten in other events or the event itself (if cast again by another unit). A solution to this problem would be dynamic indexing, or local variables.
  • Unit - Cause Temp_Unit_1 to damage Temp_Unit_2, dealing Temp_Real_3 damage of attack type Spells and damage type Magic
This line uses "Temp_Unit_1" and "Temp_Unit_2". Temp_Unit_2 is not an issue, as it is set before the function is called without an event being able to interfere. Temp_Unit_1 however, might be overwritten.
  • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
in the first iteration, Temp_Unit_1 should always be correct, but as soon as you damage a unit, you can fire an "on death event" or "damage event". If Temp_Unit_1 is used inside those event triggers, Temp_Unit_1 is no longer the caster for the second iteration.

The question is: Are those temp variables reused in other triggers? Can the ability be cast multiple times at the same time? If so, you would need to fix the code.
 
Last edited:
Without taking a deeper look into the code, i assume that it is a global variable problem. Having globals as temp variables is dangerous, as they might be overwritten in other events or the event itself (if cast again by another unit). A solution to this problem would be dynamic indexing, or local variables.
  • Unit - Cause Temp_Unit_1 to damage Temp_Unit_2, dealing Temp_Real_3 damage of attack type Spells and damage type Magic
This line uses "Temp_Unit_1" and "Temp_Unit_2". Temp_Unit_2 is not an issue, as it is set before the function is called without an event being able to interfere. Temp_Unit_1 however, might be overwritten.
  • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
in the first iteration, Temp_Unit_1 should always be correct, but as soon as you damage a unit, you can fire an "on death event" or "damage event". If Temp_Unit_1 is used inside those event triggers, Temp_Unit_1 is no longer the caster for the second iteration.

The question is: Are those temp variables reused in other triggers? Can the ability be cast multiple times at the same time? If so, you would need to fix the code.
Hmm. Well there is only 1 hero that got the "Charge" ability and only 1 hero that got the "Stomp" ability so they can't be overwritten... Maybe I could check if another triggered ability uses the same temp variables.
 
you should look for triggers with the event "Unit dies" or "Unit takes damage" that include Temp_Unit_1
I've searched on all triggers in my map but I don't find "Temp_Unit_1" in any triggers that has "Unit Dies" or "Unit takes damage"... Btw I found another triggered ability that has "Temp_Unit_1" in it.

  • War Stomp
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to War Stomp (Balrog)
    • Actions
      • Set VariableSet Temp_Unit_1 = (Triggering unit)
      • -------- -------------------- --------
      • Set VariableSet Temp_Loc_1 = (Position of Temp_Unit_1)
      • -------- -------------------- --------
      • -------- This is the initial damage of the spell --------
      • -------- -------------------- --------
      • Set VariableSet Temp_Real_1 = ((1.00 x (0.00 + (Real((Level of War Stomp (Balrog) for Temp_Unit_1))))) x (Real((Strength of Temp_Unit_1 (Include bonuses)))))
      • -------- -------------------- --------
      • -------- This is the damage over time of the spell --------
      • -------- -------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Knockback_DoT Equal to True
        • Then - Actions
          • Set VariableSet Temp_Real_2 = (1.00 x (Real((Level of War Stomp (Balrog) for Temp_Unit_1))))
        • Else - Actions
          • Set VariableSet Temp_Real_2 = 0.00
      • -------- -------------------- --------
      • -------- Pick all desired units near the caster --------
      • -------- -------------------- --------
      • Set VariableSet Temp_Group_1 = (Units within 400.00 of Temp_Loc_1 matching ((((Owner of (Matching unit)) is an enemy of (Owner of Temp_Unit_1).) Equal to True) and ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and (((Matching uni
      • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
        • Loop - Actions
          • Set VariableSet Temp_Unit_2 = (Picked unit)
          • Set VariableSet Temp_Loc_2 = (Position of Temp_Unit_2)
          • -------- -------------------- --------
          • -------- Deal initila damage --------
          • -------- -------------------- --------
          • Unit - Cause Temp_Unit_1 to damage Temp_Unit_2, dealing Temp_Real_1 damage of attack type Hero and damage type Normal
          • -------- -------------------- --------
          • -------- Calculate angle of knockback --------
          • -------- Temp_Loc_1 to Temp_Loc_2 = From caster to target = push --------
          • -------- Temp_Loc_2 to Temp_Loc_1 = From target to caster = pull --------
          • -------- -------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Knockback_Push Equal to True
            • Then - Actions
              • Set VariableSet Temp_Real_3 = (Angle from Temp_Loc_1 to Temp_Loc_2)
            • Else - Actions
              • Set VariableSet Temp_Real_3 = (Angle from Temp_Loc_2 to Temp_Loc_1)
          • -------- -------------------- --------
          • -------- Creates additional effect on units that are knocked back --------
          • -------- -------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Knockback_Effect Equal to True
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of Temp_Unit_2 using Abilities\Spells\Other\Tornado\Tornado_Target.mdl
              • Hashtable - Save Handle Of(Last created special effect) as (Key effect_1.) of (Key (Picked unit).) in Knockback_Hash.
            • Else - Actions
          • -------- -------------------- --------
          • -------- Add picked unit to knockback group --------
          • -------- -------------------- --------
          • Unit Group - Add Temp_Unit_2 to Knockback_Group
          • -------- -------------------- --------
          • -------- You don't need to save dmg or caster if you don't want to do any damage --------
          • -------- The other values are mandatory --------
          • -------- -------------------- --------
          • Hashtable - Save 0.00 as (Key loop.) of (Key (Picked unit).) in Knockback_Hash.
          • Hashtable - Save 0.00 as (Key offset.) of (Key (Picked unit).) in Knockback_Hash.
          • Hashtable - Save Temp_Real_2 as (Key dmg.) of (Key (Picked unit).) in Knockback_Hash.
          • Hashtable - Save Temp_Real_3 as (Key angle.) of (Key (Picked unit).) in Knockback_Hash.
          • Hashtable - Save Handle OfTemp_Unit_1 as (Key caster.) of (Key (Picked unit).) in Knockback_Hash.
          • -------- -------------------- --------
          • Custom script: call RemoveLocation(udg_Temp_Loc_2)
      • -------- -------------------- --------
      • Trigger - Turn on Knockback <gen>
      • -------- -------------------- --------
      • Custom script: call DestroyGroup(udg_Temp_Group_1)
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
 
Back
Top