System DamageUnitOverTime

Matrix

New Member
Reaction score
5
This system allows u not only to damage units over time but also to create special effects and to make the damage non stackable! These are the features of the system

So Pros:
1) System uses structs and not cache
2) System allows u to create speciall effects
3) System allows u to make it non-stackable

Cons:
1) System uses JassNewgenPack
2) System requires CSData+CSSafety

JASS:
//**********************************************************
//*                                                        *
//*         D A M A G E  T A R G E T  O V E R  T I M E     *
//*                       Actual Code                      *
//*                        v1.01                           *
//*                                                        *
//*                      By: Matrix                        *
//*                                                        *
//**********************************************************
library DamageTargetOverTime uses CSSafety
private struct data
unit c
unit u
timer t
real dmg
boolean attack
boolean ranged
damagetype DamageType
attacktype AttackType
weapontype WeaponType
real runned
real duration
real howoften
integer Buff
string Effect
string where
string stack
effect e
static method create takes unit c, unit u, real dmg, boolean attack, boolean ranged, attacktype AttackType, damagetype DamageType, weapontype WeaponType, real duration, real howoften, string stack,integer Buff, string Effect, string where returns data
    local data dat = data.allocate()
    local data d = GetCSData(u)
    if stack!=null and stack==d.stack then
       call data.destroy(d)
    endif
    set dat.t = NewTimer()
    set dat.u = u
    set dat.c = c
    set dat.dmg = dmg
    set dat.attack=attack
    set dat.ranged=ranged
    set dat.AttackType=AttackType
    set dat.DamageType=DamageType
    set dat.WeaponType=WeaponType
    set dat.duration = duration
    set dat.howoften=howoften
    set dat.Buff=Buff
    set dat.Effect=Effect
    set dat.where=where
    set dat.stack=stack
    set dat.runned=0
    if (Effect!=null or Effect!="") and (where!=null or where!="") then
       set dat.e=AddSpecialEffectTarget(Effect,u,where)
    endif
    call SetCSData(dat.t,dat)
    call SetCSData(u,dat)
    return dat
endmethod
method onDestroy takes nothing returns nothing
call DestroyEffect(.e)
call ReleaseTimer(.t)
endmethod
endstruct
private function Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local data dat = GetCSData(t)
    set dat.runned=dat.runned+dat.howoften
    if dat.runned>=dat.duration or GetUnitState(dat.u,UNIT_STATE_LIFE)<=.405 or (dat.Buff!=0 and GetUnitAbilityLevel(dat.u,dat.Buff)==0) then
       call data.destroy(dat)
    else
       call DestroyEffect(dat.e)
       set dat.e=AddSpecialEffectTarget(dat.Effect,dat.u,dat.where)
       call UnitDamageTarget(dat.c, dat.u, dat.dmg, dat.attack, dat.ranged, dat.AttackType, dat.DamageType, dat.WeaponType)
    endif
    set t = null
endfunction
function SetAttackType takes unit target, attacktype AttackType returns nothing
local data dat = GetCSData(target)
set dat.AttackType=AttackType
endfunction
function SetDamageType takes unit target, damagetype DamageType returns nothing
local data dat = GetCSData(target)
set dat.DamageType=DamageType
endfunction
function SetDamage takes unit target, real amount returns nothing
   local data dat = GetCSData(target)
   set dat.dmg=amount
endfunction
function SetDuration takes unit target, real duration returns nothing
   local data dat = GetCSData(target)
   set dat.duration=duration
endfunction
function SetEffect takes unit target, string Effect, string where returns nothing
   local data dat = GetCSData(target)
   set dat.Effect = Effect
   set dat.where = where
endfunction
function DamageOverBuffEx takes unit whichUnit, unit target, real amount, boolean attack, boolean ranged, attacktype AttackType, damagetype DamageType, weapontype WeaponType, real howoften,integer Buff,string stack, string Effect, string where returns nothing
call TimerStart(data.create(whichUnit, target,amount,attack,ranged, AttackType, DamageType,WeaponType, 9999999, howoften,stack, Buff,Effect, where).t, howoften, true, function Child)
endfunction
function DamageOverBuff takes unit whichUnit, unit target, real amount, attacktype AttackType, damagetype DamageType, integer Buff, real howoften returns nothing
call TimerStart(data.create(whichUnit, target,amount,true,false, AttackType, DamageType, null, 99999999, howoften,null,Buff,"","").t, howoften, true, function Child)
endfunction
function DamageOverTimeEx takes unit whichUnit, unit target, real amount, boolean attack, boolean ranged, attacktype AttackType, damagetype DamageType, weapontype WeaponType, real duration, real howoften,string stack, string Effect, string where returns nothing
call TimerStart(data.create(whichUnit, target,amount,attack,ranged, AttackType, DamageType,WeaponType, duration, howoften,stack,0, Effect, where).t, howoften, true, function Child)
endfunction
function DamageOverTime takes unit whichUnit, unit target, real amount, attacktype AttackType, damagetype DamageType, real duration, real howoften returns nothing
call TimerStart(data.create(whichUnit, target,amount,true,false, AttackType, DamageType, null, duration, howoften,null,0,"","").t, howoften, true, function Child)
endfunction
endlibrary
Download DamageUnitOverTime
 

Flare

Stops copies me!
Reaction score
662
Why are you using a string for stacking? Why not use a boolean? The stacking option is pretty restricting too since it's all or nothing (i.e. separate spells can conflict if the stack option is true). IMO, a buff/ability-check would be much more effective, e.g.
JASS:
//Take a buffer skill argument (this is taken from a DoT system I made for myself)
public function Start takes unit caster, unit target, real dps, real dmgint, real duration, string sfx, string attachpt, integer bskillid, integer bid, attacktype at, damagetype dt, weapontype wt returns nothing

//And the stack check
        if GetUnitAbilityLevel (data<i>.target, bskillid) &gt; 0 and data<i>.target == target then
            set data<i>.caster = caster
            set data<i>.target = target
            set data<i>.dps = dps
            set data<i>.dmgint = dmgint
            set data<i>.curdur = 0
            set data<i>.maxdur = duration
            set newinstance = false
            set skiploop = true
        endif

</i></i></i></i></i></i></i></i>


That will allow separate spells to stack with each other as intended, but the same spell will not stack, and it allows for the use of a buff :)

JASS:
attacktype AttackType

H2I(AttackType)

ConvertAttackType(dat.AttackType)


Please, explain why you are doing all that? Why not just store the attacktype as a struct member of type attacktype rather than using stuff that you don't even need
 

Matrix

New Member
Reaction score
5
because in CSData something was that its not good to store attactype and damagetypes if I understand right?

string is because if u dont want to stack the damge from the spell frostnova u write 'frostnova" and whe u dont want to stack damge from burningspear u write "burningSpear" but if u just write true or false it will not stack with all spells which isn't good
 

Flare

Stops copies me!
Reaction score
662
because in CSData something was that its not good to store attactype and damagetypes if I understand right?

Store it as a struct member -.-' You aren't actually attaching data to the attacktype, damagetype or weapontype, you are only attaching to timer and unit (and that won't change)

string is because if u dont want to stack the damge from the spell frostnova u write 'frostnova" and whe u dont want to stack damge from burningspear u write "burningSpear" but if u just write true or false it will not stack with all spells which isn't good

Ah, never thought of it that way, nice idea :p
 

Matrix

New Member
Reaction score
5
Store it as a struct member -.-' You aren't actually attaching data to the attacktype, damagetype or weapontype, you are only attaching to timer and unit (and that won't change)

will be fixed. (in few days)

thx for reply =)
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
> 2) System requires CSData+CSSafety
That's not a Con.
> 1) System uses JassNewgenPack
that's not a Con either.

It would be better if you use a buff check, because with buffs you can stop the dps with an ability (like Dispell and such) and thus make it balanced for melee games. But if you use a buff check you need to think of how to use it with abilities with projectiles (such as Acid Bomb), because they give a buff after some time. :rolleyes:

JASS:
call PauseTimer(.t)
call ReleaseTimer(.t)

Isn't it paused with ReleaseTimer? Why do you pause it 2 times?

Plus, some people may want to change values during the effect. Why not include methods like SetDamage, SetAttackType, SetEffect?

And please indent your code. It's horrible in this way.. :/
 

Flare

Stops copies me!
Reaction score
662
JASS:
private function Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local data dat = GetCSData(t)
    set dat.runned=dat.runned+dat.howoften
    if dat.runned&gt;=dat.duration or GetWidgetLife(dat.u)&lt;=.405 then
       call data.destroy(dat)
    else
       call DestroyEffect(dat.e)
       set dat.e=AddSpecialEffectTarget(dat.Effect,dat.u,dat.where)
       call UnitDamageTarget(dat.c, dat.u, dat.dmg, dat.attack, dat.ranged, ConvertAttackType(dat.AttackType), ConvertDamageType(dat.DamageType), ConvertWeaponType(dat.WeaponType))
       call SetCSData(t,dat)
    endif
endfunction


Why are you re-attaching data to the timer? I see no reason to do it, the data isn't going anywhere.

And you didn't null t
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top