private void DoTellStories(ToldStoriesTo village) { if (village._battleStoriesTold < _notableBattlesWon) { float _renownToGive = CalculateRenownToGive(); GainRenownAction.Apply(Hero.MainHero, _renownToGive, true); InformationManager.DisplayMessage(new InformationMessage("You told the villagers a story about a notable battle, gained " + _renownToGive + " renown.")); village._daysToResetStories = CampaignTime.DaysFromNow(RandomizeDays()); village._hasToldStories = true; village._battleStoriesTold++; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(1, 3)); if (_renownToGive >= 0.9) { if (Settlement.CurrentSettlement.Notables.Count >= 1) { InformationManager.DisplayMessage(new InformationMessage("Notable people in village were impressed by your feats and like you more.")); foreach (Hero notablePerson in Settlement.CurrentSettlement.Notables) { ChangeRelationAction.ApplyPlayerRelation(notablePerson, +1, false, true); } } } } else { InformationManager.DisplayMessage(new InformationMessage("You do not have new stories to tell to these villagers.")); } }
private void OnPlayerWinTournament() { if (Campaign.Current.GameMode != CampaignGameMode.Campaign) { return; } GainRenownAction.Apply(Hero.MainHero, this._tournamentGame.TournamentWinRenown, false); if (Hero.MainHero.MapFaction.IsKingdomFaction && Hero.MainHero.MapFaction.Leader != Hero.MainHero) { GainKingdomInfluenceAction.ApplyForDefault(Hero.MainHero, 1f); } Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(this._tournamentGame.Prize, 1, true); if (this.OverallExpectedDenars > 0) { GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this.OverallExpectedDenars, false); } Campaign.Current.TournamentManager.OnPlayerWinTournament(this._tournamentGame.GetType()); }
private void DoTellStories(ToldStoriesTo village) { if (village._battleStoriesTold < _notableBattlesWon) { SkillObject skill; int num; skill = SkillObject.FindFirst((x) => { return(x.StringId == "Charm"); }); num = (int)Math.Ceiling(MobileParty.MainParty.LeaderHero.GetSkillValue(skill) * 0.03f); float _renownToGive = CalculateRenownToGive(num); GainRenownAction.Apply(Hero.MainHero, _renownToGive, true); if ((double)_renownToGive <= 0.2) { village._daysToResetStories = CampaignTime.DaysFromNow(this.RandomizeDays()); village._hasToldStories = true; ++village._battleStoriesTold; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, 1); InformationManager.DisplayMessage(new InformationMessage("Your story failed to inspire the villagers.")); return; } InformationManager.DisplayMessage(new InformationMessage("You told the villagers a story about a notable battle, gained " + _renownToGive + " renown.")); village._daysToResetStories = CampaignTime.DaysFromNow(RandomizeDays()); village._hasToldStories = true; village._battleStoriesTold++; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(1, 3)); if (_renownToGive >= 2.0) { if (Settlement.CurrentSettlement.Notables.Count >= 1) { InformationManager.DisplayMessage(new InformationMessage("Notable people in village were impressed by your feats and like you more.")); foreach (Hero notablePerson in Settlement.CurrentSettlement.Notables) { int _relationToGive = CalculateRelationToGive(_renownToGive); ChangeRelationAction.ApplyPlayerRelation(notablePerson, _relationToGive, false, true); } } } } else { InformationManager.DisplayMessage(new InformationMessage("You do not have new stories to tell to these villagers.")); } }
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); }
//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); }