反常子个体

This commit is contained in:
2025-07-25 23:11:42 +08:00
parent a33d616d23
commit 83422aaea8
15 changed files with 240 additions and 54 deletions

Binary file not shown.

View File

@@ -1051,20 +1051,6 @@
<title>破碎人格</title> <title>破碎人格</title>
<titleShort>破碎人格</titleShort> <titleShort>破碎人格</titleShort>
<description>[PAWN_possessive]人格矩阵完全损坏,已是某个集体意识的一部分。</description> <description>[PAWN_possessive]人格矩阵完全损坏,已是某个集体意识的一部分。</description>
<skillGains>
<Shooting>-5</Shooting>
<Melee>-5</Melee>
<Construction>-5</Construction>
<Mining>-5</Mining>
<Cooking>-5</Cooking>
<Plants>-5</Plants>
<Animals>-5</Animals>
<Crafting>-5</Crafting>
<Artistic>-5</Artistic>
<Medicine>-5</Medicine>
<Social>-5</Social>
<Intellectual>-5</Intellectual>
</skillGains>
<spawnCategories> <spawnCategories>
<li>Wula_Backstory_Categories_For_Hostile_Faction</li> <li>Wula_Backstory_Categories_For_Hostile_Faction</li>
</spawnCategories> </spawnCategories>

View File

@@ -31,5 +31,11 @@
<li>WULA_Addons_Antenna_Hediff_Base</li> <li>WULA_Addons_Antenna_Hediff_Base</li>
<!--<li>MechlinkImplant</li>--> <!--<li>MechlinkImplant</li>-->
</forcedHediffs> </forcedHediffs>
<forcedTraitsChance>
<li>
<defName Degree="0">WULA_BrokenPersonalityTrait</defName>
<chance>100</chance>
</li>
</forcedTraitsChance>
</AlienRace.AlienBackstoryDef> </AlienRace.AlienBackstoryDef>
</Defs> </Defs>

View File

@@ -73,7 +73,7 @@
<li>(4000, 500)</li> <li>(4000, 500)</li>
</points> </points>
</raidLootValueFromPointsCurve> </raidLootValueFromPointsCurve>
<humanlikeFaction>false</humanlikeFaction> <humanlikeFaction>true</humanlikeFaction>
<hidden>true</hidden> <hidden>true</hidden>
<autoFlee>false</autoFlee> <autoFlee>false</autoFlee>
<canUseAvoidGrid>false</canUseAvoidGrid> <canUseAvoidGrid>false</canUseAvoidGrid>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<MentalBreakDef>
<defName>Wula_BrokenPersonality</defName>
<label>人格破碎</label>
<mentalState>Wula_BrokenPersonality</mentalState>
<intensity>Extreme</intensity>
<baseCommonality>1.0</baseCommonality>
<workerClass>WulaFallenEmpire.MentalBreakWorker_BrokenPersonality</workerClass>
</MentalBreakDef>
</Defs>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<MentalStateDef>
<defName>Wula_BrokenPersonality</defName>
<label>人格破碎</label>
<stateClass>WulaFallenEmpire.MentalState_BrokenPersonality</stateClass>
<category>Aggro</category>
<blockNormalThoughts>true</blockNormalThoughts>
<nameColor>(255, 0, 0)</nameColor>
<recoveryMtbDays>0.0001</recoveryMtbDays> <!-- 几乎立即恢复因为逻辑在PostStart中执行 -->
<modExtensions>
<li Class="WulaFallenEmpire.MentalStateDefExtension_BrokenPersonality">
<traitToAdd>WULA_Trait_Broken_Personality</traitToAdd>
<factionToJoin>Wula_Broken_Personality_Faction</factionToJoin>
<skillLevelFactor>0.5</skillLevelFactor>
</li>
</modExtensions>
<blockInteractionInitiationExcept>
<li>Insult</li>
</blockInteractionInitiationExcept>
<blockInteractionRecipientExcept>
<li>Insult</li>
</blockInteractionRecipientExcept>
<moodRecoveryThought>Catharsis</moodRecoveryThought>
<beginLetter>由于重度精神崩溃,{0}的模拟人格已经破碎,{0}受到了星球上乌拉帝国反常网络的一个主脑子节点影响,已经成为了这些反常子个体乌拉的一员。</beginLetter>
<beginLetterDef>NegativeEvent</beginLetterDef>
<baseInspectLine>精神状态:人格破碎</baseInspectLine>
</MentalStateDef>
</Defs>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<TraitDef>
<defName>WULA_BrokenPersonalityTrait</defName>
<commonality>0</commonality>
<degreeDatas>
<li>
<label>机械乌拉</label>
<description>{PAWN_nameDef}是机械乌拉。乌拉的思维模式与常人不同,在极端压力下,其模拟人格会彻底崩溃。</description>
<theOnlyAllowedMentalBreaks>
<li>Wula_BrokenPersonality</li>
</theOnlyAllowedMentalBreaks>
</li>
</degreeDatas>
</TraitDef>
</Defs>

View File

@@ -1,18 +0,0 @@
# Compiled output
bin/
obj/
# Rider
.idea/
# Visual Studio
.vs/
*.suo
*.user
*.userosf
*.sln.docstates
# OS generated files
.DS_Store
.localized
Thumbs.db

View File

@@ -3,7 +3,11 @@
"WorkspaceRootPath": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\", "WorkspaceRootPath": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\",
"Documents": [ "Documents": [
{ {
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|c:\\steam\\steamapps\\common\\rimworld\\mods\\3516260226\\source\\wulafallenempire\\recipe_administerwulamechrepairkit.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|c:\\steam\\steamapps\\common\\rimworld\\mods\\3516260226\\source\\wulafallenempire\\mentalstate_brokenpersonality.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:mentalstate_brokenpersonality.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\recipe_administerwulamechrepairkit.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:recipe_administerwulamechrepairkit.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" "RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:recipe_administerwulamechrepairkit.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}, },
{ {
@@ -63,6 +67,19 @@
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 0, "DocumentIndex": 0,
"Title": "MentalState_BrokenPersonality.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MentalState_BrokenPersonality.cs",
"RelativeDocumentMoniker": "MentalState_BrokenPersonality.cs",
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MentalState_BrokenPersonality.cs",
"RelativeToolTip": "MentalState_BrokenPersonality.cs",
"ViewState": "AQIAADMAAAAAAAAAAAAlwEsAAAAjAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-25T13:51:03.13Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Recipe_AdministerWulaMechRepairKit.cs", "Title": "Recipe_AdministerWulaMechRepairKit.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Recipe_AdministerWulaMechRepairKit.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Recipe_AdministerWulaMechRepairKit.cs",
"RelativeDocumentMoniker": "Recipe_AdministerWulaMechRepairKit.cs", "RelativeDocumentMoniker": "Recipe_AdministerWulaMechRepairKit.cs",
@@ -70,12 +87,11 @@
"RelativeToolTip": "Recipe_AdministerWulaMechRepairKit.cs", "RelativeToolTip": "Recipe_AdministerWulaMechRepairKit.cs",
"ViewState": "AQIAAC8AAAAAAAAAAAAAAC8AAAAAAAAA", "ViewState": "AQIAAC8AAAAAAAAAAAAAAC8AAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-24T05:09:33.389Z", "WhenOpened": "2025-07-24T05:09:33.389Z"
"EditorCaption": ""
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 1, "DocumentIndex": 2,
"Title": "WorkGiver_Warden_DeliverEnergy.cs", "Title": "WorkGiver_Warden_DeliverEnergy.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WorkGiver_Warden_DeliverEnergy.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WorkGiver_Warden_DeliverEnergy.cs",
"RelativeDocumentMoniker": "WorkGiver_Warden_DeliverEnergy.cs", "RelativeDocumentMoniker": "WorkGiver_Warden_DeliverEnergy.cs",
@@ -87,7 +103,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 2, "DocumentIndex": 3,
"Title": "WorkGiverDefExtension_FeedWula.cs", "Title": "WorkGiverDefExtension_FeedWula.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WorkGiverDefExtension_FeedWula.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WorkGiverDefExtension_FeedWula.cs",
"RelativeDocumentMoniker": "WorkGiverDefExtension_FeedWula.cs", "RelativeDocumentMoniker": "WorkGiverDefExtension_FeedWula.cs",
@@ -99,7 +115,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 3, "DocumentIndex": 4,
"Title": "CompApparelInterceptor.cs", "Title": "CompApparelInterceptor.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompApparelInterceptor.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompApparelInterceptor.cs",
"RelativeDocumentMoniker": "CompApparelInterceptor.cs", "RelativeDocumentMoniker": "CompApparelInterceptor.cs",
@@ -111,7 +127,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 4, "DocumentIndex": 5,
"Title": "Projectile_Launch_Patch.cs", "Title": "Projectile_Launch_Patch.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HarmonyPatches\\Projectile_Launch_Patch.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HarmonyPatches\\Projectile_Launch_Patch.cs",
"RelativeDocumentMoniker": "HarmonyPatches\\Projectile_Launch_Patch.cs", "RelativeDocumentMoniker": "HarmonyPatches\\Projectile_Launch_Patch.cs",
@@ -123,7 +139,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 6, "DocumentIndex": 7,
"Title": "IngestPatch.cs", "Title": "IngestPatch.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\IngestPatch.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\IngestPatch.cs",
"RelativeDocumentMoniker": "IngestPatch.cs", "RelativeDocumentMoniker": "IngestPatch.cs",
@@ -135,7 +151,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 5, "DocumentIndex": 6,
"Title": "CompUseEffect_WulaSkillTrainer.cs", "Title": "CompUseEffect_WulaSkillTrainer.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompUseEffect_WulaSkillTrainer.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompUseEffect_WulaSkillTrainer.cs",
"RelativeDocumentMoniker": "CompUseEffect_WulaSkillTrainer.cs", "RelativeDocumentMoniker": "CompUseEffect_WulaSkillTrainer.cs",
@@ -147,7 +163,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 7, "DocumentIndex": 8,
"Title": "Building_Wula_DarkEnergy_Engine.cs", "Title": "Building_Wula_DarkEnergy_Engine.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\Building_Wula_DarkEnergy_Engine.cs",
"RelativeDocumentMoniker": "Building_Wula_DarkEnergy_Engine.cs", "RelativeDocumentMoniker": "Building_Wula_DarkEnergy_Engine.cs",
@@ -159,7 +175,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 8, "DocumentIndex": 9,
"Title": "HediffComp_RegenerateBackstory.cs", "Title": "HediffComp_RegenerateBackstory.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HediffComp_RegenerateBackstory.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\HediffComp_RegenerateBackstory.cs",
"RelativeDocumentMoniker": "HediffComp_RegenerateBackstory.cs", "RelativeDocumentMoniker": "HediffComp_RegenerateBackstory.cs",
@@ -171,7 +187,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 9, "DocumentIndex": 10,
"Title": "WulaFallenEmpireMod.cs", "Title": "WulaFallenEmpireMod.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\WulaFallenEmpireMod.cs",
"RelativeDocumentMoniker": "WulaFallenEmpireMod.cs", "RelativeDocumentMoniker": "WulaFallenEmpireMod.cs",
@@ -183,7 +199,7 @@
}, },
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 10, "DocumentIndex": 11,
"Title": "MechanitorPatch.cs", "Title": "MechanitorPatch.cs",
"DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs", "DocumentMoniker": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\MechanitorPatch.cs",
"RelativeDocumentMoniker": "MechanitorPatch.cs", "RelativeDocumentMoniker": "MechanitorPatch.cs",

View File

@@ -0,0 +1,26 @@
using RimWorld;
using Verse;
using Verse.AI;
namespace WulaFallenEmpire
{
public class MentalBreakWorker_BrokenPersonality : MentalBreakWorker
{
public override bool TryStart(Pawn pawn, string reason, bool causedByMood)
{
// 先尝试启动精神状态
if (base.TryStart(pawn, reason, causedByMood))
{
// 成功启动后,执行附加逻辑
var extension = def.mentalState.GetModExtension<MentalStateDefExtension_BrokenPersonality>();
if (extension != null && extension.traitToAdd != null && !pawn.story.traits.HasTrait(extension.traitToAdd))
{
pawn.story.traits.GainTrait(new Trait(extension.traitToAdd));
}
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,12 @@
using RimWorld;
using Verse;
namespace WulaFallenEmpire
{
public class MentalStateDefExtension_BrokenPersonality : DefModExtension
{
public TraitDef traitToAdd;
public FactionDef factionToJoin;
public float skillLevelFactor = 1f;
}
}

View File

@@ -0,0 +1,93 @@
using RimWorld;
using Verse;
using Verse.AI;
using Verse.AI.Group;
namespace WulaFallenEmpire
{
public class MentalState_BrokenPersonality : MentalState
{
public override void PostStart(string reason)
{
base.PostStart(reason);
// 发送信件
if (PawnUtility.ShouldSendNotificationAbout(pawn))
{
// 手动实现备用逻辑:如果信件标题(beginLetterLabel)为空,则使用精神状态的通用标签(label)
string labelText = def.beginLetterLabel;
if (string.IsNullOrEmpty(labelText))
{
labelText = def.label;
}
TaggedString letterLabel = labelText.Formatted(pawn.LabelShort, pawn.Named("PAWN")).CapitalizeFirst();
TaggedString letterText = def.beginLetter.Formatted(pawn.LabelShort, pawn.Named("PAWN")).CapitalizeFirst();
if (reason != null)
{
letterText += "\n\n" + reason;
}
Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, pawn);
}
var extension = def.GetModExtension<MentalStateDefExtension_BrokenPersonality>();
if (extension != null)
{
bool alreadyBroken = pawn.story.traits.HasTrait(extension.traitToAdd);
if (!alreadyBroken)
{
// 移除所有技能热情
foreach (SkillRecord skill in pawn.skills.skills)
{
skill.passion = Passion.None;
}
// 所有技能等级减半
foreach (SkillRecord skill in pawn.skills.skills)
{
int currentLevel = skill.Level;
skill.Level = (int)(currentLevel * extension.skillLevelFactor);
}
}
// 改变派系
Faction newFaction = Find.FactionManager.FirstFactionOfDef(extension.factionToJoin);
if (newFaction == null)
{
newFaction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile);
}
if (newFaction != null)
{
pawn.SetFaction(newFaction, null);
}
}
// 离开地图
Lord lord = pawn.GetLord();
if (lord == null)
{
LordJob_ExitMapBest lordJob = new LordJob_ExitMapBest(LocomotionUrgency.Jog, canDig: true, canDefendSelf: true);
lord = LordMaker.MakeNewLord(pawn.Faction, lordJob, pawn.Map, Gen.YieldSingle(pawn));
}
else
{
lord.ReceiveMemo("PawnBroken");
}
// 强制恢复以避免状态无限持续
this.forceRecoverAfterTicks = 150;
}
public override void MentalStateTick(int delta)
{
base.MentalStateTick(delta);
// 确保在下一帧就恢复,因为所有效果都已经应用
if (age > 0)
{
RecoverFromState();
}
}
}
}

View File

@@ -99,6 +99,9 @@
<Compile Include="HarmonyPatches\Caravan_NeedsTracker_TrySatisfyPawnNeeds_Patch.cs" /> <Compile Include="HarmonyPatches\Caravan_NeedsTracker_TrySatisfyPawnNeeds_Patch.cs" />
<Compile Include="HarmonyPatches\FloatMenuOptionProvider_Ingest_Patch.cs" /> <Compile Include="HarmonyPatches\FloatMenuOptionProvider_Ingest_Patch.cs" />
<Compile Include="HarmonyPatches\Projectile_Launch_Patch.cs" /> <Compile Include="HarmonyPatches\Projectile_Launch_Patch.cs" />
<Compile Include="MentalState_BrokenPersonality.cs" />
<Compile Include="MentalStateDefExtension_BrokenPersonality.cs" />
<Compile Include="MentalBreakWorker_BrokenPersonality.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />