• 🏆 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!

[System] StructuredDD (Structured Damage Detection)

Level 29
Joined
Mar 10, 2009
Messages
5,016
Because Physical Damage Detection has this block of code:

JASS:
// Set damage variables  
        set rawAmount = GetEventDamage()
        if rawAmount == 0.0 then
            return
        endif
        set PDDS.source = GetEventDamageSource()
        set PDDS.target = GetTriggerUnit()

I already answered this question.

very true, but why cant you support to make it that way?, it would be better since this is my first choice also if it registers correctly...
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,522
very true, but why cant you support to make it that way?, it would be better since this is my first choice also if it registers correctly...

I do register correctly; everything else does not. If you want to ignore damage events with 0 damage, you can do it yourself.

JASS:
If GetEventDamage() == 0.0 then
    return
endif

Conversely, other damage detection engines cannot get back that 0 damage event.
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,522
- There should be a check in .add to see if a unit is already added imo.

That would be terrible and defeat the purpose of the system (performance improvements) - however, I do agree that a "isAdded" method would be useful.

- Can't you add a unit to a specific handler

No, you're talking about a performance optimization which isn't the system's intention (it would require a total restructuring of the code and remove other optimization)

if not, whats to point with that functionality?

readability, DRY principles, no change to running time complexity

Then you might as well remove it and stick to custom events.

That would be garbage and defeat the purpose. I may as well use plain JASS.
 
Level 2
Joined
Aug 11, 2009
Messages
22
I love you. This is exactly what I was looking for. A simple DDS with an easy implementation.

EDIT: A couple of questions though: 1. how do I use conditions with this? I'm fairly new to JASS and vJASS and don't know how these handlers work exactly. What I tried and what worked so far is using an if statement in the function called by the handler. Is this the way to go?
2. if you kill a unit, it doesn't return the damage that was needed to kill the unit, but the damage done (= includes overdamage). Is it supposed to be like that? And how would I get the damage needed to kill the unit? Make an if argument with a real comparison (GetWidgetLife vs GetEventDamage)?
 
Last edited:

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,522
I love you. This is exactly what I was looking for. A simple DDS with an easy implementation.

EDIT: A couple of questions though:

Hi NaughtySmurf, thanks for taking a look at this. I apologize for not getting back to you sooner - I read the email notification from this post, and didn't notice that you edited it with a question.

1. how do I use conditions with this? I'm fairly new to JASS and vJASS and don't know how these handlers work exactly. What I tried and what worked so far is using an if statement in the function called by the handler. Is this the way to go?

It sounds like you have the hang of it, yes. This script exposes very little new API to the user - instead, it acts as a safe wrapper to the natives provided by jass. If you want to access the attacking unit, attacked unit, or damage dealt, use GetEventDamageSource(), GetTriggerUnit, and GetEventDamage(). In future, I suggest asking for help in the help forum.

2. if you kill a unit, it doesn't return the damage that was needed to kill the unit, but the damage done (= includes overdamage). Is it supposed to be like that? And how would I get the damage needed to kill the unit? Make an if argument with a real comparison (GetWidgetLife vs GetEventDamage)?

When the damage handler enters the context of the damaged unit, that unit still has the life it had before it died. So using GetWidgetLife() will return the damage "needed" to kill it, whether it dies or not.

---

I've updated the code's style and documentation to reflect the last few years of neglect. The API is unchanged.
 
Top