ezmash

Passage Modding (setup) (VX Ace)

Sep 11th, 2013
459
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #========================================================================
  2. # Passage Modding (setup)
  3. # Version 1.0 (2013.09.12)
  4. #========================================================================
  5. # Author: Shaz
  6. #------------------------------------------------------------------------
  7. # This script lets you override passage settings on individual tiles and
  8. # ignore the tileset defaults.
  9. # This is a DEVELOPMENT-ONLY script, and should be removed prior to
  10. # releasing the game.  On release, use the corresponding (runtime) script.
  11. #------------------------------------------------------------------------
  12. # Changelog:
  13. # 2013.09.12  v1.0  Initial release
  14. #------------------------------------------------------------------------
  15. # To install:
  16. # Install into Materials section in your project's script editor below
  17. # all other scripts
  18. #------------------------------------------------------------------------
  19. # To use:
  20. # Turn on the console prior to testing your game
  21. # Switch into Passage Modding Mode (press P)
  22. # Use the following keys to make changes to passages:
  23. # - P: Toggle passage modding on/off
  24. # - X: Make the tile under the mouse impassable
  25. # - O: Make the tile under the mouse passable
  26. # - Click mouse: Toggle the passability of the 4-dir icon clicked on
  27. # - C: Toggle icon color for dark/light backgrounds
  28. # - R: Reset passages to last-saved (for current map only)
  29. # - M: Reset passages to map/tileset defaults (for current map only)
  30. # - S: Save passage settings (for ALL maps)
  31. # - H: Print these instructions to the console
  32. # Use your arrow keys to move your character around and scroll the map
  33. # REMEMBER TO SAVE YOUR WORK WHILE IN PASSAGE MODDING MODE!
  34. #------------------------------------------------------------------------
  35. # Compatibility:
  36. # This script may have compatibility issues with other scripts that:
  37. # - modify the Game_Map.check_passage method
  38. # - modify player movement and collision
  39. # - modify the map during runtime (such as tile swapping scripts)
  40. #------------------------------------------------------------------------
  41. # Terms:
  42. # Free for commercial and non-commercial use (though this is a tool
  43. # and should be removed prior to release)
  44. #========================================================================
  45.  
  46. CheckKeyState = Win32API.new('user32', 'GetKeyState', 'i', 'i')
  47. #============================================================================
  48. # MOUSE SCRIPT
  49. # by SephirothSpawn and Near Fantastica (used in setup script only)
  50. #============================================================================
  51. module PMMouse
  52.   #--------------------------------------------------------------------------
  53.   # * Mouse to Input Triggers
  54.   #   key => Input::KeyCONSTANT (key: 0 - left, 1 - middle, 2 - right)
  55.   #--------------------------------------------------------------------------
  56.   Mouse_to_Input_Triggers = {0 => Input::C, 1 => Input::B, 2 => Input::A}
  57.   #--------------------------------------------------------------------------
  58.   # * API Declarations
  59.   #--------------------------------------------------------------------------
  60.   GAKS = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  61.   GSM = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
  62.   Cursor_Pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  63.   Scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  64.   Client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
  65.   Findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
  66.   Readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  67.   ShowCursor = Win32API.new('user32', 'ShowCursor', 'i', 'l')
  68.   #--------------------------------------------------------------------------
  69.   # * Module Variables
  70.   #--------------------------------------------------------------------------
  71.   @triggers = [[0, 1], [0, 2], [0, 4]]
  72.   @old_pos = 0
  73.   @pos_i = 0
  74.   #--------------------------------------------------------------------------
  75.   # * Mouse Grid Position
  76.   #--------------------------------------------------------------------------
  77.   def self.grid
  78.     return nil if pos.nil?
  79.     mx, my = $game_map.tilemap_offset
  80.     x = (pos[0] + mx) / 32
  81.     y = (pos[1] + my) / 32
  82.     return [x, y]
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Mouse Position
  86.   #--------------------------------------------------------------------------
  87.   def self.position
  88.     return @pos.nil? ? [0, 0] : @pos
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Mouse Global Position
  92.   #--------------------------------------------------------------------------
  93.   def self.global_pos
  94.     pos = [0, 0].pack('ll')
  95.     return Cursor_Pos.call(pos) == 0 ? nil : pos.unpack('ll')
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Screen to Client
  99.   #--------------------------------------------------------------------------
  100.   def self.screen_to_client(x=0, y=0)
  101.     pos = [x, y].pack('ll')
  102.     return Scr2cli.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # * Mouse Position
  106.   #--------------------------------------------------------------------------
  107.   def self.pos
  108.     gx, gy = global_pos
  109.     x, y = screen_to_client(gx, gy)
  110.    
  111.     # Test boundaries
  112.     begin
  113.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  114.         return x, y
  115.       else
  116.         return -20, -20
  117.       end
  118.     rescue
  119.       return 0, 0
  120.     end
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # * Update Mouse Position
  124.   #--------------------------------------------------------------------------
  125.   def self.update
  126.     # Update Triggers
  127.     for i in @triggers
  128.       n = GAKS.call(i[1])
  129.       if [0, 1].include?(n)
  130.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  131.       else
  132.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  133.       end
  134.     end
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * Trigger?
  138.   #   id : 0:Left, 1:Right, 2:Center
  139.   #--------------------------------------------------------------------------
  140.   def self.trigger?(id = 0)
  141.     if pos != [-20, -20]
  142.       return @triggers[id][0] == 1
  143.     end
  144.     return false
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Repeat?
  148.   #   id : 0:Left, 1:Right, 2:Center
  149.   #--------------------------------------------------------------------------
  150.   def self.repeat?(id = 0)
  151.     return @triggers[id][0] > 0 && @triggers[id][0] % 5 == 1
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Hwnd
  155.   #--------------------------------------------------------------------------
  156.   def self.hwnd
  157.     if @hwnd.nil?
  158.       title = "\0" * 256
  159.       Readini.call('Game', 'Title', '', title, 255, '.\\Game.ini')
  160.       title.delete!("\0")
  161.       @hwnd = Findwindow.call('RGSS Player', title)
  162.     end
  163.     return @hwnd
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # * Client Size
  167.   #--------------------------------------------------------------------------
  168.   def self.client_size
  169.     rect = [0, 0, 0, 0].pack('l4')
  170.     Client_rect.call(self.hwnd, rect)
  171.     return rect.unpack('l4')[2..3]
  172.   end
  173. end
  174.  
  175. class << Input
  176.   #--------------------------------------------------------------------------
  177.   # * Alias Listings
  178.   #--------------------------------------------------------------------------
  179.   alias :seph_pmmouse_input_update :update
  180.   alias :seph_pmmouse_input_trigger? :trigger?
  181.   alias :seph_pmmouse_input_repeat? :repeat?
  182.   #--------------------------------------------------------------------------
  183.   # * Frame Update
  184.   #--------------------------------------------------------------------------
  185.   def update
  186.     PMMouse.update
  187.     seph_pmmouse_input_update
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # * Trigger? Test
  191.   #--------------------------------------------------------------------------
  192.   def trigger?(constant)
  193.     return true if seph_pmmouse_input_trigger?(constant)
  194.     unless PMMouse.pos.nil?
  195.       if PMMouse::Mouse_to_Input_Triggers.has_value?(constant)
  196.         return true if PMMouse.trigger?(PMMouse::Mouse_to_Input_Triggers.index(constant))
  197.       end
  198.     end
  199.     return false
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # * Repeat? Test
  203.   #--------------------------------------------------------------------------
  204.   def repeat?(constant)
  205.     return true if seph_pmmouse_input_repeat?(constant)
  206.     unless PMMouse.pos.nil?
  207.       if PMMouse::Mouse_to_Input_Triggers.has_value?(constant)
  208.         return true if PMMouse.repeat?(PMMouse::Mouse_to_Input_Triggers.index(constant))
  209.       end
  210.     end
  211.     return false
  212.   end
  213. end
  214.  
  215.  
  216. module DataManager
  217.   class << self
  218.     alias shaz_passage_mod_setup_load_normal_database load_normal_database
  219.   end
  220.  
  221.   def self.load_normal_database
  222.     shaz_passage_mod_setup_load_normal_database
  223.     if File.exists?("Data/Passages.rvdata2")
  224.       $data_passages = load_data("Data/Passages.rvdata2")
  225.     else
  226.       $data_passages = {}
  227.     end
  228.   end
  229. end
  230.  
  231. class Sprite_Passability < Sprite
  232.   # Create sprite for map passability
  233.   def initialize(viewport)
  234.     super(viewport)
  235.     @color = 0
  236.     @passages = $data_passages.clone
  237.     create_icons
  238.     create_bitmap
  239.     self.visible = false
  240.     update
  241.   end
  242.  
  243.   # Create icons for passable / not passable in each direction
  244.   def create_icons
  245.     @rect = Rect.new(0, 0, 32, 32)
  246.    
  247.     @box1 = Bitmap.new(32, 32)
  248.     @box1.fill_rect(0, 0, 32, 32, Color.new(255, 127, 127, 160))
  249.     @box1.clear_rect(1, 1, 30, 30)
  250.    
  251.     @box2 = Bitmap.new(32, 32)
  252.     @box2.fill_rect(0, 0, 32, 32, Color.new(127, 63, 63, 160))
  253.     @box2.clear_rect(1, 1, 30, 30)
  254.    
  255.     @pass2 = Bitmap.new(32, 32)
  256.     @pass2.fill_rect(15, 20, 3, 9, passability_color)
  257.     @pass2.fill_rect(14, 23, 5, 4, passability_color)
  258.     @pass2.fill_rect(13, 23, 7, 3, passability_color)
  259.     @pass2.set_pixel(12, 23, passability_color)
  260.     @pass2.set_pixel(20, 23, passability_color)
  261.     @pass2.set_pixel(16, 29, passability_color)
  262.    
  263.     @block2 = Bitmap.new(32, 32)
  264.     @block2.fill_rect(15, 23, 3, 2, passability_color)
  265.     @block2.set_pixel(16, 22, passability_color)
  266.     @block2.set_pixel(16, 25, passability_color)
  267.    
  268.     @pass4 = Bitmap.new(32, 32)
  269.     @pass4.fill_rect(3, 15, 9, 3, passability_color)
  270.     @pass4.fill_rect(5, 14, 4, 5, passability_color)
  271.     @pass4.fill_rect(6, 13, 3, 7, passability_color)
  272.     @pass4.set_pixel(2, 16, passability_color)
  273.     @pass4.set_pixel(8, 12, passability_color)
  274.     @pass4.set_pixel(8, 20, passability_color)
  275.    
  276.     @block4 = Bitmap.new(32, 32)
  277.     @block4.fill_rect(7, 15, 3, 2, passability_color)
  278.     @block4.set_pixel(8, 14, passability_color)
  279.     @block4.set_pixel(8, 17, passability_color)
  280.    
  281.     @pass6 = Bitmap.new(32, 32)
  282.     @pass6.fill_rect(20, 15, 9, 3, passability_color)
  283.     @pass6.fill_rect(23, 14, 4, 5, passability_color)
  284.     @pass6.fill_rect(23, 13, 3, 7, passability_color)
  285.     @pass6.set_pixel(23, 12, passability_color)
  286.     @pass6.set_pixel(23, 20, passability_color)
  287.     @pass6.set_pixel(29, 16, passability_color)
  288.    
  289.     @block6 = Bitmap.new(32, 32)
  290.     @block6.fill_rect(23, 15, 3, 2, passability_color)
  291.     @block6.set_pixel(24, 14, passability_color)
  292.     @block6.set_pixel(24, 17, passability_color)
  293.    
  294.     @pass8 = Bitmap.new(32, 32)
  295.     @pass8.fill_rect(15, 3, 3, 9, passability_color)
  296.     @pass8.fill_rect(14, 5, 5, 4, passability_color)
  297.     @pass8.fill_rect(13, 6, 7, 3, passability_color)
  298.     @pass8.set_pixel(16, 2, passability_color)
  299.     @pass8.set_pixel(12, 8, passability_color)
  300.     @pass8.set_pixel(20, 8, passability_color)
  301.    
  302.     @block8 = Bitmap.new(32, 32)
  303.     @block8.fill_rect(15, 7, 3, 2, passability_color)
  304.     @block8.set_pixel(16, 6, passability_color)
  305.     @block8.set_pixel(16, 9, passability_color)
  306.   end
  307.    
  308.   def create_bitmap
  309.     load_passages_from_map if !@passages.has_key?($game_map.map_id)
  310.     # Build passability image for current map
  311.     self.bitmap.dispose if self.bitmap
  312.     self.bitmap = Bitmap.new($game_map.width * 32, $game_map.height * 32)
  313.     self.bitmap.font.size = 16
  314.     for tx in 0 ... $game_map.width
  315.       for ty in 0 ... $game_map.height
  316.         draw_passages(tx, ty)
  317.       end
  318.     end
  319.   end
  320.  
  321.   def draw_passages(tx, ty)
  322.     self.bitmap.clear_rect(tx * 32, ty * 32, 32, 32)
  323.     self.bitmap.blt(tx * 32, ty * 32, (tx % 2 + ty % 2 == 1) ? @box1 : @box2, @rect)
  324.     self.bitmap.blt(tx * 32, ty * 32, ovr_passage(tx, ty, 2) ? @pass2 : @block2, @rect)
  325.     self.bitmap.blt(tx * 32, ty * 32, ovr_passage(tx, ty, 4) ? @pass4 : @block4, @rect)
  326.     self.bitmap.blt(tx * 32, ty * 32, ovr_passage(tx, ty, 6) ? @pass6 : @block6, @rect)
  327.     self.bitmap.blt(tx * 32, ty * 32, ovr_passage(tx, ty, 8) ? @pass8 : @block8, @rect)
  328.   end
  329.  
  330.   def ovr_passage(x, y, d)
  331.     bit = (1 << (d / 2 - 1)) & 0x0f
  332.     flag = @passages[$game_map.map_id][x,y]
  333.     pass = flag & bit == 0
  334.     return pass
  335.   end
  336.  
  337.   def dispose
  338.     self.bitmap.dispose if self.bitmap
  339.   end
  340.  
  341.   def passability_color
  342.     [Color.new(255, 255, 255, 160), Color.new(0, 0, 0, 160)][@color]
  343.   end
  344.  
  345.   def refresh
  346.     dispose
  347.     create_bitmap
  348.     update
  349.   end
  350.  
  351.   def update
  352.     super
  353.     update_position
  354.   end
  355.  
  356.   def update_position
  357.     self.ox = $game_map.display_x * 32
  358.     self.oy = $game_map.display_y * 32
  359.   end
  360.  
  361.   def set_passage(passable)
  362.     x, y = *PMMouse.grid
  363.     @passages[$game_map.map_id][x,y] = passable ? 0x00 : 0x0f
  364.     draw_passages(x, y)
  365.   end
  366.  
  367.   def toggle_4dir_passage
  368.     x, y = *PMMouse.grid
  369.     mx, my = *PMMouse.pos
  370.     mx += $game_map.tilemap_offset[0]
  371.     my += $game_map.tilemap_offset[1]
  372.     ox = mx % 32
  373.     oy = my % 32
  374.     dir = (ox - 16).abs > (oy - 16).abs ? (ox < 16 ? 4 : 6) : (oy < 16 ? 8 : 2)
  375.     bit = (1 << (dir / 2 - 1)) & 0x0f
  376.     @passages[$game_map.map_id][x,y] ^= (1 << (dir / 2 - 1))
  377.     draw_passages(x, y)
  378.   end
  379.  
  380.   def toggle_visibility
  381.     self.visible = !self.visible
  382.     if self.visible
  383.       p 'Turning on Passability mode.  Remember to save your work.'
  384.     else
  385.       p 'Turning off Passability mode.'
  386.       p 'If you have made changes, remember to switch modes again and save your work.'
  387.     end
  388.   end
  389.  
  390.   def toggle_color
  391.     @color = 1 - @color
  392.     create_icons
  393.     refresh
  394.     p 'Setting icon color for ' + (@color == 0 ? 'dark' : 'light') + ' background'
  395.   end
  396.  
  397.   def map_source
  398.     load_passages_from_map
  399.     refresh
  400.   end
  401.  
  402.   def reload
  403.     if $data_passages.has_key?($game_map.map_id)
  404.       @passages[$game_map.map_id] = $data_passages[$game_map.map_id].clone
  405.       p 'Loading last-saved passages for this map'
  406.     else
  407.       load_passages_from_map
  408.       p 'Passages not saved for this map'
  409.     end
  410.     refresh
  411.   end
  412.  
  413.   def load_passages_from_map
  414.     p 'Loading default tileset passages for this map'
  415.     @passages[$game_map.map_id] = Table.new($game_map.width, $game_map.height)
  416.     for tx in 0 ... $game_map.width
  417.       for ty in 0 ... $game_map.height
  418.         flag = 0x00
  419.         flag |= 1 if !$game_map.def_passable?(tx, ty, 2)
  420.         flag |= 1 << 1 if !$game_map.def_passable?(tx, ty, 4)
  421.         flag |= 1 << 2 if !$game_map.def_passable?(tx, ty, 6)
  422.         flag |= 1 << 3 if !$game_map.def_passable?(tx, ty, 8)
  423.         @passages[$game_map.map_id][tx,ty] = flag
  424.       end
  425.     end
  426.   end
  427.  
  428.   def save_passages
  429.     $data_passages = @passages.clone
  430.     File.open("Data/Passages.rvdata2", "wb") do |file|
  431.       Marshal.dump($data_passages, file)
  432.     end
  433.     p 'Passages for ALL maps saved'
  434.   end
  435. end
  436.  
  437. class Game_Map
  438.   attr_accessor :tilemap_offset  
  439.   attr_accessor :passage_modding
  440.  
  441.   alias shaz_passage_mod_game_map_initialize initialize
  442.   alias shaz_passage_mod_update_events update_events
  443.  
  444.   def initialize
  445.     shaz_passage_mod_game_map_initialize
  446.     @tilemap_offset = [0, 0]
  447.   end
  448.  
  449.   def def_check_passage(x, y, bit)
  450.     all_tiles(x, y).each do |tile_id|
  451.       flag = tileset.flags[tile_id]
  452.       next if flag & 0x10 != 0            # [☆]: No effect on passage
  453.       return true  if flag & bit == 0     # [○] : Passable
  454.       return false if flag & bit == bit   # [×] : Impassable
  455.     end
  456.     return false                          # Impassable
  457.   end
  458.  
  459.   def def_passable?(x, y, d)
  460.     def_check_passage(x, y, (1 << (d / 2 - 1)) & 0x0f)
  461.   end
  462.  
  463.   def update_events
  464.     shaz_passage_mod_update_events if !@passage_modding
  465.   end
  466. end
  467.  
  468. class Spriteset_Map
  469.   attr_accessor :passability_sprite
  470.   alias shaz_passage_mod_create_viewports create_viewports
  471.   alias shaz_passage_mod_create_tilemap create_tilemap
  472.   alias shaz_passage_mod_update_tilemap update_tilemap
  473.   alias shaz_passage_mod_dispose_tilemap dispose_tilemap
  474.   alias shaz_passage_mod_dispose_viewports dispose_viewports
  475.  
  476.   def create_viewports
  477.     shaz_passage_mod_create_viewports
  478.     @viewport_passage = Viewport.new
  479.     @viewport_passage.z = 150
  480.   end
  481.  
  482.   def create_tilemap
  483.     @passability_sprite = Sprite_Passability.new(@viewport_passage)
  484.     shaz_passage_mod_create_tilemap
  485.   end
  486.  
  487.   def update_tilemap
  488.     shaz_passage_mod_update_tilemap
  489.     @passability_sprite.update
  490.   end
  491.  
  492.   def dispose_tilemap
  493.     shaz_passage_mod_dispose_tilemap
  494.     @passability_sprite.dispose
  495.   end
  496.  
  497.   def dispose_viewports
  498.     shaz_passage_mod_dispose_viewports
  499.     @viewport_passage.dispose
  500.   end
  501.  
  502.   def tilemap_offset
  503.     [@tilemap.ox, @tilemap.oy]
  504.   end
  505. end
  506.  
  507. class Scene_Map < Scene_Base
  508.   alias shaz_passage_mod_start start
  509.   alias shaz_passage_mod_update update
  510.   alias shaz_passage_mod_post_transfer post_transfer
  511.   alias shaz_passage_mod_update_scene update_scene
  512.  
  513.   KEYS = {'P' => [80, 0, :pass_p], # toggle passability modding on/off
  514.           'X' => [88, 0, :pass_x], # set passability to X
  515.           'O' => [79, 0, :pass_o], # set passability to O
  516.           'C' => [67, 0, :pass_c], # toggle passability color light/dark
  517.           'R' => [82, 0, :pass_r], # reset passability to pre-save
  518.           'M' => [77, 0, :pass_m], # reset passability to map defaults
  519.           'S' => [83, 0, :pass_s], # save passability overrides
  520.           'H' => [72, 0, :pass_h]} # help
  521.  
  522.   def update
  523.     if $TEST
  524.       KEYS.each {|key, value|
  525.         press = CheckKeyState.call(value[0])
  526.         if [0,1].include?(press)
  527.           if value[1] != press
  528.             KEYS[key][1] = press
  529.             method(value[2]).call
  530.           end
  531.         end
  532.       }
  533.     end
  534.     mouse_click if PMMouse.trigger?(0) && !PMMouse.grid.nil?
  535.     shaz_passage_mod_update
  536.     $game_map.tilemap_offset = @spriteset.tilemap_offset
  537.   end
  538.  
  539.   def update_scene
  540.     shaz_passage_mod_update_scene if !$game_map.passage_modding
  541.   end
  542.  
  543.   # Toggle passability override on/off
  544.   def pass_p    
  545.     @spriteset.passability_sprite.toggle_visibility
  546.     $game_map.passage_modding = @spriteset.passability_sprite.visible
  547.     if $game_map.passage_modding
  548.       $game_player.through = true
  549.     else
  550.       $game_player.through = false
  551.     end
  552.   end
  553.  
  554.   # Set tile passability to X
  555.   def pass_x    
  556.     return if !$game_map.passage_modding
  557.     @spriteset.passability_sprite.set_passage(false)
  558.   end
  559.  
  560.   # Set tile passability to O
  561.   def pass_o    
  562.     return if !$game_map.passage_modding
  563.     @spriteset.passability_sprite.set_passage(true)
  564.   end
  565.  
  566.   # Process mouse click
  567.   def mouse_click
  568.     return if !$game_map.passage_modding
  569.     @spriteset.passability_sprite.toggle_4dir_passage
  570.   end
  571.  
  572.   # Toggle color of passability icons
  573.   def pass_c    
  574.     return if !$game_map.passage_modding
  575.     @spriteset.passability_sprite.toggle_color
  576.   end
  577.  
  578.   # Reset passability to last-saved
  579.   def pass_r    
  580.     return if !$game_map.passage_modding
  581.     @spriteset.passability_sprite.reload
  582.   end
  583.  
  584.   # Reset passability to map defaults
  585.   def pass_m    
  586.     return if !$game_map.passage_modding
  587.     @spriteset.passability_sprite.map_source
  588.   end
  589.  
  590.   # Save passability changes
  591.   def pass_s
  592.     return if !$game_map.passage_modding
  593.     @spriteset.passability_sprite.save_passages
  594.   end
  595.  
  596.   # Help (print instructions to console)
  597.   def pass_h
  598.     p 'Passing Modding'
  599.     p '---------------'
  600.     p 'P - toggle passage modding on/off'
  601.     p 'X - set tile under mouse to impassable'
  602.     p 'O - set tile under mouse to passable'
  603.     p 'C - toggle color of passability icons'
  604.     p 'R - reset passability map to last saved version'
  605.     p 'M - reset passability map to tileset defaults'
  606.     p 'S - save passage settings'
  607.     p 'H - print these instructions'
  608.     p ''
  609.     p 'To change 4-dir passage settings, click on the'
  610.     p 'icons with the mouse'
  611.     p ''
  612.     p 'Use your arrow keys to move your character'
  613.     p 'and scroll the map'
  614.     p ''
  615.     p 'NOTE - normal event and keyboard functions are'
  616.     p 'disabled during passage modding'
  617.     p ''
  618.     p 'REMEMBER TO SAVE YOUR WORK!'
  619.     p ''
  620.   end
  621.  
  622.   # rebuild passability image on new map
  623.   def post_transfer
  624.     @spriteset.passability_sprite.refresh
  625.     shaz_passage_mod_post_transfer
  626.   end
  627. end
  628.  
  629. class Game_Player < Game_Character
  630.   alias shaz_passage_mod_dash? dash?
  631.   alias shaz_passage_mod_move_by_input move_by_input
  632.   def dash?
  633.     return true if $game_map.passage_modding
  634.     shaz_passage_mod_dash?
  635.   end
  636.  
  637.   def through=(value)
  638.     @through = value
  639.   end
  640.  
  641.   def move_by_input
  642.     if $game_map.passage_modding
  643.       return if !movable? || $game_map.interpreter.running?
  644.       move_straight(Input.dir4) if Input.dir4 > 0
  645.     else
  646.       shaz_passage_mod_move_by_input
  647.     end
  648.   end
  649. end
  650.  
  651. class Game_Event < Game_Character
  652.   alias shaz_passage_mod_start start
  653.   def start
  654.     shaz_passage_mod_start if !$game_map.passage_modding
  655.   end
  656. end
  657.  
  658. # print some instructions
  659. p 'Passing Modding'
  660. p '---------------'
  661. p 'P - toggle passage modding on/off'
  662. p 'X - set tile under mouse to impassable'
  663. p 'O - set tile under mouse to passable'
  664. p 'C - toggle color of passability icons'
  665. p 'R - reset passability map to last saved version'
  666. p 'M - reset passability map to tileset defaults'
  667. p 'S - save passage settings'
  668. p 'H - print these instructions'
  669. p ''
  670. p 'To change 4-dir passage settings, click on the'
  671. p 'icons with the mouse'
  672. p ''
  673. p 'Use your arrow keys to move your character'
  674. p 'and scroll the map'
  675. p ''
  676. p 'NOTE - normal event and keyboard functions are'
  677. p 'disabled during passage modding'
  678. p ''
  679. p 'REMEMBER TO SAVE YOUR WORK!'
  680. p ''
RAW Paste Data