Bullet Pathing Explained - Now & Upcoming
- Abbysynth
- Registered user
- Posts: 465
- Joined: 30 Apr 2015, 21:15
- Location: Ottawa, Ontario
Bullet Pathing Explained - Now & Upcoming
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:
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.
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.
Hopefully this all makes sense. TLDR: Bullet pathing will be changing soon. So, expect that.
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:
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.
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.
Hopefully this all makes sense. TLDR: Bullet pathing will be changing soon. So, expect that.
- username123
- Registered user
- Posts: 285
- Joined: 08 Feb 2016, 06:45
Re: Bullet Pathing Explained - Now & Upcoming
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.
- SecretStamos (Joshuu)
- Registered user
- Posts: 1291
- Joined: 15 Oct 2014, 12:32
- Location: Stars & Stripes
Re: Bullet Pathing Explained - Now & Upcoming
Abby, you're my hero
- Halinder
- Registered user
- Posts: 315
- Joined: 28 Oct 2015, 20:56
Re: Bullet Pathing Explained - Now & Upcoming
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.
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.
- Abbysynth
- Registered user
- Posts: 465
- Joined: 30 Apr 2015, 21:15
- Location: Ottawa, Ontario
Re: Bullet Pathing Explained - Now & Upcoming
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.
For instance, the likelihood that hiding around a doorway will protect you from a turret anymore is slim.
- Sadokist
- Donor
- Posts: 630
- Joined: 01 May 2015, 07:55
- Location: Seattle, Washington
Re: Bullet Pathing Explained - Now & Upcoming
your hero is officially a grandma.SecretStamos (Joshuu) wrote:Abby, you're my hero
- coroneljones
- Registered user
- Posts: 1350
- Joined: 15 Oct 2014, 12:46
- Location: SPESS!
Re: Bullet Pathing Explained - Now & Upcoming
PRAISED BE!
Abby once again codes us something amazing
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
-Credit goes to SovietCyanide
- Szunti
- Registered user
- Posts: 293
- Joined: 10 Dec 2015, 17:18
Re: Bullet Pathing Explained - Now & Upcoming
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?
- Sargeantmuffinman
- Registered user
- Posts: 1372
- Joined: 01 Apr 2015, 14:31
- Location: Mean while in Europe somewhere.
Re: Bullet Pathing Explained - Now & Upcoming
Well I'll say my goodbyes for the old projectile code.
Old projectile code,we may or may not miss you.
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.
I don't like cute things.
Good hunting.
- forwardslashN
- Community Contributor
- Posts: 2495
- Joined: 14 Dec 2015, 23:12
- Byond: forwardslashN
Re: Bullet Pathing Explained - Now & Upcoming
The ambivalent giant white baldie in a jungle near you.
- Deadlymight
- Registered user
- Posts: 41
- Joined: 24 Jan 2016, 12:28
- Location: Disposals pipes
Re: Bullet Pathing Explained - Now & Upcoming
Awesome! Can't wait to see it in action.
Also 100/10 on that explanation!
Also 100/10 on that explanation!
Free...John Free. 'puts on shades'
- Nick123q23
- Posts: 455
- Joined: 07 Jul 2015, 12:44
- Location: LV-1201
- Byond: Nick123q23
Re: Bullet Pathing Explained - Now & Upcoming
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
Proudly played as and won a round as an Ancient Empress
- Azmodan412
- Registered user
- Posts: 1318
- Joined: 01 Oct 2015, 23:17
- Location: The Void
Re: Bullet Pathing Explained - Now & Upcoming
So no more making open corner walls and shooting at something occupying the corner space?
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
- Abbysynth
- Registered user
- Posts: 465
- Joined: 30 Apr 2015, 21:15
- Location: Ottawa, Ontario
Re: Bullet Pathing Explained - Now & Upcoming
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)
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)
- Halinder
- Registered user
- Posts: 315
- Joined: 28 Oct 2015, 20:56
Re: Bullet Pathing Explained - Now & Upcoming
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.
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.
- username123
- Registered user
- Posts: 285
- Joined: 08 Feb 2016, 06:45
Re: Bullet Pathing Explained - Now & Upcoming
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.Halinder wrote:Will you be adding multiple projectiles with large spread to the M37 shotgun?
- forwardslashN
- Community Contributor
- Posts: 2495
- Joined: 14 Dec 2015, 23:12
- Byond: forwardslashN
Re: Bullet Pathing Explained - Now & Upcoming
Halinder wrote:Will you be adding multiple projectiles with large spread to the M37 shotgun?
The ambivalent giant white baldie in a jungle near you.
- TeknoKot
- Donor
- Posts: 540
- Joined: 03 Dec 2015, 10:19
Re: Bullet Pathing Explained - Now & Upcoming
I'd settle with the square patterns, really. But this looks amazing.
"I'm a soldier, that means I'm the defendant and the judge."
Victor 'Orbital' Kaipov says, "You're all fucking stupid."
https://youtu.be/aLEL1ZSf4fM
Victor 'Orbital' Kaipov says, "You're all fucking stupid."
https://youtu.be/aLEL1ZSf4fM
- MrJJJ
- Registered user
- Posts: 1935
- Joined: 12 Jan 2015, 10:51
- Location: Spider Lab
Re: Bullet Pathing Explained - Now & Upcoming
They using slugs to apparently *prevent* FF, but it just seems weak a bit, considering how much it does damage to even a runner...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.