RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VX] Question (and possible modification) of an existing script

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 71
RMRK Junior
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 Desperation Attack ready
    if desperation
      # Execute Desperation Attack
      execute_action_desperate_attack
      return
    # If Active Battler weapon unleash
    elsif @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

I have a question about how this will function in the event of a character who duel-wields weapons. Is one of the two weapon slots on a duel-wielding character considered the "main hand"? In other words, must a weapon be placed in one of the 2 slots, specifically, in order for it to be able to unleash? Or does having 2 weapons equipped mean there's a chance for both to unleash? Or one or the other?

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Quote
# Get Main Weapon
    weapon = weapons[0]

text = sprintf("%s's %s let's out a howl! %s!", @active_battler.name,
    @active_battler.weapons[0].name, skill.name)

Seems to me that it only looks at your main weapon, not your secondary.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

***
Rep:
Level 71
RMRK Junior
Okay, thanks, so main weapon (since it displays your equipment vertically) would be the top slot, right?

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3