-
Notifications
You must be signed in to change notification settings - Fork 1
KAIMoveParams
This is a struct that can serve two purposes:
- Passing optional detailed movement parameters for custom chase functions, without needing to add a dozen more parameters to said functions.
- This is both for KAI_MoveTowards() and KAI_MoveAway().
- Making KAI_MoveAway() use its' corner checking and obstacle avoidance features, along with configuring said features. Both for 2D and 3D movement.
Note: If you're confused, here's a rule of thumb. If the variables in the first two categories are named identically to ones in KAI_MoveTowards() and/or KAI_MoveAway(), use them to pass parameters to those two. The variables the struct contains are split in three categories:
Variables used to pass more detailed movement logic for custom chase functions, particularly for moving towards an actor or position. (Passed to KAI_MoveTowards() calls)
Type: Vector3
The position for the actor to move to. Also used if this struct is used to pass parameters to KAI_MoveAway(), to make it move away from a position instead of actor.
Type: Double
A multiplier for how many steps the caller can take around an obstacle before heading straight to the TargetPos again.
Type: Double
How much the actor can turn per step to face the position it's moving to.
Type: Double
Works the same as AngleLimit but vertically, for KMT_3D. Used by KAI_MoveAway() to pass a pitch turn rate for its' KAI_MoveTowards() calls.
Type: Int
The A_Chase() flags to pass to KAI_MoveTowards(). Used both for passing params with this struct to KAI_MoveTowards() and KAI_MoveAway().
Type: Int
The KAI_MoveTowards() flags to pass.
Ditto, but for moving AWAY. (Passed to KAI_MoveAway() calls)
Type: Pointer
The actor to move away from.
Type: Int
How many positions to try per next position to run away to picked. i.e at 32, it will generate 32 points around the actor to run from, and pick the furthest (From what the actor is running from) reachable point to go to
Type: Double
The radius around which to generate potential points to run away to.
Type: Int
How many steps to take towards the next position to run, before giving up and generating another position away from the actor/position to run to.
Type: Int
The KAI_MoveAway() flags to pass.
Type: Double
If this value isn't zero and it's passed to KMA alongside KMT_3D. It will check the floor and ceiling height from the actor. If only one is within range (i.e only the ceiling is close enough), the flyer will move there, if both the a ceiling and floor to hide behind are in range, the closest is picked to hide behind. This retreat parameter can be used to make the actor hide behind lowered ceilings or raised floors, provided their target actor or position can't see them from there. It can function as a cheaper alternative to the 3D corner check, or in conjunction with it, such as for having the latter check for any cover without 256MU of the actor, while KMAHidePlaneDist can check even further to see if the ceiling or floor are potential cover, without the expensive IsPosReachable3D calls of the corner check.
Variables used to specify to KAI_MoveAway() that it should use its' corner check and/or obstacle avoidance features, and how to do so.
Type: Double
How far away from the caller to check to their left and right for a corner to run behind.
Type: Int
How many checks should the left and right corner check be split by? For example, with a CornerDist of 128, if CornerDiv is 8, it will check every 8 map units to the left and right of the caller for a position that is not directly visible or reachable by whatever actor or position the caller is running from. And pick the closest check that returns true to run to.
The 3D corner check also works the same for each arbitrary clock slice.
Type: Int
This is an important parameter for the 3D corner check used if KMA has KMT_3D passed. Since the 3D check fires reachability checks in a clock-like pattern similar to KAI_AvoidObstacles(), this parameter determines how many to shoot out, for example if it's set to 16, the KMA call will fire one check every 22.5 degrees around the actor to find a potential corner to run behind.
Type: Double
How many map units in front of the caller to check for obstacles.
Type: Int
How many slices around the actor should the code check for obstacles? i.e when set to 16, it'll fire 16 checks in a 360 degree radius, every 22.5 degrees, and pick the first clear check (No obstacles hit) as the position to walk to.
Type: Int
Ditto, but the vertical slices used to produce a sphere of checks for obstacle avoidance on KMT_3D actors. This can be kept to 0 for a purely horizontal check.
Type: Double
How many map units far away the final position from KAI_AvoidObstacles3D() must be. If it's closer than this threshold, the function returns NaN. This threshold is needed because the function tends to return at least a little bit of noise (i.e even a full unblocked sphere of traces doesn't return an averaged position that's the actors' current position).
Type: Double
Multiplier for how far the averaged position of KAI_AvoidObstacles3D() is, to for example make the flyer do more extreme turns. Negative values make it linearly scale from 1 to whatever negative value you passed (The value is made positive) based on how close the average distance to obstacles is. Basically, it makes the magnitude increase the closer the actor is to any obstacles.
Type: Double
How fast KAI_MoveAway moves the calling KMT_3D actor away from the obstacles, if any, per call.
Type: Double
Used by the KMT_3D obstacle avoidance, if any trace fired is closer than this threshold, the function returns that there's no obstacle. This minimum distance can be used in KAI_MoveAway() to make the flyer not keep trying to push away from something that it's currently scaling, like if it bumps into a wall and starts climbing. 0 means that no trace is considered too close.
Here is an example of a _KAI_LandVehicleChase() call in a vehicles' See state. With detailed parameters passed to fine tune the movement.
KAIMoveParams Params;
Params.DetourFactor = 0.8;
Params.Attempts = 32;
Params.StepThreshold = 32;
Params.RunRad = 384;
KAI_LandVehicleChase ("Spawn",LVC_ATTACKWHENSCARED,turnradius:8,384,Params);- Home
- Features
- Classes
- Functions
- Guides