Ejemplo n.º 1
0
        private void ConsequenceCharacterWindowClose()
        {
            if (Hero.MainHero != null && MobileParty.MainParty != null && characterWindowHero != null)
            {
                if (characterWindowParty != MobileParty.MainParty)
                {
                    MobileParty.MainParty.MemberRoster.AddToCounts(characterWindowHero.CharacterObject, -1);
                    if (characterWindowParty != null)
                    {
                        characterWindowParty.MemberRoster.AddToCounts(characterWindowHero.CharacterObject, 1);
                        characterWindowParty.ChangePartyLeader(characterWindowHero.CharacterObject);
                    }
                }

                foreach (string e in characterWindowEvents)
                {
                    characterWindowHero.AddEventForOccupiedHero(e);
                }

                characterWindowHero.StayingInSettlementOfNotable = characterWindowSettlement;
            }

            characterWindowHero   = null;
            characterWindowParty  = null;
            characterWindowEvents = null;
        }
Ejemplo n.º 2
0
        internal void CECaptorPrisonerRebel(MenuCallbackArgs args)
        {
            CEPersistence.animationPlayEvent = false;

            TroopRoster releasedPrisoners = TroopRoster.CreateDummyTroopRoster();

            try
            {
                foreach (TroopRosterElement element in MobileParty.MainParty.PrisonRoster.GetTroopRoster())
                {
                    if (element.Character.IsHero)
                    {
                        element.Character.HeroObject.ChangeState(Hero.CharacterStates.Active);
                    }
                }
                releasedPrisoners.Add(MobileParty.MainParty.PrisonRoster.ToFlattenedRoster());
                MobileParty.MainParty.PrisonRoster.Clear();
            }
            catch (Exception)
            {
                CECustomHandler.LogToFile("Couldn't find anymore prisoners.");
            }

            if (!releasedPrisoners.GetTroopRoster().IsEmpty())
            {
                try
                {
                    TroopRosterElement leader = releasedPrisoners.GetTroopRoster().FirstOrDefault(hasHero => hasHero.Character.IsHero);

                    Clan        clan          = null;
                    Settlement  nearest       = null;
                    MobileParty prisonerParty = null;

                    if (leader.Character != null)
                    {
                        clan          = leader.Character.HeroObject.Clan;
                        nearest       = SettlementHelper.FindNearestSettlement(settlement => settlement.OwnerClan == clan) ?? SettlementHelper.FindNearestSettlement(settlement => true);
                        prisonerParty = LordPartyComponent.CreateLordParty("CustomPartyCE_" + MBRandom.RandomInt(int.MaxValue), leader.Character.HeroObject, MobileParty.MainParty.Position2D, 0.5f, nearest);
                    }
                    else
                    {
                        clan = Clan.BanditFactions.First(clanLooters => clanLooters.StringId == "looters");
                        clan.Banner.SetBannerVisual(Banner.CreateRandomBanner().BannerVisual);
                        nearest       = SettlementHelper.FindNearestSettlement(settlement => true);
                        prisonerParty = BanditPartyComponent.CreateBanditParty("CustomPartyCE_" + 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.ActualClan = clan;
                    prisonerParty.MemberRoster.Add(releasedPrisoners.ToFlattenedRoster());
                    prisonerParty.IsActive = true;

                    prisonerParty.HomeSettlement = nearest;
                    prisonerParty.SetMovePatrolAroundPoint(nearest.IsTown
                                       ? nearest.GatePosition
                                       : nearest.Position2D);

                    if (leader.Character != null)
                    {
                        prisonerParty.Party.Owner = leader.Character.HeroObject;
#if BETA
                        prisonerParty.ChangePartyLeader(leader.Character);
#else
                        prisonerParty.ChangePartyLeader(leader.Character, true);
#endif
                    }
                    else
                    {
                        prisonerParty.Party.Owner = clan.Leader;
                    }



                    prisonerParty.RecentEventsMorale = -100;
                    prisonerParty.Aggressiveness     = 0.2f;
                    prisonerParty.InitializePartyTrade(0);

                    Hero.MainHero.HitPoints += 40;

                    CECustomHandler.LogToFile(prisonerParty.Leader.Name.ToString());
                    PlayerEncounter.RestartPlayerEncounter(MobileParty.MainParty.Party, prisonerParty.Party);
                    GameMenu.SwitchToMenu("encounter");
                }
                catch (Exception)
                {
                    CECaptorContinue(args);
                }
            }
            else
            {
                CECaptorContinue(args);
            }
        }
Ejemplo n.º 3
0
        private void RevoltLogic(SettlementInfo info, Settlement settlement)
        {
            TextObject revoltNotification = GameTexts.FindText("str_GM_RevoltNotification");

            revoltNotification.SetTextVariable("SETTLEMENT", settlement.Name.ToString());
            InformationManager.DisplayMessage(new InformationMessage(revoltNotification.ToString()));

            Hero        selectedHero     = null;
            TextObject  revolutionaryMob = GameTexts.FindText("str_GM_RevolutionaryMob");
            MobileParty mob    = MobileParty.Create(revolutionaryMob.ToString());
            TroopRoster roster = new TroopRoster();

            TroopRoster infantry = new TroopRoster();

            infantry.FillMembersOfRoster(300, settlement.Culture.MeleeMilitiaTroop);
            roster.Add(infantry);

            TroopRoster archers = new TroopRoster();

            archers.FillMembersOfRoster(200, settlement.Culture.RangedMilitiaTroop);
            roster.Add(archers);

            TroopRoster prisonRoster = new TroopRoster();

            prisonRoster.IsPrisonRoster = true;

            if (info.CurrentFaction.IsAtWarWith(info.OriginalFaction))
            {
                Clan chosenClan       = null;
                int  leastSettlements = 100;
                foreach (var noble in info.OriginalFaction.Nobles)
                {
                    int currentSettlements = noble.Clan.Settlements.Count();
                    if (currentSettlements >= leastSettlements)
                    {
                        continue;
                    }
                    leastSettlements = currentSettlements;
                    chosenClan       = noble.Clan;
                }

                selectedHero = chosenClan != null?chosenClan.Nobles.GetRandomElement() : info.OriginalFaction.Leader;
            }
            else
            {
                var clan = CreateRebellionClan(info);
                clan.AddRenown(500);
                DeclareWarAction.Apply(clan, info.CurrentFaction);
                selectedHero    = clan.Leader;
                mob.IsLordParty = true;
            }

            mob.ChangePartyLeader(selectedHero.CharacterObject);
            mob.Party.Owner = selectedHero;

            if (!info.CurrentFaction.IsAtWarWith(info.OriginalFaction))
            {
                mob.MemberRoster.AddToCounts(mob.Party.Owner.CharacterObject, 1, false, 0, 0, true, -1);
            }

            mob.InitializeMobileParty(new TextObject(revolutionaryMob.ToString(), null), roster, prisonRoster, settlement.GatePosition, 2.0f, 2.0f);

            Revolutionaries.Add(new Tuple <PartyBase, SettlementInfo>(mob.Party, info));

            MobileParty garrison = settlement.Parties.FirstOrDefault(party => party.IsGarrison);

            if (garrison == null)
            {
                foreach (var party in settlement.Parties.Where(party => party.IsMilitia || party.MapFaction.StringId == settlement.OwnerClan.MapFaction.StringId))
                {
                    garrison = party;
                    break;
                }
            }

            if (garrison == null)
            {
                ChangeOwnerOfSettlementAction.ApplyByRevolt(selectedHero, settlement);
                GetFactionInformation(info.CurrentFaction).CityRevoltedSuccess(settlement);
            }
            else
            {
                Campaign.Current.MapEventManager.StartSiegeOutsideMapEvent(mob.Party, garrison.Party);
            }

            info.RevoltProgress = 0;
        }