- Joined
- Apr 4, 2011
- Messages
- 995
Deceive
BackgroundThis Spell is a representation of what i believe makes an Assassin an Assassin. His/her ability to deceive the enemy to get close enough to make the killing blow. The best Assassin is the one you least expect, one of your own. That is what my ability portrays, Disguising oneself as the enemy to take down your target. [r] [c][c]
Hashtable
Events
Map initialization
Conditions
Actions
-------- ------------------------------------------------------------------------------ --------
-------- Creates a Hashtable and sets a variable to it --------
-------- ------------------------------------------------------------------------------ --------
Hashtable - Create a hashtable
Set Deceive_HashTable = (Last created hashtable)
-------- ------------------------------------------------------------------------------ --------
Deceive Break
Events
Unit - A unit Is attacked
Conditions
((Attacking unit) has buff Decieve ) Equal to True
((Triggering unit) is A Hero) Equal to False
(Level of (Triggering unit)) Less than 5
((Triggering unit) is Mechanical) Equal to False
Actions
-------- -------------------------------------------------------------------- --------
-------- After the spell is cast, and a unit is attacked. --------
-------- -------------------------------------------------------------------- --------
-------- Setting the Point for the Dummy Unit --------
Set Guise_Controller_Point = (Position of (Triggering unit))
-------- Creating a dummy unit and changing its speed so it doesn't lose pace with the target --------
Unit - Create 1 Unit Controller for (Owner of (Attacking unit)) at Guise_Controller_Point facing Default building facing degrees
Unit - Set (Last created unit) movement speed to (Default movement speed of (Triggering unit))
-------- Removing the Assassin and selecting the dummy unit --------
Unit - Remove (Attacking unit) from the game
Selection - Add (Last created unit) to selection
-------- Custom script that retreives the handle of the dummy unit created --------
Custom script: set udg_Deceive_Key = GetHandleId(bj_lastCreatedUnit)
-------- The dummy unit being added to the group, and then selected, and set to a variable. --------
Unit Group - Add (Last created unit) to Deceive_DummyGroup
Unit Group - Pick every unit in Deceive_DummyGroup and do (Actions)
Loop - Actions
Set Deceive_Dummy = (Picked unit)
-------- Saving the target unit for later use --------
Hashtable - Save Handle Of(Triggering unit) as 0 of Deceive_Key in Deceive_HashTable
-------- Cleaning up the Location Leak --------
Custom script: call RemoveLocation(udg_Guise_Controller_Point)
-------- -------------------------------------------------------------------- --------
-------- -------------------------------------------------------------------- --------
Controller Move
Events
Unit - A unit Is issued an order targeting a point
Conditions
(Triggering unit) Equal to Deceive_Dummy
Actions
-------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- When you select to move with the Dummy Unit this trigger orders the Target Unit to move to that same spot --------
-------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- A Temporary location is set so that it does not leak --------
Set Deceive_Temploc = (Target point of issued order)
-------- Ordering the Target Unit defined in the hashtable to move to the location moved to by the Dummy Unit --------
Unit - Order (Load 0 of Deceive_Key in Deceive_HashTable) to Move To Deceive_Temploc
-------- Cleaning up the Location Leak --------
Custom script: call RemoveLocation(udg_Deceive_Temploc)
-------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
Assassinate Cast
Events
Unit - A unit Is attacked
Conditions
(Attacking unit) Equal to Deceive_Dummy
Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
-------- After attacking an enemy with the Dummy Unit, this will order the Target Unit to attack aswell as stopping the Dummy Unit from doing any damage --------
-------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
-------- The Stop Order to the Dummy Unit --------
Unit - Order (Attacking unit) to Stop
-------- The Attack order to the Target Unit --------
Unit - Order (Load 0 of Deceive_Key in Deceive_HashTable) to Attack (Triggering unit)
-------- A Boolean to ensure the attack command was made by the caster of Deceive, and not of the command from the enemy --------
Hashtable - Save True as 1 of Deceive_Key in Deceive_HashTable
-------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
-------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
Assassinate Damage
Events
Unit - A unit Is attacked
Conditions
(Attacking unit) Equal to (Load 0 of Deceive_Key in Deceive_HashTable)
(Load 1 of Deceive_Key from Deceive_HashTable) Equal to True
Actions
-------- -------------------------------------------------------------------------------- --------
-------- The damage calculations to the Assassinated unit. --------
-------- -------------------------------------------------------------------------------- --------
-------- Setting a Temporary Location, and the facing angles of the two units. --------
Set Deceive_Temploc2 = (Position of (Attacking unit))
Set Assassinate_AngleOfAttack = (Facing of (Attacking unit))
Set Assassinate_AngleOfAttacked = (Facing of (Triggering unit))
-------- Checking if the unit is facing away from the other unit --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Assassinate_AngleOfAttacked - Assassinate_AngleOfAttack) Less than or equal to 90.00
(Assassinate_AngleOfAttacked - Assassinate_AngleOfAttack) Greater than or equal to 270.00
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) is A Hero) Equal to True
Then - Actions
-------- Edit Full damage to heroes --------
Unit - Cause Deceive_Dummy to damage (Triggering unit), dealing 300.00 damage of attack type Normal and damage type Normal
Else - Actions
-------- Edit Kill or Full Damage to units --------
Unit - Kill (Triggering unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) is A Hero) Equal to True
Then - Actions
-------- Edit Half Damage to heroes --------
Unit - Cause Deceive_Dummy to damage (Triggering unit), dealing 100.00 damage of attack type Normal and damage type Normal
Else - Actions
-------- Edit Half Damage to units --------
Unit - Cause Deceive_Dummy to damage (Triggering unit), dealing 300.00 damage of attack type Normal and damage type Normal
-------- ---------------------------------------------------- --------
-------- The Assassin returns to the map --------
-------- ---------------------------------------------------- --------
Unit - Create 1 Assassin for (Owner of Deceive_Dummy) at Deceive_Temploc2 facing Default building facing degrees
Unit - Remove (Attacking unit) from the game
Unit - Remove Deceive_Dummy from the game
Unit - Remove Deceive from (Last created unit)
-------- Adding a Dummy Spell --------
Unit - Add Deceive [Unuseable] to (Last created unit)
Hashtable - Save Handle Of(Last created unit) as 2 of Deceive_Key in Deceive_HashTable
-------- Edit Duration of Out Of Combat timer --------
Set Deceive_OutOfCombat = 5.00
Hashtable - Save Deceive_OutOfCombat as 3 of Deceive_Key in Deceive_HashTable
Trigger - Turn on Out Of Combat Timer <gen>
-------- Cleaning up Location Leaks --------
Custom script: call RemoveLocation(udg_Deceive_Temploc2)
-------- ---------------------------------------------------- --------
-------- ---------------------------------------------------- --------
Out Of Combat Timer
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
-------- --------------------------------------------------------------------------------------------- --------
-------- The timer for the Assassin to be able to cast Deceive again --------
-------- --------------------------------------------------------------------------------------------- --------
Set Deceive_OutOfCombat = (Load 3 of Deceive_Key from Deceive_HashTable)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Deceive_OutOfCombat Greater than 0.00
Then - Actions
-------- Counting down on the timer --------
Hashtable - Save (Deceive_OutOfCombat - 0.03) as 3 of Deceive_Key in Deceive_HashTable
Else - Actions
-------- Replacing the Dummy Spell with the Real Spell --------
Unit - Remove Deceive [Unuseable] from (Load 2 of Deceive_Key in Deceive_HashTable)
Unit - Add Deceive to (Load 2 of Deceive_Key in Deceive_HashTable)
-------- --------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------- --------
In Combat Reset
Events
Unit - A unit Is attacked
Conditions
(Triggering unit) Equal to (Load 2 of Deceive_Key in Deceive_HashTable)
Actions
-------- ------------------------------------------------------------------------------ --------
-------- Reseting the Out Of Combat Timer when attacked --------
-------- ------------------------------------------------------------------------------ --------
-------- Edit Duration of Out Of Combat Reset --------
Set Deceive_OutOfCombat = 5.00
Hashtable - Save Deceive_OutOfCombat as 3 of Deceive_Key in Deceive_HashTable
-------- ------------------------------------------------------------------------------ --------
-------- ------------------------------------------------------------------------------ --------
Credits to: Defskull and spartipilo for helping me out with Hashtables, Thanks!
Now that it's readable, here are the problems.
You rely on A Unit Is Attacked. That is a terrible event as it is abusable.
You have a lot of times you could store units into variables to make calling them far more efficient
You also have 4 "A Unit Is Attacked" events. Combine them into one using if/then/else statements, because every single time any unit in your map is bieng attacked it will run 4 different checks when it should run a single check. Also make sure you turn that event on and off, same with the loop.