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

a.guard? will tell you if the actor is guarding.

Ruby:
class Game_Actor
  def any_weapon?
    weapons.any?
  end
end

With that scriptlet you can now ask if the actor has any weapon, i.e. a.any_weapon?
The tutorial link is broken
The tutorial link is broken
Nice of you to provide a backup. Kind of worth mentioning:
The tutorial link is broken
It's just the same thing as the first post. Doesn't really matter that the link is broken, unless you were interested in other things the author had to say.
Is this an actual usable formula?
a.atk + (b.states.size * 5) + rand(10) - 5
ChatGPT generated this and I never seen anything like this.
This formula gains damage bonuses based on the number of states (buffs/debuffs) affecting the attacker, representing a more unpredictable enemy.
Is this an actual usable formula?

ChatGPT generated this and I never seen anything like this.
The formula will work in the sense that it'll do damage.

However the damage bonus is based on the number of states (not buffs or debuffs they are something else in RPG Maker) affecting the defender.
ChatGPT came up with another one I have never seen before.

Volleyball Attack Formula (High Damage):

css

a.atk * 4 - b.def + rand(a.atk * 0.6)


It seems to take the attack into randomization. Is this something that will work?
It works -- it will generate a random integer between (a.atk * 4 - b.def) and (a.atk * 4.6 - b.def).

There is really no point to doing this because the engine's built-in "Variance" feature makes it easy to give your attacks a random component to the damage.
Will a formula like this work?:

(rand(b.mmp) + 200)

I want an MP recovery item that can recover anywhere from 200 MP to the target's max MP.
Will a formula like this work?:

(rand(b.mmp) + 200)

I want an MP recovery item that can recover anywhere from 200 MP to the target's max MP.
Technically that would work but it may skew more towards more MP recovery than you intended because that causes the range to be from 200 to the max MP *plus* 200. If your random number ends up being at least max MP - 200, it will recover all. You'd have to do a subtraction as well to compensate for that if you wanted the range to truly end at maximum.
[200, rand(b.mmp +1)].max

That would make it a lot easier to handle it IMHO.
ChatGPT gave me this formula when asked for "unique healing spell formulas for VX Ace"
Code:
(a.mat * 2) - (a.hp / b.mhp.to_f) + 15

Never seen "b.mhp.to_f" used in a formula.

Is this a valid formula? If so, please explain "b.mhp.to_f"
Just ask ChatGPT I guess?
Though I also highly doubt the concept of asking a KI for something unique just for uniqueness sake.
1703781089567.png

At the rate you pump our coding related requests over and over it might be time to work through some Ruby/RGSS3 tutorials.
So, since I'm much more familiar with VX Ace's formula's and terms, I think I can safely say a few things.

Asking ChatGPT to generate "unique healing spell formulas" is a bad idea for 2 big reasons.

#1: It's going to hallucinate, and it's very possible that the code it gives you will not work at all.
In this case, I put it into a project, and it...worked, I guess? Not sure what the goal was, but it did damage, so sure?
#2: Even if it technically works, that formula is a complete mess. If you don't understand it, then the player won't.

I googled it, and this came up.
The to_f function in Ruby converts the value of the number as a float. If it does not fit in float, then it returns infinity.

However, this was just from a general Ruby website, and might not work for VX Ace.
So you tell me one can answer this question by googling the part of the snippet that's in doubt? Color me shocked.
I asked for a description of the formula and it gave:

Restoration based on the caster's magic attack, with a penalty based on the caster's current HP as a balancing factor.
So, I hate math, but here I go.
I don't think that's how it's going to work, because we have multiple inputs here.

Sitiation'.

User of Skill: Magic Attack: 10. HP at the current moment, not the Max HP: 100
Target of skill: Max HP: 50.

Plug that into the formula...
(10 * 2) - (100 / 50 (Something about infinity? I don't freaking know)) + 15

Equals...

Either 33 or negative infinity, not sure about that.
TL;DR, it's a weird formula, and this:
Restoration based on the caster's magic attack, with a penalty based on the caster's current HP as a balancing factor.
Is not true. There's way more going on.
Ruby:
(a.mat * 2) - (a.hp / b.mhp.to_f) + 15

Would that code return Infinity as a result? Nah. Perhaps a ridiculously low subtraction at most.

Attacker's Current HP ÷ Mob's MaxHP = Low % or Proportion
125 ÷ 1,500 = 0.083

The only way to revert it would be to make sure that the attacker always has more than 10 or 100 times the max HP of the victim.

Warning!

You'd need to add a round or to_i method to its final result to ensure you won't see any decimals (the float number) on screen.

Recommendation:

Ditch it at once for it's mere crap.
Recommendation:
Recommendation: @MoltresRider stops asking AI to create technically correct things.

If you want to make something and understand how it works, simply learn it.

If you want something and don't have the time or ability to learn how it works, ask a person.

What's the point of just saying "a unique formula"? You could have a damage formula that incorporates the cube root of an astronomical unit - that's unique, but it's not useful (as @Avery demonstrated above).

A formula should have a purpose to do a thing you intend. No one playing your game knows what the math is beneath the hood, so the mere fact that your formula is unique doesn't make any difference to anything.
I asked for a description of the formula and it gave:

Restoration based on the caster's magic attack, with a penalty based on the caster's current HP as a balancing factor.
Sure, except it's dividing the caster's current HP by the target's maximum, so I'm not sure that's going to end particularly well for anyone.

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