-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cs
More file actions
1855 lines (1756 loc) · 104 KB
/
Test.cs
File metadata and controls
1855 lines (1756 loc) · 104 KB
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using TaleWorlds.CampaignSystem;
using SandBox.View.Map;
using TaleWorlds.CampaignSystem.GameMenus;
using TaleWorlds.CampaignSystem.Overlay;
using TaleWorlds.Core;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.Localization;
using TaleWorlds.CampaignSystem.SandBox;
using TaleWorlds.MountAndBlade;
using TaleWorlds.ObjectSystem;
using System.Reflection;
using System.Linq;
using SandBox;
using System.Collections.Generic;
using SandBox.Source.Missions;
using SandBox.Source.Missions.Handlers;
using TaleWorlds.MountAndBlade.Source.Missions;
using TaleWorlds.MountAndBlade.Source.Missions.Handlers;
using Helpers;
namespace FreelancerTemplate
{
class Test : CampaignBehaviorBase
{
public static Hero followingHero;
public static CampaignTime enlistTime;
public static bool disbandArmy;
public static int EnlistTier;
public static int xp;
private static Dictionary<IFaction, int> FactionReputation = new Dictionary<IFaction, int>();
private static Dictionary<IFaction, int> retirementXP = new Dictionary<IFaction, int>();
private static Dictionary<Hero, int> LordReputation = new Dictionary<Hero, int>();
private static List<IFaction> kingVassalOffered = new List<IFaction>();
public static ItemRoster oldItems = new ItemRoster();
public static ItemRoster oldGear = new ItemRoster();
public static ItemRoster tournamentPrizes = new ItemRoster();
public static bool AllBattleCommands = false;
public static bool disable_XP = false;
public static string conversation_type = "";
public static Assignment currentAssignment;
private Settlement selected_selement;
public static Settlement Tracked;
public static Settlement Untracked;
public static bool OngoinEvent = false;
public static bool NoRetreat = false;
private MobileParty CavalryDetachment;
private int[] NextlevelXP = new int[] {0, 600, 1700, 3400, 6000, 9400, 14000, 20000};
public override void RegisterEvents()
{
if (SubModule.settings != null)
{
NextlevelXP[1] = SubModule.settings.Level1XP;
NextlevelXP[2] = SubModule.settings.Level2XP;
NextlevelXP[3] = SubModule.settings.Level3XP;
NextlevelXP[4] = SubModule.settings.Level4XP;
NextlevelXP[5] = SubModule.settings.Level5XP;
NextlevelXP[6] = SubModule.settings.Level6XP;
NextlevelXP[7] = SubModule.settings.Level7XP;
}
CampaignEvents.OnSessionLaunchedEvent.AddNonSerializedListener((object)this, new Action<CampaignGameStarter>(OnSessionLaunched));
CampaignEvents.TickEvent.AddNonSerializedListener((object)this, new Action<float>(Tick));
CampaignEvents.HourlyTickEvent.AddNonSerializedListener((object)this, new Action(Tick2));
CampaignEvents.DailyTickEvent.AddNonSerializedListener((object)this, new Action(TickDaily));
CampaignEvents.SettlementEntered.AddNonSerializedListener(this, new Action<MobileParty, Settlement, Hero>(this.OnSettlementEntered));
CampaignEvents.OnSettlementLeftEvent.AddNonSerializedListener(this, new Action<MobileParty, Settlement>(this.OnSettlementLeftEvent));
}
private void OnSettlementLeftEvent(MobileParty party, Settlement settlement)
{
if(party.LeaderHero != null && party.LeaderHero == followingHero)
{
GameMenu.ActivateGameMenu("party_wait");
}
}
private void OnSettlementEntered(MobileParty party, Settlement settlement, Hero hero)
{
if(followingHero != null && hero == followingHero)
{
GameMenu.ActivateGameMenu("party_wait");
if (settlement.IsTown)
{
Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop;
}
}
}
private void TickDaily()
{
if (followingHero != null)
{
GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, wage());
ChangeFactionRelation(followingHero.MapFaction, 10);
int XPAmount = SubModule.settings == null ? 10 : SubModule.settings.DailyXP;
ChangeLordRelation(followingHero, XPAmount);
xp += XPAmount;
GetXPForRole();
}
}
private void GetXPForRole()
{
switch (currentAssignment)
{
case Assignment.Grunt_Work:
Hero.MainHero.AddSkillXp(DefaultSkills.Athletics, 100);
return;
case Assignment.Guard_Duty:
Hero.MainHero.AddSkillXp(DefaultSkills.Scouting, 100);
return;
case Assignment.Foraging:
Hero.MainHero.AddSkillXp(DefaultSkills.Riding, 100);
if(followingHero != null && followingHero.PartyBelongedTo != null)
{
followingHero.PartyBelongedTo.ItemRoster.AddToCounts(MBObjectManager.Instance.GetObject<ItemObject>("grain"), MBRandom.RandomInt(5));
}
return;
case Assignment.Cook:
Hero.MainHero.AddSkillXp(DefaultSkills.Steward, 100);
return;
case Assignment.Sergeant:
Hero.MainHero.AddSkillXp(DefaultSkills.Leadership, 100);
if (followingHero != null && followingHero.PartyBelongedTo != null)
{
AddXPToRandomTroop();
}
return;
default :
return;
}
}
private void AddXPToRandomTroop()
{
List<CharacterObject> list = new List<CharacterObject>();
foreach(TroopRosterElement troop in followingHero.PartyBelongedTo.MemberRoster.GetTroopRoster())
{
if(!troop.Character.IsHero && (troop.Character.UpgradeTargets == null || troop.Character.UpgradeTargets.Length == 0))
{
list.Add(troop.Character);
}
}
if(list.Count > 0)
{
followingHero.PartyBelongedTo.MemberRoster.AddXpToTroop(500, list.GetRandomElement());
}
}
private int wage()
{
return Math.Max(0, Math.Min(Hero.MainHero.Level * 2 + (xp/10), 1000));
}
private void Tick2()
{
if (followingHero != null)
{
if (followingHero.PartyBelongedTo.MapEvent == null)
{
GameMenu.ActivateGameMenu("party_wait");
}
if (followingHero.CurrentSettlement != null)
{
Hero.MainHero.Heal(PartyBase.MainParty, 3 * healAmount(), true);
}
else
{
Hero.MainHero.Heal(PartyBase.MainParty, healAmount(), true);
}
bool leveledUp = false;
while(EnlistTier < 7 && xp > NextlevelXP[EnlistTier])
{
EnlistTier++;
leveledUp = true;
}
if(kingVassalOffered == null)
{
kingVassalOffered = new List<IFaction>();
}
if(retirementXP == null)
{
retirementXP = new Dictionary<IFaction, int>();
}
if (!retirementXP.ContainsKey(followingHero.MapFaction))
{
retirementXP.Add(followingHero.MapFaction, 10000);
}
int retirementXPNeeded;
retirementXP.TryGetValue(followingHero.MapFaction, out retirementXPNeeded);
if (leveledUp)
{
conversation_type = "promotion";
TextObject text = new TextObject("{=FLT0000000}{HERO} has been promoted to tier {TIER}");
text.SetTextVariable("HERO", Hero.MainHero.Name.ToString());
text.SetTextVariable("TIER", EnlistTier.ToString());
InformationManager.AddQuickInformation(text, announcerCharacter: Hero.MainHero.CharacterObject);
Campaign.Current.ConversationManager.AddDialogFlow(CreatePromotionDialog());
CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false), new ConversationCharacterData(followingHero.CharacterObject, null, false, false, false, false));
}
else if (!kingVassalOffered.Contains(followingHero.MapFaction) && GetFactionRelations(followingHero.MapFaction) >= 20000 && !leveledUp)
{
if (followingHero.IsFactionLeader)
{
conversation_type = "vassalage2";
Campaign.Current.ConversationManager.AddDialogFlow(KingdomJoinCreateDialog2());
CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false), new ConversationCharacterData(followingHero.CharacterObject, null, false, false, false, false));
}
else
{
conversation_type = "vassalage";
Campaign.Current.ConversationManager.AddDialogFlow(KingdomJoinCreateDialog());
CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false), new ConversationCharacterData(followingHero.CharacterObject, null, false, false, false, false));
}
kingVassalOffered.Add(followingHero.MapFaction);
}
else if(xp > retirementXPNeeded)
{
conversation_type = "retirement";
Campaign.Current.ConversationManager.AddDialogFlow(RetirementCreateDialog());
CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false), new ConversationCharacterData(followingHero.CharacterObject, null, false, false, false, false));
}
}
else
{
Tracked = null;
Untracked = null;
}
}
private DialogFlow RetirementCreateDialog()
{
TextObject textObject = new TextObject("{=FLT0000001}{HERO}, you have served long enough to fulfill your enlistment. You can honorably retire and keep your gear, but I have need for talented soldiers. I will offer you a bonus of 25000 {COIN} if you are willing to reenlist");
TextObject textObject2 = new TextObject("{=FLT0000002}I will reenlist");
TextObject textObject3 = new TextObject("{=FLT0000003}I will retire");
textObject.SetTextVariable("COIN", "<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
return DialogFlow.CreateDialogFlow("start", 125).NpcLine(textObject, null, null).Condition(delegate
{
if (followingHero != null)
{
textObject.SetTextVariable("HERO", Hero.MainHero.EncyclopediaLinkWithName);
}
return Hero.OneToOneConversationHero == followingHero && conversation_type == "retirement"; ;
}).Consequence(delegate
{
conversation_type = null;
}).BeginPlayerOptions().PlayerOption(textObject2, null).Consequence(delegate {
ChangeRelationAction.ApplyPlayerRelation(followingHero, 20);
GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 25000);
retirementXP.Remove(followingHero.MapFaction);
retirementXP.Add(followingHero.MapFaction, xp + 5000);
}).CloseDialog().PlayerOption(textObject3, null).Consequence(delegate () {
ChangeFactionRelation(followingHero.MapFaction, -100000);
foreach (Clan clan in followingHero.Clan.Kingdom.Clans)
{
if (!clan.IsUnderMercenaryService)
{
foreach (Hero lord in clan.Heroes)
{
if (lord.IsNoble)
{
ChangeLordRelation(lord, -100000);
}
}
}
}
ChangeRelationAction.ApplyPlayerRelation(followingHero, 20);
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
LeaveLordPartyAction(true);
}).CloseDialog().EndPlayerOptions().CloseDialog();
}
private int healAmount()
{
return 1 + (Hero.MainHero.GetSkillValue(DefaultSkills.Medicine) / 100) + (MBRandom.RandomInt(100) < (Hero.MainHero.GetSkillValue(DefaultSkills.Medicine) % 100) ? 1 : 0);
}
private DialogFlow KingdomJoinCreateDialog2()
{
TextObject textObject = new TextObject("{=FLT0000004}{HERO}, you have shown yourself to be a warrior with no equal. Hundreds of my enemies have died by your hands. I need people like you in my kingdom. I am willing to make you a vassal of my realm. I will give you a generous bonus if you agree");
TextObject textObject2 = new TextObject("{=FLT0000005}I will grant you the settlement of {FIEF} as your personal fief as a reward for your service");
TextObject textObject3 = new TextObject("{=FLT0000006}My place is as a soldier on the battlefield");
TextObject textObject4 = new TextObject("{=FLT0000007}Talk to me again if you change your mind");
TextObject textObject5 = new TextObject("{=FLT0000008}It would be a honor to serve you my liege");
TextObject textObject6 = new TextObject("{=FLT0000009}I will grant you a sum of 500000 {COIN} as a reward for your service");
textObject6.SetTextVariable("COIN", "<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
return DialogFlow.CreateDialogFlow("start", 125).NpcLine(textObject, null, null).Condition(delegate
{
textObject.SetTextVariable("HERO", Hero.MainHero.EncyclopediaLinkWithName);
return conversation_type == "vassalage2"; ;
}).Consequence(delegate
{
conversation_type = null;
}).BeginPlayerOptions().PlayerOption(textObject3, null).NpcLine(textObject4).CloseDialog().PlayerOption(textObject5, null).Consequence(delegate () {
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
LeaveLordPartyAction(true);
}).BeginNpcOptions().NpcOption(textObject2, delegate {
selected_selement = null;
List<Settlement> list = new List<Settlement>();
foreach(Settlement settlement in Hero.OneToOneConversationHero.Clan.Kingdom.Settlements)
{
if (settlement.IsTown)
{
list.Add(settlement);
}
}
if(list.Count < 1)
{
foreach (Settlement settlement in Hero.OneToOneConversationHero.Clan.Kingdom.Settlements)
{
if (settlement.IsCastle)
{
list.Add(settlement);
}
}
}
if(list.Count > 0)
{
selected_selement = list.GetRandomElement();
textObject2.SetTextVariable("FIEF", selected_selement.EncyclopediaLinkWithName);
}
return selected_selement != null;
}).Consequence(delegate{
ChangeKingdomAction.ApplyByJoinToKingdom(Hero.MainHero.Clan, Hero.OneToOneConversationHero.Clan.Kingdom);
ChangeOwnerOfSettlementAction.ApplyByGift(selected_selement, Hero.MainHero);
kingVassalOffered.Remove(Hero.OneToOneConversationHero.MapFaction);
}).CloseDialog().NpcOption(textObject6, delegate {
return true;
}).Consequence(delegate {
ChangeKingdomAction.ApplyByJoinToKingdom(Hero.MainHero.Clan, Hero.OneToOneConversationHero.Clan.Kingdom);
GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 500000);
kingVassalOffered.Remove(Hero.OneToOneConversationHero.MapFaction);
}).CloseDialog().EndNpcOptions().CloseDialog().EndPlayerOptions().CloseDialog();
}
private DialogFlow KingdomJoinCreateDialog()
{
TextObject textObject = new TextObject("{=FLT0000010}{HERO}, I recieved a message from {KING}, the leader of our kingdom. {KING_GENDER_PRONOUN} would like to speak with you personally about offering you a lordship in our kingdom. You have permission to leave my warband");
TextObject textObject2 = new TextObject("{=FLT0000011}I rather stay here");
TextObject textObject3 = new TextObject("{=FLT0000012}I will take my leave then");
return DialogFlow.CreateDialogFlow("start", 125).NpcLine(textObject, null, null).Condition(delegate
{
if(followingHero != null)
{
textObject.SetTextVariable("HERO", Hero.MainHero.EncyclopediaLinkWithName);
textObject.SetTextVariable("KING", followingHero.Clan.Kingdom.Leader.EncyclopediaLinkWithName);
textObject.SetTextVariable("KING_GENDER_PRONOUN", followingHero.Clan.Kingdom.Leader.IsFemale ? "She" : "He");
}
return conversation_type == "vassalage"; ;
}).Consequence(delegate
{
conversation_type = null;
}).BeginPlayerOptions().PlayerOption(textObject2, null).CloseDialog().PlayerOption(textObject3, null).Consequence(delegate () {
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
LeaveLordPartyAction(true);
}).CloseDialog().EndPlayerOptions().CloseDialog();
}
private DialogFlow CreatePromotionDialog()
{
TextObject textObject = new TextObject("{=FLT0000013}{HERO}, you have proven yourself to be a fine warrior. For your bravery and loyalty, I have decided to give you a promotion. Visit my blade smith and armourer in the camp and they will provide you with the gear befitting your new rank");
TextObject textObject2 = new TextObject("{=FLT0000014}It is a honor my lord");
return DialogFlow.CreateDialogFlow("start", 125).NpcLine(textObject, null, null).Condition(delegate
{
textObject.SetTextVariable("HERO", Hero.MainHero.EncyclopediaLinkWithName);
return conversation_type == "promotion"; ;
}).Consequence(delegate
{
conversation_type = null;
if (followingHero != null)
{
ChangeRelationAction.ApplyPlayerRelation(followingHero, 2 * EnlistTier);
}
Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop;
}).BeginPlayerOptions().PlayerOption(textObject2, null).CloseDialog().EndPlayerOptions().CloseDialog();
}
private void Tick(float f)
{
if (Hero.MainHero.IsPrisoner && MobileParty.MainParty != null)
{
MobileParty.MainParty.IgnoreByOtherPartiesTill(CampaignTime.DaysFromNow(1f));
}
if (followingHero != null)
{
if (followingHero.PartyBelongedTo != null && !followingHero.IsPrisoner && !Hero.MainHero.IsPrisoner && followingHero.IsAlive)
{
if(CavalryDetachment != null && CavalryDetachment.MapEvent == null)
{
foreach (TroopRosterElement troop in CavalryDetachment.MemberRoster.GetTroopRoster())
{
followingHero.PartyBelongedTo.MemberRoster.AddToCounts(troop.Character, troop.Number);
}
DestroyPartyAction.Apply(followingHero.PartyBelongedTo.Party, CavalryDetachment);
CavalryDetachment = null;
}
if (disbandArmy && followingHero.PartyBelongedTo.Army != null && followingHero.PartyBelongedTo.MapEvent == null)
{
followingHero.PartyBelongedTo.Army.DisperseArmy();
disbandArmy = false;
}
if (MobileParty.MainParty.Army != null && followingHero.PartyBelongedTo.MapEvent == null)
{
MobileParty.MainParty.Army = (Army)null;
}
if (Campaign.Current.CurrentMenuContext == null)
{
GameMenu.ActivateGameMenu("party_wait");
}
if(MobileParty.MainParty.CurrentSettlement != null)
{
LeaveSettlementAction.ApplyForParty(MobileParty.MainParty);
}
UpdateDiplomacy();
MobileParty.MainParty.Position2D = followingHero.PartyBelongedTo.Position2D;
followingHero.PartyBelongedTo.Party.SetAsCameraFollowParty();
hidePlayerParty();
MobileParty.MainParty.IsActive = false;
disable_XP = false;
NoRetreat = false;
if (followingHero.PartyBelongedTo.MapEvent != null && MobileParty.MainParty.MapEvent == null)
{
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
if (followingHero.PartyBelongedTo.Army == null)
{
followingHero.PartyBelongedTo.ActualClan.Kingdom.CreateArmy(followingHero.PartyBelongedTo.LeaderHero, Hero.MainHero.HomeSettlement, Army.ArmyTypes.Patrolling);
disbandArmy = true;
}
else if(followingHero.PartyBelongedTo.AttachedTo == null && followingHero.PartyBelongedTo.Army != null && followingHero.PartyBelongedTo != followingHero.PartyBelongedTo.Army.LeaderParty)
{
followingHero.PartyBelongedTo.Army = (Army)null;
followingHero.PartyBelongedTo.ActualClan.Kingdom.CreateArmy(followingHero.PartyBelongedTo.LeaderHero, Hero.MainHero.HomeSettlement, Army.ArmyTypes.Patrolling);
disbandArmy = true;
}
followingHero.PartyBelongedTo.Army.AddPartyToMergedParties(MobileParty.MainParty);
MobileParty.MainParty.Army = followingHero.PartyBelongedTo.Army;
MobileParty.MainParty.IsActive = true;
MobileParty.MainParty.SetMoveEngageParty(followingHero.PartyBelongedTo);
if (followingHero != null && followingHero.PartyBelongedTo != null && followingHero.PartyBelongedTo.MapEvent != null && !followingHero.PartyBelongedTo.MapEvent.IsSiegeAssault)
{
typeof(MapEvent).GetMethod("CheckNearbyPartiesToJoinMainPlayerMapEventBattle", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static).Invoke(followingHero.PartyBelongedTo.MapEvent, new object[] {});
}
}
}
else //If party gets destoryed
{
LeaveLordPartyAction(false);
}
}
}
public static void LeaveLordPartyAction(bool keepgear)
{
MobileParty.MainParty.IsActive = true;
UndoDiplomacy();
showPlayerParty();
followingHero = null;
if (!keepgear)
{
GetOldGear();
equipGear();
GetTournamentPrizes();
}
if(PlayerEncounter.Current != null)
{
PlayerEncounter.Finish(true);
}
TransferAllItems(oldItems, MobileParty.MainParty.ItemRoster);
}
private static void GetTournamentPrizes()
{
if (tournamentPrizes == null)
{
tournamentPrizes = new ItemRoster();
}
foreach(ItemRosterElement item in tournamentPrizes)
{
MobileParty.MainParty.ItemRoster.AddToCounts(item.EquipmentElement, item.Amount);
}
}
private void OnSessionLaunched(CampaignGameStarter campaignStarter)
{
if (kingVassalOffered == null)
{
kingVassalOffered = new List<IFaction>();
}
TextObject textObject1 = new TextObject("{=FLT0000015}Let me join your warband");
campaignStarter.AddPlayerLine("join_legions_start", "lord_talk_speak_diplomacy_2", "join_legions_response", textObject1.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return CharacterObject.OneToOneConversationCharacter.HeroObject != null && CharacterObject.OneToOneConversationCharacter.HeroObject.PartyBelongedTo != null && CharacterObject.OneToOneConversationCharacter.HeroObject.PartyBelongedTo.LeaderHero == CharacterObject.OneToOneConversationCharacter.HeroObject && followingHero == null && !CharacterObject.OneToOneConversationCharacter.HeroObject.Clan.IsMinorFaction && Hero.MainHero.Clan.Kingdom == null && CharacterObject.OneToOneConversationCharacter.HeroObject.CurrentSettlement == null && CharacterObject.OneToOneConversationCharacter.HeroObject.Clan.Kingdom != null;
}),(ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject2 = new TextObject("{=FLT0000016}There is no way I would let a wanted criminal like you join my ranks");
campaignStarter.AddDialogLine("join_legions_response_a", "join_legions_response", "lord_pretalk", textObject2.ToString(), new ConversationSentence.OnConditionDelegate (()=>{
return CharacterObject.OneToOneConversationCharacter.HeroObject.MapFaction.MainHeroCrimeRating > 30;
}), (ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject3 = new TextObject("{=FLT0000017}I don't want you in my warband. You and I don't get along");
campaignStarter.AddDialogLine("join_legions_response_b", "join_legions_response", "lord_pretalk", textObject3.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return CharacterObject.OneToOneConversationCharacter.HeroObject.GetRelationWithPlayer() <= -10;
}), (ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject4 = new TextObject("{=FLT0000018}About that lordship you offered me");
campaignStarter.AddPlayerLine("join_faction_start", "lord_talk_speak_diplomacy_2", "join_faction_response", textObject4.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return CharacterObject.OneToOneConversationCharacter.HeroObject != null && !CharacterObject.OneToOneConversationCharacter.HeroObject.Clan.IsMinorFaction && Hero.MainHero.Clan.Kingdom == null && CharacterObject.OneToOneConversationCharacter.HeroObject.IsFactionLeader && kingVassalOffered.Contains(CharacterObject.OneToOneConversationCharacter.HeroObject.MapFaction);
}), (ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject5 = new TextObject("{=FLT0000019}{HERO}, you have shown yourself to be a warrior with no equal. Hundreds of my enemies have died by your hands. I need people like you in my kingdom");
textObject5.SetTextVariable("HERO", Hero.MainHero.EncyclopediaLinkWithName);
campaignStarter.AddDialogLine("join_faction_lord_response", "join_faction_response", "join_faction_response_2", textObject5.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return true; ;
}), (ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject6 = new TextObject("{=FLT0000020}It would be a honor to serve you my liege");
campaignStarter.AddPlayerLine("join_faction_player_response_a", "join_faction_response_2", "join_faction_response_3", textObject6.ToString() , new ConversationSentence.OnConditionDelegate(() => {
return true;
}), (ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject7 = new TextObject("{=FLT0000021}I change my mind");
campaignStarter.AddPlayerLine("join_faction_player_response_b", "join_faction_response_2", "lord_pretalk", textObject7.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return true;
}), (ConversationSentence.OnConsequenceDelegate)null);
TextObject textObject8 = new TextObject("{=FLT0000022}I will grant you the settlement of ");
TextObject textObject9 = new TextObject("{=FLT0000023} as your personal fief as a reward for your service");
campaignStarter.AddDialogLine("join_faction_lord_response_2a", "join_faction_response_3", "lord_pretalk", textObject8.ToString() + "{FIEF}" + textObject9.ToString(), new ConversationSentence.OnConditionDelegate(() => {
selected_selement = null;
List<Settlement> list = new List<Settlement>();
foreach (Settlement settlement in Hero.OneToOneConversationHero.Clan.Kingdom.Settlements)
{
if (settlement.IsTown)
{
list.Add(settlement);
}
}
if (list.Count < 1)
{
foreach (Settlement settlement in Hero.OneToOneConversationHero.Clan.Kingdom.Settlements)
{
if (settlement.IsCastle)
{
list.Add(settlement);
}
}
}
if (list.Count > 0)
{
selected_selement = list.GetRandomElement();
MBTextManager.SetTextVariable("FIEF", selected_selement.EncyclopediaLinkWithName, false);
}
return selected_selement != null;
}), new ConversationSentence.OnConsequenceDelegate(() =>{
ChangeKingdomAction.ApplyByJoinToKingdom(Hero.MainHero.Clan, Hero.OneToOneConversationHero.Clan.Kingdom);
ChangeOwnerOfSettlementAction.ApplyByGift(selected_selement, Hero.MainHero);
kingVassalOffered.Remove(Hero.OneToOneConversationHero.MapFaction);
}));
TextObject textObject10 = new TextObject("{=FLT0000024}I will grant you a sum of 500000 {COIN} as a reward for your service");
textObject10.SetTextVariable("COIN", "<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
campaignStarter.AddDialogLine("join_faction_lord_response_2b", "join_faction_response_3", "lord_pretalk", textObject10.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return true;
}), new ConversationSentence.OnConsequenceDelegate(() => {
ChangeKingdomAction.ApplyByJoinToKingdom(Hero.MainHero.Clan, Hero.OneToOneConversationHero.Clan.Kingdom);
GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 500000);
kingVassalOffered.Remove(Hero.OneToOneConversationHero.MapFaction);
}));
TextObject textObject11 = new TextObject("{=FLT0000025}Sure you may join");
campaignStarter.AddDialogLine("join_legions_response_c", "join_legions_response", "lord_pretalk", textObject11.ToString(), new ConversationSentence.OnConditionDelegate(() => {
return true;
}), new ConversationSentence.OnConsequenceDelegate (()=> {
followingHero = Hero.OneToOneConversationHero;
enlistTime = CampaignTime.Now;
EnlistTier = 1;
xp = (GetFactionRelations(followingHero.MapFaction) / 2) + (GetLordRelations(followingHero) / 2);
bool leveledUp = false;
UpdateDiplomacy();
hidePlayerParty();
if (oldItems == null)
{
oldItems = new ItemRoster();
}
else
{
oldItems.Clear();
}
if (oldGear == null)
{
oldGear = new ItemRoster();
}
else
{
oldGear.Clear();
}
if (tournamentPrizes == null)
{
tournamentPrizes = new ItemRoster();
}
else
{
tournamentPrizes.Clear();
}
currentAssignment = Assignment.Grunt_Work;
DisbandParty();
disbandArmy = false;
TransferAllItems(MobileParty.MainParty.ItemRoster, oldItems);
SetOldGear();
Hero.MainHero.CharacterObject.Equipment.FillFrom(followingHero.Culture.BasicTroop.Equipment);
GetOldGear();
while (EnlistTier < 7 && xp > NextlevelXP[EnlistTier])
{
EnlistTier++;
leveledUp = true;
}
if (leveledUp)
{
TextObject infotext = new TextObject("{=FLT0000026}{HERO} has enlisted at tier {TIER} due to high reputation with the {FACTION}");
infotext.SetTextVariable("HERO", Hero.MainHero.Name.ToString());
infotext.SetTextVariable("TIER", EnlistTier.ToString());
infotext.SetTextVariable("FACTION", followingHero.MapFaction.Name.ToString());
InformationManager.AddQuickInformation(infotext, announcerCharacter: Hero.MainHero.CharacterObject);
getRandomEquipmentSet();
}
}));
campaignStarter.AddWaitGameMenu("party_wait", "Party Leader: {PARTY_LEADER}\n{PARTY_TEXT}", new OnInitDelegate(wait_on_init), new OnConditionDelegate(wait_on_condition), null, new OnTickDelegate(wait_on_tick), GameMenu.MenuAndOptionType.WaitMenuHideProgressAndHoursOption, GameOverlays.MenuOverlayType.None, 0f, GameMenu.MenuFlags.none, null);
TextObject textObject12 = new TextObject("{=FLT0000027}Change Equipment");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_change_equipment", textObject12.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.DefendAction;
return true;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
SwitchGear();
}), true);
TextObject textObject13 = new TextObject("{=FLT0000028}Train with the troops");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_train", textObject13.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.HostileAction;
if(followingHero.PartyBelongedTo.MemberRoster.TotalHealthyCount < 11)
{
args.Tooltip = new TextObject("{=FLT0000029}Not enough men or uninjured men in lord's party");
args.IsEnabled = false;
}
return followingHero.CurrentSettlement != null && followingHero.CurrentSettlement.IsTown && !followingHero.CurrentSettlement.Town.HasTournament;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
EnterSettlementAction.ApplyForParty(MobileParty.MainParty, followingHero.CurrentSettlement);
MobileParty.MainParty.IsActive = true;
disable_XP = true;
string scene = followingHero.CurrentSettlement.LocationComplex.GetLocationWithId("arena").GetSceneName(followingHero.CurrentSettlement.Town.GetWallLevel());
Location location = followingHero.CurrentSettlement.LocationComplex.GetLocationWithId("arena");
MissionState.OpenNew("ArenaDuelMission", SandBoxMissions.CreateSandBoxMissionInitializerRecord(scene, ""), (InitializeMissionBehvaioursDelegate)(mission => (IEnumerable<MissionBehaviour>)new MissionBehaviour[13]
{
(MissionBehaviour) new MissionOptionsComponent(),
(MissionBehaviour) new CustomArenaBattleMissionController(followingHero.PartyBelongedTo.MemberRoster),
(MissionBehaviour) new HeroSkillHandler(),
(MissionBehaviour) new MissionFacialAnimationHandler(),
(MissionBehaviour) new MissionDebugHandler(),
(MissionBehaviour) new MissionAgentPanicHandler(),
(MissionBehaviour) new HighlightsController(),
(MissionBehaviour) new BattleHighlightsController(),
(MissionBehaviour) new AgentBattleAILogic(),
(MissionBehaviour) new ArenaAgentStateDeciderLogic(),
(MissionBehaviour) new VisualTrackerMissionBehavior(),
(MissionBehaviour) new CampaignMissionComponent(),
(MissionBehaviour) new MissionAgentHandler(location)
}));
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject14 = new TextObject("{=FLT0000030}Battle Commands : All");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_battle_commands_on", textObject14.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.Tooltip = new TextObject("{=FLT0000031}Commands for all formations will be shouted durring battle\nClick to toggle");
args.optionLeaveType = GameMenuOption.LeaveType.Conversation;
return AllBattleCommands;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
AllBattleCommands = false;
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject15 = new TextObject("{=FLT0000032}Battle Commands : Player Formation Only");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_battle_commands_on", textObject15.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.Tooltip = new TextObject("{=FLT0000033}Commands for only the player's formation will be shouted durring battle\nClick to toggle");
args.optionLeaveType = GameMenuOption.LeaveType.Conversation;
return !AllBattleCommands;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
AllBattleCommands = true;
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject16 = new TextObject("{=FLT0000034}Participate in tournament");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_tournament", textObject16.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.Mission;
return followingHero.CurrentSettlement != null && followingHero.CurrentSettlement.IsTown && followingHero.CurrentSettlement.Town.HasTournament;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
disable_XP = true;
EnterSettlementAction.ApplyForParty(MobileParty.MainParty, followingHero.CurrentSettlement);
MobileParty.MainParty.IsActive = true;
TournamentGame tournamentGame = Campaign.Current.TournamentManager.GetTournamentGame(followingHero.CurrentSettlement.Town);
int upgradeLevel = followingHero.CurrentSettlement.IsTown ? followingHero.CurrentSettlement.GetComponent<Town>().GetWallLevel() : 1;
string scene = followingHero.CurrentSettlement.LocationComplex.GetScene("arena", upgradeLevel);
SandBoxMission.OpenTournamentFightMission(scene, tournamentGame, followingHero.CurrentSettlement, followingHero.CurrentSettlement.Culture, true);
Campaign.Current.TournamentManager.OnPlayerJoinTournament(tournamentGame.GetType(), followingHero.CurrentSettlement);
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject17 = new TextObject("{=FLT0000035}Show reputation with factions");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_reputation", textObject17.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.Submenu;
return true;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
GameMenu.SwitchToMenu("faction_reputation");
}), true);
TextObject textObject18 = new TextObject("{=FLT0000036}Ask commander for leave");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_ask_leave", textObject18.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.LeaveTroopsAndFlee;
return true;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
if (kingVassalOffered.Contains(followingHero.MapFaction))
{
LeaveLordPartyAction(false);
GameMenu.ExitToLast();
}
else
{
conversation_type = "ask_to_leave";
Campaign.Current.ConversationManager.AddDialogFlow(CreateAskToLeaveDialog());
CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false), new ConversationCharacterData(followingHero.CharacterObject, null, false, false, false, false));
}
}), true);
TextObject textObject19 = new TextObject("{=FLT0000037}Ask for a different assignment");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_ask_assignment", textObject19.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.Recruit;
return true;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
conversation_type = "ask_assignment";
Campaign.Current.ConversationManager.AddDialogFlow(CreateAskAssignmentDialog());
CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false), new ConversationCharacterData(followingHero.CharacterObject, null, false, false, false, false));
}), true);
TextObject textObject20 = new TextObject("{=FLT0000038}Lure bandits into ambush");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_attack", textObject20.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.HostileAction;
args.Tooltip = new TextObject("{=FLT0000039}A small group of bandits is way to nimble to catch normally. The only way to catch them is to trick them into attacking, although there is a chance things could go wrong");
if (!Hero.MainHero.CharacterObject.IsMounted)
{
args.IsEnabled = false;
args.Tooltip = new TextObject("{=FLT0000040}You need to be mounted to do this");
}
if (Hero.MainHero.IsWounded)
{
args.IsEnabled = false;
args.Tooltip = new TextObject("{=FLT0000041}You are wounded");
}
return nearbyBandit().Count > 0;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
if(nearbyBandit().Count == 0)
{
TextObject banditLureFailText = new TextObject("{=FLT0000042}The bandits did not fall for your trap");
InformationManager.DisplayMessage(new InformationMessage(banditLureFailText.ToString()));
GameMenu.ActivateGameMenu("party_wait");
return;
}
MobileParty banditParty = nearbyBandit().GetRandomElement();
banditParty.SetMoveEngageParty(followingHero.PartyBelongedTo);
banditParty.Ai.SetDoNotMakeNewDecisions(true);
showPlayerParty();
MobileParty.MainParty.IsActive = true;
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
if (Hero.MainHero.GetSkillValue(DefaultSkills.Tactics) - (5 * MobileParty.MainParty.Position2D.Distance(banditParty.Position2D)) < MBRandom.RandomInt(100))
{
Hero.MainHero.HitPoints = Math.Max(0, Hero.MainHero.HitPoints - ( 5 + MBRandom.RandomInt(15)));
InformationManager.AddQuickInformation(new TextObject("{=FLT0000043}You took some minor injuries while being chased by bandits"), announcerCharacter: Hero.MainHero.CharacterObject);
}
Hero.MainHero.AddSkillXp(DefaultSkills.Tactics, 200);
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject23 = new TextObject("{=FLT0000184}Attack enemy villagers");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_villager_attack", textObject23.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.Raid;
args.Tooltip = new TextObject("{=FLT0000185}Ride out with the cavalry to attack enemy villagers");
if (!Hero.MainHero.CharacterObject.IsMounted)
{
args.IsEnabled = false;
args.Tooltip = new TextObject("{=FLT0000040}You need to be mounted to do this");
}
if (Hero.MainHero.IsWounded)
{
args.IsEnabled = false;
args.Tooltip = new TextObject("{=FLT0000041}You are wounded");
}
return nearbyVillagers().Count > 0;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
if (nearbyVillagers().Count == 0)
{
TextObject VillagersFailText = new TextObject("{=FLT0000186}The villagers managed to escape");
InformationManager.DisplayMessage(new InformationMessage(VillagersFailText.ToString()));
GameMenu.ActivateGameMenu("party_wait");
return;
}
MobileParty Villagers = nearbyVillagers().GetRandomElement();
showPlayerParty();
MobileParty.MainParty.IsActive = true;
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
MobileParty.MainParty.Position2D = Villagers.Position2D;
CavOnly(Test.followingHero.PartyBelongedTo).Position2D = Villagers.Position2D;
MobileParty.MainParty.SetMoveEngageParty(Villagers);
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject24 = new TextObject("{=FLT0000188}Attack enemy caravan");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_villager_attack", textObject24.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.ForceToGiveGoods;
args.Tooltip = new TextObject("{=FLT0000189}Ride out with the cavalry to attack enemy caravan");
if (!Hero.MainHero.CharacterObject.IsMounted)
{
args.IsEnabled = false;
args.Tooltip = new TextObject("{=FLT0000040}You need to be mounted to do this");
}
if (Hero.MainHero.IsWounded)
{
args.IsEnabled = false;
args.Tooltip = new TextObject("{=FLT0000041}You are wounded");
}
return nearbyCaravan().Count > 0;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
if (nearbyCaravan().Count == 0)
{
TextObject VillagersFailText = new TextObject("{=FLT0000190}The caravan managed to escape");
InformationManager.DisplayMessage(new InformationMessage(VillagersFailText.ToString()));
GameMenu.ActivateGameMenu("party_wait");
return;
}
MobileParty caravan = nearbyCaravan().GetRandomElement();
showPlayerParty();
MobileParty.MainParty.IsActive = true;
while (Campaign.Current.CurrentMenuContext != null)
{
GameMenu.ExitToLast();
}
MobileParty.MainParty.Position2D = caravan.Position2D;
CavOnly(Test.followingHero.PartyBelongedTo).Position2D = caravan.Position2D;
MobileParty.MainParty.SetMoveEngageParty(caravan);
GameMenu.ActivateGameMenu("party_wait");
}), true);
TextObject textObject21 = new TextObject("{=FLT0000044}Abandon Party");
campaignStarter.AddGameMenuOption("party_wait", "party_wait_leave", textObject21.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
TextObject text = new TextObject("{=FLT0000045}This will damage your reputation with the {FACTION}");
text.SetTextVariable("FACTION", followingHero.MapFaction.Name.ToString());
args.Tooltip = text;
args.optionLeaveType = GameMenuOption.LeaveType.Escape;
return xp < 10000;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
TextObject titleText = new TextObject("{=FLT0000044}Abandon Party");
TextObject text = new TextObject("{=FLT0000046}Are you sure you want to abandon the party> This will harm relations with the entire faction");
TextObject affrimativeText = new TextObject("{=FLT0000047}Yes");
TextObject negativeText = new TextObject("{=FLT0000048}No");
InformationManager.ShowInquiry(new InquiryData(titleText.ToString() , text.ToString() , true, true, affrimativeText.ToString(), negativeText.ToString(), new Action(delegate{
ChangeFactionRelation(followingHero.MapFaction, -100000);
ChangeCrimeRatingAction.Apply(followingHero.MapFaction, 55);
foreach (Clan clan in followingHero.Clan.Kingdom.Clans)
{
if (!clan.IsUnderMercenaryService)
{
ChangeRelationAction.ApplyPlayerRelation(clan.Leader, -20);
foreach(Hero lord in clan.Heroes)
{
if (lord.IsNoble)
{
ChangeLordRelation(lord, -100000);
}
}
}
}
LeaveLordPartyAction(true);
GameMenu.ExitToLast();
}), new Action(delegate {
GameMenu.ActivateGameMenu("party_wait");
})));
}), true);
campaignStarter.AddGameMenu("faction_reputation", "{REPUTATION}", (args) => {
TextObject text = args.MenuContext.GameMenu.GetText();
string s = "";
foreach(Kingdom kingdom in Campaign.Current.Kingdoms)
{
s += kingdom.Name.ToString() + " : " + GetFactionRelations(kingdom) + "\n";
}
text.SetTextVariable("REPUTATION", s);
}, GameOverlays.MenuOverlayType.None);
TextObject textObject22 = new TextObject("{=FLT0000049}Back");
campaignStarter.AddGameMenuOption("faction_reputation", "faction_reputation_back", textObject22.ToString(), (GameMenuOption.OnConditionDelegate)(args =>
{
args.optionLeaveType = GameMenuOption.LeaveType.Leave;
return true;
}), (GameMenuOption.OnConsequenceDelegate)(args => {
GameMenu.ActivateGameMenu("party_wait");
}), true);
}
private MobileParty CavOnly(MobileParty partyBelongedTo)
{
CavalryDetachment = MobileParty.CreateParty("calavlry detachment", null, null);
TextObject customName = new TextObject("{=FLT0000187}Cavalry Detachment", null);
CavalryDetachment.InitializeMobileParty(new TroopRoster(CavalryDetachment.Party), new TroopRoster(CavalryDetachment.Party), partyBelongedTo.GetPosition2D, 1f, 0.5f);
CavalryDetachment.SetCustomName(customName);
CavalryDetachment.ActualClan = partyBelongedTo.ActualClan;
CavalryDetachment.ShouldJoinPlayerBattles = true;
foreach(TroopRosterElement troop in partyBelongedTo.MemberRoster.GetTroopRoster())
{
if(troop.Character.IsMounted && !troop.Character.IsHero)
{
int num = troop.Number;
CharacterObject character = troop.Character;
partyBelongedTo.MemberRoster.AddToCounts(character, -1 * num);
CavalryDetachment.MemberRoster.AddToCounts(character, num);
}
}
return CavalryDetachment;
}
private List<MobileParty> nearbyCaravan()
{
float radius = MobileParty.MainParty.SeeingRange;
List<MobileParty> list = new List<MobileParty>();
foreach (MobileParty party in Campaign.Current.MobileParties)
{
if (party.IsCaravan && party.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction) && party.Position2D.Distance(MobileParty.MainParty.Position2D) < radius && party.CurrentSettlement == null)
{
list.Add(party);
}
}
return list;
}
private List<MobileParty> nearbyVillagers()
{
float radius = MobileParty.MainParty.SeeingRange;
List<MobileParty> list = new List<MobileParty>();
foreach (MobileParty party in Campaign.Current.MobileParties)
{
if (party.IsVillager && party.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction) && party.Position2D.Distance(MobileParty.MainParty.Position2D) < radius && party.CurrentSettlement == null)
{
list.Add(party);
}
}
return list;