• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Damage over time trigger

Status
Not open for further replies.
Level 16
Joined
Feb 22, 2006
Messages
960
So I'm a newbie in jass and so i tried my best with this, and my question is, is there a better way to do it

i noticed it starts to lag when the spell is 5 times active

JASS:
function dot_action takes nothing returns nothing
 local unit caster = GetSpellAbilityUnit()
 local unit target = GetSpellTargetUnit()  
 local real damage = ( ( GetUnitAbilityLevelSwapped('A000', caster) * 10 ) + GetHeroInt(caster,true) )
 local integer start = 0
 local integer stop = 5
    
    loop
        exitwhen start > stop
        call UnitDamageTarget(caster,target,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        call TriggerSleepAction(3.00)
        set start = start + 1
    endloop 
 set caster = null
 set target = null
endfunction

function Condition_Function takes nothing returns boolean
  return GetSpellAbilityId() == 'A000'
endfunction

function InitTrig_dot takes nothing returns nothing
  local trigger dot= CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(dot,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(dot,Condition(function Condition_Function))
    call TriggerAddAction(dot,function dot_action)
  set dot = null    
endfunction
 
Last edited:
Level 4
Joined
Aug 9, 2004
Messages
70
Try to use native TriggerSleepAction(real duration) istead of function PolledWait.
I did not understand why it lag but natives are faster than functions, so it may work for you. Just replace;
call PolledWait(3.00) with
call TriggerSleepAction(3.00)

Tell me if it works.
 
Status
Not open for further replies.
Top