La suite à coller dans le même script :
def enemy #
$target_index += $game_troop.enemies.size
$target_index %= $game_troop.enemies.size
return $game_troop.enemies[$target_index] #
end #
def actor #
$target_index += $game_party.actors.size
$target_index %= $game_party.actors.size
return $game_party.actors[$target_index] #
end
#==============================================================================
# here is a snipplet from RPG's script...
# i changed only to lines from this...
#
# here you can add more sprite poses... if you have more... ^-^
#==============================================================================
def pose(number, frames = 4)
case number
when 0 # run
change(frames, 5, 0, 0, 0)
when 1 # standby
change(frames, 5, 0, @frame_height)
when 2 # defend
change(frames, 5, 0, @frame_height * 2)
when 3 # Hurt, loops
change(frames, 5, 0, @frame_height * 3)
when 4 # attack no loop
change(frames, 5, 0, @frame_height * 4, 0, true)
when 5 # skill
change(frames, 5, 0, @frame_height * 5)
when 6 # death
change(frames, 5, 0, @frame_height * 6)
when 7 # no sprite
change(frames, 5, 0, @frame_height * 7)
#when 8
# change(frames, 5, 0, @frame_height * 9)
# ...etc.
else
change(frames, 5, 0, 0, 0)
end
end
#--------------------------------------------------------------------------
# - Change the battle pose for an enemy
# number : pose' number
#--------------------------------------------------------------------------
def enemy_pose(number ,enemy_frames = 4)
case number
when 0 # run
change(enemy_frames, 5, 0, 0, 0)
when 1 # standby
change(enemy_frames, 5, 0, @frame_height)
when 2 # defend
change(enemy_frames, 5, 0, @frame_height * 2)
when 3 # Hurt, loops
change(enemy_frames, 5, 0, @frame_height * 3)
when 4 # attack
change(enemy_frames, 5, 0, @frame_height * 4, 0, true)
when 5 # skill
change(enemy_frames, 5, 0, @frame_height * 5)
when 6 # death
change(enemy_frames, 5, 0, @frame_height * 6)
when 7 # no sprite
change(enemy_frames, 5, 0, @frame_height * 7)
# ...etc.
else
change(enemy_frames, 5, 0, 0, 0)
end
end
def default_pose
pose(1)
# here we change the default pose when the character
# dont have over 75 % percent of the max hp
# if HP is too low (- 25%)
if (@battler.hp * 100) /@battler.maxhp < 25
pose(9)
# if HP is too low (- 50%)
elsif (@battler.hp * 100) /@battler.maxhp < 50
pose(9)
# if HP is too low (- 75%)
elsif (@battler.hp * 100) /@battler.maxhp < 75
pose(9)
end
# and here we change the pose if the character is inflicted with
# poison or other stuff like sleep, paralyzed, confused or other stuff...
# i only added the poison and sleep for test...
if @battler.state?(3) # poison
# change pose to sleep pose...
# (i dont have so much sprites... so im the defend pose)
# you can set more status effects so each effect has its own sprite...
pose(2)
elsif @battler.state?(7) #sleep
# change pose to poisoned
pose(6)
end
end
#==============================================================================
# sniplet end...
#==============================================================================
def update
super
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
if @battler.name != @battler_name
@battler.battler_hue != @battler_hue
@battler_hue = @battler.battler_hue
@battler_name = @battler.name
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @frame_width / 2
self.oy = @frame_height
if @battler.dead? or @battler.hidden
self.opacity = 0
end
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
if $noanimation == false
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
else
dispose_loop_animation
end
if @battler.is_a?(Game_Actor) and @battler_visible
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
if @battler.blink
blink_on
else
blink_off
end
unless @battler_visible
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@battler_visible = true
end
if not @battler.hidden and
(@battler.damage == nil or @battler.damage_pop) and
@battler.is_a?(Game_Actor)
appear
@battler_visible = true
end
end
if @battler_visible
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
if @battler.white_flash
whiten
@battler.white_flash = false
end
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
collapse
@battler_visible = false
else
$game_system.se_play($data_system.actor_collapse_se) unless @dead
@dead = true
pose(6)
end
else
@dead = false
end
end #
end
end
#==============================================================================
# Scene_Battle Costum Battle System
#==============================================================================
class Scene_Battle
def update_phase4
case @phase4_step
when 1
update_phase4_step1
when 2
update_phase4_step2
when 3
update_phase4_step3
when 4
update_phase4_step4
when 5
update_phase4_step5
when 6
update_phase4_step6
when 7
update_phase4_step7
end
end
def update_phase4_step1
# Change actor poses to default
#if @active_battler.is_a?(Game_Actor)
# @spriteset.actor_sprites[@active_battler.index].default_pose
#end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
@spriteset.actor_sprites[i].default_pose unless actor.dead?
end
@help_window.visible = false
if judge
return
end
if $game_temp.forcing_battler == nil
setup_battle_event
if $game_system.battle_interpreter.running?
return
end
end
if $game_temp.forcing_battler != nil
@action_battlers.delete($game_temp.forcing_battler)
@action_battlers.unshift($game_temp.forcing_battler)
end
if @action_battlers.size == 0
start_phase2
return
end
@animation1_id = 0
@animation2_id = 0
@common_event_id = 0
@active_battler = @action_battlers.shift
if @active_battler.index == nil
return
end
if @active_battler.hp > 0 and @active_battler.slip_damage?
@active_battler.slip_damage_effect
@active_battler.damage_pop = true
end
@active_battler.remove_states_auto
@status_window.refresh
@phase4_step = 2
end
def make_basic_action_result
if @active_battler.is_a?(Game_Actor)
$actor_on_top = true
elsif @active_battler.is_a?(Game_Enemy)
$actor_on_top = false
end
if @active_battler.current_action.basic == 0
#============================================================================
# WEAPONS START...
#============================================================================
#
#================================= Different Weapons with different animations
#
# this is quite simple as you can see...
# if you want to add a weapon to the animation list then look at the script below...
# and i hope you'll find out how this works...
#
#
# if not...
# here is the way...
# first thing...
# just copy and paste "elseif @active_battler_enemy.weapon_id == ID..."
# just after the last @weapon_sprite....
#
# here the ID is you need to look in you game databse the number that stands before
# your weapon name is the ID you need to input here...
#
# same thing goes for the monster party... ^-^
# monster normaly dont need more sprites for weapons....
#
# if you want to use more... then replace the "@weapon_sprite_enemy = 4"
# with these lines... (but you need to edit them)
#
# if @active_battler.weapon_id == 1 # <-- weapon ID number
# @weapon_sprite_enemy = 4 # <-- battle animation
# elsif @active_battler.weapon_id == 5 # <-- weapon ID number
# @weapon_sprite_enemy = 2 # <-- battle animation
# elsif @active_battler.weapon_id == 9 # <-- weapon ID number
# @weapon_sprite_enemy = 0 # <-- battle animation
# elsif @active_battler.weapon_id == 13 # <-- weapon ID number
# @weapon_sprite_enemy = 6 # <-- battle animation
# else
# @weapon_sprite_enemy = 4
# end
#
#================================= END
if @active_battler.is_a?(Game_Actor)
if @active_battler.weapon_id == 1 # <-- weapon ID number
@weapon_sprite = 4 # <-- battle animation
elsif @active_battler.weapon_id == 5 # <-- weapon ID number
@weapon_sprite = 2 # <-- battle animation
elsif @active_battler.weapon_id == 9 # <-- weapon ID number
@weapon_sprite = 0 # <-- battle animation
elsif @active_battler.weapon_id == 13 # <-- weapon ID number
@weapon_sprite = 6 # <-- battle animation
else
@weapon_sprite = 4
end
# monster section is here... ^-^
else# @active_battler.is_a?(Game_Enemy)
@weapon_sprite_enemy = 4
end
#
#=============================================================================
# WEAPONS END....
#=============================================================================
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
#======== here is the setting for the movement & animation...
x = target.screen_x - 32
@spriteset.enemy_sprites[@active_battler.index].enemy_pose(0)
@spriteset.enemy_sprites[@active_battler.index]\
.move(x, target.screen_y, 10)
#========= here if you look at the RPG's movement settings you'll see
#========= that he takes the number 40 for the speed of the animation...
#========= i thing thats too fast so i settet it down to 10 so looks smoother...
end
if @active_battler.is_a?(Game_Actor)
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
#======= the same thing for the player... ^-^
x = target.screen_x + 32
@spriteset.actor_sprites[@active_battler.index].pose(0)
@spriteset.actor_sprites[@active_battler.index]\
.move(x, target.screen_y, 10)
end
@target_battlers = [target]
for target in @target_battlers
target.attack_effect(@active_battler)
end
return
end
if @active_battler.current_action.basic == 1
if @active_battler.is_a?(Game_Actor)
@spriteset.actor_sprites[@active_battler.index].pose(2) #defence
else
@spriteset.enemy_sprites[@active_battler.index].enemy_pose(2) #defence
end
@help_window.set_text($data_system.words.guard, 1)
return
end
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
@help_window.set_text("Escape", 1)
@active_battler.escape
return
end
if @active_battler.current_action.basic == 3
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
if @active_battler.current_action.basic == 4
if $game_temp.battle_can_escape == false
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
update_phase2_escape
return
end
end
#--------------------------------------------------------------------------
# skill aktion...
#--------------------------------------------------------------------------
def make_skill_action_result
@skill = $data_skills[@active_battler.current_action.skill_id]
unless @active_battler.current_action.forcing
unless @active_battler.skill_can_use?(@skill.id)
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
end
@active_battler.sp -= @skill.sp_cost
@status_window.refresh
@help_window.set_text(@skill.name, 1)
#=============================================================================
# SKILL SPRITES START
#=============================================================================
# this one is the same as the one for the weapons...
# for the one who have this for the first time
# look at the script i hope it is easy to understand...
#
# the other one that have the earlier versions of this script they dont need explenation
# ... i think....
# the think that changed is the line where the animation ID is given to the sprite...
# the number after the "pose" is the animation ID... it goes for every other animation as well..
# if you have an animation for a skill that have more frames...
# then just insert the number of frames after the first number...
# so it looks like this.... "pose(5,
" <-- 5 is the animation...
# 8 is the max frame (that means your animation have 8 frames...) ^-^
if @active_battler.is_a?(Game_Actor)
if @skill.name == "Heal" # <-- first skill name
@spriteset.actor_sprites[@active_battler.index].pose(5) # <-- sprite number
elsif @skill.name == "Cross Cut" # <-- secound skill name
@spriteset.actor_sprites[@active_battler.index].pose(6) # <-- sprite number
elsif @skill.name == "Fire" # <-- third skill name
@spriteset.actor_sprites[@active_battler.index].pose(6) # <-- sprite number
end
else
if @skill.name == "Heal" # <-- first skill name
@spriteset.enemy_sprites[@active_battler.index].enemy_pose(5) # <-- sprite number
elsif @skill.name == "Cross Cut" # <-- secound skill name
@spriteset.enemy_sprites[@active_battler.index].enemy_pose(6) # <-- sprite number
elsif @skill.name == "Fire" # <-- third skill name
@spriteset.enemy_sprites[@active_battler.index].enemy_pose(6) # <-- sprite number
end
end
#=============================================================================
# SKILL SPRITES END
#=============================================================================
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
@common_event_id = @skill.common_event_id
set_target_battlers(@skill.scope)
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# how here we make the item use aktions
#--------------------------------------------------------------------------
def make_item_action_result
# sorry i didnt work on this...
# couse i dont have a sprite that uses items....
# so i just added the standby sprite here...
# when i get more time for this i'll try what i can do for this one... ^-^
# its the same as the ones above...
if @active_battler.is_a?(Game_Actor)
@spriteset.actor_sprites[@active_battler.index].pose(1)
else
@spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)
end