|
发表于 2008-12-24 18:33:58
|
显示全部楼层
模拟.......
[jass]
function Laser_Remove takes nothing returns nothing
local unit u = bj_lastCreatedUnit
call TriggerSleepAction(0)
call KillUnit(u)
call TriggerSleepAction(1)
call RemoveUnit(u)
set u = null
endfunction
function Laser takes real LocX1,real LocY1,real LocZ1,real LocX2,real LocY2,real LocZ2,integer EffectID,string Effect returns nothing
local integer i = 0
local integer imax = R2I(SquareRoot((LocX1-LocX2) * (LocX1-LocX2) + (LocY1-LocY2) * (LocY1-LocY2))/30) + 188
local real angle =Atan2(LocY2-LocY1,LocX2-LocX1)
local real MapMinX = GetRectMinX(bj_mapInitialPlayableArea)
local real MapMaxX = GetRectMaxX(bj_mapInitialPlayableArea)
local real MapMinY = GetRectMinY(bj_mapInitialPlayableArea)
local real MapMaxY = GetRectMaxY(bj_mapInitialPlayableArea)
local real height = 0
local real x = 0
local real y = 0
local real z = 0
local unit u = null
if (LocZ1!=0) or (LocZ2!=0) then
set height = (LocZ1 - LocZ2)/(imax-188)
loop
set i = i + 1
exitwhen (i > imax) or ((LocZ1-height*I2R(i)) < 0) or (x > MapMaxX) or (x < MapMinX) or (y > MapMaxY) or (y < MapMinY)
set x = LocX1 + I2R(30*i) * Cos(angle)
set y = LocY1 + I2R(30*i) * Sin(angle)
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),EffectID,x,y,angle)
call SetUnitFlyHeight(u,(LocZ1-height*I2R(i)),0)
set bj_lastCreatedUnit = u
call ExecuteFunc("Laser_Remove")
endloop
else
loop
set i = i + 1
exitwhen i > imax
set x = LocX1 + I2R(30*i) * Cos(angle)
set y = LocY1 + I2R(30*i) * Sin(angle)
call DestroyEffect(AddSpecialEffect(Effect,x,y))
endloop
endif
set u = null
endfunction
[/jass] |
|