Bactyrael

Villager
Member
Joined
Jul 12, 2019
Messages
8
Reaction score
3
First Language
English
Primarily Uses
RMMV
So right now I am using

"b.mp <= Math.RandomInt(20) + 1 + (Math.floor((a.atk - 10)/2)) + (Math.floor(a.level/2))) ? Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2)) : 0;"

To simulate a D20 roll to check if I hit an enemy based on their Armor Class. if "b.mp is less than or greater than 20 + modifier than 1D4 + modifier else 0" The only issue is that I want to add in critical and fumble for a natural 20 and a 1 respectively. To do this I know I need to use lunatic mode with yanfly's damage core but I am having trouble setting up a conditional branch for it.

{if Math.RandomInt(20)+1

= 1 then <Replace Attack: 1> <Replace Attack: Fumble> "The attack is replaced with a fumble skill using YEP_WeaponUnleash"

= 20 then Math.randomInt(8) + 1 + (Math.floor((a.atk - 10)/2)) "it ignores the Armor Class check and you roll 2d4 instead of 1d4"

= 2-19 then b.mp <= (2-19) + (Math.floor((a.atk - 10)/2)) + (Math.floor(a.level/2))) ? Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2)) : 0; "The original damage formula goes off as usual using a 2-19 value given from the D20 roll at the start"}

I'm don't really know javascript so I am not sure how to set this up with a variable and conditional branches for the variable value. Any help would be greatly appreciated as this is my entire combat system.
 

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
111
Reaction score
91
First Language
English
Primarily Uses
RMMZ
You should just be able to use a chain of ternary operators like so:
((x = (Math.randomInt(20) + 1)) === 20) ? (Do Crit Stuff Here) : (x === 1) ? (Do Fumble Stuff Here) : (Do Normal Stuff Here);

I'm not sure exactly how the everything else is done in the skill formula windows and such, but this is a valid argument that can be passed to the console.

You can use below to in the console to see that it displays either "Crit" if 20, "Fumble" if 1 or "Number" (of the dice roll) if between 2-19
((x = (Math.randomInt(20) + 1)) === 20) ? console.log("---CRIT---") : (x === 1) ? console.log("FUMBLE") : console.log(x);
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,169
Reaction score
2,546
First Language
English
Primarily Uses
RMMV
I'm not sure if you realize the trick here: whether your attack hits is calculated outside of the damage formula.

There's a separate portion of code that does the "hit roll," then everything in your damage formula only gets executed if the attack hits. So this causes two problems for you:
1 - You'll get weird-looking attacks where your d20 attack roll is a failure, but the attack is already a hit, so you're going to see your actor take a swing, show the damage animation, and hit for 0 damage.

2 - Your overall chances to hit and do damage will be lower than you expect, because you'll have the natural miss chance from RPG Maker, then an additional miss chance from the d20 roll you're programming in here.

You would (in my opinion) do much better to take this out of your damage formula and use something like Yanfly's Hit Accuracy plugin to change how the hit calculations for your skills are performed.
 

Bactyrael

Villager
Member
Joined
Jul 12, 2019
Messages
8
Reaction score
3
First Language
English
Primarily Uses
RMMV
I'm not sure if you realize the trick here: whether your attack hits is calculated outside of the damage formula.

There's a separate portion of code that does the "hit roll," then everything in your damage formula only gets executed if the attack hits. So this causes two problems for you:
1 - You'll get weird-looking attacks where your d20 attack roll is a failure, but the attack is already a hit, so you're going to see your actor take a swing, show the damage animation, and hit for 0 damage.

2 - Your overall chances to hit and do damage will be lower than you expect, because you'll have the natural miss chance from RPG Maker, then an additional miss chance from the d20 roll you're programming in here.

You would (in my opinion) do much better to take this out of your damage formula and use something like Yanfly's Hit Accuracy plugin to change how the hit calculations for your skills are performed.
I'm trying to emulate d&d combat as much as possible. The armor class portion of the equation is important for calculating hit. Because its 1d20 + stat mod + half your your level. So I can't use a universal hit rate as the modifier changes based on attack and or spell.

Is there a way to use YEP hit accuracy to factor in skill type? Some things use strength "atk", dexterity "agi", intelligence "matk", wisdom "mdef", charisma "luck", or constitution "def". I haven't incorporated the death saving throw system or saving throws in general really either so I'm unsure about that moving forward. As far as I understand, using certain hit on skills should hypothetically also remove the hit chance from rpg maker? But than I run into the 0 problem which should be a miss for not passing the Armor Class?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,169
Reaction score
2,546
First Language
English
Primarily Uses
RMMV
I'm trying to emulate d&d combat as much as possible. The armor class portion of the equation is important for calculating hit. Because its 1d20 + stat mod + half your your level.
Um...yes? My post you quoted is explaining you can't actually calculate hit inside of the damage formula :stickytongue:
So I can't use a universal hit rate as the modifier changes based on attack and or spell.
Again, that's what I explained before, that RPG Maker uses a universal hit rate unless you change it somehow.
Is there a way to use YEP hit accuracy to factor in skill type? Some things use strength "atk", dexterity "agi", intelligence "matk", wisdom "mdef", charisma "luck", or constitution "def".
It's a small plugin, it wouldn't take you long to just read the documentation. (how would you be using Cha/Con in attack rolls? Never mind, it's probably some weird 5e thing :stickytongue:)

But the short answer is apparently not. I thought it might provide notetags for you to determine how each skill hits, but that's not the case. However, the Victor Engine Hit Formula plugin does exactly that. So go with that one.

In addition, you might want to check out Frogboy's assortment of plugins - they are generally dedicated to replicating D&D mechanics.
As far as I understand, using certain hit on skills should hypothetically also remove the hit chance from rpg maker? But than I run into the 0 problem which should be a miss for not passing the Armor Class?
Yes - again, you can't determine hit/miss from within the damage formula. If you use Certain Hit, it will hit. You'd use that for things like fireball or magic missile.
 

Bactyrael

Villager
Member
Joined
Jul 12, 2019
Messages
8
Reaction score
3
First Language
English
Primarily Uses
RMMV
Um...yes? My post you quoted is explaining you can't actually calculate hit inside of the damage formula :stickytongue:

Again, that's what I explained before, that RPG Maker uses a universal hit rate unless you change it somehow.

It's a small plugin, it wouldn't take you long to just read the documentation. (how would you be using Cha/Con in attack rolls? Never mind, it's probably some weird 5e thing :stickytongue:)

But the short answer is apparently not. I thought it might provide notetags for you to determine how each skill hits, but that's not the case. However, the Victor Engine Hit Formula plugin does exactly that. So go with that one.

In addition, you might want to check out Frogboy's assortment of plugins - they are generally dedicated to replicating D&D mechanics.

Yes - again, you can't determine hit/miss from within the damage formula. If you use Certain Hit, it will hit. You'd use that for things like fireball or magic missile.
I'm confused. If 2-19 + -3 to +5 + 1 - 10 is >= armor class it hits. I'm not trying to use a % chance for an attack to be successful. I'm trying to emulate a 1 fumble, 20 crit, and 2-19 system. If I put 1-20+modifier+half level in a hit calculator how do I generate crits and fumbles? Technically it's a 5% chance for either because 1/20. Right now for example I'm using weapon unleashes for fumble and crit. But that 5% chance happens regardless of my 1 to 20 dice roll. I could roll a 20 and fumble or not meet armor class and crit. Which is the reason I want to make a conditional branch?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,169
Reaction score
2,546
First Language
English
Primarily Uses
RMMV
I'm confused.
Erm...yes. :rolleyes:
If 2-19 + -3 to +5 + 1 - 10 is >= armor class it hits.
I have absolutely no idea what this has to do with anything I said in my post. :stickytongue:
I'm not trying to use a % chance for an attack to be successful.
Of course you are. Before any modifiers, it's 90% chance to hit, 5% chance to critical, 5% chance to fumble. But, again, what does this have to do with anything I said?
If I put 1-20+modifier+half level in a hit calculator how do I generate crits and fumbles?
The fumble is the tricky part because there's no such thing in default RPG Maker (nor in default D&D), so you need to decide and explain what you want it to do. But the rest is pretty basic JavaScript:
Code:
<hit formula>
var roll=Math.randomInt(20)+1;

a._critical=false;

if (roll==1)
    result=0;
else if (roll==20)
{
   a._critical=true;
    result=100;
}
else
{
    roll+=a.atk+Math.floor(a.level/2);
    result=roll>=b.def ? 100 : 0;
}
</hit formula>
then you could use something like Yanfly's Critical Control to reference the user._critical variable (or turn off all critical hits in MV and do it in your damage formulae).
Technically it's a 5% chance for either because 1/20. Right now for example I'm using weapon unleashes for fumble and crit. But that 5% chance happens regardless of my 1 to 20 dice roll. I could roll a 20 and fumble or not meet armor class and crit.
I really don't understand what you're saying here, possibly because you're trying to do parts of the attack system in different odd places.

Also, you don't need to meet armor class in order to critical - what the heck D&D rules are you reading?
Which is the reason I want to make a conditional branch?
I mean, sure? The code I typed above has conditionals, but you are saying this as if you still want to have a conditional inside your damage formula and...I just don't get what part of what I've explained isn't making sense to you.
 

Bactyrael

Villager
Member
Joined
Jul 12, 2019
Messages
8
Reaction score
3
First Language
English
Primarily Uses
RMMV
Erm...yes. :rolleyes:

I have absolutely no idea what this has to do with anything I said in my post. :stickytongue:

Of course you are. Before any modifiers, it's 90% chance to hit, 5% chance to critical, 5% chance to fumble. But, again, what does this have to do with anything I said?

The fumble is the tricky part because there's no such thing in default RPG Maker (nor in default D&D), so you need to decide and explain what you want it to do. But the rest is pretty basic JavaScript:
Code:
<hit formula>
var roll=Math.randomInt(20)+1;

a._critical=false;

if (roll==1)
    result=0;
else if (roll==20)
{
   a._critical=true;
    result=100;
}
else
{
    roll+=a.atk+Math.floor(a.level/2);
    result=roll>=b.def ? 100 : 0;
}
</hit formula>
then you could use something like Yanfly's Critical Control to reference the user._critical variable (or turn off all critical hits in MV and do it in your damage formulae).

I really don't understand what you're saying here, possibly because you're trying to do parts of the attack system in different odd places.

Also, you don't need to meet armor class in order to critical - what the heck D&D rules are you reading?

I mean, sure? The code I typed above has conditionals, but you are saying this as if you still want to have a conditional inside your damage formula and...I just don't get what part of what I've explained isn't making sense to you.
I'll try to explain.
Roll 20

If 1
use skill fumble
"No damage is done"

If 20
use formula 1d8 + modifier.
"This doesnt check armor class, 2d4 instead of 1d4."

If b.mp <= 2-19+mod+level MOD
Use 1d4+mod
"Equals or exceeds armor class."

If b.mp > 2-19+mod+lvlMOD
than 0
"did not equal or exceed armor class. Does no damage"

I'm still learning about d&d 5e so I'm just following what I'm reading from the WoTC d&d rule books. Idk if critical miss or fumble is a house rule thing? Is it not normal to use it like that?

The damage formula changes based on weapon or spell. I'm replacing attack on each weapon with a skill so I can use 1d4 for say a dagger and 2d6 for a greatsword.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,169
Reaction score
2,546
First Language
English
Primarily Uses
RMMV
I'll try to explain.
Why? I have demonstrated repeatedly that I know (intimately) how the rules for attacking in D&D work. What are you explaining to me? What do you not understand about what I've explained and given you the code for?

You proceed to list out this process for making attack rolls and I already gave you the code to use in the Victor Engine plugin I recommended...so I just have no clue what your post is saying or asking.

This is three posts now where you're going on about the D&D rules instead of saying anything about what you do or do not understand about RPG Maker and the answers you've been given for it. Since I can't understand the purpose of the conversation, I guess I'm out. Hopefully the answers I gave you will be helpful ¯\_(ツ)_/¯
I'm still learning about d&d 5e so I'm just following what I'm reading from the WoTC d&d rule books. Idk if critical miss or fumble is a house rule thing? Is it not normal to use it like that?
There is no such thing as "fumble" in the rules. A die result of 1 is an automatic miss, so if that's what you mean, then yes, it's in the rules, but your terminology is confusing.

A die result of 20 is a critical hit regardless of the target's AC (which is exactly what I said in my last post). So when you were talking about it being wrong for you to not meet the target's AC but score a critical hit...that is actually a correct scenario.

Good luck with your game!
 

Bactyrael

Villager
Member
Joined
Jul 12, 2019
Messages
8
Reaction score
3
First Language
English
Primarily Uses
RMMV
Why? I have demonstrated repeatedly that I know (intimately) how the rules for attacking in D&D work. What are you explaining to me? What do you not understand about what I've explained and given you the code for?

You proceed to list out this process for making attack rolls and I already gave you the code to use in the Victor Engine plugin I recommended...so I just have no clue what your post is saying or asking.

This is three posts now where you're going on about the D&D rules instead of saying anything about what you do or do not understand about RPG Maker and the answers you've been given for it. Since I can't understand the purpose of the conversation, I guess I'm out. Hopefully the answers I gave you will be helpful ¯\_(ツ)_/¯

There is no such thing as "fumble" in the rules. A die result of 1 is an automatic miss, so if that's what you mean, then yes, it's in the rules, but your terminology is confusing.

A die result of 20 is a critical hit regardless of the target's AC (which is exactly what I said in my last post). So when you were talking about it being wrong for you to not meet the target's AC but score a critical hit...that is actually a correct scenario.

Good luck with your game!
I'm just trying to use lunatic mode for a custom damage formula with 4 conditional branches but I don't know java script so I'm trying to learn how to use.

Value if then if then if then if then? or something like this.

<damage formula>
var roll=Math.RandomInt(20)+1;

if (roll==1)
<Replace attack: 1>
<Replace attack: Fumble>;
if (roll==20)
Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2));
else
{
v[roll] + 1 + (Math.floor((a.atk - 10)/2)) + (Math.floor(a.level/2))) ? Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2)) : 0;
}
</damage formula>

though I can't use YEP_WeaponUnleash in a skill notetag so I would need another way to use a different skill from the notetags. Or should I just remove it and only use

<damage formula>
var roll=Math.RandomInt(20)+1;
if (roll==20)
Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2));
else
{
v[roll] + 1 + (Math.floor((a.atk - 10)/2)) + (Math.floor(a.level/2))) ? Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2)) : 0;
}
</damage formula>


Ok I am not sure if this is right but something that looks like this?

<damage formula>
var roll = Math.RandomInt(20)+1;

if (roll==1) {
console.log("Fumble");
}
if (roll==20) {
Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2));
}
else
{
var roll + (Math.floor((a.atk - 10)/2)) + (Math.floor(a.level/2))) ? Math.randomInt(4) + 1 + (Math.floor((a.atk - 10)/2)) : console.log("Miss");
}
</damage formula>
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

ngl i feel like im morbin out
I've made a lot of small changes and fixes over the past couple weeks without actually making any progress on my game...now I'm running out of things I want to change, and I'm terrified that I might have to start being productive again...the horror! D:
I made a mini devlog about the sprite animations I've been working on! You can read it by clicking here


applebuds-dreamtrotter.gif
What happens with this list, is it currently possible to buy any of these RPGMAKER at least those that are for PC?

Combat skill combination demostration

Forum statistics

Threads
122,203
Messages
1,147,232
Members
160,471
Latest member
sanguine1038
Top