• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Creating a DoT spell in Jass.

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hello ppl.
I'm working on a spell, but it needs to be a triggered DoT. But I'm not good at making jass. Could someone add the DoT effect to this?
Atm its dealing instant Intelligence of hero in damage. But it has to do HeroLevel * 30 damage over 9 seconds too. It doesn't matter if it is damage per second or damage per 3 seconds. As long as it damages HeroLevel * 30 over 9 seconds.
I would really appreciate it, because if you'll do this for me I can use it for other spells in future too.

Here's the spell:
Curse of Death.
Deals Intelligence * 1 death damage to the target and an other Level * 30 death damage over 9 seconds. The target's chance to miss is reduced by 10% for the duration. (miss effect is from Curse, which is the spell that's being triggered)

JASS:
function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00R' ) ) then
        return false
    endif
    return true
endfunction

function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real d = I2R(GetHeroInt(u, true))
    local real dd = I2R(GetHeroLevel(u))
    call UnitDamageTargetEx(u, t, d, ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, false)
endfunction

//===========================================================================
function InitTrig_Curse_of_Death takes nothing returns nothing
    set gg_trg_Curse_of_Death = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Curse_of_Death, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Curse_of_Death, Condition( function Conditions ) )
    call TriggerAddAction( gg_trg_Curse_of_Death, function Actions )
endfunction

PS. Don't watch the call UnitDamageTargetEx. It's for a damage detection system so I can make spells and melee attacks crittable with different crit chances. Just use UnitDamageTarget(...) or however you're going to do it, I will change it a bit to UnitDamageTargetEx.
 
Level 5
Joined
Dec 18, 2007
Messages
205
Best thing to do this is with a timer i think, but i have no knowledge in creating timers.
i would do this via a simple loop, but a timer is more efficent.
 
Level 10
Joined
Jun 16, 2007
Messages
415
I'll help you. First of, you've obviously converted this from a trigger not written it from start, which I don't recommend since it slows your learning process and teaches you a long and inefficient syntax.

Secondly, you have two functions named Actions and Conditions, which really aren't good names for a function, they should be like CurseOfDeathCond or so, since this won't conflict with other functions or conditions.

Also, I recommend that you aquire the H2I script as it is extremely useful for timers and functions that run over time. Also, try and get JassCraft, as it can easily correct your syntax and is a good way to learn JASS

Since you aren't using H2I, you will have to use loops to make this work, which isn't as elegant but still works:

JASS:
function CoD_Cond takes nothing returns boolean
    if GetSpellAbilityId() != 'A00R' then
        return false
    endif
    return true
endfunction

function CoD_Actions takes nothing returns nothing
    local unit t = GetSpellTargetUnit()
    local integer i = 1
    call UnitDamageTargetEx(GetTriggerUnit(), t, I2R(GetHeroInt(u, true)), ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, false)
    loop
        exitwhen i > 9
        call UnitDamageTargetEx(GetTriggerUnit(), t, I2R(GetHeroLevel(GetTriggerUnit())*30), ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, false)
        set i = i + 1
        call TriggerSleepAction(1) //or use PolledWait(1)
    endloop
    set t = null
endfunction

//===========================================================================
function InitTrig_Curse_of_Death takes nothing returns nothing
    set gg_trg_Curse_of_Death = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Curse_of_Death, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Curse_of_Death, Condition( function Conditions ) )
    call TriggerAddAction( gg_trg_Curse_of_Death, function Actions )
endfunction

This should work. Since GetTriggerUnit() is a local for all I know, you do not to declare u, and therefore neither d or dd.
 
Level 6
Joined
Sep 5, 2007
Messages
264
JASS:
    loop
        exitwhen i > 9
        call UnitDamageTargetEx(GetTriggerUnit(), t, I2R(GetHeroLevel(GetTriggerUnit())*30), ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, false)
        set i = i + 1
        call TriggerSleepAction(1) //or use PolledWait(1)
    endloop

Problems occur when using GetTriggerUnit() with any kind of wait, set it to a local variable like you did with GetSpellTargetUnit(), otherwise any other trigger may cause this one to think that a different unit casted the spell.

IE: If another ability trigger activates, then GetTriggerUnit() will return THAT casting unit, NOT the one that started this trigger...

The way that Teuncreemers declared the local variables, was better:
JASS:
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real d = I2R(GetHeroInt(u, true))
    local real dd = I2R(GetHeroLevel(u))
This way is more efficient, it doesn't rely on multiple function calls every loop, also it is far less likely to bug or crash.

Also use this as your condition function:
JASS:
function CoD_Cond takes nothing returns boolean
    return (GetSpellAbilityId() != 'A00R')
endfunction
 
Level 5
Joined
Dec 18, 2007
Messages
205
one more important thing at your code (Hoernchen) is that if you level up the ability while it is casting, it deals more damage and it should only do more damage when it is leveled up and casted again, so you should create locals for the level.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Thanks for the help people. I repped you for it!
I've got JassCraft and I'm learning a bit of jass atm, but I prefer to work more on my map then to learn as much jass as possible. Atm I just learn what I need for my map. And I think this is enough for now, thanks alot!
I go implement it in the map now!
 
Level 16
Joined
Feb 22, 2006
Messages
960
ok for your learning process i give u a little tip
JASS:
function InitTrig_Curse_of_Death takes nothing returns nothing
  local trigger cod = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( cod, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( cod, Condition( function Conditions ) )
    call TriggerAddAction( cod, function Actions )
  set cod = null
endfunction

use a local var in the init function to prevent leaks, because triggers also belongs to handles and have to be nullified :)

and also i addvise you to use timers for a dot spell, in the beginning use maybe HandleVar system if you are better with JASS start learning the using of vJass, even if you don't know vJass , download the jassnewgenpack, the trigger editor is much better for jass, and i read you use JassCraft... it's a realy good tool to learn how to trigger jass

.... ok so far :p
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
ok for your learning process i give u a little tip
JASS:
function InitTrig_Curse_of_Death takes nothing returns nothing
  local trigger cod = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( cod, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( cod, Condition( function Conditions ) )
    call TriggerAddAction( cod, function Actions )
  set cod = null
endfunction

use a local var in the init function to prevent leaks, because triggers also belongs to handles and have to be nullified :)

and also i addvise you to use timers for a dot spell, in the beginning use maybe HandleVar system if you are better with JASS start learning the using of vJass, even if you don't know vJass , download the jassnewgenpack, the trigger editor is much better for jass, and i read you use JassCraft... it's a realy good tool to learn how to trigger jass

.... ok so far :p


thanks. I'm using Jass newgen world editor already. I always call that Jass, but guess it's called vJass:).
Thanks for the nulling of the trigger tip. I will do that more now.


And thanks to moyack for the handy tutorial. I will try to save the info in my head, but sometimes jass is still making my head crash a bit;-)

thanks both!
Teuncreemers
 
Status
Not open for further replies.
Top