找回密码
 点一下
查看: 1326|回复: 1

关于FogModifier不會正確被關閉

[复制链接]
发表于 2009-3-16 16:23:48 | 显示全部楼层 |阅读模式
[codes=jass]
//===========================================================================
function SetMoonBlindnessUnitVision takes nothing returns nothing
    local string tHandle = H2S(GetTriggeringTrigger())
    local unit hero = GetStoredUnit(tHandle, "Hero")
    local player whichPlayer = GetOwningPlayer(hero)
    local integer teamIndex = GetPlayerTeamIndex(whichPlayer)
    local integer i = (teamIndex - 1) * 5 + 1
    loop
        exitwhen i > teamIndex * 5
        call SetPlayerAllianceBJ(whichPlayer, ALLIANCE_SHARED_VISION, true, udg_Players)
        call SetPlayerAllianceBJ(udg_Players, ALLIANCE_SHARED_VISION, true, whichPlayer)
        set i = i + 1
    endloop
    call SetPlayerAllianceBJ(udg_CreepPlayers[teamIndex], ALLIANCE_SHARED_VISION, true, whichPlayer)
    call KillFogModifier(GetStoredFogModifier(tHandle, "Fog"))
    call KillTrigger(GetTriggeringTrigger())
    set whichPlayer = null
endfunction

//===========================================================================
function UnitGetMoonBlindness takes nothing returns nothing
    local string tHandle = H2S(GetTriggeringTrigger())
    local integer i
    local integer teamIndex
    local unit hero = GetTriggerUnit()
    local player whichPlayer = GetOwningPlayer(hero)
    local unit lorelei = GetStoredUnit(tHandle, "Lorelei")
    local unit caster
    local integer level = GetUnitAbilityLevel(lorelei, 'A03E')
    local trigger t
    local fogmodifier fm
    if GetEventDamageSource() == lorelei and IsUnitDeadBJ(hero) == false then
        if GetRandomInt(1, 10) < 4 then
            set t = GetStoredTrigger(H2S(hero), "MoonBlindnessTrigger")
            if t!= null then
                call KillFogModifier(GetStoredFogModifier(H2S(t), "Fog"))           
                call KillTrigger(t)
            endif
            set teamIndex = GetPlayerTeamIndex(whichPlayer)
            set i = (teamIndex - 1) * 5 + 1
            loop
                exitwhen i > teamIndex * 5
                call SetPlayerAllianceBJ(whichPlayer, ALLIANCE_SHARED_VISION, false, udg_Players)
                call SetPlayerAllianceBJ(udg_Players, ALLIANCE_SHARED_VISION, false, whichPlayer)
                set i = i + 1
            endloop
            call SetPlayerAllianceBJ(udg_CreepPlayers[teamIndex], ALLIANCE_SHARED_VISION, false, whichPlayer)
            set fm = CreateFogModifierRect(whichPlayer, FOG_OF_WAR_MASKED, bj_mapInitialPlayableArea, false, true)
            call FogModifierStart(fm)
            set t = CreateTrigger()
            call StoreHandle(H2S(t), "Hero", hero)
            call StoreHandle(H2S(hero), "MoonBlindnessTrigger", t)
            call StoreHandle(H2S(t), "Fog", fm)
            call TriggerRegisterTimerEvent(t, level * 1.5, false)
            call TriggerRegisterUnitEvent(t, hero, EVENT_UNIT_DEATH)
            call TriggerAddCondition(t, Condition(function SetMoonBlindnessUnitVision))
            set caster = CreateUnit(whichPlayer, udg_SpellCaster, GetUnitX(hero), GetUnitY(hero), bj_UNIT_FACING)
            call UnitApplyTimedLife(caster, 'BTLF', 2)
            call UnitAddAbility(caster, 'A03L')
            call SetUnitAbilityLevel(caster, 'A03L', level)
            call IssueTargetOrder(caster, "channel", hero)
        endif
    endif
    call KillTrigger(GetTriggeringTrigger())
    set whichPlayer = null
    set hero = null
    set lorelei = null
    set t = null
    set fm = null
    set caster = null
endfunction
//===========================================================================
function KillFogModifier takes fogmodifier fm returns nothing
      if fm != null then
            call FogModifierStop(fm)
            call DestroyFogModifier(fm)
      endif
endfunction
[/codes]

改寫了代碼,問題解決
发表于 2009-3-16 21:04:12 | 显示全部楼层
lz可以自己做做debug,在关闭动作之前先看看你要关闭的对象是否存在,如果存在那么可能是rp了
如果不存在,那么可以再回到存储的地方,看看存储的对象是否存在之类
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-25 10:57 , Processed in 0.064963 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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