#==============================================================================
# +++ MOG - Scope EX (v1.3) +++
#==============================================================================
# By Moghunter
# [url]http://www.atelier-rgss.com/[/url]
#==============================================================================
# Adiciona a característica de área de impacto da ação baseado na posição
# e o tamanho do sprite do alvo.
# Por exemplo, uma habilidade de explosão vai acertar apenas os inimigos que
# estiverem em volta do alvo inicial.
# O script adiciona também a função de incluir todos os alvos da tela, aliados
# e inimigos juntos.
#==============================================================================
# Adicione a Tag abaixo na caixa de comentários de notas para definir a área de
# impacto da habilidade.
#
# <Scope Range = X1 - X2 - Y1 - Y2>
#
# Y1
#
# X1 X2
#
# Y2
#
# Ex -> <Scope Range = (100 - 32 - 64 - 32>
#
#==============================================================================
# Incluir todos os alvos da tela. (Inimigos e Aliados)
#==============================================================================
#
# <All Targets>
#
#==============================================================================
# Histórico
#==============================================================================
# v1.3 Melhoria no cálculo de área em alvos únicos.
# v1.2 Melhoria no sistema de calculo baseado no tamanho do sprite.
# v1.1 Possibilidade de definir a área específica para cada lado.
#
#==============================================================================
$imported = {} if $imported.nil?
$imported[:mog_scope_ex] = true
module MOG_SCOPE_EX
#============================================================================
# Definição do modo que vai ser calculado a área do alvo.
#
# 0 - Baseado apenas na posição X e Y. (ignorando o tamanho do sprite)
# 1 - Baseado na posição X e Y + o tamanho do sprite do alvo.
# (Alvos grandes tem maior area de impacto)
#
#============================================================================
SCOPE_TYPE = 1
#============================================================================
# Definição da porcentágem total do tamanho sprite, para ser efetuado o
# calculo. (Apenas se o valor do SCOPE_TYPE estiver no 1)
# Por exemplo, definindo o valor de 100% o sistema vai considerar 100% do
# tamanho do sprite para fazer o calculo.
#============================================================================
# SPRITE_SIZE_RANGE = [WIDTH %, HEIGHT %]
#============================================================================
SPRITE_SIZE_RANGE = [80,70]
end
#==============================================================================
# ■ Game Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
attr_accessor :sprite_size
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
alias mog_scope_ex_initialize initialize
def initialize
@sprite_size = [0,0,true]
mog_scope_ex_initialize
end
end
#==============================================================================
# ■ Sprite Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# * Update Bitmap
#--------------------------------------------------------------------------
alias mog_scope_ex_update_bitmap update_bitmap
def update_bitmap
@battler.sprite_size = [bitmap.width,bitmap.height,true] if bitmap
mog_scope_ex_update_bitmap
end
end
#==============================================================================
# ■ Scene Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Show Normal Animation
#--------------------------------------------------------------------------
alias mog_scope_ex_show_normal_animation show_normal_animation
def show_normal_animation(targets, animation_id, mirror = false)
new_targets = []
targets.each do |t| new_targets.push(t) if t.sprite_size[2] end
targets = new_targets
mog_scope_ex_show_normal_animation(targets, animation_id, mirror)
targets.each do |t| t.sprite_size[2] = true end
end
end
#==============================================================================
# ■ Game Action
#==============================================================================
class Game_Action
include MOG_SCOPE_EX
#--------------------------------------------------------------------------
# * Make Targets
#--------------------------------------------------------------------------
def make_targets
if !forcing && subject.confusion?
confusion_target
elsif item.for_opponent?
targets_for_opponents
elsif item.for_friend?
targets_for_friends
else
[]
end
end
#--------------------------------------------------------------------------
# * Confusion Target
#--------------------------------------------------------------------------
def confusion_target
case subject.confusion_level
when 1 ; new_targets = make_new_targets([opponents_unit.random_target],0)
when 2
if rand(2) == 0
new_targets = make_new_targets([opponents_unit.random_target],0)
else
new_targets = make_new_targets([friends_unit.random_target],1)
end
else
new_targets = make_new_targets([friends_unit.random_target],1)
end
end
#--------------------------------------------------------------------------
# * Targets for Opponents
#--------------------------------------------------------------------------
def targets_for_opponents
if item.for_random?
org_target = Array.new(item.number_of_targets) { opponents_unit.random_target }
new_targets = make_new_targets(org_target,0)
elsif item.for_one?
num = 1 + (attack? ? subject.atk_times_add.to_i : 0)
if @target_index < 0
org_target = [opponents_unit.random_target] * num
new_targets = make_new_targets(org_target,0)
else
org_target = [opponents_unit.smooth_target(@target_index)] * num
new_targets = make_new_targets(org_target,0)
end
else
return (opponents_unit.alive_members + friends_unit.alive_members) if all_targets
return opponents_unit.alive_members
end
end
#--------------------------------------------------------------------------
# * All Targets
#--------------------------------------------------------------------------
def all_targets
return true if @item.object.note =~ /<All Targets>/
return false
end
#--------------------------------------------------------------------------
# * Targets for Allies
#--------------------------------------------------------------------------
def targets_for_friends
if item.for_user?
new_targets = make_new_targets([subject],1)
elsif item.for_dead_friend?
if item.for_one?
org_target = [friends_unit.smooth_dead_target(@target_index)]
new_targets = make_new_targets(org_target,2)
else
org_target = friends_unit.dead_members
new_targets = make_new_targets(org_target,2)
end
elsif item.for_friend?
if item.for_one?
org_target = [friends_unit.smooth_target(@target_index)]
new_targets = make_new_targets(org_target,1)
else
return (opponents_unit.alive_members + friends_unit.alive_members) if all_targets
return friends_unit.alive_members
end
end
end
#--------------------------------------------------------------------------
# * Make New Targets
#--------------------------------------------------------------------------
def make_new_targets(target,type = 0)
targets = []
if all_targets
members = (opponents_unit.alive_members + friends_unit.alive_members) if type <= 1
members = friends_unit.dead_members if type == 2
else
members = opponents_unit.alive_members if type == 0
members = friends_unit.alive_members if type == 1
members = friends_unit.dead_members if type == 2
end
for t in target
for m in members
targets.push(m) if t == m
next if t == m
(targets.push(m); m.sprite_size[2] = false) if scope_range?(t,m)
end
end
return targets
end
#--------------------------------------------------------------------------
# * Scope Range
#--------------------------------------------------------------------------
def scope_range?(user,target)
t_r2 = [user.screen_x, user.screen_y] rescue nil
t_r3 = [target.screen_x, target.screen_y] rescue nil
return false if t_r2 == nil or t_r3 == nil
s_r = [0,0,0,0] ; s_p = [0,0]
s_r = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] if @item.object.note =~ /<Scope Range = (\d+) - (\d+) - (\d+) - (\d+)>/
if SCOPE_TYPE > 0
s_p = [target.sprite_size[0] / 2, target.sprite_size[1]]
s_p[0] = s_p[0] * SPRITE_SIZE_RANGE[0] / 100
s_p[1] = s_p[1] * SPRITE_SIZE_RANGE[1] / 100
end
return false if !t_r3[0].between?(t_r2[0] - (s_r[0] + s_p[0]), t_r2[0] + (s_r[1] + s_p[0]))
return false if !t_r3[1].between?(t_r2[1] - s_r[2], t_r2[1] + s_r[3] + s_p[1])
return true
end
end