Reset map script

I'm looking for a way to reset an entire map via one script call.

I know this is possible with event pages, but I'm trying to do this for 16ish maps with 40~100 events on each map..

Having a script call to do this would be enormous! Is this tough to do?
What are you trying to accomplish?


Resetting a map is as easy as simply reloading it, but that comes with a lot of consequences.
Just to reset the map to it's original state, no self switches on, people alive, etc

Best case scenario, a script call that says ->reset map 1
Event positions and such things are automatically reset on entering a map - in fact you need a script to store a change in event positions to prevent this.


So the only things that would need reset are the switches, self-switches and variables used on that map.


There probably is a way to automate that for self-switches by script, but to reset general switches and variables automatically can cause a lot of logic problems. Better you make a common event "reset for map xy" and manually control them back.
Self switches are my main concern. If I have to manually set switches and variables I have no problem with that.
Ok then let's start with something simple

class Game_Map def reload_map setup(@map_id) SceneManager.scene.instance_variable_get🙂@spriteset).refresh_characters endendScript call: $game_map.reload_mapNo different from exiting and re-entering a map.
This works perfect for resetting the map to its condition from within the map. edit: This actually pans your camera off the center of your character

Now is there a way to globally reset all switches for that map via script?

A way to do:

Event 1 in this map = self switch a/b/c/d off

is all I need. I can repeat this 100 times if need be and set it in the aforementioned script.

I can then call the script and copy pasta on each map. It would reduce the workload by many many hours
Code:
class Game_Map
  def reload_map
    setup(@map_id)
    @events.each do |id, ev|
      # assumes there are only 4. Bad assumption. Assumes "OFF" is the default state.
      $game_self_switches[[@map_id, id, "A"]] = false
      $game_self_switches[[@map_id, id, "B"]] = false
      $game_self_switches[[@map_id, id, "C"]] = false
      $game_self_switches[[@map_id, id, "D"]] = false
    end
    SceneManager.scene.instance_variable_get:)@spriteset).refresh_characters
  end
end
@flipwon: for the camera do you mean it pan the camera permanently? Or just for split second and then fixed. Or need to move before fixed. If only split second. Try using fadeout and fadein to hide that.

@hime: maybe adding checkpoint feature. Something like this maybe:

Code:
def checkpoint @events.each do |id, ev| Store the current state of the self switches in a hash variable inside game system. Which will be accessed instead just false if exist. I post using phone. So I cannot type the code . endend
Even we can also store certain event only. By passing array containing event id we want to create the check point. Then add some next if array include id in the each do statement.
class Game_Map def reload_map setup(@map_id) @events.each do |id, ev| # assumes there are only 4. Bad assumption. Assumes "OFF" is the default state. $game_self_switches[[@map_id, id, "A"]] = false $game_self_switches[[@map_id, id, "B"]] = false $game_self_switches[[@map_id, id, "C"]] = false $game_self_switches[[@map_id, id, "D"]] = false end SceneManager.scene.instance_variable_get🙂@spriteset).refresh_characters endend
Perfect. Hime you rock
@flipwon: for the camera do you mean it pan the camera permanently? Or just for split second and then fixed. Or need to move before fixed. If only split second. Try using fadeout and fadein to hide that.

@hime: maybe adding checkpoint feature. Something like this maybe:

def checkpoint @events.each do |id, ev| Store the current state of the self switches in a hash variable inside game system. Which will be accessed instead just false if exist. I post using phone. So I cannot type the code . endendEven we can also store certain event only. By passing array containing event id we want to create the check point. Then add some next if array include id in the each do statement.
It's a permanent pan within the map. I just do a quick fade reload though and it seems to work fine.

Original thread: https://forums.rpgmakerweb.com/threads/reset-map-script.17015/