-
Notifications
You must be signed in to change notification settings - Fork 0
KAI_LandVehicleChase()
inkoalawetrust edited this page Jul 29, 2023
·
7 revisions
KAI_LandVehicleChase ([Bool WaitState = Null, Int Flags = 0, ChaseFlags = 0, Double TurnRadius = 10, Double FollowDist = 384, MoveToParams Params = Null])
- WaitState: The state the vehicle should wait in if it stopped at a delayed patrol point. Default is Null, which means that it calls SetIdle().
- Flags:
- LVC_ATTACKWHENSCARED: Double the vehicles' aggression when it is scared. This is a bit of a leftover from when this functions' predecessor used A_Chase() with the +FRIGHTENED flag to make vehicles drive away. Because A_Chase() makes frightened actors a lot less likely to attack.
- LVC_NOTURRETRETARGET: The vehicle will not prefer targeting a vehicles' hull instead of its' turret, even if targeting the enemy vehicle directly would be easier.
- LVC_MAKEFRIENDSIDLE: Friendly vehicles will also call SetIdle() when they have no target, like hostile vehicles and monsters do.
- LVC_PLAYERASTHREATS: Also factor players when determining if the vehicle should drive away from powerful targets.
- LVC_USERETREATSTATE: Instead of calling KAI_MoveAway to run away. The function will jump straight to the vehicles' RetreatState.
- LVC_ZIGZAGGING: Enables the KMT_ZIGZAG flag in the functions' KAI_MoveTowards() calls. To not move the vehicles in straight lines.
- ChaseFlags: The A_Chase() flags to pass to the function, particularly to KAI_MoveTowards(). CHF_DONTMOVE in particular is useful for vehicle turrets, since it runs all the chase code except for the movement.
- TurnRadius: How many degrees can the vehicle turn with each call to the function. Default is 10.
- FollowDist: How close can a friendly vehicle get to its' friendplayer before it stops following them, to prevent dogpiling ? Default is 384 map units.
- Params: A reference to the MoveToParams struct to pass to the function, for fine tuning KAI_MoveTowards().
This is the chase function used by vehicles. It has the following unique features, in addition to most normal A_Chase behavior.
- Can drive away if its' target is +FRIGHTENING or it's +FRIGHTENED, like A_Chase() does. But will also drive away if its' target is above its' threat level threshold, keeping 4 times its' RetreatRange than with normal enemies. None of this occurs if the vehicle has +NOFEAR, or if it's patrolling and has bChaseGoal.
- Cam maintain FollowDist from the player it is allied to, if friendly.
- Stays away from all nearby enemies, allowing the vehicle to have an easier time attacking, and to also not charge head on to enemies like vanilla monsters. The distance it maintains is determined by RetreatRange.
- If the vehicle has a turret, and the turrets' current target is too high for the turret to shoot at it. Then the vehicle will begin to drive away from the turrets' target, to allow the turret to gun it down.
- If targeting an enemy vehicles' turret, it will target the actual enemy vehicle instead, if it would be more advantageous to do so.
- Can decide to stop and let its' turret fire, if it has one.
- Can only look for its' target for an amount of time defined by the SearchTime property.
- Supports ZDoom's patrol routes, friendly vehicles target whoever attacked their player, and Hexen boss strafing (If you want it for some reason).
The function can also have a reference passed to a MoveToParams struct, which passes detailed parameters to KAI_MoveTowards() and KAI_MoveAway(). Allowing you to fine tune how your vehicle moves exactly. The struct has the following passable parameters that KAI_LandVehicleChase() uses:
- RunRad: The radius around which the vehicle will try to find new points to move away to when calling KAI_MoveAway(). Default is 256.
- DetourFactor: The detour factor to use when calling KAI_MoveTowards(), this does not affect the detour factor of vehicles driving away. Default is 0.5 for driving away, and 1.0 for driving towards something.
- Attempts: How many random positions to check for the vehicle to drive away to when calling KAI_MoveAway(). Default is 32.
- StepThreshold: How many steps will the vehicle take when driving away to a certain position, before giving up and generating a new one. Default is 32. Note: AngleLimit is not passable through this struct, it's handled by TurnRadius instead.
Here is an example of a _KAI_LandVehicleChase() call in a vehicles' See state. With detailed parameters passed to fine tune the movement.
MoveToParams Params;
Params.DetourFactor = 0.8;
Params.Attempts = 32;
Params.StepThreshold = 32;
Params.RunRad = 384;
KAI_LandVehicleChase ("Spawn",LVC_ATTACKWHENSCARED,turnradius:8,384,Params);
And here is a more straightforward call to the function:
KAI_LandVehicleChase (chaseflags:CHF_DONTIDLE,followdist:256);
- Home
- Features
- Classes
- Functions
- Guides