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(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); }
//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 Postfix(TournamentGame game) { var prizePool = TournamentPrizePoolBehavior.GetTournamentPrizePool(game.Town.Settlement); prizePool.RemainingRerolls = TournamentXPSettings.Instance.MaxNumberOfRerollsPerTournament; }