Generic Unit Takes Damage Event- A Frequently Asked Question
I know this question has probably been asked ALOT but here I go: what is the JASS code trigger for Generic Unit Takes Damage Event?(which doesn't exist in GUI) i've managed to finish writting my GUI trigger, then converted it to JASS and began mangling it but i cannot finish it because i do not know the name of the code thingy GetConvertedPlayerId(GetOwningPlayer(GetDamagedUnitBJ())) ?????????? and gg_trg_TriggerNAME, GENERIC_EVENT_UNIT_DAMAGED ) ???? thanks in advance for any help!
as far as i know, and i have looked into getting the damage dealt to any unit for quite some time, there is no way to get the damage, except for individuall units. therefore you need to know which unit and register a trigger for then - that's kinda pain in the ass, but the only half-way acceptable way i found...
there is a JASS (and as well GUI) event that triggers whenever a unit takes damage. BUT it only triggers for a specific unit. NOT generic.
i relooked into it. There is no way to generically get the event of a unit getting damaged.
if you look into 'ammunition' systems a little, you'll see that all the creators would have loved using 'unit gets damaged' instead of 'unit attacks'.
I'll repeat myself: if you nevertheless want to get the damage_unit event genericall you'll have to register a trigger for every unit on your map. that triggers all call the same function. And if a unit no longer exists it's trigger will get removed.
actually i have it. the GUI version. i discovered thanks to two friends (GaDDeN and xD.Shuckle)
the first one keeps track fo the units as they enter the game.
pick new units
Events
Unit - A unit enters (Playable map area)
Conditions
Actions
Trigger - Add to damage <gen> the event (Unit - (Entering unit) Takes damage)
the second one keeps track of units already placed in the game, like creeps.
pick starting units
Events
Time - Elapsed game time is 0.05 seconds
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
Trigger - Add to damage <gen> the event (Unit - (Picked unit) Takes damage)
the last ones does the text damage ver attacked units read.
damage
Events
Conditions
Actions
Floating Text - Create floating text that reads (String((Integer((Damage taken))))) above (Triggering unit) with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 100.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 96.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 0.50 seconds
Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
as you can see its quite simple. its leakless for the record, since it tracks each unit only one time, and not every time.
this trigegr i used for my maps to show damage over units. no variables or Unlimited WE is needed.
if you want the JASS version, just make this trigger and convert it to custom text.
that is the same as Damaged Unit??????!!!! if i had known that i wouldn''t have even asked (i already knew about Add Event thingy working, but thought that with having to write script for Damaged Unit it would take too long ty though for the thingy anyways
Ok,and what about situation,when 1 unit have been added to the Event of "damage" trigger double-time or more? Would it be that that trigger will make double-time or more actions at that unit ?
Fo example: unit-create(1st entering),than unit revive (2nd entering)
Main trigger unit enters region
add event for entering unit
______________________
P.S. i know that it would be quicker to test it by myself,but that's not so serous problem for me.
@ The Warehouse: Triggering unit refers to the unit that triggered in the event. like "unit dies" event, you cna use "dying unit" as well as "triggering unit", but triggering unit is mre in general.
@ PurplePoot: if i knew JASS or handle vars, i would use that... but im new to JASS yet.
@ VampireKB: if the same unit reenters the map, it will be re-added to the event, so everytime its hit, the actions will happen twice. yeah youre right and i didnt noticed it... but it5s the best i could get in GUI. JASS is the next generation... time (for me) to learn it...