|
[jass]
    constant real               SYD_PI=3.14159
    constant real               SYD_PI2=1.570795
    constant real               SYD_TODEG=180/3.14159
    constant real               SYD_TORAD=3.14159/180
function MissileWithTargetGroup takes nothing returns nothing
    local unit u = GetEnumUnit()
    local integer vMix = GetUnitUserData(u)
    local integer aParam = Modi(vMix,200)
    local integer rParam = Modi_EX(vMix,120000,200)
    local integer tParam = vMix/120000
    local integer vLimit = SYS_GroupTempData[1]
    local integer cur = tParam - SYS_GroupTempData[0]
    local real bAngle
    local real bAngleEx
    local real r
    local real d
    local real x
    local real y
    set SYS_GroupInt = SYS_GroupInt + 1
    if(cur<=0)then
    elseif(cur>0 and cur<vLimit)then
        set bAngle = cur*SYD_PI/vLimit
        set r=1-Cos(bAngle)
        set d=r*Sin(bAngle)*rParam
        set r=r*Cos(bAngle)*SYS_GroupTempDataR[0]
        set bAngleEx = I2R(aParam)*SYD_TORAD
        call SetUnitFlyHeight(u,60+d*Sin(bAngleEx),0)
        set x = GetUnitX(SYS_GroupUnit)+r*Cos(SYS_GroupTempDataR[1])+d*Cos(bAngleEx)*Cos(SYS_GroupTempDataR[2])
        set y = GetUnitY(SYS_GroupUnit)+r*Sin(SYS_GroupTempDataR[1])+d*Cos(bAngleEx)*Sin(SYS_GroupTempDataR[2])
        call SetUnitX(u,x)
        call SetUnitY(u,y)
    elseif(cur>=vLimit)then
        call RemoveUnit(u)
        call GroupRemoveUnit(SYS_Group,u)
        set SYS_GroupInt = SYS_GroupInt - 1
    endif
    set u = null
endfunction
function MissileWithTargetLoop takes nothing returns nothing
    local integer tmIndex = GetTimerIndex(GetExpiredTimer())
    local unit su = SYS_TimerData_U00[tmIndex]
    local unit tu = SYS_TimerData_U01[tmIndex]
    set SYS_Group = SYS_TimerData_Group[tmIndex]
    set SYS_GroupUnit = su
    set SYS_GroupTarget = tu
    set SYS_GroupInt = 0
    set SYS_GroupTempData[0] = SYS_TimerData_I00[tmIndex]
    set SYS_GroupTempData[1] = SYS_TimerData_I01[tmIndex]
    set SYS_GroupTempDataR[0] = iGetDistanceBetweenUnit(su,tu)/2
    set SYS_GroupTempDataR[1] = iGetAngleBetweenUnit(su,tu)
    set SYS_GroupTempDataR[2] = iGetAngleBetweenUnit(su,tu) - SYD_PI2
    call ForGroup(SYS_Group,function MissileWithTargetGroup)
    if(SYS_GroupInt<=0)then
        call DestroyGroup(SYS_Group)
        set SYS_Group = null
        set SYS_GroupUnit = null
        set SYS_GroupTarget = null
        call ReleaseTimer(GetExpiredTimer())
    else
        set SYS_TimerData_I00[tmIndex] = SYS_TimerData_I00[tmIndex] - 1
    endif
set su = null
set tu = null
endfunction
function MissileWithTargetLanch takes unit su,unit tu,integer Num,integer aMin,integer aMax,integer dMax,integer rLatency,integer bIndex returns nothing
    local integer tmIndex
    local integer i = Num
    local integer vMix
    local integer rParam
    local integer aParam
    local integer tParam
    local integer vLimit = IConfig(R2I(iGetDistanceBetweenUnit(su,tu)/6.0),40,80)
    local group gp
    local unit blot
    local integer blotId = 'u00A'
    local real uFacing = GetUnitFacing(su)
    local location loc
    if(i<=0)then
        return
    endif
    set loc = GetUnitLoc(su)
    set tmIndex = GetTimerIndex(GetTimer())
    set gp = CreateGroup()
    loop
        exitwhen(i<=0)
        set aParam = IConfig(GetRandomInt(aMin,aMax),-90,90)+90
        set rParam = GetRandomInt(0,IConfig(dMax,0,512))
        set tParam = GetRandomInt(80,80+IConfig(rLatency,0,40))
        set vMix = tParam*120000 + rParam*200 + aParam
        set blot = CreateUnit(GetOwningPlayer(su),blotId,GetUnitX(su),GetUnitY(su),uFacing+aParam)
        call SetUnitFlyHeight(blot,60+GetLocationZ(loc),0)
        call SetUnitIgnoreRegister(blot)
        call SetUnitUserData(blot,vMix)
        call GroupAddUnit(gp,blot)
        set i = i - 1
    endloop
    set SYS_TimerData_U00[tmIndex] = su
    set SYS_TimerData_U01[tmIndex] = tu
    set SYS_TimerData_I00[tmIndex] = vLimit + rLatency
    set SYS_TimerData_I01[tmIndex] = vLimit
    set SYS_TimerData_I02[tmIndex] = bIndex
    set SYS_TimerData_Group[tmIndex] = gp
    call TimerStart(SYS_Timer[tmIndex],0.025,true,function MissileWithTargetLoop)
    call RemoveLocation(loc)
    set gp = null
    set blot = null
    set loc = null
endfunction
[/jass] |
评分
-
查看全部评分
|