Weapon firing mechanics

Started by Gabriel_Braun, July 06, 2014, 03:58:11 PM

Previous topic - Next topic

Gabriel_Braun

Hey Tynan;

It's been bugging me that I don't actually understand one of the combat functions and can't find the answer anywhere else so I have to ask you personally;

When a weapon is fired what variables are counted and in what order?  Specifically; when the warmup expires and the projectile(s) are fired, is the actual target cell decided when warmup began or the location as warmup ends?

Does the accuracy calculation take place before or after the final target cell is determined in either case?

Finally, how do the pawn 'shooting' skills apply to the overall process and at what point is it applied?

Example:
Dave is hunting a Muffalo with his R4 charge rifle.  As the R4 has a range of 24 he shoots as soon as he is this far away from his dinner target.   During the 108 ticks that pass between his beginning to fire and the actual weapon discharging the unfortunate muffalo moves two cells closer to Dave's firing position.  Three rounds aimed by a shooter with a mediocre skill in firearms fly toward their destination but probably all but one will miss the beast and so Dave continues the process until it dies.

I'm only curious about the above mechanics but actually in this short time Dave has probably killed multiple squirrels, some other muffalo and accidentally downed a fellow survivor before detonating a random boomrat that burns the unconscious colonist to death just before they could be rescued! That's Rimworld all over but Dave doesn't care, he has some important mining to perform after dropping the corpse off! 

Note:
That last 'flavourful' section was meant just for fun and should be taken lightly and not as a complaint regarding the dynamics of the game in general.

The events described are based on a true story.
Any likeness to actual people or places is unintentional.
There were no animals hurt in this retelling minimal animal casualties during the recreation.

Tynan

Well, you can disentangle the very specifics by decompiling the game and just reading the code. Here's the summary.

A shot can have a world cell or a thing as the target. When it's fired it already knows if it is going to hit or miss the target. Even if the pawn moves, they'll still be hit if the projectile had decided to hit. If the projectile decided to miss, it'll go to an adjacent square and hit whatever is there. The only way a projectile that decided to hit can not hit is if it hits something else first, like someone standing in its path.

The accuracy calculation determines the final target cell, so they're the same operation.

The accuracy calculation itself is conceptually simple. You can see a breakdown of the results by selecting a shooter and mousing over the target. It will tell you all the contributors to the hit chance. The contributors are percentages. The final hit chance is the product of all these percentages. The only complicated one is the cover-intercept contributor, which is calculated by combining the contributions from all relevant cover items adjacent to the target and at a similar angle from the target as the shooter. The contribution from each cover object is related to its size as well as the angle between shooter and target (directly between is better than off-angle).

Each round in a burst has its hit/miss result calculated independently, at the moment it is fired.

As for people firing high powered weapons all over the place and just hitting everything, including explosive boomrats - I call it FUN :D !
Tynan Sylvester - @TynanSylvester - Tynan's Blog

StorymasterQ

Quote from: Tynan on July 06, 2014, 09:22:22 PM
...When it's fired it already knows if it is going to hit or miss the target....

So, it's almost like XCOM's shot cam?
I like how this game can result in quotes that would be quite unnerving when said in public, out of context. - Myself

The dubious quotes list is now public. See it here

mrofa

Yehh it works like xcom but the old xcom or xenonauts.
Bullets get all calculation if it gonna hit or not, but if bullet will fly to its square and  pawn that was its target is gone from that square then damage will be recalculated. So pawn will still get hit but for less or non. Its kinda funny that tynan alone did more inteligent hiting mechanic than entire xcom studio :D
All i do is clutter all around.

Gabriel_Braun

Thanks Tynan and much appreciated for clearing that up!