mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-25 06:15:30 +03:00
Fix dynamic interaction problems caused by walkframe sequence movement
This commit is contained in:
parent
869ec6d0dd
commit
dc8fe6021d
@ -16142,6 +16142,7 @@ bool CAI_BaseNPC::InteractionCouldStart( CAI_BaseNPC *pOtherNPC, ScriptedNPCInte
|
||||
if ( bDebug )
|
||||
{
|
||||
NDebugOverlay::Box( vecPos, GetHullMins(), GetHullMaxs(), 255,0,0, 100, 1.0 );
|
||||
NDebugOverlay::HorzArrow( GetAbsOrigin(), vecPos, 16.0f, 255, 0, 0, 255, true, 1.0f );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -16149,7 +16150,39 @@ bool CAI_BaseNPC::InteractionCouldStart( CAI_BaseNPC *pOtherNPC, ScriptedNPCInte
|
||||
{
|
||||
//NDebugOverlay::Box( vecPos, GetHullMins(), GetHullMaxs(), 0,255,0, 100, 1.0 );
|
||||
|
||||
NDebugOverlay::Axis( vecPos, angAngles, 20, true, 10.0 );
|
||||
NDebugOverlay::Axis( vecPos, angAngles, 20, true, 1.0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Instead, make sure we fit into where the sequence movement ends at
|
||||
const char *pszSequence = GetScriptedNPCInteractionSequence( pInteraction, SNPCINT_SEQUENCE );
|
||||
int nSeq = LookupSequence( pszSequence );
|
||||
if ( pszSequence && nSeq != -1 )
|
||||
{
|
||||
Vector vecDeltaPos;
|
||||
QAngle angDeltaAngles;
|
||||
GetSequenceMovement( nSeq, 0.0f, 1.0f, vecDeltaPos, angDeltaAngles );
|
||||
if (!vecDeltaPos.IsZero())
|
||||
{
|
||||
QAngle angInteraction = GetAbsAngles();
|
||||
angInteraction[YAW] = m_flInteractionYaw;
|
||||
|
||||
Vector vecPos;
|
||||
VectorRotate( vecDeltaPos, angInteraction, vecPos );
|
||||
vecPos += GetAbsOrigin();
|
||||
|
||||
AI_TraceHull( vecPos, vecPos, GetHullMins(), GetHullMaxs(), MASK_SOLID, &traceFilter, &tr);
|
||||
if ( tr.fraction != 1.0 )
|
||||
{
|
||||
if ( bDebug )
|
||||
{
|
||||
NDebugOverlay::Box( vecPos, GetHullMins(), GetHullMaxs(), 255,0,0, 100, 1.0 );
|
||||
NDebugOverlay::HorzArrow( GetAbsOrigin(), vecPos, 16.0f, 255, 0, 0, 255, true, 1.0f );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1396,11 +1396,31 @@ void CAI_ScriptedSequence::ModifyScriptedAutoMovement( Vector *vecNewPos )
|
||||
}
|
||||
}
|
||||
|
||||
VMatrix matInteractionPosition = m_matInteractionPosition;
|
||||
|
||||
#ifdef MAPBASE
|
||||
// Account for our own sequence movement
|
||||
pAnimating = m_hTargetEnt->GetBaseAnimating();
|
||||
if (pAnimating)
|
||||
{
|
||||
Vector vecDeltaPos;
|
||||
QAngle angDeltaAngles;
|
||||
|
||||
pAnimating->GetSequenceMovement( pAnimating->GetSequence(), 0.0f, pAnimating->GetCycle(), vecDeltaPos, angDeltaAngles );
|
||||
if (!vecDeltaPos.IsZero())
|
||||
{
|
||||
VMatrix matLocalMovement;
|
||||
matLocalMovement.SetupMatrixOrgAngles( vecDeltaPos, angDeltaAngles );
|
||||
MatrixMultiply( m_matInteractionPosition, matLocalMovement, matInteractionPosition );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// We've been asked to maintain a specific position relative to the other NPC
|
||||
// we're interacting with. Lerp towards the relative position.
|
||||
VMatrix matMeToWorld, matLocalToWorld;
|
||||
matMeToWorld.SetupMatrixOrgAngles( vecRelativeOrigin, angRelativeAngles );
|
||||
MatrixMultiply( matMeToWorld, m_matInteractionPosition, matLocalToWorld );
|
||||
MatrixMultiply( matMeToWorld, matInteractionPosition, matLocalToWorld );
|
||||
|
||||
// Get the desired NPC position in worldspace
|
||||
Vector vecOrigin;
|
||||
|
Loading…
Reference in New Issue
Block a user