function GetTrackableX takes integer trackId returns real
return LoadReal( udg_GTrack_Table, trackId, 0)
endfunction
function GetTrackableY takes integer trackId returns real
return LoadReal( udg_GTrack_Table, trackId, 1)
endfunction
function GetTrackableFacing takes integer trackId returns real
return LoadReal( udg_GTrack_Table, trackId, 2)
endfunction
function GetTrackableModel takes integer trackId returns string
return LoadStr( udg_GTrack_Table, trackId, 3)
endfunction
function GetTrackablePlayer takes integer trackId returns player
if (HaveSavedHandle( udg_GTrack_Table, trackId, 6) ) then
return LoadPlayerHandle( udg_GTrack_Table, trackId, 6)
endif
return Player(15)
endfunction
function AddTrackableHitTrigger takes integer trackId, trigger t returns nothing
local integer i = LoadInteger( udg_GTrack_Table, trackId, 4)
call SaveTriggerHandle( udg_GTrack_Table, trackId, 100+i, t)
call SaveInteger( udg_GTrack_Table, trackId, 4, i+1 )
endfunction
function AddTrackableTrackTrigger takes integer trackId, trigger t returns nothing
local integer i = LoadInteger( udg_GTrack_Table, trackId, 5)
call SaveTriggerHandle( udg_GTrack_Table, trackId, -1-i, t)
call SaveInteger( udg_GTrack_Table, trackId, 5, i+1 )
endfunction
function FlushTrackableTriggers takes integer trackId returns nothing
local real x = LoadReal( udg_GTrack_Table, trackId, 0)
local real y = LoadReal( udg_GTrack_Table, trackId, 1)
local real facing = LoadReal( udg_GTrack_Table, trackId, 2)
local string model = LoadStr(udg_GTrack_Table, trackId, 3)
local player p = LoadPlayerHandle( udg_GTrack_Table, trackId, 6)
call FlushChildHashtable( udg_GTrack_Table, trackId)
call SaveReal( udg_GTrack_Table, trackId, 0, x)
call SaveReal( udg_GTrack_Table, trackId, 1, y)
call SaveReal( udg_GTrack_Table, trackId, 2, facing)
call SaveStr( udg_GTrack_Table, trackId, 3, model)
call SaveInteger( udg_GTrack_Table, trackId, 4, 0)
call SaveInteger( udg_GTrack_Table, trackId, 5, 0)
call SavePlayerHandle( udg_GTrack_Table, trackId, 6, p)
endfunction
function TrackableCreateEx takes player p returns integer
local string model = ""
local trackable t
local integer pkey
if(GetLocalPlayer() == p ) then
set model = udg_GTrack_Model
endif
set t = CreateTrackable( model, udg_GTrack_X, udg_GTrack_Y, udg_GTrack_Facing * bj_DEGTORAD)
set pkey = GetHandleId(t)
call TriggerRegisterTrackableHitEvent( udg_GTrack_HitEvent, t)
call TriggerRegisterTrackableTrackEvent( udg_GTrack_TrackEvent, t)
call SaveReal( udg_GTrack_Table, pkey, 0, udg_GTrack_X)
call SaveReal( udg_GTrack_Table, pkey, 1, udg_GTrack_Y)
call SaveReal( udg_GTrack_Table, pkey, 2, udg_GTrack_Facing)
call SaveStr( udg_GTrack_Table, pkey, 3, udg_GTrack_Model)
call SaveInteger( udg_GTrack_Table, pkey, 4, 0)
call SaveInteger( udg_GTrack_Table, pkey, 5, 0)
call SavePlayerHandle( udg_GTrack_Table, pkey, 6, p)
set t = null
return pkey
endfunction
function TrackableCreate takes nothing returns integer
local trackable t = CreateTrackable( udg_GTrack_Model, udg_GTrack_X, udg_GTrack_Y, udg_GTrack_Facing * bj_DEGTORAD )
local integer pkey = GetHandleId(t)
call TriggerRegisterTrackableHitEvent( udg_GTrack_HitEvent, t)
call TriggerRegisterTrackableTrackEvent( udg_GTrack_TrackEvent, t)
call SaveReal( udg_GTrack_Table, pkey, 0, udg_GTrack_X)
call SaveReal( udg_GTrack_Table, pkey, 1, udg_GTrack_Y)
call SaveReal( udg_GTrack_Table, pkey, 2, udg_GTrack_Facing)
call SaveStr( udg_GTrack_Table, pkey, 3, udg_GTrack_Model)
call SaveInteger( udg_GTrack_Table, pkey, 4, 0)
call SaveInteger( udg_GTrack_Table, pkey, 5, 0)
set t = null
return pkey
endfunction
function TrackableHitEvent takes nothing returns boolean
local trackable t = GetTriggeringTrackable()
local integer i = 0
local integer count
local trigger trig
local integer pkey = GetHandleId(t)
if (HaveSavedInteger( udg_GTrack_Table, pkey, 4 ) ) then
set count = LoadInteger( udg_GTrack_Table, pkey, 4)
loop
exitwhen i >= count
set trig = LoadTriggerHandle( udg_GTrack_Table, pkey, 100+i)
set udg_GTrack_HandleId = pkey
if (TriggerEvaluate(trig)) then
call TriggerExecute(trig)
endif
set i = i +1
endloop
endif
set t = null
return false
endfunction
function TrackableTrackEvent takes nothing returns boolean
local trackable t = GetTriggeringTrackable()
local integer i = 0
local integer count
local trigger trig
local integer pkey = GetHandleId(t)
if (HaveSavedInteger( udg_GTrack_Table, pkey, 5 ) ) then
set count = LoadInteger( udg_GTrack_Table, pkey, 5)
loop
exitwhen i >= count
set trig = LoadTriggerHandle( udg_GTrack_Table, pkey, -1-i)
set udg_GTrack_HandleId = pkey
if (TriggerEvaluate(trig)) then
call TriggerExecute(trig)
endif
set i = i +1
endloop
endif
set t = null
return false
endfunction
function InitTrig_GTrack_API takes nothing returns nothing
set udg_GTrack_Table = InitHashtable()
set udg_GTrack_HitEvent = CreateTrigger()
set udg_GTrack_TrackEvent = CreateTrigger()
call TriggerAddCondition( udg_GTrack_HitEvent, function TrackableHitEvent )
call TriggerAddCondition( udg_GTrack_TrackEvent, function TrackableTrackEvent )
endfunction