Jump to content
Paladox

Reedo's Simple Side Battle System - Exclude specific actors from dancing?

Recommended Posts

Here is the script:
 

Spoiler

###############################################################################
##  RSSBS - Reedo's Simple Side Battle System
##  Version 1.0
##  January 7, 2010
##  By Reedo
###############################################################################
##  SOURCE
##
##  Source thread:
##
##
##  Support thread:
##    http://www.rpgmakervx.net/index.php?showtopic=24587
###############################################################################
##  REFERENCES
##
##  None.  This is an original script by Reedo.
##  However other people have contributed ideas and bug finds. Please see the
##  support thread link above for details.
###############################################################################
##  DESCRIPTION
##
##  This script provides a plug-and-play Side Battle System for the default
##  battle system. This is purely an asthetic script, and as such, it only
##  modifies the visuals of the battle. It does not modify battle mechanics
##  when used by itself.
##
##  This script will:
##  1) Draw the party on the right side of the screen, facing left, during batle.
##  2) Cause actors to perform their stepping animation when they are on the
##     ground, and have no state restrictions applied.
##  3) Place a shadow under the actor.
##  4) Provide a target for animations, and optionally, animations themselves.
##  5) Line up actors in a staggerd row, top to bottom, with adjustable spacing,
##     recessed according to the position value of their class.
##  6) Cause actors to step forward when performing an action.
##  7) Draw actors lying down, whitened, and semi-transparent when dead.
##  8) Cause living actors to do a victory dance at the end of battle.
##  9) Provide the option to horizontally flip enemy images by enemy ID.
##
##  When used with the YERD or YEZ battle scripts, you then get even more
##  animation options (such as casting animations) and popups for most battle
##  event messages.  This SBS and YEZ combine to form an amazing SBS experience!
##     YEZ Script Link:  http://www.pockethouse.com/yez/
###############################################################################
##  COMPATIBILITY
##
##  Should be compatible with most other scripts.
##
##  This script overwrites 1 method: Spriteset_Battle.update_actors
##  All other methods are aliased, and those aliases are called.
##  The one overwrite should not cause an issue as the only functionality it
##  supresses is setting the party members to the current battle sprites. The
##  rest of the original method is maintained, and this script handles the
##  relationship between party members and battle sprites.
###############################################################################
##  REQUIREMENTS
##
##  None
###############################################################################
##  INSTALLATION
##
##  Plug-and-play. (and this time I mean it for reals!)
##
##  Insert below Materials, above other Reedo scripts.
##  All Reedo scripts should be below all YERD/YEZ scripts.
###############################################################################
##  RIGHTS & RESTRICTIONS
##
##  As with most Reedo scripts, this script is free to re-use, as-is,
##  in personal, educational, and commercial RPGVX development projects,
##  providing that:  this script, as well as the rpgmakervx.net forum link  
##  from which it was obtained, are credited in writing displayed readily
##  to the user of the final compiled code assembly.
##
##  Reedo and rgpmakervx.net retain all rights of intellect and ownership.
##  You forego all rights of warranty by utilizing this script.
###############################################################################
##  USAGE
##
##  Plug and play.  Suggested to use YEZ Battle Engine Zealous, and Reedo's
##  Tile-Based Battle Backgrounds scripts.
##
##  Some visual options can be modified below.
###############################################################################

###############################################################################
##  USER OPTIONS
###############################################################################
module REEDO_SBS

# If desired, you can modify the default script options using the constants
# below. In most cases though, you should not need to adjust these values.
 
###############################################################################
## This section controls the battle animations provided by this script
###############################################################################
  # This controls whether or not this script will provide animations during
  # battle. Set to 'true' when using this script without any other battle scene
  # enhancements. Set to 'false' when using battle scene enhancements such
  # as YEZ/YERD. Default is 'false'.
  SBS_ACTION_ANIMES = true
 
  # If this script is providing animations, then you can specify which
  # animations to use a default.
  SBS_DEFAULT_ATTACK_ANIME = 19
  # Skill and item animations will use the animation assigned to the skill or
  # item, if any. If none is assigned, then the default will be used. Specify
  # a value of 0 if you do not want a default animation. These values have no
  # effect if SBS_ACTION_ANIMES is set to 'false'.
  SBS_DEFAULT_SKILL_ANIME = 1
  SBS_DEFAULT_ITEM_ANIME = 1
 
###############################################################################
## This section adjusts the actors positions on screen
###############################################################################
  ACTOR_START_LINE = 432        # The left-most position of the first actor
  ACTOR_START_TOP = 80          # The top-most position of the first actor
  ACTOR_STAGGER_HORZ = 2        # The amount to recess each actor to the right
  ACTOR_STAGGER_VERT = 8       # The vertical spacing between characters
  ACTOR_CLASS_POS_STAGGER = 8  # The extra distance to the right for class position
  ACTOR_STEP_IN_DISTANCE = 64   # The distance an actor steps in during an action
  ACTOR_STEP_IN_RATE = 8        # The rate at which the actor covers the distance
 
###############################################################################
## This section controls when an actor displays their stepping animation
###############################################################################
  # If an actor has a state applied which has a restriction value listed in
  # the following array, the actor will not display their stepping animation
  # until the state is removed.
  NO_STEP_RESTRICTIONS = [6, 7, 18]
  # Has the same effect as above, but halts the stepping animation based on
  # the state's ID, without regard to the state's restriction.
  NO_STEP_STATES = []
 
###############################################################################
## This section adjusts the appearance of an actor when dead
###############################################################################
  ACTOR_DEATH_OPACITY = 175              # The tranparency of dead actors
  ACTOR_DEATH_ANGLE = 270                # The angle to rotate the body
  ACTOR_DEATH_TONE = [128, 128, 128, 0]  # A color tone to apply to the image
  ACTOR_DEATH_OFFSET_X = -8              # A horizontal offset to move the body by
  ACTOR_DEATH_OFFSET_Y = -8              # A vertical offset to move the body by
 
###############################################################################
## This section adjusts the actor's shadow
###############################################################################
  ACTOR_SHADOW_IMAGE = "Shadow"       # The name of the system image to use
  ACTOR_SHADOW_CUSTOM_PICTURE = nil   # The name of a resource picture to use instead; nil to use system image
  ACTOR_SHADOW_OFFSET_X = 0           # The horizontal offset to the actor's position
  ACTOR_SHADOW_OFFSET_Y = 8           # The vertical offset to the actor's position
  ACTOR_DEATH_SHADOW_OFFSET_X = 8     # Additional X offset added when dead
  ACTOR_DEATH_SHADOW_OFFSET_Y = 2     # Additional Y offset added when dead
 
###############################################################################
## This section adjusts the victory dance
###############################################################################
  VICTORY_DANCE_JUMP_HEIGHT = 16    # The height of the jump
  VICTORY_DANCE_JUMP_INCREMENT = 2  # The rate of jump movement
  VICTORY_DANCE_JUMP_HOVER = 4      # The number of frames to wait in the air
  VICTORY_DANCE_JUMP_WAIT = 70      # The number of frames before jumping again
  VICTORY_DANCE_JUMP_TWIST = true   # True to twirl when jumping; false to face forward
 
###############################################################################
## This section adjusts the battle floor location
###############################################################################
  BATTLE_FLOOR_TOP = 128  # Allows you to set the top of the battle floor
 
###############################################################################
## This section adjusts enemy images
###############################################################################
  # Specify the ID of enemies who should have their image flipped in battle
  FLIP_ENEMY = []
 
end
###############################################################################
##  MAIN SCRIPT
###############################################################################
##  EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!
###############################################################################
class Game_Battler
  alias reedo_sbs_gb_add_state add_state
  def add_state(state_id)
    reedo_sbs_gb_add_state(state_id)
    if self.is_a?(Game_Actor) and $scene.is_a?(Scene_Battle)
      bs = $scene.reedo_get_battle_sprite(reedo_battle_sprite_id)
      return if bs == nil
      bs.reedo_bc_sprite.character.step_anime = reedo_check_step_anime
      reedo_update_life_state
    end
  end
 
  alias reedo_sbs_gb_remove_state remove_state
  def remove_state(state_id)
    reedo_sbs_gb_remove_state(state_id)
    if self.is_a?(Game_Actor) and $scene.is_a?(Scene_Battle)
      bs = $scene.reedo_get_battle_sprite(reedo_battle_sprite_id)
      return if bs == nil
      bs.reedo_bc_sprite.character.step_anime = reedo_check_step_anime
      reedo_update_life_state
    end    
  end
 
  def reedo_check_step_anime
    return false if dead?
    for state in states
      return false if REEDO_SBS::NO_STEP_STATES.include?(state.id)
      return false if REEDO_SBS::NO_STEP_RESTRICTIONS.include?(state.restriction)
    end
    return true
  end
 
  def reedo_update_life_state(battle_sprite = nil)
    if dead?
      if !@reedo_dead_set
        reedo_set_dead_state(battle_sprite)
        @reedo_dead_set = true
      end
    else
      if @reedo_dead_set
        reedo_set_live_state(battle_sprite)
        @reedo_dead_set = false
      end
    end
  end
 
  def reedo_reset_dead_set
    @reedo_dead_set = false
  end
 
  def reedo_set_dead_state(battle_sprite = nil)
    if battle_sprite == nil
      bs = $scene.reedo_get_battle_sprite(reedo_battle_sprite_id)
    else
      bs = battle_sprite
    end
    return if bs == nil
    return if bs.reedo_bc_sprite.is_dead
    bs.reedo_bc_sprite.angle = REEDO_SBS::ACTOR_DEATH_ANGLE
    tone = REEDO_SBS::ACTOR_DEATH_TONE
    bs.reedo_bc_sprite.tone.set(tone[0], tone[1], tone[2], tone[3])
    bs.reedo_bc_sprite.character.opacity = REEDO_SBS::ACTOR_DEATH_OPACITY
    bs.reedo_bc_sprite.character.screen_x += REEDO_SBS::ACTOR_DEATH_OFFSET_X
    bs.reedo_bc_sprite.character.screen_y += REEDO_SBS::ACTOR_DEATH_OFFSET_Y
    bs.reedo_bc_sprite.shadow_sprite.x += REEDO_SBS::ACTOR_DEATH_SHADOW_OFFSET_X
    bs.reedo_bc_sprite.shadow_sprite.y += REEDO_SBS::ACTOR_DEATH_SHADOW_OFFSET_Y    
    bs.reedo_bc_sprite.is_dead = true
  end
 
  def reedo_set_live_state(battle_sprite = nil)
    if battle_sprite == nil
      bs = $scene.reedo_get_battle_sprite(reedo_battle_sprite_id)
    else
      bs = battle_sprite
    end
    return if bs == nil
    return if bs.reedo_bc_sprite.is_dead != true
    bs.reedo_bc_sprite.angle = 0
    bs.reedo_bc_sprite.tone.set(0, 0, 0, 0)
    bs.reedo_bc_sprite.character.opacity = 255
    bs.reedo_bc_sprite.character.screen_x -= REEDO_SBS::ACTOR_DEATH_OFFSET_X
    bs.reedo_bc_sprite.character.screen_y -= REEDO_SBS::ACTOR_DEATH_OFFSET_Y
    bs.reedo_bc_sprite.shadow_sprite.x -= REEDO_SBS::ACTOR_DEATH_SHADOW_OFFSET_X
    bs.reedo_bc_sprite.shadow_sprite.y -= REEDO_SBS::ACTOR_DEATH_SHADOW_OFFSET_Y
    bs.reedo_bc_sprite.is_dead = false
  end
end

class Game_Actor
  attr_accessor :reedo_battle_sprite_id
  attr_accessor :screen_x
  attr_accessor :screen_y
end

class Game_Actors
  def members
    return @data
  end
end

class Game_Troop
  def troop_id
    return @troop_id
  end
end

class Game_Character  
  alias reedo_sbs_gc_screen_x screen_x
  def screen_x
    if $scene.is_a?(Scene_Battle)
      return @battle_screen_x
    else
      return reedo_sbs_gc_screen_x
    end
  end

  alias reedo_sbs_gc_screen_y screen_y
  def screen_y
    if $scene.is_a?(Scene_Battle)
      return @battle_screen_y
    else
      return reedo_sbs_gc_screen_y
    end
  end
 
  def opacity=(value)
    @opacity = value
  end
  def screen_x=(value)
    @battle_screen_x = value
  end
  def screen_y=(value)
    @battle_screen_y = value
  end
  def step_anime
    return @step_anime
  end
  def step_anime=(value)
    @step_anime = value
  end
end

class Sprite_Base
  attr_accessor :reedo_victory_wait
end

class Sprite_Character
  attr_accessor :shadow_sprite
  attr_accessor :is_dead
 
  alias reedo_sbs_sc_dispose dispose
  def dispose
    @shadow_sprite.dispose if @shadow_sprite != nil
    reedo_sbs_sc_dispose
  end
 
  def create_shadow_sprite
    @shadow_sprite = Sprite_Base.new(self.viewport)
    bmp = Cache.picture(REEDO_SBS::ACTOR_SHADOW_CUSTOM_PICTURE) if REEDO_SBS::ACTOR_SHADOW_CUSTOM_PICTURE != nil
    bmp = Cache.system(REEDO_SBS::ACTOR_SHADOW_IMAGE) if bmp == nil
    @shadow_sprite.bitmap = bmp
    @shadow_sprite.src_rect = Rect.new(0, 0, bmp.width, bmp.height)
    @shadow_sprite.x = self.x - self.ox + REEDO_SBS::ACTOR_SHADOW_OFFSET_X
    @shadow_sprite.y = self.y - self.oy + REEDO_SBS::ACTOR_SHADOW_OFFSET_Y
    @shadow_sprite.z = self.z - 1
  end
 
  alias reedo_sbs_sc_update update
  def update
    reedo_sbs_sc_update
    @shadow_sprite.update if @shadow_sprite != nil
  end
end

class Sprite_Battler
  attr_accessor :reedo_bc_sprite

  alias reedo_sbs_sb_dispose dispose
  def dispose
    @reedo_bc_sprite.dispose if @reedo_bc_sprite != nil
    reedo_sbs_sb_dispose
  end
 
  alias reedo_sbs_sb_update update
  def update
    reedo_sbs_sb_update
    @reedo_bc_sprite.update if @reedo_bc_sprite != nil
  end
end

class Spriteset_Battle
  alias reedo_sbs_ssb_create_battlefloor create_battlefloor
  def create_battlefloor
    reedo_sbs_ssb_create_battlefloor
    @battlefloor_sprite.y = REEDO_SBS::BATTLE_FLOOR_TOP
  end
 
##  alias reedo_sbs_ssb_create_actors create_actors
  def create_actors
    if @actor_sprites != nil
      dispose_actors
    end
##   reedo_sbs_ssb_create_actors
    @reedo_start_points = {}
    @actor_sprites = []
    i = 1
    for actor in $game_party.members
      actor.reedo_battle_sprite_id = i - 1        
      gc = Game_Character.new
      gc.set_graphic(actor.character_name, actor.character_index)
      gc.set_direction(4)
      gc.screen_x = 0; gc.screen_y = 0
      bc = Sprite_Character.new(@viewport1, gc)
      gc.screen_x = REEDO_SBS::ACTOR_START_LINE +
                    ($data_classes[actor.class_id].position *
                    REEDO_SBS::ACTOR_CLASS_POS_STAGGER) +
                    ((i - 1) * REEDO_SBS::ACTOR_STAGGER_HORZ)
      gc.screen_y = REEDO_SBS::ACTOR_START_TOP + ((bc.height * i) +
                    (REEDO_SBS::ACTOR_STAGGER_VERT * i))
      actor.screen_x = gc.screen_x; actor.screen_y = gc.screen_y
      sb = Sprite_Battler.new(@viewport1, actor)
      sb.reedo_victory_wait = REEDO_SBS::VICTORY_DANCE_JUMP_HOVER
      sb.reedo_bc_sprite = bc
      gc.step_anime = actor.reedo_check_step_anime
      @reedo_start_points[sb] = [gc.screen_x, gc.screen_y]
      @actor_sprites.push(sb)  
      bc.update
      bc.create_shadow_sprite
      actor.reedo_reset_dead_set
      actor.reedo_update_life_state(sb)
      i += 1
    end
  end
 
  alias reedo_sbs_ssb_create_enemies create_enemies
  def create_enemies
    reedo_sbs_ssb_create_enemies
    for sprite in @enemy_sprites
      if REEDO_SBS::FLIP_ENEMY.include?(sprite.battler.enemy_id)
        sprite.mirror = true
      end
    end
  end
 
  def update_actors
    if $scene.is_a?(Scene_Battle)
      if $scene.victory_dance_time
        reedo_update_victory_dance
      end
    end    
    for sprite in @actor_sprites
      sprite.reedo_bc_sprite.character.update
      sprite.update
    end
  end
 
  def reedo_get_battle_sprite(sprite_id)
    return nil if !sprite_id.is_a?(Fixnum)
    return nil if sprite_id < 0
    return nil if sprite_id >= @actor_sprites.length
    return @actor_sprites[sprite_id]
  end
 
  def reedo_update_victory_dance
    if @victory_delta == nil
      @victory_delta = -REEDO_SBS::VICTORY_DANCE_JUMP_INCREMENT
      for sp in @actor_sprites
        sp.reedo_bc_sprite.character.step_anime = false
      end
    end
    for sp in @actor_sprites
      next if sp.battler.reedo_check_step_anime == false
      stpt = @reedo_start_points[sp]
      if sp.reedo_bc_sprite.character.screen_y < stpt[1] - REEDO_SBS::VICTORY_DANCE_JUMP_HEIGHT
        if sp.reedo_victory_wait <= 0
          @victory_delta = REEDO_SBS::VICTORY_DANCE_JUMP_INCREMENT
          sp.reedo_victory_wait = REEDO_SBS::VICTORY_DANCE_JUMP_WAIT
        else
          @victory_delta = 0
          sp.reedo_victory_wait -= 1
        end
      end
      if sp.reedo_bc_sprite.character.screen_y > stpt[1]
        if sp.reedo_victory_wait <= 0
          @victory_delta = -REEDO_SBS::VICTORY_DANCE_JUMP_INCREMENT
          sp.reedo_victory_wait = REEDO_SBS::VICTORY_DANCE_JUMP_HOVER
          sp.reedo_bc_sprite.character.step_anime = false
        else
          @victory_delta = 0
          sp.reedo_victory_wait -= 1
          sp.reedo_bc_sprite.character.step_anime = true if !sp.reedo_bc_sprite.character.step_anime
        end
      end
      if REEDO_SBS::VICTORY_DANCE_JUMP_TWIST
        if sp.reedo_bc_sprite.character.screen_y <= stpt[1]
          if (sp.reedo_bc_sprite.character.screen_y - stpt[1]) % (REEDO_SBS::VICTORY_DANCE_JUMP_HEIGHT / 4) == 0
            case sp.reedo_bc_sprite.character.direction
            when 4; sp.reedo_bc_sprite.character.set_direction(2)
            when 2; sp.reedo_bc_sprite.character.set_direction(6)
            when 6; sp.reedo_bc_sprite.character.set_direction(8)
            when 8; sp.reedo_bc_sprite.character.set_direction(4)
            end
          end
        else
          sp.reedo_bc_sprite.character.set_direction(4) if sp.reedo_bc_sprite.character.direction != 4
        end
      end
      sp.reedo_bc_sprite.character.screen_y += @victory_delta
      sp.battler.screen_y += @victory_delta
    end
  end
end

class Scene_Battle
  attr_reader :victory_dance_time
 
  alias reedo_sbs_sb_start start
  def start
    reedo_sbs_sb_start
    @current_party = $game_party.members
  end
 
  alias reedo_sbs_sb_terminate terminate
  def terminate
    reedo_teardown_actors
    reedo_sbs_sb_terminate
  end
 
  alias reedo_sbs_sb_update update
  def update
    if @current_party != $game_party.members
      @spriteset.create_actors
      @current_party = $game_party.members
    end
    reedo_sbs_sb_update
  end
 
  alias reedo_sbs_sb_execute_action_attack execute_action_attack
  def execute_action_attack
    reedo_do_execute_action("attack")
  end

  alias reedo_sbs_sb_execute_action_skill execute_action_skill
  def execute_action_skill
    reedo_do_execute_action("skill")
  end
 
  alias reedo_sbs_sb_execute_action_item execute_action_item
  def execute_action_item
    reedo_do_execute_action("item")
  end
 
  alias reedo_sbs_sb_process_victory process_victory
  def process_victory
    @victory_dance_time = true
    reedo_sbs_sb_process_victory
  end
 
  def reedo_get_battle_sprite(sprite_id)
    return @spriteset.reedo_get_battle_sprite(sprite_id)
  end
 
  def reedo_teardown_actors
    for actor in $game_actors.members
      actor.reedo_battle_sprite_id = nil if actor != nil
    end
  end
 
  def reedo_do_execute_action(action_method)
    targets = @active_battler.action.make_targets
    if @active_battler.is_a?(Game_Actor)
      reedo_actor_step_in
      if REEDO_SBS::SBS_ACTION_ANIMES
        targets.each do |t|
          if t.is_a?(Game_Actor)
            bs = reedo_get_battle_sprite(t.reedo_battle_sprite_id)
            bs.reedo_bc_sprite.character.animation_id = eval("reedo_get_" + action_method + "_animation") if bs != nil
          end
        end
      end
      eval("reedo_sbs_sb_execute_action_" + action_method)
      reedo_actor_step_back
    else
      if REEDO_SBS::SBS_ACTION_ANIMES
        targets.each do |t|
          if t.is_a?(Game_Actor)
            bs = reedo_get_battle_sprite(t.reedo_battle_sprite_id)
            bs.reedo_bc_sprite.character.animation_id = eval("reedo_get_" + action_method + "_animation") if bs != nil
          end
        end
      end
      eval("reedo_sbs_sb_execute_action_" + action_method)
    end
  end
 
  def reedo_get_attack_animation
    return REEDO_SBS::SBS_DEFAULT_ATTACK_ANIME
  end
 
  def reedo_get_skill_animation
    skill = $data_skills[@active_battler.action.skill_id]
    aid = REEDO_SBS::SBS_DEFAULT_SKILL_ANIME
    aid = skill.animation_id if skill.animation_id > 0    
    return aid
  end

  def reedo_get_item_animation
    item = $data_items[@active_battler.action.item_id]
    aid = REEDO_SBS::SBS_DEFAULT_ITEM_ANIME
    aid = item.animation_id if item.animation_id > 0    
    return aid
  end
 
  def reedo_actor_step_in
    delta = 0
    dr = REEDO_SBS::ACTOR_STEP_IN_RATE
    while delta < REEDO_SBS::ACTOR_STEP_IN_DISTANCE
      bs = reedo_get_battle_sprite(@active_battler.reedo_battle_sprite_id)
      return if bs == nil
      bs.reedo_bc_sprite.shadow_sprite.x -= dr
      bs.reedo_bc_sprite.character.screen_x -= dr
      bs.battler.screen_x -= dr
      Graphics.update
      @spriteset.update
      delta += dr
    end
  end
 
  def reedo_actor_step_back
    delta = 0
    dr = REEDO_SBS::ACTOR_STEP_IN_RATE
    while delta < REEDO_SBS::ACTOR_STEP_IN_DISTANCE
      bs = reedo_get_battle_sprite(@active_battler.reedo_battle_sprite_id)
      return if bs == nil
      bs.reedo_bc_sprite.shadow_sprite.x += dr
      bs.reedo_bc_sprite.character.screen_x += dr
      bs.battler.screen_x += dr
      Graphics.update
      @spriteset.update
      delta += dr
    end
  end
end

 

What I would like to do, is exclude specific characters from dancing at the end of combat. Can anyone help me with that? Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×