fixes to make quest tracking work better, also quest rejection in via the converation with the NPC
This commit is contained in:
@@ -448,7 +448,9 @@ class NarrativeGenerator:
|
||||
npc_relationship: str | None = None,
|
||||
previous_dialogue: list[dict[str, Any]] | None = None,
|
||||
npc_knowledge: list[str] | None = None,
|
||||
quest_offering_context: dict[str, Any] | None = None
|
||||
quest_offering_context: dict[str, Any] | None = None,
|
||||
quest_ineligibility_context: dict[str, Any] | None = None,
|
||||
player_asking_for_quests: bool = False
|
||||
) -> NarrativeResponse:
|
||||
"""
|
||||
Generate NPC dialogue in response to player conversation.
|
||||
@@ -463,6 +465,8 @@ class NarrativeGenerator:
|
||||
previous_dialogue: Optional list of previous exchanges.
|
||||
npc_knowledge: Optional list of things this NPC knows about.
|
||||
quest_offering_context: Optional quest offer context from QuestEligibilityService.
|
||||
quest_ineligibility_context: Optional context explaining why player can't take a quest.
|
||||
player_asking_for_quests: Whether the player is explicitly asking for quests/work.
|
||||
|
||||
Returns:
|
||||
NarrativeResponse with NPC dialogue.
|
||||
@@ -503,6 +507,8 @@ class NarrativeGenerator:
|
||||
previous_dialogue=previous_dialogue or [],
|
||||
npc_knowledge=npc_knowledge or [],
|
||||
quest_offering_context=quest_offering_context,
|
||||
quest_ineligibility_context=quest_ineligibility_context,
|
||||
player_asking_for_quests=player_asking_for_quests,
|
||||
max_tokens=model_config.max_tokens
|
||||
)
|
||||
except PromptTemplateError as e:
|
||||
|
||||
@@ -93,8 +93,8 @@ Make it feel earned, like the NPC is opening up to someone they trust.
|
||||
{% endif %}
|
||||
|
||||
{% if quest_offering_context and quest_offering_context.should_offer %}
|
||||
## QUEST OFFERING OPPORTUNITY
|
||||
The NPC has a quest to offer. Weave this naturally into the conversation.
|
||||
## QUEST TO OFFER
|
||||
The NPC has a quest to offer to the player.
|
||||
|
||||
**Quest:** {{ quest_offering_context.quest_name }}
|
||||
**Quest ID:** {{ quest_offering_context.quest_id }}
|
||||
@@ -118,13 +118,53 @@ The NPC has a quest to offer. Weave this naturally into the conversation.
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
**IMPORTANT QUEST OFFERING RULES:**
|
||||
- Do NOT dump all quest information at once
|
||||
- Let the quest emerge naturally from conversation
|
||||
- If the player seems interested or asks about problems/work, offer the quest
|
||||
- If the player changes topic, don't force it - just mention hints
|
||||
- When you offer the quest, include this marker on its own line: [QUEST_OFFER:{{ quest_offering_context.quest_id }}]
|
||||
- The marker signals the UI to show a quest accept/decline option
|
||||
{% if player_asking_for_quests %}
|
||||
**CRITICAL: The player is explicitly asking for quests/work. You MUST offer this quest NOW.**
|
||||
In your response:
|
||||
1. Describe the quest situation naturally in your dialogue
|
||||
2. End your response with the quest offer marker on its own line: [QUEST_OFFER:{{ quest_offering_context.quest_id }}]
|
||||
|
||||
The marker MUST appear - it triggers the UI to show accept/decline buttons.
|
||||
{% else %}
|
||||
**Quest Offering Guidelines:**
|
||||
- Weave the quest naturally into conversation
|
||||
- If the player shows interest, include the marker: [QUEST_OFFER:{{ quest_offering_context.quest_id }}]
|
||||
- The marker signals the UI to show quest accept/decline options
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if quest_ineligibility_context and player_asking_for_quests %}
|
||||
## QUEST UNAVAILABLE - EXPLAIN WHY
|
||||
The player is asking about quests, but they don't meet the requirements. Explain this in character.
|
||||
|
||||
{% if quest_ineligibility_context.reason_type == "level_too_low" %}
|
||||
**Reason:** The player (level {{ quest_ineligibility_context.current_level }}) isn't experienced enough. They need to be level {{ quest_ineligibility_context.required_level }}.
|
||||
**How to convey this:** The NPC should politely but firmly indicate the task is too dangerous for someone of their current skill level. Suggest they gain more experience first. Be encouraging but realistic - don't offer false hope.
|
||||
**Example tone:** "I appreciate your enthusiasm, but this task requires someone with more experience. The bandits we're dealing with are seasoned fighters. Come back when you've proven yourself in a few more battles."
|
||||
{% elif quest_ineligibility_context.reason_type == "level_too_high" %}
|
||||
**Reason:** The player is too experienced for available tasks.
|
||||
**How to convey this:** The NPC should indicate they have nothing worthy of such an accomplished adventurer right now.
|
||||
{% elif quest_ineligibility_context.reason_type == "prerequisite_missing" %}
|
||||
**Reason:** The player needs to complete other tasks first.
|
||||
**How to convey this:** Hint that there's something else they should do first, or that circumstances aren't right yet.
|
||||
{% elif quest_ineligibility_context.reason_type == "relationship_too_low" %}
|
||||
**Reason:** The NPC doesn't trust the player enough yet.
|
||||
**How to convey this:** Be guarded. Hint that you might have work, but you need to know you can trust them first.
|
||||
{% elif quest_ineligibility_context.reason_type == "quest_already_active" %}
|
||||
**Reason:** The player is already working on this quest.
|
||||
**How to convey this:** Remind them they already accepted this task and should focus on completing it.
|
||||
{% elif quest_ineligibility_context.reason_type == "quest_already_completed" %}
|
||||
**Reason:** The player already completed this quest.
|
||||
**How to convey this:** Thank them again for their previous help, mention you have nothing else right now.
|
||||
{% elif quest_ineligibility_context.reason_type == "too_many_quests" %}
|
||||
**Reason:** The player has too many active quests.
|
||||
**How to convey this:** Suggest they finish some of their current commitments before taking on more.
|
||||
{% else %}
|
||||
**Reason:** {{ quest_ineligibility_context.message }}
|
||||
**How to convey this:** Politely decline, staying in character.
|
||||
{% endif %}
|
||||
|
||||
**IMPORTANT:** Do NOT offer the quest. Explain the situation naturally in dialogue.
|
||||
{% endif %}
|
||||
|
||||
{% if lore_context and lore_context.has_content %}
|
||||
|
||||
Reference in New Issue
Block a user