• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Damage Floating Text

Status
Not open for further replies.
I've seen numerous threads with this, searching for over 2 hours, and yet I still haven't found anything. I need a Floating Text to appear, which shows the damage taken by a unit.
I use this event:
  • Unit - A unit is attacked
Then these actions. The other FText stuff are there, so don't worry.
  • Set DamageTaken = String(Integer(Damage Taken))
  • Floating Text - Create a floating... with the message DamageTaken...
It always shows 0.

Also, I need help with Spellbooks. I have placed a total of 4 spells, made the minimum spells 0, the max 4 (Will Increase with skills made), and the skills are activated by triggers. Like:
  • Levels
    • Events
      • Unit - A unit gains a level
    • Conditions
    • Actions
      • If (Conditions) are true, Then do (Actions), Else (Actions)
        • If - Conditions
          • (Leveling Hero) Equal to P1Hero
          • (Level of (Leveling Hero)) Equal to 2
        • Then - Actions
          • Player - Enable (Ability) for (Player)
        • Else - Actions
Yet, with each time I load the map, the spells are not properly loaded. Sometimes, 2 are loaded, only 1, and sometime, none at ALL. But a few times, the spells are loaded properly.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Ok about your first problem, ofc it shows 0 =)
Why? Because if you use "attacked", the trigger will run before the target takes any damage. You need to use the event "Unit - Unit takes damage" maybe a damage detection system.

About your second problem: Spellbooks sux -_- > but now idea what the problem there. But sounds like, that your possible max spellbook - spells are higher then the true amount of current spells inside the book.

Greetings
~ The Bomb King > Dr. Boom
 
Level 16
Joined
Aug 20, 2009
Messages
1,554
well, try using the system i got..

  • Install Display Damage
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Set tempGroup[0] = (Units in (Playable map area))
      • Unit Group - Pick every unit in tempGroup[0] and do (Actions)
        • Loop - Actions
          • Trigger - Add to Display Damage <gen> the event (Unit - (Picked unit) Takes damage)
      • Custom script: call DestroyGroup(udg_tempGroup[0])
  • Confirm Display Unit
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Display Damage <gen> the event (Unit - (Triggering unit) Takes damage)
  • Display Damage
    • Events
    • Conditions
    • Actions
      • Set tempInt[0] = (Integer((Damage taken)))
      • Set tempInt[1] = (tempInt[0] / 6)
      • Set tempPoint[0] = (Position of (Attacked unit))
      • Set tempPoint[1] = (Position of (Damage source))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt[1] Less than or equal to 90
        • Then - Actions
          • Set tempPoint[2] = (tempPoint[0] offset by (5.00 + (Real(tempInt[1]))) towards (Angle from tempPoint[1] to tempPoint[0]) degrees)
        • Else - Actions
          • Set tempPoint[2] = (tempPoint[0] offset by 90.00 towards (Angle from tempPoint[1] to tempPoint[0]) degrees)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt[0] Greater than or equal to 1
        • Then - Actions
          • Floating Text - Create floating text that reads (<Empty String> + (String((Abs(tempInt[0]))))) at tempPoint[0] with Z offset 50.00, using font size 10.00, color (15.00%, 100.00%, 100.00%), and 0.00% transparency
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempInt[0] Less than 0
            • Then - Actions
              • Floating Text - Create floating text that reads (+ + (String((Abs(tempInt[0]))))) at tempPoint[0] with Z offset 50.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
            • Else - Actions
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Set the velocity of (Last created floating text) to ((Real(tempInt[0])) / 1.35) towards (Angle from tempPoint[1] to tempPoint[0]) degrees
      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.30 seconds
      • Custom script: call RemoveLocation(udg_tempPoint[0])
      • Custom script: call RemoveLocation(udg_tempPoint[1])
      • Custom script: call RemoveLocation(udg_tempPoint[2])

i hope it helped you...:p
 
Level 9
Joined
Oct 11, 2009
Messages
477
For the damage matter; what razor21 recommended is good but it leaks trigger events which leads to serious lags. Better use a damage detection system like "Weep's GDD system" which is easy to use in both JASS and GUI triggers.
 
Level 16
Joined
Aug 20, 2009
Messages
1,554
....i used it for my game, which last 2 hours, and it don't lag, well
i know it leaks,

There is a leak , when your attacked unit is killed..but the units killed is not as much as the leaks caused by other unremoveable leak..it only affects a little i think.

i removed most of the leak, and try checking with the leakchecker program to know more leaks, i don't detect anymore than what has been removed.

but for heroes , i don't think it will leak

try asking Pharaoh_ for a better system, he got another damage detection which i seen somewhere, maybe he could make a better one if you don't really like mine. or disagree, or is not happy with it.
 
As for now, do you guys know how to deal with Spellbooks?

http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/mysteries-spellbook-33039/

For the damage matter; what razor21 recommended is good but it leaks trigger events which leads to serious lags.

Adding events to a new trigger with the method of "Trigger - Add to (Trigger) the event (Unit - (Triggering unit) takes damage" doesn't leak, it just floods that specific trigger with a bunch of events. Yes, the lag might be unavoidable, but barely visible, it requires lots of new events to join that specific trigger. The best way to deal with such issues is Jass. In jass, you can create a local trigger, which you can destroy, once certain actions have taken place. This way, you will be creating a new trigger for each unit that would create a new event in the case of GUI, but destroy it afterwards, preventing the trigger from clogging.

Example:
JASS:
function NewTrigger takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local unit u = GetTriggerUnit()
local real x = GetUnitX (u)
local real y = GetUnitY (u)
call DestroyEffect (AddSpecialEffect ("units\\lol.mdx", x, y))
set u = null
call DestroyTrigger (t)
endfunction

function UnitToDie takes nothing returns nothing
local unit u = GetTriggerUnit()
local trigger t = CreateTrigger()
call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_DEATH)
call TriggerAddAction (t, function NewTrigger)
set u = null
endfunction

This takes a Triggering unit (e.g. a unit that casts an ability) and will create a special effect at its position, once it dies. The trigger we create is destroyed afterwards, solving the problem mentioned above (of multiple events referring to one single trigger).
 
Events:
Map Initialization
Actions:
Set TempGroup = Units in Playable Map Area Matching (your conditions)
Pick Every Unit in TempGroup And Do:
Add to Damage Detect <gen> - Picked Unit Takes Damage
Custom Script: call DestroyGroup(udg_TempGroup)

Another trigger...
Events:
A unit enters Playable Map Area
Conditions:
(Your conditions)
Actions:
Add to Damage Detect <gen> - Triggering Unit Takes Damage

Damage Detect
Events:
Actions:
Floating Text - Create a floating... with the message DamageTaken...
 
Level 16
Joined
Aug 20, 2009
Messages
1,554
Events:
Map Initialization
Actions:
Set TempGroup = Units in Playable Map Area Matching (your conditions)
Pick Every Unit in TempGroup And Do:
Add to Damage Detect <gen> - Picked Unit Takes Damage
Custom Script: call DestroyGroup(udg_TempGroup)

Another trigger...
Events:
A unit enters Playable Map Area
Conditions:
(Your conditions)
Actions:
Add to Damage Detect <gen> - Triggering Unit Takes Damage

Damage Detect
Events:
Actions:
Floating Text - Create a floating... with the message DamageTaken...

isnt that what i posted?...lol, see above, post number 8, he said that using this kind of trigger leaks. and the thread starter didn't want it
 
Status
Not open for further replies.
Top