/// <summary> /// Raise skills if conditions are met. /// </summary> public void RaiseSkills() { DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; if ((now.ToClassicDaggerfallTime() - timeOfLastSkillIncreaseCheck) <= 360) { return; } timeOfLastSkillIncreaseCheck = now.ToClassicDaggerfallTime(); for (short i = 0; i < skillUses.Length; i++) { int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier((DFCareer.Skills)i); float careerAdvancementMultiplier = Career.AdvancementMultiplier; int usesNeededForAdvancement = FormulaHelper.CalculateSkillUsesForAdvancement(skills.GetSkillValue(i), skillAdvancementMultiplier, careerAdvancementMultiplier, level); if (skillUses[i] >= usesNeededForAdvancement) { skillUses[i] = 0; skills.SetSkillValue(i, (short)(skills.GetSkillValue(i) + 1)); SetCurrentLevelUpSkillSum(); DaggerfallUI.Instance.PopupMessage(HardStrings.skillImprove.Replace("%s", DaggerfallUnity.Instance.TextProvider.GetSkillName((DaggerfallConnect.DFCareer.Skills)i))); } } if (CheckForLevelUp()) { DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenCharacterSheetWindow); } }
/// <summary> /// Raise skills if conditions are met. /// </summary> public void RaiseSkills() { const int youAreNowAMasterOfTextID = 4020; DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; if ((now.ToClassicDaggerfallTime() - timeOfLastSkillIncreaseCheck) <= 360) { return; } timeOfLastSkillIncreaseCheck = now.ToClassicDaggerfallTime(); for (short i = 0; i < skillUses.Length; i++) { int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier((DFCareer.Skills)i); float careerAdvancementMultiplier = Career.AdvancementMultiplier; int usesNeededForAdvancement = FormulaHelper.CalculateSkillUsesForAdvancement(skills.GetPermanentSkillValue(i), skillAdvancementMultiplier, careerAdvancementMultiplier, level); if (skillUses[i] >= usesNeededForAdvancement) { skillUses[i] = 0; if (skills.GetPermanentSkillValue(i) < 100 && (skills.GetPermanentSkillValue(i) < 95 || !AlreadyMasteredASkill())) { skills.SetPermanentSkillValue(i, (short)(skills.GetPermanentSkillValue(i) + 1)); SetCurrentLevelUpSkillSum(); DaggerfallUI.Instance.PopupMessage(HardStrings.skillImprove.Replace("%s", DaggerfallUnity.Instance.TextProvider.GetSkillName((DFCareer.Skills)i))); if (skills.GetPermanentSkillValue(i) == 100) { List <DFCareer.Skills> primarySkills = GetPrimarySkills(); if (primarySkills.Contains((DFCareer.Skills)i)) { ITextProvider textProvider = DaggerfallUnity.Instance.TextProvider; TextFile.Token[] tokens; tokens = textProvider.GetRSCTokens(youAreNowAMasterOfTextID); if (tokens != null && tokens.Length > 0) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager); messageBox.SetTextTokens(tokens); messageBox.ClickAnywhereToClose = true; messageBox.ParentPanel.BackgroundColor = Color.clear; messageBox.Show(); } DaggerfallUI.Instance.PlayOneShot(SoundClips.ArenaFanfareLevelUp); } } } } } if (CheckForLevelUp()) { DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenCharacterSheetWindow); } }
private void TrainingSkill_OnItemPicked(int index, string skillName) { CloseWindow(); List <DFCareer.Skills> trainingSkills = GetTrainingSkills(); DFCareer.Skills skillToTrain = trainingSkills[index]; if (playerEntity.Skills.GetPermanentSkillValue(skillToTrain) > guild.GetTrainingMax(skillToTrain)) { // Inform player they're too skilled to train TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens, guild); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { // Train the skill DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime(); now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3); playerEntity.DeductGoldAmount(guild.GetTrainingPrice()); playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180); int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain); short tallyAmount = (short)(UnityEngine.Random.Range(10, 20 + 1) * skillAdvancementMultiplier); playerEntity.TallySkill(skillToTrain, tallyAmount); DaggerfallUI.MessageBox(TrainSkillId); } }
void TrainingService() { CloseWindow(); // Check enough time has passed since last trained DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; if ((now.ToClassicDaggerfallTime() - playerEntity.TimeOfLastSkillTraining) < 720) { TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingToSoonId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { // Offer training price DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(TrainingOfferId); messageBox.SetTextTokens(tokens, guild); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmTraining_OnButtonClick; messageBox.Show(); } }
protected override void TrainingService() { // Check enough time has passed since last trained DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; if ((now.ToClassicDaggerfallTime() - playerEntity.TimeOfLastSkillTraining) < 720) { TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingToSoonId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { // Show skill picker loaded with guild training skills DaggerfallListPickerWindow skillPicker = new DaggerfallListPickerWindow(uiManager, this); skillPicker.OnItemPicked += TrainingSkillPicker_OnItemPicked; foreach (DFCareer.Skills skill in GetTrainingSkills()) { skillPicker.ListBox.AddItem(DaggerfallUnity.Instance.TextProvider.GetSkillName(skill)); } uiManager.PushWindow(skillPicker); } }
protected void TrainSkill(DFCareer.Skills skillToTrain) { DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime(); now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3); playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180); int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain); short tallyAmount = (short)(UnityEngine.Random.Range(10, 20 + 1) * skillAdvancementMultiplier); playerEntity.TallySkill(skillToTrain, tallyAmount); DaggerfallUI.MessageBox(TrainSkillId); }
private void QuestCompleteMessage_OnClose() { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; // Train the skill, for free DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime(); now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3); playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180); int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skill); short tallyAmount = (short)(UnityEngine.Random.Range(10, 20 + 1) * skillAdvancementMultiplier); playerEntity.TallySkill(skill, tallyAmount); }
public void TrainingSkill_OnItemPicked(int index, string skillName) { CloseWindow(); List <DFCareer.Skills> trainingSkills; if (guildTrainingSkills.TryGetValue(service, out trainingSkills)) { DFCareer.Skills skillToTrain = trainingSkills[index]; int maxTraining = 50; if (DaggerfallSkills.IsLanguageSkill(skillToTrain)) // BCHG: Language skill training is capped by char intelligence instead of 50% { maxTraining = playerEntity.Stats.PermanentIntelligence; } if (playerEntity.Skills.GetPermanentSkillValue(skillToTrain) > maxTraining) { // Inform player they're too skilled to train TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens, this); messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); } else { // Train the skill DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime(); now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3); playerEntity.DeductGoldAmount(GetServicePrice()); playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180); int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain); short tallyAmount = (short)(UnityEngine.Random.Range(10, 21) * skillAdvancementMultiplier); playerEntity.TallySkill(skillToTrain, tallyAmount); DaggerfallUI.MessageBox(TrainSkillId); } } else { Debug.LogError("Invalid skill selected for training."); } }