Stegan

Villager
Member
Joined
Nov 21, 2020
Messages
16
Reaction score
0
First Language
German
Primarily Uses
RMVXA
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::DISABLE_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
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,813
Reaction score
14,977
First Language
English
Primarily Uses
RMMV

I've moved this thread to Learning Ruby and RGSS. Thank you.



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)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,244
Reaction score
7,628
First Language
Indonesian
Primarily Uses
RMVXA
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Feeling cute, might make an essay on the presence of Malaise in the gaming industry. idk
Just went to Metrocon here in Tampa Florida. My first anime convention. They had an anime chess battle and some funny impromtu comedy. The comedy was my favorite part. How is everyone?
I'm thinking about opening a "game in development" thread, though i'm not entirely sure yet. It's still really early in development, and most i have to show are assets or really chaotic map WIPs. There is a lot of story +the world itself though, and i struggle with converting all of my notes into readable text, and a thread might help...?
I see a button in a game, I press it. Cannot resist the temptation even if I know it's a trap.

Forum statistics

Threads
113,592
Messages
1,076,074
Members
147,590
Latest member
LiYe
Top