Advertisement
Holy87

Enemy kill counter - VX

Jul 12th, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.56 KB | None | 0 0
  1. $imported = {} if $imported == nil
  2. $imported["H87_EKC"] = true
  3. #===============================================================================
  4. # ** INCREMENTA VARIABILE CON UCCISIONE DEL NEMICO **
  5. # Versione: 1.0 (15/04/2013)
  6. # Difficoltà utente: ★
  7. #===============================================================================
  8. # DESCRIZIONE:
  9. # Mettiamo che vuoi fare una quest come "Uccidi 10 Slime!" Come si fa a tenere
  10. # il conto degli Slime uccisi? Con questo script, che li memorizza in una
  11. # variabile!
  12. #===============================================================================
  13. # UTILIZZO:
  14. # Installare lo script sotto Materials e prima del Main.
  15. # Inserire, nel riquadro delle note del nemico, la seguente etichetta:
  16. # <kill var: x>, dove x è la variabile (ID) che verrà incrementata quando quel
  17. # mostro verrà ucciso. Semplice!
  18. #===============================================================================
  19. # COMPATIBILITA':
  20. # Compatibile con quasi tutti gli script.
  21. #===============================================================================
  22.  
  23.  
  24. #===============================================================================
  25. # Attenzione: Non modificare ciò che c'è oltre, a meno che tu non sappia ciò che
  26. # fai!
  27. #===============================================================================
  28. module H87_EKC
  29.   KillVariable = /<(?:KILL VAR|kill var):[ ]*(\d+)>/i
  30. end
  31.  
  32. #===============================================================================
  33. # ** Data Nemico
  34. #===============================================================================
  35. class RPG::Enemy
  36.   attr_reader :killvariable
  37.  
  38.   #-----------------------------------------------------------------------------
  39.   # *Carica le info sulla variabile
  40.   #-----------------------------------------------------------------------------
  41.   def carica_cache_personale_ekc
  42.     return if @cache_caricata_ekc
  43.     @cache_caricata_ekc = true
  44.     @killvariable = 0
  45.     self.note.split(/[\r\n]+/).each { |riga|
  46.       case riga
  47.       #---
  48.       when H87_EKC::KillVariable
  49.         @killvariable = $1.to_i
  50.       end
  51.     }
  52.   end
  53. end
  54.  
  55. #===============================================================================
  56. # ** Scene_Title
  57. #===============================================================================
  58. class Scene_Title < Scene_Base
  59.  
  60.   #-----------------------------------------------------------------------------
  61.   # *Alias metodo load_bt_database
  62.   #-----------------------------------------------------------------------------
  63.   alias carica_db_ekc load_bt_database unless $@
  64.   def load_bt_database
  65.     carica_db_ekc
  66.     carica_enemy_ekc
  67.   end
  68.  
  69.   #-----------------------------------------------------------------------------
  70.   # *Alias metodo load_database
  71.   #-----------------------------------------------------------------------------
  72.   alias carica_db_ekc load_database unless $@
  73.   def load_database
  74.     carica_db_ekc
  75.     carica_enemy_ekc
  76.   end
  77.  
  78.   #-----------------------------------------------------------------------------
  79.   # Inizializza nel caricamento
  80.   #-----------------------------------------------------------------------------
  81.   def carica_enemy_ekc
  82.     for enemy in $data_enemies
  83.       next if enemy == nil
  84.       enemy.carica_cache_personale_ekc
  85.     end
  86.   end
  87.  
  88. end # scene_title
  89.  
  90. #===============================================================================
  91. # ** Game_Enemy
  92. #===============================================================================
  93. class Game_Enemy < Game_Battler
  94.  
  95.   #-----------------------------------------------------------------------------
  96.   # *inizializzazione
  97.   #-----------------------------------------------------------------------------
  98.   alias h87_ekc_initialize initialize unless $@
  99.   def initialize(index, enemy_id)
  100.     h87_ekc_initialize(index, enemy_id)
  101.     @killed_variable = enemy.killvariable
  102.   end
  103.  
  104.   #-----------------------------------------------------------------------------
  105.   # *alias metodo di collasso (morte)
  106.   #-----------------------------------------------------------------------------
  107.   alias h87_ekc_collapse perform_collapse unless $@
  108.   def perform_collapse
  109.     increment_killed_var if $game_temp.in_battle and dead?
  110.     h87_ekc_collapse
  111.     end
  112.  
  113.   #-----------------------------------------------------------------------------
  114.   # *incremento variabile se permesso
  115.   #-----------------------------------------------------------------------------
  116.   def increment_killed_var
  117.     $game_variables[@killed_variable] += 1 if @killed_variable != 0
  118.   end
  119. end #game_enemy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement