// 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);
        }
Example #2
0
        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();
            }
        }
Example #3
0
        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));
        }
Example #4
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 #5
0
        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);
                }
            }
        }
        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);
        }
Example #7
0
        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);
            }
        }
        // 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);
        }
        // TODO: Classic seems deterministic so when re-visiting each mages guildhall, player sees same stuff.
        // Does it change with level? Is it always generated but uses a consistent seed? How should DFU do this?
        ItemCollection GetMerchantMagicItems()
        {
            PlayerEntity   playerEntity = GameManager.Instance.PlayerEntity;
            ItemCollection items        = new ItemCollection();
            int            numOfItems   = (buildingDiscoveryData.quality / 2) + 1;

            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 = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Soul_trap);
                    magicItem.value = 5000;

                    if (Dice100.FailedRoll(25))
                    {
                        magicItem.TrappedSoulType = MobileTypes.None;
                    }
                    else
                    {
                        int id = UnityEngine.Random.Range(0, 43);
                        magicItem.TrappedSoulType = (MobileTypes)id;
                        MobileEnemy mobileEnemy = GameObjectHelper.EnemyDict[id];
                        magicItem.value += mobileEnemy.SoulPts;
                    }
                    items.AddItem(magicItem);
                }
            }
            return(items);
        }
Example #10
0
        public bool BlockedByIllusionEffect()
        {
            // In classic if the target is another AI character true is always returned.

            // Some enemy types can see through these effects.
            if (mobile.Summary.Enemy.SeesThroughInvisibility)
            {
                return(false);
            }

            // If not one of the above enemy types, and target has invisibility,
            // detection is always blocked.
            if (target.Entity.IsInvisible)
            {
                return(true);
            }

            // If target doesn't have any illusion effect, detection is not blocked.
            if (!target.Entity.IsBlending && !target.Entity.IsAShade)
            {
                return(false);
            }

            // Target has either chameleon or shade. Try to see through it.
            int chance;

            if (target.Entity.IsBlending)
            {
                chance = 8;
            }
            else // is a shade
            {
                chance = 4;
            }

            return(Dice100.FailedRoll(chance));
        }
Example #11
0
        private void DebateLie_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            sender.CloseWindow();
            int playerSkill = 0;

            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Debate)
            {
                playerSkill = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Etiquette);
                playerEntity.TallySkill(DFCareer.Skills.Etiquette, 1);
            }
            else
            {
                playerSkill = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Streetwise);
                playerEntity.TallySkill(DFCareer.Skills.Streetwise, 1);
            }

            int chanceToGoFree = playerEntity.RegionData[regionIndex].LegalRep +
                                 (playerSkill + playerEntity.Stats.GetLiveStatValue(DFCareer.Stats.Personality)) / 2;

            if (chanceToGoFree > 95)
            {
                chanceToGoFree = 95;
            }
            else if (chanceToGoFree < 5)
            {
                chanceToGoFree = 5;
            }

            if (Dice100.FailedRoll(chanceToGoFree))
            {
                // Banishment
                if (punishmentType == 0)
                {
                    state = 4;
                }
                // Execution
                else if (punishmentType == 1)
                {
                    state = 5;
                }
                // Prison/Fine
                else
                {
                    int roll = playerEntity.RegionData[regionIndex].LegalRep + Dice100.Roll();
                    if (roll < 25)
                    {
                        fine *= 2;
                    }
                    else if (roll > 75)
                    {
                        fine >>= 1;
                    }

                    state = 2;
                }
            }
            else
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149);
                messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFreeToGo));
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                messageBox.ClickAnywhereToClose          = true;
                messageBox.AllowCancel = false;
                uiManager.PushWindow(messageBox);

                // Oversight in classic: Does not refill vital signs when releasing in this case, so player is left with 1 health.
                // Also does not repair reputation.
                playerEntity.FillVitalSigns();
                playerEntity.RaiseReputationForDoingSentence();
                state = 6;
            }
            Update();
        }
Example #12
0
        public override void Update()
        {
            base.Update();

            // Close immediately if no crime assigned to player
            if (playerEntity.CrimeCommitted == Entity.PlayerEntity.Crimes.None)
            {
                CloseWindow();
                return;
            }

            if (state == 0) // Starting
            {
                regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex;

                int crimeType = (int)playerEntity.CrimeCommitted - 1;
                int legalRep  = playerEntity.RegionData[regionIndex].LegalRep;

                // Get whether punishment is normal (fine/prison) or a severe punishment (banishment/execution)
                int threshold1 = 0;
                int threshold2 = 0;

                if (legalRep < 0)
                {
                    threshold1 = -legalRep;
                    if (threshold1 > 75)
                    {
                        threshold1 = 75;
                    }
                    threshold2 = -legalRep / 2;
                    if (threshold2 > 75)
                    {
                        threshold2 = 75;
                    }
                }
                if (Dice100.FailedRoll(threshold2) &&
                    Dice100.FailedRoll(threshold1))
                {
                    punishmentType = 2; // fine/prison
                }
                else
                {
                    punishmentType = 0; // banishment or execution
                }
                // Calculate penalty amount
                int penaltyAmount = 0;

                if (legalRep >= 0)
                {
                    penaltyAmount = PenaltyPerLegalRepPoint[crimeType] * legalRep + BasePenaltyAmounts[crimeType];
                }
                else
                {
                    penaltyAmount = BasePenaltyAmounts[crimeType] - PenaltyPerLegalRepPoint[crimeType] * legalRep;
                }

                if (penaltyAmount > MaximumPenaltyAmounts[crimeType])
                {
                    penaltyAmount = MaximumPenaltyAmounts[crimeType];
                }
                else if (penaltyAmount < MinimumPenaltyAmounts[crimeType])
                {
                    penaltyAmount = MinimumPenaltyAmounts[crimeType];
                }

                penaltyAmount /= 40;

                // Calculate days of prison and fine
                daysInPrison = 0;
                fine         = 0;

                for (int i = 0; i < penaltyAmount; i++)
                {
                    if ((DFRandom.rand() & 1) != 0)
                    {
                        fine += 40;
                    }
                    else
                    {
                        daysInPrison += 3;
                    }
                }

                // If player can't pay fine, limit fine and add to prison sentence
                int playerGold = playerEntity.GetGoldAmount();
                if (playerGold < fine)
                {
                    daysInPrison += (fine - playerGold) / 40;
                    fine          = playerGold;
                }

                DaggerfallMessageBox messageBox;
                if (crimeType == 4 || crimeType == 3) // Assault or murder
                {
                    // If player is a member of the Dark Brotherhood, they may be rescued for a violent crime
                    Guilds.IGuild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Dark_Brotherhood);
                    if (guild.IsMember())
                    {
                        if (guild.Rank >= UnityEngine.Random.Range(0, 20))
                        {
                            messageBox = new DaggerfallMessageBox(uiManager, this, false, 149);
                            messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextDB));
                            messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                            messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                            messageBox.ClickAnywhereToClose          = true;
                            uiManager.PushWindow(messageBox);
                            playerEntity.FillVitalSigns();
                            playerEntity.RaiseReputationForDoingSentence();
                            state = 100;
                            return;
                        }
                    }
                }
                if (crimeType <= 2 || crimeType == 11) // Attempted breaking and entering, trespassing, breaking and entering, pickpocketing
                {
                    // If player is a member of the Thieves Guild, they may be rescued for a thieving crime
                    Guilds.IGuild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Thieves_Guild);
                    if (guild.IsMember())
                    {
                        if (guild.Rank >= UnityEngine.Random.Range(0, 20))
                        {
                            messageBox = new DaggerfallMessageBox(uiManager, this, false, 149);
                            messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextTG));
                            messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                            messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                            messageBox.ClickAnywhereToClose          = true;
                            messageBox.AllowCancel = false;
                            uiManager.PushWindow(messageBox);
                            playerEntity.FillVitalSigns();
                            playerEntity.RaiseReputationForDoingSentence();
                            state = 100;
                            return;
                        }
                    }
                }

                messageBox = new DaggerfallMessageBox(uiManager, this, false, 105);
                messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextStart));
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Guilty);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.NotGuilty);
                messageBox.OnButtonClick += GuiltyNotGuilty_OnButtonClick;
                messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                messageBox.AllowCancel = false;
                uiManager.PushWindow(messageBox);
                state = 1;       // Done with initial message
            }
            else if (state == 2) // Found guilty
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149);
                messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFoundGuilty));
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                messageBox.ClickAnywhereToClose          = true;
                messageBox.AllowCancel = false;
                uiManager.PushWindow(messageBox);

                if (daysInPrison > 0)
                {
                    state = 3;
                }
                else
                {
                    // Give the reputation raise here if no prison time will be served.
                    playerEntity.RaiseReputationForDoingSentence();
                    repositionPlayer = true;
                    playerEntity.FillVitalSigns();
                    ReleaseFromPrison();
                    state = 100;
                }
            }
            else if (state == 3) // Serve prison sentence
            {
                playerEntity.InPrison = true;
                SwitchToPrisonScreen();
                daysInPrisonLeft = daysInPrison;
                playerEntity.RaiseReputationForDoingSentence();
                repositionPlayer = true;
                state            = 100;
            }
            else if (state == 4) // Banished
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149);
                messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextBanished));
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                messageBox.ClickAnywhereToClose          = true;
                messageBox.AllowCancel = false;
                uiManager.PushWindow(messageBox);
                playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 1;
                repositionPlayer = true;
                state            = 100;
            }
            // Note: Seems like an execution sentence can't be given in classic. It can't be given here, either.
            else if (state == 5) // Execution
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149);
                messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextExecuted));
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom;
                messageBox.ClickAnywhereToClose          = true;
                messageBox.AllowCancel = false;
                uiManager.PushWindow(messageBox);
                playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 2;
                state = 6;
            }
            else if (state == 6) // Reposition player at entrance
            {
                repositionPlayer = true;
                state            = 100;
            }
            else if (state == 100) // Done
            {
                if (playerEntity.InPrison)
                {
                    if (Input.GetKey(exitKey)) // Speed up prison day countdown. Not in classic.
                    {
                        prisonUpdateInterval = 0.001f;
                    }
                    else
                    {
                        prisonUpdateInterval = 0.3f;
                    }

                    if (prisonUpdateTimer == 0)
                    {
                        prisonUpdateTimer = Time.realtimeSinceStartup;
                    }

                    if (Time.realtimeSinceStartup < prisonUpdateTimer + prisonUpdateInterval)
                    {
                        return;
                    }
                    else
                    {
                        prisonUpdateTimer = Time.realtimeSinceStartup;
                        UpdatePrisonScreen();
                    }
                }
                else
                {
                    ReleaseFromPrison();
                }
            }
        }
Example #13
0
        public override void Update(Task caller)
        {
            ulong gameSeconds = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToSeconds();

            // Init spawn timer on first update
            if (lastSpawnTime == 0)
            {
                lastSpawnTime = gameSeconds - (uint)UnityEngine.Random.Range(0, spawnInterval);
            }

            // Do nothing if max foes already spawned
            // This can be cleared on next set/rearm
            if (spawnCounter >= spawnMaxTimes && spawnMaxTimes != -1)
            {
                return;
            }

            // Clear pending foes if all have been spawned
            if (spawnInProgress && pendingFoesSpawned >= pendingFoeGameObjects.Length)
            {
                spawnInProgress = false;
                spawnCounter++;
                return;
            }

            // Check for a new spawn event - only one spawn event can be running at a time
            if (gameSeconds >= lastSpawnTime + spawnInterval && !spawnInProgress)
            {
                // Update last spawn time
                lastSpawnTime = gameSeconds;

                // Roll for spawn chance
                if (Dice100.FailedRoll(spawnChance))
                {
                    return;
                }

                // Get the Foe resource
                Foe foe = ParentQuest.GetFoe(foeSymbol);
                if (foe == null)
                {
                    SetComplete();
                    throw new Exception(string.Format("create foe could not find Foe with symbol name {0}", Symbol.Name));
                }

                // Do not spawn if foe is hidden
                if (foe.IsHidden)
                {
                    return;
                }

                // Start deploying GameObjects
                CreatePendingFoeSpawn(foe);
            }

            // Try to deploy a pending spawns
            if (spawnInProgress)
            {
                TryPlacement();
                GameManager.Instance.RaiseOnEncounterEvent();
            }
        }
Example #14
0
        static void ThiefEffects_OnNewMagicRound()
        {
            //Debug.Log("[ThiefOverhaul] Magic Round");
            if (playerEnterExit.IsPlayerInsideBuilding)
            {
                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)))
                    {
                        if (burglaryCounter >= 100)
                        {
                            DaggerfallUI.MessageBox("'Guards! Guards! We're being robbed!'");
                            if (Dice100.SuccessRoll(playerEntity.Stats.LiveLuck))
                            {
                                playerEntity.MagicalConcealmentFlags = MagicalConcealmentFlags.None;
                                DaggerfallUI.AddHUDText("Your magical concealment is broken");
                            }

                            playerEntity.CrimeCommitted = PlayerEntity.Crimes.Breaking_And_Entering;
                            playerEntity.SpawnCityGuards(true);
                        }
                        else if (burglaryCounter == 0)
                        {
                            DaggerfallUI.MessageBox(burglaryString1());
                            burglaryCounter += Mathf.Clamp(UnityEngine.Random.Range(100, 200) - playerEntity.Stats.LiveLuck, 10, 100);
                        }
                        else if (burglaryCounter < 50)
                        {
                            DaggerfallUI.MessageBox(burglaryString2());
                            burglaryCounter += Mathf.Clamp(UnityEngine.Random.Range(100, 200) - playerEntity.Stats.LiveLuck, 10, 100);
                        }
                        else
                        {
                            burglaryCounter += Mathf.Clamp(UnityEngine.Random.Range(100, 200) - playerEntity.Stats.LiveLuck, 10, 100);
                        }
                    }
                }
            }

            DaggerfallUnityItem ringSlot0     = playerEntity.ItemEquipTable.GetItem(EquipSlots.Ring0);
            DaggerfallUnityItem ringSlot1     = playerEntity.ItemEquipTable.GetItem(EquipSlots.Ring1);
            DaggerfallUnityItem markSlot0     = playerEntity.ItemEquipTable.GetItem(EquipSlots.Mark0);
            DaggerfallUnityItem markSlot1     = playerEntity.ItemEquipTable.GetItem(EquipSlots.Mark1);
            DaggerfallUnityItem braceletSlot0 = playerEntity.ItemEquipTable.GetItem(EquipSlots.Bracelet0);
            DaggerfallUnityItem braceletSlot1 = playerEntity.ItemEquipTable.GetItem(EquipSlots.Bracelet1);
            DaggerfallUnityItem bracerSlot0   = playerEntity.ItemEquipTable.GetItem(EquipSlots.Bracer0);
            DaggerfallUnityItem bracerSlot1   = playerEntity.ItemEquipTable.GetItem(EquipSlots.Bracer1);
            DaggerfallUnityItem crystalSlot0  = playerEntity.ItemEquipTable.GetItem(EquipSlots.Crystal0);
            DaggerfallUnityItem crystalSlot1  = playerEntity.ItemEquipTable.GetItem(EquipSlots.Crystal1);

            if (ringSlot0 != null && ringSlot0.TemplateIndex == templateIndex_Ring)
            {
                lockpickingBonus = 20;
            }
            else if (ringSlot1 != null && ringSlot1.TemplateIndex == templateIndex_Ring)
            {
                lockpickingBonus = 20;
            }
            else
            {
                lockpickingBonus = 0;
            }

            if (markSlot0 != null && markSlot0.TemplateIndex == templateIndex_Mark)
            {
                streetwiseBonus = 20;
            }
            else if (markSlot1 != null && markSlot1.TemplateIndex == templateIndex_Mark)
            {
                streetwiseBonus = 20;
            }
            else
            {
                streetwiseBonus = 0;
            }

            if (braceletSlot0 != null && braceletSlot0.TemplateIndex == templateIndex_Bracelet)
            {
                pickpocketBonus = 20;
            }
            else if (braceletSlot1 != null && braceletSlot1.TemplateIndex == templateIndex_Bracelet)
            {
                pickpocketBonus = 20;
            }
            else
            {
                pickpocketBonus = 0;
            }

            if (bracerSlot0 != null && bracerSlot0.TemplateIndex == templateIndex_Bracer)
            {
                climbingBonus = 20;
            }
            else if (bracerSlot1 != null && bracerSlot1.TemplateIndex == templateIndex_Bracer)
            {
                climbingBonus = 20;
            }
            else
            {
                climbingBonus = 0;
            }

            if (crystalSlot0 != null && crystalSlot0.TemplateIndex == templateIndex_Crystal)
            {
                stealthBonus = 20;
            }
            else if (crystalSlot1 != null && crystalSlot1.TemplateIndex == templateIndex_Crystal)
            {
                stealthBonus = 20;
            }
            else
            {
                stealthBonus = 0;
            }


            if (!GameManager.IsGamePaused && playerEntity.CurrentHealth > 0)
            {
                int[] skillMods = new int[DaggerfallSkills.Count];
                skillMods[(int)DFCareer.Skills.Lockpicking] = +lockpickingBonus;
                skillMods[(int)DFCareer.Skills.Streetwise]  = +streetwiseBonus;
                skillMods[(int)DFCareer.Skills.Pickpocket]  = +pickpocketBonus;
                skillMods[(int)DFCareer.Skills.Climbing]    = +climbingBonus;
                skillMods[(int)DFCareer.Skills.Stealth]     = +stealthBonus;
                playerEffectManager.MergeDirectSkillMods(skillMods);
            }
        }