Being new to Ruby and RGSS2, I figured that I'd start by doing something simple but useful and make some more parameters for my actors. I want to make an object (ActorPlus) with the parameter data (and eventually other stuff,) and attach it to the actor in it's setup.
Here's the code, divided into four parts because that's how I've got it set up and it's easy to sort through like this.
Here's ActorPlus and some Vocab stuff:
A small addition and change in Game_Battler:
The actual error message points here: setup() in Game_actor, on line 34, marked with a comment for your convienence.
Spoiler for :
#setup() is overwritten; nothing else is class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Setup # actor_id : actor ID #------------------------------------------------------------------------- def setup(actor_id) actor = $data_actors[actor_id] @actor_id = actor_id @name = actor.name @character_name = actor.character_name @character_index = actor.character_index @face_name = actor.face_name @face_index = actor.face_index @class_id = actor.class_id @weapon_id = actor.weapon_id @armor1_id = actor.armor1_id @armor2_id = actor.armor2_id @armor3_id = actor.armor3_id @armor4_id = actor.armor4_id @level = actor.initial_level @exp_list = Array.new(101) make_exp_list @exp = @exp_list[@level] @skills = [] for i in self.class.learnings learn_skill(i.skill_id) if i.level <= @level end aplus = actorplus #The Problem Line. clear_extra_values clear_extra_values_plus recover_all end #I haven't looked into equipment yet, and states are beyond me, so they're #commented out for the time being. #-------------------------------------------------------------------------- # * Get Basic Charisma #-------------------------------------------------------------------------- def base_cha n = actor.aplus.paramaplus[0, @level] # for item in equips.compact do n += item.agi end return n end #-------------------------------------------------------------------------- # * Get Basic Luck #-------------------------------------------------------------------------- def base_luk n = actor.aplus.paramaplus[1, @level] # for item in equips.compact do n += item.agi end return n end #-------------------------------------------------------------------------- # * Get Charisma #-------------------------------------------------------------------------- def cha n = [[base_cha + @cha_plus, 1].max, 999].min # for state in states do n *= state.cha_rate / 100.0 end n = [[Integer(n), 1].max, 999].min return n end #-------------------------------------------------------------------------- # * Get Luck #-------------------------------------------------------------------------- def luk n = [[base_luk + @luk_plus, 1].max, 999].min # for state in states do n *= state.luk_rate / 100.0 end n = [[Integer(n), 1].max, 999].min return n end #-------------------------------------------------------------------------- # * Set Charisma # new_cha : new charisma #-------------------------------------------------------------------------- def cha=(new_cha) @luk_plus += new_cha - self.cha @cha_plus = [[@cha_plus, -999].max, 999].min end #-------------------------------------------------------------------------- # * Set Luck # new_luk : new luck #-------------------------------------------------------------------------- def luk=(new_luk) @luk_plus += new_luk - self.luk @luk_plus = [[@luk_plus, -999].max, 999].min end end
And here are some changes to windows so I can get the numbers to show up on a status screen:
Spoiler for :
#these are all straight-up overwritten class Window_Base < Window #-------------------------------------------------------------------------- # * Draw Parameters # actor : actor # x : draw spot x-coordinate # y : draw spot y-coordinate # type : Type of parameters (0-3) #-------------------------------------------------------------------------- def draw_actor_parameter(actor, x, y, type) case type when 0 parameter_name = Vocab::atk parameter_value = actor.atk when 1 parameter_name = Vocab::def parameter_value = actor.def when 2 parameter_name = Vocab::spi parameter_value = actor.spi when 3 parameter_name = Vocab::agi parameter_value = actor.agi when 4 parameter_name = Vocab::cha parameter_value = actor.cha when 5 parameter_name = Vocab::luk parameter_value = actor.luk end self.contents.font.color = system_color self.contents.draw_text(x, y, 120, WLH, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(x + 120, y, 36, WLH, parameter_value, 2) end end class Window_Status < Window_Base #-------------------------------------------------------------------------- # * Draw Parameters # x : Draw spot X coordinate # y : Draw spot Y coordinate # slot, stat #-------------------------------------------------------------------------- def draw_parameters(x, y) draw_actor_parameter(@actor, x, y + WLH * 0, 0) draw_actor_parameter(@actor, x, y + WLH * 1, 1) draw_actor_parameter(@actor, x, y + WLH * 2, 2) draw_actor_parameter(@actor, x, y + WLH * 3, 3) draw_actor_parameter(@actor, x, y + WLH * 4, 4)# CHA draw_actor_parameter(@actor, x, y + WLH * 5, 5)# LUK end end
(I overrwrite a lot of stuff, mostly because I haven't found an explanation of this whole "alias" buisness that I felt like I understood.)