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

O sorry I didn't understand you. I thought u would like to do something with decimals.

U need it for example here:

U have an barbarian who deals more dmg depending on the health missing

I would make it that way

(a.atk*((a.mhp*1.0/a.hp)**(-1))- b.def)

Without the decimal i wouldn't get the percentage.

the scrip ("damage=[damage, 1].max") looks a lttle bit strange in my eyes would mind posting the link? I am interested in the reason doing it that way.

This would be enough to get the same goal:

[a.atk*4 - b.def*2, 1].max

and this can be user without other scripts

The script-let wouldn't work the way u planned it u forgot the 4

a.atk*4<b.def*2 ? 1 : a.atk* - b.def*2

a.atk*4<b.def*2 ? 1 : a.atk*4 - b.def*2

regards Bot
O sorry I didn't understand you. I thought u would like to do something with decimals.

U need it for example here:

U have an barbarian who deals more dmg depending on the health missing

I would make it that way

(a.atk*((a.mhp*1.0/a.hp)**(-1))- b.def)

Without the decimal i wouldn't get the percentage.

the scrip ("damage=[damage, 1].max") looks a lttle bit strange in my eyes would mind posting the link? I am interested in the reason doing it that way.

This would be enough to get the same goal:

[a.atk*4 - b.def*2, 1].max

and this can be user without other scripts

The script-let wouldn't work the way u planned it u forgot the 4

a.atk*4<b.def*2 ? 1 : a.atk* - b.def*2

a.atk*4<b.def*2 ? 1 : a.atk*4 - b.def*2

regards Bot
You are right about me forgetting the 4 in my script-let...just a misprint.

Your barbarian example wouldn't work however: (a.atk*((a.mhp*1.0/a.hp)**(-1))- b.def)

The -1 would cause the equation to have a total negative value resulting in no damage...
(I apologize for my bad English and the missing of the correct terms.)

nope try it with your calculator

1/2^(-1)=2/1

4/5^(-1)=5/4

any fraction(Integers are fractions too with the denominator 1) to the power of -1 is equals to the reversed fraction (don't know the English term for it=> denominator and the numerator are swapped). This means the smaller the number the higher the outcome.

I hope u could understand me. This showed me one thing in particular I will never work as a Math Teacher in a English speaking country.

Nevertheless i was mistaking in my formulae anyway It must be:

(a.atk*((a.hp*1.0/a.mhp)**(-1))- b.def) or

(a.atk*(a.mhp*1.0/a.hp)- b.def)

regards Bot
So I think I'm doing alright with branching out to other formulas other than atk, mat, def and mdf. But I need some reassurance on this one. In fact, I learn pretty fast and if I just give someone the info for what I'm looking to do,, can you just construct the formula for me one time? This way I can copy and learn from it. Anyway, I have this particular skill called "uppercut". Now I want one person to be more skilled in using this attack over another person but I don't want to have to clog up the system with repeating the skill and giving one person uppercut a and the other uppercut b. I think that's unnecessary and not an efficient way of handling this. So I was thinking about a certain formula:

Can I have it set up like...:

If id.1 then a.atk *6 or id.4 then a.atk * 8?

I don't know how to write it out exactly.

Basically I want the character in id slot 1 to hit with uppercut at 6 times the strength while character in id slot 4 hits with 8 times the strength.

How do I write this out?

Here is what I came up with but there is a small problem:

if a.id == 1; a.atk * 6 - b.def * 1.4; end; if a.id == 4; a.atk * 8.5 - b.def * 1.4 end;

It reads but the enemy will not receive damage. There is something I need to shift around but do not know what...
Hmm try:


if a.id==1;c=6;else;c=8.5;end;a.atk*c-b.def*1.4
Hmm try:

if a.id==1;c=6;else;c=8.5;end;a.atk*c-b.def*1.4
This worked thank you.

I may need a refresher on this: what was the purpose of C in this equation? I mean, why was it C that worked?
It does not have to be C it could be any letter or a group of letters.

It is just a variable which is used to store the dmg-factor of your skill.

I think Formar covered the topic variables in his tutorial/blogpoost

http://cobbtocs.co.uk/wp/?p=271

The problem with your formula is that it would only deal dmg if the snd if (if a.id == 4) would be true.

regards Bot
Hmm...

This one has a lot in it so we'll look at it closely. We'll use the if method and then use the rand(x) method which returns a number from 0 to x-1 meaning we will add 1 to it to simulate dice. We will also need to create some local variables, I will use c & d (DO NOT USE a & 😎 .

c=1+rand(6);d=1+rand(6);if c==1 and d==1;10000;elsif c==d;c*400;else;(c+d)*100;end;

So what can I do with this to create a skill that can do anywhere between 100 and 10,000 damage? I was thinking of a skill called "judgement of the stars" and wanted it to be an immensely wide hit variance. So how can I twist this a bit to fit an attack that does any number between 100 and 10,000?
The forumla would look this way:

9900*rand(100) +100

u simply take a percentage (between 0 and 100) of the damage + the min dmg

regards Bot
That would only hit for certain increments of damage based on x {x * rand(100) + 100}

With the formula yo provided it would hit anywhere between 9901 and 990100

You'll want to run probably want to use [rand(10000), 100].max

Note:

Max sure you take weaknesses and resistances into consideration when making the skill
That would only hit for certain increments of damage based on x {x * rand(100) + 100}

With the formula yo provided it would hit anywhere between 9901 and 990100

You'll want to run probably want to use [rand(10000), 100].max

Note:

Max sure you take weaknesses and resistances into consideration when making the skill
Your version is 100 times more likely to pick 100 instead of any other number; it's not a flat distribution.

The formula you are looking for is 100+rand(9900).
Your version is 100 times more likely to pick 100 instead of any other number; it's not a flat distribution.

The formula you are looking for is 100+rand(9900).
http://codepad.org/uqm6NXVV would disagree with your odds
Your version is 100 times more likely to pick 100 instead of any other number; it's not a flat distribution.

The formula you are looking for is 100+rand(9900).
Actually with Lowells formula I have seen a very wide range of damages 😀 .

It's working fine for me. I've been hitting for 800, 5000, etc. And any number in between. Even as low as 500. So it's doing okay.

Now if only I could put that formula in an English sentence so I can learn to make such formulas myself.
rand(10000) produces a random number between 0 and 9999

.max will pick the highest value from whatever is inside the brackets

so with [rand(10000), 100].max if the number randomed is higher than 100 that number will be picked, it it's lower 100 will be picked
http://codepad.org/uqm6NXVV would disagree with your odds
It agrees perfectly. Count the 100s; there are 10 of them in a sample of 1000 pulls. That's EXACTLY the expected value for a 100/10000 chance.
Technically any value that is 100 either hits it or is lower than 100. the [formula, 100].max code basically takes any value less than 100 and sets it to 100. As far as probability is concerned, the machines results just happened to roll 10 100's, it's not a given that it will hit it even once throughout the 1000 roles.
Technically any value that is 100 either hits it or is lower than 100. the [formula, 100].max code basically takes any value less than 100 and sets it to 100. As far as probability is concerned, the machines results just happened to roll 10 100's, it's not a given that it will hit it even once throughout the 1000 roles.
You are misunderstanding. I never said the sample proves my statement*; I said it's a terrible way to disprove it, which is what Xypher was trying to do.

I don't need the random sampling to prove my statement because I know the original distribution.

I'll try to be as clear as I can. When rand(10000) happens to roll a number between 0 and 99, it gets replaced with 100 by max.

So what was originally:

0,1,2,...,99,100,101,...,9999

becomes:

100,100,100,...,100,100,101,...,9999

and the number 100 is repeated 101 times;

(this is a correction of my earlier statement of 100 times: I had forgotten that the rand(n) function goes from 0 to n-1, not from 1 to n)

thus the probability of 100 is

p(100) = 101/10000

while the probability of any other number n > 100 is

p(n) = 1/10000

and the probability of a number m < 100 is obviously

p(m) = 0/10000

Hence my original statement that it's not a flat distribution.

*Actually, it does at a statistical level; without going into the technical details, with this peaked distribution getting a number of 100s between 7 and 13 (such as in this case 10) happens 68% of the time (what is called 1-sigma). Meanwhile, the chance of getting 10 times a 100 with a flat distribution is about 100-sigma, which is flat out zero. However, this reasoning would only be needed if we didn't know the original formula.
On a side note, it will never hit 10000 because it should be rand(10001) not random(10000)
On a side note, it will never hit 10000 because it should be rand(10001) not random(10000)
Of course. I guess the correct formula would have to be 100+rand(9901).
It sure would be nice to condense everything that's been requested and answered and such into one list, instead of having to trawl through to see if what you want has been asked etc etc.

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