Advertisement
thiago_d_d

Clone Events

Jan 15th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.46 KB | None | 0 0
  1. #================================================================
  2. # http://thiagodd.blogspot.com.br/
  3. # [TSDA] Clone Events
  4. #   --> Version 1.1
  5. # by thiago_d_D
  6. #----------------------------------------------------------------
  7. # * Features
  8. #----------------------------------------------------------------
  9. # Adds an method to clone events.
  10. #----------------------------------------------------------------
  11. # * How to use.
  12. #----------------------------------------------------------------
  13. # Paste this script in the aditional scripts section
  14. # Any old saves will not be compatible with this script, delete them
  15. #
  16. # To clone an event, run this script code
  17. #
  18. # clone_event(a,b,c,d,e)
  19. #
  20. # a - put here the map id where the event to be cloned is.
  21. # b - the id of the event that will be cloned
  22. # c - x position of the new event
  23. # d - y position of the new event
  24. # e - the map id where the new event will be
  25. #
  26. # [for scripters] the above method returns the newly created event
  27. #================================================================
  28. def clone_event(or_map_id,or_event_id,
  29.   target_x,target_y,target_map_id)
  30.   $game_map.add_event(or_map_id,or_event_id,target_x,
  31.   target_y,target_map_id)
  32. end
  33. #----------------------------------------------------------------
  34. class Game_Map
  35.   def add_event(or_id,or_id2,x, y, map_id)
  36.     if $game_maps_c.has_key?(or_id)
  37.       or_map = $game_maps_c[or_id]
  38.     else
  39.       or_map = load_data(sprintf("Data/Map%03d.rvdata", or_id))
  40.     end
  41.     or_map = load_data(sprintf("Data/Map%03d.rvdata", or_id))
  42.     or_event = or_map.events[or_id2]
  43.     if $game_maps_c.has_key?(map_id)
  44.       target_map = $game_maps_c[map_id]
  45.     else
  46.       target_map = load_data(sprintf("Data/Map%03d.rvdata", map_id))
  47.     end
  48.     event = RPG::Event.new(x,y)
  49.     event.id = target_map.events.size + 1
  50.     event.name = or_event.name
  51.     event.pages = or_event.pages
  52.     target_map.events[target_map.events.size + 1] = event
  53.     $game_maps_c[map_id] = target_map
  54.     if map_id == @map_id
  55.       @map = $game_maps_c[@map_id]
  56.       @events[@events.size + 1] = Game_Event.new(@map_id, event)
  57.       @events.size
  58.     end
  59.     $scene.refresh_spriteset
  60.     return event
  61.   end
  62.   #--------------------------------------------------------------
  63.   alias sfh_th_setup_events setup
  64.   def setup(map_id)
  65.     if $game_maps_c.has_key?(map_id)
  66.       @map_id = map_id
  67.       @map = $game_maps_c[map_id]
  68.       @display_x = 0
  69.       @display_y = 0
  70.       @passages = $data_system.passages
  71.       referesh_vehicles
  72.       setup_events
  73.       setup_scroll
  74.       setup_parallax
  75.       @need_refresh = false
  76.       return
  77.     end
  78.     sfh_th_setup_events(map_id)
  79.   end
  80. end
  81. #----------------------------------------------------------------
  82. class Scene_File
  83.   alias sfh_th_write_save_data write_save_data
  84.   def write_save_data(file)
  85.     sfh_th_write_save_data(file)
  86.     Marshal.dump($game_maps_c,         file)
  87.   end
  88.   #--------------------------------------------------------------
  89.   alias sfh_th_read_save_data read_save_data
  90.   def read_save_data(file)
  91.     sfh_th_read_save_data(file)
  92.     $game_maps_c        = Marshal.load(file)
  93.   end
  94. end
  95. class Scene_Title
  96.   alias sfh_th_create_game_objects create_game_objects
  97.   def create_game_objects
  98.     sfh_th_create_game_objects
  99.     $game_maps_c = {}
  100.   end
  101. end
  102. #----------------------------------------------------------------
  103. class Scene_Map
  104.   def refresh_spriteset
  105.     @spriteset.dispose
  106.     @spriteset = Spriteset_Map.new
  107.   end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement