HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Event: Unit Takes Damage

06-06-2006, 11:59 PM#1
moonliterhythm
Hey, I have a map where I have players buy Heroes from a tavern.

I want to play special effects on those heroes when they get damaged. However, I don't want to use a "Unit is Attacked" bcuz i want to play an effect everytime it's injured, period.

Is there any way to dynamically create a trigger that'll run anytime that specific hero is takes damage? Say when they purchase the hero, can i create a trigger in game that says "okay so from now on whenever this hero gets damaged then do blah blah"

Also, say i wanted to play the effect of mana shield (and destroy it) everytime he gets injured -- can i change the size of the effect based on his current HP/MP? Rather than be "one size"
06-07-2006, 12:11 AM#2
harshateja
1st Question: Yes, but the only way is jass that I know of. If you wanna do it that way, use the CreateTrigger() native and TriggerRegisterUnitEvent() native everytime a unit enters the playable map.
06-07-2006, 12:18 AM#3
Soulprovider
Normally like many others I would say look at the events for the event, however I feel inclined to help you so here are the events and conditions you will need for this. Also I would not recomend using manashield only because creating it and destroying it may cause a leak and thats something you do not want.

Trigger:
Collapse Events
Unit - Footman 0000 <gen> Is attacked
Collapse Conditions
(Triggering unit) Equal to (Attacked unit)
(Owner of (Attacking unit)) Equal to Neutral Hostile
Collapse Actions
Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl

To make it clearer i've added a test map for you to see how it works.

The units i've attached it to is the footman.
Try attacking hims with the spell breakers then run him over to the creep camps. Note: turn on your creep camp icon to locate the creep camps. With a little editing you can allow all units to exhibit the effect. I hope this helps. I did not bother to add the remove effect action to this since this is a test map although I would highly recommend it.\

EDIT: I didn't realize what you were asking here is the revised trigger in GUI however there are a couple of limitations.

1. It would normally affect any unit unless you specify a certain variable or unit to be designated.

2. to prevent it from happening to all of the units owned by Neutral hostile or A different player you need to set up a condition checking for certain players.

Trigger:
Collapse Events
Unit - Footman 0000 <gen> Takes damage
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Collapse Actions
Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl

I'll add the updated test map with the updated trigger

EDIT2: to answer your second question simply. Impossible. as far as I know all special effects rely on the size of the unit. Unless there is a way to change the size of a special effect in jass. Now what you can do is create a dummy unit that is invisible and Ghosted that is larger than the hero and give him the special effect then remove him. I assume that may work although I don't have anything to back that up.
06-07-2006, 12:49 AM#4
moonliterhythm
thank you very much, that dummy invisible unit idea was my only solution but i was hoping there was something better.

as for your test map, which is great, it still doesn't completely answer my question bcuz your footman is pre-placed before the map is started. i wanted to have a trigger that runs when say, a new hero is created. i want thaaat hero to have his own trigger that runs anytime HE takes damage.

he isnt preplaced on the map.

i'm not a jass noob, so i dont mind if things get messy with jass, but i dont know how to use the createtrigger() commands -- how would i go about doing that and setting it up?
06-07-2006, 01:15 AM#5
TaintedReality
Why not just create a trigger beforehand with the actions you want to happen, with the condition (Triggering Unit is a Hero) or something like that, and leave events blank. Then whenever a hero is purchased (detect this with another trigger), use the Trigger - Add Event action and add the event: Specific Unit Event - (Purchased Unit) Takes Damage. It might not be purchased unit, might be sold unit or something I dunno, I haven't used GUI in a while. But that's close enough for you to figure out.

If you really want to dynamically create triggers every time a hero is purchased, you can using JASS but I don't see why, as it won't be saving any memory (since you won't ever destroy them again).
06-07-2006, 01:20 AM#6
Soulprovider
the key word I'm looking for is impossible with GUI

maybe in JASS you can do that but i've tried every possible way I can think up and you need a specific Unit to do this with. You cannot use variables to supplement bacause the GUI editor does not allow it and in the player or generic ones the unit takes damage option is removed.


EDIT: I stand corrected
06-07-2006, 01:23 AM#7
TaintedReality
You can definately do it, you just have to add the events to the trigger every time a unit enters the map. Using the Trigger - Add Event action, using the method I just posted ; ).
06-07-2006, 01:39 AM#8
Soulprovider
LOL well I stand corrected.

You would think that someone shouldn't have to resort to that, well Tainted I bow to you.

Listen to tainted.
06-07-2006, 04:33 AM#9
Mystic Prophet
heh i use the same technique for my map. I simply replaced all the preplaced units with triggers and then made a unit enters map trigger that adds the event unit takes damage to all the needed triggers. It meant that I had to trigger all the item drops rather than using object manager and I had to set all my specific units to variables, but it works.
06-07-2006, 02:39 PM#10
emjlr3
what I would do is register whenever a unit enters map, and check if for ex.

GetHandleInt(GetTriggerUnit(),"Damage")==0

if so, create a trigger registering when the unit takes damage, and do ur actions, then do SetHandleInt(GetTriggerUnit(),"Damage",1)

so that for each unit this is only done once

not too tough
07-02-2006, 02:22 AM#11
moonliterhythm
Using KattaNa's system isn't completely necessary. I was able to set it up by dynamically creating triggers. Wow, i never knew that was possible, but it sure is one helluva powerful technique. Thanks a lot!
07-02-2006, 02:42 AM#12
shadow1500
I made a very convinient script which automatically registers the damage event for all units in the map, find it here.
Event: Unit Takes Damage - Wc3C.net