Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.83 KB | None | 0 0
  1. #===============================================================================
  2. # Move Events
  3. # By Jet10985 (Jet)
  4. # Inspired by: Ezaxess
  5. #===============================================================================
  6. # This snippet will allow you to move an event completely from one map
  7. # to the other. This means they are eliminated from the original map and
  8. # recreated in the new map.
  9. # This script has: 0 customization options.
  10. #===============================================================================
  11. # Overwritten Methods:
  12. # Game_Map: setup
  13. #-------------------------------------------------------------------------------
  14. # Aliased methods:
  15. # Scene_Title: load_database
  16. # Scene_File: write_save_data, read_save_data
  17. #===============================================================================
  18. =begin
  19. To move an event:
  20.  
  21. Use this in an event's "Script..." command:
  22.  
  23. move_event(map_id, new_map_id, ev_id, x, y)
  24.  
  25. map_id = the location of the event you want to move
  26. new_map_id = the location you want to move the event
  27. ev_id = the event id you want to move. Use 0 to specify the calling event
  28. x = the x-coordinate to move the event to
  29. y = the y-coordinate to move the event to
  30. =end
  31.  
  32. class Game_Interpreter
  33.  
  34.   def move_event(map_id, new_map_id, ev_id, x, y)
  35.     if ev_id == 0
  36.       event = get_character(0).event
  37.       $data_maps[sprintf("%03d",$game_map.map_id)].events.delete(event.id)
  38.       f = get_character(0)
  39.       $game_map.events.each_pair {|k, v|
  40.         if v == f
  41.           $game_map.events.delete(k)
  42.         end
  43.       }
  44.       $scene.spriteset.character_sprites.each {|h|
  45.         if h.character == f
  46.           $scene.spriteset.character_sprites.delete(h)
  47.           h.dispose
  48.           h = nil
  49.         end
  50.       }
  51.     else
  52.       event = $data_maps[sprintf("%03d", map_id)].events[ev_id]
  53.       $data_maps[sprintf("%03d", map_id)].events.delete(ev_id)
  54.     end
  55.     event.x, event.y = x, y
  56.     q = $data_maps[sprintf("%03d", new_map_id)].events
  57.     i = 1
  58.     until q[i].nil?
  59.       i += 1
  60.     end
  61.     q[i] = event
  62.     event.id = i
  63.     if $game_map.map_id == new_map_id
  64.       game_ev = Game_Event.new(new_map_id, event)
  65.       $game_map.events[q.size + 2] = game_ev
  66.       sprites = $scene.spriteset.character_sprites
  67.       sprites.push(Sprite_Character.new(nil, game_ev))
  68.       sprites[-1].viewport = sprites[0].viewport
  69.     end
  70.   end
  71.  
  72.   alias jet2734_command_end command_end unless $@
  73.   def command_end(*args, &block)
  74.     @list = nil
  75.     jet2734_command_end(*args, &block) unless $game_map.events[@event_id].nil?
  76.   end
  77. end
  78.  
  79. class Scene_Map
  80.  
  81.   attr_accessor :spriteset
  82.  
  83. end
  84.  
  85. class Spriteset_map
  86.  
  87.   attr_accessor :character_sprites
  88.  
  89. end
  90.  
  91. class Game_Event
  92.  
  93.   attr_reader :event
  94.  
  95. end
  96.  
  97. class Scene_Title
  98.  
  99.   alias jet3745_load_database load_database unless $@
  100.   def load_database(*args, &block)
  101.     jet3745_load_database(*args, &block)
  102.     $data_maps = {}
  103.     999.times {|i|
  104.       id  = sprintf("%03d", i)
  105.       data = "Data/Map#{id}.rvdata"
  106.       begin
  107.         data = load_data(data)
  108.         $data_maps[id] = data
  109.       rescue
  110.         next
  111.       end
  112.     }
  113.   end
  114. end
  115.  
  116. class Game_Map
  117.  
  118.   def setup(map_id)
  119.     @map_id = map_id
  120.     @map = $data_maps[sprintf("%03d", @map_id)]
  121.     @display_x = 0
  122.     @display_y = 0
  123.     @passages = $data_system.passages
  124.     referesh_vehicles
  125.     setup_events
  126.     setup_scroll
  127.     setup_parallax
  128.     @need_refresh = false
  129.   end
  130. end
  131.  
  132. class Scene_File
  133.  
  134.   alias jet3734_write_save_data write_save_data unless $@
  135.   def write_save_data(*args, &block)
  136.     jet3734_write_save_data(*args, &block)
  137.     Marshal.dump($data_maps, args[0])
  138.   end
  139.  
  140.   alias jet3743_read_save_data read_save_data unless $@
  141.   def read_save_data(*args, &block)
  142.     jet3743_read_save_data(*args, &block)
  143.     $data_maps = Marshal.load(args[0])
  144.   end
  145. end
Add Comment
Please, Sign In to add comment