-
Notifications
You must be signed in to change notification settings - Fork 0
Chase functions
These are ZScript exports of different chunks of A_Chase's native C++ code, they are used as building blocks for custom chase functions like KAI_LandVehicleChase() so that they still support existing ZDoom features like patrol routes.
Some also include parameters to modify their behavior. And most of the exported functions have a Flags parameter, that can be used to pass A_Chase flags that are used by those functions. That parameter is mandatory for the functions that use it.
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2568-2572
- Returns true if the caller should be spooked.
Used by the stock attack decision code of ShouldAttack() as it is itself a rip of A_Chase code.
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2325-2376
- Flags: The A_Chase flags to use, this is mandatory, and for custom chase functions should pass the chase flags passed to said function.
- None
Runs as the code that A_Chase runs before it begins to handle moving and attacking. Should be called first before the other exported code !
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2401-2432
- Flags: The A_Chase flags to use, this is mandatory, and for custom chase functions should pass the chase flags passed to said function.
- Returns true if the caller found an enemy of the player to attack.
Used by friendly monsters to make them target whoever attacked the player they work for if they have nothing else to attack
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2433-2467
- Flags: The A_Chase flags to use, this is mandatory, and for custom chase functions should pass the chase flags passed to said function.
- FriendsIdle: Makes friendly monsters with no target to attack go to their Spawn or See state, instead of staying on their see state and calling KAI_Wander() like hostile monsters without the CHF_DONTIDLE flag do. Default is false. Useful for NPCs that should have custom idling behavior rather than just wandering with the stock parameters.
- Returns true if the caller finds a new target, false otherwise.
Handles changing the NPCs' target if it has none left, and going to its' idle state or staying in See and calling KAI_Wander() if it can't find a new target. This function is pretty important for custom chase functions, so if you are making one, you should definitely add this in.
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2486-2535
- WaitState: The state the NPC should go to when it reaches a delayed patrol point. Default is null, which means it should just call SetIdle() to find a state to wait to.
- DetourFactor, AngleLimit, ChaseFlags, Flags: Parameters passed to KAI_MoveTowards() while the NPC is heading towards the next goal point.
- Returns a boolean that is true if the function switched to the next patrol point in a route. False otherwise.
- Returns a second boolean that is true if the NPC has a goal that it took one steps towards with KAI_MoveTowards. Basically returning if the function made the NPC move to a goal or not.
Runs the code that handles making NPCs move from one patrol point to another, unlike the native patrol handling code, this code actually handles moving to the next patrol point as well. Meaning that this function could be used alone to make something like an on rails NPC, like some kind of train or traffic system.
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2669-2673
- Flags: The A_Chase flags to use, this is mandatory, and for custom chase functions should pass the chase flags passed to said function.
- Frequency: How often the active sound will decide to play.
- Returns true if the actor played its' [[ActiveSound|https://zdoom.org/wiki/Actor_properties#ActiveSound], false otherwise.
Handles randomly playing the NPCs' active sound.
Port of: https://sourcegraph.com/github.com/ZDoom/gzdoom/-/blob/src/playsim/p_enemy.cpp?L2537-2566
- StrafeTarget: The actor to strafe from.
- Flags: The A_Chase flags to use, this is mandatory, and for custom chase functions should pass the chase flags passed to said function.
- ForceStrafe: Should the actor strafe regardless of the strafe delay or strafe chance. Default is false.
- StrafeRange: How close to the StrafeTarget must the caller be to strafe ? Default is 64*10 (640) map units.
- None
Handles the strafing mechanic of CHF_FASTCHASE/Hexen's player bosses.
- Home
- Features
- Classes
- Functions
- Guides