Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

New Attribute = failure

bukai

Member

i'm trying to add a new attribute called: stamina
it will raise the actors maxhp depending on his lvl and class.

the code looks like this:
Code:
# add stamina
module RPG
  class Actor
      @parameters = Table.new(7,100)
      for i in 1..99
        @parameters[6,i] = 1
      end
      attr_accessor :parameters
    end
  end

# Game_Battler stuff
class Game_Battler
   def clear_extra_values
    @maxhp_plus = 0
    @maxmp_plus = 0
    @atk_plus = 0
    @def_plus = 0
    @spi_plus = 0
    @sta_plus = 0
    @agi_plus = 0
  end
  
# def stamina
 def sta
    n = [[base_sta + @sta_plus, 1].max, 999].min
    for state in states do n *= state.sta_rate / 100.0 end
    n = [[Integer(n), 1].max, 999].min
    return n
  end
  
# set new stamina
   def sta=(new_sta)
    @sta_plus += new_sta - self.sta
    @sta_plus = [[@sta_plus, -999].max, 999].min
  end

  
# stamina life bonus
 def stamina_bonus
   case actor.class
   when 1
   n = (sta * actor.lvl) / 12
   when 2 
   n = (sta * actor.lvl) / 10
   when 3
   n = (sta * actor.lvl) / 11
  else
   n = (sta * actor.lvl) / 15
 end
   return n
 end
  
# MAX LIFE
  def maxhp
    return [[base_maxhp + @maxhp_plus + stamina_bonus, 1].max, maxhp_limit].min
  end
end
  
# ð GAME_BATTLER END

class Game_Actor < Game_Battler
# Basic Ausdaer
  def base_sta
    n = actor.parameters[6, @level]
    for weapon in weapons.compact do n += weapon.sta end
    for armor in armors.compact do n+= armor.sta end  
    return n
  end 
end

module RPG
  class Armor < BaseItem
    def initialize
      super
      @sta = 0
   end
     attr_accessor :sta
   end
end

module RPG
  class Weapon < BaseItem
    def initialize
      super
      @sta = 0
    end
     attr_accessor :sta
   end
end

but i'm getting an error in row 66...
 
I get an error in this part.

ARMOR < BaseItem

Because Baseitem doesn't exist, but when I erase Baseitem all works Ok.

PD: Where do you copy the Baseitem like a superclass mode?
 

bukai

Member

i forgot, its rgss2.

and hmm row 63-70:
Code:
# Basic STamina
  def base_sta
    n = actor.parameters[6, @level]
    for weapon in weapons.compact do n += weapon.sta end   # row 66 i tried it with 
    for armor in armors.compact do n+= armor.sta end  # for item in equips.compact but i get the same error
    return n
  end 
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top