|
发表于 2016-10-10 20:04:27
|
显示全部楼层
本帖最后由 o拼了命去爱你o 于 2016-10-11 07:27 编辑
//让指定单位在死亡后N秒在注册时的地点复活并保持面向角度。
//call Wolf_FuHuoEvet(unit,real) 单位和复活时间 注册后该单位死亡后会在注册的这个地点复活
//需要在调用函数之前声明一个哈希表udg_HT
function FuHhuoAction2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(udg_HT,GetHandleId(t),StringHash("fuhuounit"))
local real x = LoadReal(udg_HT,GetHandleId(u),StringHash("fuhuox"))
local real y = LoadReal(udg_HT,GetHandleId(u),StringHash("fuhuoy"))
local real angle = LoadReal(udg_HT,GetHandleId(u),StringHash("fuhuof"))
call CreateUnit( GetOwningPlayer(u), GetUnitTypeId(u), x, y, angle )
//call BJDebugMsg("已经复活!")
call FlushChildHashtable( udg_HT, GetHandleId(u) )
call FlushChildHashtable( udg_HT, GetHandleId(t) )//清空哈希表主索引
call DestroyTimer(t)//删除计时器
set t = null
set u = null
endfunction
function FuHuoAction1 takes nothing returns nothing
local timer t = CreateTimer()
call SaveUnitHandle(udg_HT,GetHandleId(t),StringHash("fuhuounit"),GetTriggerUnit())
call TimerStart(t,LoadReal(udg_HT,GetHandleId(GetTriggerUnit()),StringHash("fuhuotime")),false,function FuHhuoAction2)
//call BJDebugMsg("等待复活!")
set t = null
call DestroyTrigger( GetTriggeringTrigger() )//销毁触发器
endfunction
function Wolf_FuHuoEvet takes unit u1,real r1 returns nothing
local trigger fuhuo = CreateTrigger()
local real x = GetUnitX(u1)
local real y = GetUnitY(u1)
local real angle = GetUnitFacing(u1)
call SaveReal(udg_HT,GetHandleId(u1),StringHash("fuhuotime"),r1)
call SaveReal(udg_HT,GetHandleId(u1),StringHash("fuhuox"),x)
call SaveReal(udg_HT,GetHandleId(u1),StringHash("fuhuoy"),y)
call SaveReal(udg_HT,GetHandleId(u1),StringHash("fuhuof"),angle)
call TriggerRegisterUnitEvent( fuhuo, u1, EVENT_UNIT_DEATH )
call TriggerAddAction(fuhuo, function FuHuoAction1)
//call BJDebugMsg("注册单位死亡事件!")
set fuhuo = null
endfunction
//end 复活系统--------------------- |
|