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?
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. 🙂
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.
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".)
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. 😀
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.
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.
Garryl's solution is basically correct. Make sure to set the scope to Self and the variance to 0.