Slow down in water script...

Hi, I wrote this script into my game and now my character walks slower in water titles...
But I can't figure out a way to play this to my enemy events. They just walk over it like it's nothing.

Here is the script:

module CLAIVE_SLOW_REGION

#Region ID which slows the player.
REGION_ID = 3

#Switch used to disable this feature at any time.
DISABLE_SWITCH = 16

end


class Game_Player < Game_Character

attr_accessor :move_speed

alias :claive_update :update
def update
claive_update
check_slow_region
end

def check_slow_region
return if $game_switches[CLAIVE_SLOW_REGION:😀ISABLE_SWITCH]
r_id = $game_map.region_id($game_player.x, $game_player.y)
if r_id == CLAIVE_SLOW_REGION::REGION_ID
$game_player.move_speed = 3
else
$game_player.move_speed = 4
end
end

end
Moved to: Learning Ruby and RGSS

Well, if you base the new functionality on the Game_Player class, then naturally it's only going to affect the player.

If you want it to affect events as well, you need to base it on the Game_Character class instead.

And just put self.move_speed = whatever, not $game_player.move_speed (which is pointless to do when you're already in a class that's only used by $game_player anyway)
Here are the 5 lines to do it
Ruby:
class Game_Character
  def real_move_speed
    super - (region_id == 3 && $game_switches[xxx] ? 1 : 0 )
  end
end
Edit the condition accordingly.

Original thread: https://forums.rpgmakerweb.com/threads/slow-down-in-water-script.137268/