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

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,601
Hey.

I created a very simple floating text damage system that shows how much damage player 1 does and takes. I was wondering if there's a way to add healing to the system as well. I mean when player 1 units are healed by abilities or via triggers.

The event is the problem: there's no a good event for this thing.

  • FloatingDamage SETTINGS
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempGroup = (Units owned by Player 1 (Red))
      • Set TempGroup2 = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Trigger - Add to FloatingDamage TAKEN <gen> the event (Unit - (Picked unit) Takes damage)
      • Unit Group - Pick every unit in TempGroup2 and do (Actions)
        • Loop - Actions
          • Trigger - Add to FloatingDamage DONE <gen> the event (Unit - (Picked unit) Takes damage)
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call DestroyGroup(udg_TempGroup2)
  • FloatingDamage ADD
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Entering unit)) Equal to Player 1 (Red)
          • (Owner of (Entering unit)) Equal to Neutral Hostile
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Entering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Trigger - Add to FloatingDamage TAKEN <gen> the event (Unit - (Triggering unit) Takes damage)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Entering unit)) Equal to Neutral Hostile
            • Then - Actions
              • Trigger - Add to FloatingDamage DONE <gen> the event (Unit - (Triggering unit) Takes damage)
            • Else - Actions
  • FloatingDamage HEAL
    • Events
    • Conditions
    • Actions
      • Set TempInteger = (Integer((Damage taken)))
      • Floating Text - Create floating text that reads (|c0077FF77 + (String(TempInteger))) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 30.00%, 0.00%), and 10.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 70.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
Rep + credits to the helpers.
 

Attachments

  • FLOATING DAMAGE.w3x
    21.5 KB · Views: 64
Level 37
Joined
Mar 6, 2006
Messages
9,240
Save the heal amounts of ablities in variables. Then detect the ability cast and load the heal value. If the unit has taken less damage than the heal would be, then use the missing health amount.

This wiil propably show a value that is ~1 HP too small due to real->integer conversion.

Triggered healing should be easy to do, just convert the heal amount to integer then run a floating text trigger.

  • FloatingDamage HEAL
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Holy Light
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Max life of (Target unit of ability being cast)) - (Life of (Target unit of ability being cast))) Less than HolyLightHeal[(Level of Holy Light for (Triggering unit))]
            • Then - Actions
              • Set TempInteger = (Integer(((Max life of (Target unit of ability being cast)) - (Life of (Target unit of ability being cast)))))
            • Else - Actions
              • Set TempInteger = (Integer(HolyLightHeal[(Level of Holy Light for (Triggering unit))]))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Heal
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Max life of (Target unit of ability being cast)) - (Life of (Target unit of ability being cast))) Less than HealHeal
                • Then - Actions
                  • Set TempInteger = (Integer(((Max life of (Target unit of ability being cast)) - (Life of (Target unit of ability being cast)))))
                • Else - Actions
                  • Set TempInteger = (Integer(HealHeal))
            • Else - Actions
      • Floating Text - Create floating text that reads (|c0077FF77 + (String(TempInteger))) above (Target unit of ability being cast) with Z offset 0.00, using font size 10.00, color (100.00%, 30.00%, 0.00%), and 10.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 70.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
 
Level 7
Joined
Apr 12, 2009
Messages
188
As far as I know, there's no way to detect when a unit gains HP. Even if you could do it, how could you differentiate between regen and a healing spell?

I use a lot of healing spells in my map, all of which I converted to triggered abilities in order to trigger the healing text manually when the spell effect takes place.

Also, I HIGHLY recommend using Weep's damage detection system to do your damage detection for your floating damage text. If you want to see it in action, check out my map! Here's a previous explanation of this system:

Be warned, doing it exactly as shown in the example map by defskull is not the best way to 'detect' the damage event, since every time any unit on your map takes damage, it has to add an event to the damage text trigger (effectively causing event buildup and leakage). I remember I had some issues with doing it that way in my map some time back, and eventually converted to a really simple, GUI friendly damage detection system. I would highly recommend it if you're looking for a stable system - it also allows you to use damage detection very easily in other systems and spells!

This is the system (all it takes is copy paste of a few triggers):
Weep's Amazing Damage Detection

Then you can use a trigger like this!
  • Create Text
  • Events
  • Game - GDD_Event becomes Equal to 0.00
  • Conditions
  • GDD_Damage Greater than 1.00
  • Actions
  • Floating Text - Create floating text that reads (String((Integer(GDD_Damage)))) above GDD_DamagedUnit with Z offset 0.00, using font size 8.00, color (100.00%, 14.00%, 14.00%), and 0.00% transparency
  • Floating Text - Hide (Last created floating text) for (All players matching ((Owner of GDD_DamageSource) Not equal to (Matching player)))
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 50.00 and 100.00) towards (Random real number between 70.00 and 110.00) degrees
  • 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
If you want to see this method in action, take a look at my game Defend the Basement, and if you need further advice or help let me know :D
 
Level 37
Joined
Aug 14, 2006
Messages
7,601
Okay. What the hell. Fine. Let's see...

Yea but I want different colors. When p1 attacks yellow color, when attacked red color and when healed a green color.

That just gives massive amount of text and I don't understand JASS. Also I don't have time to start to understand such a things and I have better things to do like finish the next version of the campaign. I'm already late like 2 months or something.

So then I would need once again help and someone should do that color thing for me, bla bla bla.
 
Level 7
Joined
Apr 12, 2009
Messages
188
Yea but I want different colors. When p1 attacks yellow color, when attacked red color and when healed a green color.
That's very easy to do, and doesn't require any JASS whatsoever. Well, you will still have to trigger your healing spells to make the green text, as I said, but using a simple IF-THEN-ELSE you can check who owns the damaging unit (or damaged unit) to make the damage text yellow or red. Weeps system saves the damage amount, the damaging unit, and the damaged unit all to global variables.

That just gives massive amount of text and I don't understand JASS. Also I don't have time to start to understand such a things and I have better things to do like finish the next version of the campaign. I'm already late like 2 months or something.
I'm not sure what you mean, but if you're referring to Weeps damage system you don't have to use JASS in any way... you just copy - paste the triggers into your map. It will literally take you 5 minutes if you just read the instructions. :bored:

So then I would need once again help and someone should do that color thing for me, bla bla bla.

Well isn't that what we're here for? At least the "help" bit...
 
Level 7
Joined
Apr 12, 2009
Messages
188
Okay. Well, how I do that healing thing to your system then? And what if the healing spell is passive? I mean it comes from an item or something.

All you can do is trigger the spell yourself, even if it's from an item or a passive or whatever. What kind of passive heal are you talking about anyway? For spells that are cast, if you know the healing values of the spell, just trigger the green healing text when the spell effect takes place. You will have to make a trigger for each healing spell in the game.

The only other way I could imagine doing it is if you replaced your healing spells with damaging type spells with negative damage values and allowing friendly targeting. Then you could use the damage system to detect when the damage values are negative, and show them as the green numbers. I'm checking to see if this works right now...

[EDIT]Yeah that would be possible. I just used firebolts with negative damage targeted at allies. Then you can detect when negative damage is dealt and show green healing text! Probably the best way to do it on a large scale if you don't want to trigger your healing abilities like crazy.
 
Last edited:
Level 7
Joined
Apr 12, 2009
Messages
188
The only way your aforementioned system leaks is by adding events that never get removed.

  • Trigger - Add to FloatingDamage TAKEN <gen> the event (Unit - (Triggering unit) Takes damage)
I doubt you will notice any lag unless you have repeating creep spawns or something of the sort - where over a long game session you will build up those events very substantially. I used the same method you're using for a while and didn't notice any lag - the main reason I converted over to Weep's system is to more easily trigger custom abilities when damage is done/taken.

So for a simple damage text system you'll probably be fine as is :xxd:
 
Status
Not open for further replies.
Top