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);
            }
        }
Exemple #2
0
        public bool TryToMakeTrade()
        {
            if (!CanMakeTrade)
            {
                return(false);
            }

            //get the barter manager to handle this coroutine since we can't
            mMakingTrade = true;
            BarterManager.StartCoroutine(MakeTradeoverTime());
            return(true);
        }
        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);
        }
 public static void IsOfferAcceptable(BarterData args, Hero hero, PartyBase party, ref BarterManager __instance, ref bool __result)
 {
     try
     {
         if (BannerlordCheatsSettings.Instance?.BarterOfferAlwaysAccepted == true)
         {
             __result = true;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(BarterOfferAlwaysAccepted));
     }
 }
Exemple #5
0
 public static void IsOfferAcceptable(BarterData args, Hero hero, PartyBase party, ref BarterManager __instance, ref bool __result)
 {
     if (BannerlordCheatsSettings.Instance.BarterOfferAlwaysAccepted)
     {
         __result = true;
     }
 }
Exemple #6
0
        protected IEnumerator MakeTradeoverTime()
        {
            Debug.Log("Starting to make trade");
            var loadStart = GUILoading.LoadStart(GUILoading.Mode.SmallInGame);

            while (loadStart.MoveNext())
            {
                yield return(null);
            }
            GUILoading.ActivityInfo = "Making Trade... " + CharacterGoods.Count.ToString() + " character goods going to player";
            //give stuff to player...
            foreach (BarterGoods good in CharacterGoods)
            {
                foreach (KeyValuePair <WIStack, int> goodPair in good)
                {
                    if (goodPair.Key.HasTopItem)
                    {
                        Debug.Log("Adding " + goodPair.Key.TopItem.FileName + " to player inventory...");
                    }
                    var addItem = PlayerInventory.AddItems(goodPair.Key, goodPair.Value);
                    while (addItem.MoveNext())
                    {
                        yield return(null);
                    }
                }
                yield return(null);
            }
            //wait a tick...
            yield return(null);

            //give stuff to character...
            foreach (BarterGoods good in PlayerGoods)
            {
                foreach (KeyValuePair <WIStack, int> goodPair in good)
                {
                    var enumerator = CharacterInventory.AddItems(goodPair.Key, goodPair.Value);
                    while (enumerator.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            //TODO determine what counts as a 'successful use'
            BarterManager.Use(true);

            PlayerBank.Absorb(CharacterGoodsBank);
            CharacterBank.Absorb(PlayerGoodsBank);

            ClearGoodsAndCurrency();
            MadeTradeThisSession = true;
            Player.Get.AvatarActions.ReceiveAction(AvatarAction.BarterMakeTrade, WorldClock.AdjustedRealTime);
            var loadFinish = GUILoading.LoadFinish();

            while (loadFinish.MoveNext())
            {
                yield return(null);
            }
            Debug.Log("Finished making trade");
            mMakingTrade = false;
            yield break;
        }