RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Making a variable a multiple of a number.

0 Members and 1 Guest are viewing this topic.

****
Touhou Fantasy Developer and all around cool person. :)
Rep:
Level 85
T.G. "Thunder God" Xenomic
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...)?

***
Rep:
Level 82
IT ALL ENDED.
Cant you use a parallel process to check the player's level Periodically?

****
Touhou Fantasy Developer and all around cool person. :)
Rep:
Level 85
T.G. "Thunder God" Xenomic
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 @_@

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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.

****
Touhou Fantasy Developer and all around cool person. :)
Rep:
Level 85
T.G. "Thunder God" Xenomic
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...
« Last Edit: May 14, 2011, 01:19:38 AM by Xenomic »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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

****
Touhou Fantasy Developer and all around cool person. :)
Rep:
Level 85
T.G. "Thunder God" Xenomic
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 ^^; )

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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.

****
Touhou Fantasy Developer and all around cool person. :)
Rep:
Level 85
T.G. "Thunder God" Xenomic
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!)

*
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Modern Algebra's down with the algebraic formulae.
n = (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.
it's like a metaphor or something i don't know