private void PlayerEntity_OnExhausted(DaggerfallEntity entity) { const int youDropToTheGround1 = 1071; const int youDropToTheGround2 = 1072; bool enemiesNearby = GameManager.Instance.AreEnemiesNearby(); ITextProvider textProvider = DaggerfallUnity.Instance.TextProvider; TextFile.Token[] tokens; GameManager.Instance.PlayerMotor.CancelMovement = true; DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager); if (GameManager.Instance.PlayerEnterExit.IsPlayerSwimming) { messageBox.SetText(HardStrings.exhaustedInWater); } else { if (!enemiesNearby) { tokens = textProvider.GetRSCTokens(youDropToTheGround1); } else { tokens = textProvider.GetRSCTokens(youDropToTheGround2); } if (tokens != null && tokens.Length > 0) { messageBox.SetTextTokens(tokens); } } messageBox.ClickAnywhereToClose = true; messageBox.ParentPanel.BackgroundColor = Color.clear; messageBox.Show(); if (!enemiesNearby && !GameManager.Instance.PlayerEnterExit.IsPlayerSwimming) { // TODO: Duplicates rest code in rest window. Should be unified. DaggerfallUnity.Instance.WorldTime.Now.RaiseTime(1 * DaggerfallDateTime.SecondsPerHour); int healthRecoveryRate = FormulaHelper.CalculateHealthRecoveryRate(this); int fatigueRecoveryRate = FormulaHelper.CalculateFatigueRecoveryRate(MaxFatigue); int spellPointRecoveryRate = FormulaHelper.CalculateSpellPointRecoveryRate(MaxMagicka); CurrentHealth += healthRecoveryRate; CurrentFatigue += fatigueRecoveryRate; CurrentMagicka += spellPointRecoveryRate; TallySkill(DFCareer.Skills.Medical, 1); } else { SetHealth(0); } }
/// <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); } }
public static TextFile.Token[] GetItemInfo(DaggerfallUnityItem item, ITextProvider textProvider) { const int paintingTextId = 250; const int armorTextId = 1000; const int weaponTextId = 1001; const int miscTextId = 1003; const int soulTrapTextId = 1004; const int letterOfCreditTextId = 1007; const int potionTextId = 1008; const int bookTextId = 1009; const int arrowTextId = 1011; const int weaponNoMaterialTextId = 1012; const int armorNoMaterialTextId = 1014; const int oghmaInfiniumTextId = 1015; const int houseDeedTextId = 1073; // Handle by item group switch (item.ItemGroup) { case ItemGroups.Armor: if (ArmorShouldShowMaterial(item)) { return(textProvider.GetRSCTokens(armorTextId)); // Handle armor showing material } else { return(textProvider.GetRSCTokens(armorNoMaterialTextId)); // Handle armor not showing material } case ItemGroups.Weapons: if (item.TemplateIndex == (int)Weapons.Arrow) { return(textProvider.GetRSCTokens(arrowTextId)); // Handle arrows } else if (item.IsArtifact) { return(textProvider.GetRSCTokens(weaponNoMaterialTextId)); // Handle artifacts } else { return(textProvider.GetRSCTokens(weaponTextId)); // Handle weapons } case ItemGroups.Books: if (item.legacyMagic != null && item.legacyMagic[0].type == EnchantmentTypes.SpecialArtifactEffect) { return(textProvider.GetRSCTokens(oghmaInfiniumTextId)); // Handle Oghma Infinium } else { return(textProvider.GetRSCTokens(bookTextId)); // Handle other books } case ItemGroups.Paintings: // TODO: Show painting. Uses file paint.dat. return(textProvider.GetRSCTokens(paintingTextId)); case ItemGroups.MiscItems: // A few items in the MiscItems group have their own text display if (item.TemplateIndex == (int)MiscItems.Potion_recipe) { return(GetPotionRecipeTokens()); // Handle potion recipes } else if (item.TemplateIndex == (int)MiscItems.House_Deed) { return(textProvider.GetRSCTokens(houseDeedTextId)); // Handle house deeds } else if (item.TemplateIndex == (int)MiscItems.Soul_trap) { return(textProvider.GetRSCTokens(soulTrapTextId)); // Handle soul traps } else if (item.TemplateIndex == (int)MiscItems.Letter_of_credit) { return(textProvider.GetRSCTokens(letterOfCreditTextId)); // Handle letters of credit } else { return(textProvider.GetRSCTokens(miscTextId)); // Default misc items } default: // Handle potions in glass bottles // In classic, the check is whether RecordRoot.SublistHead is non-null and of PotionMix type. // TODO: Do we need it or will glass bottles with typedependentdata cover it? if (item.ItemGroup == ItemGroups.UselessItems1 && item.TemplateIndex == (int)UselessItems1.Glass_Bottle) { return(textProvider.GetRSCTokens(potionTextId)); } // Handle Azura's Star if (item.legacyMagic != null && item.legacyMagic[0].type == EnchantmentTypes.SpecialArtifactEffect && item.legacyMagic[0].param == 9) { return(textProvider.GetRSCTokens(soulTrapTextId)); } // Default fallback if none of the above applied return(textProvider.GetRSCTokens(miscTextId)); } }
/// <summary> /// Gets tokens from a TEXT.RSC record. /// </summary> /// <param name="id">Text resource ID.</param> /// <returns>Text resource tokens.</returns> public virtual TextFile.Token[] GetRSCTokens(int id) { return(fallback.GetRSCTokens(id)); }