I've modified and defined classes before, but I've never worked with the "RPG::" Classes themselves before, and I think I'm doing something wrong here because I can't figure out why else I'd be getting these strange errors.
I wanted to add attributes to the RPG::State class, so, in its simplest form, this is how I set it up:
class RPG::State < RPG::BaseItem #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias :scaling_initialize :initialize def initialize scaling_initialize @dur_scale_type = 3 @dur_scale_form = "" end #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :dur_scale_type attr_accessor :dur_scale_formendNow, I want to use those two new attributes when adding a State to a battler in battle. So I went to Game_Battler and overwrote the reset_state_counts method as such:
class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Reset State Counts (Turns and Steps) # Overwrite Method! Performs original state-count set, then new stuff. #-------------------------------------------------------------------------- def reset_state_counts(state_id, user, target, item) # Old Code is here! state = $data_states[state_id] variance = 1 + [state.max_turns - state.min_turns, 0].max @state_turns[state_id] = state.min_turns + rand(variance) @state_steps[state_id] = state.steps_to_remove # New Code starts here! if state.dur_scale_type > 0 # THIS IS THE ERROR LINE!!! if state.auto_removal_timing > 0 if @state_turns != nil case state.dur_scale_type when 1 @state_turns[state_id] += refine_scaling_value(state.dur_scale_form, user, target) when 3 @state_turns[state_id] = refine_scaling_value(state.dur_scale_form, user, target) end end end end endWhen the game starts, I get an error because of the line "if state.dur_scale_type > 0".
The error message reads:
Script 'Scaling_Utility' line 93: NoMethodError occurred.
undefined method `>' for nil:NilClass
When I change the line to read "if state.dur_scale_type != 0" instead of "if state.dur_scale_type > 0", the game starts okay, but the functionality I've built with the script seems to be ignored.
Together with some other trial and error that I did, these problems make me think that for some reason, dur_scale_type is being treated as a variable, but not as an integer variable. I can't figure out why this would be the case.
Notes: I added the extra arguments into methods that call the reset_state_counts method, and I think I got them all. I defined a refine_scaling_value method inside the Game_Battler class. I removed code that I don't believe is relevant, to make the code block less absurdly long as you try to help me out with this. If you think you need to see more, I'll post the entire script, as it stands now.
If anyone can help me solve this problem, you'll make my day! THANK YOU.