- Joined
- Mar 10, 2009
- Messages
- 5,016
How would you like to have One Stackable Hash on your map?, well try this...
instead of using ID of your caster/target, thus if used again it'll overwrite the previous...it gets a unique ID...
instead of destroying timers, use a recyable unitID...
this is an alternate to normal hashing and easy to use...
For GUI and JASS (no vJass) users...
Demo:
BTW: I may need testers on this, thanks!
EDIT: I should have posted this into the snippet section XD...
instead of using ID of your caster/target, thus if used again it'll overwrite the previous...it gets a unique ID...
instead of destroying timers, use a recyable unitID...
this is an alternate to normal hashing and easy to use...
For GUI and JASS (no vJass) users...
JASS:
//OneHashtable!
//by Mckill2009
//How this works:
//- Works by taking the ID of a unit from the Group and recycles it after
//- This was heavily inspired by my MuiDummyCasters snippet
//Required Variables:
//- FOG_Hash (hashtable)
//- FOG_TakeGroup (group)
//Instructions:
//- Just copy and paste this code to your map header
function FOG_RecycleDummy takes unit dummy, group g returns nothing
call GroupRemoveUnit(g, dummy)
call GroupAddUnit(udg_FOG_TakeGroup, dummy)
call FlushChildHashtable(udg_FOG_Hash, GetHandleId(dummy))
endfunction
function FOG_TakeDummy takes group g returns integer
local integer ID
local unit dummy
if FirstOfGroup(udg_FOG_TakeGroup)== null then
call BJDebugMsg("dummy created") //for testing purposes only
//========================================================
set dummy = CreateUnit(Player(15), 'hpea', 0, 0, 0)
call ShowUnit(dummy, false)
call UnitAddAbility(dummy, 'Aloc')
call PauseUnit(dummy, true)
else
//if group is not empty then it will pick the first dummy in the group
set dummy = FirstOfGroup(udg_FOG_TakeGroup)
call GroupRemoveUnit(udg_FOG_TakeGroup, dummy)
endif
call GroupAddUnit(g, dummy)
set ID = GetHandleId(dummy)
set dummy = null
return ID
endfunction
Demo:
-
OneHash
-
Events
- Player - Player 1 (Red) Selects a unit
- Conditions
-
Actions
- Custom script: set udg_ID = FOG_TakeDummy(udg_Grp1)
- Set Loc = (Position of (Triggering unit))
- Unit - Create 1 Footman for (Triggering player) at Loc facing Default building facing degrees
- Set Dummy = (Last created unit)
- Custom script: call RemoveLocation(udg_Loc)
- Hashtable - Save 10.00 as 1 of ID in FOG_Hash
- Hashtable - Save Handle OfDummy as 2 of ID in FOG_Hash
- Set Index = (Index + 1)
- Trigger - Turn on OneHashLooper <gen>
-
Events
-
OneHashLooper
-
Events
- Time - Every 1.00 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in Grp1 and do (Actions)
-
Loop - Actions
- Set ID = (Key (Picked unit))
- Set Timer = (Load 1 of ID from FOG_Hash)
- Set Dummy = (Load 2 of ID in FOG_Hash)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Timer Greater than 0.00
-
Then - Actions
- Hashtable - Save (Timer - 1.00) as 1 of ID in FOG_Hash
- Floating Text - Create floating text that reads (String(Timer)) above Dummy with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
- Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
-
Else - Actions
- Unit - Kill Dummy
- Custom script: call FOG_RecycleDummy(GetEnumUnit(), udg_Grp1)
- Set Index = (Index - 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Index Equal to 0
-
Then - Actions
- Game - Display to (All players) the text: TRIG OFF
- Game - Display to (All players) the text: (String(Index))
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
-
If - Conditions
-
Loop - Actions
-
Unit Group - Pick every unit in Grp1 and do (Actions)
-
Events
BTW: I may need testers on this, thanks!
EDIT: I should have posted this into the snippet section XD...
Attachments
Last edited: