View Issue Details

IDProjectCategoryView StatusLast Update
0002851The Dark ModAIpublic07.09.2011 19:37
Reportertels Assigned Totels  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product VersionTDM 1.06 
Target VersionTDM 1.07Fixed in VersionTDM 1.07 
Summary0002851: Remove AlertAI() and GetAlertEntity()
DescriptionThese two functions have, according to comments, nothing to do with TDM AI, so they serve no longer any purpose, and just confuse us. And they aren't use anywhere, either.

The following members can also be removed:

* lastAIAlertTime
* lastAIAlertEntity
TagsNo tags attached.
Attached Files
alert_ai_patch.txt (6,145 bytes)   
Index: game/game_local.h
===================================================================
--- game/game_local.h	(revision 4964)
+++ game/game_local.h	(working copy)
@@ -9,22 +9,7 @@
  ***************************************************************************/
 
 // Copyright (C) 2004 Id Software, Inc.
-//
 
-/** DarkMod AI Note:
-* The following members in class idGameLocal:
-* lastAIAlertEntity, lastAIAlertTime and idGameLocal::AlertAI
-* ALL have nothing to do with DarkMod AI.
-*
-* DarkMod AI alerts are handled in class idAI
-*
-* AIAlertEntity alerts ALL AI to the entity in vanilla D3
-*
-* Unfortunately idGameLocal::AlertAI has the same name as
-* our DarkMod alert function, idAI::AlertAI.  DarkMod
-* alerts do not directly make use of idGameLocal::AlertAI.
-**/
-
 #ifndef __GAME_LOCAL_H__
 #define	__GAME_LOCAL_H__
 
@@ -786,12 +771,6 @@
 
 	bool					RequirementMet( idEntity *activator, const idStr &requires, int removeItem );
 
-/**
-* The following are vanilla D3 functions that have nothing to do with TDM's AI alert system
-**/
-	void					AlertAI( idEntity *ent );
-	idActor *				GetAlertEntity( void );
-
 	bool					InPlayerPVS( idEntity *ent ) const;
 	bool					InPlayerConnectedArea( idEntity *ent ) const;
 
@@ -988,9 +967,6 @@
 	idList<idAAS *>			aasList;				// area system
 	idStrList				aasNames;
 
-	idEntityPtr<idActor>	lastAIAlertEntity;
-	int						lastAIAlertTime;
-
 	idDict					spawnArgs;				// spawn args used during entity spawning  FIXME: shouldn't be necessary anymore
 
 	pvsHandle_t				playerPVS;				// merged pvs of all players
Index: game/game_local.cpp
===================================================================
--- game/game_local.cpp	(revision 4964)
+++ game/game_local.cpp	(working copy)
@@ -358,8 +358,6 @@
 	camera = NULL;
 	aasList.Clear();
 	aasNames.Clear();
-	lastAIAlertEntity = NULL;
-	lastAIAlertTime = 0;
 	spawnArgs.Clear();
 	gravity.Set( 0, 0, -1 );
 	playerPVS.h = (unsigned int)-1;
@@ -987,9 +985,6 @@
 
 	savegame.WriteMaterial( globalMaterial );
 
-	lastAIAlertEntity.Save( &savegame );
-	savegame.WriteInt( lastAIAlertTime );
-
 	savegame.WriteDict( &spawnArgs );
 
 	savegame.WriteInt( playerPVS.i );
@@ -1406,9 +1401,6 @@
 	testmodel		= NULL;
 	testFx			= NULL;
 
-	lastAIAlertEntity = NULL;
-	lastAIAlertTime = 0;
-	
 	previousTime	= 0;
 	time			= 0;
 	framenum		= 0;
@@ -2080,9 +2072,6 @@
 
 	savegame.ReadMaterial( globalMaterial );
 
-	lastAIAlertEntity.Restore( &savegame );
-	savegame.ReadInt( lastAIAlertTime );
-
 	savegame.ReadDict( &spawnArgs );
 
 	savegame.ReadInt( playerPVS.i );
@@ -5523,32 +5512,6 @@
 
 /*
 ============
-idGameLocal::AlertAI
-============
-*/
-void idGameLocal::AlertAI( idEntity *ent ) {
-	if ( ent && ent->IsType( idActor::Type ) ) {
-		// alert them for the next frame
-		lastAIAlertTime = time + msec;
-		lastAIAlertEntity = static_cast<idActor *>( ent );
-	}
-}
-
-/*
-============
-idGameLocal::GetAlertEntity
-============
-*/
-idActor *idGameLocal::GetAlertEntity( void ) {
-	if ( lastAIAlertTime >= time ) {
-		return lastAIAlertEntity.GetEntity();
-	}
-
-	return NULL;
-}
-
-/*
-============
 idGameLocal::RadiusDamage
 ============
 */
Index: game/ai/ai.cpp
===================================================================
--- game/ai/ai.cpp	(revision 4964)
+++ game/ai/ai.cpp	(working copy)
@@ -6009,11 +6009,6 @@
 	// end our looping ambient sound
 	StopSound( SND_CHANNEL_AMBIENT, false );
 
-	/* greebo: This is not needed anymore, I reckon.
-	if ( attacker && attacker->IsType( idActor::Type ) ) {
-		gameLocal.AlertAI( ( idActor * )attacker );
-	}*/
-
 	// activate targets
 	ActivateTargets( attacker );
 
@@ -6934,20 +6929,6 @@
 			// Enemy can't be seen (obscured or hidden in darkness)
 			gameRenderWorld->DebugArrow(colorRed, GetEyePosition(), GetEyePosition() + idVec3(0,0,10), 2, 100);
 		}
-
-		// check if we heard any sounds in the last frame
-		if (enemyEnt == gameLocal.GetAlertEntity())
-		{
-			float dist = (enemyEnt->GetPhysics()->GetOrigin() - org).LengthSqr();
-
-			if (dist < Square(AI_HEARING_RANGE))
-			{
-				// Enemy within hearing distance, update position
-				// greebo: TODO: This also updates lastVisibleReachableEnemyPos, is this ok?
-				enemyDetectable= true;
-
-			}
-		}
 	}
 
 	if (enemyDetectable)
Index: game/ai/ai_events.cpp
===================================================================
--- game/ai/ai_events.cpp	(revision 4964)
+++ game/ai/ai_events.cpp	(working copy)
@@ -41,7 +41,6 @@
 const idEventDef AI_FindEnemyAI( "findEnemyAI", "d", 'e' );
 const idEventDef AI_FindEnemyInCombatNodes( "findEnemyInCombatNodes", NULL, 'e' );
 const idEventDef AI_ClosestReachableEnemyOfEntity( "closestReachableEnemyOfEntity", "E", 'e' );
-const idEventDef AI_HeardSound( "heardSound", "d", 'e' );
 // greebo: TDM Event: Try to find a visible AI of the given team
 const idEventDef AI_FindFriendlyAI( "findFriendlyAI", "d", 'e' );
 const idEventDef AI_ProcessBlindStim( "processBlindStim", "ed" );
@@ -377,7 +376,6 @@
 	EVENT( AI_FindFriendlyAI,					idAI::Event_FindFriendlyAI )
 	EVENT( AI_ProcessBlindStim,					idAI::Event_ProcessBlindStim )
 	EVENT( AI_ProcessVisualStim,				idAI::Event_ProcessVisualStim )
-	EVENT( AI_HeardSound,						idAI::Event_HeardSound )
 	EVENT( AI_SetEnemy,							idAI::Event_SetEnemy )
 	EVENT( AI_ClearEnemy,						idAI::Event_ClearEnemy )
 	EVENT( AI_MuzzleFlash,						idAI::Event_MuzzleFlash )
@@ -757,42 +755,6 @@
 
 /*
 =====================
-idAI::Event_HeardSound
-=====================
-*/
-void idAI::Event_HeardSound( int ignore_team ) {
-
-	// check if we heard any sounds in the last frame
-
-	idActor	*actor = gameLocal.GetAlertEntity();
-
-	if ( actor && ( !ignore_team || ( ReactionTo( actor ) & ATTACK_ON_SIGHT ) ) && gameLocal.InPlayerPVS( this ) ) {
-
-		idVec3 pos = actor->GetPhysics()->GetOrigin();
-
-		idVec3 org = physicsObj.GetOrigin();
-
-		float dist = ( pos - org ).LengthSqr();
-
-		if ( dist < Square( AI_HEARING_RANGE ) ) {
-
-			idThread::ReturnEntity( actor );
-
-			return;
-
-		}
-
-	}
-
-
-
-	idThread::ReturnEntity( NULL );
-
-}
-
-
-/*
-=====================
 idAI::Event_SetEnemy
 =====================
 */
alert_ai_patch.txt (6,145 bytes)   

Activities

tels

tels

03.09.2011 10:59

reporter   ~0004014

The code that calls gamelocal.AlertAI() is commented out. So this never happens, and this means lastAIAlertEntity is never set.

That means that GetAlertEntity() will always return NULL.

And that in turn means the call to "heardSound()" (e.g. the script event) is never able to return anything at all.

So HeardSound() and Event_heardSound() should be removed, too.
tels

tels

03.09.2011 11:11

reporter   ~0004015

The attached patch takes out the code, variables and events. It needs to be accompanied by taking out "heardSound()" in script/doom_events.script.

I'd like to have someone with more AI experience to verify that:

* this is indeed no longer nec. (e.g. was the commentd out call to AlertAI() really commented out because it was not nec, or did this break something?)
* everything still works as intended in regards to AI hearing the player
tels

tels

07.09.2011 19:37

reporter   ~0004018

After discussing this with grayman and once more inspecting the code, it was removed with revision 0004965. If there are any (unlikely) odd side-effects, we can always re-include the code.

Issue History

Date Modified Username Field Change
02.09.2011 11:56 tels New Issue
02.09.2011 11:56 tels Assigned To => tels
03.09.2011 10:59 tels Note Added: 0004014
03.09.2011 11:10 tels File Added: alert_ai_patch.txt
03.09.2011 11:11 tels Note Added: 0004015
03.09.2011 11:11 tels Status new => feedback
07.09.2011 19:36 tels Target Version => TDM 1.07
07.09.2011 19:37 tels Note Added: 0004018
07.09.2011 19:37 tels Status feedback => assigned
07.09.2011 19:37 tels Status assigned => resolved
07.09.2011 19:37 tels Fixed in Version => TDM 1.07
07.09.2011 19:37 tels Resolution open => fixed