HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Event Repsonse - Damage Taken

11-02-2003, 05:57 AM#1
Psyborg
I can't seem to get an event to work for this.. it says when responding to a 'takes damage' unit event.. Though the event 'unit is attacked' doesn't seem to work.. An I can't see anything else thats would be more likley to work... Perhaps I'm blind...
11-02-2003, 10:55 AM#2
Stitch
so what exactly are you trying to do?
11-02-2003, 11:29 AM#3
MMayfield45
I think it only applies to this event:

Event
Unit - Specific Unit Event - Unit Takes Damage
11-02-2003, 11:56 AM#4
Psyborg
Yea.. looks likely..
Don't suppose you can tell me why I can't seem to assign variables to unit specific event's other then exisiting units?
11-02-2003, 01:09 PM#5
MMayfield45
I think Specific Unit Event is only for units already on the map unless you add the events with triggers or use General Unit Event which doesn't have takes damage in:(.
11-02-2003, 02:10 PM#6
AIAndy
Triggers are set up by War3 at a point where your variables do not have a value yet. That is why you can't choose variables there.
But you can add the event in a trigger action. Then you can use variables there.
11-02-2003, 02:19 PM#7
drezman
what exactly are u trying to do?
11-02-2003, 10:42 PM#8
Psyborg
hmm..
Well want I want to do is have when a units takes damage a % of that damage gets converted to mana.
11-02-2003, 10:54 PM#9
Grater
You could make a pretty good approximation with a bit of trigger work.
Code:
Approximation
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set TempReal = ((Real((Custom value of TempUnit))) - (Life of TempUnit))
        Set TempReal = (Max(0.00, (TempReal x 0.33)))
        Unit - Set mana of TempUnit to ((Mana of TempUnit) + TempReal)
        Unit - Set the custom value of TempUnit to (Integer((Life of TempUnit)))
Something like this comes to mind, it just gets the difference between the units health a second ago and it's health now (old HP stored in custom value, you could use a variable instead) and then adds 33% of that to mana... if the difference is negative (ie HP regeneration, potion usage) then nothing is added.

As I said it's an approximation... potion usage, healing and HP regeneration will result in a bit of lost damage and therfore mana regeneration...
11-03-2003, 12:54 AM#10
Psyborg
mm.. I was trying that this.. but werid things happen..

Event-
*Unit - A unit Is attacked

Action-
*Trigger - Add to (This trigger) the event (Unit - (Attacked unit) Takes damage)
*If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Mana of (Attacked unit)) equal to (Max mana of (Attacked unit))
Then - Actions
Do nothing
Else - Actions
Unit - Set mana of (Attacked unit) to ((Mana of (Attacked unit)) + ((Damage taken) x 0.20))


It kinda works.. but the mana gain goes insane then wc3 hangs.. i.e. doesn't increase by 20% of the damage...
I don't understand... :(
11-03-2003, 02:36 AM#11
Grater
Do you even know what that trigger does ;)
Every time a unit is attacked, it creates a NEW event for that unit... so if a unit has been attacked a hundred times, the trigger will run a few hundred times for that unit. Ouch.

I do really like your solution, so I tweaked it to fix it. This involves a single unit group for storing what units have already been added to the trigger to prevent double,triple,quadzillion adding. You'll probably also want a condition for the type of unit. I also split it into two triggers to make it cleaner and more effecient.
Oh theres also no need to check for maximum mana.

Trigger one
Code:
Unit Recieves Mana from damage
    Events
    Conditions
    Actions
        Unit - Set mana of (Attacked unit) to ((Mana of (Attacked unit)) + ((Damage taken) x 0.20))

Trigger two
Code:
Unit is attacked
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacked unit) is in DamageTriggeredUnits) Equal to False
    Actions
        Unit Group - Add (Attacked unit) to DamageTriggeredUnits
        Trigger - Add to Unit Recieves Mana from damage <gen> the event (Unit - (Attacked unit) Takes damage)

I figure this could also be used to make a GREAT damage shield ability.
11-03-2003, 03:09 AM#12
Grater
Wowza, simply be changing the trigger action to "add damage taken" to "life of unit" you have a near perfect divine shield that protects against all types of damage and doesn't mess with regeneration/pot usage. Thats NEAT. Add magic immunity and you would could easily make an ability like DS that turns the hero into an AWESOME tank capable of asorbing limitless punishment :)
11-03-2003, 03:13 AM#13
Ligature
Wait a second - does this mean what I think it means?

Quote:
Trigger - Add to (This trigger) the event (Unit - (Attacked unit) Takes damage)

If it does, you could use that action to basically use specific unit events for units not pre-placed on the map...
11-03-2003, 03:28 AM#14
Grater
It does mean exactly that! And so much easier than I thought it would be.
11-03-2003, 06:59 AM#15
Psyborg
Right.. That makes sense.. lets hope it works..
thanks for your help.. it's annoying not knowing what your doing....