Using variable in a formula

I'm trying to build a system in which a spell's effect depends on variables :


User A selects a spell, a window pops up and asks if he wants to overcharge the spell (Ie : pay more to get a better effect/damage)


Depending on his answer Variable Overcharge is set to say +2


I'd like a way to input in my note box a way to check for that variable (long way would be with Ifs) and process a different damage formula depending on it's value


If you could give me an exemple with such a formula, it would be swell !


Bonus points if it's on multiple lines so i'm sure i understand where the colons and such go


TLDR : What syntax to check a variable in the damage formula


Cheers !


Secondary question : Do you think it would slow the game too much to add such a choice to the spells ?


What if i made it into a slidebar using common event ?
You seem to be all focused on "how am I going to use a variable in a skill's damage formula"?  That's easy.  v[1] in the damage formula gives you the value in variable 1.


My question is how are you going to get a window to pop up after they select the skill giving them the option to choose, and set the variable, in the first place?


You will need a plugin for that.
So could i use "If v[1] == 2" as a valid line ?


For your question : I was thinking to have the skill call a common event with a bind image and some heavy duty X and Y fun, scrictly eventing it


Like


If X > 75


add V[1]


    If X > 80


add V[2]


I've already done one like that, and i thought common eventing on a skill would allow me to (?)


If not that's gonna be a nail in my game concept ^^
Common events are run after damage is calculated, not before, so you could do extra stuff, but you could not change the damage dealt.  There is no opportunity, without a plugin, to insert something between the player selecting an action and that action being executed.


Something like this in your damage formula should work:

Code:
v[1] === 2 ? 10 : 15

(no if)
Ah bugger !


I'm using the noteboxes to write my damage formulas, i just see it better in 2D I guess (hence the If)


So.. this is a buzzkill ! ^^


The action gets triggered after the damage...huh..


I could always add more damage and MP cost after, but it would be ugly to watch


Ah crap...


My spells look like that :


Burn : Cost 1MP : Inflicts 1-6 fire damage


Overcharge : +1-6 per 1 addictional MP spent


Overcharge : Applies a dot for 5 rounds for an additional 2MP


Basically my whole system is based on flexibility and the absence of redundant spells (Fire/Fira/Firaga)


Knowing that and with a mind that "sees" Js in a different way than i do with my month old work with it, can you envision a way to achieve this ?


Thanks for those quick answers, at least i'm no longer coding this long common event
You will need to get a plugin developed that will allow you to do it.

Original thread: https://forums.rpgmakerweb.com/threads/using-variable-in-a-formula.72380/