I'm just wondering if there's a tutorial or example out there. I searched the following sections...(with word hashtable)
http://war3.incgamers.com/forums/forumdisplay.php?f=40 's
"General"
"Basic"
"Advanced"
Also, is the 0 of 0 the location inside the hash?
I'm really just looking for how to grab timer/board handles. If you guys have better suggestions I'm interested too. I looked at the dota example he's got some pick every player and player grouping going on, which really adds too much to my editor currently.|||So, I'm a little daft & found out the timer window variable is just a pointer, not a storage location for the actual data...too simple.
Still looking for information on the hashtables - what do you guys use them for & why does google show that only 2 people on the internet remotely know what to do with them (and willing to talk about it)?|||I am currently working with hastables, and tell you they are a very powerful tool for indexing as you can think of the map.
I designed such a spell that is running in multiple instances, like the knockback but in this case the unit is moved in the direction spellcasting front cutting everything in its path. for this use a timer that is stored in the hash table. the event which serves to collect the id of the timer is GetExpiredTimer () and the script works like this: (note that hashtables do not use locally, defined as global variables is better, since its are re-usable)
first create the global variable hashtable called "cache" and later make the hastable in your initialize trigger
this in gui mode
hashtable-create hashtable
set cache = lastcreatedhashtable
later define the script
Code:
function Silverslash_move takes nothing returns nothing
local timer ti = GetExpiredTimer()
local unit u = LoadUnitHandleBJ(StringHashBJ("caster"),GetHandleIdBJ(ti), udg_cache)
local real inc = LoadRealBJ(StringHashBJ("inc"),GetHandleIdBJ(ti), udg_cache)
local real ang = LoadRealBJ(StringHashBJ("angle"),GetHandleIdBJ(ti), udg_cache)
local location p = GetUnitLoc(u)
local location p1 = PolarProjectionBJ(p, inc, ang)
set inc = ( inc - 1 )
set p = GetUnitLoc(u)
call SetUnitPathing( u, false )
call SetUnitPositionLoc( u, p1 )
call RemoveLocation(p)
call RemoveLocation(p1)
call SaveRealBJ(inc, StringHashBJ("inc"), GetHandleIdBJ(ti), udg_cache )
set u = null
endfunction
function Trig_silverslashX_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A06H' ) ) then
return false
endif
return true
endfunction
function Trig_silverslashX_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local real inc = 30.00
local real ang = GetUnitFacing(u)
local timer te = CreateTimer()
local location p = GetUnitLoc(u)
call SaveUnitHandleBJ(u, StringHashBJ("caster"), GetHandleIdBJ(te), udg_cache )
call SaveRealBJ(inc, StringHashBJ("inc"), GetHandleIdBJ(te), udg_cache )
call SaveRealBJ(ang, StringHashBJ("angle"), GetHandleIdBJ(te), udg_cache )
call SaveLocationHandleBJ(p, StringHashBJ("p"), GetHandleIdBJ(te), udg_cache )
call TriggerSleepAction( 0.04 )
call UnitAddAbilityBJ( 'A06J', u )
call SetUnitAnimation( u, "Attack" )
call TimerStart(te, 0.02, true, function Silverslash_move)
call PolledWait(0.4)
call UnitRemoveAbilityBJ( 'A06J', u )
call SetUnitPathing( u, true )
call FlushChildHashtableBJ(GetHandleIdBJ(te), udg_cache)
call DestroyTimer(te)
set u = null
set inc = 0
set ang = 0
call RemoveLocation(p)
endfunction
//===========================================================================
function InitTrig_silverslashX takes nothing returns nothing
set gg_trg_silverslashX = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_silverslashX, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_silverslashX, Condition( function Trig_silverslashX_Conditions ) )
call TriggerAddAction( gg_trg_silverslashX, function Trig_silverslashX_Actions )
endfunction
voila, this work nice (note, the spell desing dont consider terrain patchability and the move orders are very basic, only its a basic example of stored timers in hashtables.)
the timer stored is the handle of the local timer called "te" in the actions function, this timer looping until the polledwait finish, later in each finish of the "te" success the expired timer event, here you can get the id of the timer with the native function GetExpiredTimer()
sorry for my english, i used a google translator.
No comments:
Post a Comment