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

Thanks!

#### dionisiovega

##### Villager
got a new question for you, how do you make an attack always be a critical one. I am creating a skill that has an MP Critical factor to it;

example

if a.mp>=100; a.mp-=100; (auto critical attack formula here); else; (a.atk*4-b.def*2)

I know about b.result.critical, just not sure how to do what I want.

#### lohenien

##### Veteran
I would disable criticals for that power and then use your normal attack formula but multiple it by 3 like so

Code:
if a.mp>=100; a.mp-=100;
(a.atk*4-b.def*2) * 3
else;
(a.atk*4-b.def*2)

#### dionisiovega

##### Villager
I wanted to let the player know that a critical attack was performed, that way just shows it as a normal attack.

#### Fomar0153

##### Arkz
Try:

Code:
if a.mp>=100;@result.critical=true;(a.atk*4-b.def*2)*3;else;(a.atk*4-b.def*2);end;

#### dionisiovega

##### Villager
unfortunately @result.critical=true is not a valid argument, if I include it, the formula is skipped and no damage is calculated.

#### Warpmind

##### Twisted Genius
Okay, so I'm thinking using something like an incremental success rate calculation for attacks, affecting how much damage is dealt. With stats swapped around be Skill and Power, respectively for Atk and Def, just for clarification here...

So, does something like this look about right?

Set smackdown==(a.atk+rand(100))-(b.atk+rand(100)); if smackdown>=1; a.def+(a.def*(smackdown/10)); else; 0
I didn't follow that. An incremental success rate though would require some tracking of attempts. I'll do something like it in the follow up tutorial should I ever finish it.
I'll try to clarify - it was a bit awkwardly phrased. Basically, I want to save the "attack roll" in a variable to which I can refer in the damage calculation step. I've got a background in tabletop roleplaying more than console games, so some of the terminology and even basic concepts can be... tricky to translate at times.

Hence, my suggested code would be to set variable "smackdown" (for lack of a better name) to (attacker skill+roll)-(defender skill+roll), then if the attack hits (by virtue of the variable being 1 or higher), deal damage equal to attacker's power plus a bonus equal to attacker's power multiplied by a tenth of the "smackdown" variable.

...A little clearer now?

*D'oh* And, as I had the tutorial printed for an even more thorough read (along with a couple others) on the bus, I finally spot the bit about \$game_variables[x] or v[x]... The jury's still out on the subject of whether I drink too much at work, or not enough. >.<

Last edited by a moderator:

#### Fomar0153

##### Arkz
unfortunately @result.critical=true is not a valid argument, if I include it, the formula is skipped and no damage is calculated.
Whoops:

Code:
if a.mp>=100;b.result.critical=true;(a.atk*4-b.def*2)*3;else;(a.atk*4-b.def*2);end;
Okay, so I'm thinking using something like an incremental success rate calculation for attacks, affecting how much damage is dealt. With stats swapped around be Skill and Power, respectively for Atk and Def, just for clarification here...

So, does something like this look about right?
I didn't follow that. An incremental success rate though would require some tracking of attempts. I'll do something like it in the follow up tutorial should I ever finish it.

#### dionisiovega

##### Villager

if a.mp>=100;b.result.critical=true;(a.atk*4-b.def*2)*3;else;(a.atk*4-b.def*2);end;

works perfectly.

#### Warpmind

##### Twisted Genius
Right, think I've figured out how to set up the basic attack skill as I want it... Drawing inspiration from White Wolf's Storyteller system, I figured out how to save the results of an opposed attack roll in a variable, which then gets referenced and, if one or more, gets added as a bonus to the damage roll...

v[1]=rand(a.atk)-rand(b.atk);if v[1]>=1;rand(a.def+v[1]);else;0;end

Seems to work like a charm. That leaves the relatively easy task of scaling stats down to topping out maybe somewhere in the twenties, for the sheer sake of sanity... And do similar things to all the OTHER skills for which something like this bears relevance, i.e. everything...

Perhaps I do have a masochistic streak, I dunno...

#### Ronove

##### ♫꒰･‿･๑꒱
Hey Fomar is it possible to have a forumla set up to give a debuff 85% of the time? Like for example this one attack I have set up, 85% of the time it'll add an ATK debuff and a DEF debuff on the enemy.

#### The Infamous Bon Bon

##### Executive Geek
I thought you could do that with traits.

#### Ronove

##### ♫꒰･‿･๑꒱
I don't think you can have a chance of it happening. It'll be 100% with the traits I think.

#### Warpmind

##### Twisted Genius
Wouldn't that just be setting the invocation success rate to 85%?

Or are you talking about an attack that has an 85% chance of placing a couple of debuffs in addition to the damage?

#### Ronove

##### ♫꒰･‿･๑꒱
An attack that has 85% chance of placing a couple of debuffs in addition to damage. Despite what you two seem to think, I do know my way around the skills tab! XD I wouldn't have asked if I was 99% sure I couldn't do it normally.

#### lohenien

##### Veteran
You can do this normally with traits / features. When you select which debuff you add there is a box below the selection used for putting in % chance to occur.

#### Warpmind

##### Twisted Genius
Okay, making a bit of a wild-uh... donkeyed guess here...

Set up a skill... let's say number 500, just for the sake of picking a number. That skill inflicts the debuffs, with absolute certainty.

In the attack skill that might cause those debuffs, see if you can try

v[x]=rand(100)+1;if v[x]>=15;\$data_skills[500];else;end

Bear in mind, this is a guess on my part; I'll be running a few tests along those lines now.

#### Ronove

##### ♫꒰･‿･๑꒱
@lohenian: No you can't. That is for states, not debuff. -- This is what the debuff window looks like: http://i1012.photobucket.com/albums/af243/earlronove/noyoucant.png - As you can see, no way to add a percentage of it happening.

@Warpmind: I don't think it worked? At least it didn't do it a total of 10 times in my test. In addition, how do I keep the how much the skill damages along with what you suggested? When I put that after what sets up the how hard the skill hits, it throws a scripting error at me, but if I take out the equation for damage, it works just fine.

Last edited by a moderator:

#### Warpmind

##### Twisted Genius
Yyyeah, I get the same problem. Apparently, secondary branches don't work. -.-

Trying different approaches; working within a narrow space here, so may take time. (Long hit/damage formula already.)

#### dionisiovega

##### Villager
not really sure if this is possible in the damage formula box, I know I can pull this off with a script (yanfly's followup attack script), but not any other way...

Edit:

my mistake it is the yanfly follow up skill script

Last edited by a moderator:

### Latest Profile Posts

Sometimes you Just need to realise someone is beyond help... Still hard to walk away tho
100 Horror/Tragedy Sample Maps, Penguin Mech Sprite, & TileD Templates | RPG Maker News #70

Continuing working on abs. So far I have done the workout twice. I am excited to see the results after a couple of weeks. How is everyone doing?
MZ: oh boy imma work today
Me, excited: Really?
MZ, doesn't do what I tell It too
Me: I Thought-
MZ: I am Working!
Oof, this "side project" of mine is starting to get as complex as a VS plugin, at least as far as plugin parameters are concerned. I think I now understand why a plugin like this doesn't already exist(that I know of). Learning a lot while trying to make it work though!