=begin
================================================================================
Targetting Extended v 1.1
by CrimsonSeas
================================================================================
This is a script I made to extend targettting capabilities.
Features:
+Target any allies or enemies with any action. You can choose to blow your team
mate or heal your enemies by pressing L/R button at target selection.
+Press shift at target selection to change single target skills and items to
target all.
+Define which skills both feature apply or not apply to.
+Cursors!! Multiple cursors over all targets when targeting multiple targets
+Can also divide damage among all targets when switching from single to all target
================================================================================
Compatibility
================================================================================
I think there may be many issues around this. I'll list rewrites and aliases of
default and Tankentai scripts.
Rewrites:
+Game_Battler
-make_attack_targets
-make_obj_targets
+Sprite_Battler
-moving_anime
Aliases:
+Scene_Battle
-execute_action
+Game_Battler
-make_obj_damage_value
-calc_mp_cost
=================================================================================
CONFIG
================================================================================
=end
module TargetExt
#Defines whether you can attack ally or not.
ATTACK_ANY = true
#Defines skill IDs that the 'Target Any' feature doesn't apply.
NO_TARGET_ANY_S = []
#Defines item IDs that the 'Target Any' feature doesn't apply/
NO_TARGET_ANY_I = [2]
#Defines skill IDs that the 'Target All' feature apply.
TARGET_ALL_S = [59, 63]
#Defines item IDs that the 'Target All'feature apply.
TARGET_ALL_I = [1]
#Defines damage percentage when changing target from single to all
DAMAGE_PERCENT = 66
#Defines MP percentage when changing target from single to all
MP_PERCENT = 150
#Defines vocabulary to be used when targetting multiple targets.
#Format is: [String1, [StringParty, StringEnemies]]
#Text shown on help window when targetting party:
# String1 StringParty
#Text shown on help wondow when targetting enemies:
# String1 StringEnemies
TARGET_ALL_VOC = ["Target All", ["Allies", "Enemies"]]
#Show MP cost when 'Target All' feature is being used
SHOW_MP_ALTER = true
#Divides damage among all targets when switching from single target to all target
DAMAGE_DIVIDE = true
end
class Game_Battler
def target_all
if @target_all == nil
@target_all = false
end
return @target_all
end
def inverse_target
if @inverse_target == nil
@inverse_target = false
end
return @inverse_target
end
def target_all=(target_all)
@target_all = target_all
end
def inverse_target=(inverse_target)
@inverse_target = inverse_target
end
end
module RPG
class Skill
def all_available
return TargetExt::TARGET_ALL_S.include?(@id)
end
end
class Item
def all_available
return TargetExt::TARGET_ALL_I.include?(@id)
end
end
class UsableItem
def need_selection?
return !(@scope == 11 || @scope == 0)
end
end
end
class Scene_Battle
alias crmsn_end_target end_target_selection
def end_target_selection(*args)
if @cursor2 != nil
dispose_cursor_all
end
crmsn_end_target(*args)
end
def cursor_all_visible(value)
for cursor in @cursor2
cursor.visible = value
end
end
def dispose_cursor_all
return if @cursor2 == nil
for cursor in @cursor2
cursor.dispose
cursor = nil
end
@cursor2 = nil
end
alias targetext_execute_action execute_action
def execute_action
targetext_execute_action
@active_battler.target_all = false
@active_battler.inverse_target = false
end
end
class Game_BattleAction
def make_attack_targets
targets = []
if battler.confusion?
targets.push(friends_unit.random_target)
elsif battler.berserker?
targets.push(opponents_unit.random_target)
else
targets.push(opponents_unit.smooth_target(@target_index)) unless battler.inverse_target
targets.push(friends_unit.smooth_target(@target_index)) if battler.inverse_target
end
if battler.dual_attack # Chain attack
targets += targets
end
return targets.compact
end
#--------------------------------------------------------------------------
# * Create Skill or Item Targets
# obj : Skill or item
#--------------------------------------------------------------------------
def make_obj_targets(obj)
targets = []
if obj.for_opponent?
if obj.for_random?
if obj.for_one? # One random enemy
number_of_targets = 1
elsif obj.for_two? # Two random enemies
number_of_targets = 2
else # Three random enemies
number_of_targets = 3
end
number_of_targets.times do
targets.push(opponents_unit.random_target) unless battler.inverse_target
targets.push(friends_unit.random_target) if battler.inverse_target
end
elsif obj.dual? # One enemy, dual
targets.push(opponents_unit.smooth_target(@target_index)) unless battler.inverse_target
targets.push(friends_unit.smooth_target(@target_index)) if battler.inverse_target
targets += targets
elsif obj.for_one?
if obj.all_available && battler.target_all
targets += opponents_unit.existing_members unless battler.inverse_target
targets += friends_unit.existing_members if battler.inverse_target
else
targets.push(opponents_unit.smooth_target(@target_index)) unless battler.inverse_target
targets.push(friends_unit.smooth_target(@target_index)) if battler.inverse_target
end
else # All enemies
targets += opponents_unit.existing_members unless battler.inverse_target
targets += friends_unit.existing_members if battler.inverse_target
end
elsif obj.for_user? # User
targets.push(battler)
elsif obj.for_dead_friend?
if obj.for_one? # One ally (incapacitated)
targets.push(friends_unit.smooth_dead_target(@target_index)) unless battler.inverse_target
targets.push(opponents_unit.smooth_target(@target_index)) if battler.inverse_target
else # All allies (incapacitated)
targets += friends_unit.dead_members unless battler.inverse_target
targets += opponents_unit.existing_members if battler.inverse_target
end
elsif obj.for_friend?
if obj.for_one? # One ally
if obj.all_available && battler.target_all
targets += friends_unit.existing_members unless battler.inverse_target
targets += opponents_unit.existing_members if battler.inverse_target
else
targets.push(friends_unit.smooth_target(@target_index)) unless battler.inverse_target
targets.push(opponents_unit.smooth_target(@target_index)) if battler.inverse_target
end
else # All allies
targets += friends_unit.existing_members unless battler.inverse_target
targets += opponents_unit.existing_members if battler.inverse_target
end
end
return targets.compact
end
end
class Sprite_Battler
def moving_anime
# まだ�‰�の�‚��ƒ‹�ƒ��›ば�—�Œ�‹って�„�‚‹な�‚‰�ˆ��œŸ�Œ–
@move_anime.action_reset if @anime_moving
@anime_moving = true
# �ƒ��ƒƒ�‚��‚��‚��ƒƒ�‚�中は�‚��ƒ‹�ƒ��€�武�
��”��ƒ�反転
mirror = false
mirror = true if $back_attack
# �‚��ƒ‹�ƒ�ID
id = @active_action[1]
# 対象
target = @active_action[2]
x = y = mem = 0
# 対象�Œ�˜�“の場�ˆ
if target == 0
# �‚��ƒ��‚��ƒƒ�ƒˆ�Œ決まってな�„場�ˆ�€��‡�身に�‰�›
if @target_battler == nil
x = self.x
y = self.y
else
# �‚��ƒ��‚��ƒƒ�ƒˆ�Œ空の場�ˆ�€��‡�身に�‰�›
if @target_battler[0] == nil
x = self.x
y = self.y
else
# �œ€�ˆ�に�…�って�„�‚‹�‚��ƒ��‚��ƒƒ�ƒˆに対象決�š
x = @target_battler[0].position_x
y = @target_battler[0].position_y
end
end
# 対象�Œ�•�の中�ƒの場�ˆ
elsif target == 1
# �‡�身�Œ�‚��‚��‚��ƒ�の場�ˆは�‚��ƒ��ƒŸ�ƒ�の中�ƒ�‚’�ˆ�—
if (@battler.is_a?(Game_Actor) && !@battler.inverse_target)
for target in $game_troop.members
bitmap = Cache.battler(target.battler_name, target.battler_hue)
ox = bitmap.width/2
oy = bitmap.height/2
x += target.position_x + ox
y += target.position_y + oy
mem += 1
end
x /= mem
y /= mem
# �‡�身�Œ�‚��ƒ��ƒŸ�ƒ�の場�ˆは�‚��‚��‚��ƒ�の中�ƒ�‚’�ˆ�—
else
for target in $game_party.members
ox = 16
oy = 16
x += target.position_x + ox
y += target.position_y + oy
mem += 1
end
x /= mem
y /= mem
end
# 対象�Œ�‘��–�の中�ƒの場�ˆ
elsif target == 2
# �‡�身�Œ�‚��‚��‚��ƒ�の場�ˆは�‚��‚��‚��ƒ�の中�ƒ�‚’�ˆ�—
if @battler.is_a?(Game_Actor)
for target in $game_party.members
x += target.position_x
y += target.position_y
mem += 1
end
x = x / mem
y = y / mem
# �‡�身�Œ�‚��ƒ��ƒŸ�ƒ�の場�ˆは�‚��ƒ��ƒŸ�ƒ�の中�ƒ�‚’�ˆ�—
else
for target in $game_troop.members
x += target.position_x
y += target.position_y
mem += 1
end
x = x / mem
y = y / mem
end
# 対象�Œ�‡�身の場�ˆ
else
x = self.x
y = self.y
end
# �–‹�‹位置の微調�•�
plus_x = @active_action[6]
plus_y = @active_action[7]
# �‚��ƒ��ƒŸ�ƒ�はX軸�‚’�€†に
plus_x *= -1 if @battler.is_a?(Game_Enemy)
# �œ€�‚�š„な移�‹•距�›��‚’�—�‡�
distanse_x = x - self.x - plus_x
distanse_y = y - self.y - plus_y
# �›ば�—�‚��‚��ƒ—
type = @active_action[3]
# �€Ÿ度
speed = @active_action[4]
# �Œ�“
orbit = @active_action[5]
# �‡�身�Œ�–‹�‹位置な�‚‰
if @active_action[8] == 0
@move_anime.base_x = self.x + plus_x
@move_anime.base_y = self.y + plus_y
# 対象�Œ�–‹�‹位置な�‚‰
elsif @active_action[8] == 1
@move_anime.base_x = x + plus_x
@move_anime.base_y = y + plus_y
# 距�›��‚’反対に
distanse_y = distanse_y * -1
distanse_x = distanse_x * -1
# �‹•�‹�•な�„な�‚‰
else
@move_anime.base_x = x
@move_anime.base_y = y
distanse_x = distanse_y = 0
end
# 武�
��‚��‚��‚��ƒ��ƒ�な�—は武�
�表示�—な�„
if @active_action[10] == ""
weapon = ""
# �‚��ƒ‹�ƒ�な�—�‚��ƒ��ƒŸ�ƒ�は武�
�表示�—な�„
elsif @anime_flug != true
weapon = ""
# 武�
��‚��‚��‚��ƒ��ƒ��Œ�‚�‚‹場�ˆ
else
# �›ば�
武�
��‚��ƒ��ƒ•�‚��ƒƒ�‚��Œ�Œ‡�š�•�‚Œて�„�‚‹�‹�ƒ��‚��ƒƒ�‚�
if @battler.is_a?(Game_Actor)
battler = $game_party.members[@battler.index]
weapon_id = battler.weapon_id
else
battler = $game_troop.members[@battler.index]
weapon_id = battler.weapon
end
# �‚��‚��ƒ��”��ƒ��ˆ��”��‹武�
��”��ƒ��ˆ��”��‹�ˆ��ˆ�
weapon_act = N01::ANIME[@active_action[10]].dup if @active_action[10] != ""
# 武�
��”��ƒ��ˆ��”�で素�‰‹でな�‘�‚Œば
if weapon_id != 0 && weapon_act.size == 3
weapon_file = $data_weapons[weapon_id].flying_graphic
# �ˆ��”��ƒ��Œ�Œ‡�š�•�‚Œて�„な�‘�‚Œば�—��˜の武�
��‚��ƒ��ƒ•�‚��ƒƒ�‚��‚’�–�—
if weapon_file == ""
weapon_name = $data_weapons[weapon_id].graphic
icon_weapon = false
# �•�‚‰に�Œ‡�š�Œな�‘�‚Œば�‚��‚��‚��ƒ��‚��ƒ��ƒ•�‚��ƒƒ�‚��‚’�ˆ��”�
if weapon_name == ""
weapon_name = $data_weapons[weapon_id].icon_index
icon_weapon = true
end
# �Œ‡�š�•�‚Œて�„�‚Œばその�‚��ƒ��ƒ•�‚��ƒƒ�‚�名�‚’�–�—
else
icon_weapon = false
weapon_name = weapon_file
end
# 武�
��‚��‚��‚��ƒ��ƒ��ƒ…報�‚’�–�—
weapon = @active_action[10]
# 武�
��”��ƒ��ˆ��”�で素�‰‹な�‚‰表示�—な�„
elsif weapon_act.size == 3
weapon = ""
# �‚��‚��ƒ��”��ƒ��ˆ��”�
elsif weapon_act != nil && @battler.action.skill != nil
icon_weapon = false
weapon_name = $data_skills[@battler.action.skill.id].flying_graphic
weapon = @active_action[10]
end
end
# Z座�
�‚’決�š
@move_anime.z = 1
@move_anime.z = 1000 if @active_action[9]
# 以�Šの�ƒ…報�‚’�…�て�‚��ƒ‹�ƒ��›ば�—�‚��ƒ—�ƒ��‚��ƒˆに�€��‚‹
@move_anime.anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,weapon_name,icon_weapon)
end
end
class Game_Battler
alias targetext_make_obj_dmg make_obj_damage_value
def make_obj_damage_value(user, obj)
targetext_make_obj_dmg(user, obj)
if user.target_all && obj.all_available
if @hp_damage != 0
@hp_damage *= TargetExt::DAMAGE_PERCENT
@hp_damage /= 100
@hp_damage /= user.action.make_targets.size if TargetExt::DAMAGE_DIVIDE && user.target_all
end
if @mp_damage != 0
@mp_damage *= TargetExt::DAMAGE_PERCENT
@mp_damage /= 100
@mp_damage /= user.make_targets.size if TargetExt::DAMAGE_DIVIDE && user.target_all
end
end
end
alias targetext_calc_mp_cost calc_mp_cost
def calc_mp_cost(skill)
cost = targetext_calc_mp_cost(skill)
if self.target_all && skill.all_available
cost *= TargetExt::MP_PERCENT
cost /= 100
end
return cost
end
end