[Solved]Spend MP if player has it, else is text

Status
Not open for further replies.

mogneto

Gureito Eventer
Member
Joined
Oct 2, 2016
Messages
18
Reaction score
6
First Language
Portuguese
Primarily Uses
RMMV
Not a good title, but is the shortest version I can think of.

Well, here I am again, asking for some help.
I was trying to do an event where the player must use a specific skill and, if he had enough mana (in that case, 30MP) he would spend it; otherwise a textbox will open explaining there's missing mana and the skill wouldn't cast.

For this, I made a Conditional Branch to check if the player has the skill and inside of it I used a script call command to check the mana thing.

The script:

Code:
var a = $gameActors.actor(1)
var mana = a.mp

if mana <= 30 {
$gameMessage.setFaceImage('AChars 1',0);
$gameMessage.setBackground(1);
$gameMessage.setPositionType(1);
$gameMessage.add("Esil: Não tenho mana suficiente.");
}
else {

a.loseMp(30)
Dunno if It's OK, but the script don't even makes the player to lose mana.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
You're missing a } at the end of the script. Are you like really missing it or you forgot to copy paste it?
Also, you don't loseMp. You gainMp with negative parameter if I remember correctly.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,088
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
Also, "if" conditions need to be in (brackets). Putting that all together:
Code:
var a = $gameActors.actor(1)
if (a.mp <= 30) {
  $gameMessage.setFaceImage('AChars 1',0);
  $gameMessage.setBackground(1);
  $gameMessage.setPositionType(1);
  $gameMessage.add("Esil: Não tenho mana suficiente.");
} else {
  a.gainMp(-30);
  // skill effects go here
}
Note that this can all be done with eventing (Control Variables > Game Data > Actor > MP):
Code:
◆Control Variables:#0001 check = MP of Actor1
◆If:check ≤ 30
  ◆Text:None, Window, Bottom
  :    :Esil: Não tenho mana suficiente.
  ◆
:Else
  ◆Change MP:Actor1, - 30
  ◆Comment:etc
  ◆
:End
 

mogneto

Gureito Eventer
Member
Joined
Oct 2, 2016
Messages
18
Reaction score
6
First Language
Portuguese
Primarily Uses
RMMV
Thank you guys. It's working now :^)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,225
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

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top