So I started coding a Level 5 spell for my game, and I am curious if there's an easier way to code this in without having to set a variable to the character's level, then having a whole bunch of conditional branches for each separate level (I'm hoping there is, as the level 2 and level 3 spells will be a nightmare to code if that's the case...)?
Cant you use a parallel process to check the player's level Periodically?
I suppose you could, but that'd still require the same coding as I'm using right now to make it work the way I have intended @_@
I'm not quite sure what you are asking for, but assuming you mean you want the skill to have, for instance, a greater effect everytime the level is a multiple of 5 (5, 10, 15, 20, etc...), then you could just use the modulus function. So, set a variable to the actor's level. Then mod it by 5. You would then need only one conditional branch which checks if that variable is equal to 0.
Just so you know, what modulus does is essentially give you the remainder of the variable when it is divided by 5.
Oh really? I never knew what modulus was so...I guess that helps a lot. So then...how exactly would I word it? Like...
If var[Level] is Mod 5
Change Cond: Instant Death
Else
End
Something like that??
EDIT: Ok, so a little confused. But yeah, I just want the skill to do something when it's THOSE levels, such as Level 5 Death on those with multiples of 5 in their level. So first I'd set a variable to that character's Level (so if it were Cloud, I'd make var[0001] set equal to Cloud's level), then I'd make a variable after that where var[0001] is Mod 5, then the conditional branch of....I'm lost now x_x;;
Sorry if I seem...a bit nooby right now. Never used this, so not sure what the hell I'm doing lol...
That's pretty much it. It would be something like this:
<>Variable Oper: [0001:Level] Set, Cloud Level
<>Variable Oper: [0001:Level] Mod, 5
<>Branch if Var [0001:Level] is 0
<>Special effect if level is multiple of 5
: Else
<>Regular effect
: End
I see, I see. Though I'm confused as to why 0 for the 3rd line. How exactly does it check to see if its 0 for 5 and 0? I'm assuming that if it's a number divisible by 5, then it'll automatically be 0 (or if it's a number evenly divisible in this case)? So basically it's just the extension of the divide function (thinks he is repeating what was already said ^^; )
Well, think of it this way. All numbers can be rewritten like this:
0 = (5*0) + 0
1 = (5*0) + 1
2 = (5*0) + 2
3 = (5*0) + 3
4 = (5*0) + 4
5 = (5*1) + 0
6 = (5*1) + 1
7 = (5*1) + 2
8 = (5*1) + 3
9 = (5*1) + 4
10 = (5*2) + 0
11 = (5*2) + 1
12 = (5*2) + 2
13 = (5*2) + 3
14 = (5*2) + 4
15 = (5*3) + 0
...
n = (5*a) + b
Dividing n by 5 gives you a, while modding n by 5 gives you b. So, essentially:
n / 5 = a
n % 5 = b
Whenever b is equal to 0, it means there was no remainder from the division operation, which means it is a multiple of 5.
Hmm....you learn something new everyday. I think I get it now, so now I'll be able to put this to use~ Much obliged for the help! I never fixed the codings from long ago (dunno if I want to go back and reduce the coding for Level 5 Death at the moment though...that would take quite a bit of work to do lol...not that I haven't done enough work as it is!)
Modern Algebra's down with the algebraic formulae.
Quote from: modern algebra on May 14, 2011, 01:44:03 AMn = (5*a) + b
n / 5 = a
n % 5 = b
Whenever b is equal to 0, it means there was no remainder from the division operation, which means it is a multiple of 5.
Word.