Пример #1
0
        public void EstablishCamp(MobileParty parentParty)
        {
            var party = MobileParty.Create("main_player_camp:0");

            party.StringId = "main_player_camp:0";
            party.InitializeMobileParty(new TextObject("Player Camp"), new TroopRoster(), new TroopRoster(), MobileParty.MainParty.Position2D, 1f, 0.5f);

            var roster = MobileParty.MainParty.MemberRoster;

            roster.RemoveTroop(Hero.MainHero.CharacterObject);
            party.Party.AddMembers(roster.ToFlattenedRoster());
            roster.Clear();

            party.Party.ItemRoster.Add(MobileParty.MainParty.ItemRoster);
            MobileParty.MainParty.ItemRoster.RemoveAllItems();

            MobileParty.MainParty.AddElementToMemberRoster(Hero.MainHero.CharacterObject, 1);
            party.DisableAi();
            party.Party.Owner = Hero.MainHero;

            _establishedCamp = new PlayerEstablishedCamp
            {
                Party       = party,
                ParentParty = parentParty,
                IsTraining  = false,
            };

            MBTextManager.SetTextVariable("PLAYER_CAMP_RESOURCES", _establishedCamp.Party.GetNumDaysForFoodToLast());
        }
Пример #2
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;
        }