[VX Ace] Weapon that Deals X% Damage to Enemy with State

Hello!

This is kind of an odd request (that I believe would go here), in that it's both a script request, and just asking if anyone knows of a script that could accomplish this, since it's the sort of thing that I could imagine already existing.

What I'm hoping to do is have a tag for weapons, that will multiply the damage for the equipped actor when attacking an enemy with a certain state.

For example, perhaps the weapon Slimesledge would deal 50% more damage against enemies with the "Slime" state, and so would have a tag something like <StateDamage: 10 150>, in which 10 is the Slime state, and 150 is 150% damage.

Thank you 🙂
Bump
Bump 👋
does this have to be done with a notetag? will it be used many times or only in a few cases?

If it is only a few cases then you should look for the pinned topic about damage formula coding - you can use script commands in the damage formula of the attack skill to check for states on the target and then change the damage depending on the result.

however due to limited space in the damage formula that will only work with a limited number of checks - if this is a common effect you'll need a script. and if you need a script you should report your topic to have it moved to script reqests, you'll get more answers if it is in the correct section.
Moved to: RGSS3 Script Requests
~Christmas Bump~

I'm hoping to set this up with quite a few different weapons and effects, so I'm really hoping I could do this with notetags.
Happy holidays; let me know how you go with this:
Spoiler
Ruby:
module AMN_EquipDamage
=begin
#==============================================================================#
#   AMN Equip State Damage
#   Version   1.01
#   Author:   AMoonlessNight
#   Date:     26 Dec 2019
#   Latest:   26 Dec 2019
#==============================================================================#
#   UPDATE LOG
#------------------------------------------------------------------------------#
# 26 Dec 2019 - created the script
#==============================================================================#
#   TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use; contact for commercial use
# - If you would like to edit/adjust this script, please make edits as a new
#   script (do not edit this script directly), and make sure you provide proper
#   credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script makes it so that certain equipments can deal extra damage to enemies
with certain states.

You can use notetags in the following note fields:
  Weapon
  Armour

<state damage: x,y,z A>
  where x,y,z are the state IDs and A is the multiplier (e.g. 150 for 150%)
 
  You can list as many states as you'd like, as long as they fit on one line.

=end

#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
#  Change the values in the area below to suit your needs.
#==============================================================================
 
  PHYSICAL_ONLY = true
  # will only apply multiplier for physical attacks
 
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
#  Please do not edit below this point unless you know what you are doing.
#==============================================================================
 
  REGEX = /<state[ -_]*damage:\s+(.*)\s+(\d+)>/i
end

class RPG::BaseItem
  attr_accessor :equip_damage_states

  def load_equip_damage_notetags
    @equip_damage_states = Hash.new(1.0)
    self.note.split(/[\r\n]+/).each { |line|
    case line
    when AMN_EquipDamage::REGEX
      states, rate = $1, $2
      states.split(",").each do |state|
        @equip_damage_states[state.to_i] = rate.to_i / 100.0
      end
      puts "States #{states} are at #{rate.to_i / 100.0}"
    end
    }
  end
 
end

module DataManager
  class <<self; alias :amn_eqpdmg_datamgr_loaddb :load_database; end
 
  def self.load_database
    amn_eqpdmg_datamgr_loaddb
    load_equip_damage_notetags
  end

  def self.load_equip_damage_notetags
    for group in [$data_weapons, $data_armors]
      for obj in group
        next if obj.nil?
        obj.load_equip_damage_notetags
      end
    end
  end
 
end

class Game_Battler < Game_BattlerBase
 
  alias amn_eqpdmg_gamebattler_itemelerate  item_element_rate
  def item_element_rate(user, item)
    rate = amn_eqpdmg_gamebattler_itemelerate(user, item)
    if AMN_EquipDamage::PHYSICAL_ONLY
      rate *= user.equip_damage_rate(self) if item.physical?
    else
      rate *= user.equip_damage_rate(self)
    end
    rate
  end
 
  def equip_damage_rate(target)
    return 1.0 unless self.is_a?(Game_Actor)
    tstates = target.states.collect { |s| s.id }
    tstates.inject(1.0) { |r, state_id| object_equip_damage_rate(state_id) }
  end
 
end

class Game_Actor < Game_Battler
 
  def objects_with_equip_dmg_states
    equips.compact.select { |obj| !obj.equip_damage_states.empty? }
  end
 
  def object_equip_damage_rate(state_id)
    objects_with_equip_dmg_states.inject(1.0) { |r, obj|
    r *= obj.equip_damage_states[state_id] }
  end
 
end
Happy holidays! And thank you very much! 🙂

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-weapon-that-deals-x-damage-to-enemy-with-state.115726/