• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Damage over time - spell help

Status
Not open for further replies.
Level 3
Joined
Jul 24, 2007
Messages
40
Can someone explain to me how to create a MUI damage over time spell? This is what i have...i think it doesn't work becuase
JASS:
GetSpellTargetUnit()
doesnt work after
JASS:
call TriggerSleepAction
.
any help would be appreciated.

JASS:
function Trig_Crucify_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction


function dot takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
call UnitDamageTarget(caster, target, 6 * GetUnitAbilityLevel(caster, 'A003'), true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
endfunction 

function Trig_Crucify_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()  
local real mana = GetUnitState(target,UNIT_STATE_MANA)
local real manadeduced = 1 - (.1 * GetUnitAbilityLevel(caster, 'A003'))
local real x = GetUnitX(target)
local real y = GetUnitY(target)
local effect e1
local timer t = CreateTimer()

set e1 = AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",x,y)
call UnitDamageTarget(caster, target, 30 * GetUnitAbilityLevel(caster, 'A003'), true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
call SetUnitManaBJ( target, (mana * manadeduced))
call DestroyEffect(e1)
call TimerStart(t,1,true,function dot)
call TriggerSleepAction(15)
call DestroyTimer(t)

//Clean
set caster = null
set target = null
set e1 = null
set t = null
endfunction

//===========================================================================
function InitTrig_Crucify takes nothing returns nothing
    set gg_trg_Crucify = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Crucify, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Crucify, Condition(function Trig_Crucify_Conditions))
    call TriggerAddAction( gg_trg_Crucify, function Trig_Crucify_Actions )
endfunction
 
Level 5
Joined
Aug 27, 2007
Messages
138
This won't work:

JASS:
function dot takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
call UnitDamageTarget(caster, target, 6 * GetUnitAbilityLevel(caster, 'A003'), true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
endfunction

If you choose to use a timer to do the damage, then you'll have to set handles to store the units. There's a simpler way to do this, though, and it's through a loop. Here's your trigger done with a loop, with some miscellaneous modifications made:

JASS:
function Trig_Crucify_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real mana = GetUnitState(target,UNIT_STATE_MANA)
    local integer l = GetUnitAbilityLevel(caster, 'A003')
    local real manadeduced = 1 - (.1 * l)
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local integer i = 0
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",x,y))
    call UnitDamageTarget(caster, target, 30 * l, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
    call SetUnitState( target, UNIT_STATE_MANA, mana * manadeduced)
    loop
        exitwhen i = 15
        call UnitDamageTarget(caster, target, 6 * l, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
        call TriggerSleepAction(1.00)
        //You can use a polled wait here if you prefer
        set i = i + 1
    endloop
//Clean
set caster = null
set target = null
endfunction

Here are the the reasons for the other changes:
-SetUnitManaBJ() is better done by the native SetUnitState.
-GetUnitAbilityLevel(caster, 'A003') is called three times. It's faster to call it once and set it as a variable.
-The effect variable was unnecessary. If you do DestroyEffect(AddSpecialEffect()), it still plays the birth animation.

Hope I helped.
 
Last edited:
Status
Not open for further replies.
Top