Variable in a formula as an MP cost?

Status
Not open for further replies.

Cuddlebuns

Veteran
Veteran
Joined
May 5, 2019
Messages
35
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,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
Code:
a.mp -= v[n]
?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
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,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
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
31,430
Reaction score
7,711
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,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
Well, there you go lol

My oopsie :D
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
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 Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top