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

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
500
Reaction score
173
First Language
English
Primarily Uses
RMMV
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 :)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,274
Reaction score
7,146
First Language
German
Primarily Uses
RMMV
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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,016
Reaction score
11,350
First Language
English
Primarily Uses
RMVXA
[move]RGSS3 Script Requests[/move]
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
500
Reaction score
173
First Language
English
Primarily Uses
RMMV
~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.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
641
Reaction score
416
First Language
English
Primarily Uses
RMVXA
Happy holidays; let me know how you go with this:
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Anyone here managed to never burn out on programming? My current limit is 3 months(6-8 hours per day, 7 days per week, 50 hour programming week on average), and then I just have to take a break, sometimes lasting few days(with at most 2 hours on programming per day). I've been always like this so far, so I admire those who can always be so passionate on programming :)
This is starting to become a momochi collection y'all!
Meet Swefo The candy Eater!

Hide your candy... I or I sweefe sweefefooo~~~
Automatic level scaling without an option to turn it off can be a very bad choice for a game. The worst I've ever seen was in Nightmare of Druaga, where if a power outage made your system turn off, the game detects it as an attempted cheat and overwrites your save while taking away your best gear, leaving you unable to progress at the late stages of the game, and unable to recover.
Problem with sequels: Heroes getting rid of all their items and forgets all of their skills within the span of a year without explanation. :kaomad3:
I can see the end of my prologue. Perfect time to decide to pull everything over into MZ, right? Right?!

Forum statistics

Threads
99,647
Messages
967,650
Members
131,323
Latest member
clarkebobby366
Top