The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: TDS on April 24, 2011, 01:17:49 AM

Title: Weapon Unleash
Post by: TDS on April 24, 2011, 01:17:49 AM
Weapon Unleash
Version: 1.0
Author: TDS
Date: April 23, 2011

Version History



Description


A Script that replicates the "Weapon Unleash" system from the game series "Golden sun". It allows a weapon to randomly use a skill instead of an attack.

Features


Instructions

To use the unleash effect add the following to a weapon's note box.
Code: [Select]
UNLEASH: Skill_ID %_Chance

  Skill_ID = The ID of the skill used for the weapon's unleash effect
  %_Chance = Chance of the unleash effect activating from 0-100%

Example:
Code: [Select]
UNLEASH: 23 100

Script


Code: [Select]
#==============================================================================
# ** TDS Weapon Unleash
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  A Script that replicates the "Weapon Unleash" system from the game series
#  "Golden sun".
#------------------------------------------------------------------------------
#  * Features:
#  Gives weapon a chance to "Unleash" a pre set skill during battle.
#------------------------------------------------------------------------------
#  * Instructions:
#  To use the unleash effect add the following to a weapon's note box.
#
#  UNLEASH: Skill_ID %_Chance
#
#  Skill_ID = The ID of the skill used for the weapon's unleash effect
#  %_Chance = Chance of the unleash effect activating from 0-100%
#
#  Example:
#
#  UNLEASH: 23 100
#------------------------------------------------------------------------------
#  * Notes:
#    None.
#------------------------------------------------------------------------------
#  * New Methods:
#  RPG::Weapon Module
#  - unleash_info
#    ^ Method used to read from the weapon's notebox and get unleash information.
#
#  Game_Battler:
#  - weapon_unleash?
#    ^ Method used to determine if unleash effect is possible and set unleash
#      skill as an action.
#
#  Scene_Battle:
#  - execute_weapon_unleash
#    ^ Method used to execute unleash process.
#------------------------------------------------------------------------------
#  * Aliased Methods:
#  Scene_Battle:
#  - execute_action
#    ^ Aliased to check for weapon unleash effect before original method runs.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Determine and set Weapon Unleash
  #--------------------------------------------------------------------------
  def weapon_unleash?
    # If self is not an actor ir action is not to attack
    return false if !actor? or !@action.attack?
    # Get Main Weapon
    weapon = weapons[0]
    # Return false if main weapon is nil
    return false if weapon == nil 
    # Get Unleash Information
    unleash_info = weapon.unleash_info
    # Return false if unleash info is nil
    return false if unleash_info == nil
    # If Unleash Rate is more than a random number from 0-100%
    if (rand(100) < unleash_info[1])
      # Set Weapon Unleash Skill
      @action.set_skill(unleash_info[0])
      # Return true
      return true 
    end
    # Return false by default
    return false
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #-------------------------------------------------------------------------- 
  alias tds_weapon_unleash_scene_battle_execute_action execute_action unless $@
  #--------------------------------------------------------------------------
  # * Execute Battle Actions
  #--------------------------------------------------------------------------
  def execute_action
    # If Active Battler weapon unleash
    if @active_battler.weapon_unleash?
      # Execute Weapon Unleash
      execute_weapon_unleash
      return
    end   
    # Run Original Method
    tds_weapon_unleash_scene_battle_execute_action   
  end
  #--------------------------------------------------------------------------
  # * Execute Battle Action: Weapon Unleash
  #--------------------------------------------------------------------------
  def execute_weapon_unleash   
    # Get Skill
    skill = @active_battler.action.skill
    # Weapon Unleash Text
    text = sprintf("%s's %s let's out a howl! %s!", @active_battler.name,
    @active_battler.weapons[0].name, skill.name)
    # Add Instant Text
    @message_window.add_instant_text(text)
    # Wait 20 frames
    wait(20)
    # Make Action Targets
    targets = @active_battler.action.make_targets
    # Display Animation
    display_animation(targets, skill.animation_id)
    # Run skill common event if it exist
    $game_temp.common_event_id = skill.common_event_id
    # Go Through Targets
    for target in targets
      # Execute Skill Effect
      target.skill_effect(@active_battler, skill)
      # Display Action Effects
      display_action_effects(target, skill)
    end
  end
end

#==============================================================================
# ** RPG Module
#------------------------------------------------------------------------------
# Module for handling information.
#==============================================================================

module RPG
  #============================================================================
  # ** RPG::Weapon
  #----------------------------------------------------------------------------
  # This module handles Weapon Information
  #============================================================================
  class Weapon < BaseItem
    #-------------------------------------------------------------------------
    # * Get Weapon Unleash Information
    #-------------------------------------------------------------------------
    def unleash_info
      # Check notes for Unleash Skill ID and Chance
      self.note[/UNLEASH: ([-0-9]+) ([-0-9]+)/]     
      # Retunr nil first match is nil
      return nil if $1 == nil
      # Return Array containing unleash values
      return [$1.to_i, $2.to_i]
    end
  end
end



Credit



Support


On this topic.

Known Compatibility Issues

There could be some compatibility issues with custom battle systems, since this script was tested only with the default battle system.

Restrictions

Only for use in non-commercial games.
Title: Re: Weapon Unleash
Post by: Infinate X on April 24, 2011, 02:46:01 AM
This is a really awesome script... I just don't know where to use it...  :(
Title: Re: Weapon Unleash
Post by: TDS on April 24, 2011, 02:51:07 AM
To use the unleash effect, add into a weapon's notebox the text instructed above.

Example:
Code: [Select]
UNLEASH: 14 100

If this is added for example to the default weapon "Long Sword", every time you attack with that weapon it will instead use the skill "Sickle Weasel". If you don't want it to always use the skill when it attacks lower the 100 to a lower number.
Title: Re: Weapon Unleash
Post by: hiromu656 on April 24, 2011, 02:58:20 AM
Wow, another piece of excellent work. I'm definitely going to use this, perhaps on a weapon that has a chance to set an enemy on fire... oh the possibilities.
Title: Re: Weapon Unleash
Post by: modern algebra on April 24, 2011, 03:34:38 AM
Neat effect TDS and very creative; I had never even thought of it. Good stuff! :)
Title: Re: Weapon Unleash
Post by: TheBlueFlame on May 10, 2011, 12:38:45 AM
It's very good work, but when I try to copy it into my scripts it just becomes one loooooooong line of code.
Would you happen to know who I can remedy this? I'm super excited to use it.
Title: Re: Weapon Unleash
Post by: TDS on May 10, 2011, 12:43:04 AM
I think you have to copy the code and paste it in a wordpad/notepad document then put in on your game when that happens.
Title: Re: Weapon Unleash
Post by: TheBlueFlame on May 10, 2011, 12:56:53 AM
I'll try that out, thanks TDS!

Edit: It worked! Thanks a bunch!
Title: Re: Weapon Unleash
Post by: nguyena2013 on June 16, 2011, 11:29:08 PM
How do you make the text appear before you use the unleash skill? I tried using it, the attack worked fine, but it didnt say the "Characters's weapon let out a howl" thing. thanks for the help if you can give it, if not, then I'll mess around with it
Title: Re: Weapon Unleash
Post by: TDS on June 16, 2011, 11:53:28 PM
Are you using a custom battle system and the message wont appear? Or do you want to know which line displays the unleash message?

If it's the latter, these are the lines where the unleash message is prepared.

Code: [Select]
text = sprintf("%s's %s let's out a howl! %s!", @active_battler.name, @active_battler.weapons[0].name, skill.name)
Title: Re: Weapon Unleash
Post by: nguyena2013 on June 17, 2011, 12:26:29 PM
I'm using a custom battle system. It's a side view battle system, not sure exactly which one because i'm sure there are other ones... if you could help that would be great, and if not then oh well. I'll just do my own experiments.
Title: Re: Weapon Unleash
Post by: TDS on June 17, 2011, 03:57:34 PM
I need to know which battle system it is before I can help you.
Title: Re: Weapon Unleash
Post by: nguyena2013 on June 18, 2011, 02:12:39 PM
It's the Tankentai 3.4 battle system.
Title: Re: Weapon Unleash
Post by: drakonais on August 02, 2011, 07:40:52 PM
It would be brilliant to see this work for Yanfly's Melody Engine.  Right now, it throws up errors for most of the execute_weapon_unleash section at line 123 and below.
Title: Re: Weapon Unleash
Post by: TDS on August 08, 2011, 02:53:53 AM
Please provide a link to the script when you ask people to make them compatible with them.