Advice on converting Integers and Reals in calculations

O.A

Quantum physics rules
Reaction score
29
Edit: Solved
Trying to make a damage script based on hero level, thus:
Unit - Cause (X unit) to damage (Y unit), dealing ((Real((Level of (Casting unit)))) x 5.00) damage of attack type Spells and damage type Normal. This is not working.

Also tried to make Creep Heroes lose 10% of their level amount when reviving them, thus:
Hero - Set (Revived Hero) Hero-level to ((Level of (Dead Hero)) x (Integer(0.90))). This is not working either.

I'm just thinking of these as numbers (Y x 0.9 = 90% of Y), but clearly something is going wrong in the conversion. Any replies appreciated.

Edit: Ok, seems after all the damage script is working, but the Hero still revives as level 1, and i tried it with / 2 and that one worked alright. The Hero´s level was divided by 2 every time.
 

thorhunter

You can change this now in User CP.
Reaction score
32
Try doing Hero - Set level to (Real to Integer (0.9 x Integer to Real (Level of Hero) ), as your Real to Integer (0.9) returns 1.
 
  • Like
Reactions: O.A

afisakov

You can change this now in User CP.
Reaction score
37
Try doing Hero - Set level to (Real to Integer (0.9 x Integer to Real (Level of Hero) ), as your Real to Integer (0.9) returns 1.
Actually I believe real to integer always rounds down, so 0.9 returns 0, not 1. This is why the hero level was getting set to 1 (game cannot set to level 0).
Your solution sounds good though
 

thorhunter

You can change this now in User CP.
Reaction score
32
Actually I believe real to integer always rounds down, so 0.9 returns 0, not 1. This is why the hero level was getting set to 1 (game cannot set to level 0).
You're right on this one, I never encountered any conversion issues for me to notice it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top