Hp Manage with class changing

Ok i have spent most of today looking for a way to do this but here is my issuse,

My game currently has Actors classes change depending on what weapon they have equiped, that part work fine,

that issue is with HP and because different classes have different base hp it kinda bugs out.

in my game you start with a class called "no class" that has a base hp of 1 but then when you eqiup a weapon which results in a immedate class change your base hp is adjusted but your current hp will remain at 1.

i need a way to preserve the %hp before the change and adjust the actors hp after it.

hopefully someone call at least ponit me in the right direction.

Also i made 2 common events to complete the above task but im not sure how to get them to run during this script.

or maybe there is a better way to do this.

Here is the Script im using to manage the class changes...

Spoiler
=begin
Equipment Changes Class v0.5
by kirinelf
Requested by: TheCastle

Notes:
Simply copy and paste the following in the module:

WEAPON_TYPE_ID[n] = m

where n is the weapon type ID and m is the class ID.
For example, WEAPON_TYPE_ID[1] = 1 will make all axes
turn the wearer into a Soldier.
=end

module EQUIP_CLASS

  WEAPON_TYPE_ID = {}
  WEAPON_TYPE_ID[1] = 1 # WEAPON_TYPE_ID[Weapon Type ID] = Class ID.
   WEAPON_TYPE_ID[2] = 2
#========================================================================
# Do not edit anything under this line unless you know what you're doing!
#========================================================================

end

class Game_Actor < Game_Battler

  alias equip_change_equip change_equip
    
  def change_equip(slot_id, item)
       
    equip_change_equip(slot_id, item)
          case slot_id
          when 0
            
            unless item.nil?
              class_id = EQUIP_CLASS::WEAPON_TYPE_ID[item.wtype_id]
            end
            $game_temp.reserve_common_event(5)
              if class_id != nil
                change_class(class_id, true)
                init_exp
                init_skills
           
                end
              
             
              end
          end
        end

    
 
try this...


hpper = hp/mhp.to_f


change_class(class_id, true)


init_exp


init_skills


hp = mhp*hpper


btw, doesn't using init return them to level 1???
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
Nah that didnt work oh but i didnt mention that i am using Yanfly Engine Ace,

i think that may make a difference, im new to ruby in such
Can you provide a link to your scripts please, so people don't have to go searching for them?
Sure. sorry about that.

This is Yanfly Engine Ace.

http://dl.dropbox.com/u/49701990/YEA/Ace_Core_Engine.rb

Another way around this issuse would be if anyone knew how to set base stats according to actor instead of by class if i could do that i could do a work around lol,
what happened when you tried it?


btw, it might be @hp and @mhp
ok so using the @hp and  @mhp actually generates an error on the last line, not using the @ doesnt cause any error nor fix the problem my actor stays at 1 hp with a max hp of 15..
try hp and self.mhp
oh... I looked and traced, I guess hp should have @ while mhp doesn't (hp is attr_reader of Game_BattlerBase, while mhp is a method)
oh... I looked and traced, I guess hp should have @ while mhp doesn't (hp is attr_reader of Game_BattlerBase, while mhp is a method)
this worked perfectly thanks alot.

i have only 1 small issuse it returns the value as a decimal so i get 15.0 instead of 15 in the hp bar and its looks kinda werid but

thank you thank you thank you your awesome 🙂
@hp = (mhp*hpper).to_i
that works, thanks again..

Original thread: https://forums.rpgmakerweb.com/threads/hp-manage-with-class-changing.20522/