Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wilson looks at targets through cameras #283

Open
wants to merge 1 commit into
base: ez2/mapbase
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions sp/src/game/server/ai_baseactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,10 @@ void CAI_BaseActor::UpdateHeadControl( const Vector &vHeadTarget, float flHeadIn
ConcatTransforms( worldToForward, targetXform, headXform );
MatrixAngles( headXform, vTargetAngles );

#ifdef EZ2
HeadAngleOverride( vTargetAngles );
#endif

#ifdef MAPBASE
// This is here to cover an edge case where pose parameters set to NaN invalidate the model.
if (!vTargetAngles.IsValid())
Expand Down Expand Up @@ -1273,6 +1277,16 @@ bool CAI_BaseActor::HasActiveLookTargets( void )
return m_lookQueue.Count() != 0;
}

#ifdef EZ2
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CAI_BaseActor::HasActiveRandomLookTargets( void )
{
return m_randomLookQueue.Count() != 0;
}
#endif

//-----------------------------------------------------------------------------
// Purpose: Clear any active look targets for the specified entity
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1755,6 +1769,12 @@ void CAI_BaseActor::MaintainLookTargets( float flInterval )
dir = HeadDirection3D();
}
}
#ifdef EZ2
else if ( HeadTargetPosOverride( active[i]->GetPosition(), dir, flDist ) )
{
flInterest = flInterest * HeadTargetValidity( active[i]->GetPosition() );
}
#endif
else
{
dir = active[i]->GetPosition() - vEyePosition;
Expand Down
8 changes: 8 additions & 0 deletions sp/src/game/server/ai_baseactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class CAI_BaseActor : public CAI_ExpresserHost<CAI_BaseHumanoid>
virtual bool PickRandomLookTarget( AILookTargetArgs_t *pArgs );
virtual void MakeRandomLookTarget( AILookTargetArgs_t *pArgs, float minTime, float maxTime );
virtual bool HasActiveLookTargets( void );
#ifdef EZ2
virtual bool HasActiveRandomLookTargets( void );
#endif
virtual void OnSelectedLookTarget( AILookTargetArgs_t *pArgs ) { return; }
virtual void ClearLookTarget( CBaseEntity *pTarget );
virtual void ExpireCurrentRandomLookTarget() { m_flNextRandomLookTime = gpGlobals->curtime - 0.1f; }
Expand All @@ -153,6 +156,11 @@ class CAI_BaseActor : public CAI_ExpresserHost<CAI_BaseHumanoid>
virtual bool ValidEyeTarget(const Vector &lookTargetPos);
virtual bool ValidHeadTarget(const Vector &lookTargetPos);
virtual float HeadTargetValidity(const Vector &lookTargetPos);
#ifdef EZ2
// Used by Wilson for looking from cameras
virtual bool HeadTargetPosOverride( const Vector &vecTargetPos, Vector &vecDir, float &flDist ) { return false; }
virtual bool HeadAngleOverride( QAngle &vTargetAngles ) { return false; }
#endif

virtual bool ShouldBruteForceFailedNav() { return true; }

Expand Down
14 changes: 13 additions & 1 deletion sp/src/game/server/ai_playerally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,17 @@ void CAI_PlayerAlly::GatherConditions( void )
{

bool bPlayerIsLooking = false;
#ifdef EZ2
if ( ( pLocalPlayer->GetAbsOrigin() - GetAbsOriginForSpeech( pLocalPlayer ) ).Length2DSqr() < Square(TALKER_STARE_DIST) )
#else
if ( ( pLocalPlayer->GetAbsOrigin() - GetAbsOrigin() ).Length2DSqr() < Square(TALKER_STARE_DIST) )
#endif
{
#ifdef EZ2
if ( pLocalPlayer->FInViewCone( GetEyePositionForSpeech( pLocalPlayer ) ) )
#else
if ( pLocalPlayer->FInViewCone( EyePosition() ) )
#endif
{
if ( pLocalPlayer->GetSmoothedVelocity().LengthSqr() < Square( 100 ) )
bPlayerIsLooking = true;
Expand Down Expand Up @@ -781,7 +789,7 @@ bool CAI_PlayerAlly::SelectAlertSpeech( AISpeechSelection_t *pSelection )
// NPCs can comment on smells in EZ2
if ( pSmellTarget && HasCondition( COND_SMELL ) && GetBestScent() && GetExpresser() && GetExpresser()->CanSpeakConcept( TLK_SMELL ) )
{
if( SelectSpeechResponse( TLK_SMELL, UTIL_VarArgs("distancetosmell:%f", GetAbsOrigin().DistTo( GetBestScent()->GetSoundReactOrigin() ) ), pSmellTarget, pSelection ) )
if( SelectSpeechResponse( TLK_SMELL, UTIL_VarArgs("distancetosmell:%f", GetAbsOriginForSpeech( pSmellTarget ).DistTo( GetBestScent()->GetSoundReactOrigin() ) ), pSmellTarget, pSelection ) )
return true;
}
#endif
Expand Down Expand Up @@ -1405,7 +1413,11 @@ void CAI_PlayerAlly::OnEnemyRangeAttackedMe( CBaseEntity *pEnemy, const Vector &
AI_CriteriaSet modifiers;
ModifyOrAppendEnemyCriteria( modifiers, pEnemy );

#ifdef EZ2
Vector vecEntDir = (pEnemy->EyePosition() - GetEyePositionForSpeech(pEnemy));
#else
Vector vecEntDir = (pEnemy->EyePosition() - EyePosition());
#endif
float flDot = DotProduct( vecEntDir.Normalized(), vecDir );
modifiers.AppendCriteria( "shot_dot", CNumStr( flDot ) );

Expand Down
3 changes: 3 additions & 0 deletions sp/src/game/server/ai_playerally.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ class CAI_PlayerAlly : public CAI_BaseActor
#ifdef EZ2
// Used by Wilson camera targets
virtual const Vector &GetSpeechTargetSearchOrigin() { return GetAbsOrigin(); }
virtual const Vector GetEyePositionForSpeech( CBaseEntity *pSpeechTarget ) { return EyePosition(); }
virtual const Vector &GetWorldSpaceCenterForSpeech( CBaseEntity *pSpeechTarget ) { return WorldSpaceCenter(); }
virtual const Vector &GetAbsOriginForSpeech( CBaseEntity *pSpeechTarget ) { return GetAbsOrigin(); }
#endif

CBaseEntity *GetSpeechTarget() { return m_hTalkTarget.Get(); }
Expand Down
Loading
Loading