|
[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]
改寫了代碼,問題解決 |
|