Exemplo n.º 1
0
 public static void StartBattle(PartyBase defenderParty)
 {
     StartBattleAction.Apply(MobileParty.MainParty.Party, defenderParty);
     PlayerEncounter.RestartPlayerEncounter(MobileParty.MainParty.Party, defenderParty, true);
     PlayerEncounter.Update();
     CampaignMission.OpenBattleMission(PlayerEncounter.GetBattleSceneForMapPosition(MobileParty.MainParty.Position2D));
 }
Exemplo n.º 2
0
 private void PreBattle(MobileParty targetParty)
 {
     PlayerEncounter.LeaveSettlement();
     PlayerEncounter.Finish(true);
     StartBattleAction.Apply(targetParty.Party, MobileParty.MainParty.Party);
     PlayerEncounter.RestartPlayerEncounter(MobileParty.MainParty.Party, targetParty.Party, true);
     PlayerEncounter.Update();
 }
        private static void surrender_consequence_delegate(DialogueParams param, string isPlayer) // for surrenders you need to update the player encounter- not sure if this closes the window or not
        {
            isPlayer = isPlayer.ToLower();

            if (isPlayer == "true")
            {
                PlayerEncounter.PlayerSurrender = true;
            }
            else if (isPlayer == "false")
            {   //Interestingly, PlayerEncounter.EnemySurrender = true; results in a null reference crash.
                param.PlayerParty.Party.AddPrisoners(param.AdversaryParty.Party.MemberRoster);
                param.AdversaryParty.RemoveParty();
                CustomSpawns.UX.ShowMessage("You have taken your enemies prisoner.", TaleWorlds.Library.Colors.Green);
                end_conversation_consequence_delegate(param);
            }
            else
            {
                ErrorHandler.ShowPureErrorMessage("Can't interpret " + isPlayer.ToString() + " as a bool. Possible typo in the XML consequence 'Surrender'");
            }
            PlayerEncounter.Update();
        }
Exemplo n.º 4
0
        internal void CECaptorHuntPrisoners(MenuCallbackArgs args, int amount = 20)
        {
            CEPersistence.animationPlayEvent = false;

            TroopRoster releasedPrisoners = TroopRoster.CreateDummyTroopRoster();

            if (CESettings.Instance != null)
            {
                amount = CESettings.Instance.AmountOfTroopsForHunt;
            }

            try
            {
                for (int i = 0; i < amount; i++)
                {
                    TroopRosterElement test = MobileParty.MainParty.PrisonRoster.GetTroopRoster().Where(troop => !troop.Character.IsHero).GetRandomElementInefficiently();

                    if (test.Character == null)
                    {
                        continue;
                    }

                    MobileParty.MainParty.PrisonRoster.RemoveTroop(test.Character);
                    releasedPrisoners.AddToCounts(test.Character, 1, true);
                }
            }
            catch (Exception)
            {
                CECustomHandler.LogToFile("Couldn't find anymore prisoners.");
            }

            if (!releasedPrisoners.GetTroopRoster().IsEmpty())
            {
                CECaptorContinue(args);

                try
                {
                    Clan clan = Clan.BanditFactions.First(clanLooters => clanLooters.StringId == "looters");
                    clan.Banner.SetBannerVisual(Banner.CreateRandomBanner().BannerVisual);

                    Settlement nearest = SettlementHelper.FindNearestSettlement(settlement => { return(true); });

                    MobileParty prisonerParty = BanditPartyComponent.CreateBanditParty("CustomPartyCE_Hunt_" + MBRandom.RandomInt(int.MaxValue), clan, nearest.Hideout, false);

                    PartyTemplateObject defaultPartyTemplate = clan.DefaultPartyTemplate;

                    prisonerParty.InitializeMobileParty(defaultPartyTemplate, MobileParty.MainParty.Position2D, 0.5f, 0.1f, -1);
                    prisonerParty.SetCustomName(new TextObject("{=CEEVENTS1107}Escaped Captives"));

                    prisonerParty.MemberRoster.Clear();
                    prisonerParty.MemberRoster.Add(releasedPrisoners.ToFlattenedRoster());

                    prisonerParty.RecentEventsMorale = -100;
                    prisonerParty.IsActive           = true;
                    prisonerParty.ActualClan         = clan;
                    prisonerParty.Party.Owner        = clan.Leader;
                    prisonerParty.Party.Visuals.SetMapIconAsDirty();

                    prisonerParty.HomeSettlement = nearest;
                    prisonerParty.InitializePartyTrade(0);

                    Hero.MainHero.HitPoints += 40;


                    CECustomHandler.LogToFile(prisonerParty.Leader.Name.ToString());
                    PlayerEncounter.RestartPlayerEncounter(prisonerParty.Party, MobileParty.MainParty.Party, true);
                    StartBattleAction.Apply(MobileParty.MainParty.Party, prisonerParty.Party);
                    PlayerEncounter.Update();

                    CEPersistence.huntState = CEPersistence.HuntState.StartHunt;
                    CampaignMission.OpenBattleMission(PlayerEncounter.GetBattleSceneForMapPosition(MobileParty.MainParty.Position2D));
                }
                catch (Exception)
                {
                    CECaptorKillPrisoners(args, amount);
                }
            }
            else
            {
                CECaptorContinue(args);
            }
        }
Exemplo n.º 5
0
 private void OnSessionLaunched(CampaignGameStarter campaignGameStarter)
 {
     campaignGameStarter.AddGameMenu(
         FastDialogueSubModule.FastEncounterMenu,
         "{=!}{ENCOUNTER_TEXT}",
         Init,
         GameOverlays.MenuOverlayType.Encounter,
         GameMenu.MenuFlags.none,
         null);
     campaignGameStarter.AddGameMenuOption(
         FastDialogueSubModule.FastEncounterMenu,
         $"{FastDialogueSubModule.FastEncounterMenu}_attack",
         "{=o1pZHZOF}Attack!",
         args =>
     {
         return(ShouldShowWarOptions() && ReflectionUtils.ForceCall <bool>(GetGlobalCampaignBehaviorManager(), "game_menu_encounter_attack_on_condition", new object[] { args }));
     },
         ConsequenceOf("game_menu_encounter_attack_on_consequence"),
         false,
         -1,
         false);
     campaignGameStarter.AddGameMenuOption(
         FastDialogueSubModule.FastEncounterMenu,
         $"{FastDialogueSubModule.FastEncounterMenu}_troops",
         "{=rxSz5dY1}Send troops.",
         (args) =>
     {
         return(ShouldShowWarOptions() && ReflectionUtils.ForceCall <bool>(GetGlobalCampaignBehaviorManager(), "game_menu_encounter_order_attack_on_condition", new object[] { args }));
     },
         ConsequenceOf("game_menu_encounter_order_attack_on_consequence"),
         false,
         -1,
         false);
     campaignGameStarter.AddGameMenuOption(
         FastDialogueSubModule.FastEncounterMenu,
         $"{FastDialogueSubModule.FastEncounterMenu}_getaway",
         "{=qNgGoqmI}Try to get away.",
         ConditionOf("game_menu_encounter_leave_your_soldiers_behind_on_condition"),
         ConsequenceOf("game_menu_encounter_leave_your_soldiers_behind_accept_on_consequence"),
         false,
         -1,
         false);
     campaignGameStarter.AddGameMenuOption(
         FastDialogueSubModule.FastEncounterMenu,
         $"{FastDialogueSubModule.FastEncounterMenu}_talk",
         "{=qNgGoqmI}Converse.",
         args =>
     {
         args.optionLeaveType = GameMenuOption.LeaveType.Conversation;
         return(true);
     },
         args =>
     {
         PlayerEncounter.DoMeeting();
     },
         false,
         -1,
         false);
     campaignGameStarter.AddGameMenuOption(
         FastDialogueSubModule.FastEncounterMenu,
         $"{FastDialogueSubModule.FastEncounterMenu}_surrend",
         "{=3nT5wWzb}Surrender.",
         ConditionOf("game_menu_encounter_surrender_on_condition"),
         args =>
     {
         PlayerEncounter.PlayerSurrender = true;
         PlayerEncounter.Update();
     },
         false,
         -1,
         false);
     campaignGameStarter.AddGameMenuOption(
         FastDialogueSubModule.FastEncounterMenu,
         $"{FastDialogueSubModule.FastEncounterMenu}_leave",
         "{=2YYRyrOO}Leave...",
         ConditionOf("game_menu_encounter_leave_on_condition"),
         (args) =>
     {
         MenuHelper.EncounterLeaveConsequence(args);
         if (PartyBase.MainParty.IsMobile && PartyBase.MainParty.MobileParty != null)
         {
             PartyBase.MainParty.MobileParty.IsDisorganized = false;
         }
     },
         true,
         -1,
         false);
 }