#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Ratio Damage - KGC_RateDamage ◆ VX ◆ #_/ ◇ Last Update: 2008/08/28 #_/ ◆ Written by TOMY #_/ ◆ Translation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/---------------------------------------------------------------------------- #_/ This script allows you to create skills that deal a percentage of damage. #_/ These skills can either do a percentage of damage relative to the remaining #_/ HP/MP, or a percentage relative to the target's maximum HP/MP. #_/============================================================================= #_/ ◆ Instructions For Usage ◆ #_/ To make use of these functions, you must insert the desired tag into the #_/ "Notes" box located in the skills section of the database. For example, #_/ you want Double Attack to always inflict 15% of the target's maximum HP. #_/ You would then locate Double Attack in the skills tab of the database #_/ and insert "" (without quotations) in the note box. #_/ Where Value = the percentage amount of damage. #_/ To create skills that deal damage only relative to the target's current HP #_/ you'll make use of . Easy as that. #_/============================================================================ #_/ Install: Insert above KGC_SetAttackElement, if applicable. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #=================================================# # IMPORT # #=================================================# $imported = {} if $imported == nil $imported["RateDamage"] = true #=================================================# #============================================================================== # □ KGC::RateDamage::Regexp #============================================================================== # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # # Note Field Tag Strings # # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # # Whatever word(s) are after the separator ( | ) in the following lines are # what are used to determine what is searched for in the "Note" section of a # item or skill. module KGC module RateDamage module Regexp module UsableItem # ◆ Ratio Damage tag string RATE_DAMAGE = /<((?:MAX_|max_))?(?:RATE_DAMAGE|rate_damage)>/i end end end end #=================================================# #============================================================================== # ■ RPG::UsableItem #============================================================================== class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # ○ 割合ダメージのキャッシュ生成 #-------------------------------------------------------------------------- def create_rate_damage_cache @__rate_damage = false @__rate_damage_max = false self.note.split(/[\r\n]+/).each { |line| case line when KGC::RateDamage::Regexp::UsableItem::RATE_DAMAGE # 割合ダメージ @__rate_damage = true @__rate_damage_max = ($1 != nil) end } end #-------------------------------------------------------------------------- # ○ 割合ダメージか #-------------------------------------------------------------------------- def rate_damage? create_rate_damage_cache if @__rate_damage == nil return @__rate_damage end #-------------------------------------------------------------------------- # ○ 最大値割合ダメージか #-------------------------------------------------------------------------- def rate_damage_max? create_rate_damage_cache if @__rate_damage_max == nil return @__rate_damage_max end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● スキルまたはアイテムによるダメージ計算 # user : スキルまたはアイテムの使用者 # obj : スキルまたはアイテム # 結果は @hp_damage または @mp_damage に代入する。 #-------------------------------------------------------------------------- alias make_obj_damage_value_KGC_RateDamage make_obj_damage_value def make_obj_damage_value(user, obj) if obj == nil || !obj.rate_damage? # 割合ダメージでない return make_obj_damage_value_KGC_RateDamage(user, obj) end damage = obj.base_damage if obj.damage_to_mp value = (obj.rate_damage_max? ? maxmp : mp) else value = (obj.rate_damage_max? ? maxhp : hp) end damage = value * damage / 100 damage = damage * elements_max_rate(obj.element_set) / 100 # 属性修正 damage = apply_variance(damage, obj.variance) # 分散 damage = apply_guard(damage) # 防御修正 if obj.damage_to_mp @mp_damage = damage else @hp_damage = damage end end end