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

Damage Detection question

Status
Not open for further replies.
Level 22
Joined
Feb 6, 2014
Messages
2,466
Is this kind of damage detection bad? Don't focus on the Map Init leak, but instead on the method.
  • Initial Register
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Detect Damage <gen> the event (Unit - (Picked unit) Takes damage)
  • Register Unit
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Detect Damage <gen> the event (Unit - (Triggering unit) Takes damage)
  • Detect Damage
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Damage Taken by + (Name of (Triggering unit)))
 
Level 12
Joined
May 22, 2015
Messages
1,051
This is what I am doing. I don't know what other systems do. I started from here and built the rest of the stuff based on my needs (with some help around these forums).
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
It does detect damage but it is not damage detection system. For example how are you going to negate the damage unit takes when it has full hp? The event fires before the damage is applied so simply doing hp+dmg_taken will get you nowhere.
Another problem rises with the event itself. When a unit dies - or when it is even removed, the event still remains, pointing at no unit at all. This creates a large list of non-existing units over time, slowing down the trigger as it has to get through the whole list of units assigned to the trigger whenever any unit takes damage. This may not seem like a problem at start of map, but over time this will pile up. Worst case, this ends up with the trigger collapsing and not working correctly.
A DDS uses jass to destroy and re-create the trigger, as that is the only way to remove events from a trigger.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Well it is the start of one. There is just more work to do with it if you want to make it capable of doing everything.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
It does detect damage but it is not damage detection system. For example how are you going to negate the damage unit takes when it has full hp? The event fires before the damage is applied so simply doing hp+dmg_taken will get you nowhere.
A Damage Detection System detects damage... nothing more.
So negating damage or whatever is not a main part of it.
However it is a nice feature which has to be made by the DDS to be able to use it properly.

@Nichilus I see. That was the answer I was looking for. So each units has its own trigger then when the unit dies or gets removed, the trigger is destroyed
Not necessarily.
The problem of having one trigger is that you have to add every single unit in the map to it when you refresh it.
However when using FirstOfGroup() iteration, this operation is done within the blink of an eye even with 3k units on the map.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
A Damage Detection System detects damage... nothing more.
So negating damage or whatever is not a main part of it.
However it is a nice feature which has to be made by the DDS to be able to use it properly.


Not necessarily.
The problem of having one trigger is that you have to add every single unit in the map to it when you refresh it.
However when using FirstOfGroup() iteration, this operation is done within the blink of an eye even with 3k units on the map.

I agree, a DDS main purpose is to detect the damage. So if it detects the damage, it can be called a Damage Detection System.


I meant having one trigger for each unit. Is that what DDS do? They create each trigger for each unit and when the unit is already removed from the map, they destroy the trigger to delete the Event?
EDIT: By quick inspection on PDD, looks like LFH used a periodic timer to refresh the trigger so I think that is the better way to remove the events. That way, he only used a single trigger and just periodically re-creates it removing the unnecessary Events in the process.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
My DDS uses only one trigger for all units and refreshes it every ... seconds.
By default it refreshes every 60 seconds.

Using one trigger: Less triggers = less data = less ram
Using multiple triggers: No performance lagg spike on refresh because there is no refresh.

I prefer to have the first one cause the "lagg spike" really is almost equal to 0.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
My DDS uses only one trigger for all units and refreshes it every ... seconds.
By default it refreshes every 60 seconds.

Using one trigger: Less triggers = less data = less ram
Using multiple triggers: No performance lagg spike on refresh because there is no refresh.

I prefer to have the first one cause the "lagg spike" really is almost equal to 0.

Ahh, same as looking_for_help's PDD, and the same refresh rate too. The "lag spike" can vary depending on the current number of units in the map so I can't really say if it is almost 0.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Dude, I said a blink of an eye with 3,000 units... that is 3,000/12=250 units per player, which is an average of 250*2=500 food, which is an average of 166.66% of the hardcoded maximum.

So with your nice amount of 100-200 units on the map, I can ensure you that you wont notice the refresh :)
 
Status
Not open for further replies.
Top