Advertisement
neutale

LoZ - single-screen maps transition (640x360)

Dec 26th, 2019
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.07 KB | None | 0 0
  1. # by Ben Hendel-Doying
  2. #
  3. # the following scripts are for RPG Maker VX Ace
  4. #
  5. # they allow for the automatic movement of the party between maps simply by walking
  6. # to the edge, without the need to create ANY events on any map.
  7. #
  8. # BUT: it's required that all maps be only one screen in size. (it should be easy
  9. # to remove this limitation, though I have not tried it.)
  10. #
  11. # think "Legend of Zelda" for the NES.
  12. #
  13. # a "note tag" must be added to each map, telling that map which maps to link to,
  14. # in the north, east, south, and west directions. the note tag takes this form:
  15. #
  16. #   <dir: NORTH EAST SOUTH WEST>
  17. #
  18. # where NORTH, EAST, SOUTH, and WEST should be replaced with the IDs of the maps
  19. # to link to, or 0 if no automatic linking is desired. (leave out the note tag
  20. # entirely for no automatic linking at all.)
  21. #
  22. # for example, here are the IDs and note tags of 6 hypothetical maps, arranged in
  23. # a 3x2 grid:
  24. #
  25. #   +----------------+----------------+----------------+
  26. #   |    MAP ID 1    |    MAP ID 2    |    MAP ID 3    |
  27. #   |                |                |                |
  28. #   | <dir: 0 2 4 0> | <dir: 0 3 5 1> | <dir: 0 0 6 2> |
  29. #   +----------------+----------------+----------------+
  30. #   |    MAP ID 4    |    MAP ID 5    |    MAP ID 6    |
  31. #   |                |                |                |
  32. #   | <dir: 1 5 0 0> | <dir: 2 6 0 4> | <dir: 3 0 0 5> |
  33. #   +----------------+----------------+----------------+
  34. #
  35. # these scripts assume you are happy with a window size of 640x360, and maps of
  36. # 22x13. (this is also changeable, with a little math and some tweaks to the
  37. # code.)
  38. #
  39. # to see it all in action, along with a full explanation of the code, check out
  40. # my YouTube video at: https://youtu.be/Qj3wQSLuS3w
  41.  
  42. ### RIGHTS/COPYRIGHT INFORMATION
  43.  
  44. # I, the author, release all rights to the following code, as is, to the public
  45. # domain; no rights reserved; use it freely, without limitation, and at your own
  46. # risk.
  47.  
  48. ### FINALLY
  49.  
  50. # please check out my non-RPG Maker VX Ace game, "Mysterious Space"; available on
  51. # Steam for $5 :) profits are donated to awesome causes, like space exploration.
  52.  
  53. ### ON TO THE CODE: add the following in "Main", under "Main Process"
  54.  
  55. # SETS SCREEN SIZE TO 640x360 (16:9 widescreen resolution; half 720p... 360p?)
  56. # the outer edge of tiles will be just off-screen (again, assuming 22x13 maps)
  57. Graphics.resize_screen(640, 360)
  58.  
  59. ### add the following to a new script, under "Materials"
  60.  
  61. # PREVENTS SCROLLING - ALL MAPS TAKE UP ONE SCREEN
  62. # simply removing this whole "class" block should be enough to restore normal
  63. # scrolling behavior. allowing maps of any size will require additional tweaks,
  64. # however. (see below.)
  65. class Game_Map
  66.   def set_display_pos(x, y)
  67.     @display_x = 1         # the left-most column of every map is hidden
  68.     @display_y = 1 - 0.125 # the top-most row of every map is hidden, except for a few pixels (due to the 640x360 resolution)
  69.     @parallax_x = 1
  70.     @parallax_y = 1 - 0.125
  71.   end
  72.  
  73.   # override built-in scroll methods, making them empty (prevents scrolling)
  74.   def scroll_down(distance)
  75.   end
  76.  
  77.   def scroll_left(distance)
  78.   end
  79.  
  80.   def scroll_right(distance)
  81.   end
  82.  
  83.   def scroll_up(distance)
  84.   end
  85. end
  86.  
  87. # AUTOMATICALLY CAUSE MOVEMENT WHEN THE PLAYER MOVES TO THE EDGE OF A MAP
  88. # assumes all maps are 22x13 tiles; if you want to change this, you'll need to edit
  89. # the following code...
  90. class Game_Player < Game_Character
  91.   def check_event_trigger_here(triggers)
  92.     # do original logic; leave this alone
  93.     start_map_event(@x, @y, triggers, false)
  94.    
  95.     # do EXTRA logic
  96.     if(x == 0 && $game_map.west.to_i != 0)
  97.       $game_temp.fade_type = 2
  98.       $game_player.reserve_transfer($game_map.west.to_i, 20, y, 0) # 20 = map width - 2
  99.     elsif(x == 21 && $game_map.east.to_i != 0) # 21 = map width - 1 (0 is the 1st column, so 21 is the 22nd column)
  100.       $game_temp.fade_type = 2
  101.       $game_player.reserve_transfer($game_map.east.to_i, 1, y, 0) # 1 = 1
  102.     elsif(y == 0 && $game_map.north.to_i != 0)
  103.       $game_temp.fade_type = 2
  104.       $game_player.reserve_transfer($game_map.north.to_i, x, 11, 0) # 11 = map height - 2
  105.     elsif(y == 12 && $game_map.south.to_i != 0) # 12 = map width - 1 (0 is the 1st row, so 12 is the 13th row)
  106.       $game_temp.fade_type = 2
  107.       $game_player.reserve_transfer($game_map.south.to_i, x, 1, 0) # 1 = 1
  108.     end
  109.   end
  110. end
  111.  
  112. # GET MAP IDS FROM NOTE TAG (there's probably no reason to change this)
  113. class Game_Map
  114.   def north
  115.     load_notetag_coordinates
  116.     return @north
  117.   end
  118.  
  119.   def east
  120.     load_notetag_coordinates
  121.     return @east
  122.   end
  123.  
  124.   def south
  125.     load_notetag_coordinates
  126.     return @south
  127.   end
  128.  
  129.   def west
  130.     load_notetag_coordinates
  131.     return @west
  132.   end
  133.  
  134.   def load_notetag_coordinates
  135.     regex = /<dir:\s*([0-9]+)\s*([0-9]+)\s*([0-9]+)\s*([0-9]+)\s*>/i
  136.     result = @map.note.match(regex)
  137.    
  138.     if result
  139.       @north = result[1]
  140.       @east = result[2]
  141.       @south = result[3]
  142.       @west = result[4]
  143.     else
  144.       @north = 0
  145.       @east = 0
  146.       @south = 0
  147.       @west = 0
  148.     end
  149.   end
  150. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement