Advertisement
LiTTleDRAgo

[RGSS] XAS - Multiple Treasure Drop

Mar 7th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.70 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # XAS - Multiple Treasure Drop
  3. # Version: 1.10
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. $imported ||= {}
  7. $imported[:drg_xas_multiple_treasure_drop] = 1.10
  8.  
  9. if !$xrxs_xas
  10.   raise "This script needs XAS to work"
  11. end
  12. #===============================================================================
  13. # ■ XAS_BA_ItemDrop
  14. #===============================================================================
  15. module XAS_BA_ItemDrop
  16.   #--------------------------------------------------------------------------
  17.   # ● Defeat Process
  18.   #--------------------------------------------------------------------------
  19.   def defeat_process
  20.     super      
  21.     treasure = []      
  22.     if self.battler.is_a?(Game_Enemy) && self.battler.dead? &&
  23.       $game_map.passable?(self.x, self.y,0) && terrain_tag != XAS::FALL_TERRAIN
  24.       enemy = self.battler
  25.       if rand(100) < enemy.treasure_prob and self.battler.steal == false        
  26.         treasure << $data_items[enemy.item_id] if enemy.item_id > 0
  27.         treasure << $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0
  28.         treasure << $data_armors[enemy.armor_id] if enemy.armor_id > 0
  29.       end  
  30.       make_treasure(treasure.pop) if treasure != []
  31.       # Multi Drop  
  32.       tesouro = XAS_BA_ENEMY::ENEMY_MULTI_TREASURE[enemy.id]
  33.       tesouro.each {|item_2treasure| next if item_2treasure.nil?
  34.         type = item_2treasure[0].to_s.downcase
  35.         id = item_2treasure[1]
  36.         prob = item_2treasure[2]
  37.         prob = prob.gsub('%') {''}.strip.to_i if prob.is_a?(String)
  38.         if rand(100) < prob and self.battler.steal == false
  39.           treasure << $data_items[id] if [0,'i','item'].include?(type)
  40.           treasure << $data_weapons[id] if [1,'w','weapon'].include?(type)
  41.           treasure << $data_armors[id] if [2,'a','armor'].include?(type)
  42.         end } if tesouro != nil  
  43.       treasure.each {|s| make_multi_treasure(s)} if treasure != []
  44.     end    
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● Make Multi Treasure
  48.   #--------------------------------------------------------------------------  
  49.   def make_multi_treasure(t)
  50.     opecode,list = t.is_a?(RPG::Item) ? 126 : t.is_a?(RPG::Weapon) ? 127 :
  51.                   t.is_a?(RPG::Armor) ? 128 : nil, []
  52.     if opecode != nil
  53.       number = XAS::ITEM_NUMBER[t.id]  
  54.       number = 1 unless number != nil and t.is_a?(RPG::Item)
  55.       list[0] = RPG::EventCommand.new(opecode, 0, [t.id,0,0,number])
  56.       list[1] = RPG::EventCommand.new(250, 0, [XAS::ITEMDROP_SE])
  57.       list[2] = RPG::EventCommand.new(116, 0, [])          
  58.     end
  59.     list   << RPG::EventCommand.new
  60.     command = RPG::MoveCommand.new
  61.     route   = RPG::MoveRoute.new
  62.     page    = RPG::Event::Page.new
  63.     [command.code = 14,        command.parameters = [0,0]]
  64.     [route.repeat = false,     route.list = [command, RPG::MoveCommand.new]]
  65.     [page.move_type = 3,       page.move_frequency = 6]
  66.     [page.move_route = route,  page.always_on_top = true]
  67.     page.trigger, page.list, page.through = 1, list, true
  68.     100.times {
  69.       @xy = [@x+[-1,0,1][rand(2)], @y+[-1,0,1][rand(2)],0]
  70.       break if $game_map.passable?(*@xy) && $game_map.terrain_tag(*@xy[0..1]) != XAS::FALL_TERRAIN
  71.     }
  72.     event = RPG::Event.new(*@xy[0..1])
  73.     event.pages = [page]
  74.     token = Token_Event.new($game_map.map_id, event)
  75.     token.treasure_time = 100 + (40 * MOG::XAS_ICON_ERASE_TIME)
  76.     [token.icon_name = t.icon_name,  token.direction_fix = true]
  77.     [token.walk_anime = false,       token.step_anime = false]
  78.     $game_map.add_token(token)
  79.   end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement