private static void conversation_set_up_safe_passage_barter_on_consequence(DialogueParams param)
        {
            BarterManager instance = BarterManager.Instance;
            Hero          oneToOneConversationHero = Hero.OneToOneConversationHero;
            PartyBase     mainParty  = PartyBase.MainParty;
            PartyBase     otherParty = MobileParty.ConversationParty?.Party;

            BarterManager.BarterContextInitializer initContext =
                new BarterManager.BarterContextInitializer(BarterManager.Instance.InitializeSafePassageBarterContext);
            int  persuasionCostReduction = 0;
            bool isAIBarter = false;


            if (Hero.OneToOneConversationHero == null)
            {
                Barterable[] array = new Barterable[1];
                array[0] = new SafePassageBarterable(null, Hero.MainHero, otherParty, PartyBase.MainParty);
                instance.StartBarterOffer(Hero.MainHero, oneToOneConversationHero, mainParty, otherParty, null, initContext,
                                          persuasionCostReduction, isAIBarter, array);
            }
            else
            {
                Barterable[] array = new Barterable[2];
                array[0] = new SafePassageBarterable(oneToOneConversationHero, Hero.MainHero, otherParty, PartyBase.MainParty);
                array[1] = new NoAttackBarterable(Hero.MainHero, oneToOneConversationHero, mainParty,
                                                  otherParty, CampaignTime.Days(5f));
                instance.StartBarterOffer(Hero.MainHero, oneToOneConversationHero, mainParty, otherParty, null,
                                          initContext, persuasionCostReduction, isAIBarter, array);
            }
        }
Example #2
0
        public void DailyHeroTick(Hero hero)
        {
            if (!hero.IsPrisoner || hero.PartyBelongedToAsPrisoner == null || hero == Hero.MainHero)
            {
                return;
            }

            if (CESettings.Instance.EscapeAutoRansom.SelectedIndex == 1 && hero.Clan != null && hero.PartyBelongedToAsPrisoner.MapFaction != null && MBRandom.RandomFloat < 0.1f)
            {
                // DiplomaticBartersBehavior
                IFaction mapFaction = hero.PartyBelongedToAsPrisoner.MapFaction;
                SetPrisonerFreeBarterable setPrisonerFreeBarterable = new SetPrisonerFreeBarterable(hero, mapFaction.Leader, hero.PartyBelongedToAsPrisoner, hero.Clan.Leader);
                if (setPrisonerFreeBarterable.GetValueForFaction(mapFaction) + setPrisonerFreeBarterable.GetValueForFaction(hero.Clan) > 0)
                {
                    IEnumerable <Barterable> baseBarterables = new Barterable[] { setPrisonerFreeBarterable };

                    BarterData barterData = new BarterData(mapFaction.Leader, hero.Clan.Leader, null, null, null, 0, true);
                    barterData.AddBarterGroup(new DefaultsBarterGroup());
                    foreach (Barterable barterable in baseBarterables)
                    {
                        barterable.SetIsOffered(true);
                        barterData.AddBarterable <DefaultsBarterGroup>(barterable, true);
                    }
                    Campaign.Current.BarterManager.ExecuteAIBarter(barterData, mapFaction, hero.Clan, mapFaction.Leader, hero.Clan.Leader);
                    return;
                }
            }

            if (CEApplyHeroChanceToEscape(hero))
            {
                return;
            }

            float num = 0.075f;

            if (hero.PartyBelongedToAsPrisoner.IsMobile)
            {
                num *= 6f - (float)Math.Pow(Math.Min(81, hero.PartyBelongedToAsPrisoner.NumberOfHealthyMembers), 0.25);
            }

            if (hero.PartyBelongedToAsPrisoner == PartyBase.MainParty || hero.PartyBelongedToAsPrisoner.IsSettlement && hero.PartyBelongedToAsPrisoner.Settlement.OwnerClan == Clan.PlayerClan)
            {
                num *= hero.PartyBelongedToAsPrisoner.IsSettlement
                    ? 0.5f
                    : 0.33f;
            }

            if (MBRandom.RandomFloat < num)
            {
                EndCaptivityAction.ApplyByEscape(hero);
                return;
            }
        }
        private static void barter_for_peace_consequence_delegate(DialogueParams param) // looks like a lot, I just stole most of this from tw >_>
        {
            BarterManager instance = BarterManager.Instance;
            Hero          mainHero = Hero.MainHero;
            Hero          oneToOneConversationHero = Hero.OneToOneConversationHero;
            PartyBase     mainParty              = PartyBase.MainParty;
            MobileParty   conversationParty      = MobileParty.ConversationParty;
            PartyBase     otherParty             = (conversationParty != null) ? conversationParty.Party : null;
            Hero          beneficiaryOfOtherHero = null;

            BarterManager.BarterContextInitializer initContext = new BarterManager.BarterContextInitializer(BarterManager.Instance.InitializeMakePeaceBarterContext);
            int  persuasionCostReduction = 0;
            bool isAIBarter = false;

            Barterable[] array              = new Barterable[1];
            int          num                = 0;
            Hero         originalOwner      = conversationParty.MapFaction.Leader;
            Hero         mainHero2          = Hero.MainHero;
            MobileParty  conversationParty2 = MobileParty.ConversationParty;

            array[num] = new PeaceBarterable(originalOwner, conversationParty.MapFaction, mainHero.MapFaction, CampaignTime.Years(1f));
            instance.StartBarterOffer(mainHero, oneToOneConversationHero, mainParty, otherParty, beneficiaryOfOtherHero, initContext, persuasionCostReduction, isAIBarter, array);
        }
Example #4
0
        private ComplexCost GetWithholdCost()
        {
            if (!SettingsHelper.SubSystemEnabled(SubSystemType.LoyaltyWithholding, LeavingClan))
            {
                return(null);
            }

            if (TargetKingdom != null)
            {
                JoinKingdomAsClanBarterable asClanBarterable = new JoinKingdomAsClanBarterable(LeavingClan.Leader, TargetKingdom);
                int ClanBarterableValueForClan    = asClanBarterable.GetValueForFaction(LeavingClan);
                int ClanBarterableValueForKingdom = asClanBarterable.GetValueForFaction(TargetKingdom);
                ClanBarterable = asClanBarterable;
                BarterableSum  = ClanBarterableValueForClan + ClanBarterableValueForKingdom;
            }
            else
            {
                LeaveKingdomAsClanBarterable asClanBarterable = new LeaveKingdomAsClanBarterable(LeavingClan.Leader, null);
                int ClanBarterableValueForFaction             = asClanBarterable.GetValueForFaction(LeavingClan);
                ClanBarterable = asClanBarterable;
                BarterableSum  = ClanBarterableValueForFaction - (LeavingClan.IsMinorFaction ? 500 : 0);
            }

            if (BarterableSum <= Settings.Instance.WithholdToleranceLimit * 1000000)
            {
                return(null);
            }
            BaseCalculatedCost = Math.Sqrt(BarterableSum) / Math.Log10(BarterableSum);

            return
                (new ComplexCost
                 (
                     (int)(BaseCalculatedCost * Settings.Instance.WithholdInfluenceMultiplier),
                     Settings.Instance.UseWithholdBribing && Settings.Instance.WithholdToleranceLimitForBribes * 1000000 < BarterableSum ? (int)BaseCalculatedCost * Settings.Instance.WithholdGoldMultiplier : 0
                 ));
        }
 public static void ExecuteAiBarter(object instance, IFaction faction1, IFaction faction2, Hero faction1Hero, Hero faction2Hero, Barterable barterable)
 {
     // its a stub so it has no initial content
     throw new System.NotImplementedException("It's a stub");
 }