Table of Contents

Class AITargetSelection

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Target-picking strategies shared by the attacking states and the behaviour tree.

public static class AITargetSelection
Inheritance
AITargetSelection
Inherited Members

Remarks

Kept separate from AggressionController because these modes deliberately ignore the threat table — a rampaging beast or a critter that just bites whatever is nearest has no interest in who has done the most damage to it.

Methods

GetHealthPercent(ICharacter)

Returns a character's health as a fraction (0-1) of its maximum, or 1 when unknown.

public static float GetHealthPercent(ICharacter character)

Parameters

character ICharacter

The character to measure.

Returns

float

The health fraction.

IsValidTarget(ICharacter)

Returns true when a candidate is a legal target: present, active, and alive.

public static bool IsValidTarget(ICharacter candidate)

Parameters

candidate ICharacter

The candidate to test.

Returns

bool

True if the candidate can be attacked.

PickNearest(List<ICharacter>, Vector3)

Picks the living candidate physically closest to a position.

public static ICharacter PickNearest(List<ICharacter> candidates, Vector3 origin)

Parameters

candidates List<ICharacter>

Candidates to choose from.

origin Vector3

The position to measure from.

Returns

ICharacter

The nearest valid candidate, or null when none are valid.

PickRandom(List<ICharacter>, DeterministicRNG)

Picks a uniformly random living candidate using the NPC's seeded RNG.

public static ICharacter PickRandom(List<ICharacter> candidates, DeterministicRNG rng)

Parameters

candidates List<ICharacter>

Candidates to choose from.

rng DeterministicRNG

The NPC's deterministic RNG. Falls back to the shared RNG when null.

Returns

ICharacter

A random valid candidate, or null when none are valid.

PickWeakest(List<ICharacter>)

Picks the living candidate with the lowest health fraction.

public static ICharacter PickWeakest(List<ICharacter> candidates)

Parameters

candidates List<ICharacter>

Candidates to choose from.

Returns

ICharacter

The most wounded valid candidate, or null when none are valid.