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

Fyro

Warper
Here's one, A magic attack that takes up the required MP from all party members.

Zechnophobe

Veteran
My own contribution:

A skill that deals more damage to wounded targets:

100 + b.hp < b.mhp/2 ? 100 : 0

This skill deals 100 damage, 200 if the enemy is at half health or less.

A skill that deals more damage depending on how wounded the attacker is:

100 + (a.hp / a.mhp) * 100

(You may need to do a float conversion in there to not lose decimals on the division, I haven't tested this one in a while)

Edit: Also, it looks like you can call a script from within the formula box, just as if it were a small window. This creates some pretty powerful options for what you can do with these things (for advanced users).

Lastly, I think having 'race' being a new attribute of Game_Actor would allow something like

if a.race=="elf" ? 100 : 50

Moving such an attribute up to Battler you could make things deal more damage TO certain types of enemies.

if b.race=="undead" ? 2*a.atk : a.atk

I think I like this enough to start doing it. I've been using 'effects' that call scripts to handle more complex damage calculations, but this often breaks the flow of battle. This is a much better way.  Will allow a spell I'm working on to work:

Fireshield - Cast on an ally. Whenever a physical attack is made against the target, the attacker suffers damage.

Use a little pass through function for the basic 'attack' ability to check for a fireshield state, and if so apply damage back to the attacker!

Last edited by a moderator:

pinkapinkie

Veteran
Is there a way to make a skill check how many of an item you have in inventory and then make damage accordingly? for example, if you have 4 potions, take 4 and use it in the rest of the formula.

Chemical Engineer, Game Developer, Using BlinkBoy'
Yes, just make an item check in the formula bar...

or use a custom skill cost script...

pinkapinkie

Veteran
How do I make an item check in the bar formula?

Also, is it possible to give to a character, or an enemy, a malus to it's stats without using the debuff feature? For example, i have a skill that gives +2 atk and -2 def to the user. The +2 atk is possible with the increase parameter, but it can't go down to negative values. How would I give that -2? Do I need a script? or is there something I don't know?

Last edited by a moderator:

Ministry

Villager
Also, is it possible to give to a character, or an enemy, a malus to it's stats without using the debuff feature? For example, i have a skill that gives +2 atk and -2 def to the user. The +2 atk is possible with the increase parameter, but it can't go down to negative values. How would I give that -2? Do I need a script? or is there something I don't know?
Easiest way to do this would be to make a state that gives +2 ATK and -2 DEF.  Then have your skill apply this state.

Chemical Engineer, Game Developer, Using BlinkBoy'
you can set negative numbers in the increase parameter fields...

pinkapinkie

Veteran
@ Ministry There's no way to add those kind of value in the status effect box by default. But thanks for your reply.

@ adiktuzmiko When I put like -2 in the box though, it gets automatically back to the +1 value.

Chemical Engineer, Game Developer, Using BlinkBoy'
oh w8, this is better in states, so that it isn't permanent...

you can opt to use yanfly's scripts for it... because I don't think the features actually use direct bonuses for parameters...

if it's permanent, I think you can use Common events to do the negative part...

or use the formula bar...

Last edited by a moderator:

voymasa

Veteran
I want to include something in every one of my damage formulas that prevents each attack from ever doing less than 1 damage.

I've tried:

1 + (a.atk * 4 - b.def * 2)

and

(a.mat * 2.5 - b.mdf) + 1

But attacks will still sometimes do 0 damage. I think I need to find some way to have the 1 be added after all other damage calculations are completed, but I don't know how to do that yet.

Also, I loved the tutorial. Taught me a lot.
I know a lot of posts have better ways of handling this, and I'm kind of new to RPG Maker, but I used

if (a.atk * 4 - b.def * 2) <= 0 then 1; else (a.atk * 4 - b.def * 2) ; end

with the standard variance of 20. The attacker sometimes "misses" (standard response when their atk isn't high enough to damage you) and sometimes deals 1 point of damage. I prefer it this way over 1 point consistently because I feel it adds some more realism to it (i.e. you may not be strong enough to hurt them, but you occasionally get a lucky scratch).

On another note, I used the formula box to make a skill called Flash Bomb deal 1 point of damage to each target, only while that target had more than 1 hp. This way the attack can't kill a target (and it's like the attack "stings" them).

if b.hp > 1 then 1; else 0; end

@Ronove

I use states for the debuff or multi-debuff effects that I want to have an attack apply only a certain percentage of the time (like my Cripple Strike skill which lowers their Agi and Eva by a specific percentage for a variable number of turns (3-5)). States allow me much more control over the total effect of special attacks, and their duration (which is important IMO).

voymasa

Veteran
In my game I have added the status "Undead" and would like to have the option to cause healing 'damage' to enemies and actors with that status.

I know how to set healing skills to be used on both enemies and actors...that's a standart function in the database, but how do I set the difference of wether it does damage or recover?

If I remember correctly, a - (negative sign) in front of your formula reverses the effect (damage => healing, and visa versa). Correct me if I'm wrong, but you could use Rachael's state?(id) where id is the number of your Undead state, to control whether it does

FORMULA damage or -(FORMULA) healing

ex. a skill called vampiric strike, using the HP Drain option, but Undead would heal and you would take damage, and your Undead id is 44 (I'll check the results in a second)

state?(44); -(a.atk*4-b.def*2); else a.atk*4-b.def*2; end

Okay, it's tested and it's telling me that it expects end in place of else. Help me out here. Anyways, I also have to try and figure out how to have a monster always have a state (such as zombies having the Undead state) because I had to set up a Zombify Skill to put said State on them to test it for you.

Zechnophobe

Veteran
If I remember correctly, a - (negative sign) in front of your formula reverses the effect (damage => healing, and visa versa). Correct me if I'm wrong, but you could use Rachael's state?(id) where id is the number of your Undead state, to control whether it does

FORMULA damage or -(FORMULA) healing

ex. a skill called vampiric strike, using the HP Drain option, but Undead would heal and you would take damage, and your Undead id is 44 (I'll check the results in a second)

state?(44); -(a.atk*4-b.def*2); else a.atk*4-b.def*2; end

Okay, it's tested and it's telling me that it expects end in place of else. Help me out here. Anyways, I also have to try and figure out how to have a monster always have a state (such as zombies having the Undead state) because I had to set up a Zombify Skill to put said State on them to test it for you.
If you are checking if the target has a state, remember to use "b." to connect the trait with the target. I believe that'd be b.state. I'm not in front of code, so I'm not sure if that is the correct call to check if an enemy has a state, but either way you need to specify what state you want to check

voymasa

Veteran
If you are checking if the target has a state, remember to use "b." to connect the trait with the target. I believe that'd be b.state. I'm not in front of code, so I'm not sure if that is the correct call to check if an enemy has a state, but either way you need to specify what state you want to check
You're right regarding the "b" (I forgot to add it), but I was wrong apparently regarding the -, because the target keeps taking 0 damage regardless of Undead state or not. I'll have to rethink this.

Chemical Engineer, Game Developer, Using BlinkBoy'
yeah, it seems like it doesn't work if you do it via the formula bar... coz when I negate the damage in the script itself, it seems to turn negative just fine...

Last edited by a moderator:

voymasa

Veteran
yeah, it seems like it doesn't work if you do it via the formula bar... coz when I negate the damage in the script itself, it seems to turn negative just fine...
I think maybe the - sign to reverse the effect was from VX (RGSS2 instead of Ace's RGSS3), so I think we'll have to add in another keyword command. The other problem aside from the zero damage was that when I used the b.state?(ID); -(FORMULA); else (FORMULA); end   it returned with an error regarding expected keyword of end instead of else, so I switched to the classic    if b.state==ID; then -(FORMULA); else (FORMULA); end   and I also used the (-(FORMULA)) as an additional test in case the - sign wasn't being counted properly (and thus causing the zero damage problem) but that wasn't it either. I might have to figure out what RGSS3's command is for restoring hp equal to the damage done (or a percentage of it) to the attacker (a.restorehp or whatever it is) and add that in. Ultimately it would be something like this

if b.state==UNDEAD; then a.hp - (FORMULA); b.hp + (FORMULA); else FORMULA; a.hp + (FORMULA); end

My formula is pretty crude (and I couldn't get b.state?(ID) to work), so any ideas to clean it up will be appreciated, especially if someone can tell me a better way to "heal" the Undead or attacker using the built in class functions. As a side not, the a.hp formula is too long for the formula bar.

Last edited by a moderator:

Chemical Engineer, Game Developer, Using BlinkBoy'
Of course it would return an error... you used the ? operator in a wrong manner...

it's written only as

condition? action_if_true : action_if_false

so the formula should be...

b.state?(ID) -(FORMULA) : (FORMULA)

also, remember that the formula bar takes the last line as the damage value... so putting an end means that damage = end...

Last edited by a moderator:

voymasa

Veteran
there shouldn't be an end there... remember that the formula bar takes the last line as the damage value... so putting an end means that damage = end... Also the ? operator isn't used with an else and end too...

it's written only as

condition? action_if_true : action_if_false

that should be

b.state?(ID); -(FORMULA); else (FORMULA)
Okay, so I wrote it like this

b.state?(30); -(a.atk*4-b.def*2)a.atk*4-b.def*2)

and set to HP drain in the damage type.

The error that occurs is the following

Script 'Game_Battler' line 352: SyntaxError occurred

unexpected ':', expecting \$end

and it is followed by the above formula.

What am I doing wrong and why isn't it working at all? Why is it telling my I need an end statement (which is why I use them)? I've found that when you use the conditional statements in the formula bar you need that end statement.

Last edited by a moderator:

Chemical Engineer, Game Developer, Using BlinkBoy'
you forgot another ? (the actual ? operator)... and don't put ;

it should be

b.state?(ID)? damage : damage

Last edited by a moderator:

voymasa

Veteran
you forgot another ? (the actual ? operator)... and don't put ;

it should be

b.state?(ID)? damage : damage
Well, the formula now runs. Is it normal not to exceed the target's max hp with a drain attack (I have no problem with it because why should you heal more hp from the attack than they have)? The only problem I have now is that the - sign is simply negating the damage, and not causing you to lose the hp and them gain it. Hmmmmm.

Another issue I'm dealing with is that I seem to have a problem evaluating comparisons without the if statement, i.e.

b.hp?(>1)? 1:0

Nevermind about the b.hp formula in the line above, I modified it to

b.hp>1? 1:0

and it works fine

Apparently the ? (as in b.hp?(x)) is for == comparisons.

Last edited by a moderator:

Chemical Engineer, Game Developer, Using BlinkBoy'
Ahh... so you'd like the user to lose hp equal to the heal to the target?

then it would be... IDK if this works though...

b.state?(ID)? a.hp -= damage ; -damage : damage

Latest Profile Posts

Challenging myself to make a game on the console versions of RMMV with alot of custom stuff, battle system is almost done, but holy heck is the interface and navigation so backwards on console ports. I've lost several hours of work because of design choices from that team!
If only RM had the capability to show whether a project has been edited, or not... like 99% of all other editors out there. That don't cost, too, or release new versions with very few features just to get the extra money... ugh, just too many basic features missing even after, what, two decades?
The Sinners who Never Sinned Teaser for the DEMO!

Surgically removing people's faces and grafting them on to other people is kind of fun.

(editing character art busts for my game)
I think sleep is like a foreign language to me.