Combat API

Trigger Ability

Overrides the AI's current ability and attack distance so the ability can be used when called (given within distance).

Important: The AI's attack animation index (from an AI's Animation Profile's Attack List) is required. If the attack animation index does not exist within the AI's Attack List, there will be an error.

EmeraldAPI.Combat.TriggerAbility(EmeraldSystem EmeraldComponent, EmeraldAbilityObject AbilityObject, int AttackDistance, int AttackAnimationIndex)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.TriggerAbility(EmeraldComponent, DesiredAbilityObject, DesiredAttackDistance, AttackAnimationIndex);

Kill AI

Instantly kills this AI.

EmeraldAPI.Combat.KillAI(EmeraldSystem EmeraldComponent)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.KillAI(EmeraldComponent);

Reset AI

Resets the AI so it can be reused (can also be used for custom mechanics such as reviving).

Note: This is automatically called when an AI is killed and then re-enabled.

EmeraldAPI.Combat.ResetAI(EmeraldSystem EmeraldComponent)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.ResetAI(EmeraldComponent);

Get Distance From Target

Returns the current distance between the AI and their current combat target (Returns -1 if the Combat Target is null).

EmeraldAPI.Combat.GetDistanceFromTarget(EmeraldSystem EmeraldComponent)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.GetDistanceFromTarget(EmeraldComponent);

Get Combat Target

Returns the AI's combat target.

EmeraldAPI.Combat.GetCombatTarget(EmeraldSystem EmeraldComponent)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.GetCombatTarget(EmeraldComponent);

Set Combat Target

Assigns a specified combat target for your AI to attack within the AI's Detection Radius. Note: Targets outside of an AI's Detection Radius will be ignored. If you want no distance limitations, use OverrideCombatTarget(Transform Target).

EmeraldAPI.Combat.SetCombatTarget(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.SetCombatTarget(EmeraldComponent, YourTargetTransform);

Override Combat Target

Assigns a specified combat target for your AI to attack ignoring any distance limitations. If the target is not within attacking range, the AI will move to the target's position and attack based on its attack distance, even if it is outside of its detection radius.

EmeraldAPI.Combat.OverrideCombatTarget(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.OverrideCombatTarget(EmeraldComponent, YourTargetTransform);

Flee From Target

Makes an AI flee from the specified target by switching their behavior to Coward. The AI will remain with the Coward until it is reset manually.

EmeraldAPI.Combat.FleeFromTarget(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.FleeFromTarget(EmeraldComponent, YourTargetTransform);

Search For Closest Target

Searches for a new target within the AI's Detection Radius closest to the AI.

EmeraldAPI.Combat.SearchForClosestTarget(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.SearchForClosestTarget(EmeraldComponent);

Search For Random Target

Searches for a new random target within the AI's Detection Radius.

EmeraldAPI.Combat.SearchForRandomTarget(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.SearchForRandomTarget(EmeraldComponent);

Get Last Attacker

Returns the transform that last attacked the AI.

EmeraldAPI.Combat.GetLastAttacker(EmeraldSystem EmeraldComponent, Transform Target)
//Example - It is recomended that EmeraldComponent is cached somewhere
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Combat.GetLastAttacker(EmeraldComponent);

Last updated