Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: [Luke] on January 05, 2011, 03:03:46 pm

Title: [XP] Speed Change States for Blizz-ABS
Post by: [Luke] on January 05, 2011, 03:03:46 pm
As the name says. It seems it doesn't work. What am I doing wrong?

module LUKConfig
  SLOW_STATES = [58]
  HASTE_STATES = [51]
end

class Map_Battler
  alias luke_speed_states_update update
  def update
    luke_speed_states_update
    self.battler.states.each {|id|
      if LUKConfig::SLOW_STATES.include?(id)
        @move_speed = @normal_speed - 1
      elsif LUKConfig::HASTE_STATES.include?(id)
        @move_speed = @normal_speed + 1
      end}
  end
end
Title: Re: [XP] Speed Change States for Blizz-ABS
Post by: ForeverZer0 on January 05, 2011, 04:50:18 pm
Not exactly sure, could be a couple of things. First though, it woul be better to use the "any?" method than the "include?" method. That way it doesn't iterate needlessly after the condition is already met.


if LUKConfig::SLOW_STATES.any? {|id| self.battler.states.include?(id) }

# blah blah blah

end


Some possibilities:

1. There is a "return" in the update method, or in an aliased method before it.

2. The script may need reference move_speed in a different class. Try Game_Character, or whatever the super class is of Map_Battler.

3. Make sure there is not another script below this one that also changes the move speed, nullifing what you changed.

4. Try changing script order and see what happens.

Title: Re: [XP] Speed Change States for Blizz-ABS
Post by: [Luke] on January 05, 2011, 06:54:36 pm
No script below changes the move_speed value, although changing it doesn't seem to affect player speed (I've checked with your simple but great console output - the variable change is executed, value for the battler changes, but nothing happens on the screen).
How it looks now:
module LUKConfig
  SLOW_STATES = [58]
  HASTE_STATES = [51]
end

class Game_Character
  alias luke_speed_states_update update
  def update
    luke_speed_states_update
    return if !self.is_a?(Map_Battler)
    if LUKConfig::SLOW_STATES.any? {|id| self.battler.states.include?(id)}
      @move_speed = @normal_speed - 1
    elsif LUKConfig::HASTE_STATES.any? {|id| self.battler.states.include?(id) }
      @move_speed = @normal_speed + 1
    end
  end
end


It would be nice to have this working, since I'm gonna expand it and add penalty & charging time change for specified states.
Title: Re: [XP] Speed Change States for Blizz-ABS
Post by: winkio on January 05, 2011, 07:10:51 pm
so the big reason why I don't think this is working for you is because Controller resets move speed for the player based on the user input.  To fix this without doing a large rewrite, just change @normal_speed (and Config::RUN_SPEED and Config::SNEAK_SPEED in the case of the player) to what you need them to be, then, you wont have to fight Blizz-ABS each frame.  @normal_speed is specific to each character, so you don't have to worry about it affecting characters without the state.

EDIT: Also, you should be doing this with Map_Battler, not Game_Character.