TP conversion skill?

Evil_Nazgul0616

Veteran
Veteran
Joined
Aug 29, 2013
Messages
79
Reaction score
0
First Language
English
Primarily Uses
I need help creating a certain skill for my game.

The idea of the skill is basically a "meditation" skill that converts whatever TP the user currently has into HP and MP. (So if the user has X TP when they use the skill, TP would be set to 0 and both HP and MP are recovered by X points) I tried to common event the skill, but then I found that you can't store the user's TP in a variable via common event. So is still possible to do this through eventing, or do I have to resort to a script at this point?
 

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
Put this in the skill's formula box:

if a.actor?; $game_variables[id] = a.id; endThen you can use the following script call to set a variable to the actor's TP:

Code:
$game_actors[$game_variables[id]].tp.to_i
 

Evil_Nazgul0616

Veteran
Veteran
Joined
Aug 29, 2013
Messages
79
Reaction score
0
First Language
English
Primarily Uses
Put this in the skill's formula box:

if a.actor?; $game_variables[id] = a.id; endThen you can use the following script call to set a variable to the actor's TP:

$game_actors[$game_variables[id]].tp.to_i
Got an error:

Capture.PNG

Also, how do I set the user's TP to 0 after using the skill?
 

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
Can you post screenshots of where you inputted the script call? I tested it earlier and it worked fine.
 
To set an actor's TP to zero, just put this in a regular script call:

Code:
$game_actors[$game_variables[id]].tp = 0
 
Last edited by a moderator:

Evil_Nazgul0616

Veteran
Veteran
Joined
Aug 29, 2013
Messages
79
Reaction score
0
First Language
English
Primarily Uses
Here:

Capture.PNG

Ignore the second script call, all that is doing is overwriting the battle log text.
 

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
Ahhh, if you're just setting the TP to another value, you can remove the ".to_i". I thought you were trying to use Control Variable to set a value, so that's my bad.  :)
 

Evil_Nazgul0616

Veteran
Veteran
Joined
Aug 29, 2013
Messages
79
Reaction score
0
First Language
English
Primarily Uses
So the error stopped, but now it's recovering HP and MP equal to the actor's ID number instead of the Actor's TP.
 

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
You're trying to set variable 38 to the TP amount, yes? Switch the order of the values in that first line so it's like this:

$game_variables[38] = $game_actors[$game_variables[39]].tp.to_i(This is what I thought you meant, so I guess I was right and you will have to use the ".to_i".)
 

Evil_Nazgul0616

Veteran
Veteran
Joined
Aug 29, 2013
Messages
79
Reaction score
0
First Language
English
Primarily Uses
You're trying to set variable 38 to the TP amount, yes? Switch the order of the values in that first line so it's like this:

$game_variables[38] = $game_actors[$game_variables[39]].tp.to_i(This is what I thought you meant, so I guess I was right and you will have to use the ".to_i".)
Did that. It's still using the actor's ID number instead of TP.
 

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
Ok, something else's going on then. 'Cause, again, I just tested this and what I have works fine:





(The text is so I can see the variable values before the recovery.)

Can you post a screenshot of how you've got the skill setup? And do you have any scripts in your project that may be affecting this?
 
Last edited by a moderator:

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
Aha! I think I've figured out what's going on. When I test it out, the battle message says the actor heals for 1 (their id), BUT after looking at their HP and MP, they do actually get healed for the correct amount. So I believe it's only the battle message that's giving you problems.  :)
 
If you'll give me a bit, I'll write up a bit of code that'll let you get around that.
 
Edit: Okie dokie. Add this to the front of your formula:

$game_switches[id] = trueThen stick this in your script editor:

#==============================================================================# ** Window_BattleLog#============================================================================== class Window_BattleLog < Window_Selectable  #--------------------------------------------------------------------------  # * Alias  #--------------------------------------------------------------------------  alias hollow_hide_window_battlelog_dar display_action_results  #--------------------------------------------------------------------------  # * Display Action Results  #--------------------------------------------------------------------------  def display_action_results(target, item)    return if $game_switches[1] # <--- Change the ID to whatever you need.    hollow_hide_window_battlelog_dar(target, item)  endend # Window_BattleLogAfter that, you'll just need to turn the switch back off at the end of your common event. :D
 
Last edited by a moderator:

Evil_Nazgul0616

Veteran
Veteran
Joined
Aug 29, 2013
Messages
79
Reaction score
0
First Language
English
Primarily Uses
Aha! I think I've figured out what's going on. When I test it out, the battle message says the actor heals for 1 (their id), BUT after looking at their HP and MP, they do actually get healed for the correct amount. So I believe it's only the battle message that's giving you problems.  :)

If you'll give me a bit, I'll write up a bit of code that'll let you get around that.

Edit: Okie dokie. Add this to the front of your formula:

$game_switches[id] = trueThen stick this in your script editor:

#==============================================================================# ** Window_BattleLog#============================================================================== class Window_BattleLog < Window_Selectable  #--------------------------------------------------------------------------  # * Alias  #--------------------------------------------------------------------------  alias hollow_hide_window_battlelog_dar display_action_results  #--------------------------------------------------------------------------  # * Display Action Results  #--------------------------------------------------------------------------  def display_action_results(target, item)    return if $game_switches[1] # <--- Change the ID to whatever you need.    hollow_hide_window_battlelog_dar(target, item)  endend # Window_BattleLogAfter that, you'll just need to turn the switch back off at the end of your common event. :D
This works, but now it's adding the proper amount in addition to the actor's ID number.
 
Last edited by a moderator:

Hollow

(◡‿◡✿)
Veteran
Joined
Jul 14, 2012
Messages
519
Reaction score
439
First Language
English
Primarily Uses
RMMV
Are you only testing this with the first actor? Because I believe that by default actor's will gain 1 TP (or just a general amount based on the "damage" they take) each time they are acted upon (taking damage, healed, etc.), so it may simply appear to be adding the actor's ID. If that's the case, and you still don't want that extra TP to be counted toward the heal, you could just have an additional step where you subtract 1 from the actor's TP before healing them.

If that's not it and it is adding the actor's ID: after getting the actor's TP in a variable, try subtracting their ID from that value.
 
Last edited by a moderator:

Garryl

Villager
Member
Joined
Feb 19, 2015
Messages
25
Reaction score
4
First Language
English
Primarily Uses
I did essentially the same thing as you're asking for a couple of weeks ago while trying to introduce myself to RPG Maker. Here's what I had. My implementation is very simple and requires no common events, special game scripts, or anything aside from the skill's formula box.

Damage

Type: HP Recover

Formula: c = [a.tp, b.mhp - b.hp].min; a.tp = a.tp - c; c

The formula is a script that means...

c = [a.tp, b.mhp - b.hp].min -> Save the lesser of the user's TP and the target's missing HP as variable c.

a.tp = a.tp - c -> Subtract that much TP

c -> Give that value to the formula for it to use for the HP recovered.

That's just for restoring HP (and at a 1:1 rate with TP spent). It also has a bit of extra complexity in order to leave you with any excess TP. For your original request (set TP to 0, restore HP and MP both equal to the TP spent), use the following instead:

Type: HP Recover

Formula: c = a.tp.to_i; a.tp = 0; b.mp += c; c

This formula's script means...

c = a.tp.to_i -> Save the the user's TP (before we zero it). Only uses the integer portion (TP is sometimes not a whole number behind the scenes).

a.tp = 0 -> Set TP to 0.

b.mp += c -> Add the saved TP value to target's current MP.

c -> Give the saved TP value to the formula for it to use for the HP recovered.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Garryl's solution is basically correct.  Make sure to set the scope to Self and the variance to 0.
 

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