Table of Contents

Class AIAbilityReach

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

How far an ability can actually hit something from, as the AI should reason about it.

public static class AIAbilityReach
Inheritance
AIAbilityReach
Inherited Members

Remarks

Range is Speed × LifeTime: the distance a projectile travels. Every ability that does not travel — a punch spawned in front of the caster, a ball of flame held at the hands, a self buff — reports a range of ZERO, and the combat planner compared the distance to the target against that zero: the Attack intent was unreachable, so a melee orc walked up to its target and stood there forever, and a caster with the same kit kept its archetype's preferred distance and never cast. Issue #220.

A stationary ability reaches as far as its object extends from the caster: the caster's own radius, plus the spawn offset (one half-extent of the ability object, see the Forward case in AbilityObject), plus the object's half-extent again, plus a little slack for the target's own body.

Fields

DEFAULT_TARGETED_REACH

Reach assumed for a stationary ability spawned at the aim hit point. The AI aims at its target, so this is the cast range it will engage at.

public const float DEFAULT_TARGETED_REACH = 20

Field Value

float

MIN_REACH

No ability is treated as reaching less than this; a zero reach is unplannable.

public const float MIN_REACH = 1

Field Value

float

REACH_SLACK

Allowance for the target's body and NavMesh sampling error, in metres.

public const float REACH_SLACK = 0.25

Field Value

float

Methods

Resolve(Ability, float)

The distance from the caster at which ability can hit a target.

public static float Resolve(Ability ability, float casterRadius)

Parameters

ability Ability

The ability.

casterRadius float

The caster's body radius (NavMeshAgent or collider radius).

Returns

float

The reach in metres, or 0 for a null ability.

ResolveFromExtents(AbilitySpawnTarget, float, float)

The reach of an ability whose object does not travel, from the geometry involved.

public static float ResolveFromExtents(AbilitySpawnTarget spawnTarget, float casterRadius, float prefabHalfExtent)

Parameters

spawnTarget AbilitySpawnTarget

Where the ability object is placed.

casterRadius float

The caster's body radius.

prefabHalfExtent float

Half the ability object's horizontal size.

Returns

float

The reach in metres.

Remarks

Pure, so the rule can be pinned without prefabs.

ResolvePrefabHalfExtent(Collider)

Half the horizontal footprint of an ability object's collider, scale included.

public static float ResolvePrefabHalfExtent(Collider collider)

Parameters

collider Collider

The prefab collider, or null.

Returns

float

The half-extent in metres, 0 when unknown.

Remarks

Read from the collider's shape rather than bounds: the cache hands back the collider on the prefab ASSET, which has never been through a physics update and reports empty bounds.