|
从演示图上挖来一个巫妖的连环霜冻,但是移植到自己的地图不能保存,请各位帮我看一下是什么问题。
代码如下:
library SDXX
globals
hashtable hx = InitHashtable()
endglobals
function Distance takes real x1,real x2,real y1, real y2 returns real
local real s
local real dx = x2 - x1
local real dy = y2 - y1
set s = SquareRoot(dx*dx+dy*dy)
return s
endfunction
function fzq takes real y1,real y2,real x1,real x2 returns real
local real s =(bj_RADTODEG* Atan2(y1-y2,x1-x2 ))
return s
endfunction
function zbX takes real xx,real xxx,real xxxx returns real
local real x
set x = xx+xxx*Cos(xxxx*bj_DEGTORAD)
return x
endfunction
function zbY takes real xx,real xxx,real xxxx returns real
local real y
set y = xx+xxx*Sin(xxxx*bj_DEGTORAD)
return y
endfunction
function Hero_Bn_Skill_R2 takes nothing returns nothing
local integer i = GetHandleId(GetExpiredTimer())
local unit Hero = LoadUnitHandle(hx,i,1)
local unit u = LoadUnitHandle(hx,i,2)
local unit majia = LoadUnitHandle(hx,i,3)
local boolean Boo = LoadBoolean(hx,i,5)
local boolean Booo = LoadBoolean(hx,i,6)
local integer C = LoadInteger(hx,i,7)
local unit beiyong = LoadUnitHandle(hx,i,8)
local integer i2 = 0
local real x
local real y
local real s
local group g = CreateGroup()
local group g2 = CreateGroup()
local location d = GetUnitLoc(u)
local unit xm
local unit majia2
if C == 7 /*这里的7为最大弹射次数*/ then
call PauseTimer(GetExpiredTimer())
call RemoveUnit(majia)
call FlushChildHashtable(hx,i)
call DestroyTimer(GetExpiredTimer())
else
if Boo == false then
if IsUnitAliveBJ(u) == true then
set s = fzq(GetUnitY(u),GetUnitY(majia),GetUnitX(u),GetUnitX(majia))
set x = zbX(GetUnitX(majia),13,s)//这里的13为冰霜球一开始飞行的移动速度
set y = zbY(GetUnitY(majia),13,s)//如上
call SetUnitX(majia,x)
call SetUnitY(majia,y)
if Distance(GetUnitX(majia),GetUnitX(u),GetUnitY(majia),GetUnitY(u))<=10 then
set Boo = true
call SaveBoolean(hx,i,5,Boo)
endif
else
set C = 7
endif
else
if Booo == false then
set C = C +1
call SaveInteger(hx,i,7,C)
set majia2 = CreateUnit(GetOwningPlayer(Hero),/*这里的e000改为释放技能马甲ID*/'e005',GetUnitX(u),GetUnitY(u),0)
call UnitApplyTimedLife( majia2, 'BHwe', 2.00 )
call IssueTargetOrder( majia2, "frostnova", u )
set g = GetUnitsInRangeOfLocAll(600,d)//这里的600为弹射选取单位的范围
call GroupRemoveUnit(g,u)
loop
set xm = FirstOfGroup(g)
exitwhen xm == null
if IsUnitType(xm, UNIT_TYPE_STRUCTURE) == false /*
*/and IsUnitEnemy(xm, GetOwningPlayer(Hero)) == true /*
*/ and IsUnitAliveBJ(xm) == true then
call GroupAddUnit(g2,xm)
endif
call GroupRemoveUnit(g,xm)
endloop
if CountUnitsInGroup(g2) == 0 then
set C = 7
else
set u = GroupPickRandomUnit(g2)
call SaveUnitHandle(hx,i,2,u)
call GroupRemoveUnit(g2,u)
set beiyong = GroupPickRandomUnit(g2)
call SaveUnitHandle(hx,i,8,beiyong)
set Booo = true
call SaveBoolean(hx,i,6,Booo)
endif
else
if IsUnitAliveBJ(u) == true then
set s = fzq(GetUnitY(u),GetUnitY(majia),GetUnitX(u),GetUnitX(majia))
set x = zbX(GetUnitX(majia),13,s) //这里的13为冰霜球弹射的时候的移动速度
set y = zbY(GetUnitY(majia),13,s)//如上
call SetUnitX(majia,x)
call SetUnitY(majia,y)
if Distance(GetUnitX(majia),GetUnitX(u),GetUnitY(majia),GetUnitY(u))<=10 then
set Booo = false
endif
else
if IsUnitAliveBJ(beiyong) == true then
set u = beiyong
call SaveUnitHandle(hx,i,2,u)
else
set C = 7
endif
endif
call SaveBoolean(hx,i,6,Booo)
endif
endif
endif
call SaveInteger(hx,i,7,C)
call DestroyGroup(g2)
call DestroyGroup(g)
call RemoveLocation(d)
set Hero = null
set majia = null
set u = null
set majia2 = null
set g = null
set g2 = null
set d = null
set xm = null
set beiyong = null
endfunction
function Hero_Bv_Skill_R takes unit Hero returns nothing
local unit u = GetSpellTargetUnit()
local unit majia = CreateUnit(GetOwningPlayer(Hero),/*这里的e001改为冰霜球马甲ID*/'e006',GetUnitX(Hero),GetUnitY(Hero),0)
local timer t = CreateTimer()
local integer i = GetHandleId(t)
call SaveUnitHandle(hx,i,1,Hero)
call SaveUnitHandle(hx,i,2,u)
call SaveUnitHandle(hx,i,3,majia)
call TimerStart(t,0.03,true,function Hero_Bn_Skill_R2)
set u = null
set majia = null
set Hero = null
endfunction
endlibrary
|
|