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.

Please help me debug this

When I use the Weapon Unleash script, I got the error message:
Script "Weapon_Unleash" line 42: NameError occurred
Uninitialized constant Vocab

If I delete the above line, this error occur:
Script 'Weapon_Unleash' line 84: NameError occurred.
undefined method 'execute_action_attack' for class 'Scene_Battle'

Other scripts I'm currently using are:
SDK
MACL
After Battle Change
Show HP, SP, EXP bar
Custom skill screen
Weapon-dependent skill

Here is the script:
Code:
#==============================================================================

# ** Weapon Unleash

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

#  © Dargor, 2008

#  04/03/08

#  Version 1.1

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

#  INSTRUCTIONS:

#   - Edit the constants in the Weapon_Unleash module and enjoy!

#  VERSION HISTORY:

#   - 1.0 (02/03/08), Initial release

#   - 1.1 (04/03/08), Two Swords Style support has been added

#   - 1.2 (04/03/08), Display bug fixed with Battle Frenzy script

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

 

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

#  ** Weapon Unleash Configuration

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

 

module Weapon_Unleash

  # Weapons that can unleash a skill

  Weapons = [1,2,3]

  # The skill unleashed by weapon_id

  # SYNTAX: weapon_id => skill_id

  Skill = {

              1 => 59,

              2 => 82

            }

  # Default skill unleashed         

  Skill.default = 1

  # Chances in percent to unleash a skill

  # SYNTAX: weapon_id => percent

  Rate = {

              1 => 100,

              2 => 100

             }

  # Default rate         

  Rate.default = 25         

end

 

# Text displayed in the battle text window when the skill is unleashed

Vocab::WeaponUnleash = "%s's %s unleashed %s!"

 

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

# ** Game_Actor

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

#  This class handles actors. It's used within the Game_Actors class

# ($game_actors) and referenced by the Game_Party class ($game_party).

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

 

class Game_Actor < Game_Battler

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

  # * Get Normal Attack Animation ID

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

  def atk_animation_id

    if two_swords_style

      return weapons[0].animation_id if weapons[0] != nil

      return weapons[1] == nil ? 1 : 1

    else

      return weapons[0] == nil ? 1 : weapons[0].animation_id

    end

  end

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

  # * Get Normal Attack Animation ID (Dual Wield: Weapon 2)

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

  def atk_animation_id2

    if two_swords_style

      return weapons[1] == nil ? 1 : weapons[1].animation_id

    else

      return 1

    end

  end

end

 

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

# ** Scene_Battle

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

#  This class performs battle screen processing.

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

 

class Scene_Battle < Scene_Base

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

  # * Alias listing

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

  alias dargor_execute_action_attack execute_action_attack

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

  # * Execute Battle Action: Attack

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

  def execute_action_attack

    # Execute weapon unleash check

    if @active_battler.is_a?(Game_Actor)

      weapon = @active_battler.weapons[0]

      if weapon_can_unleash?(weapon)

        # Execute weapon unleash for weapon 1

        execute_action_weapon_unleash(weapon)

      else

        # Execute normal attack for weapon 1

        execute_specific_action_attack(1)

      end

      # If battler has two swords style

      if @active_battler.two_swords_style

        weapon = @active_battler.weapons[1]

        if weapon_can_unleash?(weapon)

          # Execute weapon unleash for weapon 2

          execute_action_weapon_unleash(weapon)

        else

          # Execute normal attack for weapon 2

          execute_specific_action_attack(2)

        end

      end   

    # Execute normal attack

    else

      dargor_execute_action_attack

    end

  end

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

  # * Execute Specific Battle Action: Attack

  #     weapon : actor's weapon (1 or 2)

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

  def execute_specific_action_attack(weapon)

    if weapon == 1

      animation = @active_battler.atk_animation_id

    end

    if weapon == 2

      animation = @active_battler.atk_animation_id2

    end

    text = sprintf(Vocab::DoAttack, @active_battler.name)

    @message_window.add_instant_text(text)

    targets = @active_battler.action.make_targets

    display_normal_animation(targets, animation)

    wait(30)

    for target in targets

      target.attack_effect(@active_battler)

      display_action_effects(target)

    end

  end

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

  # * Execute Battle Action: Weapon Unleash

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

  def execute_action_weapon_unleash(weapon)

    skill = $data_skills[Weapon_Unleash::Skill[weapon.id]]

    skill = $data_skills[Weapon_Unleash::Skill.default] if skill.nil?

    weapon_name = weapon.name

    text = sprintf(Vocab::WeaponUnleash, @active_battler.name, weapon_name, skill.name)

    @message_window.add_instant_text(text)

    targets = @active_battler.action.make_targets

    display_animation(targets, skill.animation_id)

    for target in targets

      target.skill_effect(@active_battler, skill)

      display_action_effects(target, skill)

      @message_window.back_to(4)

    end

  end

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

  # * Weapon can unleash?

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

  def weapon_can_unleash?(weapon)

    return false if @active_battler.is_a?(Game_Enemy)

    return false unless Weapon_Unleash::Weapons.include?(weapon.id)

    rate = Weapon_Unleash::Rate[weapon.id]

    rate = Weapon_Unleash::Rate.default if rate.nil?

    random = rand(100)

    return random <= rate

  end

end

 

 

 

 

 

 

 

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

# ** Weapon Specials

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

# SephirothSpawn

# Version 1

# 2006-11-04

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

# * Description :

#

#   This script was designed to allow give your weapons specials when they

#   are used to attack. You can asign multiple specials and control their

#   probablilty to be used. You can force the special and make sp cost of the

#   skill nothing. (Specials are skills)

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

# * Instructions :

#

#   Place The Script Below the SDK and Above Main.

#   To customize weapon specials, refer the the customization instructions.

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

# * Customization :

#

#   Force Specials (Passes skill_can_use? test no matter what)

#    - Force_Specials = true or false

#

#   Specials Use SP

#    - Specials_Use_Sp = true or false

#

#   Setting Weapon Special

#    - Weapon_Specials = { weapon_id => { probability => skill_id, ...}, ... }

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

 

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

# * SDK Log Script

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

#SDK.log('Weapon Specials', 'SephirothSpawn', 1, '2006-11-04')

 

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

# * Begin SDK Enable Test

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

#if SDK.state('Weapon Specials')

 

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

# ** RPG::Weapon

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

 

class RPG::Weapon

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

  # * Options

  #

  #   Force Specials : When true, actor uses skill no matter what.

  #                    When false, actor must be able to use special (skill).

  #

  #   Use SP : When true, actor uses sp to cast special.

  #            When false, skill sp cost is nothing.

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

  Force_Specials  = false

  Specials_Use_Sp = false

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

  # * Weapon Specials

  #

  #   Weapon_Specials = { weapon_id => { probability => skill_id, ...}, ... }

  #

  #   Can have a greater than 100 probablity

  #   Use nil as skill id, for attack

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

  Weapon_Specials = {

    1 => { 100 => 57 }

  }

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

  # * Use Weapon Special Test

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

  def use_special?

    # Creates Array for skill ids

    specials = []

    # If Weapon Has Specials

    if Weapon_Specials.has_key?(@id)

      # Passes through each special

      Weapon_Specials[@id].each do |prob, skill_id|

        # Adds skill id to specials array probability times

        (prob).times { specials << skill_id }

      end

    end

    # Returns random action

    return specials[rand([specials.size, 100].max)]

  end

end

 

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

# ** Scene_Battle

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

   

class Scene_Battle

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

  # * Alias Listings

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

  alias seph_weaponspecials_scnbtl_mbar make_basic_action_result

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

  # * Make Basic Action Results

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

  def make_basic_action_result(battler)

    # If attack

    if battler.current_action.basic == 0

      # If Actor

      if battler.is_a?(Game_Actor)

        # If Using Weapon

        unless (weapon_id = battler.weapon_id) == 0

          # If Weapon Has a Special

          unless (skill_id = $data_weapons[weapon_id].use_special?).nil?

            # Sets To Skill Action

            battler.current_action.kind = 1

            # Sets Skill ID

            battler.current_action.skill_id = skill_id

            # If Forcing

            if RPG::Weapon::Force_Specials

              battler.current_action.forcing = true

            end

            # Use Skill

            make_skill_action_result(battler)

            # Recover SP if No SP Cost

            unless RPG::Weapon::Specials_Use_Sp

              battler.sp += $data_skills[skill_id].sp_cost

              status_refresh(battler)

            end

            return

          end

        end

      end

    end

    # Original Make basic action result processing

    seph_weaponspecials_scnbtl_mbar(battler)

  end

end

 

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

# * End SDK Enable Test

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

#end
 

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