- Joined
- Jan 11, 2009
- Messages
- 3,414
How does the hash table saving work?
I noticed when i tried using it that you wouldn't want to save two handles to the same integer value.
Here's the code i was doing:
This uses timerUtils, and isn't really complete yet i suppose. However, even though i changed the common.j and blizzard.j in the newgen folder, jasshelper says there's no such thing as a hash table (neither any of it's components).
First of all: What do i need to fix in this script?
And second: Is it possible to do this:
Or will i overwrite the first handle?
I noticed when i tried using it that you wouldn't want to save two handles to the same integer value.
Here's the code i was doing:
JASS:
function ChargeMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(hasht, 0, GetHandleId(t))
local location l3
local location l2 = LoadLocationHandle(hasht, 0, GetHandleId(t))
local location l1 = GetUnitLoc(u)
local unit temp
local group g = CreateGroup()
call QueueUnitAnimation(u, "stand ready")
if DistanceBetweenPoints(l1, l2)<32. then
set l3 = PolarProjectionBJ(l1, 32., AngleBetweenPoints(l1, l2))
if IsTerrainPathable(GetLocationX(l3), GetLocationY(l3), PATHING_TYPE_WALKABILITY) then
call SetUnitPositionLoc(u, l3)
else
call PauseTimer(t)
call ReleaseTimer(t)
endif
else
call SetUnitPositionLoc(u, l2)
call PauseTimer(t)
call ReleaseTimer(t)
call SetUnitAnimation(u, "stand")
call RemoveSavedHandle(hasht, 0, GetHandleId(t))
endif
//Bash
loop
exitwhen FirstOfGroup(g) == null
call GroupEnumUnitsInRangeOfLoc(g, l1, 60., null)
set temp = FirstOfGroup(g)
if IsUnitEnemy(temp, GetOwningPlayer(u)) then
call CreateUnitAtLoc(GetOwningPlayer(u), 'h000', l1, 0.)
call UnitAddAbility(GetLastCreatedUnit(), 'a001')
call IssueTargetOrder( GetLastCreatedUnit(), "thunderbolt", temp)
call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF', 2.00 )
call GroupRemoveUnit(g, temp)
endif
endloop
//Clean
call RemoveLocation(l1)
call RemoveLocation(l3)
call DestroyGroup(g)
set g = null
set l1 = null
set l2 = null
set l3 = null
set t = null
set u = null
set temp = null
endfunction
function Charge takes unit u, location target returns nothing
local timer t
set t = NewTimer()
call SaveLocationHandle(hasht, 0, GetHandleId(t), target)
call SaveUnitHandle(hasht, 0, GetHandleId(t), u)
call TimerStart(t, 0.033, true, function ChargeMove)
//return
endfunction
This uses timerUtils, and isn't really complete yet i suppose. However, even though i changed the common.j and blizzard.j in the newgen folder, jasshelper says there's no such thing as a hash table (neither any of it's components).
First of all: What do i need to fix in this script?
And second: Is it possible to do this:
JASS:
call SaveLocationHandle(hasht, 0, GetHandleId(t), target)
call SaveUnitHandle(hasht, 0, GetHandleId(t), u)