Beam/Ray Support

This details the requirements for a beam or ray type weapon. The codebase will use the Beam terminology to differentiate it from what is typically known as a ray (starting point and a directional vector).

Introduction

Beam-type weapons do not share a lot in common with projectile weapons, so they are treated as their own entities. They fall into two major categories: attached and non-attached. An attached beam is one that is always following the player as they are moving and turning. Non-attached beams are ones that are fired off, similar to projectiles, and will always face the direction at the time they were fired. Non-attached beams have a steady velocity and no acceleration or gravity; their velocity can be affected by a repulsor, similar to projectiles.

Beams are constructed out of one or more segments. This allows a beam to be split into several straight lines to allow for them to reflect and bounce off of walls. The "length" of a beam is the summed length of all the segments.

Segments of attached beams always retain their length as they reflect, because the starting point is fixed at the player's current location, and the ending point is fixed at the length of the beam. Non attached beams on the other hand will always have shrinking tail segments and growing head segments as they reflect, and will collapse down as they reach the length of the beam.

Damage and Collision Model

Unlike projectiles which deliver the full damage amount instantaneously, beam weapons use a Damage Per Second model. The implementation itself subdivides the actual damage applied over the number of game simulation ticks such that for any given second, the sub-second damage amount is applied multiple times. On each frame, if a collision is registered between a beam and a player, the amount of damage for that frame is applied.

For attached beams, collision anywhere along the beam will move the 'head' segment back to the collision point, potentially collapsing all the segments down into one if the collision occurs before any beam reflection. Attached beams consume some amount of resources or energy for every second they are activated (the simulator is responsible for appropriately taking care of sub-second amounts).

For non attached beams, a new segment is formed at the place of collision. The colliding vehicle will start to incur the damage of the remaining tail segments. Non attached beam consume a specific amount of resources prior to firing, much like projectiles.