HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Scrolling combat text - Event needed..

04-17-2007, 05:59 AM#1
Funness
Greetings, I am Funness... a new member here but not new to the world editor..

I am currently working on a RPG and I wish to have the damage delt to a unit float above their head..

Trigger:
SCT
Collapse SCT
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Custom script: local texttag udg_temptag
Set L = (Position of (Attacked unit))
Set tempint = (Integer((Damage taken)))
Floating Text - Create floating text that reads (String(tempint)) at L with Z offset 10.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
Custom script: call RemoveLocation(udg_L)
Set temptag = (Last created floating text)
Floating Text - Change temptag: Disable permanence
Floating Text - Set the velocity of temptag to 130.00 towards 90.00 degrees
Floating Text - Show temptag for (All players)
Floating Text - Change the fading age of temptag to 0.50 seconds
Floating Text - Change the lifespan of temptag to 1.00 seconds
Wait 1.00 seconds
Floating Text - Destroy temptag

This is my trigger.. The problem is, the "Damage Taken" real only works when the event is "Unit - |A Specific Unit| takes damage".. Where mine is "a unit gets attacked" How do I work around this? I did try having two triggers, one was

event - A unit gets attacked
Set tempunit = attacked unit
trigger - run SCT

where event would have been "tempunit" gets attacked.. but I cannot select tempunit as the "unit" for the event.

This trigger is posible, as alot of maps have it.. but I am not sure how I can do it.


An idea I had would have been to set a custom value to the unit of its hp, then when it gets attacked, do custom value - current hp = damage taken, then set the value to the new hp.. but this seems like an awkward work around.
04-17-2007, 12:58 PM#2
Vexorian
It is actually a very difficult topic.

I couldn't think of a way that didn't require dynamic triggers, you keep registering the Damaged event for every unit in your map.

To recognice if the damage was done by an attack we now make all heroes have an orb that leaves a buff to units, if the unit has the buff when damaged then it was attacked, in that case remove the buff and process the Attack Hit event.
04-18-2007, 04:30 AM#3
Funness
While I did try the add event (picked/triggering unit) takes damage.. I decided to show HP % rather that using...

Trigger:
SCT Percent
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Custom script: local texttag udg_temptag
Set L = (Position of (Attacked unit))
Set tempint = (Integer((Percentage life of (Triggering unit))))
Floating Text - Create floating text that reads ((HP: + (String(tempint))) + %) at L with Z offset 10.00, using font size 10.00, color ((((Real(tempint)) - 100.00) x -1.00)%, (Real(tempint))%, 0.00%), and 0.00% transparency
Custom script: call RemoveLocation(udg_L)
Set temptag = (Last created floating text)
Floating Text - Change temptag: Disable permanence
Floating Text - Set the velocity of temptag to 100.00 towards (Random real number between 45.00 and 135.00) degrees
Floating Text - Show temptag for (All players)
Floating Text - Change the fading age of temptag to 0.50 seconds
Floating Text - Change the lifespan of temptag to 2.00 seconds

It even goes from green-red depending on the % :)...

But my next question, does the "Floating Text - Change the lifespan of temptag to 2.00 seconds" remove the leak or do I still need to destroy it? According to the tooltip, it says "sets the age at which floating text is removed and cleaned up"..
04-18-2007, 04:52 AM#4
Dil999
I would have 2 reals, one before damage is dealt and one just after. Subtract 1-2 and display the result as text.
04-18-2007, 05:03 AM#5
Funness
Quote:
Originally Posted by Dil999
I would have 2 reals, one before damage is dealt and one just after. Subtract 1-2 and display the result as text.

I said something like that in my first post.. but I though that a colour coded hp% left would be more usful rather then damage delt.
04-18-2007, 05:16 AM#6
Pyrogasm
I believe that this may help you, though it does leak: Show damage using floating text (GUI)
04-18-2007, 05:58 AM#7
Funness
Quote:
Originally Posted by Pyrogasm
I believe that this may help you, though it does leak: Show damage using floating text (GUI)

I think the remaining HP% of a target would be more usful than the damage delt.. Hence why I am using my other trigger, see above.
04-18-2007, 06:15 AM#8
Jazradel
Try something like:
A unit enters the playable map area
Trigger - Add ((Triggering Unit) takes damage) to (Trigger)
04-18-2007, 08:33 AM#9
Funness
Like I said, I got it working.. But I decided not to use it.