Advertisement
WCouillard

RGSS3: Lune World Map (Templeton Mod)

Nov 17th, 2013
1,288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.54 KB | None | 0 0
  1. #=======================================================
  2. #        Lune World Map (Templeton Map Mod)
  3. # Original Author: Raizen
  4. # Modifications: William Couillard (cooliebk18@yahoo.com)
  5. # Contact: www.centrorpg.com
  6. # Compatibility: RMVXAce
  7. #=======================================================
  8. # Adds a world map to your game, to be viewed.
  9. # Call Script: SceneManager.call(Scene_Templeton_Map)
  10. #=======================================================
  11. module MAPVOCAB
  12.   SHOP_TITLE = "Shopping"     # Title of Shops Window
  13.   SHOP1_NAME = "Inn"          # Name of Shop #1
  14.   SHOP2_NAME = "Item Shop"    # Name of Shop #2
  15.   SHOP3_NAME = "Weapons"      # Name of Shop #3
  16.   SHOP4_NAME = "Armor"        # Name of Shop #4
  17.   SHOP5_NAME = "Accessory"    # Name of Shop #5
  18.   SHOP6_NAME = "Magic"        # Name of Shop #6
  19.   SHOP7_NAME = "Synthesis"    # Name of Shop #7
  20. end
  21. #============================================================================
  22. module Templeton_Map
  23. # World Map Filename
  24. Map_Name = "TempletonMap"
  25. # Cursor Filename
  26. Map_Cursor = "Cursor2"
  27. # Cursor's X offset
  28. Cursor_X = 24
  29. # Cursor's Y offset
  30. Cursor_Y = -6
  31. Map_Info = Array.new
  32. # Create locations on your world map below using these instructions
  33. # "Name"     => 'Map Image Name', (The filename of the map image           )
  34. # "Switch"   => Switch ID,        (ID of the switch used to unlock location)
  35. # "Position" => [X, Y],           (Position of location icon on world map  )
  36. # "Icon"     => 'Map Icon',       (Filename of map location icon           )
  37. # "Desc"     => 'Description',    (Line 1 of map description               )
  38. # "Desc2"    => 'Description'     (Line 2 of map description               )
  39. # "Shop1"    => true/false,       (Shows SHOP1 as either true or false     )
  40. # "Shop2"    => true/false,       (Shows SHOP2 as either true or false     )
  41. # "Shop3"    => true/false,       (Shows SHOP3 as either true or false     )
  42. # "Shop4"    => true/false,       (Shows SHOP4 as either true or false     )
  43. # "Shop5"    => true/false,       (Shows SHOP5 as either true or false     )
  44. # "Shop6"    => true/false,       (Shows SHOP6 as either true or false     )
  45. # "Shop7"    => true/false        (Shows SHOP7 as either true or false     )
  46. #=========================================================================
  47. # Map_Info[0]                                  
  48. #=========================================================================
  49. Map_Info[0] =
  50.    {
  51.    "Name"     => 'Home Village',
  52.    "Switch"   => 1,
  53.    "Position" => [206, 315],
  54.    "Icon"     => 'MapMarker',
  55.    "Desc"     => 'This is your hometown.',
  56.    "Desc2"    => 'Nothing cool ever happens here.',
  57.    "Shop1"    => true,                 # Inn
  58.    "Shop2"    => true,                 # Item Shop
  59.    "Shop3"    => true,                 # Weapons Shop
  60.    "Shop4"    => true,                 # Armor Shop
  61.    "Shop5"    => true,                 # Accessories Shop
  62.    "Shop6"    => false,                # Magic Shop
  63.    "Shop7"    => false                 # Synthesis Shop
  64.    }
  65. #=========================================================================
  66. # Map_Info[1]                                  
  67. #=========================================================================  
  68. Map_Info[1] =
  69.    {
  70.    "Name"     => 'Training Cave',
  71.    "Switch"   => 1,
  72.    "Position" => [220, 323],
  73.    "Icon"     => 'MapMarker',
  74.    "Desc"     => 'This is where everyone goes to train.',
  75.    "Desc2"    => 'It\'s full of weak slimes.',
  76.    "Shop1"    => false,                # Inn
  77.    "Shop2"    => false,                # Item Shop
  78.    "Shop3"    => false,                # Weapons Shop
  79.    "Shop4"    => false,                # Armor Shop
  80.    "Shop5"    => false,                # Accessories Shop
  81.    "Shop6"    => false,                # Magic Shop
  82.    "Shop7"    => false                 # Synthesis Shop
  83.    }
  84. #===========================================================================
  85. # End of script
  86. #===========================================================================
  87. end
  88. #===========================================================================
  89. # Cache Module
  90. #===========================================================================
  91. module Cache
  92.   #--------------------------------------------------------------------------
  93.   # * Cache
  94.   #--------------------------------------------------------------------------
  95.   def self.world_map(filename)
  96.     load_bitmap("Graphics/World Map/", filename)
  97.   end
  98. end
  99.  
  100. #==============================================================================
  101. # ** Scene_Templeton_Map
  102. #==============================================================================
  103. class Scene_Templeton_Map < Scene_ItemBase
  104.   #--------------------------------------------------------------------------
  105.   # * start
  106.   #--------------------------------------------------------------------------
  107.   def start
  108.     super
  109.     @get_index = 0
  110.     $templeton_map_info = Array.new
  111.     Templeton_Map::Map_Info.each {|map| $templeton_map_info.push(map) if $game_switches[map['Switch']]}
  112.     create_category_window
  113.     create_map_window
  114.     create_shop_window
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * create_category_window
  118.   #--------------------------------------------------------------------------
  119.   def create_category_window
  120.     @help_window = Window_Help_MapT.new
  121.     @help_window.viewport = @viewport
  122.     @category_window = Window_MapListT.new
  123.     @category_window.viewport = @viewport
  124.     @category_window.y = @help_window.height
  125.     @help_window.z = @category_window.z = 400
  126.     @category_window.set_handler(:cancel, method(:return_scene))
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # * create_map_window
  130.   #--------------------------------------------------------------------------
  131.   def create_map_window
  132.     @item_window = Window_ShowMapT.new
  133.     @item_window.viewport = @viewport
  134.     @category_window.item_window = @item_window
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * create_shop_window
  138.   #--------------------------------------------------------------------------
  139.   def create_shop_window
  140.     @shop_window = Window_ShowShopsT.new
  141.     @shop_window.viewport = @viewport
  142.     @shop_window.z = 400
  143.     @shop_window.y = @help_window.height + @category_window.height
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # * update
  147.   #--------------------------------------------------------------------------
  148.   def update
  149.     super
  150.     @item_window.refresh(@category_window.index) unless $templeton_map_info == []
  151.     @help_window.refresh(@category_window.index) unless $templeton_map_info == []
  152.     @shop_window.refresh(@category_window.index) unless $templeton_map_info == []
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Category [Confirm]
  156.   #--------------------------------------------------------------------------
  157.   def on_category_ok
  158.     @item_window.activate
  159.     @item_window.select_last
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # * Item [Confirm]
  163.   #--------------------------------------------------------------------------
  164.   def on_item_ok
  165.     $game_party.last_item.object = item
  166.     determine_item
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # * Item [Cancel]
  170.   #--------------------------------------------------------------------------
  171.   def on_item_cancel
  172.     @item_window.unselect
  173.     @category_window.activate
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # * play_se_for_item
  177.   #--------------------------------------------------------------------------
  178.   def play_se_for_item
  179.     Sound.play_use_item
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * use_item
  183.   #--------------------------------------------------------------------------
  184.   def use_item
  185.     super
  186.     @item_window.redraw_current_item
  187.   end
  188.   def terminate
  189.     super
  190.     @shop_window.dispose
  191.     @help_window.dispose
  192.     @item_window.dispose
  193.     @category_window.dispose
  194.   end
  195. end
  196.  
  197. #==============================================================================
  198. # ** Window_MapListT
  199. #==============================================================================
  200. class Window_MapListT < Window_Command
  201. include Templeton_Map
  202.   #--------------------------------------------------------------------------
  203.   # * Public instance variables
  204.   #--------------------------------------------------------------------------
  205.   attr_reader   :item_window
  206.   #--------------------------------------------------------------------------
  207.   # * initialize
  208.   #--------------------------------------------------------------------------
  209.   def initialize
  210.     super(0, 0)
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # * window_width
  214.   #--------------------------------------------------------------------------
  215.   def window_width
  216.     256
  217.   end
  218.   def window_height
  219.     Graphics.height - fitting_height(2) - fitting_height(5)
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # * process_ok
  223.   #--------------------------------------------------------------------------
  224.   def process_ok
  225.     if current_item_enabled?
  226.       Sound.play_ok
  227.       Input.update
  228.       deactivate
  229.       call_ok_handler
  230.     else
  231.       Sound.play_buzzer
  232.     end
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # * col_max
  236.   #--------------------------------------------------------------------------
  237.   def col_max
  238.     return 1
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # * update
  242.   #--------------------------------------------------------------------------
  243.   def update
  244.     super
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # * make_command_list
  248.   #--------------------------------------------------------------------------
  249.   def make_command_list
  250.     for i in 0...$templeton_map_info.length
  251.       command = $templeton_map_info[i]['Name']
  252.       add_command(command, nil)
  253.     end
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # * item_window
  257.   #--------------------------------------------------------------------------
  258.   def item_window=(item_window)
  259.     @item_window = item_window
  260.     update
  261.   end
  262. end
  263.  
  264. #==============================================================================
  265. # ** Window_ShowShopsT
  266. #==============================================================================
  267. class Window_ShowShopsT < Window_Base
  268. include Templeton_Map
  269.   #--------------------------------------------------------------------------
  270.   # * Object initialization
  271.   #--------------------------------------------------------------------------
  272.   def initialize
  273.     super(0, 0, window_width, window_height)
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # * window_width
  277.   #--------------------------------------------------------------------------
  278.   def window_width
  279.     256
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # * window_height
  283.   #--------------------------------------------------------------------------
  284.   def window_height
  285.     Graphics.height - 272
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # * disabled_color
  289.   #--------------------------------------------------------------------------
  290.   def disabled_color
  291.       text_color(7)
  292.     end
  293.   #--------------------------------------------------------------------------
  294.   # * refresh
  295.   #--------------------------------------------------------------------------
  296.   def refresh(index)
  297.     unless index == nil
  298.       self.contents.clear
  299.       change_color(system_color)
  300.       draw_text(0, 24 * 0, Graphics.width, 24, MAPVOCAB::SHOP_TITLE, 0)
  301.       change_color(normal_color)
  302.     if $templeton_map_info[index]['Shop1'] == true
  303.       change_color(normal_color)
  304.       draw_text(0, 24 * 1, window_width - 24, 24, MAPVOCAB::SHOP1_NAME, 0)
  305.     else
  306.       change_color(disabled_color)
  307.       draw_text(0, 24 * 1, window_width - 24, 24, MAPVOCAB::SHOP1_NAME, 0)
  308.     end
  309.     if $templeton_map_info[index]['Shop2'] == true
  310.       change_color(normal_color)
  311.       draw_text(window_width / 2, 24 * 1, window_width - 24, 24, MAPVOCAB::SHOP2_NAME, 0)
  312.     else
  313.       change_color(disabled_color)
  314.       draw_text(window_width / 2, 24 * 1, window_width - 24, 24, MAPVOCAB::SHOP2_NAME, 0)
  315.     end
  316.     if $templeton_map_info[index]['Shop3'] == true
  317.       change_color(normal_color)
  318.       draw_text(0, 24 * 2, window_width - 24, 24, MAPVOCAB::SHOP3_NAME, 0)
  319.     else
  320.       change_color(disabled_color)
  321.       draw_text(0, 24 * 2, window_width - 24, 24, MAPVOCAB::SHOP3_NAME, 0)
  322.     end
  323.     if $templeton_map_info[index]['Shop4'] == true
  324.       change_color(normal_color)
  325.       draw_text(window_width / 2, 24 * 2, window_width - 24, 24, MAPVOCAB::SHOP4_NAME, 0)
  326.     else
  327.       change_color(disabled_color)
  328.       draw_text(window_width / 2, 24 * 2, window_width - 24, 24, MAPVOCAB::SHOP4_NAME, 0)
  329.     end
  330.     if $templeton_map_info[index]['Shop5'] == true
  331.       change_color(normal_color)
  332.       draw_text(0, 24 * 3, window_width - 24, 24, MAPVOCAB::SHOP5_NAME, 0)
  333.     else
  334.       change_color(disabled_color)
  335.       draw_text(0, 24 * 3, window_width - 24, 24, MAPVOCAB::SHOP5_NAME, 0)
  336.     end
  337.     if $templeton_map_info[index]['Shop6'] == true
  338.       change_color(normal_color)
  339.       draw_text(window_width / 2, 24 * 3, window_width - 24, 24, MAPVOCAB::SHOP6_NAME, 0)
  340.     else
  341.       change_color(disabled_color)
  342.       draw_text(window_width / 2, 24 * 3, window_width - 24, 24, MAPVOCAB::SHOP6_NAME, 0)
  343.     end
  344.     if $templeton_map_info[index]['Shop7'] == true
  345.       change_color(normal_color)
  346.       draw_text(0, 24 * 4, window_width - 24, 24, MAPVOCAB::SHOP7_NAME, 0)
  347.     else
  348.       change_color(disabled_color)
  349.       draw_text(0, 24 * 4, window_width - 24, 24, MAPVOCAB::SHOP7_NAME, 0)
  350.     end
  351.     end
  352.   end
  353. end
  354. #==============================================================================
  355. # ** Window_ShowMapT
  356. #==============================================================================
  357. class Window_ShowMapT < Window_Base
  358. include Templeton_Map
  359.   #--------------------------------------------------------------------------
  360.   # * Object initialization
  361.   #--------------------------------------------------------------------------
  362.   def initialize
  363.     super(256, fitting_height(2) - 12, window_width, window_height)
  364.     self.opacity = 0
  365.     @x = 0
  366.     @y = 0
  367.     @nx = 0
  368.     @ny = 0
  369.     @cursor = Sprite.new
  370.     @cursor.bitmap = Cache.world_map(Map_Cursor)
  371.     @icon = Sprite.new
  372.     @icon.z = 201
  373.     @cursor.z = 200
  374.     @bitmap = Cache.world_map(Map_Name)
  375.     refresh(0) unless $templeton_map_info == []
  376.   end
  377.   def draw_horz_line(y)
  378.     line_y = y + line_height / 2 - 1
  379.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # * window_width
  383.   #--------------------------------------------------------------------------
  384.   def window_width
  385.     Graphics.width - 256
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * window_height
  389.   #--------------------------------------------------------------------------
  390.   def window_height
  391.     Graphics.height - fitting_height(2) + 24
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * line_color
  395.   #--------------------------------------------------------------------------
  396.   def line_color
  397.     color = normal_color
  398.     color.alpha = 48
  399.     color
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # * refresh
  403.   #--------------------------------------------------------------------------
  404.   def refresh(index)
  405.     self.contents.clear
  406.     @x += 10 if @x <= $templeton_map_info[index]['Position'][0] - window_width/2
  407.     @x -= 10 if @x >= $templeton_map_info[index]['Position'][0] - window_width/2
  408.     @y += 10 if @y <= $templeton_map_info[index]['Position'][1] - window_height/2
  409.     @y -= 10 if @y >= $templeton_map_info[index]['Position'][1] - window_height/2
  410.     @cursor.x = @x + 126 + Cursor_X - @nx + window_width/2
  411.     @cursor.y = @y + fitting_height(2) + 24 + Cursor_Y - @ny + window_height/2
  412.     unless @index == index
  413.       @index = index
  414.       @icon.bitmap = Cache.world_map($templeton_map_info[index]['Icon'])
  415.     end
  416.       @icon.x = $templeton_map_info[index]['Position'][0] + 160 - @nx
  417.       @icon.y = $templeton_map_info[index]['Position'][1] + 80 - @ny
  418.     if @x > @bitmap.width + 24 - window_width
  419.       @nx = @bitmap.width + 24 - window_width
  420.     elsif @x < 0
  421.       @nx = 0
  422.     else
  423.       @nx = @x
  424.     end
  425.     if @y > @bitmap.height + 24 - window_height
  426.       @ny = @bitmap.height + 24 - window_height
  427.     elsif @y < 0
  428.       @ny = 0
  429.     else
  430.       @ny = @y
  431.     end
  432.     rect = Rect.new(@nx, @ny, self.width , self.height)
  433.     contents.blt(0, 0, @bitmap, rect)
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # * dispose
  437.   #--------------------------------------------------------------------------
  438.   def dispose
  439.     super
  440.     @icon.bitmap.dispose
  441.     @icon.dispose
  442.     @cursor.bitmap.dispose
  443.     @cursor.dispose
  444.   end
  445. end
  446. #==============================================================================
  447. # ** Window_Help_MapT
  448. #==============================================================================
  449. class Window_Help_MapT < Window_Base
  450. include Templeton_Map
  451.   #--------------------------------------------------------------------------
  452.   # * Object initialization
  453.   #--------------------------------------------------------------------------
  454.   def initialize
  455.     super(0, 0, Graphics.width, fitting_height(2))
  456.     refresh(nil)
  457.   end
  458.   #--------------------------------------------------------------------------
  459.   # * refresh
  460.   #--------------------------------------------------------------------------
  461.   def refresh(index)
  462.     unless index == nil
  463.       self.contents.clear
  464.       draw_text(0, -12, Graphics.width, fitting_height(1), $templeton_map_info[index]['Desc'],  0)
  465.       draw_text(0,  12, Graphics.width, fitting_height(1), $templeton_map_info[index]['Desc2'], 0)
  466.     end
  467.   end
  468. #==============================================================================
  469. end # of script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement