module PC27
module CrAn
DEFAULT_CRITICAL_CALC = true
# If this switch is not equal to 0, this switch can be used to turn the
# animation ON or OFF.
Switch = 0
# The two picture id's the script uses to draw the animation. Do not use
# them for other "Show Pictures" events.
ActorPicture = 2
BackPicture = 1
# Number of frames the image needs to slide in/out
SlideInTime = 20
SlideOutTime = 20
# Number of frames the image stays and distance it moves in that time
LingerTime = 60
LingerDistance = 100
# This is the sound played at the begin of the animation and the number
# of frames you want to wait before the picture shows up.
InitSound = "Absorb1"
InitWait = 30
# Those are actor specific sounds. It plays one random sound.
ActorSounds = {
# Actor_ID => [ "sound1", "sound2", ...],
1 => [ "Water4", "Water1", "Water3"],
2 => [ "Absorb1", "Fire1", "Fire2"],
# 3 => [...
}
end
end
class Scene_Battle
include PC27::CrAn
alias pc27_crit_effect_show_animation show_animation
def show_animation(targets, animation_id)
item = @subject.current_action.item
if item.damage.none?
targets.each { |target| target.set_crit_to_false }
else
targets.each { |target| target.eval_crit(@subject, item) }
end
show_critical_animation if actor_crit?(targets)
pc27_crit_effect_show_animation(targets, animation_id)
end
def show_critical_animation
lo = LingerDistance * 0.5
play_initial_sound
show_crit_background
show_crit_actor
move_crit_actor(Graphics.width * 0.5 - lo, SlideInTime)
play_random_actor_sound(@subject)
move_crit_actor(Graphics.width * 0.5 + lo, LingerTime)
move_crit_actor(Graphics.width + 50, SlideOutTime)
erase_crit_actor
erase_crit_background
end
def play_initial_sound
RPG::SE.new(InitSound).play
wait(InitWait)
end
def play_random_actor_sound(subject)
RPG::SE.new(ActorSounds[subject.id].sample).play
end
def show_crit_actor
name = @subject.name + "CritImg"
y = Graphics.height * 0.5
pic = $game_troop.screen.pictures[ActorPicture]
pic.show(name, 1, -50, y, 100, 100, 255, 0)
end
def move_crit_actor(x, time)
y = Graphics.height * 0.5
pic = $game_troop.screen.pictures[ActorPicture]
pic.move(1, x, y, 100, 100, 255, 0, time)
wait(time)
end
def erase_crit_actor
$game_troop.screen.pictures[ActorPicture].erase
end
def show_crit_background
x = Graphics.width * 0.5
y = Graphics.height * 0.5
pic = $game_troop.screen.pictures[BackPicture]
pic.show("CritBG", 1, x, y, 100, 100, 255, 0)
end
def erase_crit_background
$game_troop.screen.pictures[BackPicture].erase
end
def actor_crit?(targets)
return false unless Switch == 0 || $game_switches[Switch]
return false unless @subject.is_a?(Game_Actor)
targets.any? {|target| target.result.critical }
end
end
class Game_Battler
def eval_crit(user, item)
@result.critical = (rand < item_cri(user, item))
end
def set_crit_to_false
@result.critical = false
end
def item_apply(user, item)
default_crit = PC27::CrAn::DEFAULT_CRITICAL_CALC
crit = @result.critical unless default_crit
@result.success = false
@result.used = item_test(user, item)
@result.missed = (@result.used && rand >= item_hit(user, item))
@result.evaded = ([email protected] && rand < item_eva(user, item))
if @result.hit?
unless item.damage.none?
@result.critical = default_crit ? (rand < item_cri(user, item)) : crit
make_damage_value(user, item)
execute_damage(user)
end
item.effects.each {|effect| item_effect_apply(user, item, effect) }
item_user_effect(user, item)
end
end
end