Advertisement
Skyloftian_Link

Schala::VariableOperation

Dec 16th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.93 KB | None | 0 0
  1. #===============================================================================
  2. # Schala::VariableOperation
  3. #-------------------------------------------------------------------------------
  4. # Por: Skyloftian
  5. #===============================================================================
  6. # > Função:
  7. #   - Este script é um add-on ao Schala Battle System que adiciona a opção de
  8. #   adicionar ou remover um valor de uma variável ao derrotar um inimigo.
  9. #-------------------------------------------------------------------------------
  10. # > Instruções:
  11. #   - Para fazer a operação, é necessário adicionar o seguinte código na
  12. #   caixa de notas do inimigo:
  13. #
  14. #   <Variable Operation = id, ope, value>
  15. #
  16. #   De maneira em que:
  17. #   id     = ID da variável
  18. #   ope    = Operação a ser realizada (1 para adição e 2 para subtração)
  19. #   value  = Valor a se adicionar ou remover
  20. #
  21. #   - Exemplo de uso:
  22. #   <Variable Operation = 5, 1, 1>   # Adiciona 1 a variável 5
  23. #   <Variable Operation = 1, 2, 3>   # Remove 3 da variável 1
  24. #
  25. #   - É só isso.
  26. #===============================================================================
  27.  
  28. #=============================================================
  29. # > Schala_Battle
  30. #=============================================================        
  31. module Schala_Battle
  32.  
  33.   #---------------------------------------------------------
  34.   # ~ Execute Variable Operation
  35.   #---------------------------------------------------------
  36.   def execute_variable_operation(enemy)        
  37.     enemy.note  =~ /<Variable Operation = (\d+), (\d+), (\d+)>/      
  38.     variable_id = $1.to_i
  39.     operation = $2.to_i
  40.     value = $3.to_i
  41.     if variable_id != nil
  42.       if operation == 1
  43.         $game_variables[variable_id] += value
  44.         $game_map.need_refresh = true    
  45.       elsif operation == 2
  46.         $game_variables[variable_id] -= value
  47.         $game_map.need_refresh = true  
  48.       end
  49.     end
  50.   end
  51.  
  52. end # Schala_Battle
  53. #=============================================================
  54. # > Game_Character < Game_CharacterBase
  55. #=============================================================      
  56. class Game_Character < Game_CharacterBase
  57.  
  58.   #---------------------------------------------------------
  59.   # ~ Execute Enemy Defeated Process
  60.   #---------------------------------------------------------
  61.   alias :new_ope :execute_enemy_defeated_process
  62.   def execute_enemy_defeated_process
  63.     enemy = $data_enemies[self.battler.enemy_id]
  64.     execute_variable_operation(enemy)
  65.     new_ope
  66.   end    
  67.      
  68.   #---------------------------------------------------------
  69.   # ~ Execute Enemy Defeated On Field
  70.   #---------------------------------------------------------
  71.   alias :new_ope_new :execute_enemy_defeated_on_field
  72.   def execute_enemy_defeated_on_field
  73.     enemy = $data_enemies[self.battler.enemy_id]
  74.     execute_variable_operation(enemy)
  75.     new_ope_new
  76.   end
  77.  
  78. end # Game_Character
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement