Advertisement
Narzew

XAS Enemy Kill Counter by Narzew v 1.00

Mar 28th, 2015
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.93 KB | None | 0 0
  1. #====================================================
  2. #**XAS Enemy Kill Counter
  3. #**v 1.00
  4. #**28.03.15
  5. #**Narzew
  6. #====================================================
  7. #**License: GPL v3
  8. #**Website: HackTut.org
  9. #====================================================
  10. #**Designed for XAS 3.91
  11. #**Not tested with XAS 3.8 or lower
  12. #====================================================
  13. #**Instructions:
  14. #**Paste the script in Xas Addons Section (below XAS Engine)
  15. #**Use $game_system.get_enemy_kills(enemy_id) to get enemy kills
  16. #**for example: $game_system.get_enemy_kills(2) will get number
  17. #**of enemies with id 2 killed.
  18. #====================================================
  19.  
  20. #====================================================
  21. #**Game_System overwrite
  22. #====================================================
  23.  
  24. class Game_System
  25.   attr_accessor :enemy_kills
  26.   alias xas_enemy_kill_counter_narzew1 initialize
  27.  
  28.   #====================================================
  29.   #**Overwrite initialize method
  30.   #====================================================
  31.  
  32.   def initialize
  33.     @enemy_kills = []
  34.     xas_enemy_kill_counter_narzew1
  35.   end
  36.  
  37.   #====================================================
  38.   #**gain_enemy_kill(id) => gain enemy kill of id
  39.   #====================================================
  40.  
  41.   def gain_enemy_kill(id)
  42.     if @enemy_kills[id] == nil
  43.       @enemy_kills[id] = 0
  44.     end
  45.     @enemy_kills[id] += 1
  46.   end
  47.  
  48.   #====================================================
  49.   #**get_enemy_kills(id) => return number of kills of a enemy id
  50.   #====================================================
  51.  
  52.   def get_enemy_kills(id)
  53.     if @enemy_kills[id] == nil
  54.       @enemy_kills[id] = 0
  55.     end
  56.     return @enemy_kills[id]
  57.   end
  58.  
  59. end
  60.  
  61. #====================================================
  62. #**Game_Event overwrite
  63. #====================================================
  64.  
  65. class Game_Event < Game_Character
  66.  
  67.   #====================================================
  68.   #**Overwrite enemy_defat_process defined by XAS
  69.   #====================================================
  70.  
  71.   alias xas_enemy_kill_counter_narzew2 enemy_defeat_process
  72.   def enemy_defeat_process(enemy)
  73.     $game_system.gain_enemy_kill(enemy.id)
  74.     xas_enemy_kill_counter_narzew2(enemy)
  75.   end
  76.  
  77. end
  78.  
  79. #====================================================
  80. #**Anti Save Corruption
  81. #**Rewrite Scene_Load::read_save_data
  82. #====================================================
  83. #**If you use custom load system, comment method below and add:
  84. #**$game_system.enemy_kills = [] if $game_system.enemy_kills == nil
  85. #**after line:
  86. #**$game_system = Marshal.load(file)
  87. #====================================================
  88.  
  89. class Scene_Load < Scene_File
  90.   alias xas_enemy_kill_counter_narzew3 read_save_data
  91.   def read_save_data(file)
  92.     xas_enemy_kill_counter_narzew3(file)
  93.     $game_system.enemy_kills = [] if $game_system.enemy_kills == nil
  94.   end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement