Yo, I was going over the vJASS way of MUI'ing spells, but one tutorial I have yet to see, is an equivalent to the H2I method which was(is)
Here I store a unit, u, then it is transferred over to the executeonce function using the timer's unique id as a missionkey.
Similarly I tried using it with structs, but no-one has explained how to access one instance from all instances available. Anyone care to explain or do you want me to elaborate a little?
Three spells are cast, with 1 second apart from each cast.
After 5 seconds of each cast, an action takes place.
So, the order of each action would be at seconds:
5, 6, 7.
So, how do I know which timer that fired if the instances used where like 4, 7 and 2?
This is what I tried
But, then again, I had no clue what to do, because as I said, I have yet to see a tutorial about this...
My educated guess, would be to set the instance number to the handle, but I thought this new way would make the H2I functions obsolete, 'cause I really hate using gamecache so this is why I jumped with joy when I heard about the new method
Ah, this is hard to explain, I hope you understand what I'm trying to convey here...
JASS:
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return 0
endfunction
function executeonce takes nothing returns nothing
local gamecache gc = udg_gamecache
local string uniqueMS = I2S(H2I(GetExpiredTimer() ) )
local unit u = I2U(GetStoredInteger(gc, "unit", uniqueMS) )
//actions
endfunction
function InitSomeTrig takes nothing returns nothing
local gamecache gc = udg_gamecache
local timer t = CreateTimer()
local string uniqueMS = I2S(H2I(t))
local unit u = CreateUnit( blabla )
call StoreInteger(gc, uniqueMS, "unit", H2I(u) )
call TimerStart( t, 5.00, false, function executeonce)
endfunction
Similarly I tried using it with structs, but no-one has explained how to access one instance from all instances available. Anyone care to explain or do you want me to elaborate a little?
Three spells are cast, with 1 second apart from each cast.
After 5 seconds of each cast, an action takes place.
So, the order of each action would be at seconds:
5, 6, 7.
So, how do I know which timer that fired if the instances used where like 4, 7 and 2?
This is what I tried
JASS:
struct Spell_Data
unit currenttarget
real targetX
real targetY
unit u
real uX
real uY
timer atimer
integer uniqueid = 0
boolean timeron = false
endstruct
globals
Spell_Data array Spell_Data_Array
integer TOTAL_INSTANCES = 0
timer TIMER = CreateTimer() // this timer is another timer used for a movement test that works splendidly...
integer TYPE = 'h001'
endglobals
function H2I takes handle h returns integer
return h
return 0
endfunction
function ExecuteMovement takes nothing returns nothing
local Spell_Data sd
local integer i = 0
loop
exitwhen i >= TOTAL_INSTANCES
set sd = Spell_Data_Array[i]
if( sd.uniqueid != 0 ) then
set sd.timeron = true
call ResetUnitAnimation(sd.u)
call DestroyTimer( sd.atimer )
endif
set i = i +1
endloop
endfunction
function Initiate takes unit u returns nothing
local Spell_Data sd = Spell_Data.create()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer angle = GetRandomInt(1,360)
local integer i = 0
local real newx = x + 150*Cos(angle*(bj_PI/180) )
local real newy = y + 150*Sin(angle*(bj_PI/180) )
local real facing = AngleBetweenPointsXY( newx, newy, x, y )
local unit u = CreateUnit( GetOwningPlayer(u), TYPE, newx,newy, facing)
set sd.atimer = CreateTimer()
set sd.currenttarget = u
set sd.u = u
set sd.uniqueid = H2I(sd.atimer)
call TimerStart( sd.atimer, 5, false, function ExecuteMovement )
set TOTAL_INSTANCES = TOTAL_INSTANCES + 1
set Spell_Data_Array[TOTAL_INSTANCES-1] = sd
endfunction
My educated guess, would be to set the instance number to the handle, but I thought this new way would make the H2I functions obsolete, 'cause I really hate using gamecache so this is why I jumped with joy when I heard about the new method
Ah, this is hard to explain, I hope you understand what I'm trying to convey here...