HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

A stupid question....

12-02-2007, 11:47 PM#1
burningice95
.....but how do you add decimal values to a hero attribute...if you use R2I, does that round up?
12-03-2007, 12:11 AM#2
Ignitedstar
I believe it rounds down, no matter what. If you want the illusion of rounding up, add .50 to the real value. That's what I've been told and what I've heard.
12-03-2007, 01:19 AM#3
burningice95
I know its doable...I've seen it done before...but all the functions to modify hero attributes take an integer.....
12-03-2007, 02:00 AM#4
XieLong
Yes, they do... and if you add 0.5 before using the R2Ifunction, it will be round real. But Ignitedstar allready sayed so...
12-03-2007, 02:23 AM#5
burningice95
grr...but there must be a workaround....although i suppose, that since the stat bonuses are awarded for killing units, i could make a global integer, and whenever that particular unit kills 5 units, it gets +1 str (.2 for units). But then it wouldn't be multi-instancable, since i don't know JASS, so i don't know how to attach integers to units...
12-03-2007, 03:07 AM#6
Ammorth
Use the custom value of the unit. It stores an integer to each unit. When the unit kills a unit, increase this value by 1. The if the value is 5, set the custom value to 0 and add 1 str. Rinse and repeat.
12-04-2007, 01:11 AM#7
burningice95
But what if I'm already using custom values....is there another GUI solution?
12-04-2007, 02:22 AM#8
vesuvan doppleganger
Userdata is unlimited if you know how to use it. All you have to do is store a number on a unit, and then use that as an index for as many arrays as you want.
12-04-2007, 02:59 AM#9
Ammorth
or convert to jass and learn how to use structs. Personally, if you have the time, learn jass. It may seem hard at first, but after awhile you will be able to code more complex code quicker and even some of the simpler code will be easier to write out than using GUI.
12-04-2007, 08:12 PM#10
burningice95
Quote:
Originally Posted by vesuvan doppleganger
Userdata is unlimited if you know how to use it. All you have to do is store a number on a unit, and then use that as an index for as many arrays as you want.

We'll i'm using a system that is constantly changing the custom data of a unit in order to keep track of how many kills it has, so the value is constantly changing...
12-04-2007, 11:11 PM#11
Jazradel
Have a integer array for the kill number.

Set the custom value for each unit to a unique value.

Then use KillArray[Custom Value of Unit] to get it.

And so on for each value you need to track.
12-05-2007, 01:08 AM#12
burningice95
This is what I came up with:

Trigger:
Find Reapers
Collapse Events
Unit - A unit Learns a skill
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Reaper
Collapse Actions
Unit - Set the custom value of (Triggering unit) to ReaperInit
Set ReaperInit = (ReaperInit + 1)

Gives each reaper a unique custom value...

Trigger:
Reapers Scyte
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Unit-type of (Killing unit)) Equal to Reaper
Collapse Actions
Set KillArray[(Custom value of (Killing unit))] = (KillArray[(Custom value of (Killing unit))] + 1)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(KillArray[(Custom value of (Triggering unit))] Greater than or equal to (90 - ((Level of Death for (Killing unit)) x 10))) and ((Level of Death for (Killing unit)) Equal to 0)
Collapse Then - Actions
Unit - Add Reapers Scythe (Neutral Hostile) to (Picked unit)
Set KillArray[(Custom value of (Killing unit))] = 0
Else - Actions
Set BonusArray[(Custom value of (Killing unit))] = (BonusArray[(Custom value of (Killing unit))] + 1)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Dying unit) is A Hero) Equal to False
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(BonusArray[(Custom value of (Killing unit))] Greater than or equal to 5) and ((Level of Death for (Killing unit)) Equal to 1)
Collapse Then - Actions
Hero - Modify Strength of (Killing unit): Add 1
Set KillArray[(Custom value of (Killing unit))] = 0
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(BonusArray[(Custom value of (Killing unit))] Greater than or equal to 3) and ((Level of Death for (Killing unit)) Equal to 2)
Collapse Then - Actions
Hero - Modify Strength of (Killing unit): Add 1
Set KillArray[(Custom value of (Killing unit))] = 0
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(BonusArray[(Custom value of (Killing unit))] Greater than or equal to 2) and ((Level of Death for (Killing unit)) Equal to 3)
Collapse Then - Actions
Hero - Modify Strength of (Killing unit): Add 1
Set KillArray[(Custom value of (Killing unit))] = 0
Else - Actions
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Death for (Killing unit)) Equal to 1
Collapse Then - Actions
Hero - Modify Strength of (Killing unit): Add 1
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Death for (Killing unit)) Equal to 2
Collapse Then - Actions
Hero - Modify Strength of (Killing unit): Add 2
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Death for (Killing unit)) Equal to 3
Collapse Then - Actions
Hero - Modify Strength of (Killing unit): Add 3
Else - Actions

Here is what I hope it does: If he has over 80 kills at level 1, 70 at level 2, or 60 at level 3, it adds the "Reapers Scythe" ability to the the killing unit. It also adds 1 str for each 5 units killed, if death is level 1, 1 str for each 3 units killed it death is level 2, and 1 str for each 2 units killed at level 3.

Thanks for the help!
12-05-2007, 01:32 PM#13
Strilanc
As a GUI person you might not find this useful, but here are the 4 common rounding operations implemented in Jass:

Collapse JASS:
    ///Returns first integer at most as large as r
    function floor takes real r returns integer
        local integer i = R2I(r)
        if (i > r) then
            return i-1
        else
            return i
        endif
    endfunction
    ///Returns first integer at least as large as r
    function ceiling takes real r returns integer
        local integer i = R2I(r)
        if (i < r) then
            return i+1
        else
            return i
        endif
    endfunction
    ///Returns the integer you get by rounding r
    function round takes real r returns integer
        return floor(r+0.5)
    endfunction
    ///Returns the integer you get by cutting off the digits after the decimal point in r
    function truncate takes real r returns integer
        return R2I(r)
    endfunction
12-05-2007, 08:08 PM#14
burningice95
Well the problem isn't finding an appropriate integer to add...its the fact that the hero field takes an integer, and not a real, so that means no decimals....but I may actually need those for something else, so thanks!