[XP] Map Switch! XP alteration? Sorta

Started by l0rdph0enix, August 02, 2011, 06:34:04 pm

Previous topic - Next topic

l0rdph0enix

Hey I'm using Map Switch! XP by Punk and it works great for what I need it to do. But I was wondering if someone could show me, or tell me how I can make a version of this script so that depending on what map you are on it changes 1 variable. Example: Your on maps [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] so it sets Variable 39 to 1, if you're on maps [11, 12, 13, 14, 15, 16, 17, 18, 19, 20] it sets Variable 39 to 2, and so on.

Spoiler: ShowHide


=begin
╔══════════════════════════════════════════════════════════════════════════════╗
║ MapSwitch! XP                                                                ║
║ By Punk                                                                      ║
║ ------------------------                                                     ║
║ 7/7/2008                                                                     ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Author's Notes:                                                            ║
║ └─ While I was working on an event system, I started thinking about making a ║
║    script which would turn on a switch whenever the player is on a certain   ║
║    map.                                                                      ║
║    During the making of this script, I learned something new...              ║
║    Constants! And Aliases!                                                   ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Description:                                                               ║
║ └─ The game creator can set what switch would turn on whenever the player is ║
║    in a certain map.                                                         ║
║ ■ Credits:                                                                   ║
║ ├─► Syvkal & Digi: Talking about $game_map.map_id.                           ║
║ ├─► Kurisu & Syvkal: Helping me out with Aliases and setting them up.        ║
║ └─► Trickster: He told me about constants and made my code less messy.       ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Things to know about:                                                      ║
║ ├─ PUNK_MAP_IDS: Setting up which Map IDs would turn on PUNK_MAP_SWITCH_ID.  ║
║ └─ PUNK_MAP_SWITCH_ID: This switch would turn on if the player happens to be ║
║                        in a map that is in the PUNK_MAP_IDS array. If the    ║
║                        player is in a map ID that isn't in the PUNK_MAP_IDS  ║
║                        array, the switch would turn off.                     ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Want to add another PUNK_MAP_IDS and PUNK_MAP_SWITCH_ID set of constants?  ║
║                                                                              ║
║  ╔════════════════════════════════════════════════════════════════════════╗  ║
║  ║ Below line 61, add these two lines. Be sure to append a number at the  ║  ║
║  ║ end of the constants so they can be easy to identify. (Example: _2)    ║  ║
║  ║ Use comment marks if you have to.                                      ║  ║
║  ╚═╤═════╤════════════════════════════════════════════════════════╤═════╤═╝  ║
║    │     │ Add these below line #61. Remember to append! (Ex: _2) │     │    ║
║    │     └────────────────────────────────────────────────────────┘     │    ║
║    │PUNK_MAP_IDS_2 = [7,9] # Map IDs Set 2                              │    ║
║    │PUNK_MAP_SWITCH_ID_2 = 3 # Switch ID Set 2                          │    ║
║  ╔═╧════════════════════════════════════════════════════════════════════╧═╗  ║
║  ║ Below line #77, add the line below this box. It's quite long. So you'll║  ║
║  ║ have to excuse me while I stretch the instruction box below.           ║  ║
║  ║ The constants within the line you'll have to paste must be the same as ║  ║
║  ║ the constants pasted below line #61.                                   ║  ║
║  ╚═╤═════╤════════════════════════════════════════════════════════╤═════╤═╝  ║
║    │     │ Add this below line #77. Remember to append! (Ex: _2)  │     │    ╚═══════╗
║    │     └────────────────────────────────────────────────────────┘     └───────────┐║
║    │$game_switches[PUNK_MAP_SWITCH_ID_2] = PUNK_MAP_IDS_2.include?($game_map.map_id)│║
║    └────────────────────────────────────────────────────────────────────────────────┘║
╚══════════════════════════════════════════════════════════════════════════════════════╝
=end

class Scene_Map
#==[Configuration]

#==<Inside>
  PUNK_MAP_IDS = [4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 18, 19, 22, 23, 24,
                  27, 30, 32, 33, 34, 36, 38, 39, 41, 43, 47, 48, 49, 50, 52,
                  53, 54, 55, 56, 57, 60, 62, 63, 64, 67, 69, 70, 71, 72, 74, 75,
                  76, 77, 79, 81, 83, 85, 86, 87] # Map IDs
  PUNK_MAP_SWITCH_ID = 12 # Switch ID
#==<Cave>
  PUNK_MAP_IDS_2 = [31, 44, 59, 68, 73, 78] # Map IDs Set 2
  PUNK_MAP_SWITCH_ID_2 = 4 # Switch ID Set 2
#==<Outside>
  PUNK_MAP_IDS_3 = [1, 2, 3, 8, 9, 16, 17, 20, 21, 25, 26, 28, 29, 35, 37, 40,
                    42, 45, 46, 51, 58, 61, 65, 66, 80, 82, 83, 84]
  PUNK_MAP_SWITCH_ID_3 = 10
#==[End Configuration]

  alias punk_main main
  def main
    punk_switch_check
    punk_main
  end

  alias punk_transfer_player transfer_player
  def transfer_player
    punk_transfer_player
    punk_switch_check
  end

  def punk_switch_check
    $game_switches[PUNK_MAP_SWITCH_ID] = PUNK_MAP_IDS.include?($game_map.map_id)
    #--<add more>--#
    $game_switches[PUNK_MAP_SWITCH_ID_2] = PUNK_MAP_IDS_2.include?($game_map.map_id)
    $game_switches[PUNK_MAP_SWITCH_ID_3] = PUNK_MAP_IDS_3.include?($game_map.map_id)
  end
end


nathmatt

did you want it by every 10 or was that just an example if it was just an example the map arrays was there 1 that is already configured in that script you wanted to use
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


l0rdph0enix

The '10' was just an example. The script I have here is just for turning on a certain switch if you're on that map other wise the switch is turned off. I use that for when the player is inside, in a cave or other cases. BUT I'd like to create another version of the script so that if you're on say Map01 called Fithavile and Fithavile is a town located on continent called Absitinvidia, then Absitinvidia's variable would be equal to 1. But hey wait now you've teleported to a new town in called Millington(Map02) and it's on a new continent Majeep, well now Majeep's variable is equal to 2. So the script would have to set the variable accordingly to what map you were on.

So going by how it's done in the Map Switch! script it would be set up as follows.

Spoiler: ShowHide


#==<Absitinvidia>
  LP_PUNK_MAP_IDS = [4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 18, 19, 22, 23, 24,
                  27, 30, 32, 33, 34, 36, 38, 39, 41, 43, 47, 48, 49, 50, 52,
                  53, 54, 55, 56, 57, 60, 62, 63, 64, 67, 69, 70, 71, 72, 74, 75,
                  76, 77, 79, 81, 83, 85, 86, 87] # Map IDs Set 1
  LP_PUNK_MAP_VARIABLE = 1 # Variable Value

#==<Majeep>
  LP_PUNK_MAP_IDS_2 = [31, 44, 59, 68, 73, 78] # Map IDs Set 2
  LP_PUNK_MAP_VARIABLE_2 = 2 # Variable Value


So now when the script sees that the player is on Map04 that it should set Variable 39 to = 1. And when the player is on Map31 to set Variable 39 to = 2. And so on. I hope that makes since.


nathmatt

ok i edit his script a little to make it more efficient here

Spoiler: ShowHide
=begin
╔══════════════════════════════════════════════════════════════════════════════╗
║ MapSwitch! XP                                                                ║
║ By Punk                                                                      ║
║ ------------------------                                                     ║
║ 7/7/2008                                                                     ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Author's Notes:                                                            ║
║ └─ While I was working on an event system, I started thinking about making a ║
║    script which would turn on a switch whenever the player is on a certain   ║
║    map.                                                                      ║
║    During the making of this script, I learned something new...              ║
║    Constants! And Aliases!                                                   ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Description:                                                               ║
║ └─ The game creator can set what switch would turn on whenever the player is ║
║    in a certain map.                                                         ║
║ ■ Credits:                                                                   ║
║ ├─► Syvkal & Digi: Talking about $game_map.map_id.                           ║
║ ├─► Kurisu & Syvkal: Helping me out with Aliases and setting them up.        ║
║ └─► Trickster: He told me about constants and made my code less messy.       ║
╟──────────────────────────────────────────────────────────────────────────────╢
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Things to know about:                                                      ║
║ ├─ PUNK_MAP_IDS: Setting up which Map IDs would turn on PUNK_MAP_SWITCH_ID.  ║
║ └─ PUNK_MAP_SWITCH_ID: This switch would turn on if the player happens to be ║
║                        in a map that is in the PUNK_MAP_IDS array. If the    ║
║                        player is in a map ID that isn't in the PUNK_MAP_IDS  ║
║                        array, the switch would turn off.                     ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ ■ Want to add another PUNK_MAP_IDS and PUNK_MAP_SWITCH_ID set of constants?  ║
║                                                                              ║
║  ╔════════════════════════════════════════════════════════════════════════╗  ║
║  ║ Below line 61, add these two lines. Be sure to append a number at the  ║  ║
║  ║ end of the constants so they can be easy to identify. (Example: _2)    ║  ║
║  ║ Use comment marks if you have to.                                      ║  ║
║  ╚═╤═════╤════════════════════════════════════════════════════════╤═════╤═╝  ║
║    │     │ Add these below line #61. Remember to append! (Ex: _2) │     │    ║
║    │     └────────────────────────────────────────────────────────┘     │    ║
║    │PUNK_MAP_IDS_2 = [7,9] # Map IDs Set 2                              │    ║
║    │PUNK_MAP_SWITCH_ID_2 = 3 # Switch ID Set 2                          │    ║
║  ╔═╧════════════════════════════════════════════════════════════════════╧═╗  ║
║  ║ Below line #77, add the line below this box. It's quite long. So you'll║  ║
║  ║ have to excuse me while I stretch the instruction box below.           ║  ║
║  ║ The constants within the line you'll have to paste must be the same as ║  ║
║  ║ the constants pasted below line #61.                                   ║  ║
║  ╚═╤═════╤════════════════════════════════════════════════════════╤═════╤═╝  ║
║    │     │ Add this below line #77. Remember to append! (Ex: _2)  │     │    ╚═══════╗
║    │     └────────────────────────────────────────────────────────┘     └───────────┐║
║    │$game_switches[PUNK_MAP_SWITCH_ID_2] = PUNK_MAP_IDS_2.include?($game_map.map_id)│║
║    └────────────────────────────────────────────────────────────────────────────────┘║
╚══════════════════════════════════════════════════════════════════════════════════════╝
=end

class Game_Map
#==[Configuration]

#==<Inside>
  PUNK_MAP_IDS = [4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 18, 19, 22, 23, 24,
                  27, 30, 32, 33, 34, 36, 38, 39, 41, 43, 47, 48, 49, 50, 52,
                  53, 54, 55, 56, 57, 60, 62, 63, 64, 67, 69, 70, 71, 72, 74, 75,
                  76, 77, 79, 81, 83, 85, 86, 87] # Map IDs
  PUNK_MAP_SWITCH_ID = 12 # Switch ID
#==<Cave>
  PUNK_MAP_IDS_2 = [31, 44, 59, 68, 73, 78] # Map IDs Set 2
  PUNK_MAP_SWITCH_ID_2 = 4 # Switch ID Set 2
#==<Outside>
  PUNK_MAP_IDS_3 = [1, 2, 3, 8, 9, 16, 17, 20, 21, 25, 26, 28, 29, 35, 37, 40,
                    42, 45, 46, 51, 58, 61, 65, 66, 80, 82, 83, 84]
  PUNK_MAP_SWITCH_ID_3 = 10
 
  def punk_map_variables(id)
    return 1 if PUNK_MAP_IDS.include?(id)
    return 2 if PUNK_MAP_IDS_2.include?(id)
    return 3 if PUNK_MAP_IDS_3.include?(id)
  end
 
#==[End Configuration]
 
  alias check_setup setup
  def setup(map_id)
    check_setup(map_id)
    punk_switch_check(map_id)
    $game_variables[39] = punk_map_variables(map_id)
  end
 
  def punk_switch_check(map_id)
    $game_switches[PUNK_MAP_SWITCH_ID] = PUNK_MAP_IDS.include?(map_id)
    #--<add more>--#
    $game_switches[PUNK_MAP_SWITCH_ID_2] = PUNK_MAP_IDS_2.include?(map_id)
    $game_switches[PUNK_MAP_SWITCH_ID_3] = PUNK_MAP_IDS_3.include?(map_id)
  end
   
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


l0rdph0enix

Cool thank you, I'll give it a run when I get home. Spent 30min last night making a common even that does what I wanted it to do with a crap load of conditional branches. That's fine and dandy but when I have to have a conditional branch for every map (so far over 86) it gets pretty long. That's why I wanted a script that all I had to do was plug in the map ID's and it does the rest for me. I looked over the code and yes I do believe it'll work for me. Thank you again for helping me out nathmatt. I'm pretty sure you're credited, in my game, might even have a special thanks too, but I'ma add a star to your name.