Esempio n. 1
0
        private void conversation_tavernkeep_bought_drinks()
        {
            int _curDrinkPrice = CalculateDrinksPrice();

            GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, _curDrinkPrice, false);
            if (_curDrinkPrice >= 500 && _curDrinkPrice < 1000)
            {
                GainRenownAction.Apply(Hero.MainHero, MBRandom.RandomFloatRanged(1.0f, 2.0f));
                Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(2, 4));
            }
            else if (_curDrinkPrice >= 1000 && _curDrinkPrice < 1500)
            {
                GainRenownAction.Apply(Hero.MainHero, MBRandom.RandomFloatRanged(2.0f, 3.5f));
                Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(4, 8));
            }
            else if (_curDrinkPrice >= 1500)
            {
                GainRenownAction.Apply(Hero.MainHero, MBRandom.RandomFloatRanged(3.5f, 5.0f));
                Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(5, 10));
            }
            InformationManager.DisplayMessage(new InformationMessage("Gained some renown and charm for buying drinks."));
            _boughtDrinksIn.Add(MobileParty.MainParty.CurrentSettlement);
        }
Esempio n. 2
0
        //REVISIT - convert to transpiler patch to just change our prize payment
        // All we really need to change is instead of giving an ItemObject - which has no ItemModifers, we give them an ItemRosterEquipement, which can have ItemModifiers
        private static bool Prefix(ref TournamentBehavior __instance)
        {
            //Override Standard behavior
            if (Campaign.Current.GameMode != CampaignGameMode.Campaign)
            {
                return(false);
            }

            /* Give Gold, Influence, Renown */
            if (__instance.OverallExpectedDenars > 0)
            {
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, __instance.OverallExpectedDenars, false);
            }
            GainRenownAction.Apply(Hero.MainHero, __instance.TournamentGame.TournamentWinRenown, false);
            if (Hero.MainHero.MapFaction.IsKingdomFaction && Hero.MainHero.MapFaction.Leader != Hero.MainHero)
            {
                GainKingdomInfluenceAction.ApplyForDefault(Hero.MainHero, TournamentPrizePoolBehavior.TournamentReward.BonusInfluence);
            }

            /* Give Item Prize */
            if (!TournamentXPSettings.Instance.EnableItemModifiersForPrizes)
            {
                if (!TournamentPrizePoolBehavior.TournamentReward.PrizeGiven)
                {
                    Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(__instance.TournamentGame.Prize, 1, true);
                    TournamentPrizePoolBehavior.TournamentReward.PrizeGiven = true;
                }
            }
            else
            {
                TournamentPrizePool currentPool = null;
                string prizeStringId            = "";
                try
                {
                    if (!TournamentPrizePoolBehavior.TournamentReward.PrizeGiven)
                    {
                        currentPool   = TournamentPrizePoolBehavior.GetTournamentPrizePool(__instance.Settlement);
                        prizeStringId = __instance.TournamentGame.Prize.StringId;

                        //Beta1.2
#if VERSION120
                        Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(currentPool.Prizes.Where(x => x.EquipmentElement.Item.StringId == prizeStringId).First().EquipmentElement, 1, true);
#endif
                        //Release1.1.1
#if VERSION111
                        Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(currentPool.Prizes.Where(x => x.EquipmentElement.Item.StringId == prizeStringId).First(), 1, true);
#endif
                        TournamentPrizePoolBehavior.TournamentReward.PrizeGiven = true;
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog.Log("ERROR: Tournament XPanded: OnPlayerWinTournament\nError Awarding Prize");

                    ErrorLog.Log("TournamentPrizePool:\n");
                    if (currentPool != null)
                    {
                        ErrorLog.Log(Newtonsoft.Json.JsonConvert.SerializeObject(currentPool));
                    }

                    ErrorLog.Log(ex.ToStringFull());

                    if (!TournamentPrizePoolBehavior.TournamentReward.PrizeGiven)
                    {
                        Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(__instance.TournamentGame.Prize, 1, true);
                        TournamentPrizePoolBehavior.TournamentReward.PrizeGiven = true;
                    }
                }
            }
            Campaign.Current.TournamentManager.OnPlayerWinTournament(__instance.TournamentGame.GetType());

            return(false);
        }
        //REVISIT - convert to transpiler patch to just change our prize payment
        // All we really need to change is instead of giving an ItemObject - which has no ItemModifers, we give them an ItemRosterEquipement, which can have ItemModifiers
        private static bool Prefix(ref TournamentBehavior __instance)
        {
            //Override Standard behavior
            if (Campaign.Current.GameMode != CampaignGameMode.Campaign)
            {
                return(false);
            }
            var tournamentInfo = TournamentsXPandedBehavior.GetTournamentInfo(__instance.TournamentGame.Town);
            var settlement     = __instance.Settlement;

            /* Give Gold, Influence, Renown */
            if (__instance.OverallExpectedDenars > 0)
            {
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, __instance.OverallExpectedDenars, false);
            }
            GainRenownAction.Apply(Hero.MainHero, __instance.TournamentGame.TournamentWinRenown, false);
            if (Hero.MainHero.MapFaction.IsKingdomFaction && Hero.MainHero.MapFaction.Leader != Hero.MainHero)
            {
                GainKingdomInfluenceAction.ApplyForDefault(Hero.MainHero, tournamentInfo.Rewards.BonusInfluence);
            }
            /* Give Reputation */
            try
            {
                if (TournamentXPSettings.Instance.BonusReputationForTournamentWin > 0)
                {
                    List <Hero> heros = new List <Hero>();

                    foreach (var n in settlement.Notables)
                    {
                        if (!heros.Contains(n))
                        {
                            heros.Add(n);
                        }
                    }
                    foreach (var v in settlement.BoundVillages)
                    {
                        foreach (var n in v.Settlement.Notables)
                        {
                            if (!heros.Contains(n))
                            {
                                heros.Add(n);
                            }
                        }
                    }
                    if (settlement.OwnerClan.Heroes.Any <Hero>())
                    {
                        foreach (var n in settlement.OwnerClan.Heroes)
                        {
                            if (!heros.Contains(n))
                            {
                                heros.Add(n);
                            }
                        }
                    }
                    if (settlement.HeroesWithoutParty.Count > 0)
                    {
                        foreach (var n in settlement.HeroesWithoutParty)
                        {
                            if (!heros.Contains(n))
                            {
                                heros.Add(n);
                            }
                        }
                    }

                    foreach (var h in heros)
                    {
                        if (MBRandom.RandomFloat < .51f)
                        {
                            ChangeRelationAction.ApplyPlayerRelation(h, TournamentXPSettings.Instance.BonusReputationForTournamentWin, true, false);
                        }
                    }
                }

                MBTextManager.SetTextVariable("RELATION_VALUE", TournamentXPSettings.Instance.BonusReputationForTournamentWin, false);
                InformationManager.AddQuickInformation(new TextObject("{=o0qwDa0q}Your relation increased by {RELATION_VALUE} with nearby notables.", null), 0, null, "");
            }
            catch (Exception ex)
            {
                ErrorLog.Log("Error giving Reputation:\n" + ex.ToStringFull());
            }

            /* Give Item Prize */
            if (!TournamentXPSettings.Instance.EnableItemModifiersForPrizes)
            {
                if (!tournamentInfo.Rewards.PrizeGiven)
                {
                    try
                    {
                        Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(__instance.TournamentGame.Prize, 1, true);
                        tournamentInfo.Rewards.PrizeGiven = true;
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Log("Error assigning prize\n" + ex.ToStringFull());
                    }
                }
            }
            else
            {
                try
                {
                    if (!tournamentInfo.Rewards.PrizeGiven)
                    {
                        try
                        {
                            if (!String.IsNullOrWhiteSpace(tournamentInfo.SelectedPrizeStringId))
                            {
                                Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(tournamentInfo.SelectedPrizeItem.ToItemRosterElement().EquipmentElement, 1, true);
                                tournamentInfo.Rewards.PrizeGiven = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorLog.Log("Error assigning prize\n" + ex.ToStringFull());
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog.Log("ERROR: Tournament XPanded: OnPlayerWinTournament\nError Awarding Prize");
                    ErrorLog.Log("TournamentPrizePool:\n");
                    if (tournamentInfo != null)
                    {
                        ErrorLog.Log(Newtonsoft.Json.JsonConvert.SerializeObject(tournamentInfo));
                    }
                    ErrorLog.Log(ex.ToStringFull());
                }
            }

            if (!tournamentInfo.Rewards.PrizeGiven)
            {
                try
                {
                    Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(__instance.TournamentGame.Prize, 1, true);
                    tournamentInfo.Rewards.PrizeGiven = true;
                }
                catch (Exception ex2)
                {
                    ErrorLog.Log("Error assigning prize\n" + ex2.ToStringFull());
                }
            }

            tournamentInfo.ReRollsUsed = 0;
            Campaign.Current.TournamentManager.OnPlayerWinTournament(__instance.TournamentGame.GetType());

            return(false);
        }