How to make the most of custom formulae. Part #1

Actually, @MoltresRider could use something weird like this formula:

b.mdef / 3

So the target will always get around a third of its magical defense as damage.
So i have some questions:

Example 1: Attack deals damage equal to strength, unless the target has equipped equipment X, otherwise less by Y
Example 1a: Attack deals damage equal to strength, unless the target has equipped equipment of type X (I don't know some notetag), otherwise less by Y
Example 2: Attack deals damage equal to X, and if the attacker has equipped Y, then the damage is greater by Z
Hey,

To check whether any equipped item contains <notetag> in its notebox, you could try this:
b.feature_objects.any? { |o| o.note["<notetag>"] }

This will technically also check states, the class and the actor/enemy database entries, but an upside would be that you don't have to modify the code to make it work on enemies, which don't have equipment.

If you strictly want to only check equipment, you could try this:
b.actor? && b.equips.any? { |o| o && o.note["<notetag>"] }

With that in mind, your examples:
1a: a.atk - (b.feature_objects.any?{|o| o.note["<type x>"]} ? 12300 : 0)
2: 12350 + (a.feature_objects.any?{|o| o.note["<type y>"]} ? 13500 : 0)
I think my approach might make it easy to use the concept in a very effective way.

First you'd have to include this scriptlet in your script editor as a brand new script.

EDITED THE SCRIPT BELOW SEVERAL OF TIMES ALREADY!

Spoiler: Very Old Version of the Script
Ruby:
# * Ekuipment's Skill Damage ACE
#   - Intended for Custom Damage Formulae
#   Scripter : Kyonides
#   2025-03-14

# This scriptlet allows you to alter your item's or skill's damage formula in
# some interesting way, by setting a custom note in the equipment's notebox
# and a target statistic that will serve as some item or skill damage modifier.

# If the target battler is an enemy, the end result will always be 0.

# * About the Damage Formula Box * #
# a represents an attacker, while b stands for a defender.

# * Damage Formula * #
# b.atk - b.equip_skill_dmg(note, stat)
# - Usage Examples:
# b.atk - b.equip_skill_dmg("<weak element>", :atk)
# b.atk - b.equip_skill_dmg("<weak element>", 300)

# * Script Calls * #
# - Non-Damage-Formula Use Cases:
# $game_actors[1].equip_skill_dmg("note", :atk)
# $game_party.members[0].equip_skill_dmg("note", :matk)

class Game_Actor
  def equip_skill_dmg(equip_note, stat_or_num)
    result = equips.compact.any? {|e| e.note[equip_note] }
    result ? stat_or_num.is_a?(Numeric)? stat_or_num : send(stat_or_num) : 0
  end
end

class Game_Enemy
  def equip_skill_dmg(equip_note, stat)
    0
  end
end

Then read the embedded comments in my script. They're right there for a darn good reason! 😮

Finally, you can use the new script call in your damage formulae at will. :ewink:

Here I'll leave the same example I included in those comments.

b.atk - b.equip_skill_dmg("<weak element>", :atk)

(I gotta admit that such an example would always return 0 as your the skill damage for an obvious reason, he, he.)

NOTES:

If the target battler is an enemy, the end result will always be 0.
You can pass either a :symbol representing a stat OR a number as the second parameter.

Latest Version of the Script

Go to the Ekuipment's Skill Damage ACE thread once it's been approved by a moderator.
Will this work the way I want it to?

I want to create a skill where a fireball enemy explodes after a set number of turns dealing its remaining HP to damage to a party member, and since its an explosion, it kills itself.

I set the a.add_state to death. Will the damage go off if the enemy kills itself?

1763560022224.png
You're using the attacker's current HP to deal damage... but it's already dead!! So the opponent wins. He has no reason to complain about it, anyway. 🤣
You're using the attacker's current HP to deal damage... but it's already dead!! So the opponent wins. He has no reason to complain about it, anyway. 🤣
So, it applies the state before dealing damage? Meaning that if the enemy has 5022 HP remaining when he uses explosion, that 5022 is ignored because it kill him first? It does not do 5022 HP damage to a party member?

Is there any way around this?
Is there any way around this?
the order. You made the actor dead before you did the damage calculation.
d = a.hp - b.mdf; a.add_state(0); d

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-most-of-custom-formulae-part-1.1143/