Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
xxultimaxx

Creating New Actor/Weapon/Armor Attributes

Question

I have been trying to make a Luck attribute for my game. I would like to have the attribute tied to the Actors, Weapons & Armors. I seem to be having success with creating it for the Actors, but not so sure about the Weapons & Armors. I attempted to alias the Modules for Weapon and Armor to include the stat, but I'm not sure if it applied.

 

Here is basically what I am trying to do:

When you call Scene_Equip, I modified what information is passed to set_new_parameters.

 def refresh
   # Set item window to visible
   @item_window1.visible = (@right_window.index == 0)
   @item_window2.visible = (@right_window.index == 1)
   @item_window3.visible = (@right_window.index == 2)
   @item_window4.visible = (@right_window.index == 3)
   @item_window5.visible = (@right_window.index == 4)
   # Get currently equipped item
   item1 = @right_window.item
   # Set current item window to @item_window
   case @right_window.index
   when 0
     @item_window = @item_window1
   when 1
     @item_window = @item_window2
   when 2
     @item_window = @item_window3
   when 3
     @item_window = @item_window4
   when 4
     @item_window = @item_window5
   end
   # If right window is active
   if @right_window.active
     # Erase parameters for after equipment change
     @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, nil)
   end
   # If item window is active
   if @item_window.active
     # Get currently selected item
     item2 = @item_window.item
     # Change equipment
     last_hp = @actor.hp
     last_sp = @actor.sp
     @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
     # Get parameters for after equipment change
     new_atk = @actor.atk
     new_pdef = @actor.pdef
     new_mdef = @actor.mdef
     new_str = @actor.str
     new_dex = @actor.dex
     new_agi = @actor.agi
     new_int = @actor.int
     new_eva = @actor.eva
     new_luck = @actor.luck
     # Return equipment
     @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
     @actor.hp = last_hp
     @actor.sp = last_sp
     # Draw in left window
     @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck)
   end
 end

 

Now in the EquipLeft window, I modified it to show all the stats (not just the two are three that were default) and to show increases or decreases in each attribute through color changes to the stats, depending on the weapon/armor in the @item_window.

 

#==============================================================================
# ** Window_EquipLeft
#------------------------------------------------------------------------------
#  This window displays actor parameter changes on the equipment screen.
#==============================================================================

class Window_EquipLeft < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     actor : actor
 #--------------------------------------------------------------------------
 def initialize(actor)
   super(0, 64, 272, 192)
   self.contents = Bitmap.new(width - 32, height - 32)
   @actor = actor
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   draw_actor_name(@actor, 4, 0)

   if @new_atk != nil
     self.contents.font.color = text_color(0)
     self.contents.draw_text(4,32,80,32,"ATK")
     if @new_atk > @actor.atk
       self.contents.font.color = text_color(6)
     elsif @new_atk < @actor.atk
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,32,80,32, @new_atk.to_s, 2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,32,80,32,"ATK")
     self.contents.draw_text(30,32,80,32,@actor.atk.to_s,2)
   end
   if @new_pdef != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,64,80,32,"PDEF")
     if @new_pdef > @actor.pdef
       self.contents.font.color = text_color(6)
     elsif @new_pdef < @actor.pdef
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,64,80,32,@new_pdef.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,64,80,32,"PDEF")
     self.contents.draw_text(30,64,80,32,@actor.pdef.to_s,2)
   end
   if @new_mdef != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,96,80,32,"MDEF")
     if @new_mdef > @actor.mdef
       self.contents.font.color = text_color(6)
     elsif @new_mdef < @actor.mdef
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,96,80,32,@new_mdef.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,96,80,32,"MDEF")
     self.contents.draw_text(30,96,80,32,@actor.mdef.to_s,2)
   end
   if @new_str != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,0,80,32,"STR")
     if @new_str > @actor.str
       self.contents.font.color = text_color(6)
     elsif @new_str < @actor.str
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,0,80,32,@new_str.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,0,80,32,"STR")
     self.contents.draw_text(160,0,80,32,@actor.str.to_s,2)
   end
   if @new_dex != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,32,80,32,"DEX")
     if @new_dex > @actor.dex
       self.contents.font.color = text_color(6)
     elsif @new_dex < @actor.dex
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,32,80,32,@new_dex.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,32,80,32,"DEX")
     self.contents.draw_text(160,32,80,32,@actor.dex.to_s,2)
   end
   if @new_agi != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,64,80,32,"AGI")
     if @new_agi > @actor.agi
       self.contents.font.color = text_color(6)
     elsif @new_agi < @actor.agi
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,64,80,32,@new_agi.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,64,80,32,"AGI")
     self.contents.draw_text(160,64,80,32,@actor.agi.to_s,2)
   end
   if @new_int != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,96,80,32,"INT")
     if @new_int > @actor.int
       self.contents.font.color = text_color(6)
     elsif @new_int < @actor.int
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,96,80,32,@new_int.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,96,80,32,"INT")
     self.contents.draw_text(160,96,80,32,@actor.int.to_s,2)
   end
   if @new_eva != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,128,80,32,"EVA")
     if @new_eva > @actor.eva
       self.contents.font.color = text_color(6)
     elsif @new_eva < @actor.eva
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,128,80,32,@new_eva.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,128,80,32,"EVA")
     self.contents.draw_text(160,128,80,32,@actor.eva.to_s,2)
   end
   if @new_luck != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,128,80,32,"LUCK")
     if @new_luck > @actor.luck
       self.contents.font.color = text_color(6)
     elsif @new_luck < @actor.luck
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,128,80,32,@new_luck.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,128,80,32,"LUCK")
     draw_actor_luck(@actor,-10,128)
   end
 end
 #--------------------------------------------------------------------------
 # * Set parameters after changing equipment
 #     new_atk  : attack power after changing equipment
 #     new_pdef : physical defense after changing equipment
 #     new_mdef : magic defense after changing equipment
 #--------------------------------------------------------------------------
 def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck)
   if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int or @new_eva != new_eva or @new_luck != new_luck
     @new_atk = new_atk
     @new_pdef = new_pdef
     @new_mdef = new_mdef
     @new_str = new_str
     @new_dex = new_dex
     @new_agi = new_agi
     @new_int = new_int
     @new_eva = new_eva
     @new_luck = new_luck
     refresh
   end
 end
end

 

So basically, I would like to figure out how to set it up so that the Luck attribute completely mimics all the other attributes (e.g. str, mdef, eva, etc...).

 

Thanks to anyone that can help!

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hmm. Well you are definitely on the right path, but the issue with adding attributes to weapons/armors, is mainly just that you only have so many fields in the database (e.g. no luck field to set that attribute)

 

however there are a few ways to work around this:

 

1. You could hardcode all your weapons/armors luck attribute

 

ex. after loading the Weapons.rxdata / Armors.rxdata files; you could set each $data_armors luck attribute to whatever you want it to be

$data_weapons[1].luck = 50

 

however that would take a lot of typing...but this would be the most surefire way to make it all work.

 

2. The method I might suggest, is have each weapon/armor get an individual icon, and include the luck attribute as the first three digits (it will make it easier if it includes leading 0s, so 50 would be 050), and just loop through the entire $data_weapons array setting each attribute to the icon_name's first three letters (then use the string.to_i method to parse the integer from string)

 

ex.

$data_weapons.each {|weapon|
 luck = weapon.icon_name[0..2] # This will grab the first 3 characters in the icon_name string
 weapon.luck = luck.to_i       # This parses the luck string into an integer
}

 

There are probably a lot of other ways to do this...but just to give you an idea on how to approach it. The first method would require more coding, but saves on image files (and having to name them correctly) and the second method saves on coding but unfortunately requires more images...

so either pick one of these methods, or maybe I have inspired an even better method for you to come up with :)

good luck, if you need a better explanation; just lemme know.

Share this post


Link to post
Share on other sites
  • 0

Thanks for the reply, kellessdee : )

 

I thought of hard coding in Scene_Title, but to no avail. If I do that for, say .str_plus, it works perfectly and modifies, but not so for .luck. I am wondering if I am missing something when it comes to attaching the luck attribute to the Actor. I am trying to model it after the eva attribute.

 

Let me explain what happens and then I will paste the script I'm working on.

 

If I run the script in a default project, I get the error: 'nil can't be coerced to Fixnum'. So, I figure if I add an attr_accessor :luck to Game_Actor and set it in setup, I'll have a number. Well, I do, and the game does not give me an error, but the luck attribute is not modified when attempting to equip. All the other attributes work fine, though. Maybe I am overlooking something completely obvious or there is an easy fix; not sure.

 

class Window_EquipLeft < Window_Base
alias old_refresh refresh
alias old_set_new_parameters set_new_parameters
 def refresh
   self.contents.clear
   draw_actor_name(@actor, 4, 0)
   if @new_atk != nil
     self.contents.font.color = text_color(0)
     self.contents.draw_text(4,32,80,32,"ATK")
     if @new_atk > @actor.atk
       self.contents.font.color = text_color(6)
     elsif @new_atk < @actor.atk
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,32,80,32, @new_atk.to_s, 2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,32,80,32,"ATK")
     self.contents.draw_text(30,32,80,32,@actor.atk.to_s,2)
   end
   if @new_pdef != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,64,80,32,"PDEF")
     if @new_pdef > @actor.pdef
       self.contents.font.color = text_color(6)
     elsif @new_pdef < @actor.pdef
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,64,80,32,@new_pdef.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,64,80,32,"PDEF")
     self.contents.draw_text(30,64,80,32,@actor.pdef.to_s,2)
   end
   if @new_mdef != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,96,80,32,"MDEF")
     if @new_mdef > @actor.mdef
       self.contents.font.color = text_color(6)
     elsif @new_mdef < @actor.mdef
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,96,80,32,@new_mdef.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,96,80,32,"MDEF")
     self.contents.draw_text(30,96,80,32,@actor.mdef.to_s,2)
   end
   if @new_str != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,0,80,32,"STR")
     if @new_str > @actor.str
       self.contents.font.color = text_color(6)
     elsif @new_str < @actor.str
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,0,80,32,@new_str.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,0,80,32,"STR")
     self.contents.draw_text(160,0,80,32,@actor.str.to_s,2)
   end
   if @new_dex != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,32,80,32,"DEX")
     if @new_dex > @actor.dex
       self.contents.font.color = text_color(6)
     elsif @new_dex < @actor.dex
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,32,80,32,@new_dex.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,32,80,32,"DEX")
     self.contents.draw_text(160,32,80,32,@actor.dex.to_s,2)
   end
   if @new_agi != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,64,80,32,"AGI")
     if @new_agi > @actor.agi
       self.contents.font.color = text_color(6)
     elsif @new_agi < @actor.agi
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,64,80,32,@new_agi.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,64,80,32,"AGI")
     self.contents.draw_text(160,64,80,32,@actor.agi.to_s,2)
   end
   if @new_int != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,96,80,32,"INT")
     if @new_int > @actor.int
       self.contents.font.color = text_color(6)
     elsif @new_int < @actor.int
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,96,80,32,@new_int.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,96,80,32,"INT")
     self.contents.draw_text(160,96,80,32,@actor.int.to_s,2)
   end
   if @new_eva != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,128,80,32,"EVA")
     if @new_eva > @actor.eva
       self.contents.font.color = text_color(6)
     elsif @new_eva < @actor.eva
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(160,128,80,32,@new_eva.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(134,128,80,32,"EVA")
     self.contents.draw_text(160,128,80,32,@actor.eva.to_s,2)
   end
   if @new_luck != nil
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,128,80,32,"LUCK")
     if @new_luck > @actor.luck
       self.contents.font.color = text_color(6)
     elsif @new_luck < @actor.luck
       self.contents.font.color = text_color(2)
     else
       self.contents.font.color = text_color(0)        
     end
     self.contents.draw_text(30,128,80,32,@new_luck.to_s,2)
   else
     self.contents.font.color = text_color(0)        
     self.contents.draw_text(4,128,80,32,"LUCK")
     self.contents.draw_text(30,128,80,32,@actor.luck.to_s,2)
   end
 end
 def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck)
   if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int or @new_eva != new_eva or @new_luck != new_luck
     @new_atk = new_atk
     @new_pdef = new_pdef
     @new_mdef = new_mdef
     @new_str = new_str
     @new_dex = new_dex
     @new_agi = new_agi
     @new_int = new_int
     @new_eva = new_eva
     @new_luck = new_luck
     refresh
   end
 end
end

class Scene_Equip
alias old_refresh refresh
 def refresh
   @item_window1.visible = (@right_window.index == 0)
   @item_window2.visible = (@right_window.index == 1)
   @item_window3.visible = (@right_window.index == 2)
   @item_window4.visible = (@right_window.index == 3)
   @item_window5.visible = (@right_window.index == 4)
   item1 = @right_window.item
   case @right_window.index
   when 0
     @item_window = @item_window1
   when 1
     @item_window = @item_window2
   when 2
     @item_window = @item_window3
   when 3
     @item_window = @item_window4
   when 4
     @item_window = @item_window5
   end
   if @right_window.active
     @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, nil)
   end
   if @item_window.active
     item2 = @item_window.item
     last_hp = @actor.hp
     last_sp = @actor.sp
     @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
     new_atk = @actor.atk
     new_pdef = @actor.pdef
     new_mdef = @actor.mdef
     new_str = @actor.str
     new_dex = @actor.dex
     new_agi = @actor.agi
     new_int = @actor.int
     new_eva = @actor.eva
     new_luck = @actor.luck
     @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
     @actor.hp = last_hp
     @actor.sp = last_sp
     @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva, new_luck)
   end
 end
end

module RPG
 class Weapon
 alias old_initialize initialize
   def initialize
     old_initialize
     @luck = 0
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :icon_name
   attr_accessor :description
   attr_accessor :animation1_id
   attr_accessor :animation2_id
   attr_accessor :price
   attr_accessor :atk
   attr_accessor :pdef
   attr_accessor :mdef
   attr_accessor :str_plus
   attr_accessor :dex_plus
   attr_accessor :agi_plus
   attr_accessor :int_plus
   attr_accessor :element_set
   attr_accessor :plus_state_set
   attr_accessor :minus_state_set
   attr_accessor :luck
 end
end

module RPG
 class Armor
 alias old_initialize initialize
   def initialize
     old_initialize
     @luck = 0
   end
   attr_accessor :id
   attr_accessor :name
   attr_accessor :icon_name
   attr_accessor :description
   attr_accessor :kind
   attr_accessor :auto_state_id
   attr_accessor :price
   attr_accessor :pdef
   attr_accessor :mdef
   attr_accessor :eva
   attr_accessor :str_plus
   attr_accessor :dex_plus
   attr_accessor :agi_plus
   attr_accessor :int_plus
   attr_accessor :guard_element_set
   attr_accessor :guard_state_set
   attr_accessor :luck
 end
end

class Game_Battler
 def luck
   n = base_luck
   return n
 end
end

class Game_Actor < Game_Battler
 def base_luck
   weapon = $data_weapons[@weapon_id]
   armor1 = $data_armors[@armor1_id]
   armor2 = $data_armors[@armor2_id]
   armor3 = $data_armors[@armor3_id]
   armor4 = $data_armors[@armor4_id]
   luck1 = weapon != nil ? weapon.luck : 0
   luck2 = armor1 != nil ? armor1.luck : 0
   luck3 = armor2 != nil ? armor2.luck : 0
   luck4 = armor3 != nil ? armor3.luck : 0
   luck5 = armor4 != nil ? armor4.luck : 0
   return luck1 + luck2 + luck3 + luck4 + luck5
 end
end

class Scene_Title
alias old_main main
 def main
   if $BTEST
     battle_test
     return
   end
   $data_actors        = load_data("Data/Actors.rxdata")
   $data_classes       = load_data("Data/Classes.rxdata")
   $data_skills        = load_data("Data/Skills.rxdata")
   $data_items         = load_data("Data/Items.rxdata")
   $data_weapons       = load_data("Data/Weapons.rxdata")
   $data_armors        = load_data("Data/Armors.rxdata")
   $data_enemies       = load_data("Data/Enemies.rxdata")
   $data_troops        = load_data("Data/Troops.rxdata")
   $data_states        = load_data("Data/States.rxdata")
   $data_animations    = load_data("Data/Animations.rxdata")
   $data_tilesets      = load_data("Data/Tilesets.rxdata")
   $data_common_events = load_data("Data/CommonEvents.rxdata")
   $data_system        = load_data("Data/System.rxdata")
   $data_weapons[1].luck = 6
   $game_system = Game_System.new
   @sprite = Sprite.new
   @sprite.bitmap = RPG::Cache.title($data_system.title_name)
   s1 = "New Game"
   s2 = "Continue"
   s3 = "Shutdown"
   @command_window = Window_Command.new(192, [s1, s2, s3])
   @command_window.back_opacity = 160
   @command_window.x = 320 - @command_window.width / 2
   @command_window.y = 288
   @continue_enabled = false
   for i in 0..3
     if FileTest.exist?("Save#{i+1}.rxdata")
       @continue_enabled = true
     end
   end
   if @continue_enabled
     @command_window.index = 1
   else
     @command_window.disable_item(1)
   end
   $game_system.bgm_play($data_system.title_bgm)
   Audio.me_stop
   Audio.bgs_stop
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @command_window.dispose
   @sprite.bitmap.dispose
   @sprite.dispose
 end
end

class Game_Actor < Game_Battler
alias old_setup setup
 def setup(actor_id)
   old_setup(actor_id)
   @luck = 0
 end 
 attr_reader   :name                     
 attr_reader   :character_name           
 attr_reader   :character_hue            
 attr_reader   :class_id                 
 attr_reader   :weapon_id                
 attr_reader   :armor1_id               
 attr_reader   :armor2_id               
 attr_reader   :armor3_id               
 attr_reader   :armor4_id               
 attr_reader   :level                   
 attr_reader   :exp                      
 attr_reader   :skills                 
 attr_accessor :luck
end

 

Also, I am new at posting, so if anyone knows how to add a spoiler to the code that would be great.

 

Thanks again for any insight!

Share this post


Link to post
Share on other sites
  • 0

Aha I think I have the solution to your problem. First off, because you have a method called luck for Game_Battler (super class of Game_Actor) and a accessor attribute luck for Game_Actor (since attribute accessors count as methods) it overwrites your Game_Battler's luck method. So you must remove the luck attribute from Game_Actor.

 

Now I know you said that gives you an error, but I have a solution to that. The issue, is when you click okay in the database (or apply) it creates a new Armor/Weapon object based on the hidden RPG module and hidden classes and saves them in the Marshal format, and then you load them into the $data_weapons/armors variable; and since the RPG::Armors/Weapons have been overwritten, these objects now also have the luck attribute (ruby is a very dynamic language and methods can be added/changed during run-time), however since it was not initialized when you originally saved the database (as it created the objects based on the old classes) each weapon and armor attribute is set to nil (no value).

 

Now while I am not 100% sure if this is the EXACT process rpg maker goes through, it is the best answer I can come up with based on the behaviours of these scripts...

 

Anyways, to fix it; what you will need to do is set EVERY single weapon/armor used in the database ($data_weapons[1].luck = 0, $data_weapons[2].luck = 0 $data_weapons[3].luck = 0...etc basically the index number in [] corresponds with the ID# in the database) to a value before you can call the luck attribute correctly.

 

I hope this all made sense, if you need further clarification lemme know.

 

as for spoiler tags:

[spoiler]spoiler goes here[/spoiler]

 

Also if you don't mind (I don't mean to cause any offence, just some advice) I have a few tips for your scripting:

 

(1) Since you are scripting for your game (not for others), I would suggest not aliasing methods and simply editing them right in their scripts in the editor. Although it's not really noticeable, by aliasing you are causing unnecessary method calls which use processing/ram power.

 

(2) Some of your aliases do not call the original method, and are thus unnecessary. Although you have been using it correctly in most cases, if you alias a method then overwrite it; but do not call the original in the overwritten method...then you really only have to overwrite the method without aliasing it...(although if you edit the scripts right in their spots, you would not have to alias anyways)

 

(3) Although not essential to efficient coding, it would be useful (to yourself mostly) to comment your code where necessary. It can help when changes are necessary or if you do not remember what exactly is happening.

 

Overall though, nothing wrong with what you have :alright: hope you don't mind me nitpicking XD I at least hope it might help

Share this post


Link to post
Share on other sites
  • 0

Thank you so much, kellessdee! That works perfectly : ) I really appreciate the help.

 

I completely overlooked the fact that the Game_Actor class fell under Game_Battler… doh! And I will definitely take your advice on the coding. I am always looking for constructive feedback so that I can be better, and I value the comments you left.

 

Thanks again!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...