Skip to content

Commit 4d79024

Browse files
committed
Update to 1.4 and add camp, bandit camp raid quests
1 parent 63be0d0 commit 4d79024

File tree

7 files changed

+163
-4
lines changed

7 files changed

+163
-4
lines changed

About/About.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<supportedVersions>
66
<li>1.2</li>
77
<li>1.3</li>
8+
<li>1.4</li>
89
</supportedVersions>
910
<description>Call other factions to get quests at will!</description>
1011
<url>https://steamcommunity.com/sharedfiles/filedetails/?id=2240610130</url>

About/Manifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<manifestUri></manifestUri>
55
<downloadUri></downloadUri>
66
<showCrossPromotions>true</showCrossPromotions>
7-
</Manifest>
7+
</Manifest>

CallForIntel.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Global
1010
Release|Any CPU = Release|Any CPU
1111
V12|Any CPU = V12|Any CPU
1212
V13|Any CPU = V13|Any CPU
13+
V14|Any CPU = V14|Any CPU
1314
EndGlobalSection
1415
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1516
{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -18,6 +19,8 @@ Global
1819
{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}.V12|Any CPU.Build.0 = V12|Any CPU
1920
{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}.V13|Any CPU.ActiveCfg = V13|Any CPU
2021
{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}.V13|Any CPU.Build.0 = V13|Any CPU
22+
{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}.V14|Any CPU.ActiveCfg = V14|Any CPU
23+
{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}.V14|Any CPU.Build.0 = V14|Any CPU
2124
EndGlobalSection
2225
GlobalSection(SolutionProperties) = preSolution
2326
HideSolutionNode = FALSE
File renamed without changes.

Common/Languages/English/Keyed/CallForIntel.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<IntelKindPawn>Refugees and slaves ({0} goodwill)</IntelKindPawn>
99
<IntelKindCombat>Hostile activity ({0} goodwill)</IntelKindCombat>
1010

11+
<!-- Ideology -->
12+
<IntelKindCamp>Work camps ({0} goodwill)</IntelKindCamp>
13+
1114
<!-- Vanilla Factions Expanded -->
1215
<IntelKindHunt>Legendary creatures ({0} goodwill)</IntelKindHunt>
1316
<IntelKindBounty>Bounties ({0} goodwill)</IntelKindBounty>

Source/CallForIntel.cs

Lines changed: 147 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,144 @@ public static void Choose(List<WeightedIntel> intel, Faction faction)
6060
}
6161
}
6262

63+
64+
public class Intel
65+
{
66+
public static List<Intel> PotentialIntel;
67+
68+
public Intel(string name, int cost, bool isIncident = false)
69+
{
70+
this.name = name;
71+
this.isIncident = isIncident;
72+
this.cost = cost;
73+
this.factions = null;
74+
}
75+
public Intel(string name, int cost, List<string> factions, bool isIncident = false)
76+
{
77+
this.name = name;
78+
this.isIncident = isIncident;
79+
this.cost = cost;
80+
this.factions = factions;
81+
}
82+
public Intel(List<string> names, int cost, bool isIncident = false)
83+
{
84+
this.names = names;
85+
this.isIncident = isIncident;
86+
this.cost = cost;
87+
this.factions = null;
88+
}
89+
public Intel(List<string> names, int cost, List<string> factions, bool isIncident = false)
90+
{
91+
this.names = names;
92+
this.isIncident = isIncident;
93+
this.cost = cost;
94+
this.factions = factions;
95+
}
96+
public Intel(Action action, int cost)
97+
{
98+
this.action = action;
99+
this.cost = cost;
100+
this.factions = null;
101+
}
102+
public Intel(Action action, int cost, List<string> factions)
103+
{
104+
this.action = action;
105+
this.cost = cost;
106+
this.factions = factions;
107+
}
108+
109+
string name;
110+
List<string> names;
111+
bool isIncident = false;
112+
113+
public Action action;
114+
115+
int cost;
116+
List<string> factions;
117+
118+
119+
// Override
120+
public bool ShouldInclude(Faction faction, Pawn negotiator)
121+
{
122+
if (factions != null && !factions.Contains(faction.def.defName))
123+
{
124+
return false;
125+
}
126+
127+
return true;
128+
}
129+
130+
public void Activate(Faction faction)
131+
{
132+
if (names != null)
133+
{
134+
name = names.RandomElement();
135+
}
136+
137+
if (action != null)
138+
{
139+
action.Invoke();
140+
} else if (isIncident)
141+
{
142+
var parms = new IncidentParms();
143+
IncidentDef incident = DefDatabase<IncidentDef>.GetNamed(name);
144+
bool execute = incident.Worker.TryExecute(parms);
145+
if (execute)
146+
{
147+
FactionDialogMakerPatch.ChargeGoodwill(faction, -cost);
148+
}
149+
else
150+
{
151+
// It is possible to fail a incident execution, in which case we do not charge goodwill
152+
faction.lastTraderRequestTick = Find.TickManager.TicksGame;
153+
Find.LetterStack.ReceiveLetter("IntelFailedLabel", "IntelFailedDialouge".Translate(faction.leader).CapitalizeFirst(), LetterDefOf.NeutralEvent);
154+
}
155+
} else
156+
{
157+
Slate slate = new Slate();
158+
slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(Find.World));
159+
slate.Set("asker", faction.leader);
160+
Quest newQuest = QuestUtility.GenerateQuestAndMakeAvailable(DefDatabase<QuestScriptDef>.GetNamed(name), slate);
161+
QuestUtility.SendLetterQuestAvailable(newQuest);
162+
FactionDialogMakerPatch.ChargeGoodwill(faction, -cost);
163+
}
164+
}
165+
166+
public List<Intel> GetMatchingIntel(Faction faction, Pawn negotiator)
167+
{
168+
List<Intel> matching = new List<Intel>();
169+
foreach (Intel intel in PotentialIntel)
170+
{
171+
if (intel.ShouldInclude(faction, negotiator))
172+
{
173+
matching.Add(intel);
174+
}
175+
}
176+
177+
return matching;
178+
}
179+
180+
}
181+
63182
#if V12
64183
[HarmonyPatch(typeof(FactionDialogMaker))]
65184
[HarmonyPatch("FactionDialogFor")]
66-
#elif V13
185+
#elif V13 || V14
67186
[HarmonyPatch(typeof(FactionDialogMaker), nameof(FactionDialogMaker.FactionDialogFor))]
68187
#endif
69188
public static class FactionDialogMakerPatch
70189
{
71190

72191
static string[] VikingHunts = { "VFEV_FenrirHunt", "VFEV_LothurrHunt", "VFEV_NjorunHunt", "VFEV_OdinHunt", "VFEV_ThrumboHunt" };
73192

74-
static void ChargeGoodwill(Faction faction, int amount)
193+
public static void ChargeGoodwill(Faction faction, int amount)
75194
{
76195
faction.lastTraderRequestTick = Find.TickManager.TicksGame;
77196

78197
// Function changed in 1.3 to use a HistoryEventDef instead of a translation string for "reason".
79198
#if V12
80199
faction.TryAffectGoodwillWith(Faction.OfPlayer, -amount, canSendMessage: false, canSendHostilityLetter: true, "GoodwillChangedReason_RequestedIntel".Translate());
81-
#elif V13
200+
#else
82201
faction.TryAffectGoodwillWith(Faction.OfPlayer, -amount, canSendMessage: false, canSendHostilityLetter: true, (HistoryEventDef)GenDefDatabase.GetDef(typeof(HistoryEventDef), "RequestedIntel"));
83202
#endif
84203
}
@@ -136,7 +255,11 @@ static void Postfix(Pawn negotiator, Faction faction, ref DiaNode __result)
136255
if (num > 0)
137256
{
138257
DiaOption failTime = new DiaOption(requestIntelString);
258+
#if V14
259+
failTime.Disable("WaitTime".Translate(GenDate.ToStringTicksToPeriod(num)));
260+
#else
139261
failTime.Disable("WaitTime".Translate(num.ToStringTicksToPeriod()));
262+
#endif
140263
__result.options.Insert(__result.options.Count - 1, failTime);
141264
return;
142265
}
@@ -179,6 +302,19 @@ static void Postfix(Pawn negotiator, Faction faction, ref DiaNode __result)
179302
nodeChoose.options.Add(optionBounty);
180303
}
181304

305+
// If Ideology is installed, work camps can be found
306+
#if !V12
307+
if (ModLister.IdeologyInstalled)
308+
{
309+
DiaOption optionCamp = new DiaOption("IntelKindCamp".Translate(5));
310+
optionCamp.link = nodeSent;
311+
optionCamp.action = delegate
312+
{
313+
GenerateIntelQuest(faction, "OpportunitySite_WorkSite", 5);
314+
};
315+
nodeChoose.options.Add(optionCamp);
316+
}
317+
#endif
182318
// Combat quests
183319
DiaOption optionCombat = new DiaOption("IntelKindCombat".Translate(10));
184320
optionCombat.link = nodeSent;
@@ -208,6 +344,14 @@ static void Postfix(Pawn negotiator, Faction faction, ref DiaNode __result)
208344
}));
209345
}
210346

347+
if (ModLister.RoyaltyInstalled)
348+
{
349+
list.Add(new WeightedIntel(30, delegate
350+
{
351+
GenerateIntelQuest(faction, "Mission_BanditCamp", 10);
352+
}));
353+
}
354+
211355
WeightedIntel.Choose(list, faction);
212356
};
213357
nodeChoose.options.Add(optionCombat);

Source/CallForIntel.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
<ErrorReport>prompt</ErrorReport>
3838
<DefineConstants>V13</DefineConstants>
3939
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'V14|AnyCPU'">
41+
<OutputPath>bin\V14\</OutputPath>
42+
<DefineConstants>V14</DefineConstants>
43+
<Optimize>true</Optimize>
44+
<PlatformTarget>AnyCPU</PlatformTarget>
45+
<LangVersion>7.3</LangVersion>
46+
<ErrorReport>prompt</ErrorReport>
47+
</PropertyGroup>
4048
<ItemGroup>
4149
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
4250
<SpecificVersion>False</SpecificVersion>

0 commit comments

Comments
 (0)