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.
[VXA] Weapon Damage Formulas

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Weapon Damage Formulas
Version: 1.0.0
Author: modern algebra
Date: 22 September 2012

Version History


  • <Version 1.0> 2012.09.22 - Original Release

Description


By default, every weapon invokes Skill 1 when it is used, which means that every weapon has the same damage formula. This script makes it so that you can customize what skill is invoked when a weapon is used, thus allowing you to control any aspect of that attack just as you could any skill. If you want a weapon that does MP damage, for instance, this script lets you make it. If you want a weapon that targets all enemies or a weapon with a different damage formula and different use message, then you can do that too.

Please note that if an actor is dual wielding, it will only run the damage formula for the item in the primary hand.

Features

  • For each weapon, you can customize the formula used to calculate damage
  • You can make some weapons that drain HP or MP or any other damage option available for skills
  • If you wish, you can change the message that plays based on the weapon used
  • For each weapon, you can customize any other option available for skills

Instructions

Paste the script into its own slot in the Script Editor, above Main but below Materials.

For details on configuration, see the header of the script itself.

Script


Code: [Select]
#==============================================================================
#    Weapon Damage Formulas
#    Version: 1.0.0
#    Author: modern algebra (rmrk.net)
#    Date: 22 September 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    By default, every weapon invokes Skill 1 when it is used, which means that
#   every weapon has the same damage formula. This script makes it so that you
#   can customize what skill is invoked when a weapon is used, thus allowing
#   you to control any aspect of that attack just as you could any skill. If
#   you want a weapon that does MP damage, for instance, this script lets you
#   make it. If you want a weapon with a different damage formula and different
#   use message, then you can do that too.
#
#    Please note that if an actor is dual wielding, it will only run the damage
#   formula for the item in the primary hand. If you want to fix that, I
#   suggest you retrieve my "Individual Strikes when Dual Wielding" script,
#   available at:    http://rmrk.net/index.php/topic,46811.0.html
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#   
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    To use this script, simply set up a skill in the database which is the
#   skill you want to run when the weapon is used. Then, you can assign that
#   skill to the weapon by placing the following code in the weapon's note
#   field:
#
#      \asid[x]
#
#   where x is the ID of the skill you set up.
#
#  EXAMPLES:
#
#    \asid[3]                    # This weapon calls skill 3 when it is used.
#    \asID[ 46 ]                 # This weapon calls skill 46 when it is used.
#    \ASID[127]                  # This weapon calls skill 127 when it is used.
#==============================================================================

$imported ||= {}
$imported[:MA_WeaponDamageFormulas] = true

#==============================================================================
# ** RPG::Weapon
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - mawdf_attack_skill_id
#==============================================================================

class RPG::Weapon
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Attack Skill ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_writer :mawdf_attack_skill_id
  def mawdf_attack_skill_id
    unless @mawdf_attack_skill_id
      @mawdf_attack_skill_id = note[/\\ASID?\[\s*(\d+)\s*\]/i] ? $1.to_i : -1
    end
    @mawdf_attack_skill_id
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    redefined method - attack_skill_id
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Attack Skill ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  unless instance_methods(false).include?(:attack_skill_id)
    #  Define the method in the Game_Actor class if undefined. This will ensure
    # that any changes to this method in Game_BattlerBase are retained, even if
    # the script that does so is below this one.
    def attack_skill_id(*args, &block); super; end
  end
  alias mawdf_atkskillid_4fa6 attack_skill_id
  def attack_skill_id(*args, &block)
    if !weapons.empty? && weapons[0].mawdf_attack_skill_id > 0
      weapons[0].mawdf_attack_skill_id
    else
      mawdf_atkskillid_4fa6(*args, &block) # Call Original Method
    end
  end
end

Credit


  • modern algebra

Support


Please post in this topic at RMRK.net if you have any questions, suggestions, or error reports concerning this script.

Known Compatibility Issues

I am not currently aware of any compatibility issues.

Author's Notes


The reason that this script does not work perfectly with dual wielding is because, by default, dual wielding operates as a single attack, and the only benefit of holding a second weapon is that it increases the atk stat and so increases the damage. In order for me to make it so that dual wielding would integrate more smoothly with this script, I would essentially need to change the way dual wielding works altogether to create two separate attacks, and while that is not particularly difficult, it seemed outside the scope of this otherwise simple script.

For that reason, it is its own script, and if you want actors to be able to dual wield weapons with different damage formulas, then I suggest you retrieve my Individual Strikes when Dual Wielding script.

Terms of Use


I adopt RMRK's default Terms of Use.
« Last Edit: January 31, 2013, 09:47:38 PM by modern algebra »