#==============================================================================
# +++ MOG - Scope EX (v1.5) +++
#==============================================================================
# By Moghunter
# [url]https://atelierrgss.wordpress.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.5 Correção de ativar o sistema sem fazer comentário na caixa de notas.
# v1.4 Compatibilidade com MOG Sprite Actor.
# 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.
#
#==============================================================================
#首先请把技能的目标设成单个敌人或单个队友或使用者
#技能备注里
#<Scope Range = 120 - 120 - 64 - 40>
#目标两侧120像素,向上64像素,向下40像素
#技能对上述范围内的目标生效
#<All Targets>
#范围内全部目标,不分敌我
#如果备注里填入
#<All Targets>
#<Scope Range = 544 - 544 - 416 - 416>
#那好吧,这是一个地地道道的全屏范围的技能,当然你的画面尺寸是544*416.
#精灵尺寸,大概是给怪物图设个尺寸来代替怪物图原本的尺寸
#SPRITE_SIZE_RANGE = [80,70]
#范围类型,大概是0表示用怪物图原本的尺寸,而1是用上面设置的尺寸
#SCOPE_TYPE = 1
#以上两个设定会影响到范围的计算,细微之处不是很确定。
$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 $imported[:mog_battler_motion] != nil and $imported[:mog_sprite_actor] != nil
return @subject.pre_target if @subject != nil and @subject.pre_target != nil
end
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+)>/
return false if s_r == [0,0,0,0]
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