I made a spell that picks a targeted enemy unit, spin it around with my hero and then the unit is thrown away. However, when a unit casts it the game lags heavily!
The Hero with this spell is Cairne Bloodhoof and he is on my test map (optimized).
Here is my spell trigger:
After the unit is thrown the lag dissipates.
The Hero with this spell is Cairne Bloodhoof and he is on my test map (optimized).
Here is my spell trigger:
Code:
Unit Throwing
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to (==) Unit Throwing (Cairne Bloodhoof)
Actions
Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
Set Caster_Cairne[PlayerNumber] = (Triggering unit)
Set Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] = (Target unit of ability being cast)
Unit - Pause Caster_Cairne[PlayerNumber]
Unit - Pause Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))]
Unit - Turn collision for Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] Off
Set Skill_UnitPos = (Position of (Triggering unit))
Set Temp_Point = (Skill_UnitPos offset by 100.00 towards -90.00 degrees)
Unit - Move Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] instantly to Temp_Point
Animation - Play Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))]'s death animation
Point - Remove Temp_Point
Point - Remove Skill_UnitPos
Animation - Play Caster_Cairne[PlayerNumber]'s stand, ready animation
Unit Group - Add Caster_Cairne[PlayerNumber] to Skill_UnitSpin
Unit Group - Add Target_Cairne[(Player number of (Owner of (Target unit of ability being cast)))] to Skill_UnitSpin
Trigger - Turn on Units Spin <gen>
Code:
Units Spin
Events
Time - Every 0.01 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in Skill_UnitSpin and do (Actions)
Loop - Actions
Set PlayerNumber = (Player number of (Owner of (Picked unit)))
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Skill_SpinAngle[PlayerNumber] Greater than or equal to (>=) 3780.00
Then - Actions
Unit - Unpause Caster_Cairne[PlayerNumber]
Animation - Play Caster_Cairne[PlayerNumber]'s attack, 1 animation
Unit Group - Remove Caster_Cairne[PlayerNumber] from Skill_UnitSpin
Set Skill_SpinAngle[PlayerNumber] = 0.00
Do Multiple ActionsFor each (Integer A) from 0 to 16, do (Actions)
Loop - Actions
Unit - Unpause Target_Cairne[(Integer A)]
Unit - Turn collision for Target_Cairne[(Integer A)] On
Set N[(Integer A)] = 0.00
Unit Group - Add Target_Cairne[(Integer A)] to Skill_Knockback
Animation - Play Caster_Cairne[PlayerNumber]'s spell, slam animation
Unit Group - Remove Target_Cairne[(Integer A)] from Skill_UnitSpin
Special Effect - Create a special effect attached to the origin of Caster_Cairne[PlayerNumber] using Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
Special Effect - Destroy (Last created special effect)
Set Temp_Point = (Position of Target_Cairne[(Integer A)])
Unit - Create 1 Dummy for (Owner of Target_Cairne[(Integer A)]) at Temp_Point facing Default building facing (270.0) degrees
Set Target_Cairne[(Integer A)] = (Last created unit)
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
Point - Remove Temp_Point
Trigger - Turn off (This trigger)
Else - Actions
Set Temp_UnitFacing = (Facing of (Picked unit))
Set Temp_Angle = (Temp_UnitFacing + 20.00)
Set Skill_SpinAngle[PlayerNumber] = (Skill_SpinAngle[PlayerNumber] + 20.00)
Animation - Play Caster_Cairne[PlayerNumber]'s stand, ready animation
Unit - Make Caster_Cairne[PlayerNumber] face Temp_Angle over 0.00 seconds
Set Skill_UnitPos = (Position of Caster_Cairne[PlayerNumber])
Set Temp_Point = (Skill_UnitPos offset by 150.00 towards (Temp_UnitFacing - 10.00) degrees)
Do Multiple ActionsFor each (Integer A) from 0 to 16, do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the chest of Target_Cairne[(Integer A)] using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Caster_Cairne[PlayerNumber] to damage Target_Cairne[(Integer A)], dealing (0.50 x (Real((Level of Unit Throwing (Cairne Bloodhoof) for Caster_Cairne[PlayerNumber])))) damage of attack type Normal and damage type Normal
Unit - Move Target_Cairne[(Integer A)] instantly to Temp_Point
Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
Loop - Actions
Destructible - Kill (Picked destructible)
Point - Remove Skill_UnitPos
Point - Remove Temp_Point
Code:
Knockback
Events
Time - Every 0.01 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in Skill_Knockback and do (Actions)
Loop - Actions
Set PlayerNumber = (Player number of (Owner of (Picked unit)))
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
N[PlayerNumber] Greater than or equal to (>=) 400.00
Then - Actions
Unit Group - Remove (Picked unit) from Skill_Knockback
Set N[PlayerNumber] = 0.00
Else - Actions
Set N[PlayerNumber] = (N[PlayerNumber] + 5.00)
Set Skill_UnitPos = (Position of (Picked unit))
Set Temp_Point = (Skill_UnitPos offset by 5.00 towards ((Facing of (Picked unit)) - 180.00) degrees)
Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
Special Effect - Destroy (Last created special effect)
Unit - Move (Picked unit) instantly to Temp_Point
Destructible - Pick every destructible within 300.00 of Temp_Point and do (Actions)
Loop - Actions
Destructible - Kill (Picked destructible)
Point - Remove Skill_UnitPos
Point - Remove Temp_Point
After the unit is thrown the lag dissipates.