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

[Trigger] Damage Taken

Status
Not open for further replies.
Level 4
Joined
Aug 24, 2008
Messages
38
Damage Taken (Solved)

I'd like to ask a pretty simple question what I can't find answer to :S
I'm creating a spell what heals nearby allied units based on the damage the target took. The main problem is that somehow I can't call for the damage taken. I know there should be an event what's called "Unit - Takes Damage" but there is no such thing actually in my WE :xxd: Later I can use "Damage Taken" as a real, but there is no such event.. :hohum:

Here is the trigger I made so far:


  • Events
    • Unit - A unit is attacked
  • Conditions
    • (Attacked Unit) Equal to UnitArrayOfMine[RequiedNumber]
    • (Unit-type of (Attacked Unit)) Equal to RequiedUnitTypeOfMine
  • Actions
    • Set TempPoint = (Position of (Attacked Unit))
    • Unit Group - Remove all units from TempUnitGroup
    • Unit Group - Add all units of (Units within 400.00 of TempPoint matching (((Matching Unit) belongs to an ally of (Owner of (Attacked Unit)) Equal to True) to TempUnitGrop
    • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked Unit) is A structure) Equal to False
          • Then - Actions
            • Set TempPoint2 = (Position of (Picked Unit))
            • Unit - Set life of (Picked unit) to (Life of (Picked unit)) + (((Damage Taken) / 100.00) x (8.00 + ((Real((Level of Holy Blood for (Attacked Unit)))) x 2.00))))
            • Special Effect - Creates and destroys a healing special effect here
          • Else - Actions
            • Do Nothing
    • Unit Group - Remove all units from TempUnitGroup
I think the problem right now is that the "Unit is attacked" and "Damage taken" are not compatible.

Ideas? (You might notice something else in the trigger... It just don't works in the way I want. Don't hesitate to tell me if it's wrong somewhere :wink:)


EDIT: I solved the problem in my own way.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
You have to use the specific unit takes damage event. Afterall an attack has nothing to do with damage (only when a unit begins to attack a unit). As you guess this means that every unit on your map needs this event for it to work as any unit takes damage. Watch out for event leaks and trigger destruction related crashes.
 
Level 4
Joined
Aug 24, 2008
Messages
38
Oh thanks for reply. But I can't use variables in "specific unit event"... Any ideas about this one? (I might just create a trigger what counts the damage. Only 2 integers, it's quite simple but if anyone has a better idea, please let me know!)
 
Level 9
Joined
May 28, 2007
Messages
365
Oh thanks for reply. But I can't use variables in "specific unit event"... Any ideas about this one? (I might just create a trigger what counts the damage. Only 2 integers, it's quite simple but if anyone has a better idea, please let me know!)

This spell might be too hard for you to do in GUI. You can't have a trigger that counts the damage, because you have to trigger all units in your map to work on the damage system (and that's what you have to make: a damage detection system. There are tons in the JASS resources section).

In GUI specific unit event won't take a variable, but in JASS it will.
 
Level 4
Joined
Aug 24, 2008
Messages
38
add all units to a unit group that enters the entire map and then you do in your group add event picked unit takes damage

Eeeeeh... sorry, what? :D

BTW, I done it in a quite ridiculous way. I just have to save the hero's life into an integer every second. Just some math.
[LifeSaved]-[LifeAfterAttacked]
This of-course can be a bit buggy, but none will notice :p
The trick is that I check if this value, and if it's negative I set the damage taken to a number based on skill level. If something happens, then the skill will determinate how much healing has to be done. Quite simple :p

Thanks for the help guys!
 
add all units to a unit group that enters the entire map and then you do in your group add event picked unit takes damage

  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Unit Group - Pick Every unit in playable map area and do
      • Actions
        • Trigger - Add Event(PickedUnit-Takes Damage) to DamageDetectionTrigger
 
Status
Not open for further replies.
Top