Fonstw

Lv.14 Jackrabbit
Member
Joined
Nov 6, 2013
Messages
20
Reaction score
1
First Language
Dutch
Primarily Uses
Hello RPG Maker community!

I am trying to get a skill to cost equal to the caster's level times 5. The effect of the skill will be, to heal the ally's HP equal to the caster's level times 10.

I tried using the damage formula like so:

a.mp >= a.level * 5 ? a.mp -= a.level * 5 && b.hp += a.level * 10 : 0 But that healed 0, and used up ALL the MP!

Then I tried to use Yanfly's Skill Cost Manager, and tried to do this:

<custom cost requirement>user.mp >= user.level * 5</custom cost requirement><custom cost perform>user.mp -= user.level * 5</custom cost perform>User refers to the Scene_Skill script, standard included in RPG VX Ace:

#-------------------------------------------------------------------------- # * Get Skill's User #-------------------------------------------------------------------------- def user @actor endAll I get is the following error message (before I even selected the skill itself):

Untitled.png

I understand that "user" does not exist in the current context (when showing the skill in the skill-menu, in-battle)

Although, I really don't know what else to use.

Yes, I am new to Ruby and scripting in RPG Maker, but not to programming with other languages.

If anyone could help me out, that would be much appreciated!
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,968
Reaction score
14,820
First Language
English
Primarily Uses
RMVXA
Instead of user, have you tried self? In other words, does it work if you used self.mp >= self.level * 5 for the cost requirement (and similar for the perform line)

Edit: I should add, mine is for the skill cost manager script. Ksjp17's solution (below mine) is for the damage formula.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
A couple of things I don't understand with your formula

Why have you got

      a.mp >= a.level * 5 ?

What is the if statement doing in this context?

Also I do not understand why you have &&

Try this instead

a.mp -= a.level * 5; b.hp-= a.level * 10

EDIT

Perhaps I should have said this explicitly, but the MP cost box in the main part of the skill tab should be set at 0 for that formula to work, otherwise it will probably deduct whatever is there as well.
 
Last edited by a moderator:

Fonstw

Lv.14 Jackrabbit
Member
Joined
Nov 6, 2013
Messages
20
Reaction score
1
First Language
Dutch
Primarily Uses
      a.mp >= a.level * 5 ?

Why have you got
Because it makes sure that I can't cast the skill as long as I don't have enough MP, ergo: I have 35 MP, skill costs 50, then it should skip tha whole formula.

EDIT: Also, I tried "a.mp -= a.level * 5; b.hp-= a.level * 10", and (again) it takes all MP and all HP.
 
Last edited by a moderator:

Fonstw

Lv.14 Jackrabbit
Member
Joined
Nov 6, 2013
Messages
20
Reaction score
1
First Language
Dutch
Primarily Uses
Instead of user, have you tried self? In other words, does it work if you used self.mp >= self.level * 5 for the cost requirement (and similar for the perform line)
Hm. Why didn't I think of that ;)

But it worked, thank a lot!
 

Latest Threads

Latest Posts

Latest Profile Posts

I think it's ready - Chapter Selection:
unknown.png
On another more gaming topic, I paid 20 bucks for a visual novel to emotionally destroy me. I may write an entry about that.
1638611395177.png
Reading about metaverses recently. I can totally imagine myself in the future, logging in with VR glasses to a virtual beach villa sitting in a virtual chair, with a virtual laptop facing the sea...coding 16-bit RM.
Mod name: "[Game name] Gameplay Overhaul"
What they actually mean: "Here is a mod that makes the game harder."
I decided to reinstall one of my most favourite game of all times, Gothic 2. Time to get back to Khorinis!

Forum statistics

Threads
117,174
Messages
1,105,151
Members
153,279
Latest member
andrew_smith
Top