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,847
Reaction score
14,983
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,248
Reaction score
7,636
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

I guess it becomes purely academic in less than four days but before then can anyone explain to me why the %^&*( animations in the MZ database don't have a 'Hue' slider??
Who here knows of the hidden laws of this multiverse? Such as the law of attraction
Exploding Fruits and Rasaks Pixelfarm Assets | RPG Maker News #108

So ghosts can go through walls and stuff, and depending their type (according to fantasy media) they can or can't interact with objects to a certain degree...

So why they don't always fall through floors? Do they always float and sometimes simulate walking? If things go through them how can they hear/see? And why sometimes they have clothing? Do clothes die as well?
my birthday was yesterday...
i feel closer 2 being able 2 get a discount on the kids menu than i do being able to buy booze1627428008986.png

Forum statistics

Threads
113,704
Messages
1,076,782
Members
147,728
Latest member
Alteria
Top