Advertisement
Guest User

Addon for Single State Stack Removal and Remove Commands

a guest
Jan 18th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.73 KB | None | 0 0
  1. #============================================================================
  2. #
  3. #  "Remove Single State Stack with Remove Command" - Script
  4. #
  5. #  Version: 1.0 (January 18th, 2016)
  6. #  Author:  Another Fen <forums.rpgmakerweb.com>
  7. #  
  8. #  Requires:
  9. #  - "Stacking States" V1.1  by Neon Black
  10. #    http://forums.rpgmakerweb.com/index.php?/topic/14110-stacking-states/
  11. #  - "State Add/Remove Commands" V1.01  by Shaz
  12. #    http://forums.rpgmakerweb.com/index.php?/topic/18593-state-addremove-commands/
  13. #
  14. # Contents: -----------------------------------------------------------------
  15. #  
  16. #  Removing states by skill effects and event commands should now remove only
  17. #  one stack. The state will still get completely removed when it expires or
  18. #  is resisted.
  19. #  
  20. #  This script is meant to be inserted below the required scripts but as
  21. #  close to "▼ Materials" as possible. It might not work with future versions
  22. #  of either script.
  23. #
  24. #============================================================================
  25.  
  26. class Game_Battler
  27.  
  28.   #--------------------------------------------------------------------------
  29.   # * Remove Single State Stack
  30.   #  Future changes to remove_state/erase_state may have to be reflected here!
  31.   #--------------------------------------------------------------------------
  32.   def remove_state_stack(state_id)
  33.     case @states.count(state_id)
  34.     when 0
  35.       return
  36.     when 1
  37.       remove_state(state_id)
  38.     else
  39.       @states.delete_at(@states.index(state_id))
  40.       @result.removed_states.push(state_id).uniq!
  41.       refresh
  42.       state_remove_command(state_id)
  43.     end
  44.   end
  45.  
  46.   #--------------------------------------------------------------------------
  47.   # * Erase State  (Redefined)
  48.   #  Now calls "state_remove_command" once for every removed stack
  49.   #--------------------------------------------------------------------------
  50.   def erase_state(state_id)
  51.     erase_count = state_stack(state_id)
  52.     super
  53.     erase_count.times { state_remove_command(state_id) }
  54.   end
  55.  
  56.   #--------------------------------------------------------------------------
  57.   # * [Remove State] Effect  (Redefined)
  58.   #  Modified to remove only one stack. Removed "remove_state" call!
  59.   #--------------------------------------------------------------------------
  60.   def item_effect_remove_state(user, item, effect)
  61.     chance = effect.value1
  62.     if rand < chance
  63.       remove_state_stack(effect.data_id)  # <- Modified
  64.       @result.success = true
  65.     end
  66.   end
  67. end
  68.  
  69.  
  70. class Game_Interpreter
  71.  
  72.   #--------------------------------------------------------------------------
  73.   # * Change State  (Redefined)
  74.   #  Modified to remove only one stack. Removed "remove_state" call!
  75.   #--------------------------------------------------------------------------
  76.   def command_313
  77.     iterate_actor_var(@params[0], @params[1]) do |actor|
  78.       already_dead = actor.dead?
  79.       if @params[2] == 0
  80.         actor.add_state(@params[3])
  81.       else
  82.         actor.remove_state_stack(@params[3])  # <- Modified
  83.       end
  84.       actor.perform_collapse_effect if actor.dead? && !already_dead
  85.     end
  86.     $game_party.clear_results
  87.   end
  88.  
  89.   #--------------------------------------------------------------------------
  90.   # * Change Enemy State  (Redefined)
  91.   #  Modified to remove only one stack. Removed "remove_state" call!
  92.   #--------------------------------------------------------------------------
  93.   def command_333
  94.     iterate_enemy_index(@params[0]) do |enemy|
  95.       already_dead = enemy.dead?
  96.       if @params[1] == 0
  97.         enemy.add_state(@params[2])
  98.       else
  99.         enemy.remove_state_stack(@params[2])  # <- Modified
  100.       end
  101.       enemy.perform_collapse_effect if enemy.dead? && !already_dead
  102.     end
  103.   end
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement