- Joined
- Jan 5, 2009
- Messages
- 1,126
Note: This method may be inefficient but will possibly work.
Using X, Y co-ordinates is better than locations, as they do not leak and are faster.
They do not use as much memory as a location.
First Create a Hashtable Variable and call it CRSHash.
Now Create a Point Variable and call that Temp_CRSPoint
The Hashtable will be used to store the X, Y. And the point will get us the X, Y of the units.
Ok.
Here is the trigger that will get us the X, Y.
The Old values of the unit are cleared.
And the new ones stored!
I have added a test Map. I made it myself.
~Crazed_seal
Your friendly Crazed Seal!
Creep Respawn System Using Hashtable and X, Y
By Crazed_seal
How this Works
This Works by saving all the creeps co-ordinates(X, Y) into a hashtable.Using X, Y co-ordinates is better than locations, as they do not leak and are faster.
They do not use as much memory as a location.
HashTable Init
First Create a Hashtable Variable and call it CRSHash.
Now Create a Point Variable and call that Temp_CRSPoint
The Hashtable will be used to store the X, Y. And the point will get us the X, Y of the units.
Trigger One
Ok.
Here is the trigger that will get us the X, Y.
-
Save
-

Events
-


Time - Elapsed game time is 0.01 seconds
-
-

Conditions
-

Actions
-


Custom script: set bj_wantDestroyGroup = true
-


-------- Cleans some Group Leaks. Very Useful for temporary Groups. --------
-


Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
-



Loop - Actions
-




Set Temp_CRSPoint = (Position of (Picked unit))
-




-------- Gets the Point of the Unit --------
-




Hashtable - Save (X of Temp_CRSPoint) as (Key (Picked unit)) of 0 in CRSHash
-




-------- Saves the X of the Unit --------
-




Hashtable - Save (Y of Temp_CRSPoint) as (Key (Picked unit)) of 1 in CRSHash
-




-------- Saves the Y of the Unit --------
-




Custom script: call RemoveLocation(udg_Temp_CRSPoint)
-




-------- Removes the Location to stop leaks. --------
-
-
-
-
Revival
Time to make the revival Trigger.-
Revival
-

Events
-


Unit - A unit Dies
-
-

Conditions
-


(Owner of (Triggering unit)) Equal to Neutral Hostile
-
-

Actions
-


Wait 15.00 seconds
-


-------- Don't want them to instantly revive. --------
-


Set Temp_CRSPoint = (Point((Load (Key (Triggering unit)) of 0 from CRSHash), (Load (Key (Triggering unit)) of 1 from CRSHash)))
-


-------- Converts XY to Point --------
-


Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at Temp_CRSPoint facing (Random angle) degrees
-


-------- Creates Replacement Unit at XY --------
-


Custom script: call RemoveLocation(udg_Temp_CRSPoint)
-


-------- Removes Point --------
-


Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in CRSHash
-


-------- Clears Old Values of old unit. --------
-


Set Temp_CRSPoint = (Position of (Last created unit))
-


-------- Saves the units point --------
-


Hashtable - Save (X of Temp_CRSPoint) as (Key (Last created unit)) of 0 in CRSHash
-


-------- Grabs the X of units point --------
-


Hashtable - Save (Y of Temp_CRSPoint) as (Key (Last created unit)) of 1 in CRSHash
-


-------- Grabs the Y of units point --------
-


Custom script: call RemoveLocation(udg_Temp_CRSPoint)
-


-------- Removes the Point only leaving the XY Values stored in the Hashtable --------
-
-
The Old values of the unit are cleared.
And the new ones stored!
End
Hopefully you like this tutorial!I have added a test Map. I made it myself.
~Crazed_seal
Your friendly Crazed Seal!






