Simple damage detection [GUI] v2

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
This trigger function is one of the easiest way how to detect and possibly save damage that unit gets in real time.

I hope nobody uploaded similar function like this.


  • trigger "init"
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
  • trigger "Damage Source"
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Group = (Units in (Playable map area) matching ((Life of (Matching unit)) Not equal to (Load (Key life) of (Key (Matching unit)) from Hashtable)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in Group and do (Actions)
            • Loop - Actions
              • Set Real = (Load (Key life) of (Key (Picked unit)) from Hashtable)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Life of (Picked unit)) Less than Real
                • Then - Actions
                  • Set Real = (Real - (Life of (Picked unit)))
                  • Set Point = (Position of (Picked unit))
                  • Floating Text - Create floating text that reads (String(Real)) at Point with Z offset 0.00, using font size 9.00, color (100.00%, 10.00%, 10.00%), and 10.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 84.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable suspend state
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
                  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                  • Custom script: call RemoveLocation(udg_Point)
                  • Hashtable - Save (Life of (Picked unit)) as (Key life) of (Key (Picked unit)) in Hashtable
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of (Picked unit)) Greater than Real
                    • Then - Actions
                      • Hashtable - Save (Life of (Picked unit)) as (Key life) of (Key (Picked unit)) in Hashtable
                    • Else - Actions
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Group)


Created by DatnessX
Give credits if you use, thanks :)

Keywords:
function, trigger, GUI, simple, damage, detection, system, hitpoints, life, hp
Contents

Just another Warcraft III map (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. Simple damage detection [GUI] v2 | Reviewed by Maker | 3rd Aug 2013 NEEDS FIX [tr] A periodic check is not a proper way to detect damage We don't need yet another damage...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.


Simple damage detection [GUI] v2 | Reviewed by Maker | 3rd Aug 2013
NEEDS FIX


126248-albums6177-picture66522.png


  • A periodic check is not a proper way to detect damage
  • We don't need yet another damage detection system
    that does not surpass the already existing ones
[tr]
 
I hope nobody uploaded similar function like this.

It's been done quite a lot before.

By the way, 0.01 seconds is too low of a period. In Warcraft III, we use 0.03125 (or 0.03 in GUI because you can't have more than 2 digits after the decimal point :v.
33 frames per second is ideal for performance and visuals~

edit
Then again, I see what you're doing here. Don't do that, it's not scalable. It gets really slow with more units.
With 600 units, this is 600 times slower than with 1 unit.
Some of the damage detection systems on this site scale much better. Look at DamageEngine by Bribe, look at DDS by Nestharus, DamageEvent by Nestharus, StructuredDD by Cokemonkey, PhysicalDamageDetection by looking_for_help, GDD by Weep, etc...
 
Well, this is the simplest and fastest way how to do it.
The Every 0.01 second gametime can anybody change if use...
And the group does not picking if the life of some unit in the map is'nt changed,
so if you want 600x slower game, you need to attack with 600 units at the same time :)

i think it's quite different than functions from other ppl, so why not approve it :)
 
Different does not equate good :v

What you have here is not a damage detection system, but a damage-text system. I would highly recommend the usage of DamageEngine by Bribe to do the damage detection for you because it does it excellently, correctly, and everyone uses it, so this library would actually be more useful if it used it too.

You're evaluating the life of each unit 100 times per second inside a Group enumeration. This is definitely not the fastest way to do it :|
(And that's the _best_ case)

Bribe's DamageEngine is practically idle until damage actually occurs :eek:
 
no point in running the trigger if there are no units being damaged
no point checking every unit on the map if they are damaged or not
however something like this would be perfect if the unit takes damage event did not exist

Unit takes damage works only for units you can sellect in editor,
this function works for every units in the map. (trigger created, summoned etc.)
And this system is easy and not that lagy as you think.
For maps where are not such lot of units its good in my opinion.
And also good for trigger beginners.
 
Level 37
Joined
Sep 26, 2009
Messages
8,446
Wow Phoenix would create an epic amount of spam here.

Honestly what kind of CPU do you have to be able to handle this?

Look up Damage Detection in the spells database.

The worst thing to do in programming is to not listen to peoples' advice. So far you have done nothing but defend yourself here, instead of adapt to the advice. A year from now you'll look back and realize how stubborn you were here and how genuine our advice to you is.
 
Level 29
Joined
Oct 24, 2012
Messages
6,545
Unit takes damage works only for units you can sellect in editor,
this function works for every units in the map. (trigger created, summoned etc.)
And this system is easy and not that lagy as you think.
For maps where are not such lot of units its good in my opinion.
And also good for trigger beginners.

the damage detection system does not work only for those units. It works for all units in map.

Its not lagy till u get a lot of units which most maps have anyways.

This is not good for beginners as we dont want to teach beginners the wrong way of doing things.

Im not trying to attack u but u need to listen to the more advanced users on here. Like bribe / mag / basically all of the ppl that posted.
 
Level 29
Joined
Oct 24, 2012
Messages
6,545
What bribe was saying if u didnt understand was Theres no reason to just reject this resource. Just change it to be better with the suggestions that have been made.

At the point it is now it isnt worth having it on here. Thats how most spells and systems start. They need to be refined just like this one needs to be refined.
 
I set the checking event to 0.03.
Anyway, if you compare the "director's cut" damage systems, you can find that this function is the simplest damage detection, detect spell damage, physic damage, well any kind of damage is detected for so short and simple function.
I bet lot of users just do not understand the other damage systems... this is the easiest way for them how to learn and use/modify something.

In future, the users can anytime improve this function to be fastest.
 
You cannot really use it to do anything than show collective damage over time...

Why?

1) It doesn't detect individual damage instances
2) It doesn't provide anything that users can use (repeatedly) when someone takes damage

Yes it's simpler than those other systems, but it's too simple to be useful...

Take bribe's for example...

If you look at the main triggers, you probably won't understand it... but you don't even need to understand any of Bribe's trigger... coz alll you need to know is how to use the detection itself, which is just a simple Real variable event

  • Events
    • Real - GDDSomething becomes equal to 1.00
and that's it... it's that simple to use...

with just knowing that single event, we can do so many things already...

but yours? it's too hardcoded... we need to modify your main trigger if we want to do something when a unit is "damaged"... and a system that needs it's main code to be modified just to use it is NOT A SYSTEM... it's a template...

and as I said, it doesn't even detect individual damage instances... so even in it's most basic function of showing damage taken, it's already a not good trigger...
 
You check life lose in time intervals, not per damage...

Example:

Two spells were casted unto a unit (within the interval time), 1 deals 100 damage, the other deals 200 damage

Since your trigger checks only for HP lose per interval, it will only show 300 damage, not the individual 100 and 200 damage...

now what if I want to have an action that happens whenever a unit is damaged? since your trigger will consider all HP lost within the interval as only 1 damage instance, then one the case of the two damages above, the action will only fire once, when it should fire twice because the unit was actually damaged twice...

So in essence, your trigger is simply about "Detecting Life Reduction Per Interval" and not "Damage Detection"
 
Last edited:
Level 37
Joined
Sep 26, 2009
Messages
8,446
Yes, and you're probably looking at hundreds of lines of extra code to handle that, not to mention if the person has a custom item that is also a periapt-of-vitality, or what if an ability like Avatar wears off and that unit now has less HP, there are many scenarios where this happens. You're adding stuff to your "simple" library just to make sure it doesn't glitch out.

By the time you add enough features that you think are "simple", simply to ensure that your resource doesn't break, you'll realize how complex this kind of thing really needs to be, and how much simpler it is to just use a DDS.
 
That thing you'r saying, is possible only if the two spells are casted on the same target before 0.03 seconds, which is almost impossible.
I also tryed to attack with big amout of units to the same target at once, the system detected every damage.

Impssible? Maybe if you're using only one unit to cast spell, or you're playing alone and using two units at the same time...But if ur playing on multiplayer, then two or more persons can easily do the multiple casts at almost the same time... + triggered damage too...

How big? If it's too big, how can you be so sure that it actually detected all damages? because if they're too many, I bet the damage texts were too clustered to be identified...
 
Level 29
Joined
Oct 24, 2012
Messages
6,545
That thing you'r saying, is possible only if the two spells are casted on the same target before 0.03 seconds, which is almost impossible.
I also tryed to attack with big amout of units to the same target at once, the system detected every damage.

thats not impossible like adiktuz said if multiple ppl cast a spell then the damage is done b4 ur trigger detects it.

Main problem is any map has a lot of units. If ur hero is in the middle of 10 units chances are they will attack a lot of time in between ur detection.
 
Level 31
Joined
Jul 10, 2007
Messages
6,307
Also, it's not like a DDS is hard to use either :\

JASS:
struct Test extends array
    private static method onDamage takes nothing returns nothing
    endmethod

    implement DDS
endstruct

Yours is really a template as it is, and not a very good one at that (as people were saying before).

a DDS should be able to do a few things

#1: detect the damage type (physical, spell, code)
#2: detect the source of the damage (attacker)
#3: detect the target of the damage (defender)
#4: provide a way for people to run their code when a damage event occurs without having to modify your code (no templates)
#5: provide a way for people to decide what order their code will run in (priorities)
#6: detect damage amount accurately (every piece of damage, not bulk, 100% of the time, 0% chance of failure)
#7: provide a way to modify that damage (including saving the unit if the damage would have killed the unit and the damage was set to 0)
#8: apply code to specific units efficiently with priorities (damage events specific to a unit) and work this in with any global events

If your thing does not meet all of the criteria, chances are that it's not very good ;p
 
Top