Disable Encounter

Disable Encounter 1.0.0
Feelzor
​

Introduction
This script simply disables the encounter temporarily everywhere in just one call; same to enable it again.

Features
- Disables the encounter

How to Use
Just copy-paste the code in the script editor and then call it from wherever you want using the following instructions:
To disable the encounter temporarily, just open a script and put in it $game_player.disable_encounter.
To enable it again, just open a script and put in it $game_player.enable_encounter.
The script won't re-enable it automatically.

Script
Code:
#################################################################################
#                               DISABLE ENCOUNTER                               #
#                                  By: FEELZOR                                  #
#################################################################################
#                                                                               #
# Free to use for any commercial or non-commercial project.                     #
# Credits not required but really appreciated.                                  #
#                                                                               #
# To disable encounter, make a script call with $game_player.disable_encounter  #
# in it. To enable it again, make a script call with                            #
# $game_player.enable_encounter.                                                #
#################################################################################
if true #set to false to disable
class Game_Player < Game_Character
  alias enc_initialize initialize
  def initialize
    enc_initialize
    @encounter_disabled = false
  end
  
  alias enc_encounter encounter
  def encounter
    return false if @encounter_disabled
    enc_encounter
  end
  
  def enable_encounter
    $game_player.make_encounter_count
    @encounter_disabled = false
  end
  
  def disable_encounter
    @encounter_disabled = true
  end
end
end #endif

Credit and Thanks
- Feelzor
- IXFURU who inspired me with their DISABLE DASH script.

Author's Notes
As it is my first script, it may have problems or be written in a wrong way.
I tried to do my best making it as I found no script like that while searching on Google (maybe that's because I'm not level 1 yet.. 😛), but do not hesitate to give me any tip to improve the code!
Fantastic job for a first script, but I'm going to reluctantly burst your bubble a little and point out that it's somewhat redundant: on page 3 of event commands is "Change Encounter" where you can enable or disable encounters. This functionality already exists in the default engine.
Aaaaaah thank you!
That's why I couldn't find a script anywhere :') I was searching for this option and I didn't take a look at this part. My bad! Thanks for pointing this out, though! 😀

So I guess this script is useless now (at least I tried 😛).
Thanks for your reply anyway, I'll keep on trying to find good scripts to do! 😀
Look on the bright side: you figured out for yourself how to implement a feature that the engine had, so however you look at it, it was valuable experience.
Yeah that's right 😀 I wouldn't complain about it, as it makes me learn Ruby and help me know how aliases work 😀
btw, check out class_eval. It's a more efficient way of reopening classes that doesn't require declaring them again.
btw, check out class_eval. It's a more efficient way of reopening classes that doesn't require declaring them again.
But how is that relevant here? o.o
The only thing I would use that method is to define lotsa methods for a class at once with a simple iteration of all the data for them (to create dynamic methods based on a separate database, for example).
Other than that, I can't see any reason to use it.
Which leads me to my question... Why/how would it be more efficient and on what else could it be used for other than batch definitions?
Because simply using that method instead of doing the regular syntax for normal method definitions doesn't seem more efficient to me, on the contrary, in my opinion.
But how is that relevant here? o.o
The only thing I would use that method is to define lotsa methods for a class at once with a simple iteration of all the data for them (to create dynamic methods based on a separate database, for example).
Other than that, I can't see any reason to use it.
Which leads me to my question... Why/how would it be more efficient and on what else could it be used for other than batch definitions?
Because simply using that method instead of doing the regular syntax for normal method definitions doesn't seem more efficient to me, on the contrary, in my opinion.

There's an interesting article here exploring the difference between them: http://juixe.com/techknow/index.php/2007/01/17/reopening-ruby-classes-2/

Honestly the biggest upside to it from my perspective is that when using class_eval you don't have to worry about which class the one you're reopening is inheriting from; when doing it the other way you need to look at the original class if you're not sure what it's a child of or if it's even a child of anything at all, so if nothing else it saves a little bit of time.

Original thread: https://forums.rpgmakerweb.com/threads/disable-encounter.85943/