Mantella
Mantella copied to clipboard
Allow player to interrupt conversation with hotkey
This section of code in output_manager.py
allows the player to "interrupt" a radiant conversation and join in (turning it into a multi-NPC conversation):
https://github.com/art-from-the-machine/Mantella/blob/94fdfba52e5be60ded5a8e7a96d3a63bc1ae560f/src/output_manager.py#L648C1-L653C46
A new line of communication can be created which indicates whether the player is attempting to interrupt the LLM's response at any point (and not just radiant conversations), and if so, end the response as shown in the code above. For example:
end_conversation = self.game_state_manager.load_data_when_available('_mantella_end_conversation', '')
radiant_dialogue_update = self.game_state_manager.load_data_when_available('_mantella_radiant_dialogue', '')
player_interrupt = self.game_state_manager.load_data_when_available('_mantella_player_interrupt', '')
# stop processing LLM response if:
# max_response_sentences reached (and the conversation isn't radiant)
# conversation has switched from radiant to multi NPC (this allows the player to "interrupt" radiant dialogue and include themselves in the conversation)
# the conversation has ended
if ((num_sentences >= self.max_response_sentences) and (radiant_dialogue == False)) or ((radiant_dialogue == True) and (radiant_dialogue_update.lower() == 'false')) or (end_conversation.lower() == 'true') or (player_interrupt.lower == 'true'):
break
Note that this line of communication would also need to be added to the Mantella Spell. The method of communication will change once this HTTP PR is merged: https://github.com/art-from-the-machine/Mantella/pull/205. It is better to wait for this HTTP PR to be merged before working on this task to avoid rework.