Skip to content

Commit 71bab9d

Browse files
committed
add mp support to ai classes
1 parent 737f579 commit 71bab9d

File tree

6 files changed

+45
-8
lines changed

6 files changed

+45
-8
lines changed

src/game/server/ai_hint.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,13 @@ bool CAI_Hint::HintMatchesCriteria( CAI_BaseNPC *pNPC, const CHintCriteria &hint
13451345

13461346
if ( hintCriteria.HasFlag(bits_HINT_HAS_LOS_TO_PLAYER|bits_HAS_EYEPOSITION_LOS_TO_PLAYER) )
13471347
{
1348-
CBasePlayer *pPlayer = AI_GetSinglePlayer();
1348+
#ifdef BDSBASE
1349+
CBasePlayer* pPlayer = UTIL_GetNearestVisiblePlayer(this);
1350+
if (!pPlayer)
1351+
UTIL_GetNearestPlayer(GetAbsOrigin());
1352+
#else
1353+
CBasePlayer* pPlayer = AI_GetSinglePlayer();
1354+
#endif //BDSBASE
13491355

13501356
if( pPlayer != NULL )
13511357
{

src/game/server/ai_planesolver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ void CAI_PlaneSolver::GenerateObstacleNpcs( const AILocalMoveGoal_t &goal, float
351351
}
352352
}
353353

354-
CBaseEntity *pPlayer = UTIL_PlayerByIndex( 1 );
354+
#ifdef BDSBASE
355+
CBaseEntity* pPlayer = UTIL_GetNearestPlayer(m_pNpc->GetAbsOrigin());
356+
#else
357+
CBaseEntity* pPlayer = UTIL_PlayerByIndex(1);
358+
#endif //BDSBASE
355359
if ( pPlayer )
356360
{
357361
Vector mins, maxs;

src/game/server/ai_relationship.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ void CAI_Relationship::ApplyRelationship( CBaseEntity *pActivator, CBaseEntity *
191191

192192
// The player spawns slightly after the NPCs, meaning that if we don't wait, the
193193
// player will miss any relationships placed on them.
194-
if ( AI_IsSinglePlayer() && !UTIL_GetLocalPlayer() )
194+
#ifdef BDSBASE
195+
if (UTIL_GetLocalPlayer())
196+
#else
197+
if (AI_IsSinglePlayer() && !UTIL_GetLocalPlayer())
198+
#endif //BDSBASE
195199
{
196200
SetThink( &CAI_Relationship::ApplyRelationshipThink );
197201
SetNextThink( gpGlobals->curtime );

src/game/server/ai_scriptconditions.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,19 @@ void CAI_ScriptConditions::EvaluationThink()
474474
int iActorsDone = 0;
475475

476476
#ifdef HL2_DLL
477-
if( AI_GetSinglePlayer()->GetFlags() & FL_NOTARGET )
477+
#ifdef BDSBASE
478+
/* if( AI_GetSinglePlayer()->GetFlags() & FL_NOTARGET )
478479
{
479480
ScrCondDbgMsg( ("%s WARNING: Player is NOTARGET. This will affect all LOS conditiosn involving the player!\n", GetDebugName()) );
481+
}*/
482+
#else
483+
if (AI_GetSinglePlayer()->GetFlags() & FL_NOTARGET)
484+
{
485+
ScrCondDbgMsg(("%s WARNING: Player is NOTARGET. This will affect all LOS conditiosn involving the player!\n", GetDebugName()));
480486
}
487+
#endif //BDSBASE
481488
#endif
482489

483-
484490
for ( int i = 0; i < m_ElementList.Count(); )
485491
{
486492
CAI_ScriptConditionsElement *pConditionElement = &m_ElementList[i];

src/game/server/ai_speech.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@ bool CAI_Expresser::SpeakFindResponse( AI_Response &outResponse, AIConcept_t con
313313
// Append local player criteria to set, but not if this is a player doing the talking
314314
if ( !GetOuter()->IsPlayer() )
315315
{
316-
CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
316+
#ifdef BDSBASE
317+
CBasePlayer* pPlayer = UTIL_GetNearestPlayer(GetOuter()->GetAbsOrigin());
318+
#else
319+
CBasePlayer* pPlayer = UTIL_PlayerByIndex(1);
320+
#endif //BDSBASE
317321
if( pPlayer )
318322
pPlayer->ModifyOrAppendPlayerCriteria( set );
319323
}
@@ -879,7 +883,11 @@ void CAI_ExpresserHost_NPC_DoModifyOrAppendCriteria( CAI_BaseNPC *pSpeaker, AI_C
879883
set.AppendCriteria( "weapon", "none" );
880884
}
881885

882-
CBasePlayer *pPlayer = AI_GetSinglePlayer();
886+
#ifdef BDSBASE
887+
CBasePlayer* pPlayer = UTIL_GetNearestPlayer(pSpeaker->GetAbsOrigin());
888+
#else
889+
CBasePlayer* pPlayer = AI_GetSinglePlayer();
890+
#endif //BDSBASE
883891
if ( pPlayer )
884892
{
885893
Vector distance = pPlayer->GetAbsOrigin() - pSpeaker->GetAbsOrigin();

src/game/server/ai_utils.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@
2323

2424
inline CBasePlayer *AI_GetSinglePlayer()
2525
{
26-
if ( gpGlobals->maxClients > 1 )
26+
#ifdef BDSBASE
27+
/*
28+
if ( gpGlobals->maxClients > 1 )
29+
{
30+
return NULL;
31+
}
32+
*/
33+
#else
34+
if (gpGlobals->maxClients > 1)
2735
{
2836
return NULL;
2937
}
38+
#endif //BDSBASE
3039

3140
return UTIL_GetLocalPlayer();
3241
}

0 commit comments

Comments
 (0)