Skip to content

KAI_Wander()

inkoalawetrust edited this page Jan 1, 2024 · 3 revisions

KAI_Wander ([Int Attempts = 24, Double RunRad = 256, Int MaxSteps = 72, Double DetourFactor = 0.5, Double AngleLimit = 10, Int ChaseFlags = 0, Int Flags = 0])

Parameters:

  • Attempts: How many positions to try per next position picked. Default is 24.
  • RunRad: The radius around which to find a viable position to go to. Default is 256 map units.
  • MaxSteps: How many steps the actor is allowed to take before having to find a new position to move to. Default is 72.
  • DetourFactor, AngleLimit, ChaseFlags, Flags: These parameters work the same as in KAI_MoveTowards(). However the DetourFactor is halved.

Return type(s):

  • None

Function:

Makes the NPC pick random positions around RunRad for them to head to, wandering aimlessly looking for a fight. Basically a more sophisticated and organic acting A_Wander.

Actors reach the position they are supposed to go to once they are within MeleeRange of it, similar to ZDoom patrol points.

Like A_Wander() it also handles making friendly monsters follow players instead of wandering, unless +DONTFOLLOWPLAYERS is on.

Example

This stupid Pinky just pointlessly wanders around.

Class WanderingPinky : KAI_Actor Replaces Demon
{
	Default
	{
		Health 150;
		PainChance 180;
		Speed 10;
		Radius 30;
		Height 56;
		Mass 400;
		Monster;
		+FLOORCLIP
		SeeSound "demon/sight";
		AttackSound "demon/melee";
		PainSound "demon/pain";
		DeathSound "demon/death";
		ActiveSound "demon/active";
		Obituary "$OB_DEMONHIT";
		Tag "$FN_DEMON";
	}
	
	States
	{
		Spawn:
			SARG AABBCCDD 2 Fast KAI_Wander();
			Loop;
		}
}

See also

Clone this wiki locally