Hp Manage with class changing

forteller

Veteran
Veteran
Joined
Dec 2, 2013
Messages
105
Reaction score
19
First Language
English
Primarily Uses
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...

=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

    
 
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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???
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

forteller

Veteran
Veteran
Joined
Dec 2, 2013
Messages
105
Reaction score
19
First Language
English
Primarily Uses
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Can you provide a link to your scripts please, so people don't have to go searching for them?
 

forteller

Veteran
Veteran
Joined
Dec 2, 2013
Messages
105
Reaction score
19
First Language
English
Primarily Uses
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,
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
what happened when you tried it?


btw, it might be @hp and @mhp
 
Last edited by a moderator:

forteller

Veteran
Veteran
Joined
Dec 2, 2013
Messages
105
Reaction score
19
First Language
English
Primarily Uses
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..
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
try hp and self.mhp
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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)
 
Last edited by a moderator:

forteller

Veteran
Veteran
Joined
Dec 2, 2013
Messages
105
Reaction score
19
First Language
English
Primarily Uses
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 :)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
@hp = (mhp*hpper).to_i
 

forteller

Veteran
Veteran
Joined
Dec 2, 2013
Messages
105
Reaction score
19
First Language
English
Primarily Uses
that works, thanks again..
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
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.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top