Example #1
0
        //Adds the relation to the detrmained allies
        private void SetRelation(Hero alliedHero, int currentRelation, int newRelation, int rel, bool isLordParty)
        {
            int relationCap = FTRConfig.newInstance.FTRInitialize.RelationCap;
            int relToCap;

            if (relationCap > currentRelation)
            {
                if (relationCap >= newRelation)
                {
                    CharacterRelationManager.SetHeroRelation(Hero.MainHero, alliedHero, newRelation);
                    if (isLordParty == true)
                    {
                        CharacterRelationManager.SetHeroRelation(Hero.MainHero, alliedHero.Clan.Leader, newRelation);
                    }
                    RelationshipOutput(rel, newRelation, alliedHero.ToString());
                }
                else
                {
                    if (rel >= (relationCap - currentRelation))
                    {
                        relToCap    = relationCap - currentRelation;
                        newRelation = currentRelation + relToCap;
                        CharacterRelationManager.SetHeroRelation(Hero.MainHero, alliedHero, newRelation);
                        if (isLordParty == true)
                        {
                            CharacterRelationManager.SetHeroRelation(Hero.MainHero, alliedHero.Clan.Leader, newRelation);
                        }
                        RelationshipOutput(relToCap, newRelation, alliedHero.ToString());
                    }
                }
            }
        }
        private static void EscapedPrisoner()//Escaped Prisoner start
        {
            Hero mainhero = Hero.MainHero;
            Hero lord     = Hero.FindAll((Hero tmp) => (tmp.Culture.StringId == mainhero.Culture.StringId) && tmp.IsAlive && !tmp.MapFaction.IsMinorFaction && tmp.IsPartyLeader && tmp.PartyBelongedTo.IsHolding == false).GetRandomElementInefficiently <Hero>();

            if (lord != null)
            {
                Vec2 escapePosition = lord.PartyBelongedTo.Position2D;
                CharacterRelationManager.SetHeroRelation(mainhero, lord, -50);


                if (CSCharCreationOption.CSLocationOption == 9)
                {
                    MobileParty.MainParty.Position2D = escapePosition;
                    MapState mapstate;
                    mapstate = (GameStateManager.Current.ActiveState as MapState);
                    mapstate.Handler.TeleportCameraToMainParty();
                }
            }
            //Using Looter gear as baseline
            CharacterObject characterObject = MBObjectManager.Instance.GetObject <CharacterObject>("looter");

            Hero.MainHero.BattleEquipment.FillFrom(characterObject.Equipment);
            Hero.MainHero.CivilianEquipment.FillFrom(characterObject.Equipment);
        }
        private void OnHourlyTickEvent(MobileParty mobileParty)
        {
            Hero companion = mobileParty.LeaderHero;

            if (mobileParty == MobileParty.MainParty ||
                companion == null ||
                !mobileParty.IsLordParty ||
                companion.Clan != Clan.PlayerClan)
            {
                return;
            }

            Settlement target = mobileParty.TargetSettlement;

            if (mobileParty.DefaultBehavior != AiBehavior.PatrolAroundPoint ||
                target.OwnerClan != Clan.PlayerClan)
            {
                return;
            }

            if (mobileParty.Position2D.DistanceSquared(target.Position2D) > MinPatrolDistance)
            {
                //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " too far away from " + target.Name));
                mobileParty.SetMoveGoToSettlement(target);
                return;
            }
            //InformationManager.DisplayMessage(new InformationMessage(companion.Name + " patrolling around " + target.Name));

            int companion_relation;

            foreach (Hero notable in target.Notables)
            {
                companion_relation = CharacterRelationManager.GetHeroRelation(companion, notable) + 1;
                if (companion_relation % HoursRequirement == 0)
                {
                    // reset companion personal relation
                    companion_relation = 0;

                    // increase player relation
                    int oldRelation = notable.GetRelation(Hero.MainHero);
                    ChangeRelationAction.ApplyPlayerRelation(notable, 1, false, false);
                    int newRelation     = notable.GetRelation(Hero.MainHero);
                    int relation_change = newRelation - oldRelation;

                    if (relation_change > 0)
                    {
                        TextObject textObject = GameTexts.FindText("str_your_relation_increased_with_notable", null);
                        TextObject heroText   = new TextObject();
                        ZenDzeeCompatibilityHelper.SetTextVariable(heroText, "NAME", notable.Name);
                        ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "HERO", heroText);
                        ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "VALUE", newRelation);
                        ZenDzeeCompatibilityHelper.SetTextVariable(textObject, "MAGNITUDE", relation_change);
                        InformationManager.DisplayMessage(new InformationMessage(textObject.ToString()));
                    }
                }
                CharacterRelationManager.SetHeroRelation(companion, notable, companion_relation);
            }
        }
        private static void SetVassal(Hero hero)
        {
            //Find a clan that matches culture
            string culture = hero.Culture.StringId;
            Hero   lord    = Hero.FindAll((Hero tmp) => (tmp.Culture.StringId == hero.Culture.StringId) && tmp.IsAlive && tmp.IsFactionLeader && !tmp.MapFaction.IsMinorFaction).GetRandomElementInefficiently <Hero>();

            if (lord != null)  //Adding to prevent crash on custom cultures with no kingdom
            {
                Clan targetclan = lord.Clan;
                CharacterRelationManager.SetHeroRelation(hero, lord, 10);
                ChangeKingdomAction.ApplyByJoinToKingdom(hero.Clan, targetclan.Kingdom, false);
                GainKingdomInfluenceAction.ApplyForJoiningFaction(hero, 10f);
            }
        }
        private static void ExiledDmgRelation()
        {
            Hero mainhero = Hero.MainHero;
            Hero lord     = Hero.FindAll((Hero tmp) => (tmp.Culture.StringId == mainhero.Culture.StringId) && tmp.IsAlive && tmp.IsFactionLeader && !tmp.MapFaction.IsMinorFaction).GetRandomElement <Hero>();

            CharacterRelationManager.SetHeroRelation(mainhero, lord, -50);
            foreach (Hero alllord in Hero.FindAll((alllord) => (alllord.MapFaction == lord.MapFaction) && alllord.IsAlive))
            {
                CharacterRelationManager.SetHeroRelation(mainhero, alllord, -5);
            }
            ;
            CharacterRelationManager.SetHeroRelation(mainhero, lord, -50);
            ChangeCrimeRatingAction.Apply(lord.MapFaction, 49, false);
            //float test = Campaign.Current.
        }
Example #6
0
        /*****************/
        /*** RELATIONS ***/
        /*****************/

        /*** Change Relation ***/
        public static void ChangeRelation(Hero lord1, Hero lord2, int change)
        {
            if (lord1 != null && lord2 != null)
            {
                int relation = CharacterRelationManager.GetHeroRelation(lord1, lord2) + change;

                if (relation > 100)
                {
                    relation = 100;
                }
                else
                {
                    if (relation < -100)
                    {
                        relation = -100;
                    }
                }

                CharacterRelationManager.SetHeroRelation(lord1, lord2, relation);
            }
        }
Example #7
0
        public static void ChangeRelation(Hero lord1, Hero lord2, int change)
        {
            bool flag = lord1 != null && lord2 != null;

            if (flag)
            {
                int  num   = CharacterRelationManager.GetHeroRelation(lord1, lord2) + change;
                bool flag2 = num > 100;
                if (flag2)
                {
                    num = 100;
                }
                else
                {
                    bool flag3 = num < -100;
                    if (flag3)
                    {
                        num = -100;
                    }
                }
                CharacterRelationManager.SetHeroRelation(lord1, lord2, num);
            }
        }
        private void UpdatePersonalRelation(Hero baseHero, Hero otherHero, int relationChange)
        {
            int newValue = MBMath.ClampInt(CharacterRelationManager.GetHeroRelation(baseHero, otherHero) + relationChange, -100, 100);

            CharacterRelationManager.SetHeroRelation(baseHero, otherHero, newValue);
        }