
修改几个函数后直接使用 call CreateBdUnit('单位类型')即可,,当然.哈希排泄需要自己写个单位死亡清除哈希.我的地图里有了.就没发出来
/*被动怪函数
函数名:CreateBdUnit(单位类型,恢复时间)*/
function CreateBdUnitT takes nothing returns nothing
local integer tid=GetHandleId(GetExpiredTimer())
local group g=GetUnitsInRectOfPlayer(GetPlayableMapRect(),Player(PLAYER_NEUTRAL_AGGRESSIVE))
local unit u
loop
set u=FirstOfGroup(g)
exitwhen u==null
call GroupRemoveUnit(g,u)
if GetHxBool(GetHandleId(u),"AttackOK") and GameTime-GetHxReal(GetHandleId(u),"AttackTime")>10 then
call SetHxReal(GetHandleId(u),"AttackTime",0)
call SetHxBool(GetHandleId(u),"AttackOK",false)
call SetUnitOwner(u,Player(PLAYER_NEUTRAL_PASSIVE),false)
endif
endloop
call DestroyGroup(g)
set g=null
set u=null
endfunction
function CreateBdUnitTri takes nothing returns nothing
local integer tid=GetHandleId(GetTriggeringTrigger())
local unit my=GetTriggerUnit()
local integer myid=GetHandleId(my)
local integer lid=GetHxInteger(tid,"lid")
if GetUnitTypeId(my)==lid then
call SetHxReal(myid,"AttackTime",GameTime)
call SetHxBool(myid,"AttackOK",true)
call SetUnitOwner(my,Player(PLAYER_NEUTRAL_AGGRESSIVE),false)
endif
set my=null
endfunction
function CreateBdUnit takes integer lid returns nothing
local trigger t=CreateTrigger()
local timer tim=CreateTimer()
call SetHxInteger(GetHandleId(t),"lid",lid)
call SetHxTimer(GetHandleId(t),"timer",tim)
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction(t,function CreateBdUnitTri)
//启动判断计时器
call TimerStart(tim,3,true,function CreateBdUnitT)
set t=null
set tim=null
endfunction