- Joined
- Jul 9, 2008
- Messages
- 253
Hello everybody, so I'm trying to make a spell again. This time it involves a timer, and because I've never used a timer before and have no idea how it actually works. I post you this trigger and hope that you can make it work.
Information about the spell:
Well the spell should just create a dummy and move it forward for now. But it gives a error in line "local unit caster = GetTriggerUnit()" saying it's a "Type missbatch in assignment". Please help me.
Trigger ( JASS ):
It's not finished, I just need the moving to work.
Thanks in advance, Quetzalcotl
Information about the spell:
Well the spell should just create a dummy and move it forward for now. But it gives a error in line "local unit caster = GetTriggerUnit()" saying it's a "Type missbatch in assignment". Please help me.
Trigger ( JASS ):
JASS:
// Spell ID //
constant function Shadow_Path_ID takes nothing returns integer
return 'A00R'
endfunction
function Shadow_Path_Expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = LoadUnitHandle( udg_SP_Hash , GetHandleId( t ) , 1 )
local unit dummy = LoadUnitHandle( udg_SP_Hash , GetHandleId( t ) , 2 )
local real angle = LoadReal( udg_SP_Hash , GetHandleId( t ) , 3 )
local real cx = GetUnitX( caster )
local real cy = GetUnitY( caster )
local real tx = GetUnitX( dummy )
local real ty = GetUnitY( dummy )
local real dx = tx - cx
local real dy = ty - cy
local real distance = SquareRoot(dx * dx + dy * dy)
local real dispertime = distance * 0.03
local real px = tx + dispertime * Cos( angle * bj_DEGTORAD )
local real py = ty + dispertime * Sin( angle * bj_DEGTORAD )
//
call SetUnitX( dummy , px )
call SetUnitY( dummy , py )
//
//call DestroyTimer( t )
//
//set t = null
set caster = null
set dummy = null
endfunction
function Shadow_Path_Actions takes nothing returns nothing
local trigger t = CreateTimer()
local unit caster = GetTriggerUnit()
local location loc = GetSpellTargetLoc()
local player p = GetOwningPlayer( caster )
local real cx = GetUnitX( caster )
local real cy = GetUnitY( caster )
local real tx = GetLocationX( loc )
local real ty = GetLocationY( loc )
local unit dummy
local real facing = bj_RADTODEG * Atan2( ty - cy , tx - cx )
//
set dummy = CreateUnit( p , 'h004' , cx , cy , facing )
call UnitApplyTimedLife( dummy , 'BTLF' , 1. )
//
call SaveUnitHandle( udg_SP_Hash , GetHandleId( t ) , 1 , caster )
call SaveUnitHandle( udg_SP_Hash , GetHandleId( t ) , 2 , dummy )
call SaveReal( udg_SP_Hash , GetHandleId( t ) , 3 , facing )
call TimerStart( t , 0.03 , true , function Shadow_Path_Expire )
//
call PolledWait( 1. )
//
call DestroyTimer( t )
//
call RemoveLocation( loc )
//
set caster = null
set dummy = null
set p = null
set loc = null
endfunction
// Spell Condition //
function Trig_Shadow_Path_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Shadow_Path_ID()
endfunction
//===========================================================================
function InitTrig_Shadow_Path takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
set udg_SP_Hash = InitHashtable()
loop
exitwhen i == 16
call TriggerRegisterPlayerUnitEvent( t, Player( i ) , EVENT_PLAYER_UNIT_SPELL_EFFECT , null )
set i = i + 1
endloop
call TriggerAddCondition( t , Condition( function Trig_Shadow_Path_Conditions ) )
call TriggerAddAction( t , function Trig_Shadow_Path_Actions )
set t = null
endfunction
It's not finished, I just need the moving to work.
Thanks in advance, Quetzalcotl