#=============================================================================== # Side-View Battle System # By Jet10985 (Jet) #=============================================================================== # This script will allow you to have battle where all the actor's sprites are # display on the right side of the screen. # This script has: 37 customization options. #=============================================================================== # Overwritten Methods: # Scene_Battle: display_attack_animation # Spriteset_Battle: update_actors #------------------------------------------------------------------------------- # Aliased methods: # Game_Actor: level_up, gain_exe # Game_Battler: hp=, mp=, add_state, attack_effect, skill_effect, item_effect # Spriteset_Battle: create_actors, create_enemies # Sprite_Character: initialize, update, dispose # Sprite_Battler: update, dispose # Scene_Battle: execute_action, next_actor, prior_actor, execute_action_item, # execute_action_skill, terminate #=============================================================================== module JSBS #============================================================================= # ENEMY OPTIONS #============================================================================= # These are the attack animations for enemies when they use a regular attack. # It follows this format: enemy_id => animation_id ENEMY_ATK_ANIMS = { 1 => 4, 6 => 2, 5 => 27 } # This is the default enemy attack animation, used when they do not have a # specific attack animation above. ENEMY_ATK_ANIMS.default = 1 # This is a list of enemies whose portraits should be flipped in battle. FLIPPED_ENEMIES = [2, 3, 4, 5, 8, 10, 12, 13, 14, 16, 17, 18, 19] #============================================================================= # ACTOR OPTIONS #============================================================================= # Should the player sprite have a shadow beneath them? PLAYER_SHADOW = true # These are sprite changes depending on state infliction. # It follows this format: state_id => "sprite_appention" # This means if the state is inflicted, the sprite will look for a graphic # that is the same name as the character's sprite, plus the appended option. # EX: Ralph's sprite's name is $ralph. Ralph gets knocked-out. This means # state 1 was inflicted, and my below config for 1 was: 1 => "_dead" # Now, his shown sprite will be $ralph_dead. If the sprite does not exist, # no change will be made. # The sprite index will be the same as the actor's. STATE_SPRITES = { 1 => "_dead", 2 => "_poison", 3 => "_blind" } #============================================================================= # GENERAL_OPTIONS #============================================================================= # This is the animation displayed when a skill is about to be used. SKILL_ANIMATION = 43 # This is the animation displayed when an item is about to be used. ITEM_ANIMATION = 43 # These are the animations played when a state is inflicted. # It follows this format: state_id => animation_id STATE_ANIMATIONS = { 1 => 56, 2 => 50, 3 => 51 } #============================================================================= # FIELD OPTIONS #============================================================================= # This is where the line-up begins. [x, y]. The higher the x, the further # right and the higher the y the further down. FIELD_POS = [400, 80] # This is how far down, and to the right each player is from the previous # actor. [x, y]. Same rules as above. FIELD_SPACING = [12, 50] # This is the space difference for actor's depending on their row position. # This is the difference for BACK ROW actors, middle row actors will be half # of this value and front row will be none. ROW_DIFFERENCE = 20 #============================================================================= # COLOR/TEXT OPTIONS #============================================================================= # The text and color shown when a character is knocked out (dies). KNOCKOUT_TEXT = "Knockout" KNOCKOUT_COLOR = Color.new(255, 167, 0) # The text and color shown when a character takes damage. # The actual damage is appended to the end. HURT_TEXT = "Damage +" HURT_COLOR = Color.new(255, 0, 0) HURT_TEXT_MP = "Mana -" HURT_COLOR_MP = Color.new(225, 30, 255) # The text and color shown when a character heals health. # The actual health is appended to the end. HEAL_TEXT = "Heal +" HEAL_COLOR = Color.new(0, 255, 0) HEAL_TEXT_MP = "Mana +" HEAL_COLOR_MP = Color.new(35, 200, 255) # The text and color shown when a character gains exp. # The actual exp is appended to the end. EXP_PLUS_TEXT = "EXP +" EXP_PLUS_COLOR = Color.new(167, 167, 0) # The text and color shown when an attack is critical. CRITICAL_TEXT = "Critical" CRITICAL_COLOR = Color.new(255, 106, 43) # The text and color shown when an attack misses. MISSED_TEXT = "Miss" MISS_COLOR = Color.new(45, 78, 99) # The text and color shown when an attack is evaded. EVADED_TEXT = "Evaded" EVADE_COLOR = Color.new(156, 187, 255) # The text and color shown when an attack is not effective against the target. UNEFFECTIVE_TEXT = "Uneffective" UNEFFECTIVE_COLOR = Color.new(0, 0, 0) # The text, color, and animation shown when a character levels up. # For no animation, use 0. LEVEL_TEXT = "Level Up" LEVEL_COLOR = Color.new(167, 255, 52) LEVEL_UP_ANIM = 37 # These are the colors used for displaying when a state is added. # It follows this format: state_id => Color.new(r, g, b) STATE_ADDED_COLORS = { 2 => Color.new(128, 0, 255), 3 => Color.new(128, 0, 255), 4 => Color.new(128, 0, 255) } end #=============================================================================== # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO. #=============================================================================== class Game_Character attr_accessor :step_anime %w[screen_x screen_y].each {|a| aStr = %Q{ alias jet6372_#{a} #{a} unless $@ def #{a}(*args, &block) $BTEST ? 0 : jet6372_#{a}(*args, &block) end } module_eval(aStr) } end class Game_Actor alias jet4921_level_up level_up unless $@ def level_up(*args, &block) jet4921_level_up(*args, &block) unless @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0 make_popup(JSBS::LEVEL_TEXT, JSBS::LEVEL_COLOR) self.battle_sprite.start_animation($data_animations[JSBS::LEVEL_UP_ANIM]) end end alias jet1029_gain_exp gain_exp unless $@ def gain_exp(exp, flag = false) make_popup(JSBS::EXP_PLUS_TEXT + exp.to_s, JSBS::EXP_PLUS_COLOR) jet1029_gain_exp(exp, flag) end def animation_id=(t) self.battle_sprite.start_animation($data_animations[t]) end end class Game_Battler attr_accessor :battle_sprite alias jet8573_add_state add_state unless $@ def add_state(sid) before = state?(sid) jet8573_add_state(sid) return if before == state?(sid) f = $data_animations[JSBS::STATE_ANIMATIONS[sid] || 0] self.battle_sprite.start_animation(f) if sid == 1 make_popup(JSBS::HURT_TEXT + @hp_damage.to_s, JSBS::HURT_COLOR) make_popup(JSBS::KNOCKOUT_TEXT, JSBS::KNOCKOUT_COLOR) else make_popup("+#{$data_states[sid].name}", JSBS::STATE_ADDED_COLORS[sid] || Color.new(0, 0, 0)) end end alias jet7567_hp hp= unless $@ def hp=(*args, &block) if @critical make_popup(JSBS::CRITICAL_TEXT, JSBS::CRITICAL_COLOR) end jet7567_hp(*args, &block) f = @hp_damage.abs.to_s if @hp_damage < 0 make_popup(JSBS::HEAL_TEXT + f, JSBS::HEAL_COLOR) elsif @hp_damage >= 0 && !state?(1) make_popup(JSBS::HURT_TEXT + f, JSBS::HURT_COLOR) end end alias jet7567_mp mp= unless $@ def mp=(*args, &block) if @critical make_popup(JSBS::CRITICAL_TEXT, JSBS::CRITICAL_COLOR) end jet7567_mp(*args, &block) if @mp_damage != 0 f = @mp_damage.abs.to_s if @mp_damage < 0 make_popup(JSBS::HEAL_TEXT_MP + f, JSBS::HEAL_COLOR_MP) elsif @mp_damage >= 0 && !state?(1) make_popup(JSBS::HURT_TEXT_MP + f, JSBS::HURT_COLOR_MP) end end end %w[attack item skill].each {|a| aStr = %Q{ alias jet4382_#{a}_effect #{a}_effect unless $@ def #{a}_effect(*args, &block) jet4382_#{a}_effect(*args, &block) if @missed make_popup(JSBS::MISSED_TEXT, JSBS::MISS_COLOR) elsif @evaded make_popup(JSBS::EVADED_TEXT, JSBS::EVADE_COLOR) elsif @skipped make_popup(JSBS::UNEFFECTIVE_TEXT, JSBS::UNEFFECTIVE_COLOR) end end } module_eval(aStr) } def make_popup(text, color) return unless $scene.is_a?(Scene_Battle) f = self.battle_sprite f.popups.unshift(Sprite_JetPopup.new(text, color, f)) end def battle_sprite return $scene.is_a?(Scene_Battle) ? @battle_sprite : Sprite_Base.new(nil) end end class Spriteset_Battle alias jet2847_create_enemies create_enemies unless $@ def create_enemies(*args, &block) jet2847_create_enemies(*args, &block) @enemy_sprites.each {|a| a.battler.battle_sprite = a a.mirror = JSBS::FLIPPED_ENEMIES.include?(a.battler.id) } end alias jet3835_create_actors create_actors unless $@ def create_actors(*args, &block) jet3835_create_actors(*args, &block) @jet_party = $game_party.members @actor_sprites.each {|a| a.dispose } @actor_sprites = [] $game_party.members.each {|a| f = Game_Character.new f.set_graphic(a.character_name, a.character_index) f.step_anime = true f.set_direction(4) n = Sprite_Character.new(@viewport1, f) n.battle_sprite = true n.jet_x = JSBS::FIELD_POS[0] + a.index * JSBS::FIELD_SPACING[0] n.jet_y = JSBS::FIELD_POS[1] + a.index * JSBS::FIELD_SPACING[1] n.jet_x += a.class.position * (JSBS::ROW_DIFFERENCE / 2) n.actor = a if JSBS::PLAYER_SHADOW v = Sprite.new(nil) v.bitmap = Cache.system("Shadow") n.shadow_sprite = v end @actor_sprites.push(n) a.battle_sprite = n } end def update_actors if @jet_party != $game_party.members @actor_sprites.each {|a| a.dispose } @actor_sprites = [] create_actors end @actor_sprites.each {|a| a.update } end end class Sprite_JetPopup < Sprite_Base def initialize(text, color, obj) super(nil) @text = text @color = color @character = obj self.visible = false form_self end def form_self samp = Bitmap.new(1, 1) self.bitmap = Bitmap.new(samp.text_size(@text).width, 24) self.bitmap.font.color = @color self.bitmap.draw_text(0, 0, self.bitmap.width, 24, @text) self.x = @character.x - (self.bitmap.width / 2) self.y = @character.y - 16 samp.dispose end def update super self.y -= 1 self.opacity -= 2.125 if self.opacity <= 0 self.dispose end end end class Sprite_Character attr_accessor :battle_sprite, :jet_x, :jet_y, :shadow_sprite, :actor alias jet4646_initialize initialize unless $@ def initialize(*args, &block) @battle_sprite = false jet4646_initialize(*args, &block) end alias jet3645_update update unless $@ def update(*args, &block) jet3645_update(*args, &block) if @battle_sprite @character.step_anime = !@actor.dead? @character.update self.x = @jet_x self.y = @jet_y if !@actor.nil? f = @actor.states.dup f.sort! {|a, b| a.priority <=> b.priority }.reverse! for i in 0...f.size a = JSBS::STATE_SPRITES[f[i].id] next if a.nil? b = (Cache.character(@character.character_name + a) rescue false) next unless b index = @character.character_index @character.set_graphic(@character.character_name + a, index) break end end if !@shadow_sprite.nil? @shadow_sprite.x = self.x - @shadow_sprite.width / 2 @shadow_sprite.y = self.y - 28 @shadow_sprite.visible = self.visible @shadow_sprite.viewport = self.viewport @shadow_sprite.z = self.z - 1 end end end def move_x(times, amount) i = 0 until i == times self.jet_x += amount i += 1 [Graphics, $scene.spriteset].each {|a| a.update } end end end class Game_Enemy def atk_animation_id return JSBS::ENEMY_ATK_ANIMS[@enemy_id] end def atk_animation_id2 return 0 end end class Scene_Battle attr_reader :spriteset alias jet2711_execute_action execute_action unless $@ def execute_action(*args, &block) if @active_battler.is_a?(Game_Actor) if !@active_battler.action.nothing? && !@active_battler.action.guard? @active_battler.battle_sprite.move_x(11, -6) end end jet2711_execute_action(*args, &block) if @active_battler.is_a?(Game_Actor) if !@active_battler.action.nothing? && !@active_battler.action.guard? @active_battler.battle_sprite.move_x(11, 6) end end end alias jet3457_terminate terminate unless $@ def terminate(*args, &block) ($game_party.members + $game_troop.members).each {|a| a.battle_sprite.dispose rescue nil a.battle_sprite = nil } jet3457_terminate(*args, &block) end def display_attack_animation(targets) aid1 = @active_battler.atk_animation_id aid2 = @active_battler.atk_animation_id2 display_normal_animation(targets, aid1, false) display_normal_animation(targets, aid2, true) wait_for_animation end %w[next prior].each {|a| aStr = %Q{ alias jet3734_#{a}_actor #{a}_actor unless $@ def #{a}_actor(*args, &block) f = @active_battler f.battle_sprite.move_x(6, 6) if f.is_a?(Game_Actor) jet3734_#{a}_actor(*args, &block) f = @active_battler f.battle_sprite.move_x(6, -6) if f.is_a?(Game_Actor) end } module_eval(aStr) } %w[skill item].each {|a| aStr = %Q{ alias jet3733_execute_action_#{a} execute_action_#{a} unless $@ def execute_action_#{a}(*args, &block) n = $data_animations[JSBS::#{a.upcase}_ANIMATION] @active_battler.battle_sprite.start_animation(n) wait_for_animation jet3733_execute_action_#{a}(*args, &block) end } module_eval(aStr) } end %w[Sprite_Character Sprite_Battler].each {|a| aStr = %Q{ class #{a} attr_accessor :popups alias jet4758_initialize initialize unless $@ def initialize(*args, &block) @popups = [] @updating_sprites = [] @popup_wait = 0 jet4758_initialize(*args, &block) end alias jet7467_update update unless $@ def update(*args, &block) jet7467_update(*args, &block) if @popup_wait == 0 if !@popups.empty? @updating_sprites.push(@popups.pop) @popup_wait = 30 end else @popup_wait -= 1 end @updating_sprites.each {|a| a.visible = true if !a.visible a.update @updating_sprites.delete(a) if a.disposed? } end alias jet5483_dispose dispose unless $@ def dispose(*args, &block) (@updating_sprites + @popups).each {|a| a.dispose } @shadow_sprite.dispose if !@shadow_sprite.nil? jet5483_dispose(*args, &block) end end } eval(aStr) }