Advertisement
Kakakadafi

Kadafi - Summon Event

Jul 1st, 2015
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.62 KB | None | 0 0
  1. #=============================================================================
  2. # Kadafi - Summon Event
  3. # Version : 1.0
  4. # Contact : http://forums.rpgmakerweb.com/index.php?/user/33654-kadafi/
  5. # =============================================================================
  6. ($imported ||= {})[:Kadafi_SummonEvent] = true
  7. # =============================================================================
  8. # CHANGE LOGS:
  9. # -----------------------------------------------------------------------------
  10. # 2015.07.02 - Finished script
  11. # =============================================================================
  12. =begin
  13.  
  14.   Introduction :
  15.   This script allow you to summon event from the spesific map to the current map.
  16.  
  17.   How to Use :
  18.   Script Call: summon_event(map_id, event_id, x, y)
  19.  
  20.   Terms of Use :
  21.   Credit me as Kadafi. You are allowed to edit this script as long as you
  22.   don't claim it yours.
  23.  
  24. =end
  25. # =============================================================================
  26. # Don't edit below this line unless you know what to do.
  27. # =============================================================================
  28. class Game_Map
  29.   #--------------------------------------------------------------------------
  30.   # * Add Event
  31.   #--------------------------------------------------------------------------
  32.   def add_event(map_id, event_id, pos)
  33.     map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
  34.     event = map.events[event_id]
  35.     @events[@events.size + 1] = Game_Event.new(@map_id, event, @events.size + 1, pos)
  36.     refresh
  37.   end
  38. end
  39.  
  40. class Game_Event
  41.   #--------------------------------------------------------------------------
  42.   # * [Overwrite] Object Initialization
  43.   #--------------------------------------------------------------------------
  44.   def initialize(map_id, event, clone_id = nil, pos = nil)
  45.     super()
  46.     @map_id = map_id
  47.     @event = event
  48.     if !clone_id.nil?
  49.       @id = clone_id
  50.       moveto(pos[0], pos[1])
  51.     else
  52.       @id = @event.id
  53.       moveto(@event.x, @event.y)
  54.     end
  55.     refresh
  56.   end
  57.  
  58.   #--------------------------------------------------------------------------
  59.   # * [Overwrite] Determine if Event Page Conditions Are Met
  60.   #--------------------------------------------------------------------------
  61.   def conditions_met?(page)
  62.     c = page.condition
  63.     if c.switch1_valid
  64.       return false unless $game_switches[c.switch1_id]
  65.     end
  66.     if c.switch2_valid
  67.       return false unless $game_switches[c.switch2_id]
  68.     end
  69.     if c.variable_valid
  70.       return false if $game_variables[c.variable_id] < c.variable_value
  71.     end
  72.     if c.self_switch_valid
  73.       key = [@map_id, @id, c.self_switch_ch]
  74.       return false if $game_self_switches[key] != true
  75.     end
  76.     if c.item_valid
  77.       item = $data_items[c.item_id]
  78.       return false unless $game_party.has_item?(item)
  79.     end
  80.     if c.actor_valid
  81.       actor = $game_actors[c.actor_id]
  82.       return false unless $game_party.members.include?(actor)
  83.     end
  84.     return true
  85.   end
  86. end
  87.  
  88. class Game_Interpreter
  89.   #--------------------------------------------------------------------------
  90.   # * Add Event
  91.   #--------------------------------------------------------------------------
  92.   def summon_event(map_id, event_id, x, y)
  93.     $game_map.add_event(map_id, event_id, [x, y])
  94.     SceneManager.scene.refresh_characters
  95.   end
  96. end
  97.  
  98. class Scene_Map
  99.   #--------------------------------------------------------------------------
  100.   # * Refresh Characters
  101.   #--------------------------------------------------------------------------
  102.   def refresh_characters
  103.     @spriteset.refresh_characters
  104.   end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement