Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Move Events
- # By Jet10985 (Jet)
- # Inspired by: Ezaxess
- #===============================================================================
- # This snippet will allow you to move an event completely from one map
- # to the other. This means they are eliminated from the original map and
- # recreated in the new map.
- # This script has: 0 customization options.
- #===============================================================================
- # Overwritten Methods:
- # Game_Map: setup
- #-------------------------------------------------------------------------------
- # Aliased methods:
- # Scene_Title: load_database
- # Scene_File: write_save_data, read_save_data
- #===============================================================================
- =begin
- To move an event:
- Use this in an event's "Script..." command:
- move_event(map_id, new_map_id, ev_id, x, y)
- map_id = the location of the event you want to move
- new_map_id = the location you want to move the event
- ev_id = the event id you want to move. Use 0 to specify the calling event
- x = the x-coordinate to move the event to
- y = the y-coordinate to move the event to
- =end
- class Game_Interpreter
- def move_event(map_id, new_map_id, ev_id, x, y)
- if ev_id == 0
- event = get_character(0).event
- $data_maps[sprintf("%03d",$game_map.map_id)].events.delete(event.id)
- f = get_character(0)
- $game_map.events.each_pair {|k, v|
- if v == f
- $game_map.events.delete(k)
- end
- }
- $scene.spriteset.character_sprites.each {|h|
- if h.character == f
- $scene.spriteset.character_sprites.delete(h)
- h.dispose
- h = nil
- end
- }
- else
- event = $data_maps[sprintf("%03d", map_id)].events[ev_id]
- $data_maps[sprintf("%03d", map_id)].events.delete(ev_id)
- end
- event.x, event.y = x, y
- q = $data_maps[sprintf("%03d", new_map_id)].events
- i = 1
- until q[i].nil?
- i += 1
- end
- q[i] = event
- event.id = i
- if $game_map.map_id == new_map_id
- game_ev = Game_Event.new(new_map_id, event)
- $game_map.events[q.size + 2] = game_ev
- sprites = $scene.spriteset.character_sprites
- sprites.push(Sprite_Character.new(nil, game_ev))
- sprites[-1].viewport = sprites[0].viewport
- end
- end
- alias jet2734_command_end command_end unless $@
- def command_end(*args, &block)
- @list = nil
- jet2734_command_end(*args, &block) unless $game_map.events[@event_id].nil?
- end
- end
- class Scene_Map
- attr_accessor :spriteset
- end
- class Spriteset_map
- attr_accessor :character_sprites
- end
- class Game_Event
- attr_reader :event
- end
- class Scene_Title
- alias jet3745_load_database load_database unless $@
- def load_database(*args, &block)
- jet3745_load_database(*args, &block)
- $data_maps = {}
- 999.times {|i|
- id = sprintf("%03d", i)
- data = "Data/Map#{id}.rvdata"
- begin
- data = load_data(data)
- $data_maps[id] = data
- rescue
- next
- end
- }
- end
- end
- class Game_Map
- def setup(map_id)
- @map_id = map_id
- @map = $data_maps[sprintf("%03d", @map_id)]
- @display_x = 0
- @display_y = 0
- @passages = $data_system.passages
- referesh_vehicles
- setup_events
- setup_scroll
- setup_parallax
- @need_refresh = false
- end
- end
- class Scene_File
- alias jet3734_write_save_data write_save_data unless $@
- def write_save_data(*args, &block)
- jet3734_write_save_data(*args, &block)
- Marshal.dump($data_maps, args[0])
- end
- alias jet3743_read_save_data read_save_data unless $@
- def read_save_data(*args, &block)
- jet3743_read_save_data(*args, &block)
- $data_maps = Marshal.load(args[0])
- end
- end
Add Comment
Please, Sign In to add comment