Combat
Key Features
Manages Player Combat: Tracks player's attackers (added, removed, killed), auto engagements and finding enemies.
Attack & Health: Combat is driven by 2 components, attacker and health.
Realtime combat: Handled by moving and stationary attack tasks.
Melee & Ranged: Simple attack in proximity to enemy or firing ranged projectiles.
Line of Sight: Use line of sight for obstacles on module for all units or per-unit.
Event-Driven Updates: Global events for tracking health changes. Per unit events for tracking health and attack status changes.
Structure
Combat Module - Easy access to player's attackers, finding enemies, detecting attack range and retrieving attack positions for initial movement.
Attack Capability - Defines unit stance (no attack, defensive, aggressive and stand ground), range of attack, reload speed, default damage, line of sight range, damage based on unit type, specify invalid targets, etc.
Unit Attack - Management of attacker's state; reloading, moving, entering/exiting combat, etc. Currently it has 4 built-in options for Stance with
UnitAttackdefault implementation.No Attack: Never engages on its own. Must be commanded to attack.
Defensive: Uses last commanded target position as defensive point; unless manually specified. Configuration includes defend range.
Stand Ground: Does not move, attacks only when enemy is within the attack range.
Aggressive: Typical behaviour, looks for targets nearby and engages. Switches targets only if another is very close (depends on attack task configuration) and at the same time closer than the target.
Attack LOS - Attacker specific LOS used before attacking and finding its target.
Projectile Launcher - Responsible for firing and managing projectiles of
UnitAttack.Projectile - Use existing or create your own projectile behaviours. Provides basic projectile, proximity projectile, impact projectile (AOE) and collision projectile.
Health Capability - Defines health points, auto regeneration, and if health can increase or decrease current hit points (heal or damage).
Health - Management of health's state.
HealthFinder - Spatial grid finder, optimised for larger number of units.
Tasks - Provides abstract task for customisation of attack behaviour, stationary attack task, mobile (movement) attack task and move and attack task with position as the final target.
Combat Events - Global events for tracking health changes and firing projectiles.
Usage Examples
Control Attackers
To disable or enable automatic detection of nearby enemies in runtime use the following method:
When disabling this none of the units will automatically engage and you have full control over engagement process by starting tasks/sending attackers to health targets.
Find Nearby Enemies
When you wish to find nearby enemies for the attacker:
Damage Health
When you wish to deal damage instantly to the target.
Move and Attack command
When you wish for movable unit with attack capability to move to a specific position while picking up enemies and engaging on the way.
This schedules a specific task with input & context, with no additional validation. Be careful when using this if not used on valid units; starting tasks on invalid units might throw exceptions, depending on the task.
Change Stance
When attack unit needs to change it's stance/behaviour:
Manual Health Tracking
To track health state changes, hook your scripts to any of the events available in CombatEvents .
Healing
When you wish to heal entity manually.
Last updated