====== Sistema de Batalla de Kotfire ====== ===== Ficha Técnica ===== * **Nombre original:** Kotfire Custom Battle System * **Nombre del autor:** Kotfire * **Utilidad:** Sistema de batalla lateral * **Dependencia de otros Scripts:** No * **Incompatibilidad:** Desconocida ===== Instalación ===== Crea un script encima de "Main" para cada uno de los siguientes códigos. ==== Script principal ==== #============================================================================== # Kotfire Custom Battle System #============================================================================== # Script por: Kotfire # Versión 1.0 #----------------------------------------------------------------------------- # -Instrucciones- # Pegar encima de main y de todos los add-on para este script # Leer el archivo de texto adjunto donde están todas las instrucciones ampliadas # Editar las opciones a tu gusto # Disfrutar #============================================================================== # ■ Options #------------------------------------------------------------------------------ module Options module Cbs Animations = ["Stand", "Move_to", "Move_back", "Attack", "Skill", "Hit", "Guard", "Miss", "Dead", "Item", "Victory"] # Posiciones de las poses en la plantilla Stand = 0 Move_to = 1 Move_back = 2 Attack = 3 Skill = 4 Hit = 5 Guard = 6 Miss = 7 Dead = 8 Item = 9 Victory = 10 Default_frames = [84, 84] Move_speed = 10 Weapon = { 21 => [Attack, false] } Skill_Anim = { 57 => [11, false] } Actor_Frame = {} Enemy_Frame = {} Pose_Frames = { 0 => 3, 3 => 5, 4 => 5, 5 => 1, 6 => 1, 7 => 1, 8 => 1, 9 => 4, 10 => 6, 11 => 6 } Pose_Delay = {} end end #------------------------------------------------------------------------------ # - ATENCIÓN - #------------------------------------------------------------------------------ # NO EDITES NADA A PARTIR DE AQUÍ SI NO TIENES CONOCIMIENTOS DE RGSS #------------------------------------------------------------------------------ #============================================================================== # ■ Add-on Manager #------------------------------------------------------------------------------ # Basado en el SDK log system #------------------------------------------------------------------------------ module Add_on #--------------------------------------------------------------------------- @add_ons = [] @state = {} #--------------------------------------------------------------------------- def self.insert(name) @add_ons.push(name) @state[name] = true end #--------------------------------------------------------------------------- def self.enable(name) @state[name] = true end #--------------------------------------------------------------------------- def self.disable(name) @state[name] = false return end #--------------------------------------------------------------------------- def self.state(name) return @state[name] end #--------------------------------------------------------------------------- def self.scripts return @add_ons end end #============================================================================== # ■ Game_Battle #------------------------------------------------------------------------------ class Game_Battle #-------------------------------------------------------------------------- attr_accessor :animated_battlers attr_accessor :animated_enemies attr_accessor :move_battlers attr_accessor :move_enemies attr_accessor :mirror #-------------------------------------------------------------------------- def initialize @animated_battlers = true @animated_enemies = true @move_battlers = true @move_enemies = true @mirror = false end end #============================================================================== # ■ Scene_Title #------------------------------------------------------------------------------ class Scene_Title #-------------------------------------------------------------------------- alias kot_cbs_scenetitle_commandnewgame command_new_game def command_new_game $game_battle = Game_Battle.new kot_cbs_scenetitle_commandnewgame end #-------------------------------------------------------------------------- alias kot_cbs_scenetitle_battletest battle_test def battle_test $game_battle = Game_Battle.new kot_cbs_scenetitle_battletest end end #============================================================================== # ■ Scene_Load #------------------------------------------------------------------------------ class Scene_Load < Scene_File #------------------------------------ alias kot_cbs_sceneload_readsavedata read_save_data def read_save_data(file) kot_cbs_sceneload_readsavedata(file) $game_battle = Marshal.load(file) end end #============================================================================== # ■ Scene_Save #------------------------------------------------------------------------------ class Scene_Save < Scene_File #------------------------------------ alias kot_cbs_scenesave_writesavedata write_save_data def write_save_data(file) kot_cbs_scenesave_writesavedata(file) Marshal.dump($game_battle, file) end end #============================================================================== # ■ Spriteset_Battle #------------------------------------------------------------------------------ class Spriteset_Battle #-------------------------------------------------------------------------- attr_reader :viewport1 attr_reader :viewport2 #-------------------------------------------------------------------------- def initialize @viewport1 = Viewport.new(0, 0, 640, 320) @viewport2 = Viewport.new(0, 0, 640, 480) @viewport3 = Viewport.new(0, 0, 640, 480) @viewport4 = Viewport.new(0, 0, 640, 480) @viewport2.z = 101 @viewport3.z = 200 @viewport4.z = 5000 @battleback_sprite = Sprite.new(@viewport1) @enemy_sprites = [] for enemy in $game_troop.enemies.reverse @enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy)) end @actor_sprites = [] @actor_sprites.push(Sprite_Battler.new(@viewport1)) @actor_sprites.push(Sprite_Battler.new(@viewport1)) @actor_sprites.push(Sprite_Battler.new(@viewport1)) @actor_sprites.push(Sprite_Battler.new(@viewport1)) @weather = RPG::Weather.new(@viewport1) @picture_sprites = [] for i in 51..100 @picture_sprites.push(Sprite_Picture.new(@viewport3, $game_screen.pictures[i])) end @timer_sprite = Sprite_Timer.new update end end #============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ class Game_Battler #-------------------------------------------------------------------------- attr_accessor :sprite_delay attr_accessor :sprite_index attr_accessor :sprite_frames attr_accessor :frame_width attr_accessor :frame_height attr_accessor :real_dead attr_accessor :pose attr_accessor :repeat attr_accessor :moving attr_accessor :x attr_accessor :y attr_accessor :target_x attr_accessor :target_y attr_accessor :animate attr_accessor :anim_wait attr_reader :victory attr_reader :start_x attr_reader :start_y attr_reader :move_speed #-------------------------------------------------------------------------- alias kot_cbs_gamebattler_initialize initialize def initialize @sprite_delay = 8 @sprite_index = -1 @sprite_frames = 4 @frame_width = Options::Cbs::Default_frames[0] @frame_height = Options::Cbs::Default_frames[1] @real_dead = false @pose = Options::Cbs::Stand @sprite_frames = Options::Cbs::Pose_Frames[@pose] if Options::Cbs::Pose_Frames[@pose] != nil @repeat = true @target_x = 0 @target_y = 0 @start_x = 0 @start_y = 0 @x = nil @y = nil @moving = false @move_speed = Options::Cbs::Move_speed @animate = false @anim_wait = 0 @victory = false kot_cbs_gamebattler_initialize end #------------------------------------ def set_pose(number, loop = true, delay = 8) @pose = number @repeat = loop @sprite_frames = 4 frames = Options::Cbs::Pose_Frames[number] @sprite_frames = frames if frames != nil @sprite_delay = delay delay_pose = Options::Cbs::Pose_Delay[number] @sprite_delay = delay_pose if delay_pose != nil end #------------------------------------ def move_to(target_x, target_y, speed = Options::Cbs::Move_speed) if self.is_a?(Game_Actor) return unless $game_battle.move_battlers elsif self.is_a?(Game_Enemy) return unless $game_battle.move_enemies end return if target_x == @x && target_y == @y @target_x = target_x @target_y = target_y @move_speed = speed @moving = true end #------------------------------------ def anim(pose, repeat = false, wait = nil) return if @animate @sprite_index = -1 set_pose(pose, repeat) wait = @sprite_frames if Options::Cbs::Pose_Delay[pose] == nil wait = [@sprite_frames * Options::Cbs::Pose_Delay[pose] - (Options::Cbs::Pose_Delay[pose] * 2), 8].max if wait == nil @anim_wait = wait @animate = true @victory = true if pose == Options::Cbs::Victory end #------------------------------------ def set_frame(id) if self.is_a?(Game_Actor) && Options::Cbs::Actor_Frame[id] != nil @frame_width = Options::Cbs::Actor_Frame[id][0] if Options::Cbs::Actor_Frame[id][0] != nil @frame_height = Options::Cbs::Actor_Frame[id][1] if Options::Cbs::Actor_Frame[id][1] != nil elsif self.is_a?(Game_Enemy) && Options::Cbs::Enemy_Frame[id] != nil @frame_width = Options::Cbs::Enemy_Frame[id][0] if Options::Cbs::Enemy_Frame[id][0] != nil @frame_height = Options::Cbs::Enemy_Frame[id][1] if Options::Cbs::Enemy_Frame[id][1] != nil end end #------------------------------------ def reset set_pose(Options::Cbs::Stand) @victory = false @target_x = 0 @target_y = 0 @start_x = 0 @start_y = 0 @x = nil @y = nil end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ class Game_Actor < Game_Battler #-------------------------------------------------------------------------- def screen_x if $game_battle.mirror @start_x = 40 + ($game_party.actors.size * 20) - self.index * 40 if self.index != nil @start_x += (self.frame_width - 64) / 2 else @start_x = 530 - ($game_party.actors.size * 20) + self.index * 40 if self.index != nil @start_x -= (self.frame_width - 64) / 2 end return @start_x end #-------------------------------------------------------------------------- def screen_y @start_y = 210 - ($game_party.actors.size * 17.5) + self.index * 20 if self.index != nil @start_y -= (self.frame_height - 64) return @start_y end #-------------------------------------------------------------------------- def screen_z return self.index if self.index != nil end end #============================================================================== # ■ Game_Enemy #------------------------------------------------------------------------------ class Game_Enemy < Game_Battler #------------------------------------ def screen_x if $game_battle.mirror @start_x = 640 - $data_troops[@troop_id].members[@member_index].x else @start_x = $data_troops[@troop_id].members[@member_index].x end return @start_x end #------------------------------------ def screen_y @start_y = $data_troops[@troop_id].members[@member_index].y return @start_y end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- attr_accessor :battler #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false @start = false end #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- def update super if @battler == nil self.bitmap = nil loop_animation(nil) return end unless @start @battler.set_frame(@battler.id) @battler.reset self.mirror = 1 if $game_battle.mirror @start = true end if Graphics.frame_count % @battler.sprite_delay == 0 @battler.sprite_index += 1 unless @battler.sprite_index >= @battler.sprite_frames - 1 @battler.sprite_index = 0 if @battler.sprite_index >= @battler.sprite_frames - 1 && @battler.repeat if @battler.is_a?(Game_Actor) @battler.sprite_index = 0 unless $game_battle.animated_battlers elsif @battler.is_a?(Game_Enemy) @battler.sprite_index = 0 unless $game_battle.animated_enemies end x = @battler.frame_width * @battler.sprite_index y = @battler.frame_height * @battler.pose self.bitmap = nil self.bitmap = RPG::Cache.battler(@battler.battler_name, @battler.battler_hue) self.src_rect.set(x, y, @battler.frame_width, @battler.frame_height) end if @battler.animate if @battler.anim_wait <= 0 @battler.animate = false @battler.set_pose(Options::Cbs::Stand) unless @battler.victory return end if Graphics.frame_count % @battler.sprite_delay == 0 @battler.anim_wait -= 1 end end if @battler.moving if @battler.is_a?(Game_Actor) if @battler.target_x == @battler.start_x @battler.set_pose(Options::Cbs::Move_back) elsif @battler.target_x != @battler.start_x @battler.set_pose(Options::Cbs::Move_to) end end if @battler.is_a?(Game_Enemy) if @battler.target_x == @battler.start_x @battler.set_pose(Options::Cbs::Move_back) elsif @battler.target_x != @battler.start_x @battler.set_pose(Options::Cbs::Move_to) end end if @battler.x < @battler.target_x @battler.x += @battler.move_speed @battler.x = @battler.target_x if @battler.x > @battler.target_x else @battler.x -= @battler.move_speed @battler.x = @battler.target_x if @battler.x < @battler.target_x end if @battler.y < @battler.target_y @battler.y += @battler.move_speed @battler.y = @battler.target_y if @battler.y > @battler.target_y else @battler.y -= @battler.move_speed @battler.y = @battler.target_y if @battler.y < @battler.target_y end @battler.moving = false if @battler.x == @battler.target_x && @battler.y == @battler.target_y else @battler.set_pose(Options::Cbs::Stand) if (@battler.pose == Options::Cbs::Move_to or @battler.pose == Options::Cbs::Move_back) && !@battler.animate && !@battler.victory if @battler.x == nil && @battler.y == nil @battler.x = @battler.target_x = @battler.screen_x @battler.y = @battler.target_y = @battler.screen_y end end 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 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 if @battler.dead? && @battler.real_dead @battler.set_pose(Options::Cbs::Dead) else @battler.real_dead = false 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 else 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) unless @battler.real_dead else $game_system.se_play($data_system.actor_collapse_se) unless @battler.real_dead end @battler.set_pose(Options::Cbs::Dead) @battler.real_dead = true end end self.x = @battler.x self.y = @battler.y self.z = @battler.y + @battler.frame_height end end #============================================================================== # ■ Arrow_Enemy #------------------------------------------------------------------------------ class Arrow_Enemy < Arrow_Base #-------------------------------------------------------------------------- # - Uso del Personaje que el cursor ha señalado #-------------------------------------------------------------------------- def enemy return $game_troop.enemies[@index] end #-------------------------------------------------------------------------- # - Renovacion del Frame #-------------------------------------------------------------------------- def update super # Estara en el aire, si el enemigo no es señalado $game_troop.enemies.size.times do break if self.enemy.exist? @index += 1 @index %= $game_troop.enemies.size end # Cursor derecho if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += 1 @index %= $game_troop.enemies.size break if self.enemy.exist? end end # Cursor izquierdo if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += $game_troop.enemies.size - 1 @index %= $game_troop.enemies.size break if self.enemy.exist? end end # Opciones de coordenadas del sprite if self.enemy != nil self.x = self.enemy.x + self.enemy.frame_width / 2 self.y = self.enemy.y + self.enemy.frame_height / 2 end end end #============================================================================== # ■ Arrow_Actor #------------------------------------------------------------------------------ class Arrow_Actor < Arrow_Base #-------------------------------------------------------------------------- # - Uso del Personaje que el cursor ha señalado #-------------------------------------------------------------------------- def actor return $game_party.actors[@index] end #-------------------------------------------------------------------------- # - Renovacion del Frame #-------------------------------------------------------------------------- def update super # Cursor derecho if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) @index += 1 @index %= $game_party.actors.size end # Cursor izquierdo if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) @index += $game_party.actors.size - 1 @index %= $game_party.actors.size end # Opciones de coordenadas del sprite if self.actor != nil self.x = self.actor.x + self.actor.frame_width / 2 self.y = self.actor.y + self.actor.frame_height / 2 end end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ class Scene_Battle #-------------------------------------------------------------------------- #alias kot_cbs_scenebattle_main main def main $game_temp.in_battle = true $game_temp.battle_turn = 0 $game_temp.battle_event_flags.clear $game_temp.battle_abort = false $game_temp.battle_main_phase = false $game_temp.battleback_name = $game_map.battleback_name $game_temp.forcing_battler = nil $game_system.battle_interpreter.setup(nil, 0) @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4]) @actor_command_window.y = 160 @actor_command_window.z = 999 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false @party_command_window = Window_PartyCommand.new @help_window = Window_Help.new @help_window.back_opacity = 160 @help_window.visible = false @status_window = Window_BattleStatus.new @message_window = Window_Message.new @spriteset = Spriteset_Battle.new @wait_count = 0 if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end start_phase1 loop do Graphics.update Input.update update if $scene != self break end end $game_map.refresh Graphics.freeze @actor_command_window.dispose @party_command_window.dispose @help_window.dispose @status_window.dispose @message_window.dispose if @skill_window != nil @skill_window.dispose end if @item_window != nil @item_window.dispose end if @result_window != nil @result_window.dispose end @spriteset.dispose if $scene.is_a?(Scene_Title) Graphics.transition Graphics.freeze end if $BTEST and not $scene.is_a?(Scene_Gameover) $scene = nil end end #-------------------------------------------------------------------------- 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 when 8 update_phase4_step8 end end #-------------------------------------------------------------------------- def update_phase4_step2 # If not a forcing action unless @active_battler.current_action.forcing # If restriction is [normal attack enemy] or [normal attack ally] if @active_battler.restriction == 2 or @active_battler.restriction == 3 # Set attack as an action @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 end # If restriction is [cannot perform action] if @active_battler.restriction == 4 # Clear battler being forced into action $game_temp.forcing_battler = nil # Shift to step 1 @phase4_step = 1 return end end # Clear target battlers @target_battlers = [] case @active_battler.current_action.kind when 0 if @active_battler.current_action.basic == 0 if @active_battler.is_a?(Game_Actor) weapon_id = @active_battler.weapon_id if weapon_id != 0 && Options::Cbs::Weapon.include?(weapon_id) && !Options::Cbs::Weapon[weapon_id][1] make_basic_action_result else @phase4_step = 7 return end else @phase4_step = 7 return end else make_basic_action_result end when 1 skill_id = @active_battler.current_action.skill_id if Options::Cbs::Skill_Anim.include?(skill_id) && Options::Cbs::Skill_Anim[skill_id][1] @phase4_step = 7 return else make_skill_action_result end when 2 make_item_action_result end # Shift to step 3 if @phase4_step == 2 @phase4_step = 3 end end #-------------------------------------------------------------------------- def update_phase4_step3 # Animation for action performer (if ID is 0, then white flash) if @animation1_id == 0 @active_battler.white_flash = true else @active_battler.animation_id = @animation1_id @active_battler.animation_hit = true end case @active_battler.current_action.kind when 0 if @active_battler.current_action.basic == 0 weapon_id = @active_battler.weapon_id if Options::Cbs::Weapon.include?(weapon_id) @active_battler.anim(Options::Cbs::Weapon[weapon_id][0]) if Options::Cbs::Animations.include?("Attack") else @active_battler.anim(Options::Cbs::Attack) if Options::Cbs::Animations.include?("Attack") end elsif @active_battler.current_action.basic == 1 @active_battler.anim(Options::Cbs::Guard) if Options::Cbs::Animations.include?("Guard") end when 1 skill_id = @active_battler.current_action.skill_id if Options::Cbs::Skill_Anim.include?(skill_id) @active_battler.anim(Options::Cbs::Skill_Anim[skill_id][0]) if Options::Cbs::Animations.include?("Skill") else @active_battler.anim(Options::Cbs::Skill) if Options::Cbs::Animations.include?("Skill") end when 2 @active_battler.anim(Options::Cbs::Item) if Options::Cbs::Animations.include?("Item") end @wait_count = @active_battler.anim_wait # Shift to step 4 @phase4_step = 4 end #-------------------------------------------------------------------------- def update_phase4_step4 # Animation for target for target in @target_battlers target.animation_id = @animation2_id target.animation_hit = (target.damage != "Miss") if target.damage.is_a?(Numeric) && target.damage > 0 if target.guarding? target.anim(Options::Cbs::Guard) if Options::Cbs::Animations.include?("Guard") else target.anim(Options::Cbs::Hit) if Options::Cbs::Animations.include?("Hit") end else if target.damage.is_a?(String) target.anim(Options::Cbs::Miss) if Options::Cbs::Animations.include?("Miss") end end end @wait_count = 8 # Shift to step 5 @phase4_step = 5 end #-------------------------------------------------------------------------- def update_phase4_step6 # Clear battler being forced into action $game_temp.forcing_battler = nil # If common event ID is valid if @common_event_id > 0 # Set up event common_event = $data_common_events[@common_event_id] $game_system.battle_interpreter.setup(common_event.list, 0) end # Shift to step 1 if (@active_battler.current_action.kind == 0 && @active_battler.current_action.basic == 0) or @active_battler.current_action.kind == 1 @phase4_step = 8 else @phase4_step = 1 end end #-------------------------------------------------------------------------- # * Frame Update (main phase step 7 : move to) #-------------------------------------------------------------------------- def update_phase4_step7 if @active_battler.is_a?(Game_Actor) target = $game_troop.smooth_target_enemy(@active_battler.current_action.target_index) x = target.x + ($game_battle.mirror ? -(target.frame_width / 1.5): (target.frame_width / 1.5)) y = target.y - (@active_battler.frame_height - target.frame_height) @active_battler.move_to(x, y) if Options::Cbs::Animations.include?("Move_to") else target = $game_party.smooth_target_actor(@active_battler.current_action.target_index) x = target.x + ($game_battle.mirror ? (target.frame_width / 1.5): -(target.frame_width / 1.5)) y = target.y - (@active_battler.frame_height - target.frame_height) @active_battler.move_to(x, y) if Options::Cbs::Animations.include?("Move_to") end if @active_battler.x == @active_battler.target_x && @active_battler.y == @active_battler.target_y if @active_battler.current_action.basic == 0 make_basic_action_result else make_skill_action_result end @phase4_step = 3 end end #-------------------------------------------------------------------------- # * Frame Update (main phase step 8 : move back) #-------------------------------------------------------------------------- def update_phase4_step8 @active_battler.move_to(@active_battler.start_x, @active_battler.start_y, 5) if Options::Cbs::Animations.include?("Move_back") if @active_battler.x == @active_battler.target_x && @active_battler.y == @active_battler.target_y @phase4_step = 1 end end #-------------------------------------------------------------------------- # * Start After Battle Phase #-------------------------------------------------------------------------- alias kot_cbs_scenebattle_start_phase5 start_phase5 def start_phase5 for actor in $game_party.actors actor.anim(Options::Cbs::Victory) if Options::Cbs::Animations.include?("Victory") end kot_cbs_scenebattle_start_phase5 end end #============================================================================== # ■ Sprite (Damage) #------------------------------------------------------------------------------ module RPG class Sprite < ::Sprite #-------------------------------------------------------------------------- def damage(value, critical) dispose_damage if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_damage_sprite = ::Sprite.new(self.viewport) @_damage_sprite.bitmap = bitmap @_damage_sprite.ox = 80 @_damage_sprite.oy = 20 @_damage_sprite.x = self.x + Options::Cbs::Default_frames[0] / 2 @_damage_sprite.y = self.y - self.oy / 2 @_damage_sprite.z = 3000 @_damage_duration = 40 end end end ==== Comando individuales ==== **Este script solo es comaptible con éste sistema de batalla** Colocar encima de "Main" y debajo del script principal. #============================================================================== # Commandos Individuales #============================================================================== # Script por: Kotfire # Versión 2.0 # Versión especial para mi script de combate: "Kotfire Custom Battle" #------------------------------------------------------------------------------ # Instrucciones # - Copiar en un script encima de main # - Elegir el modo(por id o por clase) # - Cambiar los comandos para cada personaje # - Disfrutar #============================================================================== # ■ Add-on Manager #------------------------------------------------------------------------------ Add_on.insert("Actor_Commands") if Add_on.state("Actor_Commands") == true #============================================================================== # ■ Options #------------------------------------------------------------------------------ module Options module Actor_Commands MODE = 0 # 0 : Id / 1 : Clase end end #============================================================================== # Scene_Battle #============================================================================== class Scene_Battle alias kot_commands phase3_setup_command_window def phase3_setup_command_window case Options::Actor_Commands::MODE when 0 # Id del personaje en la base de datos actor = $game_party.actors[@actor_index].id when 1 # Id de la clase del personaje actor = $game_party.actors[@actor_index].class_id end # Para cada personaje o clase sus propios comandos case actor when 1 commands = ["Zarpazo", "Furia", "Defensa", "Objeto"] when 2 commands = ["Ataque", "Habilidad", "Defensa", "Objeto"] when 3 commands = ["Disparo", "Tiro", "Defensa", "Objeto"] when 4 commands = ["Ataque", "Hechizo", "Defensa", "Objeto"] #when 3 #commands = [Comando1, Comando2, Comando3, Comando4] #ect.. end @actor_command_window.change(commands) kot_commands end end #============================================================================== # Window_Command #============================================================================== class Window_Command < Window_Selectable def change(commands = @original) @original = @commands unless @original @commands = commands ? commands : @original refresh end end #------------------------------------------------------------------------------ end ==== Fondo de batalla animado ==== **Éste script solo es compatible con éste sistema de batala.** Colocar encima de "Main" y debajo del script principal. #============================================================================== # Fondo de Batalla Animado #============================================================================== # Script por: Kotfire # Versión 1.0 # Versión especial para mi script de combate: "Kotfire Custom Battle" #----------------------------------------------------------------------------- # -Instrucciones- # Pegar encima de main y disfrutar # Editar la opción Template, true si el fondo animado es una sola imagen y # false si son varias. En el segundo caso las imagenes tendrán que llamarse # Nombredelfondo-1, Nombredelfondo-2 etc. # Ejemplo: Pradera-1, Pradera-2, Pradera-3 ... #============================================================================== # ■ Add-on Manager #------------------------------------------------------------------------------ Add_on.insert("Anim_BattleBack") if Add_on.state("Anim_BattleBack") == true #============================================================================== # ■ Options #------------------------------------------------------------------------------ module Options module Animated_Back Template = true end end #============================================================================== # ■ Game_Battle #------------------------------------------------------------------------------ class Game_Battle #-------------------------------------------------------------------------- attr_accessor :back_delay # Retraso entre frames attr_accessor :back_frames # Número de frames attr_accessor :back_animated # fondo animado? #-------------------------------------------------------------------------- alias kot_animatedbattleback_gamebattle_initialize initialize def initialize @back_delay = 5 @back_frames = 8 @back_animated = true kot_animatedbattleback_gamebattle_initialize end end #============================================================================== # ■ Spriteset_Battle #------------------------------------------------------------------------------ class Spriteset_Battle #-------------------------------------------------------------------------- alias kot_animatedbattleback_spritesetbattle_initialize initialize def initialize @back_index = 0 @back_delay = $game_battle.back_delay @back_frames = $game_battle.back_frames @animated = $game_battle.back_animated kot_animatedbattleback_spritesetbattle_initialize end #-------------------------------------------------------------------------- def update_backsprite return unless @animated return unless Graphics.frame_count % @back_delay == 0 @back_index += 1 if @back_index > @back_frames @back_index = 0 update_backsprite end if Options::Animated_Back::Template x = 640 * (@back_index - 1) else x = 0 @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name + "-#{@back_index}") end width = @battleback_sprite.bitmap.width / @back_frames height = @battleback_sprite.bitmap.height @battleback_sprite.src_rect.set(x, 0, width, height) end end #============================================================================== # ■ Scene_Battle (1) #------------------------------------------------------------------------------ class Scene_Battle #-------------------------------------------------------------------------- alias kot_animatedbattleback_scenebattle_update update def update @spriteset.update_backsprite kot_animatedbattleback_scenebattle_update end end #------------------------------------------------------------------------------ end ==== Posición de batalla ==== **Este script sólo es compatible con éste sistema de batalla** Colocar encima de "Main" y debajo del script principal. #============================================================================== # Posición De Batalla #============================================================================== # Script por: Kotfire # Versión 1 # Versión especial para mi script de combate: "Kotfire Custom Battle" #----------------------------------------------------------------------------- # -Instrucciones- # Pegar encima de main y disfrutar #============================================================================== # ■ Add-on Manager #------------------------------------------------------------------------------ Add_on.insert("Battle_Position") if Add_on.state("Battle_Position") == true #============================================================================== # ** Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :position # position #-------------------------------------------------------------------------- # * Setup # actor_id : actor ID #-------------------------------------------------------------------------- alias setup_kot setup def setup(actor_id) actor = $data_actors[actor_id] @class_id = actor.class_id @position = $data_classes[@class_id].position setup_kot(actor_id) end #-------------------------------------------------------------------------- def screen_x if $game_battle.mirror @start_x = 40 + ((-10 * @position) + ($game_party.actors.size * 20)) - self.index * 40 if self.index != nil @start_x += (self.frame_width - 64) / 2 else @start_x = 530 - ((-10 * @position) + ($game_party.actors.size * 20)) + self.index * 40 if self.index != nil @start_x -= (self.frame_width - 64) / 2 end return @start_x end end #============================================================================== # ** Game_Party #============================================================================== class Game_Party #-------------------------------------------------------------------------- # * Random Selection of Target Actor # hp0 : limited to actors with 0 HP #-------------------------------------------------------------------------- def random_target_actor(hp0 = false) # Initialize roulette roulette = [] # Loop for actor in @actors # If it fits the conditions if (not hp0 and actor.exist?) or (hp0 and actor.hp0?) # Get actor class [position] position = actor.position # Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2 n = 4 - position # Add actor to roulette n times n.times do roulette.push(actor) end end end # If roulette size is 0 if roulette.size == 0 return nil end # Spin the roulette, choose an actor return roulette[rand(roulette.size)] end end #============================================================================== # ** Window_MenuStatus #------------------------------------------------------------------------------ # This window displays party member status on the menu screen. #============================================================================== class Window_MenuStatus < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 480, 480) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size actor = $game_party.actors[i] position = actor.position x = 64 + 24 * position y = i * 116 draw_actor_graphic(actor, x - 40, y + 80) draw_actor_name(actor, x, y) draw_actor_class(actor, x + 90, y) draw_actor_hp(actor, x, y + 32) draw_actor_sp(actor, x, y + 64) draw_actor_level(actor, x + 184, y) draw_actor_exp(actor, x + 184, y + 32) end end #-------------------------------------------------------------------------- # * Cursor Rectangle Update #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(0, @index * 116, self.width - 32, 96) end end end #============================================================================== # ** Window_Steps #------------------------------------------------------------------------------ # This window displays step count on the menu screen. #============================================================================== class Window_Steps < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 120, 32, "Pasos") self.contents.font.color = normal_color self.contents.draw_text(4, 0, 120, 32, $game_party.steps.to_s, 2) end end #============================================================================== # ** Scene_Save #============================================================================== class Scene_Save < Scene_File #-------------------------------------------------------------------------- # * Decision Processing #-------------------------------------------------------------------------- def on_decision(filename) # Play save SE $game_system.se_play($data_system.save_se) # Write save data file = File.open(filename, "wb") write_save_data(file) file.close # If called from event if $game_temp.save_calling # Clear save call flag $game_temp.save_calling = false # Switch to map screen $scene = Scene_Map.new return end # Switch to menu screen $scene = Scene_Menu.new(5) end #-------------------------------------------------------------------------- # * Cancel Processing #-------------------------------------------------------------------------- def on_cancel # Play cancel SE $game_system.se_play($data_system.cancel_se) # If called from event if $game_temp.save_calling # Clear save call flag $game_temp.save_calling = false # Switch to map screen $scene = Scene_Map.new return end # Switch to menu screen $scene = Scene_Menu.new(5) end end #============================================================================== # ** Scene_End #============================================================================== class Scene_End #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update command window @command_window.update # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to menu screen $scene = Scene_Menu.new(6) return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 0 # to title command_to_title when 1 # shutdown command_shutdown when 2 # quit command_cancel end return end end #-------------------------------------------------------------------------- # * Process When Choosing [Cancel] Command #-------------------------------------------------------------------------- def command_cancel # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to menu screen $scene = Scene_Menu.new(6) end end #============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs menu screen processing. #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # * Object Initialization # menu_index : command cursor's initial position #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Make command window s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "Estado" s5 = "Posición" s6 = "Guardar" s7 = "Salir" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7]) @command_window.index = @menu_index # If number of party members is 0 if $game_party.actors.size == 0 # Disable items, skills, equipment, and status @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) @command_window.disable_item(4) end # If save is forbidden if $game_system.save_disabled # Disable save @command_window.disable_item(5) end # Make play time window @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 256 # Make steps window @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 352 # Make gold window @gold_window = Window_Gold.new @gold_window.x = 0 @gold_window.y = 416 # Make status window @status_window = Window_MenuStatus.new @status_window.x = 160 @status_window.y = 0 # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @command_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @command_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update # If command window is active: call update_command if @command_window.active update_command return end # If status window is active: call update_status if @status_window.active update_status return end end #-------------------------------------------------------------------------- # * Frame Update (when command window is active) #-------------------------------------------------------------------------- def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to map screen $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # If command other than save or end game, and party members = 0 if $game_party.actors.size == 0 and @command_window.index < 4 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Branch by command window cursor position case @command_window.index when 0 # item # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to item screen $scene = Scene_Item.new when 1 # skill # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 # Play decision SE $game_system.se_play($data_system.decision_se) # Make status window active @command_window.active = false @status_window.active = true @status_window.index = 0 when 5 # save # If saving is forbidden if $game_system.save_disabled # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to save screen $scene = Scene_Save.new when 6 # end game # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to end game screen $scene = Scene_End.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when status window is active) #-------------------------------------------------------------------------- def update_status # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Make command window active @command_window.active = true @status_window.active = false @status_window.index = -1 return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 1 # skill # If this actor's action limit is 2 or more if $game_party.actors[@status_window.index].restriction >= 2 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to skill screen $scene = Scene_Skill.new(@status_window.index) when 2 # equipment # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to equipment screen $scene = Scene_Equip.new(@status_window.index) when 3 # status # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to status screen $scene = Scene_Status.new(@status_window.index) when 4 # Play decision SE $game_system.se_play($data_system.decision_se) unless $game_party.actors[@status_window.index].position >= 2 $game_party.actors[@status_window.index].position += 1 else $game_party.actors[@status_window.index].position = 0 end @status_window.refresh end return end end end #------------------------------------------------------------------------------ end ===== Recursos necesarios ===== Para éste sistema de batalla hace falta unos battlers especiales, con una "pose" por acción del combatiente y con 6 frames por "pose". Cada pose puede ser modificada en el script principal y el tamaño total del battler no es fijo.