NPC dynamic interaction improvements and fixes#270
Conversation
…w pose parameter to change animations based on angle)
| void SetInteractionCantDie( bool bCantDie ) { m_bCannotDieDuringInteraction = bCantDie; } | ||
| bool HasInteractionCantDie( void ); | ||
| bool HasValidInteractionsOnCurrentEnemy( void ); | ||
| virtual bool CanStartDynamicInteractionDuringMelee() { return false; } |
There was a problem hiding this comment.
Question: Is this ever overwritten and does it ever return true? Or is it more for future use?
There was a problem hiding this comment.
I had to use CanStartDynamicInteractionDuringMelee() for some E:Z2-specific changes and I decided to bring it here for general utility purposes in case other mods use custom dynamic interaction AI.
There may be some merit to overriding this function on Combine soldiers, which I did in E:Z2's case, but I'm going to leave that for a future update when I understand the effects and consequences of soldier interactions outside of E:Z2 better.
| pRagdoll->CollisionProp()->SetCollisionBounds( mins, maxs ); | ||
|
|
||
| #ifdef MAPBASE | ||
| // If this was a NPC running a dynamic interaction, disable collisions with the interaction partner |
There was a problem hiding this comment.
What about when the animation is complete? Would this make that NPC never collide with this ragdoll? Could that ever be an issue?
There was a problem hiding this comment.
The ragdoll will continue to have collisions disabled with the interaction partner, but I don't think it would be an issue. There is nothing which specifically relies on NPCs colliding with serverside ragdolls.
1upD
left a comment
There was a problem hiding this comment.
Looks good to me! I asked a few questions in comments because I want to understand this better, but I don't think any of them are changes that need to be addressed.
This PR adds several improvements and fixes for NPC dynamic interactions, especially for increasing the capabilities of custom ones.
Keyvalues
Dynamic interactions now support the following new keyvalues:
angles_max_diff— The maximum difference fromangles_relativerequired in order to perform the interaction. Previously, this was hardcoded as4, and that will be the default if this keyvalue is not specified.their_sequence,their_activity, etc. — Optional separate sequence or activity names to use on the target NPC, rather than using the same sequence or activity name as the triggering NPC. This allows for interactions between two NPCs which use the same model.related_interactions— Other interactions which should be delayed as well when this interaction runs. Separated by comma, but also supports wildcards.Better sequence movement handling
Dynamic interaction testing was not designed with sequence walkframe movement (i.e. sequences which literally move the NPC to another location) in mind. This was previously amended with the new
end_positionkeyvalue, but this is not always appropriate and is sometimes unnecessary when the sequence's end position can be calculated through movement. This also did not retroactively apply to existing interactions which may need end position testing.Now, if the
end_positionkeyvalue is not specified, dynamic interactions will directly test sequence movement before running. This will occur on all interactions with sequence movement, including existing ones, but only a small number of them actually have it. One set of interactions which does have it is the Combine Hunter's interactions with citizens, which sometimes result in the hunter being stuck in walls if there wasn't enough room at their end position. This change will fix that.The
end_positionkeyvalue is still functional and will override the sequence movement check. It can be used for sequences with different end positions which do not use sequence walkframe movement, or to prevent the sequence movement check from occurring.Specific NPC hacks
This PR integrates the following minor hacks for HL2 NPCs running dynamic interactions:
npc_combine_fixed_shootposcan be used to make this fix occur under all cases.I tried to separate most of these changes into separate commits to make them easier to understand, although the heavily specialized nature of this subject may make it difficult to do a thorough review.
PR Checklist
developbranch OR targets another branch with a specific goal in mind