Example #1
0
        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"));
            }
        }
Example #2
0
        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.Lockpicking)
            {
                return;
            }

            if (!IsMagicallyHeld)
            {
                int chance = 0;
                player.TallySkill(DFCareer.Skills.Lockpicking, 1);
                chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.Lockpicking);

                if (Random.Range(0, 101) > chance)
                {
                    Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
                    FailedSkillLevel = player.Skills.Lockpicking;
                }
                else
                {
                    Game.DaggerfallUI.Instance.PopupMessage(HardStrings.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(HardStrings.lockpickingFailure);
            }
        }
        public void AttemptLockpicking()
        {
            int chance = 0;

            if (IsMoving)
            {
                return;
            }

            if (!IsOpen && IsLocked)
            {
                if (!IsMagicallyHeld)
                {
                    PlayerEntity player = Game.GameManager.Instance.PlayerEntity;
                    player.TallySkill((short)Skills.Lockpicking, 1);
                    chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.Lockpicking);

                    if (Random.Range(0, 101) > chance)
                    {
                        Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
                    }
                    else
                    {
                        Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingSuccess);
                        CurrentLockValue = 0;

                        if (PlaySounds && PickedLockSound > 0 && audioSource)
                        {
                            DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                            if (dfAudioSource != null)
                            {
                                dfAudioSource.PlayOneShot(PickedLockSound);
                            }
                        }

                        ToggleDoor();
                    }
                    LockPickingAttempted = true;
                }
                else
                {
                    Game.DaggerfallUI.Instance.PopupMessage(HardStrings.lockpickingFailure);
                }
            }
        }
        public void LookAtLock()
        {
            if (CurrentLockValue < 20)
            {
                PlayerEntity player = Game.GameManager.Instance.PlayerEntity;
                // There seems to be an oversight in classic. It uses two separate lockpicking functions (seems to be one for animated doors in interiors and one for exterior doors)
                // but the difficulty text is always based on the exterior function.
                // DF Unity doesn't have exterior locked doors yet, so the below uses the interior function.
                int chance = FormulaHelper.CalculateInteriorLockpickingChance(player.Level, CurrentLockValue, player.Skills.GetLiveSkillValue(DFCareer.Skills.Lockpicking));

                if (chance >= 30)
                {
                    if (chance >= 35)
                    {
                        if (chance >= 95)
                        {
                            Game.DaggerfallUI.SetMidScreenText(HardStrings.lockpickChance[9]);
                        }
                        else if (chance >= 45)
                        {
                            Game.DaggerfallUI.SetMidScreenText(HardStrings.lockpickChance[(chance - 45) / 5]);
                        }
                        else
                        {
                            Game.DaggerfallUI.SetMidScreenText(HardStrings.lockpickChance3);
                        }
                    }
                    else
                    {
                        Game.DaggerfallUI.SetMidScreenText(HardStrings.lockpickChance2);
                    }
                }
                else
                {
                    Game.DaggerfallUI.SetMidScreenText(HardStrings.lockpickChance1);
                }
            }
            else
            {
                Game.DaggerfallUI.SetMidScreenText(HardStrings.magicLock);
            }
        }