|
这段J的代码在1。24不可以用,谁能修复一下吗?雇用兵系统的
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function I2Tm takes integer i returns timer
return i
return null
endfunction
function GetUnitCurrentFree_Func takes unit u returns boolean
local string s = OrderId2String(GetUnitCurrentOrder(u))
if s == null then
return true
endif
return false
endfunction
function SetGuard_Func takes nothing returns nothing
local timer tm = GetExpiredTimer()
local unit Eidolon = I2U(GetStoredInteger(udg_Shousave, I2S(H2I(tm)), "Eidolon"))
local unit captain = I2U(GetStoredInteger(udg_Shousave, I2S(H2I(tm)), "Captain"))
local real x = GetUnitX(captain) - GetUnitX(Eidolon)
local real y = GetUnitY(captain) - GetUnitY(Eidolon)
local real d = x*x + y*y
local real v
local real a
local effect e
local real life = GetStoredReal(udg_Shousave, I2S(H2I(tm)), "Life")
local integer p = GetStoredInteger(udg_Shousave,I2S(H2I(tm)), "Percent")
set v = GetStoredReal(udg_Shousave, I2S(H2I(tm)), "GuardRanger")
if GetUnitState(Eidolon, UNIT_STATE_LIFE) > 0 then
if d<v*v then
if GetUnitCurrentFree_Func(Eidolon)==true and GetRandomInt(0,100)<p then
set x = GetUnitX(captain)
set y = GetUnitY(captain)
set d = GetRandomReal(0,v)
set a = GetRandomReal(0,360)
call IssuePointOrder(Eidolon, "patrol", x+d*CosBJ(a), y+d*SinBJ(a))
endif
else
set v = GetStoredReal(udg_Shousave, I2S(H2I(tm)), "ReturnRanger")
if d<v*v then
if GetUnitCurrentFree_Func(Eidolon)==true then
call IssuePointOrder(Eidolon, "patrol", GetUnitX(captain), GetUnitY(captain))
endif
else
set v = GetStoredReal(udg_Shousave, I2S(H2I(tm)), "OutRanger")
if d!=0 and d>v*v then
call SetUnitPosition(Eidolon,GetUnitX(captain),GetUnitY(captain))
set e =AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\FaerieDragonInvis\\FaerieDragon_Invis.mdl" ,captain,"origin")
call DestroyEffect(e)
else
call IssuePointOrder(Eidolon, "move", GetUnitX(captain), GetUnitY(captain))
endif
endif
endif
endif
set tm = null
set Eidolon = null
set captain = null
endfunction
function SetGuard takes unit Eidolon, unit captain, real timeout, real guardRanger, real returnRanger, real outRanger,integer percent returns nothing
local timer tm = CreateTimer()
call StoreInteger(udg_Shousave, I2S(H2I(Eidolon)), "Timer", H2I(tm))
call StoreInteger(udg_Shousave, I2S(H2I(tm)), "Eidolon",H2I(Eidolon))
call StoreInteger(udg_Shousave, I2S(H2I(tm)), "Captain", H2I(captain))
call StoreInteger(udg_Shousave, I2S(H2I(tm)), "Percent", percent)
call StoreReal(udg_Shousave, I2S(H2I(tm)), "GuardRanger", guardRanger)
call StoreReal(udg_Shousave, I2S(H2I(tm)), "ReturnRanger", returnRanger)
call StoreReal(udg_Shousave, I2S(H2I(tm)), "OutRanger", outRanger)
call TimerStart(tm, timeout, true, function SetGuard_Func)
set tm = null
endfunction
function RemoveGuard takes unit Eidolon returns nothing
local integer tm = GetStoredInteger(udg_Shousave, I2S(H2I(Eidolon)), "Timer")
call FlushStoredMission(udg_Shousave, I2S(H2I(Eidolon)))
call FlushStoredMission(udg_Shousave, I2S(tm))
call DestroyTimer(I2Tm(tm))
endfunction |
|