Advertisement
roninator2

Coelocanth Remove State by Weakness addon

Dec 7th, 2024
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.82 KB | None | 0 0
  1. # State Remove by Weakness by Coelocanth
  2. # Addon by Roninator2
  3. #
  4. # This script alters the "remove by damage" flag on states by giving some
  5. # extra options about what sort of damage removes the state.
  6. #
  7. # Instructions
  8. #
  9. # Install this script in the usual way by inserting below Materials in the
  10. # script editor.
  11. #
  12. # In the database, add the following note tags to states with the
  13. # "remove by damage" flag set:
  14. #
  15. # <remove by element damage: amount>
  16. # e.g. <remove by element damage: 50>
  17. #
  18. # Damage will only remove the state if it is higher than the value specified.
  19.  
  20. class RPG::State < RPG::BaseItem
  21.   attr_accessor :remove_by_element_damage
  22.   def load_notetags_ccsrw
  23.     @remove_by_weakness = false
  24.     @remove_by_strength = false
  25.     @remove_by_elements = []
  26.     @remove_by_element_damage = 0
  27.     self.note.split(/^/).each do |line|
  28.       case line
  29.       when /<remove by weakness>/i
  30.         @remove_by_weakness = true
  31.       when /<remove by strength>/i
  32.         @remove_by_strength = true
  33.       when /<remove by element:(\d+)/
  34.         @remove_by_elements.push($1.to_i)
  35.       when /<remove by element damage:[ _-](\d+)/
  36.         @remove_by_element_damage = ($1.to_i)
  37.       end
  38.     end
  39.   end
  40. end
  41.  
  42. class Game_Battler
  43.   def remove_states_by_damage
  44.     states.each do |state|
  45.       if state.remove_by_damage && rand(100) < state.chance_by_damage
  46.         next if state.remove_by_weakness && @result.element_rate <= 1.0
  47.         next if state.remove_by_strength && @result.element_rate >= 1.0
  48.         if @result.hp_damage >= state.remove_by_element_damage
  49.           remove_state(state.id)
  50.           next
  51.         end
  52.         next unless state.remove_by_elements.empty? ||
  53.                     state.remove_by_elements.include?(@result.element_id) ||
  54.         remove_state(state.id)
  55.       end
  56.     end
  57.   end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement