View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0004326 | The Dark Mod | AI | public | 25.05.2016 18:48 | 21.11.2026 18:06 |
| Reporter | grayman | Assigned To | Dragofer | ||
| Priority | normal | Severity | normal | Reproducibility | random |
| Status | feedback | Resolution | open | ||
| Product Version | TDM 2.04 | ||||
| Target Version | TDM 2.15 | ||||
| Summary | 0004326: Searching AI problem in Awaiting the Storm | ||||
| Description | AI have a difficult time on the second floor of Awaiting the Storm, while searching for and attacking the player in tight quarters. | ||||
| Steps To Reproduce | Use the attached savegames, or if they no longer work when 2.04 is released, recreate the scene by running through AtS and gathering up 2 or more guards to chase you to the 2nd floor dining room. | ||||
| Tags | search | ||||
| Attached Files | |||||
|
First reported here: http://forums.thedarkmod.com/topic/18074-beta-testing-204/page-4#entry389531 |
|
| Removing target release version. Will target to 2.07 when that shows up on the list of revs. | |
|
In my set of sources, this one might have some work I've already done on this: Y:/TDM/TDMSource/darkmod_src_2.04_4326 |
|
| 2.08? | |
|
I tested this in 2.07 beta, and it looks much better than I remember it back when this issue was filed. I did some work in 2.07 in the area of chasing/throwing, so maybe that had a positive effect here. 3 guards chasing me around while I was up on the tables. They were either chasing or swatting me with swords or throwing rocks. No treadmilling at any time. I ran back and forth to several tables, so I covered a fair amount of space. If a couple other people can check it, and it looks okay, I would just close it as fixed in 2.07. If problems persist, move it to 2.08. |
|
| Thanks for the confirmations. In feedback until more beta testing data comes back. I'll double check too. | |
|
Hmm... I'm seeing pretty much the 2.04 behavior here. Coordinates where I stopped and allowed AI to chase me: -641.01 -707.5 276.25 : 12.1 -2.29 0 |
|
| Removing myself as "Assigned To" because I doubt I will ever have time to work on it. | |
|
A big fix patch attached prevents AI from pathing into narrow areas and thus get stuck prevents AI from constantly trying to reach the player and get tangled with other AI keeps the AI from getting stuck after settling on the "unreachable state" even though the player has now moved and reachable the first AI to identify the player as unreachable tells the other AI ai_unreachable_fix.patch (20,814 bytes)
Index: AIComm_Message.h
===================================================================
--- AIComm_Message.h (revision 11370)
+++ AIComm_Message.h (working copy)
@@ -178,6 +178,8 @@
RaiseTheAlarm_CorpseHasBeenSeen_CommType,
RaiseTheAlarm_UnconsciousPersonHasBeenSeen_CommType,
+ EnemyUnreachable_CommType,
+
NumCommTypes, // invalid type
};
Index: ai/AI.cpp
===================================================================
--- ai/AI.cpp (revision 11370)
+++ ai/AI.cpp (working copy)
@@ -7985,6 +7985,18 @@
}
}
+ // The chase watchdog found out that the AI cannot get to the enemy there, although AAS says he is reachable
+ // (narrow passage, obstruction unknown to AAS). Trust the experience over AAS, otherwise the AI leaves the
+ // unreachable-target state at once and starts walking against the obstruction again.
+ if ( enemyReachable && onGround && GetMemory().IsEnemyMarkedUnreachable( enemyPos ) )
+ {
+ enemyReachable = false;
+ if ( move.moveCommand == MOVE_TO_ENEMY )
+ {
+ AI_DEST_UNREACHABLE = true;
+ }
+ }
+
AI_ENEMY_IN_FOV = false;
AI_ENEMY_VISIBLE = false;
AI_ENEMY_TACTILE = false;
Index: ai/Memory.cpp
===================================================================
--- ai/Memory.cpp (revision 11370)
+++ ai/Memory.cpp (working copy)
@@ -81,6 +81,8 @@
lastEnemyPos(0,0,0),
canHitEnemy(false),
willBeAbleToHitEnemy(false),
+ unreachableEnemyPos(0,0,0),
+ unreachableEnemyUntil(0),
canBeHitByEnemy(false),
currentSearchSpot(0,0,0),
hidingSpotTestStarted(false),
@@ -187,6 +189,8 @@
savefile->WriteVec3(lastEnemyPos);
savefile->WriteBool(canHitEnemy);
savefile->WriteBool(willBeAbleToHitEnemy);
+ savefile->WriteVec3(unreachableEnemyPos);
+ savefile->WriteInt(unreachableEnemyUntil);
savefile->WriteBool(canBeHitByEnemy);
savefile->WriteVec3(currentSearchSpot);
savefile->WriteBool(hidingSpotTestStarted);
@@ -263,6 +267,28 @@
savefile->WriteBool(issueMoveToPositionTask); // grayman #3052
}
+// the mark is valid this long, and is refreshed while the AI stays in the unreachable-target state
+static const int ENEMY_UNREACHABLE_MARK_TIME = 6000;
+// the enemy must be within this distance of the marked position for the mark to apply
+static const float ENEMY_UNREACHABLE_MARK_RADIUS = 96.0f;
+
+void Memory::MarkEnemyUnreachable(const idVec3& enemyPos)
+{
+ unreachableEnemyPos = enemyPos;
+ unreachableEnemyUntil = gameLocal.time + ENEMY_UNREACHABLE_MARK_TIME;
+}
+
+bool Memory::IsEnemyMarkedUnreachable(const idVec3& enemyPos) const
+{
+ return unreachableEnemyUntil > gameLocal.time
+ && (enemyPos - unreachableEnemyPos).LengthSqr() < ENEMY_UNREACHABLE_MARK_RADIUS * ENEMY_UNREACHABLE_MARK_RADIUS;
+}
+
+void Memory::RefreshEnemyUnreachable()
+{
+ unreachableEnemyUntil = gameLocal.time + ENEMY_UNREACHABLE_MARK_TIME;
+}
+
void Memory::Restore(idRestoreGame* savefile)
{
savefile->ReadObject(reinterpret_cast<idClass*&>(owner));
@@ -337,6 +363,8 @@
savefile->ReadVec3(lastEnemyPos);
savefile->ReadBool(canHitEnemy);
savefile->ReadBool(willBeAbleToHitEnemy);
+ savefile->ReadVec3(unreachableEnemyPos);
+ savefile->ReadInt(unreachableEnemyUntil);
savefile->ReadBool(canBeHitByEnemy);
savefile->ReadVec3(currentSearchSpot);
savefile->ReadBool(hidingSpotTestStarted);
Index: ai/Memory.h
===================================================================
--- ai/Memory.h (revision 11370)
+++ ai/Memory.h (working copy)
@@ -440,6 +440,15 @@
// If the AI checks this, the CanHitEnemy query sets it as well as canHitEnemy
bool willBeAbleToHitEnemy;
+ // Chase watchdog: the AI walked toward the enemy but made no progress, although AAS claims the enemy is reachable
+ // (narrow passage, obstruction which AAS does not know about, ...). While the enemy stays around this position
+ // it is treated as unreachable, so that the AI stops treadmilling and uses its unreachable-target behavior (throwing objects etc.).
+ idVec3 unreachableEnemyPos;
+ int unreachableEnemyUntil; // game time, 0 = no mark
+ void MarkEnemyUnreachable(const idVec3& enemyPos);
+ bool IsEnemyMarkedUnreachable(const idVec3& enemyPos) const;
+ void RefreshEnemyUnreachable();
+
/**
* When true, an enemy can potentially hit us with a melee attack in the near future
**/
Index: ai/States/UnreachableTargetState.cpp
===================================================================
--- ai/States/UnreachableTargetState.cpp (revision 11370)
+++ ai/States/UnreachableTargetState.cpp (working copy)
@@ -105,8 +105,21 @@
{
bark = "snd_cantReachTarget";
}
- owner->commSubsystem->AddCommTask(CommunicationTaskPtr(new SingleBarkTask(bark, message)));
+ SingleBarkTaskPtr barkTask(new SingleBarkTask(bark, message));
+ CommMessagePtr unreachableMessage(new CommMessage(
+ CommMessage::EnemyUnreachable_CommType,
+ owner,
+ NULL,
+ enemy,
+ memory.lastEnemyPos,
+ memory.currentSearchEventID
+ ));
+
+ barkTask->SetAdditionalMessage(unreachableMessage);
+
+ owner->commSubsystem->AddCommTask(CommunicationTaskPtr(barkTask));
+
if (cv_ai_debug_transition_barks.GetBool())
{
gameLocal.Printf("%d: %s can't reach the target, barks '%s'\n",gameLocal.time,owner->GetName(),bark.c_str());
@@ -179,9 +192,12 @@
}
else
{
- owner->movementSubsystem->PushTask(
- TaskPtr(new MoveToPositionTask(owner->lastVisibleReachableEnemyPos))
- );
+ if (!memory.IsEnemyMarkedUnreachable(enemy->GetPhysics()->GetOrigin()))
+ {
+ owner->movementSubsystem->PushTask(
+ TaskPtr(new MoveToPositionTask(owner->lastVisibleReachableEnemyPos))
+ );
+ }
// grayman #3507 - randomize wait time
_takeCoverTime = gameLocal.time + 2000 + gameLocal.random.RandomFloat()*2000; // wait 2-4 seconds
}
@@ -256,6 +272,15 @@
// grayman #3775 - test reachability before deciding to throw an object
+ // The chase watchdog marked the enemy as unreachable (AAS disagrees, but the AI could not get there).
+ // Keep the mark while the AI is in this state, so that it does not drop out again and walk against the obstruction.
+ const idVec3 enemyOrigin = enemy->GetPhysics()->GetOrigin();
+ bool markedUnreachable = memory.IsEnemyMarkedUnreachable(enemyOrigin);
+ if (markedUnreachable)
+ {
+ memory.RefreshEnemyUnreachable();
+ }
+
// This checks if the enemy is reachable again so we can go into combat state
if (owner->enemyReachable || owner->TestMelee() || memory.canHitEnemy)
{
@@ -271,9 +296,10 @@
// grayman #3507 - new way
// FindAttackPosition() handles both melee and ranged attacks
+ // (not while marked: it finds the same AAS positions at the mouth of the passage, which are no use)
idVec3 targetPoint;
- if (owner->FindAttackPosition(_reachEnemyCheck, enemy, targetPoint, COMBAT_NONE))
+ if (!markedUnreachable && owner->FindAttackPosition(_reachEnemyCheck, enemy, targetPoint, COMBAT_NONE))
{
owner->GetMind()->EndState();
return;
Index: ai/Tasks/ChaseEnemyTask.cpp
===================================================================
--- ai/Tasks/ChaseEnemyTask.cpp (revision 11370)
+++ ai/Tasks/ChaseEnemyTask.cpp (working copy)
@@ -29,10 +29,24 @@
namespace ai
{
-ChaseEnemyTask::ChaseEnemyTask()
+ChaseEnemyTask::ChaseEnemyTask() :
+ _reachEnemyCheck(0),
+ _progressOrigin(0,0,0),
+ _progressTime(-1),
+ _stagingOrigin(0,0,0),
+ _hasStagingOrigin(false),
+ _retreating(false),
+ _retreatStartTime(-1)
{}
-ChaseEnemyTask::ChaseEnemyTask(idActor* enemy)
+ChaseEnemyTask::ChaseEnemyTask(idActor* enemy) :
+ _reachEnemyCheck(0),
+ _progressOrigin(0,0,0),
+ _progressTime(-1),
+ _stagingOrigin(0,0,0),
+ _hasStagingOrigin(false),
+ _retreating(false),
+ _retreatStartTime(-1)
{
_enemy = enemy;
}
@@ -56,10 +70,18 @@
}
_reachEnemyCheck = 0;
+ _progressTime = -1;
+ _hasStagingOrigin = false;
+ _retreating = false;
+ _retreatStartTime = -1;
owner->AI_RUN = true;
owner->MoveToPosition(owner->lastVisibleEnemyPos);
}
+
+static const float CHASE_STAGING_REACHED_DISTANCE = 32.0f;
+static const int CHASE_RETREAT_TIMEOUT = 8000;
+
bool ChaseEnemyTask::Perform(Subsystem& subsystem)
{
DM_LOG(LC_AI, LT_INFO)LOGSTRING("Chase Enemy Task performing.\r");
@@ -91,8 +113,66 @@
bool enemyUnreachable = false;
+ // Combat takes priority over retreating.
+ if (owner->m_bFlatFooted || memory.canHitEnemy)
+ {
+ _retreating = false;
+ _retreatStartTime = -1;
+ }
+
+ // If a retreat is already underway, do not issue another chase command.
+ if (_retreating)
+ {
+ const idVec3& origin = owner->GetPhysics()->GetOrigin();
+ const float distance = (origin - _stagingOrigin).LengthFast();
+ const moveStatus_t status = owner->GetMoveStatus();
+
+ if (distance <= CHASE_STAGING_REACHED_DISTANCE &&
+ status == MOVE_STATUS_DONE)
+ {
+ // The AI has actually returned to its staging position.
+ _retreating = false;
+ _retreatStartTime = -1;
+ _progressTime = -1;
+
+ memory.MarkEnemyUnreachable(enemy->GetPhysics()->GetOrigin());
+ owner->StopMove(MOVE_STATUS_DONE);
+ enemyUnreachable = true;
+ }
+ else if ((gameLocal.time - _retreatStartTime) > CHASE_RETREAT_TIMEOUT ||
+ (status != MOVE_STATUS_MOVING &&
+ status != MOVE_STATUS_WAITING &&
+ status != MOVE_STATUS_DONE))
+ {
+ // Retreat failed or took too long. Use the original fallback.
+ _retreating = false;
+ _retreatStartTime = -1;
+ _progressTime = -1;
+
+ memory.MarkEnemyUnreachable(enemy->GetPhysics()->GetOrigin());
+ owner->StopMove(MOVE_STATUS_DONE);
+ enemyUnreachable = true;
+ }
+ else if (status == MOVE_STATUS_DONE)
+ {
+ // Movement ended without reaching the requested staging position.
+ _retreating = false;
+ _retreatStartTime = -1;
+ _progressTime = -1;
+
+ memory.MarkEnemyUnreachable(enemy->GetPhysics()->GetOrigin());
+ owner->StopMove(MOVE_STATUS_DONE);
+ enemyUnreachable = true;
+ }
+ else
+ {
+ // Still moving or legitimately waiting.
+ return false;
+ }
+ }
+
// are we currently flat-footed?
- if ( owner->m_bFlatFooted )
+ if (!enemyUnreachable && owner->m_bFlatFooted)
{
_reachEnemyCheck = 0;
@@ -107,7 +187,7 @@
}
}
// Can we damage the enemy already? (this flag is set by the combat state)
- else if (memory.canHitEnemy)
+ else if (!enemyUnreachable && memory.canHitEnemy)
{
_reachEnemyCheck = 0;
@@ -117,13 +197,66 @@
// Turn to the player
owner->TurnToward(enemy->GetEyePosition());
}
+ // The enemy was already found to be out of reach (see the progress watchdog below), and he is still around there:
+ // AAS keeps saying that he is reachable, so don't start walking against the obstruction again.
+ else if (!enemyUnreachable && memory.IsEnemyMarkedUnreachable(enemy->GetPhysics()->GetOrigin()))
+ {
+ owner->StopMove(MOVE_STATUS_DONE);
+ enemyUnreachable = true;
+ }
// no, push the AI forward and try to get to the last visible reachable enemy position
- else if (owner->MoveToPosition(owner->lastVisibleReachableEnemyPos))
+ else if (!enemyUnreachable && owner->MoveToPosition(owner->lastVisibleReachableEnemyPos))
{
_reachEnemyCheck = 0;
- if (owner->GetMoveStatus() == MOVE_STATUS_DONE)
+ if (owner->GetMoveStatus() != MOVE_STATUS_DONE && HasNoProgress(owner))
{
+ bool retreatStarted = false;
+
+ if (_hasStagingOrigin)
+ {
+ // Try returning to the last validated staging position.
+ if (owner->MoveToPosition(_stagingOrigin))
+ {
+ moveStatus_t status = owner->GetMoveStatus();
+
+ if (status == MOVE_STATUS_MOVING ||
+ status == MOVE_STATUS_WAITING)
+ {
+ _retreating = true;
+ _retreatStartTime = gameLocal.time;
+ retreatStarted = true;
+ }
+ else if (status == MOVE_STATUS_DONE &&
+ (owner->GetPhysics()->GetOrigin() - _stagingOrigin).LengthFast()
+ <= CHASE_STAGING_REACHED_DISTANCE)
+ {
+ // The staging position was already reached.
+ memory.MarkEnemyUnreachable(enemy->GetPhysics()->GetOrigin());
+ owner->StopMove(MOVE_STATUS_DONE);
+ _progressTime = -1;
+ enemyUnreachable = true;
+ }
+ }
+ }
+
+ if (retreatStarted)
+ {
+ return false;
+ }
+
+ if (!enemyUnreachable)
+ {
+ // No usable staging position, or retreat could not be started.
+ memory.MarkEnemyUnreachable(enemy->GetPhysics()->GetOrigin());
+ owner->StopMove(MOVE_STATUS_DONE);
+ _progressTime = -1;
+ enemyUnreachable = true;
+ }
+ }
+ else if (owner->GetMoveStatus() == MOVE_STATUS_DONE)
+ {
+ _progressTime = -1;
// Position has been reached, turn to enemy, if visible
if (owner->AI_ENEMY_VISIBLE)
{
@@ -132,7 +265,7 @@
}
}
}
- else if (owner->AI_MOVE_DONE && !owner->m_HandlingDoor)
+ else if (!enemyUnreachable && owner->AI_MOVE_DONE && !owner->m_HandlingDoor)
{
// Enemy position itself is not reachable, try to find a position within melee range around the enemy
if (_reachEnemyCheck < 4)
@@ -194,7 +327,7 @@
enemyUnreachable = true;
}
}
- else
+ else if (!enemyUnreachable)
{
enemyUnreachable = true;
}
@@ -211,6 +344,115 @@
return false; // not finished yet
}
+// Distance behind the AI at which a staging position is sampled.
+static const float CHASE_STAGING_DISTANCE = 64.0f;
+// Maximum distance AAS may move a staging candidate when snapping it into an area.
+static const float CHASE_STAGING_MAX_SNAP = 16.0f;
+
+void ChaseEnemyTask::UpdateStagingPosition(idAI* owner)
+{
+ idAAS* aas = owner->GetAAS();
+
+ if (aas == NULL)
+ {
+ return;
+ }
+
+ const idVec3& origin = owner->GetPhysics()->GetOrigin();
+
+ // Determine the direction in which the AI has actually been travelling.
+ idVec3 direction = origin - _progressOrigin;
+
+ // This initial implementation assumes conventional vertical gravity.
+ direction.z = 0.0f;
+
+ if (direction.Normalize() < 0.1f)
+ {
+ return;
+ }
+
+ // Sample a position behind the AI, rather than using the watchdog origin itself.
+ idVec3 candidate = origin - direction * CHASE_STAGING_DISTANCE;
+
+ const idVec3 requestedCandidate = candidate;
+
+ const idBounds& bounds = owner->GetPhysics()->GetBounds();
+
+ int areaNum = aas->PointReachableAreaNum(candidate, bounds, 0);
+
+ if (areaNum <= 0)
+ {
+ return;
+ }
+
+ // Snap the candidate into its reachable AAS area.
+ aas->PushPointIntoAreaNum(areaNum, candidate);
+
+ // Reject candidates that had to be moved too far.
+ if ((candidate - requestedCandidate).LengthSqr() >
+ CHASE_STAGING_MAX_SNAP * CHASE_STAGING_MAX_SNAP)
+ {
+ return;
+ }
+
+ // Validate the snapped position again.
+ areaNum = aas->PointReachableAreaNum(candidate, bounds, 0);
+
+ if (areaNum <= 0)
+ {
+ return;
+ }
+
+ // Make sure the staging position is meaningfully behind the AI.
+ if ((candidate - origin).LengthFast() < 40.0f)
+ {
+ return;
+ }
+
+ _stagingOrigin = candidate;
+ _hasStagingOrigin = true;
+}
+
+// How long the AI may stay (nearly) in place while being told to chase.
+static const int CHASE_NO_PROGRESS_TIME = 2500;
+// The AI has made progress if it moved farther than this from the reference point
+static const float CHASE_PROGRESS_DISTANCE = 24.0f;
+
+bool ChaseEnemyTask::HasNoProgress(idAI* owner)
+{
+ // Legitimate reasons to stand still: waiting for a door, elevator, or somebody to pass.
+ if (owner->m_HandlingDoor || owner->m_HandlingElevator
+ || owner->movementSubsystem->IsWaiting()
+ || owner->movementSubsystem->GetBlockedState() == MovementSubsystem::EResolvingBlock
+ || !owner->AI_ENEMY_VISIBLE)
+ {
+ _progressTime = -1;
+ return false;
+ }
+
+ const idVec3& origin = owner->GetPhysics()->GetOrigin();
+
+ if (_progressTime < 0)
+ {
+ _progressOrigin = origin;
+ _progressTime = gameLocal.time;
+ return false;
+ }
+
+ if ((origin - _progressOrigin).LengthFast() > CHASE_PROGRESS_DISTANCE)
+ {
+ // The AI has moved. Record a candidate staging position behind it.
+ UpdateStagingPosition(owner);
+
+ _progressOrigin = origin;
+ _progressTime = gameLocal.time;
+
+ return false;
+ }
+
+ return (gameLocal.time - _progressTime) > CHASE_NO_PROGRESS_TIME;
+}
+
CMultiStateMoverPosition* ChaseEnemyTask::CanFetchElevator(CMultiStateMover* mover, idAI* owner)
{
if (!owner->CanUseElevators() || owner->GetAAS() == NULL)
@@ -253,7 +495,15 @@
void ChaseEnemyTask::SetEnemy(idActor* enemy)
{
- _enemy = enemy;
+ if (_enemy.GetEntity() != enemy)
+ {
+ _enemy = enemy;
+
+ _progressTime = -1;
+ _hasStagingOrigin = false;
+ _retreating = false;
+ _retreatStartTime = -1;
+ }
}
void ChaseEnemyTask::Save(idSaveGame* savefile) const
@@ -262,6 +512,12 @@
_enemy.Save(savefile);
savefile->WriteInt(_reachEnemyCheck);
+ savefile->WriteVec3(_progressOrigin);
+ savefile->WriteInt(_progressTime);
+ savefile->WriteVec3(_stagingOrigin);
+ savefile->WriteBool(_hasStagingOrigin);
+ savefile->WriteBool(_retreating);
+ savefile->WriteInt(_retreatStartTime);
}
void ChaseEnemyTask::Restore(idRestoreGame* savefile)
@@ -270,6 +526,12 @@
_enemy.Restore(savefile);
savefile->ReadInt(_reachEnemyCheck);
+ savefile->ReadVec3(_progressOrigin);
+ savefile->ReadInt(_progressTime);
+ savefile->ReadVec3(_stagingOrigin);
+ savefile->ReadBool(_hasStagingOrigin);
+ savefile->ReadBool(_retreating);
+ savefile->ReadInt(_retreatStartTime);
}
ChaseEnemyTaskPtr ChaseEnemyTask::CreateInstance()
Index: ai/Tasks/ChaseEnemyTask.h
===================================================================
--- ai/Tasks/ChaseEnemyTask.h (revision 11370)
+++ ai/Tasks/ChaseEnemyTask.h (working copy)
@@ -35,6 +35,19 @@
idEntityPtr<idActor> _enemy;
int _reachEnemyCheck;
+ // Progress watchdog: the AI keeps being told to walk to a position AAS says is reachable,
+ // but does not actually get anywhere (narrow passage, unknown obstruction).
+ idVec3 _progressOrigin; // where the AI was when the watchdog was last reset
+ int _progressTime; // when the watchdog was last reset, -1 = not started
+
+ // Last validated position behind the AI while it was making progress.
+ idVec3 _stagingOrigin;
+ bool _hasStagingOrigin;
+
+ // True while retreating to the saved staging position.
+ bool _retreating;
+ int _retreatStartTime;
+
// Private default constructor
ChaseEnemyTask();
public:
@@ -58,6 +71,8 @@
virtual void SetEnemy(idActor* enemy);
private:
+ bool HasNoProgress(idAI* owner);
+ void UpdateStagingPosition(idAI* owner);
CMultiStateMoverPosition* CanFetchElevator(CMultiStateMover* mover, idAI* owner);
};
Index: ai/Tasks/SingleBarkTask.cpp
===================================================================
--- ai/Tasks/SingleBarkTask.cpp (revision 11370)
+++ ai/Tasks/SingleBarkTask.cpp (working copy)
@@ -106,11 +106,21 @@
{
int msgTag = 0; // grayman #3355
// Push the message and play the sound
- if (_message != NULL)
+ if (_message != NULL || _additionalMessage != NULL)
{
- // Setup the message to be propagated, if we have one
- msgTag = gameLocal.GetNextMessageTag(); // grayman #3355
- owner->AddMessage(_message,msgTag);
+ msgTag = gameLocal.GetNextMessageTag();
+
+ if (_message != NULL)
+ {
+ owner->AddMessage(_message, msgTag);
+ }
+
+ if (_additionalMessage != NULL)
+
+ {
+ owner->AddMessage(_additionalMessage, msgTag);
+ }
+
}
owner->GetMind()->GetMemory().currentlyBarking = true; // grayman #3182 - idle anims w/voices cannot start
@@ -138,6 +148,11 @@
return true; // grayman #3857
}
+void SingleBarkTask::SetAdditionalMessage(const CommMessagePtr& message)
+{
+ _additionalMessage = message;
+}
+
void SingleBarkTask::OnFinish(idAI* owner)
{
owner->GetMind()->GetMemory().currentlyBarking = false;
@@ -168,6 +183,11 @@
{
_message->Save(savefile);
}
+ savefile->WriteBool(_additionalMessage != NULL);
+ if (_additionalMessage != NULL)
+ {
+ _additionalMessage->Save(savefile);
+ }
}
void SingleBarkTask::Restore(idRestoreGame* savefile)
@@ -189,6 +209,18 @@
{
_message = CommMessagePtr();
}
+ bool hasAdditionalMessage;
+ savefile->ReadBool(hasAdditionalMessage);
+
+ if (hasAdditionalMessage)
+ {
+ _additionalMessage = CommMessagePtr(new CommMessage);
+ _additionalMessage->Restore(savefile);
+ }
+ else
+ {
+ _additionalMessage = CommMessagePtr();
+ }
}
SingleBarkTaskPtr SingleBarkTask::CreateInstance()
Index: ai/Tasks/SingleBarkTask.h
===================================================================
--- ai/Tasks/SingleBarkTask.h (revision 11370)
+++ ai/Tasks/SingleBarkTask.h (working copy)
@@ -40,6 +40,8 @@
// The message which should be delivered when barking
CommMessagePtr _message;
+ // nbohr1more
+ CommMessagePtr _additionalMessage;
// Default constructor
SingleBarkTask();
@@ -72,6 +74,7 @@
// Class-specific methods
virtual void SetSound(const idStr& soundName);
virtual void SetMessage(const CommMessagePtr& message);
+ void SetAdditionalMessage(const CommMessagePtr& message);
};
} // namespace ai
|
|
|
Do you know what's the problem with the using AI agents code as is? They generate shitload of code, which may fix the current problem, but generates more problems in the future. And every time you commit such a code, you make it harder for everyone to work with the code without AI agent =) I'm really wary of adding hundreds of new code into AI in order to fix a very special issue which only happens in one map. |
|
|
Yes, that makes sense but I've seen the same problem in other maps. This was part of a Grayman discussion about some general shortcomings about our pathfinding behaviors. I guess I'll leave this here for anyone who wants to chime in on the severity of this kind of problem. This map is one of the easiest ways to reproduce it. Perhaps another dev will look at what this fixes and replace the code with a similar design... |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 25.05.2016 18:48 | grayman | New Issue | |
| 25.05.2016 18:48 | grayman | Status | new => assigned |
| 25.05.2016 18:48 | grayman | Assigned To | => grayman |
| 25.05.2016 18:48 | grayman | File Added: storm_saves.zip | |
| 25.05.2016 19:38 | grayman | Note Added: 0008172 | |
| 21.10.2016 15:27 | grayman | Target Version | TDM 2.05 => TDM 2.06 |
| 16.09.2017 18:09 | grayman | Note Added: 0009260 | |
| 16.09.2017 18:09 | grayman | Target Version | TDM 2.06 => |
| 16.09.2017 18:12 | grayman | Target Version | => TDM 2.07 |
| 06.10.2017 02:15 | nbohr1more | Target Version | => TDM 2.07 |
| 24.11.2017 16:28 | grayman | Assigned To | grayman => |
| 24.11.2017 16:44 | grayman | Status | assigned => new |
| 11.12.2017 21:57 | grayman | Note Added: 0009760 | |
| 19.12.2018 14:16 | nbohr1more | Note Added: 0010972 | |
| 19.12.2018 17:54 | grayman | Note Added: 0010973 | |
| 19.12.2018 17:57 | nbohr1more | Assigned To | => grayman |
| 19.12.2018 17:57 | nbohr1more | Status | new => feedback |
| 19.12.2018 17:58 | nbohr1more | Note Added: 0010974 | |
| 20.12.2018 04:47 | nbohr1more | Note Added: 0010988 | |
| 29.12.2018 22:52 | nbohr1more | Target Version | TDM 2.07 => TDM 2.08 |
| 23.11.2019 01:52 | grayman | Target Version | TDM 2.08 => |
| 26.10.2020 23:07 | grayman | Assigned To | grayman => |
| 26.10.2020 23:07 | grayman | Status | feedback => new |
| 26.10.2020 23:07 | grayman | Note Added: 0012841 | |
| 11.02.2024 01:12 | Fiver | Tag Attached: search | |
| 21.11.2026 08:18 | nbohr1more | Note Added: 0017397 | |
| 21.11.2026 08:18 | nbohr1more | File Added: ai_unreachable_fix.patch | |
| 21.11.2026 08:18 | nbohr1more | Assigned To | => stgatilov |
| 21.11.2026 08:18 | nbohr1more | Status | new => feedback |
| 21.11.2026 08:18 | nbohr1more | Target Version | => TDM 2.15 |
| 21.11.2026 12:02 | stgatilov | Note Added: 0017398 | |
| 21.11.2026 13:53 | nbohr1more | Note Added: 0017399 | |
| 21.11.2026 18:06 | nbohr1more | Assigned To | stgatilov => Dragofer |