Save-Point
MapSwitch 2 for RPG Maker XP [Exclusive] - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: MapSwitch 2 for RPG Maker XP [Exclusive] (/thread-2207.html)



MapSwitch 2 for RPG Maker XP [Exclusive] - PK8 - 07-03-2009

MapSwitch! 2 (RMXP)
Version: 2

Introduction
This script is pretty much designed to help developers streamline their projects with great ease. Here's how the script works and try to bear with my sloppy attempt at an explanation.

Okay so when a player enters a certain group of Map IDs, a particular switch would activate. When the player leaves one of those Map IDs, the switch that activated upon entering in the map would deactivate as well.

Again, I think it's totally useful and it helps streamline your project a little bit. Alright, here's an example:
How about marking which maps are "dungeons"? Whenever the player enters a map marked as a "dungeon", a switch would activate.

Features
  • Developers can set up what group of map IDs would activate a switch.
  • Switch deactivates whenever the player is not in a marked map ID.
  • It might help streamline your project.

Screenshots
I can't screenshot this but I will say this. Try the script out, set it up, enter multiple rooms and use RMXP's debug function (press F9) to see which switches are activated.

Demo
No demo.

Script
Code:
=begin
?????????????????????????????????????????????????????????????????????????????????
? MapSwitch 2 for RPG Maker XP                                                 ?
? Version 2                                                                    ?
? by PK8                                                                       ?
? July 3rd, 2009                                                               ?
? http://rmvxp.com                                                             ?
?????????????????????????????????????????????????????????????????????????????????
? ? Table of Contents                                                          ?
? ?? Author's Notes                - Line 17?20                                ?
? ?? Introduction & Description    - Line 22?34                                ?
? ?? Features                      - Line 36?39                                ?
? ?? Setting Up                    - Line 41?50                                ?
? ?? This aliases the following... - Line 52?53                                ?
? ?? Thanks                        - Line 55?57                                ?
?????????????????????????????????????????????????????????????????????????????????
? ? Author's Notes                                                             ?
? I made v1 a year ago, mainly to give users (primarily eventers) a script     ?
? which could help them out a little. Version 2 might not be much but it's a   ?
? vast improvement over the first.                                             ?
?????????????????????????????????????????????????????????????????????????????????
? ? Introduction & Description                                                 ?
? This script is pretty much designed to help developers streamline their      ?
? projects with great ease. Here's how the script works and try to bear with my?
? sloppy attempt at an explanation.                                            ?
?                                                                              ?
? Okay so when a player enters a certain group of Map IDs, a particular switch ?
? would activate. When the player leaves one of those Map IDs, the switch that ?
? activated upon entering in the map would deactivate as well.                 ?
?                                                                              ?
? Again, I think it's totally useful and it helps streamline your project a    ?
? little bit. Alright, here's an example:                                      ?
? How about marking which maps are "dungeons"? Whenever the player enters a map?
? marked as a "dungeon", a switch would activate.                              ?
?????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Developers can set up what group of map IDs would activate a switch.       ?
? ? Switch deactivates whenever the player is not in a marked map ID.          ?
? ? It might help streamline your project.                                     ?
?????????????????????????????????????????????????????????????????????????????????
? ? Setting Up                                                                 ?
?   Take a look at this:                                                       ?
?                                                                              ?
?   Usage:                                                                     ?
?   Mapswitch[switch id] = [multiple map ids]                                  ?
?                                                                              ?
?   Example:                                                                   ?
?   Mapswitch[1] = [2, 3, 5]                                                   ?
?   Whenever the player is on maps 2, 3 or 5, switch 1 would activate. Whenever?
?   the player is not in any of those maps, the switch would deactivate.       ?
?????????????????????????????????????????????????????????????????????????????????
? ? This aliases the following...                                              ?
? main - Scene_Map                                                             ?
?????????????????????????????????????????????????????????????????????????????????
? ? Thanks                                                                     ?
? EJlol: Helping out with a hash-related problem I had while remaking this     ?
?        short script.                                                         ?
?????????????????????????????????????????????????????????????????????????????????
=end

#===============================================================================?
# ** MapSwitch 2 for RPG Maker XP customisation!
#-------------------------------------------------------------------------------
# Set up which maps would activate a particular switch.
# Remember: Mapswitch[switchid] = [map ids]
#===============================================================================?
class PK8
  Mapswitch = {} # Don't touch this.
  
  # Switch ID  |  Multiple Map IDs
  Mapswitch[1] = [1, 100]
  Mapswitch[3] = [2, 3, 4, 5, 6]
  Mapswitch[11] = [8]
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================
class Scene_Map
  alias pk8_mapswitch_main :main
  
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    pk8_mapswitch_main
    PK8::Mapswitch.each_pair { |pk8_maps_sid, pk8_maps_mid|
    $game_switches[pk8_maps_sid] = pk8_maps_mid.include?($game_map.map_id) }
  end
end

Instructions
Jump to line 70 and set up the script from there.

FAQ
Awaiting question.

Compatibility
This aliases main of Scene_Map.

Credits and Thanks
EJlol helped me out with stuff related to hashes.

Author's Notes
I made v1 a year ago, mainly to give users (primarily eventers) a script which could help them out a little. Version 2 might not be much but it's a vast improvement over the first.

Terms and Conditions
Exclusive to RMVXPUniverse, also, credit me please. :3