=begin
#==============================================================================
** Scope Damage Modifer
Author: Hime
Date: Jul 30, 2013
------------------------------------------------------------------------------
** Change log
Jul 30, 2013
- added compatibility with Scope Change script
Sep 21, 2012
- added condition for all other scopes to fix nil value bug
Aug 18, 2012
- initial release
------------------------------------------------------------------------------
This script adds a scope-based damage modifier to your skills/items.
Maybe a skill that targets all enemies should deal less damage to each enemy
than when you use it to target a single enemy.
To specify a single-scope modifier, tag your skill/item with
<single_scope_mod: x>
To specify an all-scope modifier, tag your skill/item with
<all_scope_mod: x>
For some number x.
This is only useful if you have a script that allows you to change
the scope of your skills.
#==============================================================================
=end
$imported = {} if $imported.nil?
$imported["Tsuki_ScopeDamage"] = true
#==============================================================================
# ** Configuration
#==============================================================================
module Tsuki
module Scope_Damage
Single_Scope_Regex = /<(single_scope_mod|single scope mod):\s*(.*)>/i
All_Scope_Regex = /<(all_scope_mod|all scope mod):?\s*(.*)>/i
end
end
#==============================================================================
# ** Rest of the script
#==============================================================================
module RPG
class UsableItem
def single_damage_modifier
return @single_dmg_mod unless @single_dmg_mod.nil?
res = Tsuki::Scope_Damage::Single_Scope_Regex.match(self.note)
return @single_dmg_mod = res ? res[2].to_f : 1
end
def all_damage_modifier
return @all_dmg_mod unless @all_dmg_mod.nil?
res = Tsuki::Scope_Damage::All_Scope_Regex.match(self.note)
return @all_dmg_mod = res ? res[2].to_f : 1
end
end
end
class Game_ActionResult
alias :th_scope_change_make_damage :make_damage
def make_damage(value, item)
value = apply_scope_modifier(value, item).to_i
th_scope_change_make_damage(value, item)
end
def apply_scope_modifier(value, item)
return value * item.single_damage_modifier if item.for_one?
return value * item.all_damage_modifier if item.for_all?
return value
end
end
#-------------------------------------------------------------------------------
# Compatibilty with Scope Change
#-------------------------------------------------------------------------------
if $imported["Tsuki_ScopeChange"]
class Game_ActionResult
attr_accessor :action
alias :th_scope_damage_modifier_clear :clear
def clear
th_scope_damage_modifier_clear
@action = Game_Action.new(self)
end
def apply_scope_modifier(value, item)
return value * item.single_damage_modifier if @action.scope.for_one?
return value * item.all_damage_modifier if @action.scope.for_all?
return value
end
end
class Game_Battler < Game_BattlerBase
alias :th_tsuki_action_item_test :item_test
def item_test(user, item)
@result.action = user.current_action
th_tsuki_action_item_test(user, item)
end
end
end