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.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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