Zouzaka

Capture de monstre version Dofus

Dec 31st, 2015
197
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2. Description :
  3. Ce Script permet de capturer un groupe de monstre dans un objet afin de l'affronter
  4. plus par la suite.
  5.  
  6. Utilisation :
  7. -Créer un objet qui ne cible personne et utilisable uniquement en combat
  8. -Inserez ceci dans la note de l'objet :
  9.           <capture>
  10. -Mettez l'index de la nouvelle icone de l'objet apres la capture a la ligne 13
  11. =end
  12.  
  13. Full_id = 9
  14. Can_Capture_Swtich = 1
  15.  
  16. # Fin des modifications.
  17. class RPG::UsableItem
  18.   attr_accessor :captured_team
  19.   attr_accessor :default_icone_index
  20.   alias :z_initialize :initialize
  21.   def initialize
  22.     z_initialize
  23.     @captured_team = nil
  24.     @default_icone_index = @icon_index
  25.   end
  26.   def is_capture_item?
  27.     /<capture>/.match(@note) ? true : false
  28.   end
  29. end
  30. class Game_Party
  31.   alias :z_usable? :usable?
  32.   def usable?(item)
  33.     if item
  34.       return false if !BattleManager.can_capture? && item.is_capture_item?
  35.     end
  36.     members.any? {|actor| actor.usable?(item) }
  37.   end
  38. end
  39. class Game_Battler
  40.   alias :z_use_item :use_item
  41.   def use_item(item)
  42.     if item.is_capture_item? && item.captured_team == nil
  43.       create_captured_item(item)
  44.       item.effects.each {|effect| item_global_effect_apply(effect) }
  45.       consume_item(item)   if item.is_a?(RPG::Item)
  46.     elsif item.is_capture_item? && item.captured_team != nil
  47.       consume_item(item)   if item.is_a?(RPG::Item)
  48.       use_capture(item)
  49.     else
  50.       z_use_item(item)
  51.     end
  52.   end
  53.   def use_capture(item)
  54.     @capture_battle = true
  55.     # Re-index
  56.     $data_capture.slice!($data_capture.index(item))
  57.     id = item.id
  58.     $data_items.slice!(id)
  59.     $data_items.each do |itm|
  60.       if itm
  61.         itm.id = itm.id-1 if itm.id > id
  62.       end
  63.     end
  64.     # Start Battle
  65.    
  66.     BattleManager.setup(item.captured_team, true, true, false)
  67.     BattleManager.save_bgm_and_bgs
  68.     BattleManager.play_battle_bgm
  69.     SceneManager.call(Scene_Battle)
  70.   end
  71.   def create_captured_item(item)
  72.     @new_item = item.clone
  73.     @new_item.id = $data_items.length
  74.     @new_item.description = $game_troop.troop.name
  75.     @new_item.captured_team = $game_troop.troop.id
  76.     @new_item.default_icone_index = item.icon_index
  77.     @new_item.icon_index = Full_id
  78.     @new_item.occasion = 2
  79.     $data_items << @new_item
  80.     $data_capture << @new_item
  81.     $game_party.gain_item(@new_item, 1)
  82.   end
  83. end
  84. class Scene_Battle
  85.   alias :z_use_item :use_item
  86.   def use_item
  87.     z_use_item
  88.     if @subject.current_action.item.is_capture_item?
  89.       show_animation($game_troop.members, @subject.current_action.item.animation_id)
  90.     end
  91.   end
  92. end
  93.  
  94. module BattleManager
  95.   class << self
  96.     alias :z_setup :setup
  97.     def setup(troop_id, can_escape = true, can_lose = false, can_capture = true)
  98.       z_setup(troop_id, can_escape, can_lose)
  99.       @can_capture = can_capture
  100.     end
  101.     def can_capture?
  102.       return (@can_capture && !$game_switches[Can_Capture_Swtich])
  103.     end
  104.   end
  105. end
  106.  
  107. module DataManager
  108.   class << self
  109.     alias :make_capture_save :make_save_contents
  110.     alias :extract_capture_save :extract_save_contents
  111.     alias :creat_capture_object :create_game_objects
  112.     def make_save_contents
  113.       make_capture_save.merge({:capture =>$data_capture})
  114.     end
  115.     def extract_save_contents(contents)
  116.       extract_capture_save(contents)
  117.       $data_capture        = contents[:capture]
  118.       $data_items.concat($data_capture)
  119.     end
  120.     def create_game_objects
  121.       $data_capture          = Array.new
  122.       creat_capture_object
  123.     end
  124.   end
  125. end
RAW Paste Data