-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCEPrisonerDialogue.cs
279 lines (239 loc) · 16.9 KB
/
CEPrisonerDialogue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#define V127
using CaptivityEvents.Brothel;
using CaptivityEvents.Config;
using CaptivityEvents.Custom;
using CaptivityEvents.Events;
using CaptivityEvents.Helper;
using Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;
using TaleWorlds.CampaignSystem.GameMenus;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Settlements;
namespace CaptivityEvents
{
internal class CEPrisonerDialogue
{
private readonly Dynamics _dynamics = new();
public void AddPrisonerLines(CampaignGameStarter campaignGameStarter)
{
campaignGameStarter.AddDialogLine("CELordDefeatedLord", "start", "CELordDefeatedLordAnswer", "{=pURE9lFV}{SURRENDER_OFFER}", ConversationCEEventLordCaptureOnCondition, null, 200, null);
campaignGameStarter.AddPlayerLine("CELordDefeatedLordAnswerCapture", "CELordDefeatedLordAnswer", "defeat_lord_answer_1", "{=g5G8AJ5n}You are my prisoner now.", null, null, 100, null, null);
campaignGameStarter.AddPlayerLine("CELordDefeatedLordAnswerRelease", "CELordDefeatedLordAnswer", "defeat_lord_answer_2", "{=vHKkVkAF}You have fought well. You are free to go.", new ConversationSentence.OnConditionDelegate(LCELordDefeatedLordAnswerReleaseOnConditionCombatant), new ConversationSentence.OnConsequenceDelegate(LCELordDefeatedLordAnswerReleaseOnConsequence), 100, null, null);
campaignGameStarter.AddPlayerLine("CELordDefeatedLordAnswerReleaseNonCom", "CELordDefeatedLordAnswer", "defeat_lord_answer_2", "{=SFWNy76G}As you are not a warrior, you are free to go.", new ConversationSentence.OnConditionDelegate(LCELordDefeatedLordAnswerReleaseOnConditionNoncombatant), new ConversationSentence.OnConsequenceDelegate(LCELordDefeatedLordAnswerReleaseOnConsequence), 100, null, null);
campaignGameStarter.AddPlayerLine("CELordDefeatedLordAnswerStrip", "CELordDefeatedLordAnswer", "LordDefeatedCaptureCEModAnswer", "{=CEEVENTS1107}Time to strip you of your belongings.", null, ConversationCEEventLordCaptureOnConsequence);
campaignGameStarter.AddPlayerLine("LordDefeatedCaptureCEMod", "defeated_lord_answer", "LordDefeatedCaptureCEModAnswer", "{=CEEVENTS1107}Time to strip you of your belongings.", null, ConversationCEEventLordCaptureOnConsequence);
campaignGameStarter.AddDialogLine("LordDefeatedReturn", "LordDefeatedCaptureCEModAnswer", "close_window", "{=!}{RESPONSE_STRING}", ConversationCEEventResponseInPartyOnCondition, null);
campaignGameStarter.AddDialogLine("start_wanderer_unmet_party", "start", "prisoner_recruit_start_player", "{=!}{RESPONSE_STRING}", ConversationConditionTalkToPrisonerInParty, null, 120);
campaignGameStarter.AddDialogLine("start_wanderer_unmet_party", "lord_introduction", "prisoner_recruit_start_player", "{=!}{RESPONSE_STRING}", ConversationConditionTalkToPrisonerInParty, null, 120);
campaignGameStarter.AddDialogLine("start_wanderer_unmet_cell", "start", "CEPrisonerInCell", "{=!}{RESPONSE_STRING}", ConversationConditionTalkToPrisonerInCell, null, 120);
campaignGameStarter.AddDialogLine("start_wanderer_unmet_cell", "lord_introduction", "CEPrisonerInCell", "{=!}{RESPONSE_STRING}", ConversationConditionTalkToPrisonerInCell, null, 120);
campaignGameStarter.AddPlayerLine("PrisonerPrisonerInParty_01", "CEPrisonerInParty", "PrisonerPrisonerInPartyResponse", "{=CEEVENTS1108}Time to have some fun.", null, ConversationCEEventInPartyOnConsequence);
campaignGameStarter.AddPlayerLine("PrisonerPrisonerInParty_02", "CEPrisonerInParty", "close_window", "{=CEEVENTS1051}Nevermind.", null, null);
campaignGameStarter.AddPlayerLine("PrisonerPrisonerInParty", "prisoner_recruit_start_player", "PrisonerPrisonerInPartyResponse", "{=CEEVENTS1108}Time to have some fun.", null, ConversationCEEventInPartyOnConsequence);
campaignGameStarter.AddDialogLine("PrisonerPrisonerInPartyResponseChat", "PrisonerPrisonerInPartyResponse", "close_window", "{=!}{RESPONSE_STRING}", ConversationCEEventResponseInPartyOnCondition, null);
campaignGameStarter.AddPlayerLine("CEPrisonerInCell_01", "CEPrisonerInCell", "CEPrisonerInCell_01_response", "{=CEEVENTS1052}You are coming with me.", null, null);
if (CESettings.Instance?.ProstitutionControl ?? true) campaignGameStarter.AddPlayerLine("CEPrisonerInCell_02", "CEPrisonerInCell", "CEPrisonerInCell_02_response", "{=CEBROTHEL0979}Time to make you work at the brothel.", null, null, 100, ConversationCEEventBrothelOnCondition);
campaignGameStarter.AddDialogLine("CEPrisonerInCell_01_r", "CEPrisonerInCell_01_response", "close_window", "{=!}{RESPONSE_STRING}", ConversationCEEventResponseInPartyOnCondition, ConversationCEEventInCellOnConsequence);
campaignGameStarter.AddDialogLine("CEPrisonerInCell_02_r", "CEPrisonerInCell_02_response", "close_window", "{=!}{RESPONSE_STRING}", ConversationCEEventResponseInPartyOnCondition, ConversationCEEventBrothelOnConsequence);
campaignGameStarter.AddPlayerLine("CEPrisonerInCell_02", "CEPrisonerInCell", "close_window", "{=CEEVENTS1051}Nevermind.", null, null);
}
public bool LCELordDefeatedLordAnswerReleaseOnConditionNoncombatant()
{
return (Hero.OneToOneConversationHero.Clan == null || Hero.OneToOneConversationHero.Clan.IsMapFaction || Hero.OneToOneConversationHero.Clan.Leader != Hero.OneToOneConversationHero) &&
Hero.OneToOneConversationHero.IsNoncombatant;
}
public bool LCELordDefeatedLordAnswerReleaseOnConditionCombatant()
{
return (Hero.OneToOneConversationHero.Clan != null && !Hero.OneToOneConversationHero.Clan.IsMapFaction && Hero.OneToOneConversationHero.Clan.Leader == Hero.OneToOneConversationHero) || !
Hero.OneToOneConversationHero.IsNoncombatant;
}
public void AddCustomLines(CampaignGameStarter campaignGameStarter, List<CEScene> CECustomScenes)
{
try
{
foreach (CEScene CustomScene in CECustomScenes)
{
foreach (Line CustomLine in CustomScene.Dialogue.Lines)
{
if (CustomLine.Ref != null && CustomLine.Ref.ToLower() == "ai")
{
campaignGameStarter.AddDialogLine(CustomLine.Id, CustomLine.InputToken, CustomLine.OutputToken, CustomLine.Text, () => { return ConversationCECustomScenesOnCondition(CustomScene.Name, CustomLine.Condition != null && CustomLine.Condition.ToLower() == "true"); }, () => ConversationCECustomScenesOnConsequence(CustomLine)
);
}
else
{
campaignGameStarter.AddPlayerLine(CustomLine.Id, CustomLine.InputToken, CustomLine.OutputToken, CustomLine.Text, null, () => ConversationCECustomScenesOnConsequence(CustomLine)
);
}
}
}
}
catch (Exception e)
{
TextObject textObject = new("{=CEEVENTS0999}Error: failed to initialize scenes");
InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Red));
CECustomHandler.ForceLogToFile("Error: failed to initialize scenes");
CECustomHandler.ForceLogToFile(e.Message + " : " + e);
}
}
private bool ConversationCECustomScenesOnCondition(string SceneName, bool alwaysShow = false)
{
CharacterObject conversation = CharacterObject.OneToOneConversationCharacter;
return alwaysShow || conversation.StringId == "CECustomStringId_" + SceneName;
}
private void ConversationCECustomScenesOnConsequence(Line CustomLine)
{
if (CustomLine.Consequence != null)
{
switch (CustomLine.Consequence.ToLower())
{
case "afterbattle":
CEPersistence.battleState = CEPersistence.BattleState.AfterBattle;
break;
}
}
if (CustomLine.OutputToken == "close_window")
{
CharacterObject.OneToOneConversationCharacter.StringId = "";
if (CustomLine.NextScene != null)
{
try
{
GameMenu.SwitchToMenu(CustomLine.NextScene);
}
catch (Exception)
{
CECustomHandler.LogToFile("NextScene Failed - " + CustomLine.Id);
}
}
}
}
private bool ConversationCEEventBrothelOnCondition(out TextObject text)
{
text = TextObject.Empty;
if (Settlement.CurrentSettlement != null && CEBrothelBehavior.DoesOwnBrothelInSettlement(Settlement.CurrentSettlement))
{
return true;
}
text = new TextObject("{=}You do not own the brothel in this settlement.");
return false;
}
private void LCELordDefeatedLordAnswerReleaseOnConsequence()
{
if (Hero.OneToOneConversationHero.IsPrisoner)
{
EndCaptivityAction.ApplyByReleasedAfterBattle(Hero.OneToOneConversationHero);
}
_dynamics.RelationsModifier(CharacterObject.OneToOneConversationCharacter.HeroObject, 4, null, true, true);
DialogHelper.SetDialogString("DEFEAT_LORD_ANSWER", "str_prisoner_released");
}
private bool ConversationCEEventLordCaptureOnCondition()
{
if (Campaign.Current.CurrentConversationContext == ConversationContext.CapturedLord && Hero.OneToOneConversationHero != null && Hero.OneToOneConversationHero.MapFaction != null && Hero.OneToOneConversationHero.MapFaction.IsBanditFaction)
{
GameState currentState = Game.Current.GameStateManager.ActiveState;
DialogHelper.SetDialogString("SURRENDER_OFFER", "str_surrender_offer");
return true;
}
return false;
}
private void ConversationCEEventBrothelOnConsequence()
{
CharacterObject captive = CharacterObject.OneToOneConversationCharacter;
captive.HeroObject.PartyBelongedToAsPrisoner.AddPrisoner(captive, -1);
PartyBase.MainParty.AddPrisoner(captive, 1);
CEBrothelBehavior.AddBrothelPrisoner(Settlement.CurrentSettlement, captive);
}
private void ConversationCEEventLordCaptureOnConsequence()
{
Campaign.Current.CurrentConversationContext = ConversationContext.Default;
new CaptorSpecifics().CECaptorStripVictim(CharacterObject.OneToOneConversationCharacter.HeroObject);
if (CharacterObject.OneToOneConversationCharacter.HeroObject.GetSkillValue(CESkills.Slavery) < 50) new Dynamics().RelationsModifier(CharacterObject.OneToOneConversationCharacter.HeroObject, -10);
TakePrisonerAction.Apply(Campaign.Current.MainParty.Party, CharacterObject.OneToOneConversationCharacter.HeroObject);
}
private bool ConversationConditionTalkToPrisonerInCell()
{
CharacterObject captive = CharacterObject.OneToOneConversationCharacter;
if (captive != null && captive.IsHero && captive.HeroObject.GetSkillValue(CESkills.IsSlave) == 1)
{
if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 250) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1053}Yes you came {?PLAYER.GENDER}mistress{?}master{\\?}! [ib:confident][rb:very_positive]");
else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 100) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1054}Yes {?PLAYER.GENDER}mistress{?}master{\\?} [ib:weary][rb:positive]");
else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 50) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1055}Yes? [ib:weary][rb:unsure]");
else MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1072}I am not your slave! [ib:aggressive][rb:very_negative]");
}
else
{
MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1057}What do you want? [ib:nervous][rb:very_negative]");
}
return Hero.OneToOneConversationHero != null && Hero.OneToOneConversationHero.PartyBelongedToAsPrisoner != null && Hero.OneToOneConversationHero.PartyBelongedToAsPrisoner.IsSettlement && Hero.OneToOneConversationHero.PartyBelongedToAsPrisoner.Settlement.OwnerClan == Clan.PlayerClan && Hero.OneToOneConversationHero.HeroState == Hero.CharacterStates.Prisoner;
}
private bool ConversationConditionTalkToPrisonerInParty()
{
CharacterObject captive = CharacterObject.OneToOneConversationCharacter;
if (captive != null && captive.IsHero && captive.HeroObject.GetSkillValue(CESkills.IsSlave) == 1)
{
if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 250) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1053}Yes you came {?PLAYER.GENDER}mistress{?}master{\\?}! [ib:confident][rb:very_positive]");
else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 100) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1054}Yes {?PLAYER.GENDER}mistress{?}master{\\?} [ib:weary][rb:positive]");
else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 50) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1055}Yes? [ib:weary][rb:unsure]");
else MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1072}I am not your slave! [ib:aggressive][rb:very_negative]");
}
else
{
MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1057}What do you want? [ib:nervous][rb:very_negative]");
}
return Hero.OneToOneConversationHero != null && Hero.OneToOneConversationHero.PartyBelongedToAsPrisoner == PartyBase.MainParty && Hero.OneToOneConversationHero.PartyBelongedToAsPrisoner.IsMobile && Hero.OneToOneConversationHero.HeroState == Hero.CharacterStates.Prisoner;
}
private bool ConversationCEEventResponseInPartyOnCondition()
{
try
{
CharacterObject captive = CharacterObject.OneToOneConversationCharacter;
if (captive != null && captive.IsHero && captive.HeroObject.GetSkillValue(CESkills.IsSlave) == 1)
{
if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 250) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1073}Finally![ib:confident][rb:very_positive]");
else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 100) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1071}Yes {?PLAYER.GENDER}mistress{?}master{\\?} [ib:confident2][rb:positive]");
else if (captive.HeroObject.GetSkillValue(CESkills.Slavery) > 50) MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1070}Alright.[ib:weary][rb:unsure]");
else MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1072}What?! [ib:aggressive][rb:very_negative]");
}
else
{
MBTextManager.SetTextVariable("RESPONSE_STRING", "{=CEEVENTS1109}Wait what?[ib:nervous][rb:very_negative]");
}
}
catch (Exception e)
{
CECustomHandler.ForceLogToFile("Failed to launch ConversationCEEventResponseInPartyOnCondition : " + e);
}
return true;
}
private void ConversationCEEventInPartyOnConsequence()
{
CEPersistence.captivePlayEvent = true;
CEPersistence.captiveToPlay = CharacterObject.OneToOneConversationCharacter;
}
private void ConversationCEEventInCellOnConsequence()
{
try
{
CEPersistence.captivePlayEvent = true;
CEPersistence.captiveToPlay = CharacterObject.OneToOneConversationCharacter;
CEPersistence.gameEntity = Mission.Current.Scene.GetFirstEntityWithName("_barrier_passage_center");
CEPersistence.agentTalkingTo = Mission.Current.Agents.FirstOrDefault(agent => agent.Character == CharacterObject.OneToOneConversationCharacter);
CEPersistence.dungeonState = CEPersistence.DungeonState.StartWalking;
}
catch (Exception e)
{
CECustomHandler.ForceLogToFile("Failed to launch ConversationCEEventInCellOnConsequence : " + e);
}
}
}
}