找回密码
 点一下
查看: 3482|回复: 0

如何判断单位是否移动的两个函数

  [复制链接]
发表于 2009-8-14 17:32:10 | 显示全部楼层 |阅读模式
RespondingAction
[codes=jass]
function RespondingAction takes nothing returns nothing
    if (GetUnitTypeId(GetDyingUnit())) == "hhdl") then
        call DisplayTextToForce(GetPlayersAll(),"IsStanding = False")
        call DestroyTrigger(GetTriggeringTrigger())
        //自定义事件(未移动
)
    else
        if (GetUnitTypeId(GetDyingUnit())) == "hrdh") then
            call DisplayTextToForce(GetPlayersAll(),"IsStanding = True")
            call DestroyTrigger(GetTriggeringTrigger())
            //自定义事件(移动中
)
        endif
    endif
endfunction

[/codes]

UnitStandCheck takes
[codes=jass]
function UnitStandCheck takes unit U returns nothing
    local unit WitchUnit = U
    local unit RespondingUnit = null
    local location UnitLoc = GetUnitLoc(WitchUnit)
    local boolean IsStanding = true
    local trigger RespondingTrigger = null

    loop
        if (IsStanding == true) then
            if (DistanceBetweenPoints(UnitLoc, GetUnitLoc(WitchUnit)) > 10 ) then)
                set RespondingUnit = CreateUnitAtLoc(GetOwningPlayer(WitchUnit), "hhdl", Location(0, 0), 0.00)
                set IsStanding = false

                set RespondingTrigger = CreateTRigger()
                call TriggerRegisterAnyUnitEventBJ(RespondingTrigger,EVENT_PLAYER_UNIT_DEATH)
                call TriggerAddAction(RespondingTrigger, function RespondingAction)

                call ExplodeUnitBJ(RespondingUnit)
                call SetUnitUserData(WitchUnit, 0)
                //自定义事件(未移动
)
            endif
        else
            if (DistanceBetweenPoints(UnitLoc, GetUnitLoc(WitchUnit)) <= 10 ) then)
                set RespondingUnit = CreateUnitAtLoc(GetOwningPlayer(WitchUnit), "hrdh", Location(0, 0), 0.00)
                set IsStanding = true

                set RespondingTrigger = CreateTRigger()
                call TriggerRegisterAnyUnitEventBJ(RespondingTrigger,EVENT_PLAYER_UNIT_DEATH)
                call TriggerAddAction(RespondingTrigger, function RespondingAction)

                call ExplodeUnitBJ(RespondingUnit)
                call SetUnitUserData(WitchUnit, 0)
                //自定义事件(移动中
)
            endif
        endif

        set UnitLoc = GetUnitLoc(WitchUnit)
        call PolledWait(0.01)
    endloop
endfunction

[/codes]

评分

参与人数 1威望 +14 收起 理由
alexries + 14 超级有用。

查看全部评分

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-4-26 16:24 , Processed in 0.097798 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表