Tutorial Clumsy but Effective GUI damage detection

TomTTT

New Member
Reaction score
44
Editor thoughts (in other words - why the heck the tutorial is made)
Ok. So i few days ago i helped someone to create a floating text about taking amount of gold from a unit if you have an item... And i noticed the only way was to do this was by using a damage detection system that I found at last, But telling the truth, it has been mostly JASS, but you could refer to whoever needed. And i thought, why not trying to make my own GUI friendly damage detection system? So today, when I sang in the shower as usual :)D) i came to realisation!

The point (in other words - skip your stories and lemme see!)
Since the event,
Trigger:
  • Unit - A unit Is attacked

Is triggered like half a second before the actual attack happens, you can set the life of the attacked unit in a real variable,
Trigger:
  • Set realArray[1] = (Life of (Triggering unit))

then wait a little while,
Trigger:
  • Wait 0.50 seconds

And then set the life of the attacked unit again, in another variable,
Trigger:
  • Set realArray[2] = (Life of (Triggering unit))

And with the Arithmetic option, calculate the damage dealt!
Trigger:
  • Set realArray[3] = (realArray[1] - realArray[2])

So for all those who in need of a damage detection, an easy-but-taking some-time trigger without all the JASS that the only think you know about it is it's name (and for those who don't, it's JASS, clever, right?)
So basically, the trigger is simple:
Trigger:
  • Detect
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set realArray[1] = (Life of (Triggering unit))
      • Wait 0.50 seconds
      • Set realArray[2] = (Life of (Triggering unit))
      • Set realArray[3] = (realArray[1] - realArray[2])


I'm pretty sure i'll get flamed for this but i just couldn't hold posting this here. I did a research and the only damage detection i found WAS made with JASS.

NOTE
Whenever i say those things about JASS i don't mean to under estimate it's power. I do realise it IS a lot more powerful than GUI, but this tutorial is meant for those (like me) who don't understand JASS.

I don't see this neccesery, since this is a one trigger system (is it called a system?) but added a demo map.
 

Attachments

  • Damage Detection GUI.w3x
    16.9 KB · Views: 319

tommerbob

Minecraft. :D
Reaction score
110
Weep's Damage Detection system is made in Jass, but it is made for GUI users, and it is very very simple to use. No need for this.
 

Flare

Stops copies me!
Reaction score
662
Sadly, this is not really effective at all - two perfectly plausible (and very common) situations in a WC3 game will cause this to screw up (or just not do what the name says)
  • Healing/natural regeneration - if healing occurs or natural regeneration is relatively high, your damage value is going to be thrown off
  • Spell damage - A Unit Is Attacked doesn't handle offensive spells targeted at the unit, so they won't be capable of registering as damage sources (but they are able to throw off normal attacks if the spell lands during your 0.5sec window)

There may be more pitfalls with this system, but I want to play some more Call of Duty now... :3

I'm pretty sure i'll get flamed for this but i just couldn't hold posting this here. I did a research and the only damage detection i found WAS made with JASS.
I get the feeling I might have posted one long ago... although, it may have been part of another demo map. I'll have to try and fish it up from my attachments
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
sorry but not only what flare said is right but it wouldnt even detect all physical attacks damage.
1). ranged units attack will most probably not hit within these 0.5 seconds.
2). not all melee units have an attack animation point value of 0.5 or below, attacks of units with values above 0.5 will not be detected as well.

besides, very very inaccurate.

to the damage detection part:
you can make damage detection systems solely with GUI. its not even hard. i made my own damage detection systems myself when i wasnt this experienced in map making.
the problem with GUI damage detection systems is that they always leak. you cannot make them leak-free. but Weep made a pretty decent damage detection system which is GUI friendly and can be used like a generic "any unit is damaged" event in GUI.
 

Medeam

New Member
Reaction score
3
Everything leaks no matter what....
The difference between jass and gui aren't so high unless you are doing huge over 200 unit projectile or physics systems which almost or anybody has never done.

Tho they are right, this is not so great of a damage detection method but it is very good still no matter since there is no gui damage detect.... That reminds me, I should submit one and get all the jass'ers to flame me.

I would advise trying to explore a bit past unit is attacked and look for unit groups combined with specific unit events as well Accname any gui damage detect can be generic/any unit is damaged too.... it is just not done and ready for you like Weep's is and even if it is easy and simple... I barely see anyone ever use it in their maps unless it is one that is advanced.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
What happen if several units are damaged?
This working style should be graveyarded.
We already have this.
 

Medeam

New Member
Reaction score
3
But it is not gui.... This also helps lead the way for more beginners or people who have trouble remembering how to do stuff like this but better instead of starting on something complex they can start small and move onto that half jass dmg detect then pure jass.

I think if the tutorial was made for all units on a map then it would be fine, but now it would not work on several units.

So why not help him to try to index or hashtable this and use a better event with actions and conditions.

I would help but I am currently busy and will try to help if nobody does later...
 

tommerbob

Minecraft. :D
Reaction score
110
But it is not gui.... This also helps lead the way for more beginners or people who have trouble remembering how to do stuff like this but better instead of starting on something complex they can start small and move onto that half jass dmg detect then pure jass.

I think if the tutorial was made for all units on a map then it would be fine, but now it would not work on several units.

So why not help him to try to index or hashtable this and use a better event with actions and conditions.

I would help but I am currently busy and will try to help if nobody does later...

It doesn't matter if GDD is GUI or not. It's a system designed to make map making easier, which it does. You don't use a system so you know the ins and outs of how it works. Yo use a system because it makes your job as a mapmaker easier.

Sure, there are the tech junkies out there who want to understand how every little thing works, and I'll admit it is nice to understand things. But for most mapmakers, they use "systems" so they don't have to do all the dirty work--that's what the system is for.

GDD is the best damage detection system out there for GUI users. It is simple, easy to implement, and requires no Jass knowledge.
 

Weep

Godspeed to the sound of the pounding
Reaction score
401
But it is not gui.... This also helps lead the way for more beginners or people who have trouble remembering how to do stuff like this but better instead of starting on something complex they can start small and move onto that half jass dmg detect then pure jass.
...except that for people who'd rather do it all themselves, there is an easier, accurate, and already well-known method of setting up true damage detection in pure GUI (it's mentioned in almost every thread asking about GUI and damage detection, and uses adding an event to a trigger with another trigger).

Ironically, making the OP's system MUI would be most easily done using JASS :eek: in the form of custom script for locals. :p
 

Romek

Super Moderator
Reaction score
963
Working damage detection is easily made in GUI. It's just easier to do so in JASS. As for leaks... I doubt it'll make any difference to any modern computer. As long as you don't create too many units. Make a GUI damage detection for your own use though. Don't submit 'leaky' code in hope of having it approved. :p

Also, do note that people who use JASS don't necessarily hate people who use GUI. Most people who code in JASS actually started from GUI, including me. JASS is obviously more powerful, but is also considerably harder to learn (though it's actually easier to use once you know how to, however odd that sounds). GUI is made for beginners, and is obviously much easier to learn, though it's also much more limited.

You seem to be under some impression that there's a war between people who use each of the two methods of coding. This is not the case. :rolleyes:
 

Bogrim

y hello thar
Reaction score
154
This system doesn't detect damage though. It detects life changes over the span of 0.50 seconds - usually more because of the large inaccuracity in the wait action compared to a timer. One of the many reasons for this doesn't make a damage system is because if the unit is healed you can't detect the damage taken.

The war is totally there, Romek. It's just fought between the lines.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top