I'm using this script made by pencilcase27 that basically takes an image and has it glide across the screen when an actor lands a critical hit. In order for the image to be triggered by the script, the file needs to be named in a specific way using the actor's name (actorname+Critimg). However, I wanted to edit the script so that it references the actor's id instead of their name. The reason being that if I were to edit a character's name through the name processor event, the script no longer works, since the name has changed. I would contact pencilcase27 himself, but he hasn't been active for over a year.
I know I need to edit this line, but I'm not exactly sure what to change "@subject.name" to.
def show_crit_actor
name = @subject.name + "CritImg" #@subject.name
Any help at all would be greatly appreciated! 😀
Here's the full script:
I know I need to edit this line, but I'm not exactly sure what to change "@subject.name" to.
def show_crit_actor
name = @subject.name + "CritImg" #@subject.name
Any help at all would be greatly appreciated! 😀
Here's the full script:
module PC27
module CrAn
# 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 => [ "impact_02" ],
2 => [ "impact_02" ],
3 => [ "impact_02" ],
4 => [ "impact_02" ],
5 => [ "impact_02" ],
6 => [ "impact_02" ],
7 => [ "impact_02" ],
8 => [ "impact_02" ],
9 => [ "impact_02" ],
10 => [ "impact_02" ],
}
end
end
class Scene_Battle
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 = PC27::CrAn::LingerDistance * 0.5
play_initial_sound
show_crit_background
show_crit_actor
move_crit_actor(Graphics.width * 0.5 - lo, PC27::CrAn::SlideInTime)
play_random_actor_sound(@subject)
move_crit_actor(Graphics.width * 0.5 + lo, PC27::CrAn::LingerTime)
move_crit_actor(Graphics.width + 50, PC27::CrAn::SlideOutTime)
erease_crit_actor
erease_crit_background
end
def play_initial_sound
RPG::SE.new(PC27::CrAn::InitSound).play
wait(PC27::CrAn::InitWait)
end
def play_random_actor_sound(subject)
RPG::SE.new(PC27::CrAn::ActorSounds[subject.id].sample).play
end
def show_crit_actor
name = @subject.name + "CritImg" #@subject.name
y = Graphics.height * 0.5
$game_troop.screen.pictures[PC27::CrAn::ActorPicture].show(name,
1, -50, y, 100, 100, 255, 0)
end
def move_crit_actor(x, time)
y = Graphics.height * 0.5
$game_troop.screen.pictures[PC27::CrAn::ActorPicture].move(1,
x, y, 100, 100, 255, 0, time)
wait(time)
end
def erease_crit_actor
$game_troop.screen.pictures[PC27::CrAn::ActorPicture].erase
end
def show_crit_background
x = Graphics.width * 0.5
y = Graphics.height * 0.5
$game_troop.screen.pictures[PC27::CrAn::BackPicture].show("CritBG",
1, x, y, 100, 100, 255, 0)
end
def erease_crit_background
$game_troop.screen.pictures[PC27::CrAn::BackPicture].erase
end
def actor_crit?(targets)
return false unless (PC27::CrAn::Switch == 0 || $game_switches[PC27::CrAn::Switch])
return false unless @subject.is_a?(Game_Actor)
targets.each do |target|
return true if target.result.critical
end
return false
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)
crit = @result.critical
@result.clear
@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 = 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
module CrAn
# 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 => [ "impact_02" ],
2 => [ "impact_02" ],
3 => [ "impact_02" ],
4 => [ "impact_02" ],
5 => [ "impact_02" ],
6 => [ "impact_02" ],
7 => [ "impact_02" ],
8 => [ "impact_02" ],
9 => [ "impact_02" ],
10 => [ "impact_02" ],
}
end
end
class Scene_Battle
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 = PC27::CrAn::LingerDistance * 0.5
play_initial_sound
show_crit_background
show_crit_actor
move_crit_actor(Graphics.width * 0.5 - lo, PC27::CrAn::SlideInTime)
play_random_actor_sound(@subject)
move_crit_actor(Graphics.width * 0.5 + lo, PC27::CrAn::LingerTime)
move_crit_actor(Graphics.width + 50, PC27::CrAn::SlideOutTime)
erease_crit_actor
erease_crit_background
end
def play_initial_sound
RPG::SE.new(PC27::CrAn::InitSound).play
wait(PC27::CrAn::InitWait)
end
def play_random_actor_sound(subject)
RPG::SE.new(PC27::CrAn::ActorSounds[subject.id].sample).play
end
def show_crit_actor
name = @subject.name + "CritImg" #@subject.name
y = Graphics.height * 0.5
$game_troop.screen.pictures[PC27::CrAn::ActorPicture].show(name,
1, -50, y, 100, 100, 255, 0)
end
def move_crit_actor(x, time)
y = Graphics.height * 0.5
$game_troop.screen.pictures[PC27::CrAn::ActorPicture].move(1,
x, y, 100, 100, 255, 0, time)
wait(time)
end
def erease_crit_actor
$game_troop.screen.pictures[PC27::CrAn::ActorPicture].erase
end
def show_crit_background
x = Graphics.width * 0.5
y = Graphics.height * 0.5
$game_troop.screen.pictures[PC27::CrAn::BackPicture].show("CritBG",
1, x, y, 100, 100, 255, 0)
end
def erease_crit_background
$game_troop.screen.pictures[PC27::CrAn::BackPicture].erase
end
def actor_crit?(targets)
return false unless (PC27::CrAn::Switch == 0 || $game_switches[PC27::CrAn::Switch])
return false unless @subject.is_a?(Game_Actor)
targets.each do |target|
return true if target.result.critical
end
return false
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)
crit = @result.critical
@result.clear
@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 = 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