• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Problem with simple Damage Detection System

Status
Not open for further replies.
Level 9
Joined
Dec 6, 2007
Messages
233
In a map i'm working on, all of the damage is triggered, so I'm using a basic DDS to stop non-triggered attacks from causing damage.

  • DDS Event Adder
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to DDS <gen> the event (Unit - (Triggering unit) Takes damage)
  • DDS
    • Events
    • Conditions
    • Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
Works, except not the first time a unit receives damage. It doesn't begin activating until after the unit has already been damaged once. Can anyone explain how to fix this?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Unit takes damage event runs before the life is actually reduced.

You're adding the life before the damage is reduced from the unit's hit points. You need to add max hp and then reset it after 0.00 second timer expires in addition of calculating the damage.

Use http://www.hiveworkshop.com/forums/spells-569/gui-damage-engine-201016/ to make things easier for you.
 
Level 9
Joined
Dec 6, 2007
Messages
233
Grr, I don't like using things I didn't make, but thanks for the help maker. The DDS still works for triggering attack triggers, but the events leak. Is there a custom script function perhaps for clearing the events out? Or must I use the damage engine for that as well?
 

Br0

Br0

Level 4
Joined
May 4, 2012
Messages
102
  • DDS Event Adder
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to DDS <gen> the event (Unit - (Triggering unit) Takes damage)
  • DDS
    • Events
    • Conditions
    • Actions
      • Wait 0.00 seconds
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
That should fix it, however incase of the same unit able to come back to the map such as being a hero or ressurection or animate dead you should add all units to a unit group, and check to see if they're in that unit group so they don't get added again to the trigger.

Edit: You can't really clean event leaks in GUI I know for sure, but in JASS I do not know however you can avoid the limit where the leaking events cause Wc3 to automatically shutdown since event leaks do not cause lag or anything else besides a limit where it hits then blows up. To do this all you have to do is make dummy triggers I call it which is multiple copies of the same trigger, and you use an integer to detect when that trigger has hit around 8000 then start adding to another trigger with the same actions, and conditions for it. Doesn't take much extra work, and works successfully as far as I know.
 
Level 9
Joined
Dec 6, 2007
Messages
233
I've tested your suggestions Br0
The Dummy trigger idea is great; I feel better about using the DDS for attack detection now. As for damage, It does prevent damage from normal attacks, but it has a noticeable delay before it heals the unit.
 

Br0

Br0

Level 4
Joined
May 4, 2012
Messages
102
I've tested your suggestions Br0
The Dummy trigger idea is great; I feel better about using the DDS for attack detection now. As for damage, It does prevent damage from normal attacks, but it has a noticeable delay before it heals the unit.

Make a life add and removal ability if your worried about the delay killing the unit before the heal can kick in. Glad to help.
 
Status
Not open for further replies.
Top