• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Spell damaging corpses

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
JASS:
function Caladbolg_Conditions takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_Caladbolg))
endfunction

function Caladbolg_Move takes nothing returns nothing
    local location sp0
    local location sp1
    local group tg
    local boolexpr b = Condition(function Caladbolg_Conditions)
    set sp0 = GetUnitLoc(udg_Caladbolg)
    set tg = GetUnitsInRangeOfLocMatching(100.00, sp0, b)
    if IsUnitGroupEmptyBJ(tg) == false then
        call UnitDamageTarget( udg_PlayerHero[GetConvertedPlayerId(GetOwningPlayer(udg_Caladbolg))], GroupPickRandomUnit(tg), ( 120.00 * I2R(GetUnitUserData(udg_Caladbolg)) ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null )
        call SetUnitUserData( udg_Caladbolg, 0 )
        call RemoveUnit( udg_Caladbolg )
        set udg_Caladbolg = null
        set udg_caladbolgtime = 0
        call DisableTrigger( GetTriggeringTrigger() )
        call RemoveLocation(sp0)
        set sp0 = null
        call RemoveLocation(sp1)
        set sp1 = null
        set b = null
    elseif udg_caladbolgtime >= 2000 then
        call SetUnitUserData( udg_PlayerHero[GetConvertedPlayerId(GetOwningPlayer(udg_Caladbolg))], 0 )
        call RemoveUnit( udg_Caladbolg )
        set udg_Caladbolg = null
        set udg_caladbolgtime = 0
        call DisableTrigger( GetTriggeringTrigger() )
        call RemoveLocation(sp0)
        set sp0 = null
        call RemoveLocation(sp1)
        set sp1 = null
        set b = null
    else
        set udg_caladbolgtime = (udg_caladbolgtime + 32)
        set sp1 = PolarProjectionBJ(sp0, 32.00, GetUnitFacing(udg_Caladbolg))
        call SetUnitPositionLoc( udg_Caladbolg, sp1 )
        call RemoveLocation(sp0)
        set sp0 = null
        call RemoveLocation(sp1)
        set sp1 = null
        set b = null
    endif
endfunction

//===========================================================================
function InitTrig_Caladbolg_Move takes nothing returns nothing
    set gg_trg_Caladbolg_Move = CreateTrigger( )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Caladbolg_Move, 0.04 )
    call TriggerAddAction( gg_trg_Caladbolg_Move, function Caladbolg_Move )
endfunction

This trigger makes the arrow moves and deals damage if something goes in the way, but if there is a corpse between you and your target, the arrow vanish in the corpse...
 
Level 27
Joined
Feb 22, 2006
Messages
3,052
JASS:
function Caladbolg_Conditions takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_Caladbolg)) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 1
endfunction
Note that 1 isn't the lowest you can go and still be alive, it's like .403 or something, but I forgot exactly.
--donut3.5--
 
Status
Not open for further replies.
Top