Help - Search - Members - Calendar
Full Version: + [ Recover HP/MP/States when Level Up ] +
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS2-Submissions
woratana
Recover HP/MP/States when Level Up
Version 1.0
by Woratana
Release Date: 10/06/2008


Introduction
Here is a little snippet I scripted after lost one VX game. tongue.gif
I just think that it should be easier (for player) if actors' status are recover when they level up. biggrin.gif

Enjoy~ laugh.gif


Screenshots
-No screenshot-


Script
Place it above main

CODE
CODE
#===============================================================
# ● [VX] ◦ Recover HP/MP/States when Level Up ◦ □
#--------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Thaiware RPG Maker Community
# ◦ Released on: 10/06/2008
# ◦ Version: 1.0
#--------------------------------------------------------------
# ◦ How to use:
# Put this script above main, you can setup script below
#=================================================================

class Game_Actor < Game_Battler
  
  #==================================
  # * SCRIPT SETUP PART
  #----------------------------------
  RECOVER_HP = true # Recover HP when level up? (true/false)
  RECOVER_MP = true # Recover MP when level up?
  REMOVE_STATES = true # Cure all states when level up?
  #==================================
  
  alias wora_fullhpmp_gamact_lvup level_up
  def level_up
    wora_fullhpmp_gamact_lvup
    @hp = maxhp if RECOVER_HP
    @mp = maxmp if RECOVER_MP
    if REMOVE_STATES
      @states.clone.each {|i| remove_state(i) }
    end
  end
end



Instruction
Place the script above main.
You can setup script in setup part if you don't want to recover all HP/MP/states when level up.


Author's Notes
Free for use in your work if credit is included.


Bug Report?
Please give me these informations:
QUOTE
- What is it says in error window?
- When is it get error? (Right after run game, when you choose something, etc.)
- Do you have any other scripts running in your game that may crash with this script?
Hanmac
use this:
CODE
@states.clone.each {|i| remove_state(i) if REMOVE_STATES == true or REMOVE_STATES.include?(i) }

so you can use an array of states, witch are removed.
woratana
REMOVE_STATES must be boolean OR array only. tongue.gif

It can't be both. biggrin.gif
Hanmac
yes, but
CODE
if [1,2,3]
  p "true"
end

puts "true" because [1,2,3] is not false
woratana
Well, I still don't see the point. sad.gif

Because it will always return true. So it will always remove all the states.

CODE
a = [1,2,3]
p 'true' if a or a.include?(2) # true
p 'true' if a or a.include?(5) # true
Hanmac
you frogot the == true

test:
CODE
a = [1,2,3]
p 'true' if a == true or a.include?(2) # true
p 'true' if a == true or a.include?(5) # false
woratana
Yeah, but that stills not make me understand what do you want to say~
According to your last reply:
QUOTE (Hanmac @ Jun 11 2008, 12:00 AM) *
you frogot the == true

test:
CODE
a = [1,2,3]
p 'true' if a == true or a.include?(2) # true
p 'true' if a == true or a.include?(5) # false


This mean...
QUOTE (woratana @ Jun 10 2008, 11:39 PM) *
REMOVE_STATES must be boolean OR array only. tongue.gif

It can't be both. biggrin.gif


Isn't it?
Hanmac
test it:
REMOVE_STATES = false it make nothing
REMOVE_STATES = true it makes all
REMOVE_STATES = [] it make nothing
REMOVE_STATES = [1,2,3] it removes state 1,2 and 3

CODE
    if REMOVE_STATES # if false ignore this and array are true
      @states.clone.each {|i|
        if REMOVE_STATES == true or REMOVE_STATES.include?(i) #if true ignore include?, otherwise check include
          remove_state(i)
        end
        }
    end


or very short:
CODE
@states.clone.each {|i| remove_state(i) if REMOVE_STATES == true or REMOVE_STATES.include?(i) } if REMOVE_STATES
woratana
Well, that's actually a good idea. smile.gif Nice job!

Though, false will return NoMethodError biggrin.gif
because boolean doesn't has method 'include?'
Hanmac
have you test it?

because false cant go into the each because "if REMOVE_STATES" at the end.
or have you forgot this?
woratana
Yeah, I totally forgot about that. biggrin.gif
Beecheese
This might be a little old, but I wanted to show my support for this script. Very small but very practical, I agree with you, actors should recover fully after leveling up.
woratana
Thanks smile.gif
I'm glad you like it~^^

The post like yours kept me scripting. biggrin.gif
Omegas7
Hey! Thank you dude thumbsup.gif.
mudducky
You do come up with the most useful idea's for scripts. Many thanks for making this, Woratana. thanks.gif
repic
ok, im a total noob at this and i got lost at the begining...how exsactly do i do this?
woratana
Put it in script editor ^^
Mickadell
Comment
Rate: Excellent

Thank you,
So much. I really needed this or my game would be to rigged. So thanks again
This really helped.
Mickadell
Problem
When I used it one of my Characters healed but the other didn't
I have 2 Characters and I am using your 2 player script.
woratana
It doesn't heal the party, it heal only the one who level up. ^^
Toph-Bei-Fong-12
Wow! Thanks, wora! And yeah, this is a simple but great script! tongue.gif
Saffaron123
Wow, this is so usefull. Alot of games could use this. I hate when you level up, and die. dry.gif

I love your scripts laugh.gif
Thanks wink.gif
redyugi
I never knew there was a script for this.
If I had, I wouldn't have written my Level Up Effects script.
ZeroManArmy
When it says to install above main does it mean to install it in the materials space? Or above the main script?
Xzygon
@ZeroManArmy
Above the main script and in the materials space is the same thing...
kitty-two
Thank you for the script! biggrin.gif
I really like it and it's very useful!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.