// TODO: Migrate this into seperate class accessible to climbingMotor and HangingMotor /// <summary> /// See if the player can pass a climbing skill check /// </summary> /// <returns>true if player passed climbing skill check</returns> public bool ClimbingSkillCheck(int basePercentSuccess) { player.TallySkill(DFCareer.Skills.Climbing, 1); if (overrideSkillCheck) { return(true); } int percentSuccess = FormulaHelper.CalculateClimbingChance(player, basePercentSuccess); if (Dice100.FailedRoll(percentSuccess)) { // Don't allow skill check to break climbing while swimming // Water makes it easier to climb var playerPos = controller.transform.position.y + (76 * MeshReader.GlobalScale) - 0.95f; var playerFootPos = playerPos - (controller.height / 2) - 1.20f; // to prevent player from failing to climb out of water var waterPos = playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale; if (playerFootPos >= waterPos) // prevent fail underwater { return(false); } } return(true); }
private void AttemptAvoid() { int playerSkillRunning = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Running); int playerSkillStealth = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Stealth); int successChance = Mathf.Max(playerSkillRunning, playerSkillStealth); successChance = successChance * maxSuccessChance / 100; DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager); mb.SetText("You approach a hostile encounter. Attempt to avoid it?"); mb.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes, true); mb.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); mb.ParentPanel.BackgroundColor = Color.clear; mb.OnButtonClick += (_sender, button) => { _sender.CloseWindow(); if (button == DaggerfallMessageBox.MessageBoxButtons.Yes) { if (Dice100.SuccessRoll(successChance)) { delayCombat = true; delayCombatTime = DaggerfallUnity.Instance.WorldTime.Now.ToClassicDaggerfallTime() + 10; StartFastTravel(destinationSummary); } else { DaggerfallUI.MessageBox("You failed to avoid the encounter!"); } } }; mb.Show(); }
private static void KillAll(bool all = true) { DaggerfallEntityBehaviour[] entityBehaviours = FindObjectsOfType <DaggerfallEntityBehaviour>(); int length = entityBehaviours.Length; int killed = 0; int mobs = 0; int luck = playerEntity.Stats.LiveLuck / 4; for (int i = 0; i < length; i++) { DaggerfallEntityBehaviour entityBehaviour = entityBehaviours[i]; if (entityBehaviour.EntityType == EntityTypes.EnemyMonster || entityBehaviour.EntityType == EntityTypes.EnemyClass) { mobs++; if (all) { killed++; entityBehaviour.Entity.SetHealth(0); } else if (Dice100.SuccessRoll(luck)) { killed++; entityBehaviour.Entity.SetHealth(0); } } } horrorWakeup = true; playerEntity.CurrentHealth = playerEntity.MaxHealth; playerEntity.CurrentFatigue = playerEntity.MaxFatigue; playerEntity.CurrentMagicka = playerEntity.MaxMagicka; DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack(); }
private static void PercentManaRegenRealtime() { if (FixedUpdateCounter >= 80) // 50 FixedUpdates is approximately equal to 1 second since each FixedUpdate happens every 0.02 seconds, that's what Unity docs say at least. { FixedUpdateCounter = 0; float playerWillMod = (Mathf.Pow(1.019f, player.Stats.LiveWillpower) - 1) * RegenAmountModifier; //float playerWillMod = player.Stats.LiveWillpower * 0.05f * RegenAmountModifier; if (GameManager.Instance.PlayerEffectManager.HasVampirism() && !(GameManager.Instance.PlayerEffectManager.GetRacialOverrideEffect() as VampirismEffect).IsSatiated()) // If player is a vampire and currently does NOT have their thirst sated, they will regen magic much slower. { playerWillMod *= 0.2f; // Vampires with unsated thirst will only regen mana at 20% of their normal amount. } if (GameManager.Instance.PlayerEffectManager.HasReadySpell || player.CurrentMagicka >= player.MaxMagicka) // Don't allow regen "tick" to occur while player has spell ready to fire, nor if they currently have full mana. { return; } ManaCounter += playerWillMod; if (Dice100.SuccessRoll((int)Mathf.Floor(player.Stats.LiveLuck / 2))) { ManaCounter *= 1.3f; } if (ManaCounter >= 1) { int quotient = (int)Math.Truncate(ManaCounter); player.IncreaseMagicka(Mathf.Max((int)Mathf.Round(player.MaxMagicka * (quotient / 100f)), 1)); //Debug.LogFormat("Basic Magic Regen, Just Increased Your Mana By {0} Points. Remainder Is {1}", Mathf.Max((int)Mathf.Round(player.MaxMagicka * (quotient / 100f)), 1), ManaCounter - quotient); ManaCounter -= quotient; } } }
/// <summary> /// Randomly add a potion /// </summary> public static void RandomlyAddPotion(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { collection.AddItem(ItemBuilder.CreateRandomPotion()); } }
public void AttemptBash(bool byPlayer) { if (!IsOpen) { // Play bash sound if flagged and ready if (PlaySounds && BashSound > 0 && audioSource) { DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>(); if (dfAudioSource != null) { dfAudioSource.PlayOneShot(BashSound); } } // Cannot bash magically held doors if (!IsMagicallyHeld) { // Roll for chance to open int chance = 20 - CurrentLockValue; if (Dice100.SuccessRoll(chance)) { CurrentLockValue = 0; ToggleDoor(true); } } if (byPlayer && Game.GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle) { Game.GameManager.Instance.MakeEnemiesHostile(); } } }
private void StealButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (windowMode == WindowModes.Buy && cost > 0) { // Calculate the weight of all items picked from shelves, then get chance of shoplifting success. int weightAndNumItems = (int)basketItems.GetWeight() + basketItems.Count; int chanceBeingDetected = FormulaHelper.CalculateShopliftingChance(PlayerEntity, null, buildingDiscoveryData.quality, weightAndNumItems); PlayerEntity.TallySkill(DFCareer.Skills.Pickpocket, 1); if (Dice100.FailedRoll(chanceBeingDetected)) { DaggerfallUI.AddHUDText(TextManager.Instance.GetText(textDatabase, "stealSuccess"), 2); RaiseOnTradeHandler(basketItems.GetNumItems(), 0); PlayerEntity.Items.TransferAll(basketItems); PlayerEntity.TallyCrimeGuildRequirements(true, 1); } else { // Register crime and start spawning guards. DaggerfallUI.AddHUDText(TextManager.Instance.GetText(textDatabase, "stealFailure"), 2); RaiseOnTradeHandler(0, 0); PlayerEntity.CrimeCommitted = PlayerEntity.Crimes.Theft; PlayerEntity.SpawnCityGuards(true); } CloseWindow(); } }
private void DonationMsgBox_OnGotUserInput(DaggerfallInputMessageBox sender, string input) { int amount = 0; if (int.TryParse(input, out amount)) { if (playerEntity.GetGoldAmount() > amount) { // Deduct gold, and apply blessing playerEntity.DeductGoldAmount(amount); int factionId = (int)Temple.GetDivine(buildingFactionId); // Change reputation int rep = Math.Abs(playerEntity.FactionData.GetReputation(factionId)); if (Dice100.SuccessRoll(2 * amount / rep + 1)) { playerEntity.FactionData.ChangeReputation(factionId, 1); // Does not propagate in classic } // Show thanks message DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(DonationThanksId), this); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TooGenerousId), this); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } } }
void AttemptAvoidEncounter() { int successChance = Mathf.Min(GameManager.Instance.PlayerEntity.Stats.LiveLuck + GameManager.Instance.PlayerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Stealth) - 50, maxAvoidChance); if (Dice100.SuccessRoll(successChance)) { Debug.LogWarning("Avoided enemies enountered during travel, chance: " + successChance); ignoreEncounters = true; ignoreEncountersTime = (uint)Time.unscaledTime + 15; if (DestinationName != null) { BeginTravel(); } else { FollowPath(); } travelControlUI.ShowMessage(MsgAvoidSuccess); } else { Debug.Log("Failed to avoid enemies enountered during travel, chance: " + successChance); DaggerfallUI.MessageBox(MsgAvoidFail); } }
static void RandomIngredient(float chance, ItemGroups ingredientGroup, List <DaggerfallUnityItem> targetItems) { while (Dice100.SuccessRoll((int)chance)) { targetItems.Add(ItemBuilder.CreateRandomIngredient(ingredientGroup)); chance *= 0.5f; } }
/// <summary> /// Randomly add a map /// </summary> public static void RandomlyAddMap(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { DaggerfallUnityItem map = new DaggerfallUnityItem(ItemGroups.MiscItems, 8); collection.AddItem(map); } }
static Weapons RandomBigWeapon() { Weapons weapon = (Weapons)UnityEngine.Random.Range((int)Weapons.Claymore, (int)Weapons.War_Axe + 1); if (weapon == Weapons.Dai_Katana && Dice100.SuccessRoll(95)) { weapon = Weapons.Claymore; // Dai-katana's are really rare. } return(weapon); }
/// <summary> /// Randomly add a potion recipe /// </summary> public static void RandomlyAddPotionRecipe(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { DaggerfallUnityItem potionRecipe = new DaggerfallUnityItem(ItemGroups.MiscItems, 4); byte recipe = (byte)Random.Range(0, 20); potionRecipe.typeDependentData = recipe; collection.AddItem(potionRecipe); } }
static Weapons RandomShortblade() { if (Dice100.SuccessRoll(95)) { return(CoinFlip() ? Weapons.Dagger : Weapons.Shortsword); } else { return((Weapons)UnityEngine.Random.Range((int)Weapons.Dagger, (int)Weapons.Wakazashi + 1)); } }
public bool StealthCheck() { if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle && !motor.IsHostile) { return(false); } if (!wouldBeSpawnedInClassic) { return(false); } if (distanceToTarget > 1024 * MeshReader.GlobalScale) { return(false); } uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); if (gameMinutes == timeOfLastStealthCheck) { return(detectedTarget); } if (target == Player) { PlayerMotor playerMotor = GameManager.Instance.PlayerMotor; if (playerMotor.IsMovingLessThanHalfSpeed) { if ((gameMinutes & 1) == 1) { return(detectedTarget); } } else if (hasEncounteredPlayer) { return(true); } PlayerEntity player = GameManager.Instance.PlayerEntity; if (player.TimeOfLastStealthCheck != gameMinutes) { player.TallySkill(DFCareer.Skills.Stealth, 1); player.TimeOfLastStealthCheck = gameMinutes; } } timeOfLastStealthCheck = gameMinutes; int stealthChance = 2 * ((int)(distanceToTarget / MeshReader.GlobalScale) * target.Entity.Skills.GetLiveSkillValue(DFCareer.Skills.Stealth) >> 10); return(Dice100.FailedRoll(stealthChance)); }
public void AttemptLockpicking() { if (IsMoving) { return; } PlayerEntity player = Game.GameManager.Instance.PlayerEntity; // If player fails at their current lockpicking skill level, they can't try again if (FailedSkillLevel == player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking)) { return; } if (!IsMagicallyHeld) { int chance = 0; int lockpickSuccessCheck = 0; chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking)); if (Dice100.FailedRoll(chance)) { player.TallySkill(DFCareer.Skills.Lockpicking, 1, lockpickSuccessCheck); Game.DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetLocalizedText("lockpickingFailure")); FailedSkillLevel = player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking); } else { lockpickSuccessCheck = 1; player.TallySkill(DFCareer.Skills.Lockpicking, 1, lockpickSuccessCheck, CurrentLockValue); Game.DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetLocalizedText("lockpickingSuccess")); CurrentLockValue = 0; if (PlaySounds && PickedLockSound > 0 && audioSource) { DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>(); if (dfAudioSource != null) { dfAudioSource.PlayOneShot(PickedLockSound); } } ToggleDoor(true); } } else { Game.DaggerfallUI.Instance.PopupMessage(TextManager.Instance.GetLocalizedText("lockpickingFailure")); } }
/// <summary> /// Randomly add a potion /// </summary> public static void RandomlyAddPotionRecipe(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { List <int> recipeKeys = GameManager.Instance.EntityEffectBroker.GetPotionRecipeKeys(); int recipeIdx = UnityEngine.Random.Range(0, recipeKeys.Count); DaggerfallUnityItem potionRecipe = new DaggerfallUnityItem(ItemGroups.MiscItems, 4) { PotionRecipeKey = recipeKeys[recipeIdx] }; collection.AddItem(potionRecipe); } }
/// <summary> /// Randomly add a potion recipe /// </summary> public static void RandomlyAddPotionRecipe(int chance, ItemCollection collection) { if (Dice100.SuccessRoll(chance)) { int recipeIdx = Random.Range(0, PotionRecipe.classicRecipeKeys.Length); int recipeKey = PotionRecipe.classicRecipeKeys[recipeIdx]; DaggerfallUnityItem potionRecipe = new DaggerfallUnityItem(ItemGroups.MiscItems, 4) { PotionRecipeKey = recipeKey }; collection.AddItem(potionRecipe); } }
// Capture this message so we can play pain voice public void RemoveHealth(int amount) { if (dfAudioSource && DaggerfallUnity.Settings.CombatVoices && Dice100.SuccessRoll(40)) { Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; bool heavyDamage = amount >= playerEntity.MaxHealth / 4; SoundClips sound = Entity.DaggerfallEntity.GetRaceGenderPainSound(playerEntity.Race, playerEntity.Gender, heavyDamage); float pitch = dfAudioSource.AudioSource.pitch; dfAudioSource.AudioSource.pitch = pitch + Random.Range(0, 0.3f); dfAudioSource.PlayOneShot((int)sound, 0, 1f); dfAudioSource.AudioSource.pitch = pitch; } }
/// <summary> /// Performs a chance roll for this effect based on chance settings. /// </summary> /// <returns>True if chance roll succeeded.</returns> public virtual bool RollChance() { if (!Properties.SupportChance) { return(false); } bool outcome = Dice100.SuccessRoll(ChanceValue()); //Debug.LogFormat("Effect '{0}' has a {1}% chance of succeeding and rolled {2} for a {3}", Key, ChanceValue(), roll, (outcome) ? "success" : "fail"); return(outcome); }
public override void OnWeaponHitEntity(PlayerEntity playerEntity, DaggerfallEntity targetEntity = null) { const int chanceOfAttackSound = 10; const int chanceOfBarkSound = 20; // Check if we killed an innocent and update satiation - do not need to be transformed if (KilledInnocent(targetEntity)) { UpdateSatiation(); } // Do nothing further if not transformed if (!isTransformed) { return; } // Lycanthrope characters emit both attack and bark sounds while attacking SoundClips customSound = SoundClips.None; if (infectionType == LycanthropyTypes.Werewolf) { if (Dice100.SuccessRoll(chanceOfAttackSound)) { customSound = SoundClips.EnemyWerewolfAttack; } else if (Dice100.SuccessRoll(chanceOfBarkSound)) { customSound = SoundClips.EnemyWerewolfBark; } } else if (infectionType == LycanthropyTypes.Wereboar) { if (Dice100.SuccessRoll(chanceOfAttackSound)) { customSound = SoundClips.EnemyWereboarAttack; } else if (Dice100.SuccessRoll(chanceOfBarkSound)) { customSound = SoundClips.EnemyWereboarBark; } } // Play sound through weapon FPSWeapon screenWeapon = GameManager.Instance.WeaponManager.ScreenWeapon; if (screenWeapon && customSound != SoundClips.None) { screenWeapon.PlayAttackVoice(customSound); } }
private static void ShopShelfBurglar(RaycastHit hit) { PlayerGPS.DiscoveredBuilding buildingData = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData; if (RMBLayout.IsShop(buildingData.buildingType) && !PlayerActivate.IsBuildingOpen(buildingData.buildingType)) { int stealthValue = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Stealth); stealthValue -= buildingData.quality * 2; if (Dice100.FailedRoll(StealthCalc(stealthValue, false))) { burglaryCounter += Mathf.Clamp(UnityEngine.Random.Range(100, 200) - playerEntity.Stats.LiveLuck, 10, 100); } } }
private static WeaponMaterialTypes randomMat() { WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Iron; if (GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeon) { matRoll = (matRoll - 15) + dungeonQuality(); } else { matRoll -= UnityEngine.Random.Range(10, 20); } //increased chance of orcish when in orsinium or an orc stronghold if (Dice100.SuccessRoll(luckMod * 2)) { if ((region == (int)DaggerfallRegions.OrsiniumArea || dungeon == (int)DFRegion.DungeonTypes.OrcStronghold) && Dice100.SuccessRoll(luckMod)) { return(WeaponMaterialTypes.Orcish); } else { matRoll += luckMod * 4; } } if (matRoll > 90) { if (Dice100.SuccessRoll(luckMod * 3)) { weaponMaterial = RandomHighTier(); } else { weaponMaterial = WeaponMaterialTypes.Dwarven; } } else if (matRoll > 83) { weaponMaterial = WeaponMaterialTypes.Elven; } else if (matRoll > 75) { weaponMaterial = WeaponMaterialTypes.Silver; } else if (matRoll > 35) { weaponMaterial = WeaponMaterialTypes.Steel; } return(weaponMaterial); }
public void AttemptBash(bool byPlayer, PlayerEntity player = null, EnemyEntity enemy = null) { // Play bash sound if flagged and ready if (PlaySounds && BashSound > 0 && audioSource) { DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>(); if (dfAudioSource != null) { dfAudioSource.PlayOneShot(BashSound); } } if (IsOpen) { // Bash-close the door ToggleDoor(true); } // Cannot bash magically held doors else if (!IsMagicallyHeld) { int chance = 0; if (player != null) { chance = Mathf.Clamp(15 + (int)Mathf.Ceil((player.Stats.LiveStrength - 50) / 2.5f) - CurrentLockValue, 1, 100); } else if (enemy != null) { chance = Mathf.Clamp(15 + (int)Mathf.Ceil((enemy.Stats.LiveStrength - 50) / 2.5f) - CurrentLockValue, 1, 100); } else { chance = 20 - CurrentLockValue; } // Roll for chance to open if (Dice100.SuccessRoll(chance)) { CurrentLockValue = 0; ToggleDoor(true); } } if (byPlayer && Game.GameManager.Instance.PlayerEnterExit.IsPlayerInsideDungeonCastle) { Game.GameManager.Instance.MakeEnemiesHostile(); } }
ItemCollection GetMerchantMagicItems(bool onlySoulGems = false) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; ItemCollection items = new ItemCollection(); int numOfItems = (buildingDiscoveryData.quality / 2) + 1; // Seed random from game time to rotate magic stock every 24 game hours // This more or less resolves issue of magic item stock not being deterministic every time player opens window // Doesn't match classic exactly as classic stocking method unknown, but should be "good enough" for now int seed = (int)(DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime() / DaggerfallDateTime.MinutesPerDay); UnityEngine.Random.InitState(seed); if (!onlySoulGems) { for (int i = 0; i <= numOfItems; i++) { // Create magic item which is already identified DaggerfallUnityItem magicItem = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race); magicItem.IdentifyItem(); items.AddItem(magicItem); } items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Spellbook)); } if (guild.CanAccessService(GuildServices.BuySoulgems)) { for (int i = 0; i <= numOfItems; i++) { DaggerfallUnityItem magicItem; if (Dice100.FailedRoll(25)) { // Empty soul trap magicItem = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Soul_trap); magicItem.value = 5000; magicItem.TrappedSoulType = MobileTypes.None; } else { // Filled soul trap magicItem = ItemBuilder.CreateRandomlyFilledSoulTrap(); } items.AddItem(magicItem); } } return(items); }
public void StockMerchantMagicItems(PlayerGPS.DiscoveredBuilding buildingData, bool onlySoulGems = false) { stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now); items.Clear(); int buildingQuality = buildingData.quality; Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; int playerLuck = playerEntity.Stats.LiveLuck; int numOfItems = (buildingData.quality / 2) + 1; if (!onlySoulGems) { for (int i = 0; i <= numOfItems; i++) { // Create magic item which is already identified DaggerfallUnityItem magicItem = ItemBuilder.CreateRandomMagicItem(playerEntity.Gender, playerEntity.Race, -1, buildingQuality, playerLuck); magicItem.IdentifyItem(); items.AddItem(magicItem); } items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Spellbook)); } if (onlySoulGems) { numOfItems *= 2; } for (int i = 0; i <= numOfItems; i++) { DaggerfallUnityItem magicItem; if (Dice100.FailedRoll(25)) { // Empty soul trap magicItem = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Soul_trap); magicItem.value = 5000; magicItem.TrappedSoulType = MobileTypes.None; } else { // Filled soul trap magicItem = ItemBuilder.CreateRandomlyFilledSoulTrap(); } items.AddItem(magicItem); } }
public override void OnWeaponHitEnemy(PlayerEntity playerEntity, EnemyEntity enemyEntity) { const int chanceOfAttackSound = 10; const int chanceOfBarkSound = 20; // Do nothing if not transformed if (!isTransformed) { return; } // Lycanthrope characters emit both attack and bark sounds while attacking SoundClips customSound = SoundClips.None; if (infectionType == LycanthropyTypes.Werewolf) { if (Dice100.SuccessRoll(chanceOfAttackSound)) { customSound = SoundClips.EnemyWerewolfAttack; } else if (Dice100.SuccessRoll(chanceOfBarkSound)) { customSound = SoundClips.EnemyWerewolfBark; } } else if (infectionType == LycanthropyTypes.Wereboar) { if (Dice100.SuccessRoll(chanceOfAttackSound)) { customSound = SoundClips.EnemyWereboarAttack; } else if (Dice100.SuccessRoll(chanceOfBarkSound)) { customSound = SoundClips.EnemyWereboarBark; } } // Play sound through weapon FPSWeapon screenWeapon = GameManager.Instance.WeaponManager.ScreenWeapon; if (screenWeapon && customSound != SoundClips.None) { screenWeapon.PlayAttackVoice(customSound); } }
public static void TheftItems_OnLootSpawned(object sender, ContainerLootSpawnedEventArgs e) { if (e.ContainerType == LootContainerTypes.HouseContainers) { int liveLuck = playerEntity.Stats.LiveLuck; int itemNumber = (liveLuck / 10) - UnityEngine.Random.Range(1, 40); while (itemNumber > 0) { DaggerfallUnityItem item = BurglaryLoot(); e.Loot.AddItem(item); itemNumber--; itemNumber--; } if (Dice100.SuccessRoll(liveLuck / 10)) { DaggerfallUnityItem item = ItemBuilder.CreateItem(ItemGroups.Currency, (int)Currency.Gold_pieces); item.stackCount = UnityEngine.Random.Range(Mathf.Max(1, liveLuck / 10), liveLuck * 10); e.Loot.AddItem(item); } if (Dice100.SuccessRoll(liveLuck / 10)) { DaggerfallUnityItem map = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Map); } if (Dice100.SuccessRoll(liveLuck / 10)) { int typeRoll = UnityEngine.Random.Range(0, 100); DaggerfallUnityItem itemWpnArm; int level = UnityEngine.Random.Range(1, playerEnterExit.Interior.BuildingData.Quality); if (typeRoll > 50) { itemWpnArm = ItemBuilder.CreateRandomWeapon(level); } else { itemWpnArm = ItemBuilder.CreateRandomArmor(level, playerEntity.Gender, playerEntity.Race); } itemWpnArm.currentCondition = (int)(UnityEngine.Random.Range(0.3f, 0.75f) * itemWpnArm.maxCondition); e.Loot.AddItem(itemWpnArm); } } }
// TODO: Migrate this into seperate class accessible to climbingMotor and HangingMotor /// <summary> /// See if the player can pass a climbing skill check /// </summary> /// <returns>true if player passed climbing skill check</returns> public bool ClimbingSkillCheck(int basePercentSuccess) { player.TallySkill(DFCareer.Skills.Climbing, 1); if (overrideSkillCheck) { return(true); } int skill = player.Skills.GetLiveSkillValue(DFCareer.Skills.Climbing); int luck = player.Stats.GetLiveStatValue(DFCareer.Stats.Luck); if (player.Race == Entity.Races.Khajiit) { skill += 30; } // Climbing effect states "target can climb twice as well" - doubling effective skill after racial applied if (player.IsEnhancedClimbing) { skill *= 2; } // Clamp skill range skill = Mathf.Clamp(skill, 5, 95); float luckFactor = Mathf.Lerp(0, 10, luck * 0.01f); // Skill Check float percentSuccess = Mathf.Lerp(basePercentSuccess, 100, skill * .01f) + luckFactor; if (Dice100.FailedRoll((int)percentSuccess)) { // Don't allow skill check to break climbing while swimming // Water makes it easier to climb var playerPos = controller.transform.position.y + (76 * MeshReader.GlobalScale) - 0.95f; var playerFootPos = playerPos - (controller.height / 2) - 1.20f; // to prevent player from failing to climb out of water var waterPos = playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale; if (playerFootPos >= waterPos) // prevent fail underwater { return(false); } } return(true); }
/// <summary> /// Our work is done here. /// </summary> private void Juggle() { // Juggle current things DaggerfallUI.AddHUDText(string.Format("Juggling {0} {1}...", thingsRemaining, thingName)); // We might drop something! if (Dice100.SuccessRoll(dropPercent)) { thingsRemaining--; DaggerfallUI.AddHUDText("Oops, I dropped one!"); } // Give up if we've dropped everything if (thingsRemaining == 0) { DaggerfallUI.AddHUDText(string.Format("Dropped all the {0}. I give up!", thingName)); return; } }