# ============================================================================== # ▼▼▼▼▼▼ TroyZ - States Hit Count Removal ▼▼▼▼▼▼ # ============================================================================== # Script by : Agung Prasetyo(TroyZ) # Contact me by : - Email agung.endisnear.xyz@gmail.com # - Forum RPGMakerID, username TroyZ # - Handphone 085756289121 # Engine : VXAce # Level : Easy # Version : 1.0 # ------------------------------------------------------------------------------ # Change Logs : # 18 June 2013 : Version 1.0 released # ------------------------------------------------------------------------------ # How this work : # This script will give you an ability to create states that removed at a # certain hit count and certain probability. # ------------------------------------------------------------------------------ # How to use : # Place it between material and main. Use this notetags inside states : # # # # # The states that have this notetags will be removed when the affected battler # suffers the x total hits at y% probability. You don't have to write the percent # sign at y, just put the number actually. For example, a state have this notetags : # # # # # The state will be removed when the affected battler suffers 3 hits from enemies. # When the battler get 3 hits from enemies, the state will be removed at 50% chance. # ------------------------------------------------------------------------------ # Compatibility issues : # None yet. If you found some, let me know, and bug fixes will come out soon. # ------------------------------------------------------------------------------ # Who to credit : # - Allah swt. : For the chance of living that he has given to me. # - Nabi Muhammad saw. : As a leader and messenger and prophet of Muslim. # I'm proud to be your follower. :) # - Agung Prasetyo(TroyZ) : Thats me, of course, the ones that made this script. :P # ------------------------------------------------------------------------------ # License : # - Free Game : Just credit those names above. # - Commercial Game : Same as free game's license. # ------------------------------------------------------------------------------ $imported = {} if $imported.nil? $imported[:TroyZ_StatesHitCountRemoval] = true # ------------------------------------------------------------------------------ # There is nothing to config beyond this line # ------------------------------------------------------------------------------ module AGUNG module HIT_COUNT HIT_COUNT_DEFAULT = 0 HIT_COUNT_REMOVE_CHANCE_DEFAULT = 0 end module NOTETAGS_HIT_COUNT HIT_COUNT = /<(?:REMOVE BY HIT|remove by hit):[ ]*(\d+)>/i HIT_COUNT_REMOVE_CHANCE = /<(?:REMOVE BY HIT CHANCE|remove by hit chance):[ ]*(\d+)>/i end end module DataManager class << self alias agung_load_states_hit_count_removal_dbase_x load_database end def self.load_database agung_load_states_hit_count_removal_dbase_x agung_load_notetags_hit_count_removal_x end def self.agung_load_notetags_hit_count_removal_x [$data_states].each do |states| states.each do |obj| next unless obj obj.agung_load_notetags_hit_count_removal_x end end end end class RPG::State < RPG::BaseItem include AGUNG::HIT_COUNT include AGUNG::NOTETAGS_HIT_COUNT attr_accessor :hit_count attr_accessor :chance_by_hit_count def agung_load_notetags_hit_count_removal_x @hit_count = HIT_COUNT_DEFAULT @chance_by_hit_count = HIT_COUNT_REMOVE_CHANCE_DEFAULT self.note.split(/[\r\n]+/).each { |baris| case baris when HIT_COUNT @hit_count = $1.to_i when HIT_COUNT_REMOVE_CHANCE @chance_by_hit_count = $1.to_i end } end end class Game_BattlerBase alias agung_clear_states_x clear_states def clear_states agung_clear_states_x @state_hit_count = {} end alias agung_erase_state_x erase_state def erase_state(state_id) agung_erase_state_x(state_id) @state_hit_count.delete(state_id) end end class Game_Battler < Game_BattlerBase alias agung_reset_state_counts_x reset_state_counts def reset_state_counts(state_id) agung_reset_state_counts_x(state_id) @state_hit_count[state_id] = $data_states[state_id].hit_count end def update_states_hit_count states.each do |state| @state_hit_count[state.id] -= 1 if @state_hit_count[state.id] > 0 end end def remove_states_by_hit_count states.each do |state| if @state_hit_count[state.id] == 0 && rand(100) < state.chance_by_hit_count remove_state(state.id) end end end alias agung_on_damage_x on_damage def on_damage(value) agung_on_damage_x(value) update_states_hit_count remove_states_by_hit_count end end # ------------------------------------------------------------------------------ # END OF SCRIPT # ------------------------------------------------------------------------------