- Joined
- Feb 22, 2006
- Messages
- 960
So i was a bit borred and then i tested a bit around and created a littel exponential system which creates an exponential equation. you can call each product from these equation:
here a sample usage:
the original math formula is = f(x) = c * a^x
so in my case c = 300 | a = 1.3 | x = 5
note: a > 1 increase | a < 1 decrease
the last number in the function call is always the number of the instance
this will create following reals (expostruct.r[1-5])
r[1] = 390.00
r[2] = 507.00
r[3] = 659.10
r[4] = 856.83
r[5] = 1113.879
you get this reals with the function
to destroy a Expo you have the function
then you could use it for your spell
i think the system could be usefull for some spells which increases damage per time or something like that
JASS:
library ExpoSystem
globals
private constant integer x = 100 //not more then 100 powers
private constant integer MAX_PLAYER = 12 //max player support
private constant integer MAX_INSTANCES = 3000 //max instances which can be created at the same time per player
private boolean array EXPO_ALREADY [MAX_PLAYER]
endglobals
private struct expostruct
real array r [x]
static method create takes real c,real a,integer n returns expostruct
local expostruct dat = expostruct.allocate()
local integer i = 1
set dat.r[1] = c*a
loop
exitwhen i >= n+1
set dat.r[i] = dat.r[i-1]*a
set i = i + 1
endloop
return dat
endmethod
endstruct
globals
private expostruct array Dat [MAX_INSTANCES] [MAX_PLAYER]
endglobals
function CreateExpo takes real c, real a, integer n,player p,integer instance returns nothing
if instance > 3000 then
debug call BJDebugMsg("You can't have more then 3000 instances so pls chose a number under 3000!")
return
endif
if Dat[instance] [GetPlayerId(p)] > 0 then
call expostruct.destroy(Dat[instance] [GetPlayerId(p)])
set Dat[instance] [GetPlayerId(p)] = expostruct.create(c,a,n)
endif
endfunction
function GetExpo takes integer n,player p,integer instance returns real
return Dat[instance] [GetPlayerId(p)].r[n]
endfunction
function DestroyExpo takes player p,integer instance returns nothing
call expostruct.destroy(Dat[instance] [GetPlayerId(p)])
endfunction
endlibrary
here a sample usage:
the original math formula is = f(x) = c * a^x
so in my case c = 300 | a = 1.3 | x = 5
note: a > 1 increase | a < 1 decrease
the last number in the function call is always the number of the instance
call CreateExpo(300,1.3,5,Player(0),1)
this will create following reals (expostruct.r[1-5])
r[1] = 390.00
r[2] = 507.00
r[3] = 659.10
r[4] = 856.83
r[5] = 1113.879
you get this reals with the function
GetExpo(1-5,Player(0),1)
to destroy a Expo you have the function
DestroyExpo(GetTriggerPlayer(),1)
then you could use it for your spell
i think the system could be usefull for some spells which increases damage per time or something like that
Last edited: