Diep Collision Mechanics

Written by u/Aznatf

Hello welcome back to the explanation of collision mechanics in diep.io 

Today I'm gonna give you one straight forward example, where you can see the use of the formulas.

bullet/bullet collision :

We have a 7bp and 7dm Annihilator Bullet and a 7bp and 7dm Factory Drone. With the 2 equations DPL = 4 * Df * DS and BP = 20 * Bf / Df * PP we can calculate the attack and the defense stat of both bullets.

The annihilator bullet deals 84HP damage per loop and has 100HP health. The factory drone has 200HP health but only deals 19.6HP damage per loop.

You have now two possibilities:

You can do each loop separately or just sum all over them.

If you wanna do the quick version you just calculate the BP loss for both sides.

As you can see the Annihilator Bullet will survive the impact and the Factory Drone will not, if the impact will lasts long enough.

What's the point of all this you may ask. Well now we can choose if we wanna have the endresult, see what happens at every loop and see how long collisions lasts. It's an great method to calculate every step of an collision and it describes every collision we can observe in the game.

We just saw that having the most bullet HP doesn't make one bullet also the strongest one. The damage per loop is also very important. That is also the reason why an Annihilator Bullet with Bf = 6 is 6 / 2.8 or 2.142857143 times stronger then a Factory Drone. It may has only half its Bullet HP but has 4.285714286 or 84/19.6 times its attack strength to make up for it.

The Bf in the end just gives us an overall bullet power comparison but doesn't tell us where the power really lies. Now we can see, thanks to the DPL's and Df's, where every bullet is "good" at and can determine all bullet HP and their corresponding DPL's.

Note:

An collision can only lasts a natural number amount of loops. So just 1 or 2 or 3 or 4... loops. That's the reason a loop is equivalent to a contact. A collision could last 3 loops but with a bullet only dealing 2.1 times it's DPL. The reason for this is the way the game is programmed. Since there can't be 2.1 loops it's handled in a way that the damage is 2.1 times the DPL but the collision will last 3 loops. So the 2.1 are just the "technical" loops. It seems a bit odd but you have to think about it this way. If the "technical" number of loops and real number would be the same you encounter 2 problems. First a bullet that would last 2.1 loops and on an other instance 2.7 loops would make the same damage despite the fact they have different HP values. Second in IT they can only by a natural number of loops.

To sum up everything we know about collisions:

The 3 laws of collision mechanics:

Thanks for reading my little series explaining ingame collisions. Hope you liked it.

All remaining equations and final post on in-game collisions.

I never really explained where the original equations from lyw's 318 post (https://www.reddit.com/r/Diepio/comments/51fplu/durability_formula/) come from and how you can obtain them. I always kinda said those where law cause I derived anything from those. I also gonna prove without the newer once or at least not the once that are consequences of them, cause some say that of course you get the same equations because I started with them. With this out of my way let's begin the propably last post to finally fully explains collisions.

MH = 48 + 2 * lvl + 20 * mh

By observating the behavior of the change of health with each stat and level we can conclude that this must be the right equation. For every level you get 2HP and for every MH points you get 20HP and you start at 48HP (technically 50HP but then you would have to write lvl - 1 in the equation so I just used the base health value for an level 0 tank).

BS = 1 + 0.2 * bd

This can be obtained by two different methods. I'll explain one of the two now and the other one later. The easier way to find this equation is to look at the DPL for tanks and shapes which only depends on body strength.

DPL = 20 * BS

If you have 0 bd you deal 20HP damage, with 1 bd 24HP, with 2 bd 28HP and so on...

This can be written down as DPL = 20 * (1 + 0.2 * bd) which fullfills what we can observe.

For tank to tank collisions the DPL of the tanks are 50% more than usual.

DPL = 30 * BS

We get the same result with BS = 1 + 0.2 * bd. Hence now the damage per loop increases by 6HP pro collision.

D = 1/4 * MH * BS

What even is durability D?

It simply combines MH and BS into one equation so we can compare them more easily. Imagine it as the "real HP" an tank has but i gave it the unit squares as lyw also did.

Here is a thought experiment:

Take a square which has obviously 0 damage reduction (dr) and 10HP health. This would give it D = 10HP. But if an object had the same amount of health (10HP) but more body damage therefore more damage reduction it would also have more durability than a square. This means that even if 10HP are displayed on the screen the object would have more "real HP". We can in theory turn body damage into health. In practise this formula just tells us how much corresponding HP it would have if it had the same damage reduction as an square.

Biohazard made in this post (https://www.reddit.com/r/Diepio/comments/60dvdt/body_damage_statistics/) an equation for durability which follows the rules I explained above.

D = MH / (1 - dr)

I'm gonna divide it by 10 to create the unit square.

D = MH / (10 * (1 - dr))

Now we compare anything to a square so to get the "real HP" you just multiply by 10.

We know from tests that an 0 bd tank has 60% damage reduction in comparison to a square.

D = MH / (10 * (1 - 0.6)) S

and it has at 50HP at level 1

D = 50 / (10 * (1 - 0.6)) S = 12.5 S

S stands for square. So an basic tank is 12.5 times more durable than a square.

If we now look at the "new" durability equation :

D = 1/4 * MH * BD = 1/4 * 50 * 1 S = 12.5 S

We get the same result.

Maybe this is just a coincende that we choose BD = 1 and a factor of 1/4 in front of it but if you run this for more diverse builds you come to the conclusion that it matches it perfectly. Just try it out. This is the second method you can get the BD = 1 + 0.2 * bd. By simply trying out some values for MH and BD and caluclate the durability of the build.

Db = Bf * DM * Ps = Bf * (0.7 + 0.3 * dm) * (1 + 0.75 * bp)

The bullet durability (Db) is also in unit squares so it makes it very easy to compare now durabilities between tanks and bullets. You get this equation again by trying some values for DM and Ps. Every bullet in the game increases its damage and penetration in equal proportions. The Bf value just tells you how much more durable an bullet is in comparison to an other if they have the same stats. It's usefull to find similarities between the durabilities for example the same bullet will have the same durability with either 0 dm and 2 bp or 1 dm and 1 bp. By strategic testing you get the formula above.

Bonus equations :

MH_L = 4 * Db / BS

I used this formula before but never explained its origin.

To get it we think about what the durability loss is, we experience if a bullet hit us and transfers all its damage onto us.

Idea :

D - D_a = Db

The differnce between our full durabilty or simply the durability (D) we have before the impact and the durability (D_a) after the impact is the bullet durability (Db).

with D = 1/4 * MH * BS and D_a = 1/4 * MH_a * BS

MH_a : health we would have left after the impact

plugging those in gives us:

1/4 * MH * BS - 1/4 * MH_a * BS = Db

→ Db = 1/4 * BS * (MH - MH_a)

Since the health before minus the health after is just the health loss we can rewritte it as:

Db = 1/4 * BS * MH_L

→ MH_L = 4 * Db / BS

This is the health loss you receive if a bullet hits and it doesn't survive the impact.

Note: We can get the general GH_L equations from it

generall durability : D = 1/80 * DPL * GH (see last post to understand it)

same idea as before:

D - D_a = Db

→ 1/80 * DPL * (GH - GH_a) = 1/80 * DPL * GH_L = Db

→ GH_L = 80 * Db / DPL

We can also get it by summing up over all possible loops in a collision with the fundamental collision equation

GH_L = GH'' * DPL'' / DPL

but I guess you trust me that you'll come to the same equation as before.

Last is the damage reduction formula which you can also derive from the MH_L equation instead of the more complex way I did in the last post.

Going back to our square. It has D = 1S and MH = 10HP. You may see a contradiction here. It has 10HP but only 1S durability. If we would assume a square has 0 bd the durability for it would be :

D = 1/4 * MH * (1 + 0.2 * bd) S = 1/4 * 10 * 1 S = 2.5 S ← with 0 bd

Something must be wrong. In order to fix it we have to give a square an BD stat of -3, as counterintuitive as it sounds.

D = 1/4 * 10 * (1 + 0.2 * (-3)) S = 1 S

Sidenote : Triangle has also bd = -3 and pentagon has bd = -2

This also explains why pentagons deal 12HP damage per loop and triangles 8HP. For squares explanation please look at the laws of collision mechanics.

DPL of shapes:

DPL = 20 * BS = 20 * (1 + 0.2 * bd)

for pentagon : DPL = 20 * (1 + 0.2 * (-2)) HP = 12HP

for triangle : DPL = 20 * (1 + 0.2 * (-3)) HP = 8HP

Back to square again:

We know square has dr = 0 and we definded the damage reduction as:

dr = 1 - MH_L / MH_L° with the MH_L° a square experiences

MH_L = 4 * Db / BS

and MH_L° = 4 * Db / BS = 4 * Db / (1 + 0.2 * (-3)) = 4 * Db / 0.4 = 10 * Db

plugging everything in:

dr = 1 - MH_L / MH_L° = 1 - (4 * Db / BS) / (10 * Db)

= 1 - 4 * Db / (BS * 10 * Db)

Db cancels out:

dr = 1 - 4 / (10 * BS)

the same form the last post

Now that I hope everything is cleared out i can do the final summary of the collisions in the game.

We went from those fundamental equations :

to the newest theory :

plus the 3 laws of collision mechanincs and the 2 value tables (Df and Pf)

You notice that we don't need to know either the durability of objects or their Bf's anymore to calculate something. Durabilty only has become a tool to figure bullet health out without knowing their stats (for example bosses)

I really hope you enjoyed the series i made on explanating ingame collisions and I covered everything related to it from discrete damage per loop to negative stat points for shapes to damage reduction and the law's every object has to obey. Hope I explained everything nice and simple so that everyone can understand it.