Esempio n. 1
0
        public void OnSettlementOwnerChangedMod(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            if (!Campaign.Current.GameStarted)
            {
                return;
            }

            changeSettlementCulture(settlement);
        }
Esempio n. 2
0
 private void OnSettlementOwnerChanged(Settlement settlement, bool arg2, Hero arg3, Hero arg4, Hero arg5, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
 {
     if (detail != ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.BySiege)
     {
         this.AddCounter(settlement);
     }
     else
     {
         settlement.Culture = ChangeSettlementCulture.initialCultureDictionary[settlement];
     }
 }
Esempio n. 3
0
        private void UpdateOnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            var lst = ButterLib.DistanceMatrix.DistanceMatrix.GetSettlementOwnersPairedList(SettlementDistanceMatrix !);

            if (lst is null)
            {
                return;
            }

            if ((newOwner.Clan is not null || oldOwner.Clan is not null) && newOwner.Clan != oldOwner.Clan)
            {
                var clans = Clan.All.Where(c => c.IsInitialized && c.Fiefs.Any()).ToList();

                if (oldOwner.Clan is not null)
                {
                    foreach (Clan clan in clans)
                    {
                        if (clan != oldOwner.Clan)
                        {
                            var distance = ButterLib.DistanceMatrix.DistanceMatrix.CalculateDistanceBetweenClans(oldOwner.Clan, clan, lst);
                            ClanDistanceMatrix !.SetDistance(oldOwner.Clan, clan, distance.GetValueOrDefault());
                        }
                    }
                }
                if (newOwner.Clan is not null)
                {
                    foreach (Clan clan in clans)
                    {
                        if (clan != newOwner.Clan)
                        {
                            var distance = ButterLib.DistanceMatrix.DistanceMatrix.CalculateDistanceBetweenClans(newOwner.Clan, clan, lst);
                            ClanDistanceMatrix !.SetDistance(newOwner.Clan, clan, distance.GetValueOrDefault());
                        }
                    }
                }
            }

            if ((newOwner.Clan?.Kingdom is not null || oldOwner.Clan?.Kingdom is not null) && newOwner.Clan?.Kingdom != oldOwner.Clan?.Kingdom)
            {
                KingdomDistanceMatrix = new DistanceMatrixImplementation <Kingdom>();
            }
        }
 private static void OnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
 {
     if (settlement.IsFortification &&
         newOwner != capturerHero &&
         detail == ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.BySiege)
     {
         ChangeOwnerOfSettlementAction.ApplyBySiege(capturerHero, capturerHero, settlement);
     }
 }
Esempio n. 5
0
        public void OnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            if (detail != ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.BySiege)
            {
                return;
            }

            Kingdom previousOwnerKingdom = oldOwner.MapFaction as Kingdom;
            Kingdom newOwnerKingdom      = newOwner.MapFaction as Kingdom;

            if (previousOwnerKingdom != null && newOwnerKingdom != null && previousOwnerKingdom != newOwnerKingdom)
            {
                _warExhaustionManager.AddSiegeWarExhaustion(previousOwnerKingdom, newOwnerKingdom);
            }
        }
Esempio n. 6
0
        public void OnSettlementOwnerChangedMod(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            if (!Campaign.Current.GameStarted || Campaign.Current.Settlements == null)
            {
                return;
            }

            if (first)
            {
                initializeAllSettlementCultures();
            }

            if (!Settings.Instance.PlayerKingdomOnly || (Settings.Instance.PlayerKingdomOnly && settlement.OwnerClan.Leader.IsHumanPlayerCharacter))
            {
                if (settlement.IsVillage || settlement.IsCastle || settlement.IsTown)
                {
                    ChangeCultureManager.Instance.InfluenceMap[settlement.StringId].OnNewOwner();
                }
            }

            /*
             * // Attempt to set culture based on kingdoms
             * if (oldOwner.Clan.Kingdom != null && newOwner.Clan.Kingdom != null)
             * {
             *  if (oldOwner.Clan.Kingdom.Culture.StringId != newOwner.Clan.Kingdom.Culture.StringId)
             *  {
             *      ChangeCultureUtils.ChangeSettlementCulture(settlement, newOwner.Clan.Kingdom.Culture);
             *  }
             * }
             * // Fallback to setting culture on clan
             * else if (oldOwner.Clan != null && newOwner.Clan != null)
             * {
             *  if (oldOwner.Clan.Culture != newOwner.Clan.Culture)
             *  {
             *      ChangeCultureUtils.ChangeSettlementCulture(settlement, newOwner.Clan.Culture);
             *  }
             * }
             */
        }
        private void OnSettlementOwnerChangedEvent(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturedHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            var settlementInfo = Managers.Settlement.Get(settlement);

            settlementInfo.UpdateOwnerRevolt(newOwner.MapFaction);

            if (capturedHero?.PartyBelongedTo?.Party != null)
            {
                var revolt = RevoltManager.Instance.GetRevoltByParty(capturedHero.PartyBelongedTo.Party);
                if (revolt != null && !RevolutionsSettings.Instance.RevoltsMinorFactionsMechanic && revolt.IsMinorFaction)
                {
                    if (revolt.SettlementInfo.CurrentFaction == revolt.SettlementInfo.LoyalFaction)
                    {
                        var previousFactionOwner = BaseManagers.Faction.GetLordWithLeastFiefs(revolt.SettlementInfo.PreviousFaction).HeroObject;
                        ChangeOwnerOfSettlementAction.ApplyByRevolt(previousFactionOwner, settlement);
                    }
                    else
                    {
                        var loyalFactionOwner = BaseManagers.Faction.GetLordWithLeastFiefs(revolt.SettlementInfo.LoyalFaction).HeroObject;
                        ChangeOwnerOfSettlementAction.ApplyByRevolt(loyalFactionOwner, settlement);
                    }

                    Managers.Kingdom.DestroyKingdom(capturedHero.Clan.Kingdom);
                    Managers.Clan.DestroyClan(capturedHero.Clan);
                    capturedHero.PartyBelongedTo.RemoveParty();
                    KillCharacterAction.ApplyByRemove(capturedHero);

                    RevoltManager.Instance.Revolts.Remove(revolt);
                }
            }
        }
Esempio n. 8
0
 private void UpdateExpasionismScore(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
 {
     if (newOwner.MapFaction != oldOwner.MapFaction && newOwner.MapFaction.IsKingdomFaction && detail == ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.BySiege)
     {
         this._expansionismManager.AddSiegeScore(newOwner.MapFaction);
     }
 }
Esempio n. 9
0
        private void OnSettlementOwnerChangedEvent(Settlement settlement, bool bl, Hero hero1, Hero hero2, Hero hero3, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            SettlementInfo settlementInfo = GetSettlementInformation(settlement);

            if (settlementInfo != null)
            {
                settlementInfo.ResetOwnership();
            }
        }
Esempio n. 10
0
        private static bool Prefix(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            if ((detail == ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.BySiege || detail == ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.ByBarter || detail == ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.ByRevolt) && oldOwner != null && oldOwner.MapFaction != null && oldOwner.MapFaction.Leader != oldOwner && oldOwner.IsAlive && oldOwner.MapFaction.Leader != Hero.MainHero)
            {
                //float value = settlement.GetValue(true);
                //int num = (int)((1.0 + Math.Max(1.0, Math.Sqrt((double)(value / 100000f)))) * (double)((newOwner.MapFaction != oldOwner.MapFaction) ? 1f : 0.5f));
                //ChangeRelationAction.ApplyRelationChangeBetweenHeroes(oldOwner, oldOwner.MapFaction.Leader, -num, false);
                if (oldOwner.Clan != null && settlement != null)
                {
                    oldOwner.Clan.Influence -= (float)(settlement.IsTown ? 50 : 25);
                }
            }

            return(false);
        }
Esempio n. 11
0
 private void OnSettlementChange(Settlement s, bool b, Hero newOwner, Hero oldOwner, Hero h3, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail details)
 {
     if (details == ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail.BySiege)
     {
         if (s == null || oldOwner == null || newOwner == null || oldOwner.Clan == null || newOwner.Clan == null || oldOwner.Clan.Kingdom == null || newOwner.Clan.Kingdom == null) //absolutely disgusting.
         {
             WriteString("There has been a siege. \n");
         }
         else
         {
             WriteString(s.Name + " has been captured succesfully through siege, changing hands from " + oldOwner.Clan.Kingdom.Name + " to " + newOwner.Clan.Kingdom.Name + "\n");
         }
     }
 }
Esempio n. 12
0
        public void OnSettlementOwnerChangedMod(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
        {
            if (!Campaign.Current.GameStarted || Campaign.Current.Settlements == null)
            {
                return;
            }

            if (first)
            {
                initializeAllSettlementCultures();
            }

            if (!Settings.Instance.PlayerKingdomOnly || (Settings.Instance.PlayerKingdomOnly && settlement.OwnerClan.Leader.IsHumanPlayerCharacter))
            {
                if (settlement.IsVillage || settlement.IsCastle || settlement.IsTown)
                {
                    DynaCultureManager.Instance.InfluenceMap[settlement.StringId].OnNewOwner();
                }
            }
        }