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.

SephirothSpawn's Weapon Speacials Script [RTAB compatible]

I'm not much of a scripter (read: I know nothing about RGSS scripting but I have experience in other programming languages), but the other day I was messing around with SephirothSpawn's Weapon specials script and I made it compatible with Cogwheel's RTAB system by commenting out the SDK dependency and changing the names of a few variables.

The script allows you to have weapons that perform skills when you use a regular attack. Once again, this is not my script, all credit goes to SephirothSpawn. I don't know if this been done before (and please correct me if I did something wrong, this is my first scripting-related endeavor), but here's my edited version of the script:

Code:
#==============================================================================
# ** 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

Edit: Forgot to mention, this is compatible with most RTAB addons except for connected attacking. By most, I mean all the other official addons and all unofficial that I have tested it with. If you plan to use it, you must remove "Connected Attacking" and "Consumable Items Patch" or disable them.
 

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