Advertisement
FlipelyFlip

FFS - Enemy Steal Saver V2

Sep 7th, 2024
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.40 KB | None | 0 0
  1. class Game_Enemy < Game_Battler
  2.   #--------------------------------------------------------------------------
  3.   # * Get Gold
  4.   #--------------------------------------------------------------------------
  5.   def gold(index)
  6.     stolen_gold = $game_troop.stolen_money[@index]
  7.     return enemy.gold + stolen_gold
  8.   end
  9.   #--------------------------------------------------------------------------
  10.   # * Create Array of Dropped Items
  11.   #--------------------------------------------------------------------------
  12.   def make_drop_items(index)
  13.     enemy.drop_items.inject([]) do |r, di|
  14.       if di.kind > 0 && rand * di.denominator < drop_item_rate
  15.         r.push(item_object(di.kind, di.data_id))
  16.       else
  17.         r
  18.       end
  19.     end
  20.   end
  21. end
  22.  
  23. class RPG::Enemy::DropItem
  24.   def initialize(k=0,id=1,de=1)
  25.     @kind = k
  26.     @data_id = id
  27.     @denominator = de
  28.   end
  29.  
  30.   attr_accessor :kind
  31.   attr_accessor :data_id
  32.   attr_accessor :denominator
  33. end
  34.  
  35. #==============================================================================
  36. # ** Game_Troop
  37. #------------------------------------------------------------------------------
  38. #  This class handles enemy groups and battle-related data. Also performs
  39. # battle events. The instance of this class is referenced by $game_troop.
  40. #==============================================================================
  41.  
  42. class Game_Troop < Game_Unit
  43.   #--------------------------------------------------------------------------
  44.   # * Object Initialization
  45.   #--------------------------------------------------------------------------
  46.   alias :ffs_enemy_steal_saver_initialize :initialize
  47.   def initialize
  48.     @stolen_items = []
  49.     @stolen_gold = []
  50.     ffs_enemy_steal_saver_initialize
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Clear
  54.   #--------------------------------------------------------------------------
  55.   alias :ffs_enemy_steal_saver_clear :clear
  56.   def clear
  57.     ffs_enemy_steal_saver_clear
  58.     @stolen_items = []
  59.     @stolen_gold = []
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Setup
  63.   #--------------------------------------------------------------------------
  64.   alias :ffs_enemy_steal_saver_setup :setup
  65.   def setup(troop_id)
  66.     ffs_enemy_steal_saver_setup(troop_id)
  67.     @enemies.each do |member|
  68.       next unless $data_enemies[member.enemy_id]
  69.       @stolen_items[member.index] = []
  70.       @stolen_gold[member.index] = 0
  71.     end
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # * Returns the stolen items
  75.   #--------------------------------------------------------------------------
  76.   def stolen_item
  77.     return @stolen_items
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # * Returns the stolen money
  81.   #--------------------------------------------------------------------------
  82.   def stolen_money
  83.     return @stolen_gold
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Adds the stolen item
  87.   #--------------------------------------------------------------------------
  88.   def add_stolen_item(item, index)
  89.     @stolen_items[index].push(item)
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # * Add Stolen Money
  93.   #--------------------------------------------------------------------------
  94.   def add_stolen_money(money, index)
  95.     @stolen_gold[index] += money
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Create Array of Dropped Items
  99.   #--------------------------------------------------------------------------
  100.   def make_drop_items
  101.     dead_members.inject([]) {|r, enemy|
  102.       r += enemy.make_drop_items(enemy.index)
  103.       r += @stolen_items[enemy.index]
  104.     }
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Calculate Total Gold
  108.   #--------------------------------------------------------------------------
  109.   def gold_total    
  110.     check_var ? get_gold_total*@diff_hash[var_value][9]/100 : get_gold_total
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Calculate Total Gold
  114.   #--------------------------------------------------------------------------
  115.   def get_gold_total
  116.     dead_members.inject(0) {|r, enemy| r += enemy.gold(enemy.index) } * gold_rate
  117.   end
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement