• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Why i cannot put dot for the Floating Text? (like 0.50, 0.75)

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,137
Hello everyone. I can deal damage based on attribute x 0.50 it is ok but i cannot use it as floating text.
I have tried to convert integer to string, i can put 0.50 in there

  • Floating Text - Create floating text that reads (String(((Intelligence of Archmage 0041 <gen> (Include bonuses)) x (Integer(0.50))))) above Archmage 0041 <gen>
But it says 0 now. Am i missing something?
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Something you can do to make it easier on yourself is to compute the number in steps and save it in a variable along the way. Then reference that variable in the floating text line:
  • Set RealVar = (Real(Intelligence of Archmage 0041 <gen> (Include bonuses)))
  • Set RealVar = (RealVar x 0.50)
  • Floating Text - Create floating text that reads (String(RealVar)) above Archmage 0041 <gen>
 
Level 17
Joined
Jun 2, 2009
Messages
1,137
Yes it is working but i am trying to do that and i am bad with aritmethic.
This is the float that i am trying to show

Level 1: 45 + 0.50 INT damage
Level 2: 90 + 1.00 INT damage
Level 3: 135 + 1.5 INT damage
Level 4: 180 + 2.0 INT damage

I don't know when to create arithmethic, when to close and where to create brackets and close these.
Here is the my attempt. I can set it as 1, 2, 3, 4 etc etc. I cannot put . between numbers.
When i convert it to real it gives 0. Here is the map and my attempts.
 

Attachments

  • float_test_v2.w3x
    16.3 KB · Views: 0
Level 39
Joined
Feb 27, 2007
Messages
5,010
I can set it as 1, 2, 3, 4 etc etc. I cannot put . between numbers.
Because they are integers when they should be reals. You really need to understand the difference between a real number (61.34 or -1.98 or 4.00) and an integer (61 or -1 or 4), as that distinction is super important when writing triggers.

As biridius said in their first reply... Integer math does not round at all; instead it always truncates ("cuts off" or "stops") everything after the dot. So 10/5 = 2, but 9/5 = 1 (this would be 1.8 but the .8 gets cut off and it becomes 1 because of integer truncation). This applies to any computation done using only integers. If you attempt to multiply a number by 1/2 (where 1/2 is made from integers) it will round the 1/2 to 0 and then multiply by that number, giving you 0 again.

Notice that the damage dealt by each each level of the spell are all multiples of each other. I mean that the base damage goes up by 45 for each level, and the int scaling multiplier goes up by 0.50 every level. It's thus possible to rewrite the cooldowns like this:

Level 1: 1 x (45 + 0.50 INT) damage
Level 2: 2 x (45 + 0.50 INT) damage
Level 3: 3 x (45 + 0.50 INT) damage
Level 4: 4 x (45 + 0.50 INT) damage
Level N = N x (45 + 0.50 INT) damage

You could write that in a trigger like this:
  • Set DMG = (Real(Intelligence of Archmage 0041 <gen> (Include bonuses)))
  • Set DMG = (DMG x 0.50)
  • Set DMG = (DMG + 45.00)
  • Set DMG = (DMG x (Real(Level of ABILITY for UNIT)))
  • Floating Text - Create floating text that reads (String(DMG)) above Archmage 0041 <gen>
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
@Pyrogasm Sorry for late reply. I was busy with other things and Floats we're not a big problem to me.
Yes it worked like this.

  • Events
    • Game - DamageModifierEvent becomes Equal to 1.00
  • Conditions
    • IsDamageSpell Equal to False
  • Actions
    • Set DMG = (DMG + 4)
    • Set DMG = ((Level of GhoulQ for DamageEventSource) x 4)
    • Floating Text - Create floating text that reads (String(DMG)) above DamageEventSource with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
    • Unit - Set life of DamageEventSource to ((Life of DamageEventSource) + (4.00 x (Real((Level of GhoulQ for DamageEventSource)))))
Thank you so much.
 
Status
Not open for further replies.
Top