Combat

Purpose
A big focus of our game will be combat. This means that our game will revolve around holding off waves of enemies with guns and traps.

Weapon types
For the future:
 * Default weapon: Assault rifle. This weapon is most useful when there are a lot of enemies with normal speed.
 * Low damage output
 * High fire rate
 * Medium range
 * Special: The weapons special will be an explosive bullet. This bullet will explode on impact and do area damage. This is not implemented yet.
 * Sniper rifle: Snipers will let the player shoot enemies at a distance. The high damage output makes it perfect for far away enemies.
 * High damage output
 * Low fire rate
 * High range
 * Special: The snipers special is its normal bullet. The bullet is a piercing bullet that hits everything in its path but does less damage the more things it hits. (Implemented Pierces bullet for the amount of enemies indicated)Untitled.png


 * Shotgun: Shotguns will take care of fast enemies in 1 shot. This weapon is also useful with slow traps.
 * High damage output, but bullet spread (high if all bullets hit, low if only 1 bullet hit)
 * Medium fire rate
 * Low range
 * Special: The shotgun can switch between 2 stands horizontal bullets or vertical bullets.

UI/UX
We need UI/UX for:
 * Overheating meter: Each weapon has a different overheating rate. (This is a replacement for bullets)
 * Cooldown: Is the reload time after overheating
 * Recharge: Time between shot.
 * Assault Rifle:
 * Overheat Chance: Low chance of overheating (A lot of bullets)
 * Cooldown: Quick
 * Recharge: Quick
 * Special on or off
 * Zoom scope
 * Sniper Rifle:
 * Overheat: High chance of overheating
 * CoolDown: Slow
 * Recharge: Slow
 * Zoom scope
 * Shotgun:
 * Overheat: Medium chance of overheating
 * Cooldown: Medium
 * Recharge: Medium
 * Special horizontal or vertical
 * Aim assist
 * Successfully hitting an enemy (sound)
 * Successfully headshotting an enemy (if applicable)(sound)
 * Missing an enemy - decal on the wall
 * Sounds are covered here

WeaponComponent
The WeaponComponent is a self-contained UActorComponent so it can be easily attached to the players, enemies, and turrets. It's responsible for the entirety of the gunplay as it keeps track of fire rate, overheating, animations, sound, and more.

Use Requirements

 * The actor to which the WeaponComponent is attached to needs to contain another component that has a socket called GripPoint. The WeaponComponent will automatically attach itself to this socket or remain floating at the world's origin and throw an error message.
 * The mesh for the WeaponComponent needs to contain a socket called Muzzle. Its transform decides the spawn point for the projectiles it fires. If the socket is not found it will fall back to the transform of the entire mesh, which is undesired.
 * The weapon mesh used by the WeaponComponent is currently hardcoded to the GunBlockout USkeletalMesh. This will change in the future.

Current Functionality

 * Switching of weapon configuration. The WeaponComponent can act as an assault rifle, shotgun, and sniper rifle. The data that drives these configurations are stored in a UDataTable called WeaponConfiguration_DT under Content/Databases. The content is linked to a source CSV file stored in the same directory, accessible through Windows Explorer. The configurations can be edited in both locations but make sure to import or export from Unreal to keep both synced.
 * Player input and per-frame input friendly. The WeaponComponent is self-managing so it's approachable with input on a frame-to-frame basis but it will only shoot when it is able to do so. With this approach, the WeaponComponent can both function with player input and AI input since that works in different ways.
 * Fire rate implemented. As mentioned above, the WeaponComponent will fire when it can and this is currently completely defined by the configurations fire rate.
 * Multiple projectiles per shot. The shotgun configuration spawns multiple projectiles each time the gun is fired. Projectiles do not collide with the actor that spawned them and also don't collide with other projectiles.
 * Projectile spread. Weapons do not have a spread pattern but have fully random projectile spread. Configurations define a half-angle (in degrees) and each projectile fired will travel in a direction that intersects with a point in the base circle of the cone that belongs to that half-angle.
 * Classes and blueprints that are derived from HealthActor and HealthCharacter have a health value and can be hurt by the projectiles.
 * Gunshot sound. Shooting currently plays a placeholder sound effect. It's not been tested for fast fire rates.
 * Projectiles that collide with something physical get destroyed and play a placeholder particle effect.

Planned Functionality (ToDo list)

 * Overheating mechanic. The second feature that dictates whether the WeaponComponent can shoot is the heat of the weapon. Each shot causes a set amount of heat. Continuously firing causes the gun to overheat, causing it to force a cooldown state during which the WeaponComponent can't fire while it cools down. Not shooting while there is stored heat also allows the weapon to cool down while still being able to shoot. This feature has UI, sounds, an animation, material and/or particle effects to convey information to the player.
 * Crosshair for aim indicator and optical zoom for the sniper rifle.
 * Weapon recoil to complicate rapid firing.
 * Meshes for the WeaponComponent. A single mesh with minute differences between configurations.
 * Animations for the WeaponComponent and the object it's attached to regarding shooting, idling, moving and overheating.
 * Sounds for the WeaponComponent regarding shooting and overheating and impact.
 * Decals for collision with walls and other targets (scorch effect/blood).
 * Particle effects for the shot projectiles and their collision with objects.

Blueprint Functions
Change Weapon Configuration, a function to change the configuration of the WeaponComponent. Target is the WeaponComponent object in question. The current configuration names are Rifle, Shotgun, and Sniper.

Set Shoot State, a function to pass input to the WeaponComponent. Target is the WeaponComponent object in question. The only exposed input state is AI. Call the function with AI within the AI blackboard. The WeaponComponent will see if it can shoot and act accordingly than revert the input state to the default: none. Input for players is handled

within the codebase.

TargetableObjectInterface
This is a blueprint exposed interface that provides methods for dealing damage to whatever implements this interface. Currently, the projectiles fired by the WeaponComponent check on collision with an object if this interface is implemented by the object. If it's the case then the projectile can damage the object through these defined methods.

Use Requirements

 * Classes and Blueprints that need to respond to projectiles need to implement the TargetableObjectInterface. Doing this allows them to define custom behavior to the functions defined by the interface which are used by projectiles or traps throughout the codebase. If the behavior is not defined than the object still won't respond to the projectiles/traps.

Current Functionality
Future Functionality
 * OnHazardHit. A function to deal X damage.
 * OnHazardHitOverTime. A function to deal X amount of damage over Y amount of time.
 * Potentially rework damage over time to deal an X amount of damage every Y second over a Z amount of seconds. This will move the damage over time behavior from a fluent behavior to a ticking behavior.

Blueprint Functions
To add the interface to a blueprint, open Class Settings int the Toolbar when editing the blueprint. In the Details panel opened by class settings locate the category Interfaces. Use the Add dropdown under "Implemented Interfaces" and search for TargetableObjectInterface. Compile and Save and then the blueprint in question will implement the interface and will be able to add custom behavior to the following functions. On Hazard Hit, this event is called when the object that implements the interface is hit by something that deals damage that occurs once. The damage value is provided and the blueprint can use it or define its own reaction. On Hazard Hit Over Time, this event is called when the object that implements the interface is hit by something that deals damage over a certain amount of time. The damage value and duration is provided and the blueprint can use it or define its own reaction. Inheritance

If the blueprint in question is a child of a class or blueprint that implements the interface then there is no need to add the interface to the blueprint in question again, it will already be listed under "Inherited Interfaces" instead of "Implemented Interfaces". If this child blueprint replaces the behavior then just define each event within the blueprint and it will overwrite its parent's behavior. If said behavior needs to be preserved than make sure to include a node to the parent's function before defining the rest of the event's behavior.

Health Base Classes
To streamline the default health and dying behavior for objects in the game there are two base classes that own a HealhComponent and implement the TargetableObjectInterface and define default behavior for its functions. These base classes are HealthActor and HealthCharacter. The first is intended for a stationary object and the latter for objects that need to move/be controlled. The base classes define basic behavior for the interface's events and also add a new event, the OnDeath event. This event is called when the object is destroyed with no health remaining.

Remember to use the parent node when defining the interface's events in child blueprints or else the default behavior of the base class is overwritten.