Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ==============================================================================
- # ▼▼▼▼▼▼ TroyZ - States Damage 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 when the
- # battler has suffered certain amount of damage at certain probability.
- # ------------------------------------------------------------------------------
- # How to use :
- # Place it between material and main. Use this notetags inside states :
- #
- # <remove by damage: x>
- # <remove by damage chance: y>
- #
- # The states that have this notetags will be removed when the affected battler
- # suffers the x total damage 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 :
- #
- # <remove by damage: 800>
- # <remove by damage chance: 50>
- #
- # The state will be removed when the affected battler suffers 800 damage from enemy.
- # When the battler get 800 damage from enemy, 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_StatesDamageCountRemoval] = true
- # ------------------------------------------------------------------------------
- # There is nothing to config beyond this line
- # ------------------------------------------------------------------------------
- module AGUNG
- module DAMAGE_COUNT
- DAMAGE_COUNT_DEFAULT = 0
- DAMAGE_COUNT_REMOVE_CHANCE_DEFAULT = 0
- end
- module NOTETAGS_DAMAGE_COUNT
- DAMAGE_COUNT = /<(?:REMOVE BY DAMAGE|remove by damage):[ ]*(\d+)>/i
- DAMAGE_COUNT_REMOVE_CHANCE = /<(?:REMOVE BY DAMAGE CHANCE|remove by damage chance):[ ]*(\d+)>/i
- end
- end
- module DataManager
- class << self
- alias agung_load_states_damage_count_removal_dbase_x load_database
- end
- def self.load_database
- agung_load_states_damage_count_removal_dbase_x
- agung_load_notetags_damage_count_removal_x
- end
- def self.agung_load_notetags_damage_count_removal_x
- [$data_states].each do |states|
- states.each do |obj|
- next unless obj
- obj.agung_load_notetags_damage_count_removal_x
- end
- end
- end
- end
- class RPG::State < RPG::BaseItem
- include AGUNG::DAMAGE_COUNT
- include AGUNG::NOTETAGS_DAMAGE_COUNT
- attr_accessor :damage_count
- attr_accessor :chance_by_damage_count
- def agung_load_notetags_damage_count_removal_x
- @damage_count = DAMAGE_COUNT_DEFAULT
- @chance_by_damage_count = DAMAGE_COUNT_REMOVE_CHANCE_DEFAULT
- self.note.split(/[\r\n]+/).each { |baris|
- case baris
- when DAMAGE_COUNT
- @damage_count = $1.to_i
- when DAMAGE_COUNT_REMOVE_CHANCE
- @chance_by_damage_count = $1.to_i
- end
- }
- end
- end
- class Game_BattlerBase
- alias agung_clear_states_damage_count_x clear_states
- def clear_states
- agung_clear_states_damage_count_x
- @state_damage_count = {}
- end
- alias agung_erase_state_damage_count_x erase_state
- def erase_state(state_id)
- agung_erase_state_damage_count_x(state_id)
- @state_damage_count.delete(state_id)
- end
- end
- class Game_Battler < Game_BattlerBase
- def reset_state_damage_counts(state_id)
- state = $data_states[state_id]
- @state_damage_count[state_id] = state.damage_count
- end
- def add_state(state_id)
- if state_addable?(state_id)
- add_new_state(state_id) unless state?(state_id)
- reset_state_counts(state_id)
- reset_state_damage_counts(state_id)
- @result.added_states.push(state_id).uniq!
- end
- end
- def update_states_damage_count
- states.each do |state|
- @state_damage_count[state.id] -= @result.hp_damage if @state_damage_count[state.id] > 0
- end
- end
- def remove_states_by_damage_count
- states.each do |state|
- if @state_damage_count[state.id] <= 0 && rand(100) < state.chance_by_damage_count
- remove_state(state.id)
- end
- end
- end
- alias agung_on_damage_count_x on_damage
- def on_damage(value)
- agung_on_damage_count_x(value)
- update_states_damage_count
- remove_states_by_damage_count
- end
- end
- # ------------------------------------------------------------------------------
- # END OF SCRIPT
- # ------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement