Need a formula

Dinowc

don't expect anything, prepare for everything
Reaction score
223
I'm completely stuck as I can't figure out a proper formula for this scaling

Ability Level | Damage

1 | 80
2 | 120
3 | 175
4 | 245
5 | 330

as you can see, the increase is exponential, each time it deals +15 more damage than on previous bonus

so:
80 + 40 = 120
120 + 55 = 175 (since 40 + 15 = 55)
175 + 70 = 245 (since 55 + 15 = 70)
245 + 85 = 330

and so on...

my current formula is this:
JASS:
private function Damage takes integer level returns real
    return DAMAGE_BASE + (level - 1) * (DAMAGE_LEVEL + DAMAGE_INCREASE)
endfunction

where:
DAMAGE_BASE = 80
DAMAGE_LEVEL = 40
DAMAGE_INCREASE = 15

obviously it returns wrong values :/
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
thx but how would I make it configurable?

cause I can't just use 7.5, 17.5 and 55 :/
I need a constant formula so I can easily change the scaling later

is there a way to do it with exponentiation or something?
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
globals
    private integer array myDamage
endglobals

function onInit takes nothing returns nothing
    set myDamage[1] = 80
    set myDamage[2] = 120
    set myDamage[3] = 175
    set myDamage[4] = 245
    set myDamage[5] = 330
endfunction
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Damage = 80 + 40*(Level-1) + 15*(3^(Level-2))

Is that what you're looking for?
EDIT: Thats not right yet. Level-2 still turns up negative. Let me think of something else.
EDIT2: Here. This should work.
Code:
function CalculatePower takes integer Int returns integer
    local integer Power = ((Int*(Int+1))/2)
    if ( Power <= 0 ) then
        return 0
    endif
    return Power
endfunction

function CastSpell takes integer Level returns nothing
    local integer Damage = (80 + (40*(Level-1)) + (15*CalculatePower(Level-2)))
endfunction
Damage dealt is the same as the local "Damage". The first function only checks if there is any power of 15 to add. Results:
Code:
1).  80 + 40*0(  0) + 15* 0(  0) =  80
2).  80 + 40*1( 40) + 15* 0(  0) = 120
3).  80 + 40*2( 80) + 15* 1( 15) = 175
4).  80 + 40*3(120) + 15* 3( 45) = 245
5).  80 + 40*4(160) + 15* 6( 90) = 330
6).  80 + 40*5(200) + 15*10(150) = 430
7).  80 + 40*6(240) + 15*15(225) = 545
8).  80 + 40*7(280) + 15*21(315) = 675
9).  80 + 40*8(320) + 15*28(420) = 820
10). 80 + 40*9(360) + 15*36(540) = 980
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
EDIT2: Here. This should work.
Code:
function CalculatePower takes integer Int returns integer
    local integer Power = ((Int*(Int+1))/2)
    if ( Power <= 0 ) then
        return 0
    endif
    return Power
endfunction

function CastSpell takes integer Level returns nothing
    local integer Damage = (80 + (40*(Level-1)) + (15*CalculatePower(Level-2)))
endfunction

you're the man :thup:
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
If you want the formula for the sequence its:

Damage = (7,5)(n)^2 + 22,5(n)+ 55 < where n is the level of the skill

All you need is the level of the ability and you've got the damage

EDIT 1: Not quite correct, tried to work it out in my head
Did it the right way and got a piece of paper and now I got it:

Damage = (7,5)(n)^2 + 17,5(n) + 55 < again, n is the level of the skill:

lvl 1 - Damage = (7,5)(1)^2 + 17,5(1) + 55 = 80
lvl 2 - Damage = (7,5)(2)^2 + 17,5(2) + 55 = 120
lvl 3 - Damage = (7,5)(3)^2 + 17,5(3) + 55 = 175
lvl 4 - Damage = (7,5)(4)^2 + 17,5(4) + 55 = 245
lvl 5 - Damage = (7,5)(5)^2 + 17,5(5) + 55 = 330
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
So the commas are supposed to be periods, from "," to "."? I think some people use commas instead of decimal points when doing sums.
 

keychup

Active Member
Reaction score
34
that's silly. if i were to use fullstops instead of commas my number would look like this:

300.000,000

what does that look like? a 300?
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
7,5 >>> seven and a half :D
Because mathematically . can be interpreted as x (multiply)
So: 7.5 could be read as 7x5 that's why I write seven and a half with a ,

and besides, 300,000,000.99 just makes it easier to read, not that important in maths, I would rather write it as 300 000 000,99
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
* is used for programming syntax, on paper though, which is where I do my calculations, "." means multiply
It's too much of a luss to write x every time you need to multiply, plus X is a common variable name, so you don't really
write: Xx2x33xX, for sanity's sake you'd rather write x.2.33.x = 66x^2
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Still, someone that wants to use your numbers will have to change all the , to ..
And even more, if they don't make the assumption that's the change, has to reply to the thread asking if , is supposed to be ., then wait for you or someone else to reply.
I never said use x, I said * :p
 

Romek

Super Moderator
Reaction score
963
> Because mathematically . can be interpreted as x (multiply)
a·b, not a.b. And this only applies to unknowns/variables. You don't use 'dots' for multiplication when you know the values, because of the ambiguity with a decimal point (such as your value of 7·5). Also, commas are used to separate thousands when writing large numbers (10,000,000 vs 10000000), so they're not the best alternative either.
I know in some countries ',' is used as a decimal point instead of '.', though in all programming languages, including JASS and GUI, '.' is used for a decimal point, and '*' for multiplication.

Let's not start trying to change the standard. :p
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
Very true, but I just happen to be in one of those countries :p
when I do programming I switch to the standard syntax, just math where I use a , :p

Anyways, did he come right with the formula?
 
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