@@ -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 ) ;
0 commit comments