Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Battlecry V3.4 Error

Hi there script gurus!

I'm receiving an error when my character is attacked while using this script. Strange, as I don't even have any values assigned yet.

Here is the error I get:

"Script' 1 - V3.4' line 722: NoMethodError occurred.
undefined method 'include?' for nil:NilClass"

And here is the script (line 722 highlighted):


Code:
#==============================================================================

# ** Dalissa's Battle Cry

#      by DerVVulfman

#      Version 3.4-b (Game_System instance version)

#      02-03-2007

#    Full SDK 2.3 Compatible (Does not need or require SDK 2.3)

#------------------------------------------------------------------------------

#

#  INTRODUCTION:

#

#  This add-on system allows you to pre-program additional vocal cues for your

#  battlers so they can play these additional vocals during battle events.  It

#  can perform battle cries for heroes and enemies, for regular attacks or for

#  skill events.

#

#  This script was a request by a couple of friends.   Both wanted a system to 

#  enhance their combat systems  and personalize  their battles  with an audio

#  system not dependant on the "battle animation" built into RMXP.   Now, with

#  this script, you can set each battler to scream out their 'battle cry' when

#  they perform their battle action.

#

#

#------------------------------------------------------------------------------

#

#  THE CONFIGURATION SECTION:

#

#  This version uses instance values stored within the $game_system class.  As

#  such, it has two bonuses:   reduced memory requirements  and a smaller RMXP

#  script.  This version is smaller than the one that uses ($)Global values.

#

#  However,  calling the values 'in-game' from map events or in-script requires 

#  you to call the $game_system class to perform any changes:

#

#  EX:

#  @>script: $game_system.actor_cry_attack = {1 >= "Charge",

#   :      :    2 => "Yarrrr", 7 => "HieeeYah", 8 => "Haa" }

#

#  Not much except the string is a little longer as it requres the $game_system

#  prefix at the start of each value.

#

#  Also as stated,  the values are stored  withing the $game_system class.   As 

#  such, the configuration system  of this script is located around line 238 of

#  this script, and not at the top.

#

#------------------------------------------------------------------------------

#

#  SETTING THE BATTLECRIES:

#

#  First off,  let me point out  that this system  plays audio clips  that are

#  kept in either your project's or the RTP's Audio\SE directory.  These clips

#  may be of any file format goverened by RMXP, and as such, no file extension

#  will be necessary when actually setting up your battlecry system.

#

#  In this script's  "CONFIGURATION"  system,  you will see two sets of hashes,

#  one set for the actor battlers  and the other for the enemy battlers.   Each

#  set has eight identical hashes:  Attack, Skill, Skill_I, Item, Item_I, Block

#  Escape and Defeat.

#

#  Under most circumstances,  you merely need to enter  the ID number of a bat-

#  tler and the audio clip  it will perform...  or a group  of battlers  as the

#  below syntax shows:

#

#  $hash = { battler id => "audioclip", battler id => "audioclip", .... }

#

#

#  *** Please see the Audio Clip section (below) regarding files and pitch. ***

#

#

#  A few hashes are designed for items and skills,  allowing you to set a range

#  of audio effects for each battler.  Each battler can now have multiple audio

#  clips, one for each skill and/or item used.  The syntax for these few hashes

#  is similar in nature:

#

#  hash = { battler id => { id => "audioclip", id => "audioclip",... },... }

#

#  A few more hashes are designed to give a range of random sound effects. 

#  These are designed in the following fashion:

#

#  hash = { battler id => [ "audioclip", "audioclip",...],... }

#

#  And a few actually combine the two, individual skills/items 'and' random

#  audio clips...  though that may seem excessive???

#

#  hash = {battler => (id => ["audio",...], id=>["audio",... ],... },... }

#

#  If, for example,  you want a 'ghost'  battler to moan when it is performing

#  an attack (assuming it's enemy #1 in your RTP), you would add the following:

#

#       $game_system.enemy_cry_attack = {1 => "GhostMoan01"}

#

#  ... assuming you have an audio file named  "GhostMoan01"  in your project's

#  Audio\SE directory  or in your RTP directory.   Again,  please note that no

#  file extension is needed or required.  

#

#  And, if you were to set TWO sets of battlecries  (one for a ghost & one for 

#  a zombie),  you'd enter them in the following manner  (again,  assuming the

#  RTP monsters are being used):

#

#       $game_system.enemy_cry_attack = {1 => "GhostMoan01", 9 => "ZombieGroan04"}

#

#  As you can see, you can skip between battlers when setting audio clips. And

#  while it is preferred to enter them in the id number order, it isn't neces-

#  sary.

#

# (NOTE:  Enemies normally cannot use items, so unless an additional script has

#         been added that permits item usage for enemies,  the item hashes will

#         be useless.)

#

#  To prevent monotony, there is an additional value that is in the system be-

#  low the two sets of hashes.  This value, 'occur_cry_chance', determines the

#  chance of an audio clip to be played.   A value of 100 equals a 100% chance

#  of the file to be played, while a 25 gives the system a 1 in 4 chance of it

#  being played.

#

#------------------------------------------------------------------------------

#

#  AUDIO CLIPS:

#

#  It's not enough that this system  allows you to play  pre-programmed Sounds

#  for your battlers,  but you can even determine if the effect played is of a

#  non-standard pitch.

#

#  What does this mean?

#

#  You can use the same audio file in your project for different battlers, and

#  make them sound different  just by changing the pitch setting being used by

#  that clip.  Valid pitch ranges from 50 to 150 (aka 50% to 150% of normal).

#

#  Setting a 'audioclip' can now be performed  by entering the filename alone,

#  which automatically sets the pitch to 100 (the default).   Or you can enter

#  an array that combines both the filename and pitch.  

#

#  Example:

#    @actor_cry_attack        = { 1 => "Test1", 2 => ["Test2", 120],... }

#

#  This example sets the 1st battler to use a file called 'Test1' and uses the

#  default pitch level.  The 2nd battler uses a file called 'Test2' and is set

#  to 120%

#

#------------------------------------------------------------------------------

#

#  COMPATIBILITY:

#

#  This script was designed around the basic DBS system.   I can confirm it's

#  functionality with the RTAB system,  as well as ParaDog's CTB v 2.58,  the

#  newest CTB by XRXS (version 65a).

#

#  It is NOT compatible with Ccoa's CTB v 3.04 script and it is unknown as to

#  the compatability to KGC's Active Count Battle system.

#

#  This audio system will not work, and is not compatible with Cybersam's Ani-

#  mation system.

#

#------------------------------------------------------------------------------

#

#  KNOWN ISSUES:

#

#  As this system retrieves the action states of the battlers:  Attack, Skill,

#  Item...  and from nothing else,  then this system begins to play the battle

#  cries from the  very moment  these states are triggered.   The only battler

#  overlay system  (Front-View system to a Side-View System)  that this script

#  works with is the new incarnation of Minkoff's Animated Battlers - Enhanced

#  (version 4.7 or higher) as a trigger system has been recently added to that

#  script.

#

#  Earlier versions of Animated Battlers will not play the audio clips for the

#  battlers... if any are still around.

#

#------------------------------------------------------------------------------

#

#  JUST IN CASE:

#

#  By default, the battlecry system will merely NOT play any sound effect if a

#  given battler has no related audio clip.  The system will even skip search-

#  ing through the system  if a hash is empty.   This is  designed  to prevent 

#  avoidable errors  as well  as to play  only the proper clip  for the proper

#  battler.

#

#  Also, with a little assistance from Me? and Mr.Mo,  I was able to create an

#  Error-Check routine that 'ensures' that no error  in this system will cause

#  the system to crash.

#

#  For example, if you enter into a hash of audio clips in the system,  a piece

#  that doesn't exist (either in the project or the RTP file), then this script

#  will merely skip playing this audio file to prevent errors.

#

#------------------------------------------------------------------------------

#

#  THANKS:

#

#  Thanks to  Mimi-Chan  and  ~AtlasWing~  for requesting  this script,  and to 

#  grimreaper1357 for noticing a 'bug',  though it wasn't the error  he thought 

#  it was.  uzumakishade, for 'forcing my hand' to add weapon hashes.   He also

#  suggested the inclusion of 'random' sets for each audio type.  I went so far

#  as to  expand and allow  each skill,  item  & etc to have multiple  'random'

#  Clips. And thanks to Grimreaper1357 for suggesting 'struck' audio clips, and 

#  to joooda for suggesting  'critical hit'  audio clips.   Thanks also goes to

#  Nico_14_Ian and vpcdmd for finding a mistake with random-individual cries...

#  fixed now.   To pierce carradine I thank  for finding an annoying glitch for

#  collapse effects that only  used the last battler's collapse effect, and for

#  finding the 'miss' damage glitch that prevented the same effect from working.

#  And to ElMaligno for noticing that default 'field' actions  (Items, Skills &

#  Attack commands... map event routines) didn't properly work,  and for disco-

#  vering a glich when 'healing' items/spells were used on the map.  Fixed.

#

#==============================================================================

 

 

 

#==============================================================================

# ** Game_System

#------------------------------------------------------------------------------

#  This class handles data surrounding the system. Backround music, etc.

#  is managed here as well. Refer to "$game_system" for the instance of 

#  this class.

#==============================================================================

 

class Game_System

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :default_ase

  attr_accessor :default_ese

  attr_accessor :actor_cry_attack

  attr_accessor :actor_cry_attack_r

  attr_accessor :actor_cry_attack_i

  attr_accessor :actor_cry_attack_r_i

  attr_accessor :actor_cry_skill

  attr_accessor :actor_cry_skill_r

  attr_accessor :actor_cry_skill_i

  attr_accessor :actor_cry_skill_r_i

  attr_accessor :actor_cry_item

  attr_accessor :actor_cry_item_r

  attr_accessor :actor_cry_item_i

  attr_accessor :actor_cry_item_r_i

  attr_accessor :actor_cry_block

  attr_accessor :actor_cry_block_r

  attr_accessor :actor_cry_escape

  attr_accessor :actor_cry_escape_r

  attr_accessor :actor_cry_struck

  attr_accessor :actor_cry_struck_r

  attr_accessor :actor_cry_critical

  attr_accessor :actor_cry_critical_r

  attr_accessor :actor_cry_defeat

  attr_accessor :actor_cry_defeat_r

  attr_accessor :enemy_cry_attack

  attr_accessor :enemy_cry_attack_r

  attr_accessor :enemy_cry_attack_i

  attr_accessor :enemy_cry_attack_r_i

  attr_accessor :enemy_cry_skill

  attr_accessor :enemy_cry_skill_r

  attr_accessor :enemy_cry_skill_i

  attr_accessor :enemy_cry_skill_r_i

  attr_accessor :enemy_cry_item

  attr_accessor :enemy_cry_item_r

  attr_accessor :enemy_cry_item_i

  attr_accessor :enemy_cry_item_r_i

  attr_accessor :enemy_cry_block

  attr_accessor :enemy_cry_block_r

  attr_accessor :enemy_cry_escape

  attr_accessor :enemy_cry_escape_r

  attr_accessor :enemy_cry_struck

  attr_accessor :enemy_cry_struck_r

  attr_accessor :enemy_cry_critical

  attr_accessor :enemy_cry_critical_r

  attr_accessor :enemy_cry_defeat

  attr_accessor :enemy_cry_defeat_r

  attr_accessor :occur_cry_chance

  attr_accessor :anim_cry_detect

  attr_accessor :rtab_cry_detect

 

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  alias dbc_init initialize

  def initialize

    # Perform the original call

    dbc_init

    

   #========================================================================

   #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #

   #========================================================================

    # Hero battle cries

    @actor_cry_attack       = {}

      @actor_cry_attack_r   = {}

      @actor_cry_attack_i   = {}

      @actor_cry_attack_r_i = {}

    @actor_cry_skill        = {}    

      @actor_cry_skill_r    = {}    

      @actor_cry_skill_i    = {}

      @actor_cry_skill_r_i  = {}

    @actor_cry_item         = {}

      @actor_cry_item_r     = {} 

      @actor_cry_item_i     = {}

      @actor_cry_item_r_i   = {}

    @actor_cry_block        = {}

      @actor_cry_block_r    = {}

    @actor_cry_escape       = {}

      @actor_cry_escape_r   = {}

    @actor_cry_struck       = {}

      @actor_cry_struck_r   = {}

    @actor_cry_critical     = {}

      @actor_cry_critical_r = {}

    @actor_cry_defeat       = {}

      @actor_cry_defeat_r   = {}

      

    # Enemy battle cries

    @enemy_cry_attack       = {}

      @enemy_cry_attack_r   = {}# { 6 => ["Mimi-01", "Mimi-03", "Mimi-07", "eya"] }

      @enemy_cry_attack_i   = {}

      @enemy_cry_attack_r_i = {}

    @enemy_cry_skill        = {}

      @enemy_cry_skill_r    = {}

      @enemy_cry_skill_i    = {}

      @enemy_cry_skill_r_i  = {}

    @enemy_cry_item         = {}

      @enemy_cry_item_r     = {}

      @enemy_cry_item_i     = {}

      @enemy_cry_item_r_i   = {}

    @enemy_cry_block        = {}

      @enemy_cry_block_r    = {}

    @enemy_cry_escape       = {}

      @enemy_cry_escape_r   = {}

    @enemy_cry_struck       = {}

      @enemy_cry_struck_r   = {}

    @enemy_cry_critical     = {}

      @enemy_cry_critical_r = {}

    @enemy_cry_defeat       = {}

      @enemy_cry_defeat_r   = {}

    

    # Chance of occuring

    @occur_cry_chance   = 100

    

    # Final - Arrays for collapse system

    @default_ase = []

    @default_ese = []   

 

  end  

end

 

 

 

#==============================================================================

# ** Dalissa's Collapse

#------------------------------------------------------------------------------

#  This module performs routines for choosing the collapse SE played during combat.

#==============================================================================

 

module Dalissa_Collapse

  #--------------------------------------------------------------------------

  # * Collapse Changing Call

  #--------------------------------------------------------------------------   

  def call_collapse_change

    # Create temporary hash and array

    bcry_temp       = {}

    battlecollapse  = []

    battlecharge    = []

    # Retrieve Cry Based on Battler

    if self.is_a?(Game_Enemy)

      battlecollapse = $game_system.default_ese

      battlecollapse = $game_system.enemy_cry_defeat[self.id] if $game_system.enemy_cry_defeat.include?(self.id)

      bcry_temp      = $game_system.enemy_cry_defeat_r[self.id] if $game_system.enemy_cry_defeat_r.include?(self.id)

      bcry_rand      = rand(bcry_temp.size) if bcry_temp != nil

      battlecollapse = bcry_temp[bcry_rand] if bcry_temp[bcry_rand] != nil

    else

      battlecollapse = $game_system.default_ase

      battlecollapse = $game_system.actor_cry_defeat[self.id] if $game_system.actor_cry_defeat.include?(self.id)

      bcry_temp      = $game_system.actor_cry_defeat_r[self.id] if $game_system.actor_cry_defeat_r.include?(self.id)

      bcry_rand      = rand(bcry_temp.size) if bcry_temp != nil

      battlecollapse = bcry_temp[bcry_rand] if bcry_temp[bcry_rand] != nil

    end

    # Set with default pitch if converted string

    if battlecollapse.is_a?(Array)

      battlecharge = battlecollapse

    else

      battlecharge = [battlecollapse, 100]

    end    

    # Reset to nil if empty

    battlecharge = nil if battlecharge[0] == []    

    # If the battle cry isn't nil

    if battlecharge != nil

      begin

        @trd = RPG::AudioFile.new(battlecharge[0])

        Audio.se_play("Audio/SE/" + @trd.name, 0, battlecharge[1])

        # Sound file is true

      rescue Errno::ENOENT

        # Sound file is invalid (restore default)

        battlecharge = nil

      end 

      # Set the cry

      if battlecharge != nil 

        # Branch based on battler type

        if self.is_a?(Game_Enemy)

          $data_system.enemy_collapse_se.name   = battlecharge[0]

          $data_system.enemy_collapse_se.pitch  = battlecharge[1]

        else

          $data_system.actor_collapse_se.name   = battlecharge[0]

          $data_system.actor_collapse_se.pitch  = battlecharge[1]

        end

      # Else reset the default  

      else

        # Branch based on battler type

        if self.is_a?(Game_Enemy)

          $data_system.enemy_collapse_se.name   = $game_system.default_ese[0]

          $data_system.enemy_collapse_se.pitch  = $game_system.default_ese[1]

        else

          $data_system.actor_collapse_se.name   = $game_system.default_ase[0]

          $data_system.actor_collapse_se.pitch  = $game_system.default_ase[1]

        end        

      end

    end

  end

end

 

 

 

#==============================================================================

# ** Dalissa's Cry

#------------------------------------------------------------------------------

#  This module performs routines for playing the selected battlecry itself

#==============================================================================

 

module Dalissa_Cry

  #--------------------------------------------------------------------------

  # * Play the Cry

  #--------------------------------------------------------------------------

  def play_cry(battlecry)

    # Error checking.  Makes sure that even the default sound file is available.

    # If it is missing, then the system will set the battle cry to >none<.

    #

    # If the chance of the battle cry is true

    if rand(100) <= $game_system.occur_cry_chance

      # If the battle cry isn't nil

      if battlecry != nil

        # Separate file and pitch values

        battlefile  = battlecry[0]

        battlepitch = battlecry[1]

        begin

          @trd = RPG::AudioFile.new(battlefile)

          Audio.se_play("Audio/SE/" + @trd.name, 0, battlepitch)

          # Sound file is true

        rescue Errno::ENOENT

          # Sound file is invalid (restore default)

          battlecry = nil

        end 

        # Play the cry

        if battlecry != nil 

          Audio.se_play("Audio/SE/" + @trd.name, 80, battlepitch)

        end

      end

    end

  end  

end

 

 

 

#==============================================================================

# ** Game_Battler 

#------------------------------------------------------------------------------

#  This class deals with battlers. It's used as a superclass for the Game_Actor

#  and Game_Enemy classes.

#==============================================================================

 

class Game_Battler

  include Dalissa_Collapse

  include Dalissa_Cry

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------  

  attr_accessor :dbc_b_dmg

  #--------------------------------------------------------------------------

  # * Applying Normal Attack Effects

  #     attacker : battler

  #--------------------------------------------------------------------------

  alias dbc_ae attack_effect

  def attack_effect(attacker)

    # Setup return value

    result = false

    # Perform the Original call

    result = dbc_ae(attacker)

    # If in battle

    if $game_temp.in_battle     

      # Obtain pre-damaged HP

      cry_dmg = self.hp

      # Obtain damage applied

      $game_system.rtab_cry_detect ? self_dmg = self.damage[attacker] : self_dmg = self.damage

      # Calculate current HP (for Collapse Changing Call)

      cry_dmg -= self_dmg  if self_dmg.to_i != 0

      # The Included module (Collapse Changing Call)

      call_collapse_change if cry_dmg <= 0

    end

    # Return with result

    return result

  end

  #--------------------------------------------------------------------------

  # * Apply Skill Effects

  #     user  : the one using skills (battler)

  #     skill : skill

  #--------------------------------------------------------------------------

  alias dbc_se skill_effect

  def skill_effect(user, skill)

    # Setup return value

    result = false

    # Perform the Original call

    result = dbc_se(user, skill)

    # If in battle

    if $game_temp.in_battle

      # Obtain pre-damaged HP

      cry_dmg = self.hp

      # Obtain damage applied

      $game_system.rtab_cry_detect ? self_dmg = self.damage[user] : self_dmg = self.damage

      # Calculate current HP (for Collapse Changing Call)

      cry_dmg -= self_dmg  if self_dmg.to_i != 0

      # The Included module (Collapse Changing Call)

      call_collapse_change if cry_dmg <= 0

    end

    # Return with result

    return result

  end

  #--------------------------------------------------------------------------

  # * Application of Item Effects

  #     item : item

  #--------------------------------------------------------------------------

  alias dbc_ie item_effect

  def item_effect(item, battler = @active_battler)

    # Setup return value

    result = false

    # Perform the Original call  

    $game_system.rtab_cry_detect ? result = dbc_ie(item, battler) : result = dbc_ie(item)

    # If in battle

    if $game_temp.in_battle

      # Obtain pre-damaged HP

      cry_dmg = self.hp

      # Obtain damage applied

      $game_system.rtab_cry_detect ? self_dmg = self.damage[battler] : self_dmg = self.damage

      # Calculate current HP (for Collapse Changing Call)

      cry_dmg -= self_dmg  if self_dmg.to_i != 0

      # The Included module (Collapse Changing Call)

      call_collapse_change if cry_dmg <= 0

    end

    # Return with result

    return result

  end

end

 

 

 

#==============================================================================

# ** Scene_Battle

#------------------------------------------------------------------------------

#  This class performs battle screen processing.

#==============================================================================

 

class Scene_Battle

  include Dalissa_Collapse

  include Dalissa_Cry

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  alias dbc_main main

  def main

    # Store original 'collapse' SE

    $game_system.default_ase  = [ $data_system.actor_collapse_se.name,

                                  $data_system.actor_collapse_se.pitch ]

    $game_system.default_ese  = [ $data_system.enemy_collapse_se.name,

                                  $data_system.enemy_collapse_se.pitch ]

    # Perform the original call

    dbc_main

    # Restore original 'collapse' SE

    $data_system.actor_collapse_se.name   = $game_system.default_ase[0]

    $data_system.actor_collapse_se.pitch  = $game_system.default_ase[1]

    $data_system.enemy_collapse_se.name   = $game_system.default_ese[0]

    $data_system.enemy_collapse_se.pitch  = $game_system.default_ese[1]

  end

  #--------------------------------------------------------------------------

  # * Frame Update (main phase step 2 : start action)

  #--------------------------------------------------------------------------

  alias update_phase4_step2_scream update_phase4_step2

  def update_phase4_step2(battler = @active_battler)

    # Do not perform here if Animated Battlers is detected

      unless $game_system.anim_cry_detect == true

      # Obtain & Play Battle Cries

      perform_cry(battler)

    end  

    # Perform original routine  

    if $game_system.rtab_cry_detect == true

      update_phase4_step2_scream(battler)

    else

      update_phase4_step2_scream

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (main phase step 3 : animation for action performer)

  #--------------------------------------------------------------------------  

  alias dbc_update_phase4_step3 update_phase4_step3

  def update_phase4_step3(battler = @active_battler)

    # Perform original routine  

    if $game_system.rtab_cry_detect == true

      dbc_update_phase4_step3(battler)

    else

      dbc_update_phase4_step3

    end

    # Only perform if using Animated Battlers

    if $game_system.anim_cry_detect == true

      if $battle_charge == true

        # Obtain & Play Battle Cries

        perform_cry(battler)

        # Reset Flag

        $battle_charge = false

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (main phase step 3 : animation for action performer)

  #--------------------------------------------------------------------------  

  alias dbc_up4s4 update_phase4_step4

  def update_phase4_step4(battler = @active_battler)

    # Loop through all targetted battlers

    for target in ($game_system.rtab_cry_detect ? battler.target : @target_battlers)

      # Calculate for successful hit

      dbc_damage = ($game_system.rtab_cry_detect ? target.damage[battler] : target.damage)

      dbc_critical = ($game_system.rtab_cry_detect ? target.critical[battler] : target.critical)

      # If damage DID occur

      if dbc_damage.is_a?(Numeric) and dbc_damage > 0

        bcry_temp = {}

        battlecry = nil

        # Obtain Battle Cries for Enemies

        if target.is_a?(Game_Enemy)

          battlecry = choosecry2(target.id, $game_system.enemy_cry_struck, $game_system.enemy_cry_struck_r)

          if dbc_critical

            battlecry = choosecry2(target.id, $game_system.enemy_cry_critical, $game_system.enemy_cry_critical_r)

          end

        else

          battlecry = choosecry2(target.id, $game_system.actor_cry_struck, $game_system.actor_cry_struck_r)

          if dbc_critical

            battlecry = choosecry2(target.id, $game_system.actor_cry_critical, $game_system.actor_cry_critical_r)

          end

        end

        # Perform the cry

        play_cry(battlecry)

        # Erase Battle Cry

        battlecry = nil

      end

    end

    # Perform the original call

    if $game_system.rtab_cry_detect

      dbc_up4s4(battler)

    else

      dbc_up4s4

    end

  end  

  #--------------------------------------------------------------------------

  # * Retrieve & Perform the Cry

  #--------------------------------------------------------------------------

  def perform_cry(battler)

    # Re-Set Battle Cry to empty

    battlecry = nil

    # Create temporary hash

    bcry_temp = {}

    # Obtain Battle Cries for Enemies

    if battler.is_a?(Game_Enemy)

      # Branch according to each action

      case battler.current_action.kind

      when 0  # basic

        battlecry = choosecry(battler.id, $game_system.enemy_cry_attack, $game_system.enemy_cry_attack_i, $game_system.enemy_cry_attack_r, $game_system.enemy_cry_attack_r_i, battler.weapon_id)

        # If blocking

        if battler.current_action.basic == 1

          battlecry = choosecry2(battler.id, $game_system.enemy_cry_block, $game_system.enemy_cry_block_r)

        end

        # If escaping

        if battler.current_action.basic == 2

          battlecry = choosecry2(battler.id, $game_system.enemy_cry_escape, $game_system.enemy_cry_escape_r)

        end

        # If resting

        if battler.current_action.basic == 3

          battlecry = nil

        end

      when 1  # skill

        battlecry = choosecry(battler.id, $game_system.enemy_cry_skill, $game_system.enemy_cry_skill_i, $game_system.enemy_cry_skill_r, $game_system.enemy_cry_skill_r_i, battler.current_action.skill_id)

      when 2  # item

        battlecry = choosecry(battler.id, $game_system.enemy_cry_item, $game_system.enemy_cry_item_i, $game_system.enemy_cry_item_r, $game_system.enemy_cry_item_r_i, battler.current_action.item_id)

      end

    # otherwise, Obtain Battle Cries for Actors

    else

      # Branch according to each action

      case battler.current_action.kind

      when 0  # basic

        battlecry = choosecry(battler.id, $game_system.actor_cry_attack, $game_system.actor_cry_attack_i, $game_system.actor_cry_attack_r, $game_system.actor_cry_attack_r_i, battler.weapon_id)

        # If blocking

        if battler.current_action.basic == 1

          battlecry = choosecry2(battler.id, $game_system.actor_cry_block, $game_system.actor_cry_block_r)

        end

        # If escaping

        if battler.current_action.basic == 2

          battlecry = choosecry2(battler.id, $game_system.actor_cry_escape, $game_system.actor_cry_escape_r)

          end

        # If resting

        if battler.current_action.basic == 3

          battlecry = nil

        end

      when 1  # skill

        battlecry = choosecry(battler.id, $game_system.actor_cry_skill, $game_system.actor_cry_skill_i, $game_system.actor_cry_skill_r, $game_system.actor_cry_skill_r_i, battler.current_action.skill_id)

      when 2  # item

        battlecry = choosecry(battler.id, $game_system.actor_cry_item, $game_system.actor_cry_item_i, $game_system.actor_cry_item_r, $game_system.actor_cry_item_r_i, battler.current_action.item_id)

      end

    end

    # Perform the cry

    play_cry(battlecry)

    # Erase Battle Cry

    battlecry = nil

  end

  #--------------------------------------------------------------------------

  # * Choose the cry

  #--------------------------------------------------------------------------

  def choosecry(dbc_battler, dbc_main, dbc_i, dbc_r, dbc_r_i, dbc_id)

    # Create empty hash for substitutions

    dbc_temp  = {}

    dbc_temp2 = {}

    dbc_cry   = []

    dbc_cry2  = []

    # Set basic cry

    [color=#FF0000]dbc_cry     = dbc_main[dbc_battler]   if dbc_main.include?(dbc_battler)[/color]

    # Fill temp value & obtain battlecry (Individual)

    dbc_temp    =   dbc_i[dbc_battler]    if dbc_i.include?(dbc_battler)

    dbc_cry     =   dbc_temp[dbc_id]      if dbc_temp[dbc_id]     != nil

    # Fill temp value & obtain battlecry (Random)

    dbc_temp    =   nil # Empty the temp value

    dbc_temp    =   dbc_r[dbc_battler]    if dbc_r.include?(dbc_battler)

    if dbc_temp !=  nil

      dbc_rand  =   rand(dbc_temp.size)

      dbc_cry   =   dbc_temp[dbc_rand]    if dbc_temp[dbc_rand]   != nil

    end

    # Fill temp value & obtain battlecry (Individual Randoms)

    dbc_temp = nil    # Empty the temp value

    dbc_temp    =   dbc_r_i[dbc_battler]  if dbc_r_i.include?(dbc_battler)

    if dbc_temp !=  nil

      dbc_temp2 =   dbc_temp[dbc_id]      if dbc_temp[dbc_id]     != nil

      dbc_rand  =   rand(dbc_temp2.size)  if dbc_temp2            != nil

      dbc_cry   =   dbc_temp2[dbc_rand]   if dbc_temp2[dbc_rand]  != nil

    end

    # Reset to nil if empty

    dbc_cry = nil if dbc_cry == []

    # Return if nil

    return if dbc_cry == nil

    # Return with default pitch if converted string

    unless dbc_cry.is_a?(Array)

      dbc_cry2 = [dbc_cry, 100]

      return dbc_cry2

    end

    # Return the cry

    return dbc_cry

  end  

  #--------------------------------------------------------------------------

  # * Choose the cry (smaller version)

  #--------------------------------------------------------------------------

  def choosecry2(dbc_battler, dbc_main, dbc_r)

    # Create empty hash for substitutions

    dbc_temp = {}

    dbc_cry   = []

    dbc_cry2  = []

    # Set basic cry

   dbc_cry     = dbc_main[dbc_battler] if dbc_main.include?(dbc_battler)

    # Fill temp value & obtain battlecry (Random)

    dbc_temp    = dbc_r[dbc_battler]    if dbc_r.include?(dbc_battler)

    dbc_rand    = rand(dbc_temp.size)   if dbc_temp != nil

    dbc_cry     = dbc_temp[dbc_rand]    if dbc_temp[dbc_rand] != nil

    # Reset to nil if empty

    dbc_cry = nil if dbc_cry == []

    # Return if nil

    return if dbc_cry == nil

    # Return with default pitch if converted string

    unless dbc_cry.is_a?(Array)

      dbc_cry2 = [dbc_cry, 100]

      return dbc_cry2

    end

    # Return the cry

    return dbc_cry

  end

end

 

 

 

#==============================================================================

# ** Spriteset_Battle

#------------------------------------------------------------------------------

#  This class brings together battle screen sprites. It's used within

#  the Scene_Battle class.

#==============================================================================

class Spriteset_Battle

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  # Special note:  When the normal method for detecting RTAB fails, I do this

  alias bcry_initialize initialize

  def initialize

    # Perform the original routine

    bcry_initialize

    # If RTAB's 'zoom' feature is present

    if @real_zoom != nil

      # Set the RTAB detector to 'true'

      $game_system.rtab_cry_detect = true

    end

  end

end

 

 

 

#==============================================================================

# ** Sprite_Battler

#------------------------------------------------------------------------------

#  This sprite is used to display the battler.  It observes the Game_Character

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Sprite_Battler < RPG::Sprite

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  alias bcry_initialize initialize

  def initialize(viewport, battler = nil)

    # Perform the original routine

    bcry_initialize(viewport,battler)

    # If Animated Battler's 'battler offset' feature is present

    if @battler_offset != nil

      # Set the Animated Battlers detector to 'true'

      $game_system.anim_cry_detect = true

    end

  end

end

Any ideas?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top