Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- # ▼ Special Defenses v1.00
- # -- Last Updated: 2012.10.18
- # -- Level: Simple
- # -- Requires: n/a
- #
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["MOTO-SpecialDefenses"] = true
- #==============================================================================
- # ▼ Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2012.10.07 - Started Script and Finished.
- #
- #==============================================================================
- # ▼ Introduction
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Gives you additional defensive options to apply to your weapons and armor.
- #
- #==============================================================================
- # ▼ Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
- #
- # -----------------------------------------------------------------------------
- # Weapon Notetags - These notetags go in the weapons notebox in the database.
- # -----------------------------------------------------------------------------
- # <block>
- # This tag allows a weapon to be used for blocking, the chance that it will
- # succeed is determined by its block rate. This will be the default rate unless
- # otherwise defined.
- #
- # <critical block>
- # This tag allows a weapon to be used for blocking, with the additional effect
- # that it will also block critical hits.
- #
- # <block text: x>
- # Allows you to set up custom messages to display when a weapon successfully
- # blocks an attack. Otherwise it will use the default message defined below.
- #
- # <block rate: x%>
- # Allows you to adjust how often this weapon will block attacks. Otherwise uses
- # the default set below.
- #
- # <block adjust: +/-x>
- # <block adjust: +/-x%>
- # This tag affects the block rate of all items you have equipped.
- #
- # <unblockable>
- # Allows you to designate this weapon's attacks as unblockable.
- #
- # -----------------------------------------------------------------------------
- # Armor Notetags - These notetags go in the weapons notebox in the database.
- # -----------------------------------------------------------------------------
- # <block>
- # This tag allows armor to be used for blocking, the chance that it will
- # succeed is determined by its block rate. This will be the default rate unless
- # otherwise defined.
- #
- # <critical block>
- # This tag allows armor to be used for blocking, with the additional effect
- # that it will also block critical hits.
- #
- # <block text: x>
- # Allows you to set up custom messages to display when your armor successfully
- # blocks an attack. Otherwise it will use the default message defined below.
- #
- # <block rate: x%>
- # Allows you to adjust how often this armor will block attacks. Otherwise uses
- # the default set below.
- #
- # <block adjust: +/-x>
- # <block adjust: +/-x%>
- # This tag affects the block rate of all items you have equipped.
- #
- #==============================================================================
- # ▼ Compatibility
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
- # it will run with RPG Maker VX without adjusting.
- #
- #==============================================================================
- module MOTO
- module SPECDEF
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # - Default Block Text -
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # If a weapon or armor is not designated a message to display when used for
- # blocking, this is displayed instead.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- DEFAULT_BLOCK_TEXT = "%2$s absorbed the blow!"
- DEFAULT_BLOCK_SOUND = "Absorb1"
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # - Default Block Rate -
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # If a weapon or armor is not designated a rate at which to block attacks,
- # this percentage will be used.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- DEFAULT_BLOCK_RATE = 0.10
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # - Guard Block Boost -
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Increases your chance to block by this percentage while guarding. This
- # is an multiplicative increase, 25% + 25% is a 31% chance.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- GUARD_BLOCK_BOOST = 0.25
- end # BLOCK
- end # MOTO
- #==============================================================================
- # ▼ I will not help you troubleshoot if you change anything below; I will
- # incorporate fixes if your find something that is broken.
- #==============================================================================
- module MOTO
- module REGEXP
- module BASEITEM
- DOES_BLOCK = /<(?:BLOCK|block)>/i
- DOES_BLOCK_CRIT = /<(?:CRITICAL_BLOCK|critical)[\s_](?:BLOCKING|block)>/i
- BLOCK_TEXT = /<(?:BLOCK_TEXT|block text):[ ](.*)>/i
- BLOCK_SOUND = /<(?:BLOCK_SOUND|block sound):[ ](.*)>/i
- BLOCK_RATE = /<(?:BLOCK_RATE|block rate):[ ](\d+)([%%])>/i
- BLOCK_ADJUST_SET = /<(?:BLOCK_ADJUST|block adjust):[ ]([\+\-]\d+)>/i
- BLOCK_ADJUST_PER = /<(?:BLOCK_ADJUST|block adjust):[ ]([\+\-]\d+)([%%])>/i
- UNBLOCKABLE = /<?:UNBLOCKABLE|unblockable>/i
- end # BASEITEM
- end # REGEXP
- end # MOTO
- #==============================================================================
- # ■ DataManager
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias method: load_database
- #--------------------------------------------------------------------------
- class <<self; alias load_database_specdef load_database; end
- def self.load_database
- load_database_specdef
- load_notetags_specdef
- end
- #--------------------------------------------------------------------------
- # new method: load_notetags_war
- #--------------------------------------------------------------------------
- def self.load_notetags_specdef
- groups = [$data_weapons, $data_armors, $data_skills]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_notetags_specdef
- end
- end
- end
- end # DataManager
- #==============================================================================
- # ■ RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :does_block
- attr_accessor :does_block_crit
- attr_accessor :block_text
- attr_accessor :block_rate
- attr_accessor :block_sound
- attr_accessor :block_adjust_set
- attr_accessor :block_adjust_per
- attr_accessor :unblockable
- #--------------------------------------------------------------------------
- # common cache: load_notetags_specdef
- #--------------------------------------------------------------------------
- def load_notetags_specdef
- @does_block = false;
- @does_block_crit = false;
- @block_text = MOTO::SPECDEF::DEFAULT_BLOCK_TEXT
- @block_rate = MOTO::SPECDEF::DEFAULT_BLOCK_RATE * 100
- @block_sound = MOTO::SPECDEF::DEFAULT_BLOCK_SOUND
- @block_adjust_set = 0
- @block_adjust_per = 1
- @unblockable = false
- self.note.split(/[\r\n]+/).each { |line|
- case line
- #---
- when MOTO::REGEXP::BASEITEM::DOES_BLOCK
- @does_block = true
- when MOTO::REGEXP::BASEITEM::DOES_BLOCK_CRIT
- @does_block = true
- @does_block_crit = true
- when MOTO::REGEXP::BASEITEM::BLOCK_TEXT
- @block_text = $1.to_s
- when MOTO::REGEXP::BASEITEM::BLOCK_RATE
- @block_rate = $1.to_i
- when MOTO::REGEXP::BASEITEM::BLOCK_SOUND
- @block_sound = $1.to_s
- when MOTO::REGEXP::BASEITEM::BLOCK_ADJUST_SET
- @block_adjust_set = $1.to_i
- when MOTO::REGEXP::BASEITEM::BLOCK_ADJUST_PER
- @block_adjust_per = $1.to_i * 0.01 + 1
- when MOTO::REGEXP::BASEITEM::UNBLOCKABLE
- @unblockable = true
- end
- } # self.note.split
- end
- end # RPG::BaseItem
- #==========================================================================
- # ■ Game_BattlerBase
- #==========================================================================
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # new method: can_block?
- #--------------------------------------------------------------------------
- def can_block?
- does_block? && movable?
- end
- #--------------------------------------------------------------------------
- # new method: does_block?
- #--------------------------------------------------------------------------
- def does_block?
- if actor?
- for equip in equips
- next if equip.nil?
- return equip if equip.does_block
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # new method: adjusted_block_rate
- #--------------------------------------------------------------------------
- def adjusted_block_rate(rate)
- if actor?
- for equip in equips
- next if equip.nil?
- rate += equip.block_adjust_set
- rate *= equip.block_adjust_per
- end
- end
- return rate
- end
- #--------------------------------------------------------------------------
- # new method: did block?
- #--------------------------------------------------------------------------
- def did_block?
- if actor?
- for equip in equips
- next if equip.nil?
- next if !equip.does_block
- return equip if adjusted_block_rate(equip.block_rate) > rand(100)
- end
- end
- return false
- end
- end # Game_BattlerBase
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # alias: make_damage_value
- #--------------------------------------------------------------------------
- alias make_damage_value_specdef make_damage_value
- def make_damage_value(user, item)
- did_block = false;
- if can_block? && !item.unblockable
- did_block = did_block?
- if did_block != false
- @result.critical = false unless !did_block.does_block_crit
- @result.blocked = did_block
- end
- end
- make_damage_value_specdef(user, item)
- end
- #--------------------------------------------------------------------------
- # alias method: execute_damage
- #--------------------------------------------------------------------------
- alias execute_damage_specdef execute_damage
- def execute_damage(user)
- return if @result.blocked && !@result.critical
- execute_damage_specdef(user)
- end
- end # Game_Battler
- #==============================================================================
- # ■ Game_ActionResult
- #==============================================================================
- class Game_ActionResult
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :blocked
- #--------------------------------------------------------------------------
- # alias : clear_hit_flags
- #--------------------------------------------------------------------------
- alias clear_hit_flags_specdef clear_hit_flags
- def clear_hit_flags
- @blocked = false
- clear_hit_flags_specdef
- end
- #--------------------------------------------------------------------------
- # new method: block_text
- #--------------------------------------------------------------------------
- def block_text
- sprintf(@blocked.block_text, @battler.name, @blocked.name)
- end
- end # Game_ActionResult
- #==============================================================================
- # ■ Window_BattleLog
- #==============================================================================
- class Window_BattleLog < Window_Selectable
- #--------------------------------------------------------------------------
- # alias : display_hp_damage
- #--------------------------------------------------------------------------
- alias display_hp_damage_specdef display_hp_damage
- def display_hp_damage(target, item)
- return if item && !item.damage.to_hp?
- if target.result.blocked && !target.result.critical
- Audio.se_play("/Audio/SE/" + target.result.blocked.block_sound, 80, 110)
- add_text(target.result.block_text)
- wait
- end
- display_hp_damage_specdef(target, item)
- end
- end
- #==============================================================================
- #
- # ▼ End of File
- #
- #==============================================================================
Add Comment
Please, Sign In to add comment