feat(ai): per-NPC npc:set_movement_hold movement lever - #645
Merged
Merged
Conversation
Per-object bool on CAI_Stalker. While set, parse_velocity_mask takes its existing Stand branch, so the engine mover cannot start the NPC and the path survives for resume. Default false keeps vanilla byte-identical. The engine computes no condition. The caller decides when to hold and owns clearing the flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
npc:set_movement_hold(bool)on CAI_Stalker. While true,parse_velocity_masktakes its existing Stand branch: speed 0, movement type Stand, path and destination preserved. Movement resumes when the flag clears. Default false. When unset the change is one bool read added to the existing Stand condition, behavior stays vanilla. The engine computes no condition, the caller decides when to hold.Use case
A standing NPC hit mid reaction gets started running by the combat planner while the hit animation still owns the legs. The body slides with no walk cycle. Scripts can read the reaction (
is_hit_anim_playingfrom #629,critically_wounded) but cannot stop the mover, that path is C++. With this bind a script holds the NPC while the reaction plays and releases after. The slide is gone and the NPC resumes its route. It also covers any scripted plant-in-place that today needs a smart cover or an animation override.Constraint
The flag persists while the object is online and has no decay. The caller owns clearing it, a stale true holds the NPC until cleared. Not serialized, a reconstructed object comes back false.
Files changed
ai_stalker.h/ai_stalker.cpp/ai_stalker_inline.h:m_movement_holdbool, ctor init false, accessors (17 lines)script_game_object.h/script_game_object_inventory_owner.cpp/script_game_object_script3.cpp: the bind, stalker cast with error log,.defnext toset_vision_speed(15 lines)stalker_movement_manager_base.cpp: one line in theparse_velocity_maskStand conditionlua_help_ex.script: manifest entry8 files, 33 insertions, 1 deletion.
Lua usage
Testing
Local DX11 build from this branch, 0 errors. Field session on a full GAMMA install with a live consumer wiring the condition above onto a 200ms monitor plus the hit callback: