CDDA 3d Ballistics (throwing, bows, long range shooting, artillery)

Introduction

Greetings CDDA! I am a long-time lurker and player and a big fan of the project. I am not an experienced enough programmer to tackle 3d ballistics project myself, but I think it is worthwhile for the core developers to take this on and I can offer some organized thoughts on this matter.

I believe the current ballistics system can be greatly improved by removing the current 2d dispersion and a ‘TODO’ for 3d dispersion system in /src/ballistics.cpp and replacing it with a more generalized simulation. I included a bit of math in this document to assist the thought process of whoever ends up pursuing this project.

I propose we simulate initial velocity and mass, character accuracy, mechanical accuracy, gravitational force, atmospheric drag, wind force, terminal ballistic damage and maybe Coriolis wind/force if anybody is willing to tackle that. To support this system, some preliminary work must be done.

Preliminary Work

Implement projectile physics

Ballistic projectiles must travel at a certain speed from the launcher. It is worthwhile to perform calculations on the projectile 10 times in one turn (second), or more depending on how tolerable the lag is. It can even be a world-gen option. We should call this period: ballistic_time_step_size

A projectile should determine whether the fuze conditions will be met within the next calculation period and if so, then work out exactly which tile to strike/activate in.

A player (or later on NPC) will input direction and elevation into the ballistics function and this will result in a projectile leaving the launcher at the direction and elevation the player specified (degrees direction and elevation must be converted into x,y,z component velocities by the function)

A ballistic projectile should have the following parameters specified by its JSON:

  • Applicable launcher list
  • Mass
  • Silhouette Area (from the front)
  • Drag Coefficient
  • Muzzle Velocity for each launcher (to be split among xyz components by ballistic function)
  • Muzzle Energy for each launcher (0.5massvelocity^2)
  • Projectile Damage at Muzzle for each launcher (can use existing slash/blunt/pierce system, basically 100% damage at muzzle with fall-off based on terminal speed)
  • Mechanical accuracy of the projectile (given in degrees, but displayed to player in MOA, 1MOA~0.0167degrees.)

A launcher should have the following parameters available:

Mechanical accuracy of the launcher (given in degrees but displayed to player in MOA. Ex: rifles have accuracies of 0.5MOA-5MOA)

Math

We should use the following definition of drag:

Drag = (Density of Air * Drag Coefficient * Silhouette Area)/2

Glossary

  • a_px, a_py, a_pz = acceleration of projectile in x,y,z direction
  • C_d = drag coefficient (0.04 for streamlined object, 0.38 for aerodynamic elongated object and 0.47 for sphere)
  • ρ = air density at current elevation (1.225kg/m^3 at sea level, 1.007 at 2km, 0.4135 at 10km)
  • A = silhouette area
  • m = mass of projectile
  • g = gravitational acceleration (9.8 m/s^2) on earth’s surface
  • x_p, y_p, z_p = xyz position of projectile at next iteration
  • x_0p, y_0p, z_0p = previous iteration’s xyz position of projectile
  • v_0x, v_0y, v_0z = the xyz component velocity of projectile at previous iteration
  • ballistic_time_step_size = delta time since last iteration (0.1s default provided it doesn’t lag)

Acceleration Equations

a_px =(-0.5C_dρA(v_px+v_wx)^2)/m

a_py =(-0.5C_dρA(v_py+v_wy)^2)/m

a_pz =-g-(0.5C_dρA(v_pz+v_wz)^2)/m

Kinematic Equations

x_p=x_0p+v_0xballistic_time_step_size+0.5a_px^2

y_p=y_0p+v_0yballistic_time_step_size+0.5a_py^2

z_p=z_0p+v_0zballistic_time_step_size+0.5a_pz^2

Initial Velocity

Initial velocity is provided by the projectile’s initial velocity (v_0) and is split into X, Y and Z components by vector math from spherical to cartesian using the compass direction and elevation the character has provided the ballistic function.

v_0x=v_0*sinφcosθ

v_0y=v_0*sinφsinθ

v_0z=v_0*cosφ

  • θ=compass direction
  • φ=elevation

Limitation: I chose not to specify side silhouette area and side drag coefficient for wind to simplify work for the future.

Create “area target” fire mode

The player should be allowed to fire weapons in four ways:

  • On the local map, aim at a selected point target (ex: zombie, cursor) and fire directly at it as players do currently and the program will compensate for projectile drop due to gravity. This will be noticeable for throwing weapons and bows.
  • Open the “area target” GUI and select/type a compass direction and gun elevation and fire at it.
  • Fire using the “long range point target” option if equipped with a weapon equipped with an optical sight. This should significantly expand the reality bubble of the player in the chosen direction (based on quality/stabilization of optic up to 1500 meters/squares) and allow them to manually enter elevation and windage corrections when they select a tile to shoot at.
  • Additionally, if player finds/creates an artillery computer attached to a weapon, they should be allowed to use the ballistics computer GUI and to open the world map and select a certain tile to shoot at or to input the exact coordinates and have the program compensate for most of the forces acting on the projectile.

Virtual Z-Levels

Artillery fire (e.g., catapults, mortars) requires a projectile to travel to z-elevations far in excess of what’s necessary for OVERMAP_HEIGHT for normal gameplay.

Depending on how they are implemented, virtual z-levels can be useful later for aircraft and AAA fire at aircraft. (ex: your aircraft flies at 12km elevation and is at virtual Z-level 6000)

Reality Bubble

The popular flight simulator based on MicroProse Falcon 4 (BMS.) has background simulation (think of dwarf fortress world gen) and then a detailed simulation “reality bubble” for the main aircraft and for all munitions launched from the aircraft. I propose a similar approach for CDDA.

As a ballistic object travels through the CDDA world, it should trigger enemy spawns the same way a player would and if the fuze triggers at a certain position, it should simulate the release of whatever payload it carries.

This system should allow for the sterilization of remote areas from enemies through artillery bombardment.

Dispersion

Launcher Dispersion

Every launcher should have a mechanical dispersion maximum statistic specified in degrees (may be displayed to player in MOA) and every projectile launched from this launcher should roll x_dispersion from -mechanical_dispersion_maximum to mechanical_dispersion_maximum. it should then roll y_dispersion from -mechanical_dispersion_maximum to mechanical_dispersion_maximum and finally roll this for the z component.

Character (player or NPC) Dispersion

  • The character’s weapon skill (ex: throwing, bows) and a new “indirect attack” proficiency should be averaged to add x,y,z dispersions from 10 degrees at level 0 to 0 degrees at level 10.
  • The launcher’s aiming device should make this easier or harder. If a launcher has no artillery sight, then it should multiply character dispersion by 3.
  • If it has a rudimentary sight, then it should multiply it by 2
  • If it has a decent artillery sight, then it should multiply it by 1.5
  • If it is attached to a ballistic computer, then it should multiply it by 1

Total Dispersion

  • character_dispersion_maximum =(applicable_weapon_skill+indirect_attack_proficiency10)/2launcher_aiming_device_modifier)
  • character_dispersion_x,y,z= roll from –character_dispersion_maximum to character_dispersion_maximum
  • Finally, add both mechanical_dispersion and character_dispersion to the direction and elevation the character provided the ballistic function and use this value to launch the projectile.

GUI and Command Line Parser

There should be a GUI with mouse support where a player can enter gun direction and elevation using dials or the command line parser or use the ballistics computer functions if one is present.

Ex parser commands:

  • fire NNW 45
  • 350.555 30
  • 20 degrees 60 degrees
  • 3/4pi pi/2
  • directly up
  • zenith

Artillery Launcher Examples

  • Catapult (standalone or vehicle mounted)
  • Trebuchet (standalone or vehicle mounted)
  • Large Slingshot (standalone or vehicle mounted)
  • Black powder cannon (standalone or vehicle mounted)
  • 37-150mm mortars List of infantry mortars - Wikipedia
  • Field guns and howitzers

Tangential Suggestions

Drones, Self-Spotting and BDA

Artillery is much more fun when you’re able to see the destruction you’re causing. It can be handled in a realistic manner through the following technologies:

  • Remote observation through TV feed from launched projectile if camera and radio are mounted
  • Remote observation through camera mounted on terrain/quadcopters/fixed wing drones/robotic vehicles in the area. This will provide additional challenge with multiple reality bubbles since the drones will need one on their own.

Drones are the most effective and realistic method of spotting targets for your own artillery fire. Commercial quadcopter spotting for a mortar is the go-to strategy of the current batch of wars and a game can’t be realistic without simulating this capability.

Terminal Ballistics

There should be some handling for shooting light projectiles out to long distance and the damage caused by such.

The projectile should impact with enough energy (J) and pressure (kPa) to damage the target.

Fuze types

Several methods of activating a payload should exist:

  • Impact fuze – the projectile will activate the payload after lightly touching an object/tile. Easy to make.
  • Timer fuze – detonates after a set amount of time after arming. Easy to make.
  • Delayed impact fuze – the projectile will strike whatever is in its way first and then activate the payload.
  • Radio-proximity fuze – the projectile will activate its payload when it reaches 5 tiles distance to an object after a 50-tile arming period
  • Pressure mine fuze – creates a mine triggered by something stepping on it/driving over it after it impacts the ground
  • Magnetic mine fuze – creates a mine triggered by a metal object passing over it after it impacts the ground
  • Command-activated fuze – to be used with a TV-feed and remote to activate the payload on command

Explosives Simulation

I propose we implement a virtual explosive object that will be created prior to detonating an explosive. When a bomb detonates, it should check an inner explosive radius for other bombs and that bomb should check its inner explosive radius for other bombs and this should happen iteratively, and each object should be added to the virtual explosive object. The inner explosive radius should be one third of the actual explosive radius to avoid dealing with weird explosion geometry.

This virtual explosive object should then be treated as a single bomb with the yield of all component bombs. This will allow the player to stack explosives in an area and explode them as a single large bomb.

It can be fun to implement a fuze failure chance to simulate unexploded ordnance (that can then be exploded with additional artillery fire)

It may be fun to simulate explosion velocity and explosion energy for every explosive.

Payloads

Some ideas of payloads that can be activated by the fuze:

  • Dummy – does nothing when activated. Strikes everything in the tile it lands in. Has a 30% chance of bouncing forward once but losing 30% of its x and y velocities.
  • Explosive – hammer strikes primer when explosive impacts something with enough force and detonates the secondary explosive
  • Activatable item – acts as if the player activated it. Must be crafted with a powered microcontroller (with battery) and motor (solenoid.)
  • Pressure Mine – creates a pressure plate activated mine upon being activated by the fuze. Anything that steps/drives over it will detonate the mine.
  • Magnetic Mine – creates a magnetically activated mine upon being activated by the fuze. Metal objects/subjects (like cyborgs) passing over this mine will detonate it.

Commanding NPC Area Fire

It would be fun for the player to act as a spotter for NPC controlled artillery batteries. It would require implementing radios, radio channels and artillery conversation options where you specify either map coordinates or direction and elevation over the radio channel.

It would also be fun to command a group of NPC soldiers near the player to volley fire their bows/muskets/grenades in a certain direction to bully zombies before the charge into a location.

Weather Simulation

Wind speed can be specified either abstractly or it can be specified by altitudes and locations (ex, wind will blow SSW at 3m/s from 0 to 1000m at these world map tiles, but blow NE at 10m/s from 1000m to 10km at those same world map tiles)

Expanding Point Cloud Type Artillery

It may be fun to simulate grapeshot type projectiles launched from an artillery piece as a constantly expanding cloud that will strike a set of tiles with constantly decreasing probability/damage.

Virtual Projectiles Using Multiple Powder Charges

It’s worth simulating loading a certain quantity of powder charges into the gun (see XM231/XM232 system XM231/XM232 Modular Artillery Charge System (MACS) ) and this process creating a projectile with varying muzzle velocities.

Faction Wars

To provide targets for artillery.

2 Likes

The big question you’re skipping over here is “why?”. In other words, what benefit does this bring to the game?

A more neutral phrasing is, “what impact will this have on how the game is played?”, and the answer is, “it will slow down combat a great deal.”

DDA is not a sniping or artillery simulation game, it’s a tactical RPG where the player character has skills pertinent to performing tasks such as shooting a target, players don’t micromanage how that happens. Also, DDA is an extremely “target rich environment” where a character is expected to fight hundreds to thousands of enemies over the course if the game, attack actions must be reasonably streamlined. As such having the player input elevation and windage is a non-starter, just pick a target and fire.

Regarding ballistic simulation, all local ballistic actions clock in at under a second, so from the game point of view, projectiles arrive instantly. Non-local ballistics don’t give the target a chance to respond, so there is likewise no reason to treat them as non-instantaneous.

For area target attacks, the player should still simply select a target and the character will use their abilities to attempt to execute the action.

I’m not clear on the purpose of virtual z-levels, you just plot a ballistic arc and only evaluate the parts of that arc that are within the simulated area(s). If you are firing at a target more than ~50m off the ground, we need a somewhat different system rather than trying to do something like load hundreds of empty z-levels.

There are other recommendations, but tbey have similar issues of not serving the goals of the game.

2 Likes

Impressive presentation!
I wish this level of ability to sell my ideas.

1 Like

Thanks for reading my post!

I compiled some of my thoughts regarding why a ballistic system with (limited) global simulation is a great choice for CDDA, despite its tactical roguelike nature:

  • The world will feel dead without simulation of offloaded/remote areas. The player will feel the world is lifeless if there is no depth to their interactions with the larger world.
  • There should be background simulation of NPC activity and progress of the cataclysm and this background simulation should allow the player to impact it.
  • If background simulation is implemented, the player will need methods of interacting with remote areas/the world at large. Remote technology is a great way to achieve this in a realistic manner (cameras, quadcopters, ugvs, etc…)
  • Player will wish to reach out and touch those remote areas, and if a ballistic system is not implemented a player will inevitably ask “why can’t I deliver artillery to remote targets?” It’s highly unrealistic to limit the player in this manner. Artillery is the main tool of warfare for hundreds of years now.
  • It is not realistic to add guns, but to limit the player to shooting them to within spitting range. Real engagement ranges can be hundreds of meters.

Regarding the pacing of this new system:

  • I never intended for the area target/ballistic fire to be the primary way of shooting enemies.
  • One possible way to implement this new system without making the old system onerous is to have a separate binding to fire using area target/long range shooting mode. Ex: f to fire immediately at a nearby target and F to fire using ballistic system. The existing system can benefit from 3d scattering and ballistic arcs as well when considering bows and throwing weapons.
  • I think non-instant projectiles can give the player opportunities to take action in a roguelike setting. Take a look at the way DF adventure mode handles reactions and opportunities if you’re interested in this.

Regarding virtual z-levels:

  • It’s the most realistic way I can think of for high-arc projectiles traveling to the top z level and then re-entering at the top z-level at another world tile. It doesn’t have to be implemented this way though.
  • Ex: each weapon can have a max world-tile range specified and depending on how close the player shoots the weapon to its max range, the flatter the exit and entrance of the projectile is when it disappears from view and then reappers at the target map tile. (to simulate the trajectory difference between shooting at 45 degrees and 80 degrees)
1 Like

This feels like a backwards reasoning - Your building up a justification around a detailed out-of-bubble simulation to then include offensive means of engaging out-of-bubble. The part about firearm engagement ranges is reasonable, but it faces a problem that if you can reach out into this abstracted second-layer bubble, it should be able to reach out to you. At which point, its not an abstracted second layer bubble, its just a larger normal bubble.

Artillery may be the main tool of warfare, but we’re not engaging in warfare. Were engaging in a much smaller scale of combat than warfare, more akin to skirmishing. Artillery warfare is industrialized warfare at a minimum, industrialized and mechanized in the more modern context, and not something that a lone survivor or small survivor community is liable to use as “default engagement” methods. There’s really no need to create such a complicated and involved system that would ask to change so much about normal combat for minimal benefit, or create a secondary, underutilized combat system alongside the actual one that now must be maintained, to handle the rare case of the player having artillery and wanting to shell some map tile out there. Probably easier to utilize a ‘hack’ like loading a localized reality bubble just to resolve the strike on target and assuming the rest was fine. And last I heard that idea discussed, the reality bubble was not very cooperative, I’m just stating in general.

Pacing extends beyond the act of actually making your attack, but living and existing in that world. Having raiders engaging you from long distances like this would make any build that’s not carrying around long distance rifles a game of peek a boo, multiplied by ‘realistic’ distances as you try to cross hundreds of tiles. Any street lane in the city would become a long killbox for anything with firepower. While these are realistic in of themselves, they massively shift the enjoyment of the game, as everything slows down to accommodate you as a a player dealing with the significantly larger amounts of threats presented to you actively, and having to fight them potentially all at the same time. Combine that with the fact that you’d have to deal with all these extra mechanics when actually engaged at that range, and it’ll be even slower.

Remember, when you have a new ‘long’ range bracket in your combat model, every fight still starts in ‘long’ range. A larger, more encompassing long range means more fights at long range, under long range rules.

One side bit that I don’t think is super relevant but I want to point out as well - If the player is firing in any situation where proper 3d ballistic trajectories for their artillery is going to make a difference, they’ll never see it - by definition, if they’re having issues they would be occluded from seeing the target. If they’re firing across a vast, open field, the trajectory simulation provides no benefit. Using artillery right means never seeing your target, which as a game designer means your player will never really see you using ‘close enough’ as a design goal.

I do like the idea of long range sniping or having limited artillery attacks. Snipping should however only be possible with specific guns that can fire accuratly at exteme ranges so something like a assault rifle isn´t going to cut it but a military or police sniper rifle certainly would and some hunting rifles as well. Sniping should also be a high skill activity and be heavely impacted by stuff such as the condition of the gun and the quality of ammo you are using.

I could also see artillery fire being a thing that would be in the capabilities of a single or small group of sruvivors. I don´t think that fireing a howarts is a good idea since you are unlikely to find one and the nessecery ammonition much less have the knowladge to be able to accuratly fire one. You can however probably scavenge and military mortars and use those to soften up a large zombie horde. You even see people make their own improvised mortar and mortar rounds in places like syria. Than there is the fact that a single survivor can probably make much more primitive pre industrial cannons and blackpowder rockets.

Tl;dr for my reply, the simulation doesn’t dictate the interface. I agree that a lot of the scenarios you outline could be supported, and I already have plans for doing so. However, just because we would have some degree of ballistic simulation happening does not mean the player’s input into that system should expose all that detail. The player’s input still boils down to “select a target and decide how long to spend aiming per shot”.

You are pivoting to a separate issue. I didn’t say interaction at a distance was a problem, and the game does include a ballistic simulation to some extent, though you are overstating how complex it needs to be. I am already planning to add more interaction at larger distances, but there are myriad technical issues to address, it’s not just a matter of coming up with the idea. The problem is the micromanagement-heavy manual aiming proposal.

One, manually tweaking windage, elevation (charge amount for artillery) does not fit in the UI for the game, it’s a large departure from how everything else is done. The character has a certain set of skills for accomplishing tasks, the player just provides executive decisions.
Two. and the reason for the above, is that if you add an option that provides a benefit for micromanagement, players will frequently take it regardless of negative impact to the user experience, and then you’re back to it making the game less fun. Micromanagement of ballistics is a non starter.

Indirect fire is an option, but the interface will still boil down to selecting a target and some indication of how much time the character should spend aiming.

Hard no, there is no meaningful opportunity for a character to take action once a projectile is in flight, either their own projectile or one targeting them. I outlined this in my last post, if you have issues with that, address them specifically.

Agree. As I pointed out in my previous reply, if you’re not dealing with obstructions reasonable ballistic calculations are quite straightforward, all you need is to determine the impact site and use that to load the appropriate map chunk so you can apply any effects.

I agree, the selective use of extreme range engagement with good rifles or burst fire weapons is something I want to add. I include burst fire, because if you’re firing at e.g. a dense group of zombies, you can still score numerous hits at these extreme ranges with an assault rifle, especially since your default targets aren’t going to be taking cover.

Definite agreement on mortars, they would be the primary use case here. In particular, not player-fired mortars, but mortars owned by NPC factions that the player can use to call in fire support with a radio. Again, that would just be choosing a point on the map as the aim point, no manual entry of anything.

One-pound cannons or so would definitely be something you could manufacture as well, though there is a serious question of kill rate at extreme range, if you don’t have a range-based arms race going on, I seriously question the efficacy of investing in black powder cannons or mortars for long range fire, most shots are going to miss, and even hits are only going to take out a handful of targets. I strongly suspect medium range grape shot is what you really want to be shooting out of a cannon, giving it enough range to spread but not enough to lose too much velocity.
Rockets are pretty much right out, I haven’t come across any sources indicating that pre-industrial rockets were good for anything but intimidation.

1 Like

Your target isn´t always going to be a group of enemies. Sometimes you will be shooting at a large static target such as enemy fortifications, migo towers and fungal structures. You aren´t going to have a lot of options in damaging these things at extreme ranges and a blackpowder cannon or mortar might be an adiquate and fairly economical option. Depending on the situation it might in fact be your only option in damaging such targets at extreme ranges.

Pre-industrial rockets also have possible uses. Yes they where horrifically inaccurate and would only be effective if used in large number to saturate a given area. But they can be filled with incendiary and used to light something on fire. This would be of great use against the mycus and more limited against the triffids as they could be used to start fires over a large area. These rockets also have a long range of more than a kilometer so you could use them to start fires far and wide deep in mycus territory. Rockets are also far more mobile as they can be carried by a survivor and you you don´t need to haul a cannon or mortar around.

Currently the hard limit on firearms range is about 120 paces, about 80 meters. With a few hours of training I went from “which bit do you put the magazine in?” to reliably hitting person sized targets at 200m down iron sights with an assault rifle, and I am by no means naturally skilled. Sure, an assault rifle isn’t going to make 1500m shots, but an assault rifle with plentiful ammunition and a sight would be a far more powerful asset than it is in game.