• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Math hard, want formula, too dumb

Status
Not open for further replies.
Level 1
Joined
Jan 23, 2015
Messages
160
I'm trying to make so player can level up and pick ability "health bonus"

I don't math math, help me please


  • Set NonHeroHealthBonus[UDex] = ((1 x (Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex])) x 10)

I just want it so for that every additional level of the ability "health bonus" they don't get +10 per level, they get -


Level 0 = nothing, of course
Level 1 = +10 Health
Level 2 = +20 (Not just another 10) = 30
Level 3 = +30 (Not just another 10) = 60
Level 4 = + 40 (Not just another 10) = 100


Thanks a lot guys.
 
Last edited:
Level 1
Joined
Jan 23, 2015
Messages
160
Make 4 abilities, with 10/30/60/100hp bonus and remove/add them accordingly (since hp bonus doesn't work past lvl 1). Or create 10/20/30/40hp bonus abilities and just add them up.

Really, no need to do anything more complex.

Forgot to mention, using bonus mod. Can get basically any number.

Just need the equation to have it so that a level up isn't +10 HP, it would be +20 if it was leveled up to level 2. It would be +30 if it were leveled up to level 3.
Base Health is 10 + Level of Ability "Health Bonus" = Total Health

10 + level 0 "Health Bonus" = 10

10 + level 1 "Health Bonus" = 20

10 + level 2 "Health Bonus" = 30

10 + level 3 "Health Bonus" = 40

etc

You know what I mean? It is difficult to say because if I knew how to say it I would be able to type it right haha. Thanks a lot for your fast help!
 
Last edited:
Level 1
Joined
Jan 23, 2015
Messages
160
I know how to use bonus mod.

My only problem is I don't know how to use math lol

I need an equation please.

I think I am getting closer

Base Health is 10 + Level of Ability "Health Bonus" = Total Health

level 0 "Health Bonus" = +0 Health
Base Health = 10

level 1 "Health Bonus" = +10
Base Health = 20

level 2 "Health Bonus" = +20 Health
Base Health = 40

level 3 "Health Bonus" = 30
Base Health = 70


etc

I'm using GUI
 
Last edited:
Level 1
Joined
Jan 23, 2015
Messages
160
You literally just need to add the difference between levels. I don't understand what the problem is. Just add 10 * level each time you level up the ability. It adds up to 100.

I don't have any problem buddy

Could you show me in trigger talk how to do what I asked for?


  • Set NonHeroHealthBonus[UDex] = ((1 x (Level of Non-Hero Stats (Health Bonus)) for UDexUnits[UDex])) x 10)
  • No problems, friend, just can't do math. Thanks again
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
Oh how convenient! I just lectured a Calculus 2 class on infinite series and sequences :>

The bonus for level 0 seems rather redundant, so I'm going to redefine the sequence as an = {10, 30, 60, 100...} where n represents the ability level (so we start at n = 1)

The terms of the sequence can easily factor into 10 or 5. However, since I'm thinking ahead, I'm pretty confident that 5 is our best choice. In order for 5 to become 10, we need to multiply by 2. Since n = 1, we need that to somehow become 2. In addition, if n = 2, we need our n to somehow transform into 6. Fortunately, I've been working with infinite sequences for a while... so I know that our sequence can be represented by: an = 5(n^2 + n)

Let's try it out!

If the ability level is 1, then a1 = 5((1)^2 + 1) = 5(1 + 1) = 5(2) = 10
If the ability level is 2, then a2 = 5((2)^2 + 2) = 5(4 + 2) = 5(6) = 30
a3 = 5((3)^2 + 3) = 5(9 + 3) = 5(12) = 60
a4 = 5((4)^2 + 4) = 5(16 + 4) = 5(20) = 100
a5 = 5((5)^2 + 5) = 5(25 + 5) = 5(30) = 150
and sooo on and so forth...​
 
I already gave you the answer. Each level, add 10 * ability level HP. That way, on four levels it adds up to 100. 10 + 20 + 30 + 40 = 100. This is literally an arithmetic sequence, but you don't even need to understand math to grasp this concept at such a tiny scale.

Also this is not a triggering problem, this is a math problem, and I have not used GUI for literally 10 years at this point, and neither will I even try to decipher unreadable "GUI friendly" stuff.
 
Level 1
Joined
Jan 23, 2015
Messages
160
Oh how convenient! I just lectured a Calculus 2 class on infinite series and sequences :>

The bonus for level 0 seems rather redundant, so I'm going to redefine the sequence as an = {10, 30, 60, 100...} where n represents the ability level (so we start at n = 1)

The terms of the sequence can easily factor into 10 or 5. However, since I'm thinking ahead, I'm pretty confident that 5 is our best choice. In order for 5 to become 10, we need to multiply by 2. Since n = 1, we need that to somehow become 2. In addition, if n = 2, we need our n to somehow transform into 6. Fortunately, I've been working with infinite sequences for a while... so I know that our sequence can be represented by: an = 5(n^2 + n)

Let's try it out!
If the ability level is 1, then a1 = 5((1)^2 + 1) = 5(1 + 1) = 5(2) = 10
If the ability level is 2, then a2 = 5((2)^2 + 2) = 5(4 + 2) = 5(6) = 30
a3 = 5((3)^2 + 3) = 5(9 + 3) = 5(12) = 60
a4 = 5((4)^2 + 4) = 5(16 + 4) = 5(20) = 100
a5 = 5((5)^2 + 5) = 5(25 + 5) = 5(30) = 150
and sooo on and so forth...

So I could just down and dirty into arrays using that?
 
Last edited:
No, considering how bonus mod works, it is an arithmetic sequence, since he wants values to be 10/30/60/100, the real sequence he needs is 10/20/30/40 since that's the number he's adding via bonus mod. He doesn't need to care about the net total, he needs to care about the ADDITION.

It is literally down to adding 10 * ability level each level up. That's all. That's literally the solution to this problem. There's nothing else and I don't understand how this is hard to understand.
 
I said:
Each level, add 10 * ability level HP.
I said:
Each level, add 10 * ability level HP.
I said:
Each level, add 10 * ability level HP.

I got the impression he wants to add 10/30/60/100 bonus, not 10/20/30/40.

If the former, I guess my way works. If the latter, go with HappyTauren.

I went with how he explained it. The number on the right of his equation is the net total, the numbers on the left are how he gets there. Either way, I am defeated.
 
Thanks for spamming what you said, let's look at what he said:
They don't get 10 per level in my case, either.
They get 10 * level. Not in total. Every level, that's the addition. As I said. That's my point. It adds up to 100 in the end, which is according to his original equation.

This is how bonus mod works. You ADD a bonus, and I said he should ADD 10 * level every level up. Bonus mod doesn't care about your total bonus, you should be thinking of increments.
 
You gain such behaviour if you use summationrow (not sure how that is called in english but try out Gaußsche Summenformel).

as jass with the wanted result.
JASS:
function PrivateCalcValue takes real base, real addPerLevel, real levelSummationMulti, integer level returns real
   return base + addPerLevel * (level) + (levelSummationMulti * (level*(level+1)) / 2)
endfunction

If you want to mimic world Editors autofill feature you can do that below, less math.
JASS:
function PrivateCalcValue takes real base, real addPerLevel, real multiOfPrev, real levelSummationMulti, integer level returns real
   local integer loopA = 2
   local real amount = base
   loop
       exitwhen loopA > level
       set amount = amount * multiOfPrev
       set amount = amount + addPerLevel
       set amount = amount + levelSummationMulti * loopA
       set loopA = loopA + 1
   endloop
   return amount
endfunction
 
Level 1
Joined
Jan 23, 2015
Messages
160
Thanks for spamming what you said, let's look at what he said:

They don't get 10 per level in my case, either.
They get 10 * level. Not in total. Every level, that's the addition. As I said. That's my point. It adds up to 100 in the end, which is according to his original equation.

This is how bonus mod works. You ADD a bonus, and I said he should ADD 10 * level every level up. Bonus mod doesn't care about your total bonus, you should be thinking of increments.

I just needed help with an equation trigger style, HappyTauren. I appreciate everyone's help. Killcide was pushing it in the right direction, I need it to basically be +10 each time, I think? I'm very sorry it is hard to be specific.

I do have excel, but I'm not great with it
 
Alright, so tell me how much TOTAL bonus HP the unit is supposed to get from this ability at each level.

Let's say the unit has 1000 HP. And level 1 ability. How much HP should it have? How much should it have with level 2/3/4 ability? Let's go from there.

Again, this is not about any sort of an equation, you literally need to figure out how much you ADD each time, since that's all you need to care about with the bonus mod.
 
Level 1
Joined
Jan 23, 2015
Messages
160
Alright, so tell me how much TOTAL bonus HP the unit is supposed to get from this ability at each level.

Let's say the unit has 1000 HP. And level 1 ability. How much HP should it have? How much should it have with level 2/3/4 ability? Let's go from there.

Again, this is not about any sort of an equation, you literally need to figure out how much you ADD each time, since that's all you need to care about with the bonus mod.

I do not yet know exactly how I want to scale my game

As as a start I was using each "Health Bonus" point got a solid +20 HP

But I want it to scale! How can I do this? Eventually, 20 might become useless, right?

I want to scale this ability. I want it to do +20 HP at first level

So, if base Health is 10 HP, that puts them at 30 HP

I want to scale still. What now? OK, I'm thinking +30 at second level.

So, if base Health is 30 from last "Health Bonus" then at level 2 it base HP is 60
 
Level 1
Joined
Jan 23, 2015
Messages
160
it is summation row.
  • ( (level * (level + 1) ) / 2 ) x multi

I'm no math wiz, but this looks like it would work. Could you noob GUI this for me


- edit

Nevermind I will do that myself in the morning. Thanks guys, will update tomorrow
 
That could be what he said. But it could also be something else. In summation, he has no idea what he really wants and has no idea how to express it. For now, though, since he wants the bonus to scale, he's probably the best off using your formula.

But here's the problem.

HE IS USING THE BONUS MOD.

HE NEEDS TO BE CONCERNED WITH HOW MUCH HE ADDS EACH LEVEL. That's what he needs to calculate to actually make this work.
 
Level 1
Joined
Jan 23, 2015
Messages
160
That could be what he said. But it could also be something else. In summation, he has no idea what he really wants and has no idea how to express it. For now, though, since he wants the bonus to scale, he's probably the best off using your formula.

But here's the problem.

HE IS USING THE BONUS MOD.

HE NEEDS TO BE CONCERNED WITH HOW MUCH HE ADDS EACH LEVEL. .

xoxo
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Yeah you should stop beating around the bush and just say what the total bonuses are for each level. The sequence formula I provided adds 10/30/60/100 and possibly 150 if you wanted to keep up the pattern going. If you want something linear like 10/20/30/40, then this whole thread was pretty much pointless lol.

HappyTauren's will also work for 10/30/60/100 since he uses recursion (you can already see in this conversation who the programmer and who the mathematician is).
 
Level 1
Joined
Jan 23, 2015
Messages
160
Yeah you should stop beating around the bush and just say what the total bonuses are for each level. The sequence formula I provided adds 10/30/60/100 and possibly 150 if you wanted to keep up the pattern going. If you want something linear like 10/20/30/40, then this whole thread was pretty much pointless lol.

HappyTauren's will also work for 10/30/60/100 since he uses recursion (you can already see in this conversation who the programmer and who the mathematician is).

Wasn't trying to beat around the bush buddy. Was literally just asking for help. Thanks guys
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,217
In worst case you could use a look up table, basically an array that maps ability level as an index to values.

Otherwise if you want it to naturally scale there are surprisingly few useful formula one can use.

Linear scale: {Constant} * {Ability Power} // Such as used by games like Xenoblade Chronicals 1.
Exponential scale: {Constant} * {Multiplier} ^ {Ability Power} // Such as used by games like Heroes of the Storm.
Logarithmic scale: {Constant} * ln({Base} + {Multiplier} * {Ability Power}) // Used to scale powerful effects similar to Diablo II.

Ability Power can be computed a variety of different ways. In Xenoblade it is usually some quantity of the hero stats. Heroes of the Storm it is simply just team level.
 
Level 1
Joined
Jan 23, 2015
Messages
160
In worst case you could use a look up table, basically an array that maps ability level as an index to values.

Otherwise if you want it to naturally scale there are surprisingly few useful formula one can use.

Linear scale: {Constant} * {Ability Power} // Such as used by games like Xenoblade Chronicals 1.
Exponential scale: {Constant} * {Multiplier} ^ {Ability Power} // Such as used by games like Heroes of the Storm.
Logarithmic scale: {Constant} * ln({Base} + {Multiplier} * {Ability Power}) // Used to scale powerful effects similar to Diablo II.

Ability Power can be computed a variety of different ways. In Xenoblade it is usually some quantity of the hero stats. Heroes of the Storm it is simply just team level.

This is very helpful. Thanks Doc. I thought about scaling it off of something like this:

unit's base health (from object editor, just a flat number) + 5%,10%,15% etc

where the right side is the bonus of max health based on the base health, the same one from object editor.

The problem I have is using items that increase max health too. The player can abuse this by equipping an item, accepting the level up, choosing the "Health Bonus" and then just remove the item.



I think I'm asking for something a lot more complex than what I thought I was asking for. I'm basically just asking for a spray-on scaling system huh? I promise I didn't mean to ask for that haha
 
Level 1
Joined
Jan 23, 2015
Messages
160
I appreciate everyone's help - I have evolved what I'm doing into a new thread

Hope I am more clear in that one, and I have provided a demo map.

Thanks again
 
Status
Not open for further replies.
Top