View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002246 | The Dark Mod | AI | public | 08.06.2010 12:52 | 03.12.2026 01:30 |
| Reporter | grayman | Assigned To | |||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | acknowledged | Resolution | open | ||
| Platform | Win32 | OS | Windows | OS Version | XP |
| Product Version | TDM 1.02 | ||||
| Summary | 0002246: Continuing interrupted conversations | ||||
| Description | Enhancement Request ... Conversations can be aborted if one or more of the actors raises his alert level. For example, 2 actors could be relaying critical information, and if one of them says something like "What was that?" in response to player movement, the conversation is aborted. A more natural response would be: talk talk talk ... [player moves, alerting an actor and pausing the conversation] "What was that?" silence for a moment "Oh I guess it was the wind." [resume conversation] talk talk talk ... | ||||
| Steps To Reproduce | I can provide a test map with a conversation if it's needed. | ||||
| Tags | talk | ||||
| Of course, if the player is seen and the actors go after him, aborting the conversation makes sense. It's just the low-level alerts that should lead to resuming a conversation. Preventing the actors from chasing the player around is the mapper's responsibility if the conversation is important. | |
| I think we need a conversation spawnarg that tells AI to ignore alerts of a certain level, with a default of 2 (so anything that wouldn't cause searching would be ignored). | |
|
Guard 1: "Oh, man! I was totally banging this chick last night! She was all, COME OUT OF THE SHADOWS, YOU!" Guard 2: "Seriously? I got in the mood last night and told my wife SHOW YOURSELF OVER THERE!" Guard 1: Oh man! This girl was all, like, DID I JUST SEE SOMETHING MOVE?" I'm sorry, I couldn't help myself. I'll go hide in a corner now... |
|
| Someone's been smokin' the wacky tabaccy. | |
|
Preliminary patch tdm_2246_resume_conversations.patch (4,284 bytes)
--- a/game/ai/Mind.h
+++ b/game/ai/Mind.h
@@ -105,6 +105,13 @@
return _stateQueue.front();
}
+ // Find a state anywhere in the stack. Suspended states remain alive below
+ // temporary alert/search states.
+ StatePtr FindState(const idStr& stateName) const;
+
+ // Remove a state from anywhere in the stack, running its cleanup hook.
+ bool RemoveState(const idStr& stateName);
+
// Returns the Memory structure, which holds the various mind variables
ID_INLINE Memory& GetMemory() {
return _memory;
--- a/game/ai/Mind.cpp
+++ b/game/ai/Mind.cpp
@@ -234,6 +234,46 @@
}
}
+StatePtr Mind::FindState(const idStr& stateName) const
+{
+ for (StateQueue::const_iterator i = _stateQueue.begin(); i != _stateQueue.end(); ++i)
+ {
+ if ((*i)->GetName() == stateName)
+ {
+ return *i;
+ }
+ }
+
+ return StatePtr();
+}
+
+bool Mind::RemoveState(const idStr& stateName)
+{
+ idAI* owner = _owner.GetEntity();
+ assert(owner);
+
+ for (StateQueue::iterator i = _stateQueue.begin(); i != _stateQueue.end(); ++i)
+ {
+ if ((*i)->GetName() == stateName)
+ {
+ const bool wasCurrentState = (i == _stateQueue.begin());
+ (*i)->Cleanup(owner);
+ _stateQueue.erase(i);
+ if (wasCurrentState)
+ {
+ _switchState = true;
+ }
+ if (_stateQueue.empty())
+ {
+ PushState(STATE_DEFAULT);
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
void Mind::ClearStates()
{
idAI* owner = _owner.GetEntity();
--- a/game/ai/States/ConversationState.cpp
+++ b/game/ai/States/ConversationState.cpp
@@ -175,7 +175,10 @@
if (!CheckAlertLevel(owner))
{
DM_LOG(LC_CONVERSATION, LT_DEBUG)LOGSTRING("Actor %s is too alert to continue a conversation\r", owner->GetName());
- owner->GetMind()->SwitchState(owner->backboneStates[EObservant]);
+ // Keep this ConversationState on the mind's stack. Alert/search states
+ // temporarily take priority, then the conversation can resume when
+ // those states finish.
+ owner->GetMind()->PushState(owner->backboneStates[EObservant]);
return;
}
--- a/game/ai/Conversation/Conversation.cpp
+++ b/game/ai/Conversation/Conversation.cpp
@@ -180,16 +180,10 @@
continue;
}
- // Let's see if the AI is currently in a conversation.
- ConversationStatePtr convState =
- std::dynamic_pointer_cast<ConversationState>(ai->GetMind()->GetState());
-
- if (convState != NULL)
- {
- // End the conversation state
- ai->GetMind()->EndState();
- ai->m_InConversation = false; // grayman #3559
- }
+ // The conversation may be suspended below temporary alert/search states.
+ // Remove it from anywhere in the mind stack when the conversation ends.
+ ai->GetMind()->RemoveState(STATE_CONVERSATION);
+ ai->m_InConversation = false; // grayman #3559
}
}
@@ -251,6 +245,29 @@
return false;
}
+ // A temporary alert/search state can sit above a participant's
+ // ConversationState. Pause the conversation as a whole until every actor
+ // is back in their conversation state; otherwise commands would run while
+ // one participant is investigating and the conversation would abort.
+ for (int i = 0; i < GetNumActors(); ++i)
+ {
+ idAI* actor = GetActor(i);
+ if (actor == NULL) return false;
+
+ ConversationStatePtr convState = GetConversationState(i);
+ if (convState == NULL) return false;
+
+ if (actor->GetMind()->GetState() != convState)
+ {
+ // Seeing/engaging an enemy is not a temporary interruption.
+ if (actor->GetEnemy() != NULL)
+ {
+ return false;
+ }
+ return true;
+ }
+ }
+
if (command->GetType() == ConversationCommand::EWaitForAllActors)
{
// Special case: we need to wait until all actors are ready again
@@ -317,11 +334,12 @@
}
// Let's see if the AI can handle this conversation command
- ConversationStatePtr convState = std::dynamic_pointer_cast<ConversationState>(ai->GetMind()->GetState());
+ ConversationStatePtr convState = std::dynamic_pointer_cast<ConversationState>(
+ ai->GetMind()->FindState(STATE_CONVERSATION));
if (convState == NULL)
{
- // AI is not in ConversationState anymore
+ // AI is no longer part of this conversation.
DM_LOG(LC_CONVERSATION, LT_DEBUG)LOGSTRING("Conversation %s: ai %s is not in conversation mode anymore.\r", _name.c_str(), ai->name.c_str());
return ConversationStatePtr();
}
|
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 08.06.2010 12:52 | grayman | New Issue | |
| 08.06.2010 12:57 | grayman | Note Added: 0003046 | |
| 10.06.2010 17:33 | greebo | Status | new => acknowledged |
| 05.04.2011 01:20 | Springheel | Note Added: 0003792 | |
| 07.04.2011 03:32 | Mortem Desino | Note Added: 0003796 | |
| 07.04.2011 06:04 | grayman | Note Added: 0003797 | |
| 30.12.2020 00:36 | nbohr1more | Relationship added | related to 0004341 |
| 10.02.2024 22:27 | Fiver | Tag Attached: talk | |
| 03.12.2026 01:30 | nbohr1more | Note Added: 0017407 | |
| 03.12.2026 01:30 | nbohr1more | File Added: tdm_2246_resume_conversations.patch |