Beispiel #1
0
        //private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
        //{
        //    var codes = new List<CodeInstruction>(instructions);
        //    codes.RemoveRange(0, codes.Count - 1);
        //    return codes.AsEnumerable();
        //}

        private static void Postfix(TournamentGame __instance, ref ItemObject __result)
        {
            //__result currently has stock item.
            try
            {
                __result = TournamentPrizePoolBehavior.GenerateTournamentPrize(__instance, null, false);
            }
            catch (Exception ex)
            {
                ErrorLog.Log("ERROR: Tournament Prize System: GetTournamentPrize");
                ErrorLog.Log(ex.ToStringFull());
            }
        }
Beispiel #2
0
        private static void Postfix(TournamentVM __instance)
        {
            try
            {
                var currentPool = TournamentPrizePoolBehavior.GetTournamentPrizePool(__instance.Tournament.TournamentGame.Town.Settlement);
                if (!string.IsNullOrWhiteSpace(currentPool.SelectedPrizeStringId))
                {
                    var ire = currentPool.Prizes.Where(x => x.EquipmentElement.Item.StringId == currentPool.SelectedPrizeStringId).First();

                    __instance.PrizeVisual   = new ImageIdentifierVM(ire);
                    __instance.PrizeItemName = ire.EquipmentElement.GetModifiedItemName().ToString();
                }
            }
            catch (Exception ex)
            {
            }
        }
        private static bool Prefix(TournamentBehavior __instance)
        {
            var winners = (List <TournamentParticipant>)Traverse.Create(__instance.CurrentMatch).Method("GetWinners").GetValue();

            if (winners.Where(x => x.Character.HeroObject == Hero.MainHero).Count() > 0)
            {
                if (__instance.CurrentRoundIndex > TournamentPrizePoolBehavior.TournamentReward.LastPayoutIndex)
                {
                    TournamentPrizePoolBehavior.TournamentReward.LastPayoutIndex = __instance.CurrentRoundIndex;
                    if (TournamentXPSettings.Instance.EnableRenownPerTroopTier)
                    {
                        var renownbonus = 0f;
                        foreach (var team in __instance.CurrentMatch.Teams)
                        {
                            var teambonus = 0f;
                            foreach (var p in team.Participants)
                            {
                                teambonus += TournamentPrizePoolBehavior.GetRenownValue(p.Character);
                                if (p.Character.IsHero && p.Character.HeroObject == Hero.MainHero)
                                {
                                    teambonus = 0;
                                    break;
                                }
                            }
                            renownbonus += teambonus;
                        }
                        TournamentPrizePoolBehavior.TournamentReward.BonusRenown += renownbonus;
                    }
                    if (TournamentXPSettings.Instance.BonusTournamentMatchGold > 0)
                    {
                        if (TournamentXPSettings.Instance.BonusTournamentMatchGoldImmediate)
                        {
                            GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, TournamentXPSettings.Instance.BonusTournamentMatchGold, false);
                        }
                        else
                        {
                            typeof(TournamentBehavior).GetProperty("OverallExpectedDenars").SetValue(__instance, __instance.OverallExpectedDenars + TournamentXPSettings.Instance.BonusTournamentMatchGold);
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #4
0
        private static bool Prefix(PlayerTownVisitCampaignBehavior __instance, MenuCallbackArgs args)
        {
            //PlayerTownVisitCampaignBehavior.UpdateMenuLocations(args.MenuContext.GameMenu.StringId);
            //Traverse.Create(__instance).Method("UpdateMenuLocations").GetValue(new object[] { args.MenuContext.GameMenu.StringId });

            typeof(PlayerTownVisitCampaignBehavior).GetMethod("UpdateMenuLocations", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly).Invoke(__instance, new object[] { args.MenuContext.GameMenu.StringId });

            if (Settlement.CurrentSettlement == null || !Settlement.CurrentSettlement.IsTown || Campaign.Current.TournamentManager.GetTournamentGame(Settlement.CurrentSettlement.Town) == null || !Campaign.Current.IsDay)
            {
                MBTextManager.SetTextVariable("ADDITIONAL_STRING", GameTexts.FindText("str_town_empty_arena_text", null), false);
            }
            else
            {
                TextObject name = Campaign.Current.TournamentManager.GetTournamentGame(Settlement.CurrentSettlement.Town).Prize.Name;

                //Need to turn this into a transpiler instead
                var currentPool = TournamentPrizePoolBehavior.GetTournamentPrizePool(Settlement.CurrentSettlement);
                if (!string.IsNullOrWhiteSpace(currentPool.SelectedPrizeStringId))
                {
                    var ire = currentPool.Prizes.Where(x => x.EquipmentElement.Item.StringId == currentPool.SelectedPrizeStringId).FirstOrDefault();
                    name = ire.EquipmentElement.GetModifiedItemName();
                }

                MBTextManager.SetTextVariable("ITEM", name, false);
                MBTextManager.SetTextVariable("ADDITIONAL_STRING", GameTexts.FindText("str_town_new_tournament_text", null), false);
            }

            //var checknext = (bool)Traverse.Create(__instance).Method("CheckAndOpenNextLocation").GetValue(new object[] { args });
            var checknext = (bool)typeof(PlayerTownVisitCampaignBehavior).GetMethod("CheckAndOpenNextLocation", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly).Invoke(__instance, new object[] { args });

            //if (PlayerTownVisitCampaignBehavior.CheckAndOpenNextLocation(args))
            if (checknext)
            {
                return(false);
            }
            args.MenuTitle = new TextObject("{=mMU3H6HZ}Arena", null);
            return(false);
        }
Beispiel #5
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);
        }
 private static void Prefix(TournamentGame tournament)
 {
     TournamentPrizePoolBehavior.ClearTournamentPrizes(tournament.Town.Settlement);
 }
Beispiel #7
0
        private static void Postfix(TournamentGame game)
        {
            var prizePool = TournamentPrizePoolBehavior.GetTournamentPrizePool(game.Town.Settlement);

            prizePool.RemainingRerolls = TournamentXPSettings.Instance.MaxNumberOfRerollsPerTournament;
        }