Decimals, Possible?

GooS

Azrael
Reaction score
154
It might have just been that I was tired but in GUI I can't find any way to make Decimals except for this way:

Code:
Hero - Modify Strength of (Triggering unit): Set to ((Strength of (Triggering unit) (Exclude bonuses)) x (11 / 10)

This is the way I want hero attributes to increase, however since I couldn't find a way to add direct decimals I had to do 11/10 to get 1.1.
BUT for the real question, will this actually be read as a decimal or closest rounded up Integer?

This will make a hero that starts with 18 str get 19.8 but that cant be so
as a follow up question after I've gotten the number 19.8 THEN I want to round it up to closest integer, 20 in this case. (does it do this automatically? as when you use static increases through unit editor you can set them to decimal values and they round up.)
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Integer values = full values, no decimals.

Real values = Decimals.

Don't know if that's what you were looking for.

Edit: Integer values are rounded of to the closest full value, excluding the decimals. Though I do think that they will count the decimals, which in your case would result in a Strength increase of 1/1/1/1/1/1/1/1/1/2 I think. (No it wouold not, that would be if you added 1.1 str and leveled 10 times, but you get the point)
 

Darg

Administrator
Reaction score
49
The value that the field is expecting is an integer, so even if you gave it a real number then it would just round it off to the nearest integer anyway.
 

GooS

Azrael
Reaction score
154
Integer values = full values, no decimals.

Real values = Decimals.

I did know that, but I cant find a way to make the attribute multiplier into an real value (that which say: 11/10 in this code) in that codestring. As Real value variables does not show up in the variable box (No variables of this type defined)

The value that the field is expecting is an integer, so even if you gave it a real number then it would just round it off to the nearest integer anyway.

Is there a way to override this like in making a trigger calculating the next stat increase using real values then rounding up, placing it in an integer variable then set the increased strength to that variable?
 

Darg

Administrator
Reaction score
49
I initially said to use the "Convert Real to Integer" function, then quickly realised it wouldn't really do much in the end : - )
 

GooS

Azrael
Reaction score
154
;D I'll make a combotrigger then post it here and you could say if it would work, however this would mean indexing the unit in a variable of some sort while calculating the new stats , or do I have to?

Can't you set normal number like curent str of hero + 1?
No I don't want the attribute increment to be static and I don't want to make a trigger for each level, and in this way your attributes would increase more and more the higher level you get.
 

Trollvottel

never aging title
Reaction score
262
if you want small bonusses then just use a real variable and increase it a bit and if it is higher than 1, add 1 str/agi/int-point and decrease the variable by 1
 

GooS

Azrael
Reaction score
154
if you want small bonusses then just use a real variable and increase it a bit and if it is higher than 1, add 1 str/agi/int-point and decrease the variable by 1

Sry I dont quite understand how that would solve my problem, it's not that I want small increments it's that I want them to get higher attribute bonuses the higher level they get.

I might have just missunderstood you could you clearify what you mean ;D?
 

GooS

Azrael
Reaction score
154
Just a noob asking for help, JASS possibility?

Well the question is simple so all just get it out there.
Is it possible with JASS to do as following:

Set a Real variable to current attribute of hero

take that Real variable multiply it by 1.1

round that variable up to closest integer

set hero attribute to that Integer

In addition the trigger should be able to be called from many heroes at the same time.
It sounds easy and probably is for many of you JASSers, however I couldn't find a way using GUI.
If this is possible, I might just have to learn JASS ;D

Thx in advance.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Try it in GUI, you don't seem to need any waits, so it should be MUI even though you'd use globals in GUI.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Code:
Attribute Gain
    Events
        Unit - A unit Gains a level
    Conditions
        (Unit-type of (Triggering unit)) Equal to Paladin
    Actions
        Set CurrentStr = (Strength of (Triggering unit) (Exclude bonuses))
        Set StrGain = ((Real(CurrentStr)) x 1.10)
        Set StrGainFinal = (Integer(StrGain))
        Hero - Modify Strength of (Triggering unit): Add (StrGainFinal - CurrentStr)

Just change/remove the conditions.

CurrentStr = Integer Variable
StrGain = Real Variable
StrGainFinal = integer Variable
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Code:
Attribute Gain
    Events
        Unit - A unit Gains a level
    Conditions
        (Unit-type of (Triggering unit)) Equal to Paladin
    Actions
        Set CurrentStr = (Strength of (Triggering unit) (Exclude bonuses))
        Set StrGain = Integer(((Real(CurrentStr)) x 1.10))
        Hero - Modify Strength of (Triggering unit): Add (StrGain - CurrentStr)

Just change/remove the conditions.

CurrentStr = Integer Variable
StrGain = Integer Variable

Edited it a bit so he doesn't need 2 "gain" variables.
 

GooS

Azrael
Reaction score
154
Ahh thx very much , both of you ;)

My mind is currently so out of it :)
Will edit it a bit though ^^
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
> round that variable up to closest integer

@above codes
That does not round to the closest integer.
Converting a Real to Integer removes the decimals, but does not round it.
7.6 becomes 7, 100.9999 becomes 100, etc.

Add 0.5 to the Real before converting it to Integer if you want to round it.
 

Mittsies

New Member
Reaction score
24
Keep in mind no matter what, your hero attribute will NEVER be a decimal. If you multiply 31 strength by 1.1 you will get 34, not 34.1 (It will round down, but it will never round up, even its 34.9). If you want your hero's attribute to be a decimal, well, it's not possible to my knowledge.

EDIT: Just noticed darkRae's post, haha.
 

Technomancer

New Member
Reaction score
14
If this is accurate then how does DotA have decimals in their strength gains?

If you wanted to make a trigger for it simply have reals that store the stat gains, then a loop like so:

loop
exitwhen StrGainReal < 1.
StrGainReal = StrGainReal - 1
A 1 to HeroStat (whatever the code is for that)
endloop
 

GooS

Azrael
Reaction score
154
Hmm did not work, either I made the trigger wrong:
Code:
Set StrGain = (Integer(((Real(CurStr)) x 1.10)))
But it seems as if it automatically rounds down the real value.
Tried 4 lvlups and got 1 str each lvl even though 18 (starting str) * 1.1 = 19.8 and should be round up to 20.

Edit:
Thx darkRae, yah that should work, I dont want the stats to display the attribute as a decimal, just so that the increment is not static from lvl to lvl not using to many triggers.
 

GooS

Azrael
Reaction score
154
That does not round to the closest integer.
Converting a Real to Integer removes the decimals, but does not round it.
7.6 becomes 7, 100.9999 becomes 100, etc.

Add 0.5 to the Real before converting it to Integer if you want to round it.

This is true, so to always get the -in lack of better word I use javascript- roof of a number i should add 0.99 instead of 0.5

I realized after trying with 0.5 that the attribute increment was to low as the Max lvl for that map this is going to be in is 20.

Thx all for helping :)

Edit: Posting result
Using arrays to reduce the amount of variables, index 1 = str, 2 = int, 3 = agi.
The (Race of (Triggering unit)) Equal to Human condition will be changed later on for possibly custom values or any other varibles that are designated at map init, this was just for testing.
Reason for the If is cus there will be diffrent multipliers for the diffrent heroes depending on Primary Attributes and such.

Code:
Level Increase
    Events
        Unit - A unit Gains a level
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Race of (Triggering unit)) Equal to Human
            Then - Actions
                Set CurAtt[1] = (Strength of (Triggering unit) (Exclude bonuses))
                Set AttGain[1] = ((Real(CurAtt[1])) x 1.10)
                Set AttGain[1] = (AttGain[1] + 0.99)
                Set AttGainFinal[1] = (Integer(AttGain[1]))
                Hero - Modify Strength of (Triggering unit): Add (AttGainFinal[1] - CurAtt[1])
            Else - Actions

This system work exactly as it's meant to sofar, a bit changed attributes, but no more than 2 extra str at lvl 20 (maxlvl).

Increments are as follow in str/lvl 2,2,3,3,3,4,4,4,5,5,6,6,7,8,8,9,10,11,12

Perfect for my map ^^ Thx again y'all.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top