RMMZ Random encounters only active after a switch is ON?

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,393
Reaction score
1,097
First Language
French
Is there a way so that the random encounters on a map are only active after a switch is ON? Or more generally any script or plugin that would achieve that?

I also have Visustella.
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
780
Reaction score
748
First Language
german
Primarily Uses
RMMZ
You can alias Game_Player.prototype.canEncounter or Game_System.prototype.isEncounterEnabled. Doesn't matter which one you pick.

Create a plugin and insert this:

Code:
(function() {
  const alias = Game_Player.prototype.canEncounter
  Game_Player.prototype.canEncounter = function() {
    return $gameSwitches.value(42) && alias.call(this);
})()

Replace 42 with your Switch Id.
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,393
Reaction score
1,097
First Language
French
Don't we get way too used to relying on plugins? lol
Although truth be told sometimes the native functions are surprisingly limited. But not this time!
 

Latest Threads

Latest Profile Posts

KDS
Hey guys! Iam currently updating my free digital art shop , let me know if you need anything done :) https://forums.rpgmakerweb.com/index.php?threads/kds-free-open-digital-art-shop.17097/
Hello! I’d like to ask where is a good place to start logging about my game dev progress as production of my game goes forth
In one of our campus classrooms was a bag full of stuff people forgot there... my bag. That I forgot there xD
You know your room is too tiny for how much stuff you have when it gives you literal insomnia. I just cleared a bunch of stuff out and man it feels good!
1670381555475.png
Meet the Kernel. You encounter him in cyberspace. He's important!

Forum statistics

Threads
127,098
Messages
1,183,963
Members
167,028
Latest member
Edujandro
Top