• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Generic Unit Takes Damage Event- A Frequently Asked Question

Status
Not open for further replies.
Level 2
Joined
Jan 27, 2006
Messages
10
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!
 
Level 6
Joined
Feb 18, 2005
Messages
263
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...
 
Level 6
Joined
Feb 18, 2005
Messages
263
i guess i know what you overheard.

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.
 
Level 4
Joined
Nov 22, 2004
Messages
62
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.
Code:
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.

Code:
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.
Code:
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.

i hope it helps.
 
Level 2
Joined
Jan 27, 2006
Messages
10
(Triggering unit)
that is the same as Damaged Unit??????!!!!
if i had known that i wouldn''t have even asked :p (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
 
Level 4
Joined
Feb 12, 2006
Messages
99
I'm guessing that's what you were explaining on our clan forums...well, I hardly know what handle variables are, but that's still pretty cool.
 
Level 9
Joined
Nov 27, 2004
Messages
465
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.
 
Level 4
Joined
Nov 22, 2004
Messages
62
@ 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...
 
Status
Not open for further replies.
Top