Variable in a formula as an MP cost?

Status
Not open for further replies.

Cuddlebuns

Veteran
Veteran
Joined
May 5, 2019
Messages
30
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Is there a way for the MP cost of a skill to be determined by a variable? A rough formula would be "v[n] = MP cost".
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
Code:
a.mp -= v[n]
?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
oh, sorry :D

upload_2019-5-27_22-56-17.png

In the formula section of the desired skill or item. You can use any valid javascrip there, and a few objects are available. you have access to the attacker, which has mp. its just a case of reducing the mp..

the ; in the formula signifies a new line to the game interpreter. so it would do the damage, then take the mp (but it would seem to be the same time to the player)

Hope this helped :*
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
np, hope it works, I havent messed with the formula box of mv much - it woulda worked for ace though :D
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
28,956
Reaction score
6,666
First Language
German
Primarily Uses
RMMV
@Cuddlebuns @??????
Unfortunately the Diabolical Codemaster made a tiny but important mistake...

The damage done is always the last number processed in the damage formula, so the cost reduction needs to come first:
Code:
a.mp-=v[5]; a.atk*4 - b.def*2
Additionally, while this does reduce the MP by the cost, the engine no longer prevents the use of the spell if the actor has less MP than set in variable 5, he would always be able to case this skill even with 0 MP (because the skill cost itself needs to be set to 0)

To prevent that you'll need a script that allows for different skill costs - for example the one from Yanfly or from Tsukihime.
That would even allow you to set items as skill costs in addition to MP and TP however
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
Well, there you go lol

My oopsie :D
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
5,867
Reaction score
4,212
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Stuffing three people in a room and thinking they'll study together is so wrong XD I don't get how people do group studies. We just end up gossiping about everything except studying lol
Been parallax mapping nigh all night. :D
2nd character based on the same random inputs
the coffee shop i go to for open mic every friday only has 2 more open mics left and then they're done :'( i'm gonna die!
Everytime someone says Intel "kabylake" I hear either baby lake or ladycake.

Forum statistics

Threads
93,384
Messages
911,876
Members
122,886
Latest member
unisity
Top