HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Weather effect in my spell.

10-02-2007, 01:39 PM#1
StRoNgFoE_2000
This is a spell that when you cast, creates a satellite in the air, and creates the weather effect "Sun Rays". The sun rays has a reverse unholy aura that drains 2% HP a second, (Thats the reason for the KillLowHP function because unholy aura bugs units at 1HP). The problem is, itt creates the weather effect for only one player, and the native for creating weather effects does not take a player argument, so.. I'm confused how would I go about creating the weather effect for everyone?

Collapse JASS:
function BeamSatteliteCond takes nothing returns boolean
    return GetSpellAbilityId() == 'A03M'
endfunction
function ShouldUnitDie takes nothing returns boolean
    local unit u = GetFilterUnit()
    if (GetUnitAbilityLevel(u, 'B00B') > 0) and (GetUnitState(u, UNIT_STATE_LIFE) == 1) then
        set u = null
        return true
    endif
    set u = null
    return false
endfunction
function KillLowHP takes nothing returns nothing
    local unit u
    local timer t = CreateTimer()
    local group g = CreateGroup()
    local rect r = bj_mapInitialPlayableArea
    local boolexpr b = Condition(function ShouldUnitDie)
    local integer i = GetHandleInt(t, "loops")
    call GroupEnumUnitsInRect(g, r, b)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call KillUnit(u)
        call GroupRemoveUnit(g, u)
    endloop
    if (i > 0) then
        set i = i - 1
        call SetHandleInt(t, "loops", i)
    else
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
    endif
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    set u = null
    set t = null
    set g = null
    set r = null
    set b = null
endfunction
function RemoveLight takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local weathereffect w = GetHandleWeather(t, "weather")
    call EnableWeatherEffect(w, false)
    call RemoveWeatherEffect(w)
    call FlushHandleLocals(t)
    call PauseTimer(t)
    call DestroyTimer(t)
    set t = null
    set w = null
endfunction
function BeamSattelite takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local player p = GetOwningPlayer(u)
    local timer t = CreateTimer()
    local timer z = CreateTimer()
    local real x
    local rect r
    local weathereffect w
    if (IsPlayerInForce(p, udg_Force1)) then
        set r = gg_rct_SatteliteTop
    else
        set r = gg_rct_SatteliteBottom
    endif
    set w = AddWeatherEffect(r, 'LRaa')
    call EnableWeatherEffect(w, true)
    call SetHandleHandle(t, "weather", w)
    call SetHandleInt(z, "loops", 40)
    call TimerStart(t, 40, false, function RemoveLight)
    call TimerStart(z, 1, true, function KillLowHP)
    set u = null
    set p = null
    set t = null
    set w = null
endfunction
function InitTrig_BeamSatteliteCast takes nothing returns nothing
    local integer i = 0
    local player p
    set gg_trg_BeamSatteliteCast = CreateTrigger()
    loop
        exitwhen i > 11
        set p = Player(i)
        call TriggerRegisterPlayerUnitEvent(gg_trg_BeamSatteliteCast, p, EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
    endloop
    call TriggerAddCondition(gg_trg_BeamSatteliteCast, Condition(function BeamSatteliteCond))
    call TriggerAddAction(gg_trg_BeamSatteliteCast, function BeamSattelite)
    set p = null
endfunction