How can I detect if the damage is from a normal attack?

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
Yeah, yeah I know how to detect the damages but

How? How can I detect if the damage is from a normal attack only?
:confused::nuts::banghead::D
 

Komaqtion

You can change this now in User CP.
Reaction score
469
That isn't possible, unless you use Damage, by Jesus4Lyf...

And even with using that, you'll need to deal ALL damage using a few "natives" (They're not really natives, but they do the same as the natives and also provide some information to the system...) so it's quite complicated...
 

Viikuna

No Marlo no game.
Reaction score
265
The proper way is to do all damage but normal attacks with triggers.

Most of damage detection systems have some functions and thingies for supporting that stuff.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
How can I detect if the damage is from a normal attack only?
If you're willing to give up the use of most, if not all, orb effects and buff-placers, give every unit a hidden ability based on, say, Slow Poison, and check whether the damaged unit has that buff (and if it does, remove the buff as the first thing in the trigger, of course.)
 

Viikuna

No Marlo no game.
Reaction score
265
The system posted by Troll-Brain is broken for recursive damage, just a warning.

Its not broken. You just need to know how to attach the source where damage was done to damage:


JASS:


globals
    private boolean ItWasMe=false
endglobals


function onDamage takes nothing returns nothing
    if not ItWasMe then
        set ItWasMe=true
        call DealSomeNiceAndSmoothDamage()
        set ItWasMe=false
    endif
endfunction


Damn yo, you might even wanna do this for some weird reason:


JASS:

globals
   private  boolean ItWasMe=false
   private  integer Counter=0
endglobals


function onDamage takes nothing returns nothing
    if not ItWasMe then
        if UnitHasBuffOfType(thisunit,somebuff)
             if Counter>X then // its some lame and cool loop, ey. Isnt that awesome?
                   set Counter=0
                   set ItWasMe=true
                   call DealSomeNiceAndSmoothDamage(thisunit)
                   set ItWasMe=false
             else
                   call DealSomeNiceAndSmoothDamage(thisunit)
                   set Counter=Counter+1
             endif
        else
            set ItWasMe=true
            call DealSomeNiceAndSmoothDamage(thisunit)
            set ItWasMe=false
        endif
    endif
endfunction


So, its not broken. Also Dusks system has a damage type which is not detected by system, so you can use it instead of those private booleans. ( But if you do, the damage wont be detected by any other trigger either.. )

edit. Dont know if your system always ignores recursive damage, but if it does you should change it to way Dusks system works, because sometimes people might indeed wanna do some recursive damage.

edit2. I know that noone asked my opinion, but I just think that all this recursive damage bullshit is just some over protectism of noobs and people who lack common sense.

A good documentation which mentions these issues does way more good than some build in system features. ( Although that not-detected damage type is indeed nice in some cases I guess.)
 

Jesus4Lyf

Good Idea™
Reaction score
397
You completely misunderstood.
The system posted by Troll-Brain is broken for recursive damage, just a warning.
As in, the type detection is actually broken. Let's say you have two spells on a unit, event response 1: if physical, return 30% damage (as spell), event response 2: if physical, the hero spins dealing 200 damage to all units in 300 AoE.

In dusk's system, when the hero gets attacked, it will register that physical damage was dealt, and return 30% damage as spell, which will then run another instance where the damage dealt was spell, and when it continues to fire the second response, it will still think it is dealing spell damage, not physical. It should set the damage type back to physical.
This does not happen with Damage.

>Dont know if your system always ignores recursive damage
Recursive damage is vital and not a bug or broken. That's why IDDS is broken, its damage type detection is not stack based. It was part of what made me write Damage - there was no damage detection system that didn't break (for type checking). Indeed, my system is the only system I know of which supports it, and it is commonly used for damage-on-damage stuff (damage-on-damage is VERY common - that is recursive damage).
 

Viikuna

No Marlo no game.
Reaction score
265
Damn, thats quite clever I must say. I should have seen that possibility before.

But anyways, Dusks system is still not broken, because it uses priority events. You can use the lowest priority for recursive damage, so it wont mess up those damage events fired after it, because there is none.

--Okay, I understand that people have more than one recursive damage thing in their maps usually. So saying that your Damage system is the only one to handle recursive damage stuff properly seems pretty reasonable.

edit.

It seems that I was wrong. I tested these with Dusks system and it works fine:

JASS:
scope A initializer init

globals
    constant real debugduration= 5.
endglobals


// returns attack damage by 30% with magical damage type

private function StuffIsGoingOn takes nothing returns boolean
    if GetTriggerDamageType()==DAMAGE_TYPE_ATTACK then
        call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"A")
        call UnitDamageTargetEx(GetTriggerDamageTarget(),GetTriggerDamageSource(),GetTriggerDamage()*.3,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SPELL, false)
        call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"A-end")
    endif
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterDamageEvent(t,10)
    call TriggerAddCondition(t,Condition(function StuffIsGoingOn))
endfunction


endscope

scope B initializer init



// Displays message when unit takes magic damage

private function StuffIsGoingOn takes nothing returns boolean
    if GetTriggerDamageType()==DAMAGE_TYPE_SPELL then
        call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"B")
    endif
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterDamageEvent(t,10) // so this is registerted after A
    call TriggerAddCondition(t,Condition(function StuffIsGoingOn))
endfunction


endscope

scope C initializer init

globals
   private boolean ItWasMe=false
   private boolean ASD=true
endglobals

// Displays message when unit takes attack damage

private function StuffIsGoingOn takes nothing returns boolean
    if GetTriggerDamageType()==DAMAGE_TYPE_ATTACK and ASD then
        if not ItWasMe then
        // This is to replace your spin and damage example:
            set ItWasMe=true
            call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"C")
            call UnitDamageTargetEx(GetTriggerDamageSource(),GetTriggerDamageTarget(),10.,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_ATTACK, false)
            call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"C-end")
            set ItWasMe=false
        endif
    endif
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterDamageEvent(t,10) 
    call TriggerAddCondition(t,Condition(function StuffIsGoingOn))
endfunction


endscope


Im not sure if I missed something, but it displays messages correctly.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Replace in A:
JASS:
scope B initializer init

// Displays message when unit takes magic damage

private function StuffIsGoingOn takes nothing returns boolean
    if GetTriggerDamageType()==DAMAGE_TYPE_ATTACK then
        call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"A")
        call UnitDamageTargetEx(GetTriggerDamageTarget(),GetTriggerDamageSource(),GetTriggerDamage()*.3,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SPELL, false)
        if GetTriggerDamageType()==DAMAGE_TYPE_SPELL then
            call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"FAIL")
        endif
        call DisplayTimedTextToPlayer(Player(0),0.0,0.0,debugduration,"A-end")
    endif
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterDamageEvent(t,10) // so this is registerted after A
    call TriggerAddCondition(t,Condition(function StuffIsGoingOn))
endfunction

endscope

I can't test, but I expect "FAIL" displays... ignore the below if it doesn't. o_O
See, one might say "oh, that bug is not a problem who would do such a thing". But when I use Damage, I stack multiple conditions on one trigger to add multiple responses to the Damage event, it means you have less triggers (and well, it's more efficient). Obviously, this would not work at all with IDDS. So the event responses are broken and poorly written. Basically, after calling UnitDamageTargetEx, all your event responses are broken. Really nasty that that's not documented (unless I missed it).

Anyway, if you read the code, you will see exactly why I'd do such a thing if I were using IDDS - it wastes time setting variables in between each trigger fired by the event...
Like, surely you'd agree, it's just done wrong. The bug doesn't even need recursion to occur.

PS. By the way, the bug is completely fixable. Dusk just needs to see how it's done in my sys.
 

Viikuna

No Marlo no game.
Reaction score
265
It displays no FAIL message. If you want me to post my testcode or testmap I can do that, but I think you should try this by yourself, because I dont really know anymore what to look for and Im getting pretty confused, to be honest.

edit. It seems that IDDS handles damage as somekind of packets with somekind of stack method. My brain cant handle this stuff right now, but I guess theres some thingy that makes that stuff work properly.

edit2. I take my words back. It just allocates an unique integer for each packet, and uses than integer as an array index, so you can change packets damage amount and damage type without fucking things up.

edit3. Packets original damage type and amount are stored to locals, so thats why it doesnt matter that that global changes when doing recursive damage, unless you use those functions provided by IDDS, which are to change those things and changes those locals too. ( So that edit2. should have been: ..to make changing packets damage type and amount possible, or something )

Or some stuff like that.
 

Viikuna

No Marlo no game.
Reaction score
265
Its basicly this:

JASS:
local integer d  = DamageType


and this inside the loop:

JASS:
set DamageType        = d


d holds the original damage typr of packet. Recursive damage cant fuck it up.

If you decide to change packets damage type, its done here:

JASS:
if NewDamageType[id] >= 0 then
     //Update damagetype if it was changed
     set d = NewDamageType[id]
endif



Thats pretty cool actually. Together with priority events you can even change damage type for some spell or something.

One of IDDS testmap triggers is about that:

JASS:
scope DamageSwapPassive initializer Init
private function Conditions takes nothing returns boolean
    return GetTriggerDamageType() == DAMAGE_TYPE_ATTACK and GetRandomInt(1, 100) <= 50
endfunction

private function Actions takes nothing returns nothing
    call BJDebugMsg("Damage type swapped to FLAME!")
    call SetDamageType(DAMAGE_TYPE_FLAME)
endfunction

private function Init takes nothing returns nothing
    local trigger trg = CreateTrigger()
    call TriggerAddAction(trg, function Actions)
    call TriggerAddCondition(trg, Condition(function Conditions))
    call TriggerRegisterDamageEvent(trg, 0) 
    set trg = null
endfunction
endscope


Notice that 0 priority. This is run before anything else. Priorities are pretty useful for other stuff too.

With priorities you can do this:

Damage modifiers > Damage Blocking > Critical Strike > LifeSteal.

In otherwords you make sure that you dont life steal damage that is blocked, but you life steal extra damage from damage modifiers and critical strike.

( You can deal the actual extra damage with damage type that is not detected by system and/or restore units health if it takes too much damage and stuff like that to make damage modifier stuff actually work. )
 

Jesus4Lyf

Good Idea™
Reaction score
397
>d holds the original damage typr of packet. Recursive damage cant fuck it up.
See, that's why it can't work. It sets the global vars before each thing it fires. What if something it fires fires that loop, setting the global, and then tries to read it again afterwards...

I'll just make a mental note to check this stuff next time I get a shot.
 

Viikuna

No Marlo no game.
Reaction score
265
If something fires inside loop, it just fires that function again, and that function will have its own locals, which makes it "MUI".

Recursive damage can get between [lJASS]call TriggerExecute(Trg[1])[/lJASS] and [lJASS]call TriggerExecute(Trg[2])[/lJASS], but nothing can get between [lJASS]set DamageType = d[/lJASS] and [lJASS]call TriggerExecute(Trg)[/lJASS].

It would be different if DamageType was set before the loop, but since its set inside the loop it works.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top