public static void OnApplicationTick() { if (ScreenManager.TopScreen is GauntletPartyScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.X) && BannerlordCheatsSettings.Instance.EnableHotkeys) { var partyScreen = ScreenManager.TopScreen as GauntletPartyScreen; var partyVM = partyScreen.GetViewModel <PartyVM>(); var selectedCharacter = partyVM.CurrentCharacter; if (selectedCharacter.IsHero || (!selectedCharacter.IsUpgrade1Exists && !selectedCharacter.IsUpgrade2Exists)) { return; } var index = PartyBase.MainParty.MemberRoster.FindIndexOfTroop(selectedCharacter.Character); var missingXp = selectedCharacter.MaxXP * selectedCharacter.Number - selectedCharacter.CurrentXP; PartyBase.MainParty.MemberRoster.AddXpToTroopAtIndex(missingXp, index); var newTroop = selectedCharacter.Troop; newTroop.Xp = selectedCharacter.MaxXP * selectedCharacter.Number; selectedCharacter.Troop = newTroop; selectedCharacter.InitializeUpgrades(); var message = string.Format(L10N.GetText("AddTroopXpMessage"), selectedCharacter.Name); InformationManager.DisplayMessage(new InformationMessage(message, Color.White)); } }
private static void AddItems(int count) { var inventoryScreen = ScreenManager.TopScreen as InventoryGauntletScreen; var inventoryVM = inventoryScreen.GetViewModel <SPInventoryVM>(); var selectedItem = inventoryVM.GetSelectedItem(); if (selectedItem == null) { return; } var index = TaleWorlds.CampaignSystem.PartyBase.MainParty.ItemRoster.FindIndexOfElement(selectedItem.ItemRosterElement.EquipmentElement); if (index < 0) { return; } TaleWorlds.CampaignSystem.PartyBase.MainParty.ItemRoster.AddToCounts(selectedItem.ItemRosterElement.EquipmentElement, count); selectedItem.ItemCount += count; var message = string.Format(L10N.GetText("AddItemsMessage"), count, selectedItem.ItemDescription); Message.Show(message); }
private static void AddTroops(int count) { var partyScreen = ScreenManager.TopScreen as GauntletPartyScreen; var partyVM = partyScreen.GetViewModel <PartyVM>(); var selectedCharacter = partyVM.CurrentCharacter; if (selectedCharacter.IsHero) { return; } var index = PartyBase.MainParty.MemberRoster.FindIndexOfTroop(selectedCharacter.Character); PartyBase.MainParty.AddToMemberRosterElementAtIndex(index, count); var newTroop = selectedCharacter.Troop; newTroop.Number += count; selectedCharacter.Troop = newTroop; selectedCharacter.UpdateTradeData(); selectedCharacter.ThrowOnPropertyChanged(); var message = string.Format(L10N.GetText("AddTroopsMessage"), count, selectedCharacter.Name); InformationManager.DisplayMessage(new InformationMessage(message, Color.White)); }
private static void AddTroops(int count) { var partyScreen = ScreenManager.TopScreen as GauntletPartyScreen; var partyVM = partyScreen.GetViewModel <PartyVM>(); var selectedCharacter = partyVM.CurrentCharacter; if (selectedCharacter.IsHero) { return; } if (selectedCharacter.IsPrisoner) { PartyBase.MainParty.AddPrisoner(selectedCharacter.Character, count); } else { PartyBase.MainParty.AddMember(selectedCharacter.Character, count); } var newTroop = selectedCharacter.Troop; newTroop.Number += count; selectedCharacter.Troop = newTroop; selectedCharacter.UpdateTradeData(); selectedCharacter.ThrowOnPropertyChanged(); var message = string.Format(L10N.GetText("AddTroopsMessage"), count, selectedCharacter.Name); Message.Show(message); }
public static void OnApplicationTick() { try { if (ScreenManager.TopScreen is InventoryGauntletScreen && BannerlordCheatsSettings.Instance?.EnableHotkeys == true) { if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.LeftShift, InputKey.X)) { Hero.MainHero.ChangeHeroGold(100000); Message.Show(string.Format(L10N.GetText("AddGoldMessage"), 100000)); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.X)) { Hero.MainHero.ChangeHeroGold(1000); Message.Show(string.Format(L10N.GetText("AddGoldMessage"), 1000)); } } } catch (Exception e) { SubModule.LogError(e, typeof(EnableHotkeysMoney)); } }
public static void OnApplicationTick() { if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.F) && BannerlordCheatsSettings.Instance.EnableHotkeys) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; currentHero.HeroDeveloper.UnspentFocusPoints++; charVM.CurrentCharacter.UnspentCharacterPoints++; var message = string.Format(L10N.GetText("AddUnspentFocusPointMessage"), currentHero.Name); InformationManager.DisplayMessage(new InformationMessage(message, Color.White)); } else if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.G) && BannerlordCheatsSettings.Instance.EnableHotkeys) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; currentHero.HeroDeveloper.UnspentAttributePoints++; charVM.CurrentCharacter.UnspentAttributePoints++; var message = string.Format(L10N.GetText("AddUnspentAttributePointMessage"), currentHero.Name); InformationManager.DisplayMessage(new InformationMessage(message, Color.White)); } }
private static void AddTroops(CharacterObject characterObject, int count) { PartyBase.MainParty.AddMember(characterObject, count); var message = string.Format(L10N.GetText("AddTroopsFromEncyclopediaMessage"), count, characterObject.Name); Message.Show(message); }
public BannerlordCheatsSettings() { string modName; try { modName = L10N.GetText(BannerlordCheatsSettings.ModName); } catch { modName = "Cheats"; } this.DisplayName = $"{modName} {Assembly.GetExecutingAssembly().GetName().Version}"; }
public static void OnApplicationTick() { if (ScreenManager.TopScreen is GauntletClanScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.X) && BannerlordCheatsSettings.Instance.EnableHotkeys) { Hero.MainHero.AddInfluenceWithKingdom(1000); InformationManager.DisplayMessage(new InformationMessage(L10N.GetText("AddInfluenceMessage"), Color.White)); } }
public static void OnApplicationTick() { try { if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && BannerlordCheatsSettings.Instance?.EnableHotkeys == true) { if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.A)) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; EnableHotkeysCharacterAttributes.SetMaximum(currentHero, DefaultCharacterAttributes.Control); EnableHotkeysCharacterAttributes.SetMaximum(currentHero, DefaultCharacterAttributes.Cunning); EnableHotkeysCharacterAttributes.SetMaximum(currentHero, DefaultCharacterAttributes.Endurance); EnableHotkeysCharacterAttributes.SetMaximum(currentHero, DefaultCharacterAttributes.Intelligence); EnableHotkeysCharacterAttributes.SetMaximum(currentHero, DefaultCharacterAttributes.Social); EnableHotkeysCharacterAttributes.SetMaximum(currentHero, DefaultCharacterAttributes.Vigor); charVM.RefreshValues(); var message = string.Format(L10N.GetText("SetAllAttributesMessage"), currentHero.Name); Message.Show(message); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D1)) { EnableHotkeysCharacterAttributes.AddPoint(DefaultCharacterAttributes.Vigor); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D2)) { EnableHotkeysCharacterAttributes.AddPoint(DefaultCharacterAttributes.Control); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D3)) { EnableHotkeysCharacterAttributes.AddPoint(DefaultCharacterAttributes.Endurance); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D4)) { EnableHotkeysCharacterAttributes.AddPoint(DefaultCharacterAttributes.Cunning); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D5)) { EnableHotkeysCharacterAttributes.AddPoint(DefaultCharacterAttributes.Social); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D6)) { EnableHotkeysCharacterAttributes.AddPoint(DefaultCharacterAttributes.Intelligence); } } } catch (Exception e) { SubModule.LogError(e, typeof(EnableHotkeysCharacterAttributes)); } }
public static void OnApplicationTick() { if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.A) && BannerlordCheatsSettings.Instance.EnableHotkeys) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; currentHero.SetAttributeValue(CharacterAttributesEnum.Control, 10); currentHero.SetAttributeValue(CharacterAttributesEnum.Cunning, 10); currentHero.SetAttributeValue(CharacterAttributesEnum.Endurance, 10); currentHero.SetAttributeValue(CharacterAttributesEnum.Intelligence, 10); currentHero.SetAttributeValue(CharacterAttributesEnum.Social, 10); currentHero.SetAttributeValue(CharacterAttributesEnum.Vigor, 10); charVM.RefreshValues(); var message = string.Format(L10N.GetText("SetAllAttributesMessage"), currentHero.Name); InformationManager.DisplayMessage(new InformationMessage(message, Color.White)); } if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D1) && BannerlordCheatsSettings.Instance.EnableHotkeys) { AddPoint(CharacterAttributesEnum.Vigor); } if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D2) && BannerlordCheatsSettings.Instance.EnableHotkeys) { AddPoint(CharacterAttributesEnum.Control); } if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D3) && BannerlordCheatsSettings.Instance.EnableHotkeys) { AddPoint(CharacterAttributesEnum.Endurance); } if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D4) && BannerlordCheatsSettings.Instance.EnableHotkeys) { AddPoint(CharacterAttributesEnum.Cunning); } if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D5) && BannerlordCheatsSettings.Instance.EnableHotkeys) { AddPoint(CharacterAttributesEnum.Social); } if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D6) && BannerlordCheatsSettings.Instance.EnableHotkeys) { AddPoint(CharacterAttributesEnum.Intelligence); } }
public override void OnInitialState() { base.OnInitialState(); if (!SubModule.ConfirmFileExists()) { InformationManager.ShowInquiry(new InquiryData( L10N.GetText("ModName"), L10N.GetText("ModWarningMessage"), true, false, L10N.GetText("ModWarningMessageConfirm"), null, SubModule.CreateConfirmFile, null)); } }
public BannerlordCheatsSettings() { string modName; try { modName = L10N.GetText(BannerlordCheatsSettings.ModName); } catch { modName = "Cheats"; } var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); version = Regex.Replace(version, @"\.0", string.Empty); if (!version.Contains(".")) { version += ".0"; } this.DisplayName = $"{modName} {version}"; }
public static void OnApplicationTick() { try { if (ScreenManager.TopScreen is GauntletClanScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.X) && BannerlordCheatsSettings.Instance?.EnableHotkeys == true) { Hero.MainHero.AddInfluenceWithKingdom(1000); Message.Show(L10N.GetText("AddInfluenceMessage")); } } catch (Exception e) { SubModule.LogError(e, typeof(EnableHotkeysInfluence)); } }
public static void OnApplicationTick() { try { if (ScreenManager.TopScreen is GauntletCharacterDeveloperScreen && BannerlordCheatsSettings.Instance?.EnableHotkeys == true) { if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.F)) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; currentHero.HeroDeveloper.UnspentFocusPoints++; charVM.CurrentCharacter.UnspentCharacterPoints++; var message = string.Format(L10N.GetText("AddUnspentFocusPointMessage"), currentHero.Name); Message.Show(message); } else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.G)) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; currentHero.HeroDeveloper.UnspentAttributePoints++; charVM.CurrentCharacter.UnspentAttributePoints++; var message = string.Format(L10N.GetText("AddUnspentAttributePointMessage"), currentHero.Name); Message.Show(message); } } } catch (Exception e) { SubModule.LogError(e, typeof(EnableHotkeysCharacterPoints)); } }
public override void OnGameInitializationFinished(Game game) { base.OnGameInitializationFinished(game); if (!(game.GameType is Campaign) || SubModule.PatchesApplied) { return; } try { var harmony = new Harmony("BannerlordCheats"); harmony.PatchAll(); SubModule.PatchesApplied = true; } catch (Exception e) { Debugger.Break(); try { var errorFilePath = SubModule.CreateErrorFile(e); InformationManager.ShowInquiry(new InquiryData( L10N.GetText("ModFailedLoadWarningTitle"), L10N.GetTextFormat("ModFailedLoadWarningMessage", errorFilePath), true, false, L10N.GetText("ModWarningMessageConfirm"), null, null, null)); } catch { // Not worth crashing for } } }
public static void OnApplicationTick() { try { if (ScreenManager.TopScreen is GauntletPartyScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.X) && BannerlordCheatsSettings.Instance?.EnableHotkeys == true) { var partyScreen = ScreenManager.TopScreen as GauntletPartyScreen; var partyVM = partyScreen.GetViewModel <PartyVM>(); var selectedCharacter = partyVM.CurrentCharacter; if (selectedCharacter.IsHero || !selectedCharacter.IsUpgradableTroop) { return; } var index = PartyBase.MainParty.MemberRoster.FindIndexOfTroop(selectedCharacter.Character); var missingXp = selectedCharacter.MaxXP * selectedCharacter.Number - selectedCharacter.CurrentXP; PartyBase.MainParty.MemberRoster.AddXpToTroopAtIndex(missingXp, index); var newTroop = selectedCharacter.Troop; newTroop.Xp = selectedCharacter.MaxXP * selectedCharacter.Number; selectedCharacter.Troop = newTroop; selectedCharacter.InitializeUpgrades(); var message = string.Format(L10N.GetText("AddTroopXpMessage"), selectedCharacter.Name); Message.Show(message); } } catch (Exception e) { SubModule.LogError(e, typeof(EnableHotkeysTroopExperience)); } }
private static void AddPoint(CharacterAttributesEnum type) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; var oldValue = currentHero.GetAttributeValue(type); if (oldValue >= 10) { return; } currentHero.SetAttributeValue(type, oldValue + 1); charVM.RefreshValues(); var message = string.Format(L10N.GetText("AddAttributePointMessage"), Enum.GetName(typeof(CharacterAttributesEnum), type), currentHero.Name); InformationManager.DisplayMessage(new InformationMessage(message, Color.White)); }
private static void AddPoint(CharacterAttribute attribute) { var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>(); var currentHero = charVM.CurrentCharacter.Hero; var oldValue = currentHero.GetAttributeValue(attribute); if (oldValue >= 10) { return; } currentHero.HeroDeveloper.AddAttribute(attribute, 1, false); charVM.RefreshValues(); var message = string.Format(L10N.GetText("AddAttributePointMessage"), attribute.Name, currentHero.Name); Message.Show(message); }
internal static void LogError(Exception e, Type type) { string errorFilePath; try { errorFilePath = SubModule.CreateErrorFile(e, type); } catch { return; } try { InformationManager.ShowInquiry(new InquiryData( L10N.GetText("ModExceptionTitle"), L10N.GetTextFormat("ModExceptionMessage", errorFilePath), true, false, L10N.GetText("ModWarningMessageConfirm"), null, null, null)); } catch { try { Message.Show(L10N.GetTextFormat("ModExceptionMessage", errorFilePath), Colors.Red); } catch { // If this fails everything is lost anyways } } }
public static void OnApplicationTick() { if (ScreenManager.TopScreen is InventoryGauntletScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.X) && BannerlordCheatsSettings.Instance.EnableHotkeys) { Hero.MainHero.ChangeHeroGold(1000); InformationManager.DisplayMessage(new InformationMessage(string.Format(L10N.GetText("AddGoldMessage"), 1000), Color.White)); } else if (ScreenManager.TopScreen is InventoryGauntletScreen && Keys.IsKeyPressed(InputKey.LeftControl, InputKey.LeftShift, InputKey.X) && BannerlordCheatsSettings.Instance.EnableHotkeys) { Hero.MainHero.ChangeHeroGold(100000); InformationManager.DisplayMessage(new InformationMessage(string.Format(L10N.GetText("AddGoldMessage"), 100000), Color.White)); } }