Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ jobs:
--exclude='docs/' \
--exclude='*.csproj' \
--exclude='*.sln' \
--exclude='.coderabbit.yaml' \
--exclude='.pre-commit-config.yaml' \
--exclude='INTRODUCTION.txt' \
--exclude='.gitignore' \
--exclude='.gitattributes' \
--exclude='*.md' \
Expand Down
61 changes: 60 additions & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,66 @@
<li>1.6</li>
<li>1.7</li>
</supportedVersions>
<description>AI-powered storyteller that creates coherent narratives based on colony history and current situation. Requires RimMind Core. [v2.0 BREAKING CHANGES]</description>
<description>[h1]RimMind - Storyteller (v2.0)[/h1]
AI Story Director, dramatic tension curve engine, and causal narrative incident selector for RimWorld. Instead of rolling arbitrary raid dice based solely on wealth graphs, the AI Storyteller observes your colony's real history, emotional pacing, and unresolved conflicts to orchestrate multi-chapter sagas, bespoke lore letters, and interactive Storyteller Altar dialogues.

[b]v2.0 Clean Architecture &amp; RimWorld 1.6 / 1.7 Dual-Version Support:[/b]
[list]
[*][b]RimWorld 1.6 &amp; 1.7 (Waylith / .NET 10) Ready[/b]: Native multi-target compilation supporting both RimWorld 1.6 (.NET Framework 4.8) and RimWorld 1.7 (.NET 10 / Harmony 2.x &amp; 3.x).
[*][b]v2.0 Resilient Director Pipeline[/b]: Non-blocking request lifecycle coordination ([code]StorytellerRequestCoordinator[/code]) with 15,000-tick timeout protection, 2,500-tick failure backoff, and automatic truncated JSON repair. Note: v1.x saves are not compatible with v2.0.
[*][b]Full Vanilla Trader / Caravan / Quest Ecosystem Preserved[/b]: Combines AI narrative direction with vanilla RimWorld's complete orbital trader, faction caravan, visitor, and quest generation schedule so your colony economy and diplomacy thrive naturally.
[/list]

[h2]What Is RimMind[/h2]
RimMind is an enterprise-grade, AI-powered RimWorld mod suite. Integrated with Large Language Models (LLM), it transforms colonists into self-reflecting agents with distinct personalities, three-tier memories, natural spoken dialogues, autonomous mechanisms, and dynamic storytelling.

[h2]Sub-mod List &amp; Dependency Relationships[/h2]
[table]
[tr][th]Mod[/th][th]Responsibility[/th][th]Dependencies[/th][th]GitHub[/th][/tr]
[tr][td]RimMind-Core[/td][td]LLM runtime, 4-Zone context engine, async queue, ToolCall registry &amp; F8 Hub[/td][td]Harmony[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Core]Link[/url][/td][/tr]
[tr][td]RimMind-Actions[/td][td]Composite ToolCall mechanisms, battlefield triage &amp; autonomous construction[/td][td]Core[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Actions]Link[/url][/td][/tr]
[tr][td]RimMind-Advisor[/td][td]Colonist self-reflective advice cards, 5-domain autonomy &amp; player approval[/td][td]Core, Actions[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Advisor]Link[/url][/td][/tr]
[tr][td]RimMind-Dialogue[/td][td]Contextual spoken dialogue via express_dialogue ToolCall &amp; speech bubbles[/td][td]Core[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Dialogue]Link[/url][/td][/tr]
[tr][td]RimMind-Memory[/td][td]3-Tier cognitive memory hierarchy, work aggregation &amp; temporal decay[/td][td]Core[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Memory]Link[/url][/td][/tr]
[tr][td]RimMind-Personality[/td][td]Big-Five psychological profiles, dawn monologues &amp; dynamic mood thoughts[/td][td]Core[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Personality]Link[/url][/td][/tr]
[tr][td][b]RimMind-Storyteller[/b][/td][td]AI Story Director, dramatic tension curve, chained arcs &amp; Storyteller Altar[/td][td]Core, Memory[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Storyteller]Link[/url][/td][/tr]
[tr][td]RimMind-Extension-ModelService[/td][td]Multi-provider routing, Anthropic KV cache, local gateways &amp; load balancing[/td][td]Core[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Extension-ModelService]Link[/url][/td][/tr]
[tr][td]RimMind-Bridge-RimChat[/td][td]RimChat compatibility bridge: dialogue/action mutual exclusion &amp; context sync[/td][td]Core, RimChat[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Bridge-RimChat]Link[/url][/td][/tr]
[tr][td]RimMind-Bridge-RimTalk[/td][td]RimTalk compatibility bridge: bubble harmonization &amp; bidirectional context[/td][td]Core, RimTalk[/td][td][url=https://github.com/RimWorld-RimMind-Mod/RimWorld-RimMind-Mod-Bridge-RimTalk]Link[/url][/td][/tr]
[/table]
[code]Core ──┬── Actions ── Advisor
├── Dialogue
├── Memory ── Storyteller
├── Personality
├── Extension-ModelService
├── Bridge-RimChat
└── Bridge-RimTalk[/code]

[h2]Core Features[/h2]
[list]
[*][b]AI Event Selection &amp; Causal Lore Letters[/b] - Evaluates valid in-game [code]IncidentDef[/code] candidates ([code]CanFireNow[/code]) against your colony's recent history from [code]RimMind-Memory[/code], crafting custom incident letters that directly reference your colonists' past deeds.
[*][b]Dramatic Tension Curve ([code]StorytellerMemory[/code] &amp; [code]TensionMath[/code])[/b] - Continuously tracks colony hardship, casualties, mood equilibrium, and daily tension decay to balance intense climaxes with earned recovery periods.
[*][b]Multi-Chapter Narrative Event Chains[/b] - Links incidents across multi-step story arcs ([code]chain_id[/code], [code]chain_step[/code], [code]chain_total[/code], [code]next_hint[/code]) with bounded threat-point multipliers and faction/raid strategy hints.
[*][b]Storyteller Altar &amp; Agent Console[/b] - Build the in-game [b]Storyteller Altar[/b] to converse directly with the AI Story Director ([code]Window_StorytellerDialogue[/code]), negotiate your colony's fate, or inspect/steer narrative pacing via [code]Window_StorytellerAgentControl[/code].
[*][b]Full Vanilla Trader / Caravan / Quest Ecosystem[/b] - Retains full vanilla storyteller [code]StorytellerComp[/code] schedules for orbital traders, allied trade caravans, hospitality visitors, and quests alongside AI-directed dramatic arcs.
[*][b]Intelligent Fallback Mode[/b] - If your LLM API is offline, rate-limited, or unconfigured, seamlessly falls back to balanced tension-aware incident selection so gameplay never stalls.
[/list]

[h2]Storyteller Director Pipeline[/h2]
[table]
[tr][th]Stage[/th][th]Component[/th][th]Function[/th][/tr]
[tr][td]1. Memory &amp; Tension[/td][td]StorytellerMemory / TensionMath[/td][td]Aggregates high-importance colony memories and computes current dramatic tension (0 to 100)[/td][/tr]
[tr][td]2. Candidate Filtering[/td][td]RimMindIncidentSelector[/td][td]Pre-filters valid IncidentDefs via CanFireNow and groups threats, blessings, and neutral events[/td][/tr]
[tr][td]3. Async LLM Direction[/td][td]StorytellerRequestCoordinator[/td][td]Dispatches non-blocking AI request with timeout &amp; backoff guards[/td][/tr]
[tr][td]4. Parse &amp; Fire[/td][td]StorytellerResponseParserPure[/td][td]Validates incident choice, clamps threat points, fires custom letter &amp; records chain step[/td][/tr]
[/table]

[h2]Frequently Asked Questions[/h2]
[b]Q: Will I still get regular trade caravans, orbital traders, and quests?[/b]
A: Yes! The AI Storyteller preserves the full vanilla trader, caravan, and quest generation ecosystem while directing narrative events and story chains on top.

[b]Q: What happens if an AI request times out or my API key runs out?[/b]
A: [code]StorytellerRequestCoordinator[/code] automatically recovers from timeouts after 15,000 ticks and uses tension-balanced fallback selection so your campaign continues smoothly.</description>
<modDependencies>
<li>
<packageId>brrainz.harmony</packageId>
Expand Down
114 changes: 114 additions & 0 deletions Defs/StorytellerDefs/RimMindDirector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,120 @@
<minDaysPassed>5</minDaysPassed>
<mtbDays>6</mtbDays>
</li>
<li Class="StorytellerCompProperties_ShipChunkDrop"/>
<!-- Ally/neutral interaction -->
<li Class="StorytellerCompProperties_FactionInteraction">
<incident>RaidFriendly</incident>
<baseIncidentsPerYear>15</baseIncidentsPerYear>
<minSpacingDays>0.4</minSpacingDays>
<fullAlliesOnly>true</fullAlliesOnly>
<minDanger>High</minDanger>
</li>
<li Class="StorytellerCompProperties_FactionInteraction">
<incident>TraderCaravanArrival</incident>
<minDaysPassed>5</minDaysPassed>
<baseIncidentsPerYear>5</baseIncidentsPerYear>
<minSpacingDays>6</minSpacingDays>
<allowedTargetTags>
<li>Map_PlayerHome</li>
</allowedTargetTags>
</li>
<li Class="StorytellerCompProperties_FactionInteraction">
<incident>VisitorGroup</incident>
<minDaysPassed>3</minDaysPassed>
<baseIncidentsPerYear>4</baseIncidentsPerYear>
<minSpacingDays>5</minSpacingDays>
<allowedTargetTags>
<li>Map_PlayerHome</li>
</allowedTargetTags>
</li>
<li Class="StorytellerCompProperties_FactionInteraction">
<incident>TravelerGroup</incident>
<minDaysPassed>1</minDaysPassed>
<baseIncidentsPerYear>6</baseIncidentsPerYear>
<minSpacingDays>1</minSpacingDays>
<allowedTargetTags>
<li>Map_PlayerHome</li>
</allowedTargetTags>
</li>
<!-- Caravan / temp map -->
<li Class="StorytellerCompProperties_CategoryIndividualMTBByBiome">
<category>Misc</category>
<allowedTargetTags>
<li>Caravan</li>
<li>Map_TempIncident</li>
</allowedTargetTags>
</li>
<li Class="StorytellerCompProperties_CategoryIndividualMTBByBiome">
<category>ThreatSmall</category>
<applyCaravanVisibility>true</applyCaravanVisibility>
<allowedTargetTags>
<li>Caravan</li>
<li>Map_TempIncident</li>
</allowedTargetTags>
</li>
<li Class="StorytellerCompProperties_CategoryIndividualMTBByBiome">
<category>ThreatBig</category>
<applyCaravanVisibility>true</applyCaravanVisibility>
<allowedTargetTags>
<li>Caravan</li>
<li>Map_TempIncident</li>
</allowedTargetTags>
</li>
<!-- Quests - non-Royalty -->
<li Class="StorytellerCompProperties_RandomQuest">
<category>GiveQuest</category>
<allowedTargetTags>
<li>World</li>
</allowedTargetTags>
<onDays>10</onDays>
<numIncidentsRange>1</numIncidentsRange>
<acceptFractionByDaysPassedCurve>
<points>
<li>(8, 0)</li>
<li>(15, 1)</li>
</points>
</acceptFractionByDaysPassedCurve>
<minSpacingDays>3</minSpacingDays>
<disableIfAnyModActive>
<li>Ludeon.RimWorld.Royalty</li>
</disableIfAnyModActive>
</li>
<!-- Quests - Royalty -->
<li Class="StorytellerCompProperties_RandomQuest">
<category>GiveQuest</category>
<allowedTargetTags>
<li>World</li>
</allowedTargetTags>
<onDays>12</onDays>
<numIncidentsRange>2</numIncidentsRange>
<acceptFractionByDaysPassedCurve>
<points>
<li>(8, 0)</li>
<li>(15, 1)</li>
</points>
</acceptFractionByDaysPassedCurve>
<minSpacingDays>3</minSpacingDays>
<enableIfAnyModActive>
<li>Ludeon.RimWorld.Royalty</li>
</enableIfAnyModActive>
</li>
<!-- World misc incidents -->
<li Class="StorytellerCompProperties_CategoryMTB">
<category>Misc</category>
<allowedTargetTags>
<li>World</li>
</allowedTargetTags>
<minDaysPassed>15</minDaysPassed>
<mtbDays>15</mtbDays>
</li>
<!-- Orbital trader -->
<li Class="StorytellerCompProperties_OnOffCycle">
<incident>OrbitalTraderArrival</incident>
<onDays>7</onDays>
<offDays>8</offDays>
<numIncidentsRange>1</numIncidentsRange>
</li>
<!-- 初始加入者 -->
<li Class="StorytellerCompProperties_Triggered">
<incident>StrangerInBlackJoin</incident>
Expand Down
7 changes: 7 additions & 0 deletions Source/Storyteller/IncidentSelectionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@ public static bool ShouldNotify(
=> notificationsEnabled
&& (kind == StorytellerIncidentKind.ThreatBig
|| kind == StorytellerIncidentKind.ThreatSmall);

public static bool RequiresHostileFaction(
string? incidentDefName,
string? categoryDefName)
=> (string.Equals(categoryDefName, "ThreatBig", StringComparison.Ordinal)
|| string.Equals(categoryDefName, "ThreatSmall", StringComparison.Ordinal))
&& !string.Equals(incidentDefName, "RaidFriendly", StringComparison.Ordinal);
}
}
7 changes: 6 additions & 1 deletion Source/Storyteller/RimMindIncidentSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ public static (FiringIncident? incident, IncidentResponse? response) ParseRespon

if (!string.IsNullOrEmpty(result.@params.faction_hint))
{
bool requiresHostile = IncidentSelectionPolicy.RequiresHostileFaction(
incidentDef.defName,
incidentDef.category?.defName);
var faction = Find.FactionManager.AllFactions
.FirstOrDefault(f => f.def.defName == result.@params.faction_hint
&& f.HostileTo(Faction.OfPlayer));
&& (requiresHostile
? f.HostileTo(Faction.OfPlayer)
: !f.IsPlayer && !f.HostileTo(Faction.OfPlayer) && !f.defeated));
if (faction != null) parms.faction = faction;
}

Expand Down
Loading
Loading