Bullet Pathing Explained - Now & Upcoming

Generic, on-topic discussion about Colonial Marines.
Post Reply
User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Bullet Pathing Explained - Now & Upcoming

Post by Abbysynth » 02 Apr 2016, 00:41

What do I mean exactly by bullet pathing? This is the way the bullet moves from turf to turf after it's been fired, how it interact with targets along the way, and how it ends its flight. There are and have been many different methods for projectiles in Byond.

The oldest methods use a function called step_towards to loop the projectiles. Effectively, each turf the bullet uses Byond's built in movement code to make it move in the best direction towards the target. This method is clunky and cumbersome and has a large number of drawbacks, foremost is that the pathing more heavily weighs towards the east and west rather than north and south- meaning that facing east and west and shooting follows different paths than shooting north or south. Step_towards handles diagonals extremely badly and does weird things around adjacent targets.

This leads to some odd stuff around corners, for example:

Image

There should be no line of sight from the red to blue due to the walls in the way (black squares) but because of the east-west bias the bullet can magically bend around the corner. There's a lot more examples of this which I'm sure many players have seen themselves. Bullets just travel oddly, like to bounce around tiles. It's not natural looking at all.

Us and TG are the only codebases as far as I know that still use the step_towards method, and it's probably pretty likely TG will switch at some point.

Baystation, Paradise, and Goon use 3 other different methods of bullet pathing, all more or less similar to each other. Baystation uses a type of variable called a datum to store a bullet's flight path info, such as its angle of attack and the turfs it has to go through. Paradise skips that and has their bullets generate the flight path on the fly, but their simpler version lacks a lot of features of Bay's. Goon's is almost identical to Baystation's. Most of these codebases use what's known as "pixel projectiles" -- not only does it try to aim the bullet exactly where a person clicked, it subtly manipulates the bullet sprite's icon along the way so it looks like it's travelling a smooth line. Pretty clever, and it looks nice.

All these pathing methods have their merits and downsides, but I think what most people are interested in is CM's.

As you might have guessed, CM has always used the original step_towards pathing method and most of the projectile code itself is extremely old. In a big coming update, I've completely rewritten everything there is about CM's projectile system, foremost of which is the outdated pathing. Instead of using an existing codebases I've written my own pathing methods from scratch.

Effectively, what it does is use Bresenham's line drawing algorithm to generate a line of turfs going from point A to point B. It then sends the bullet along that flightpath, and halts it if it scans the next turf and hits something. You've seen Bresenham's before -- it's the same turf generator that I added to the flamethrower.

Image

Bresenham's algorithm is fast and super efficient at generating these turfs, and it does it very neatly and logically. It handles corners pretty well and if the bullets using my method run out of "flight path" turfs, it spontaneously takes the angle of its current path and generates a new one on the fly at the tail turf of the last one- thus being scalable to fire at any range. Rather than prefer a specific direction like step_towards, Bresenham's method prefers to just travel as straight as possible, but will do angled shots as you'd expect.

What does this mean for you, the player? It means a lot of your old strategies for avoiding and giving fire will no longer work or may work in unexpected ways, like hiding/shooting from around doorways. It will however feel a lot smoother and more intuitive to shoot at things. Generally, with Bresenham's algorithm, if you can see something, then logically you should be able to shoot it.

Image

Hopefully this all makes sense. TLDR: Bullet pathing will be changing soon. So, expect that.

User avatar
username123
Registered user
Posts: 285
Joined: 08 Feb 2016, 06:45

Re: Bullet Pathing Explained - Now & Upcoming

Post by username123 » 02 Apr 2016, 00:49

Damn, nice job, im starting to feel bad for asking a 6 month ban now that important changes will be implemented soon in the server.

User avatar
SecretStamos (Joshuu)
Registered user
Posts: 1291
Joined: 15 Oct 2014, 12:32
Location: Stars & Stripes

Re: Bullet Pathing Explained - Now & Upcoming

Post by SecretStamos (Joshuu) » 02 Apr 2016, 01:04

Abby, you're my hero

User avatar
Halinder
Registered user
Posts: 315
Joined: 28 Oct 2015, 20:56

Re: Bullet Pathing Explained - Now & Upcoming

Post by Halinder » 02 Apr 2016, 01:10

I love these changes. I'm not gonna be able to hit xenos for a week, and I love it.
https://i.gyazo.com/75f378476ef8f516e2f ... 2fa13b.png

LOOC: Halinder: p.s. the alien hive has huggers that you can use for breathing masks
LOOC: Barnabus Jones: Perfect game tips and tricks from halinder

[D] OOC: Eonoc: Hitler was a giant glowing yellow bug lizard. A very charismatic one.

User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Re: Bullet Pathing Explained - Now & Upcoming

Post by Abbysynth » 02 Apr 2016, 01:44

Just as a sidenote, this applies to ALL projectiles, including turrets and xeno spits, but not thrown items or certain specific weapons such as Yautja spearcasters, M92 nade launcher or SADAR which each use a custom built simplified "throw this at that thing" method.

For instance, the likelihood that hiding around a doorway will protect you from a turret anymore is slim.

User avatar
Sadokist
Donor
Donor
Posts: 630
Joined: 01 May 2015, 07:55
Location: Seattle, Washington

Re: Bullet Pathing Explained - Now & Upcoming

Post by Sadokist » 02 Apr 2016, 01:49

SecretStamos (Joshuu) wrote:Abby, you're my hero
your hero is officially a grandma.

User avatar
coroneljones
Registered user
Posts: 1350
Joined: 15 Oct 2014, 12:46
Location: SPESS!

Re: Bullet Pathing Explained - Now & Upcoming

Post by coroneljones » 02 Apr 2016, 05:30

PRAISED BE!

Abby once again codes us something amazing
I am Crornel Jrones, grorious admin of Coronial Mahreens. U ar arr nast Trorr and will be ding dong bannu. U critizize Xenos? Ding dong Bannu. U no rike grorious adminnu? Ding dong Bannu. U comrpain about Marine nerfs? Dingdong bannu. U comprain about grorrious adminnu? O yoo betta bereev dat's a bannu. It has come to my Grorrious attention dat nasty trorr has been imidatingu me on serveru, dis is a shamfrul dispray and unacceptaboo so dey ding dong bannu. End of Rine -----------------Rine ends here.'
-Credit goes to SovietCyanide
Image Image

User avatar
Szunti
Registered user
Posts: 293
Joined: 10 Dec 2015, 17:18

Re: Bullet Pathing Explained - Now & Upcoming

Post by Szunti » 02 Apr 2016, 06:13

This means that the path is often same in the reverse direction (depending on how you handle the case when the bullet is right between two tiles). If you can shoot him, he can shoot you too. Which removes shooting from cover. Won't it be missed?

User avatar
Sargeantmuffinman
Registered user
Posts: 1372
Joined: 01 Apr 2015, 14:31
Location: Mean while in Europe somewhere.

Re: Bullet Pathing Explained - Now & Upcoming

Post by Sargeantmuffinman » 02 Apr 2016, 07:26

Well I'll say my goodbyes for the old projectile code.

Old projectile code,we may or may not miss you.
George S.Patton once said:No bastard ever won a war by dying for his country. He won it by making some other poor dumb bastard die for his country.

I don't like cute things.

Good hunting.

User avatar
forwardslashN
Community Contributor
Community Contributor
Posts: 2495
Joined: 14 Dec 2015, 23:12
Byond: forwardslashN

Re: Bullet Pathing Explained - Now & Upcoming

Post by forwardslashN » 02 Apr 2016, 11:47

Image
The ambivalent giant white baldie in a jungle near you.

User avatar
Deadlymight
Registered user
Posts: 41
Joined: 24 Jan 2016, 12:28
Location: Disposals pipes

Re: Bullet Pathing Explained - Now & Upcoming

Post by Deadlymight » 02 Apr 2016, 16:23

Awesome! Can't wait to see it in action.
Also 100/10 on that explanation!
Free...John Free. 'puts on shades'

Image

User avatar
Nick123q23
Posts: 455
Joined: 07 Jul 2015, 12:44
Location: LV-1201
Byond: Nick123q23

Re: Bullet Pathing Explained - Now & Upcoming

Post by Nick123q23 » 02 Apr 2016, 16:33

Does this incorporate ricochet bullets, if you shoot something too close and the bullet bounces off in another direction?
Player of faceless xenomorphs of the species XX121, Miranda 'Mira' Laporte, Daniel Gryphon, Kia and Akl'iiya Quatza-rij
Proudly played as and won a round as an Ancient Empress

User avatar
Azmodan412
Registered user
Posts: 1318
Joined: 01 Oct 2015, 23:17
Location: The Void

Re: Bullet Pathing Explained - Now & Upcoming

Post by Azmodan412 » 02 Apr 2016, 17:15

So no more making open corner walls and shooting at something occupying the corner space?
Image

Tyler 'Thrift' Borealis: Slaughterer of stupid xenos, insane motherfucker, and who played tower defense with Predators with an axe.
Predator Duels Won: 1
Predator Duels Lost: 2

BRING IT ON CASANY! I DO NOT CAST DOWN A CHALLENGE!
43 Xenos and counting.

Hunter Games: I am Moon Moon! Destroyer of worlds! Ahuhuhuhuhuhuhuhu!
Moon Moon Victories: x1

User avatar
Abbysynth
Registered user
Posts: 465
Joined: 30 Apr 2015, 21:15
Location: Ottawa, Ontario

Re: Bullet Pathing Explained - Now & Upcoming

Post by Abbysynth » 03 Apr 2016, 18:26

I'd like to answer your questions but the short answer is: I don't know how it will affect corners and cover exactly, there's still a large amount of testing planned before any of it goes on the live server. Ricochets aren't currently a thing.

Also note that there's a small degree of bullet spread now to every shot, based on the gun's accuracy and burst value (similar to turrets) so even having a 'clear shot' doesn't really mean a bullet will always go there. (it's REALLY small though unless you're chain-firing a MAR-40 on full auto or something)

User avatar
Halinder
Registered user
Posts: 315
Joined: 28 Oct 2015, 20:56

Re: Bullet Pathing Explained - Now & Upcoming

Post by Halinder » 03 Apr 2016, 19:12

Will you be adding multiple projectiles with large spread to the M37 shotgun?
https://i.gyazo.com/75f378476ef8f516e2f ... 2fa13b.png

LOOC: Halinder: p.s. the alien hive has huggers that you can use for breathing masks
LOOC: Barnabus Jones: Perfect game tips and tricks from halinder

[D] OOC: Eonoc: Hitler was a giant glowing yellow bug lizard. A very charismatic one.

User avatar
username123
Registered user
Posts: 285
Joined: 08 Feb 2016, 06:45

Re: Bullet Pathing Explained - Now & Upcoming

Post by username123 » 03 Apr 2016, 19:57

Halinder wrote:Will you be adding multiple projectiles with large spread to the M37 shotgun?
This, we need an actual shotgun, not a "wanna be" bolt action rifle that is not worth using because even a service pistol has a higher dps.

User avatar
forwardslashN
Community Contributor
Community Contributor
Posts: 2495
Joined: 14 Dec 2015, 23:12
Byond: forwardslashN

Re: Bullet Pathing Explained - Now & Upcoming

Post by forwardslashN » 04 Apr 2016, 00:01

Halinder wrote:Will you be adding multiple projectiles with large spread to the M37 shotgun?
Image
The ambivalent giant white baldie in a jungle near you.

User avatar
TeknoKot
Donor
Donor
Posts: 540
Joined: 03 Dec 2015, 10:19

Re: Bullet Pathing Explained - Now & Upcoming

Post by TeknoKot » 04 Apr 2016, 06:48

I'd settle with the square patterns, really. But this looks amazing.
:blush: "I'm a soldier, that means I'm the defendant and the judge."

Image

Victor 'Orbital' Kaipov says, "You're all fucking stupid."

https://youtu.be/aLEL1ZSf4fM

User avatar
MrJJJ
Registered user
Posts: 1935
Joined: 12 Jan 2015, 10:51
Location: Spider Lab

Re: Bullet Pathing Explained - Now & Upcoming

Post by MrJJJ » 04 Apr 2016, 21:52

username123 wrote: This, we need an actual shotgun, not a "wanna be" bolt action rifle that is not worth using because even a service pistol has a higher dps.
They using slugs to apparently *prevent* FF, but it just seems weak a bit, considering how much it does damage to even a runner...

Post Reply