Beispiel #1
0
        //generates pop-ups, either to indicate failed transaction
        //or to prompt with yes / no option
        void GeneratePopup(TransactionResult result, int amount = 0)
        {
            if (result == TransactionResult.NONE)
            {
                return;
            }

            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);

            messageBox.ClickAnywhereToClose = true;
            this.amount = amount;

            if (result == TransactionResult.TOO_HEAVY)
            {
                messageBox.SetText(HardStrings.cannotCarryGold);
            }
            else
            {
                messageBox.SetTextTokens((int)result, this);
            }

            if (result == TransactionResult.DEPOSIT_LOC) //show messagebox window w/ yes no buttons
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += DepositLOC_messageBox_OnButtonClick;
            }

            else if (result == TransactionResult.SELL_HOUSE_OFFER) //show messagebox window w/ yes no buttons
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += SellHouse_messageBox_OnButtonClick;
            }
            else if (result == TransactionResult.SELL_SHIP_OFFER)
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += SellShip_messageBox_OnButtonClick;
            }

            messageBox.Show();
        }
 private void SellButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
 {
     Debug.Log("Sell");
     DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
     if (!guild.CanAccessService(Services.GetService(npcService)))
     {
         DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this);
         msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(DaggerfallGuildServicePopupWindow.InsufficientRankId));
         msgBox.ClickAnywhereToClose = true;
         msgBox.Show();
     }
     else
     {
         CloseWindow();
         uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.SellMagic, guild }));
     }
 }
        private static void BribePrompt()
        {
            string[] message =
            {
                "Halt! You are under arrest for " + playerEntity.CrimeCommitted.ToString() + ".",
                " ",
                "Do you attempt to bribe the guard?"
            };
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

            messageBox.SetText(message);
            messageBox.ParentPanel.BackgroundColor = Color.clear;
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
            messageBox.OnButtonClick += Bribe_OnButtonClick;
            messageBox.Show();
        }
        public static void LocatorService(IUserInterfaceWindow window)
        {
            // Get the guild instance.
            IGuild thisGuild = GameManager.Instance.GuildManager.GetGuild(FactionFile.GuildGroups.GGroup0);

            // Check how many holy items the player has and offer that many discounted.
            PlayerEntity playerEntity        = GameManager.Instance.PlayerEntity;
            List <DaggerfallUnityItem> tomes = playerEntity.Items.SearchItems(ItemGroups.ReligiousItems, (int)ReligiousItems.Holy_tome);

            tomes.AddRange(playerEntity.WagonItems.SearchItems(ItemGroups.ReligiousItems, (int)ReligiousItems.Holy_tome));
            List <DaggerfallUnityItem> daggers = playerEntity.Items.SearchItems(ItemGroups.ReligiousItems, (int)ReligiousItems.Holy_dagger);

            daggers.AddRange(playerEntity.WagonItems.SearchItems(ItemGroups.ReligiousItems, (int)ReligiousItems.Holy_dagger));
            int holyCount = tomes.Count + daggers.Count;

            // Show trade window and a popup message to inform player how many discounted locators they can purchase.
            DaggerfallTradeWindow tradeWindow = (DaggerfallTradeWindow)
                                                UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { DaggerfallUI.UIManager, null, DaggerfallTradeWindow.WindowModes.Buy, thisGuild });

            tradeWindow.MerchantItems = GetLocatorDevices(holyCount, RankLocatorCosts[thisGuild.Rank]);
            DaggerfallUI.UIManager.PushWindow(tradeWindow);
            tradeWindow.OnTrade += LocatorPurchase_OnTrade;

            if (thisGuild.Rank < 8)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, window);
                string[]             message    =
                {
                    "   If you can supply the guild with either a holy tome or holy dagger,",
                    "  then we can sell locator devices at a third of normal price per relic.",
                    "    Locator prices will reduce as you gain higher ranks in the guild.",
                    "",
                    "      You currently have " + holyCount + " holy relics in your posession, so you can",
                    "     purchase up to that many discounted locators at this time.",
                };
                if (holyCount == 0)
                {
                    message[4] = "       You don't have any holy relics with you right now, so";
                    message[5] = "     unfortunately we can't offer you any discounts this time.";
                }
                messageBox.SetText(message);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
            }
        }
Beispiel #5
0
        public static void RestOrPackTent(RaycastHit hit)
        {
            DaggerfallMessageBox campPopUp = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);

            if (hit.transform.gameObject.GetInstanceID() == Tent.GetInstanceID())
            {
                string[] message = { "Do you wish to rest?" };
                campPopUp.SetText(message);
                campPopUp.OnButtonClick += CampPopUp_OnButtonClick;
                campPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                campPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                campPopUp.Show();
            }
            else
            {
                DaggerfallUI.MessageBox("This is not your camp.");
            }
        }
        void Update()
        {
            if (playerAutopilot != null)
            {
                if (!travelUi.isShowing)
                {
                    DaggerfallUI.UIManager.PushWindow(travelUi);
                }

                playerAutopilot.Update();

                hudVitals.Update();

                if (GameManager.Instance.AreEnemiesNearby() && delayCombat <= 0.0f)
                {
                    if (encounterAvoidanceSystem)
                    {
                        InterruptFastTravel();

                        UserInterfaceManager uiManager      = DaggerfallUI.Instance.UserInterfaceManager;
                        DaggerfallMessageBox avoidEncounter = new DaggerfallMessageBox(uiManager, DaggerfallMessageBox.CommonMessageBoxButtons.YesNo,
                                                                                       "You approach a hostile encounter. Attempt to avoid it?", uiManager.TopWindow);
                        avoidEncounter.OnButtonClick += AvoidEncounter_OnButtonClick;
                        avoidEncounter.Show();
                    }
                    else
                    {
                        travelUi.CloseWindow();
                        DaggerfallUI.MessageBox("An enemy is seeking to bring a premature end to your journey...");
                        return;
                    }
                }
                else if (delayCombat > 0.0f)
                {
                    delayCombat -= Time.deltaTime;

                    if (delayCombat <= 0.0f)
                    {
                        delayCombat = 0.0f;
                    }
                }
            }
        }
Beispiel #7
0
        protected override void MixCauldron()
        {
            base.MixCauldron();

            item.currentCondition -= 10;

            if (item.currentCondition < 1)
            {
                TextFile.Token[] tokens = DaggerfallUnity.TextProvider.GetRSCTokens(itemBrokenTextId);
                if (tokens != null && tokens.Length > 0)
                {
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                    messageBox.SetTextTokens(tokens, item);
                    messageBox.ClickAnywhereToClose = true;
                    messageBox.Show();
                }
                parentPanel.OnMouseMove += ParentPanel_OnMouseMove;
            }
        }
        public override void Update(Task caller)
        {
            DaggerfallMessageBox messageBox = CreateCustomMessagePrompt(ParentQuest, id);

            if (messageBox != null)
            {
                Debug.Log("Created messagebox");
                Debug.Log("Adding buttons (" + buttonKeys.Length.ToString() + ")");
                for (int i = 0; i < buttonKeys.Length; i++)
                {
                    Debug.Log("Creating button: " + buttonKeys[i]);
                    messageBox.AddCustomButton(id + i, buttonKeys[i], false);
                }
                Debug.Log("Adding click event");
                messageBox.OnCustomButtonClick += MessageBox_OnCustomButtonClick;
                Debug.Log("Showing messagebox");
                messageBox.Show();
            }
            SetComplete();
        }
Beispiel #9
0
        public void ShowHolidayText()
        {
            const int holidaysStartID = 8349;

            uint minutes   = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            int  holidayId = Formulas.FormulaHelper.GetHolidayId(minutes, holidayTextLocation.RegionIndex);

            if (holidayId != 0)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                messageBox.SetTextTokens(holidaysStartID + holidayId);
                messageBox.ClickAnywhereToClose        = true;
                messageBox.ParentPanel.BackgroundColor = Color.clear;
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.Show();
            }

            // Set holiday text timer to a somewhat large value so it doesn't show again and again if the player is repeatedly crossing the
            // border of a city.
            holidayTextTimer = 10f;
        }
        private static void ShowMessageBox(string message, bool clickAnywhereToClose = true, string[] buttons = null)
        {
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

            messageBox.ClickAnywhereToClose        = clickAnywhereToClose;
            messageBox.ParentPanel.BackgroundColor = Color.clear;
            messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);

            messageBox.SetText(message);

            if (buttons != null)
            {
                for (int i = 0; i < buttons.Length; i++)
                {
                    messageBox.AddCustomButton(99 + i, buttons[i], false);
                }
                messageBox.OnCustomButtonClick += Tent_messageBox_OnButtonClick;
            }

            messageBox.Show();
        }
Beispiel #11
0
        private void EffectActionPrompt_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            sender.CloseWindow();

            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Anchor)
            {
                SetAnchor();
            }
            else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Teleport)
            {
                if (GameManager.Instance.PlayerEntity.AnchorPosition == null)
                {
                    DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, DaggerfallUI.Instance.UserInterfaceManager.TopWindow);
                    mb.SetTextTokens(achorMustBeSet);
                    mb.ClickAnywhereToClose = true;
                    mb.Show();
                    return;
                }
                TeleportPlayer();
            }
        }
Beispiel #12
0
        void PromptPlayer()
        {
            // Get peered entity gameobject
            DaggerfallEntityBehaviour entityBehaviour = GetPeeredEntityBehaviour(manager);

            if (!entityBehaviour)
            {
                return;
            }

            // Target must be player - no effect on other entities
            if (entityBehaviour != GameManager.Instance.PlayerEntityBehaviour)
            {
                return;
            }

            // Prompt for outcome
            DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, DaggerfallMessageBox.CommonMessageBoxButtons.AnchorTeleport, teleportOrSetAnchor, DaggerfallUI.Instance.UserInterfaceManager.TopWindow);

            mb.OnButtonClick += EffectActionPrompt_OnButtonClick;
            mb.Show();
        }
Beispiel #13
0
        private void EffectActionPrompt_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            sender.CloseWindow();

            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Anchor)
            {
                SetAnchor();
            }
            else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Teleport)
            {
                if (!anchorSet)
                {
                    DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, DaggerfallUI.Instance.UserInterfaceManager.TopWindow);
                    mb.SetTextTokens(achorMustBeSet);
                    mb.ClickAnywhereToClose = true;
                    mb.Show();
                    forcedRoundsRemaining = 0;
                    ResignAsIncumbent();
                    return;
                }
                TeleportPlayer();
            }
        }
Beispiel #14
0
    private void CheckDependencies()
    {
        bool          hasSortIssues    = false;
        List <string> errorMessages    = null;
        var           modErrorMessages = new List <string>();

        foreach (Mod mod in ModManager.Instance.Mods.Where(x => x.Enabled))
        {
            bool?isGameVersionSatisfied = mod.IsGameVersionSatisfied();
            if (!isGameVersionSatisfied.HasValue)
            {
                Debug.LogErrorFormat("Mod {0} requires unknown game version ({1}).", mod.Title, mod.ModInfo.DFUnity_Version);
            }
            else if (!isGameVersionSatisfied.Value)
            {
                modErrorMessages.Add(string.Format(ModManager.GetText("gameVersionUnsatisfied"), mod.ModInfo.DFUnity_Version));
            }

            ModManager.Instance.CheckModDependencies(mod, modErrorMessages, ref hasSortIssues);
            if (modErrorMessages.Count > 0)
            {
                if (errorMessages == null)
                {
                    errorMessages = new List <string>();
                    errorMessages.Add(ModManager.GetText("dependencyErrorMessage"));
                    errorMessages.Add(string.Empty);
                }

                errorMessages.Add(string.Format("- {0}", mod.Title));
                errorMessages.AddRange(modErrorMessages);
                errorMessages.Add(string.Empty);
                modErrorMessages.Clear();
            }
        }

        if (errorMessages != null && errorMessages.Count > 0)
        {
            if (hasSortIssues)
            {
                errorMessages.Add(ModManager.GetText("sortModsQuestion"));
            }

            var messageBox = new DaggerfallMessageBox(uiManager, this);
            messageBox.EnableVerticalScrolling(80);
            messageBox.SetText(errorMessages.ToArray());
            if (hasSortIssues)
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                messageBox.OnButtonClick += (sender, button) =>
                {
                    if (button == DaggerfallMessageBox.MessageBoxButtons.Yes)
                    {
                        ModManager.Instance.AutoSortMods();
                        Debug.Log("Mods have been sorted automatically");
                    }

                    sender.CancelWindow();
                    moveNextStage = true;
                };
            }
            else
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.OK, true);
                messageBox.OnButtonClick += (sender, button) =>
                {
                    sender.CancelWindow();
                    moveNextStage = true;
                };
            }
            messageBox.Show();
        }
        else
        {
            moveNextStage = true;
        }
    }
        public static void RepairMarkService(IUserInterfaceWindow window)
        {
            Debug.Log("Repair Recall Mark service.");

            DaggerfallUnityItem markOfRecall = FindRecallMark();

            if (markOfRecall == null)
            {
                if (GameManager.Instance.PlayerEntity.GetGoldAmount() < replaceMarkCost)
                {
                    DaggerfallUI.MessageBox(new string[] {
                        "You don't appear to have your Mark of Recall on you, or enough",
                        "for a replacement. If you have been careless and lost or broken",
                        "it, I can replace it for a price of 10,000 gold pieces. They're",
                        "expensive, and the guild only provides one free Mark per member."
                    });
                }
                else
                {
                    DaggerfallMessageBox replaceMarkBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, window, true);
                    string[]             message        =
                    {
                        "   You don't appear to have your Mark of Recall on you.",
                        "   If you have been careless and lost or broken it, then",
                        "      I can replace it at a cost of 10,000 gold.",
                        "",
                        "      Would you like a replacement Mark of Recall?"
                    };
                    replaceMarkBox.SetText(message);
                    replaceMarkBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    replaceMarkBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                    replaceMarkBox.OnButtonClick += ReplaceMarkBox_OnButtonClick;
                    replaceMarkBox.Show();
                }
            }
            else
            {
                int cost = CalculateRepairCost(markOfRecall);
                if (GameManager.Instance.PlayerEntity.GetGoldAmount() < cost)
                {
                    DaggerfallUI.MessageBox(notEnoughGoldId);
                }
                else if (cost == 0)
                {
                    if (HasLocationsBook())
                    {
                        DaggerfallUI.MessageBox("Your Mark of Recall shows no signs of wear that I can see.");
                    }
                    else
                    {
                        DaggerfallMessageBox replaceBookBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, window, true);
                        string[]             message        =
                        {
                            "Your Mark of Recall shows no signs of wear that I can see.",
                            "",
                            "  However, you do appear to have misplaced your guild hall",
                            "      locations book. Would you like a replacement?"
                        };
                        replaceBookBox.SetText(message);
                        replaceBookBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                        replaceBookBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                        replaceBookBox.OnButtonClick += ReplaceBookBox_OnButtonClick;
                        replaceBookBox.Show();
                    }
                }
                else
                {
                    string message = "Repairing your Mark of Recall will cost " + cost + " gp, okay?";
                    DaggerfallMessageBox confirmRepairBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallMessageBox.CommonMessageBoxButtons.YesNo, message, window);
                    confirmRepairBox.OnButtonClick += ConfirmRepairBox_OnButtonClick;
                    confirmRepairBox.Show();
                }
            }
        }
Beispiel #16
0
        public DaggerfallMessageBox ShowMessagePopup(int id)
        {
            const int chunkSize = 22;

            // Get message resource
            Message message = GetMessage(id);

            if (message == null)
            {
                return(null);
            }

            // Get all message tokens
            TextFile.Token[] tokens = message.GetTextTokens();
            if (tokens == null || tokens.Length == 0)
            {
                return(null);
            }

            // Split token lines into chunks for display
            // This break huge blocks of text into multiple popups
            int lineCount = 0;
            List <TextFile.Token>   currentChunk = new List <TextFile.Token>();
            List <TextFile.Token[]> chunks       = new List <TextFile.Token[]>();

            for (int i = 0; i < tokens.Length; i++)
            {
                // Add current token
                currentChunk.Add(tokens[i]);

                // Count new lines and start a new chunk at max size
                if (tokens[i].formatting == TextFile.Formatting.JustifyCenter ||
                    tokens[i].formatting == TextFile.Formatting.JustifyLeft ||
                    tokens[i].formatting == TextFile.Formatting.Nothing)
                {
                    if (++lineCount > chunkSize)
                    {
                        chunks.Add(currentChunk.ToArray());
                        currentChunk.Clear();
                        lineCount = 0;
                    }
                }
            }

            // Add final chunk only if not empty
            if (currentChunk.Count > 0)
            {
                chunks.Add(currentChunk.ToArray());
            }

            // Display message boxes in reverse order - this is the previous way of showing stacked popups
            DaggerfallMessageBox rootMessageBox = null;

            for (int i = chunks.Count - 1; i >= 0; i--)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                messageBox.SetTextTokens(chunks[i]);
                messageBox.ClickAnywhereToClose        = true;
                messageBox.AllowCancel                 = true;
                messageBox.ParentPanel.BackgroundColor = Color.clear;
                messageBox.Show();

                if (i == 0)
                {
                    rootMessageBox = messageBox;
                }
            }

            //// Compose root message box and use AddNextMessageBox() - this is a new technique added by Hazelnut
            //// TODO: Currently when linking more than two message boxes the final two boxes loop between each other
            //// Will return to this later to check, for now just want to continue with quest work
            //DaggerfallMessageBox rootMessageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
            //rootMessageBox.SetTextTokens(chunks[0]);
            //rootMessageBox.ClickAnywhereToClose = true;
            //rootMessageBox.AllowCancel = true;
            //rootMessageBox.ParentPanel.BackgroundColor = Color.clear;

            //// String together remaining message boxes (if any)
            //DaggerfallMessageBox lastMessageBox = rootMessageBox;
            //for (int i = 1; i < chunks.Count; i++)
            //{
            //    DaggerfallMessageBox thisMessageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
            //    thisMessageBox.SetTextTokens(chunks[i]);
            //    thisMessageBox.ClickAnywhereToClose = true;
            //    thisMessageBox.AllowCancel = true;
            //    thisMessageBox.ParentPanel.BackgroundColor = Color.clear;
            //    lastMessageBox.AddNextMessageBox(thisMessageBox);
            //    lastMessageBox = thisMessageBox;
            //}
            //rootMessageBox.Show();

            // Set a quest break so popup will display immediately
            questBreak = true;

            return(rootMessageBox);
        }
Beispiel #17
0
        private int ApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
        {
            const int doYouSurrenderToGuardsTextID = 15;

            EnemyEntity  entity       = entityBehaviour.Entity as EnemyEntity;
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            // Calculate damage
            damage = FormulaHelper.CalculateAttackDamage(entity, playerEntity, false, 0, weapon);

            // Break any "normal power" concealment effects on enemy
            if (entity.IsMagicallyConcealedNormalPower && damage > 0)
            {
                EntityEffectManager.BreakNormalPowerConcealmentEffects(entityBehaviour);
            }

            // Tally player's dodging skill
            playerEntity.TallySkill(DFCareer.Skills.Dodging, 1);

            // Handle Strikes payload from enemy to player target - this could change damage amount
            if (damage > 0 && weapon != null && weapon.IsEnchanted)
            {
                EntityEffectManager effectManager = GetComponent <EntityEffectManager>();
                if (effectManager)
                {
                    damage = effectManager.DoItemEnchantmentPayloads(EnchantmentPayloadFlags.Strikes, weapon, entity.Items, playerEntity.EntityBehaviour, damage);
                }
            }

            if (damage > 0)
            {
                if (entity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch)
                {
                    // If hit by a guard, lower reputation and show the surrender dialogue
                    if (!playerEntity.HaveShownSurrenderToGuardsDialogue && playerEntity.CrimeCommitted != PlayerEntity.Crimes.None)
                    {
                        playerEntity.LowerRepForCrime();

                        DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                        messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(doYouSurrenderToGuardsTextID));
                        messageBox.ParentPanel.BackgroundColor = Color.clear;
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                        messageBox.OnButtonClick += SurrenderToGuardsDialogue_OnButtonClick;
                        messageBox.Show();

                        playerEntity.HaveShownSurrenderToGuardsDialogue = true;
                    }
                    // Surrender dialogue has been shown and player refused to surrender
                    // Guard damages player if player can survive hit, or if hit is fatal but guard rejects player's forced surrender
                    else if (playerEntity.CurrentHealth > damage || !playerEntity.SurrenderToCityGuards(false))
                    {
                        SendDamageToPlayer();
                    }
                }
                else
                {
                    SendDamageToPlayer();
                }
            }
            else
            {
                sounds.PlayMissSound(weapon);
            }

            return(damage);
        }
Beispiel #18
0
        private static void BribePopup()
        {
            int regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex;
            int crimeType   = (int)playerEntity.CrimeCommitted - 1;
            int legalRep    = playerEntity.RegionData[regionIndex].LegalRep;
            int streetwise  = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Streetwise) + (playerEntity.Stats.LiveLuck / 10) - 5;
            int crimeLevel  = 1;

            //Legalrep = 0 common. -11 gives chance of Criminal Conspiracy, -80 is hated.

            //1 = minor, 2 = major, 3 = high
            if ((crimeType >= 4 && crimeType <= 7) || crimeType == 9)
            {
                crimeLevel = 2;
            }
            else if (crimeType == 10 || crimeType == 11 || crimeType == 14)
            {
                crimeLevel = 3;
            }

            int cost = CalculateBribeCost(crimeLevel);

            if (cost > playerEntity.GoldPieces)
            {
                DaggerfallUI.MessageBox("You are not carrying enough gold to pay the guard.");
            }

            bool charmGuard  = UnityEngine.Random.Range(10, 100) * crimeLevel < streetwise + legalRep;
            bool affordBribe = cost <= playerEntity.GoldPieces;


            if (charmGuard)
            {
                if (cost == 0)
                {
                    playerEntity.CrimeCommitted = PlayerEntity.Crimes.None;
                    playerEntity.SpawnCityGuards(false);
                    string[] message =
                    {
                        "You manage to talk yourself out of the situation.",
                        " ",
                        "The guard leaves you alone without even taking a bribe."
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                    messageBox.SetText(message);
                    messageBox.ClickAnywhereToClose        = true;
                    messageBox.AllowCancel                 = true;
                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                    messageBox.Show();
                }
                if (affordBribe)
                {
                    playerEntity.CrimeCommitted = PlayerEntity.Crimes.None;
                    playerEntity.SpawnCityGuards(false);
                    string[] message =
                    {
                        "You come to an agreement with the guard.",
                        " ",
                        cost.ToString() + " gold changes hands and you part ways."
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                    messageBox.SetText(message);
                    messageBox.ClickAnywhereToClose        = true;
                    messageBox.AllowCancel                 = true;
                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                    messageBox.Show();
                }
                else
                {
                    ArrestPrompt();
                    string[] message =
                    {
                        "You almost come to an agreement with the guard.",
                        " ",
                        "But you do not have the " + cost.ToString() + " gold he demands."
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                    messageBox.SetText(message);
                    messageBox.ClickAnywhereToClose        = true;
                    messageBox.AllowCancel                 = true;
                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                    messageBox.Show();
                }
            }
            else
            {
                ArrestPrompt();
                DaggerfallUI.MessageBox("The guard is not interested in your attempts at a conversation.");
            }
        }
Beispiel #19
0
        internal void DisplayLocationInfo()
        {
            if (LocationSummary.LocationType == DFRegion.LocationTypes.Coven ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonKeep ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonLabyrinth ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonRuin ||
                LocationSummary.LocationType == DFRegion.LocationTypes.Graveyard ||
                LocationSummary.LocationType == DFRegion.LocationTypes.None)
            {
                return;
            }

            Dictionary <int, PlayerGPS.DiscoveredLocation> discoveryData = GameManager.Instance.PlayerGPS.GetDiscoverySaveData();

            if (discoveryData.ContainsKey(LocationSummary.ID))
            {
                PlayerGPS.DiscoveredLocation discoveredLocation             = discoveryData[locationSummary.ID];
                Dictionary <int, PlayerGPS.DiscoveredBuilding> locBuildings = discoveredLocation.discoveredBuildings;
                if (locBuildings != null && locBuildings.Count > 0)
                {
                    IDictionary <DFLocation.BuildingTypes, int> buildingTypeCounts = new SortedDictionary <DFLocation.BuildingTypes, int>();
                    List <string> guildNames = new List <string>();
                    foreach (PlayerGPS.DiscoveredBuilding building in locBuildings.Values)
                    {
                        if (RMBLayout.IsNamedBuilding(building.buildingType))
                        {
                            string guildName = building.displayName.StartsWith("The ") ? building.displayName.Substring(4) : building.displayName;
                            if (building.buildingType == DFLocation.BuildingTypes.GuildHall && !guildNames.Contains(guildName))
                            {
                                guildNames.Add(guildName);
                            }

                            if (building.buildingType != DFLocation.BuildingTypes.GuildHall)
                            {
                                if (buildingTypeCounts.ContainsKey(building.buildingType))
                                {
                                    buildingTypeCounts[building.buildingType]++;
                                }
                                else
                                {
                                    buildingTypeCounts.Add(building.buildingType, 1);
                                }
                            }
                        }
                    }
                    List <TextFile.Token> tokens = new List <TextFile.Token>();
                    tokens.Add(new TextFile.Token()
                    {
                        text       = GetLocationNameInCurrentRegion(locationSummary.MapIndex, true),
                        formatting = TextFile.Formatting.TextHighlight
                    });
                    tokens.Add(newLine);
                    tokens.Add(newLine);

                    guildNames.Sort();
                    string guilds = "";
                    foreach (string guildName in guildNames)
                    {
                        if (!string.IsNullOrWhiteSpace(guilds))
                        {
                            guilds += ", ";
                        }
                        guilds += guildName;
                    }
                    TextFile.Token tab1 = TextFile.TabToken;
                    tab1.x = 45;
                    TextFile.Token tab2 = TextFile.TabToken;
                    tab2.x = 100;
                    TextFile.Token tab3 = TextFile.TabToken;
                    tab3.x = 145;
                    if (!string.IsNullOrWhiteSpace(guilds))
                    {
                        tokens.Add(TextFile.CreateTextToken("Guild Halls:    " + guilds));
                    }
                    tokens.Add(newLine);
                    tokens.Add(TextFile.NewLineToken);

                    bool secondColumn = false;
                    foreach (DFLocation.BuildingTypes buildingType in buildingTypeCounts.Keys)
                    {
                        tokens.Add(TextFile.CreateTextToken(buildingType.ToString()));
                        tokens.Add(!secondColumn ? tab1 : tab3);
                        tokens.Add(TextFile.CreateTextToken(buildingTypeCounts[buildingType].ToString()));
                        if (!secondColumn)
                        {
                            tokens.Add(tab2);
                        }
                        else
                        {
                            tokens.Add(TextFile.NewLineToken);
                        }
                        secondColumn = !secondColumn;
                    }

                    infoBox = new DaggerfallMessageBox(uiManager, this);
                    infoBox.ClickAnywhereToClose = true;
                    infoBox.SetHighlightColor(Color.white);
                    infoBox.SetTextTokens(tokens.ToArray());
                    infoBox.OnClose += InfoBox_Close;
                    infoBox.Show();

                    return;
                }
            }
            DaggerfallUI.MessageBox("You have no knowledge of " + GetLocationNameInCurrentRegion(locationSummary.MapIndex, true) + ".");
        }
Beispiel #20
0
        private int ApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
        {
            const int doYouSurrenderToGuardsTextID = 15;

            EnemyEntity  entity       = entityBehaviour.Entity as EnemyEntity;
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            int enemyDamType = EnemyDamageTypeUsed(entity, weapon); // Returns an integer value that corresponds to a specific damage type that this type of enemy can use, will use later on in combat formula.

            // Calculate damage
            damage = FormulaHelper.CalculateAttackDamage(entity, playerEntity, -1, 0, weapon, out bool shieldBlockSuccess, out int mainDamType, out bool critStrikeSuccess, out bool armorPartAbsorbed, out bool armorCompleteAbsorbed, out Items.DaggerfallUnityItem addedAIWeapon, out bool hitSuccess, out bool metalShield, out bool metalArmor, enemyDamType);

            // Break any "normal power" concealment effects on enemy
            if (entity.IsMagicallyConcealedNormalPower && damage > 0)
            {
                EntityEffectManager.BreakNormalPowerConcealmentEffects(entityBehaviour);
            }

            // Tally player's dodging skill
            playerEntity.TallySkill(DFCareer.Skills.Dodging, 1);

            // Handle Strikes payload from enemy to player target - this could change damage amount
            if (damage > 0 && weapon != null && weapon.IsEnchanted)
            {
                EntityEffectManager effectManager = GetComponent <EntityEffectManager>();
                if (effectManager)
                {
                    damage = effectManager.DoItemEnchantmentPayloads(EnchantmentPayloadFlags.Strikes, weapon, entity.Items, playerEntity.EntityBehaviour, damage);
                }
            }

            // If the AI was given a weapon through the damage formula, this gives them that weapon for this part of the calling method for later use.
            if (weapon == null)
            {
                weapon = addedAIWeapon;
            }

            // Play associated sound when armor/shield was responsible for absorbing damage completely.
            if (damage <= 0)
            {
                if (hitSuccess && shieldBlockSuccess)
                {
                    sounds.PlayShieldBlockSound(weapon, metalShield);
                }
                else if (hitSuccess && armorCompleteAbsorbed)
                {
                    sounds.PlayArmorAbsorbSound(weapon, metalArmor);
                }
                else
                {
                    sounds.PlayMissSound(weapon);
                }
            }

            if (damage > 0)
            {
                if (entity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch)
                {
                    // If hit by a guard, lower reputation and show the surrender dialogue
                    if (!playerEntity.HaveShownSurrenderToGuardsDialogue && playerEntity.CrimeCommitted != PlayerEntity.Crimes.None)
                    {
                        playerEntity.LowerRepForCrime();

                        DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                        messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(doYouSurrenderToGuardsTextID));
                        messageBox.ParentPanel.BackgroundColor = Color.clear;
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                        messageBox.OnButtonClick += SurrenderToGuardsDialogue_OnButtonClick;
                        messageBox.Show();

                        playerEntity.HaveShownSurrenderToGuardsDialogue = true;
                    }
                    // Surrender dialogue has been shown and player refused to surrender
                    // Guard damages player if player can survive hit, or if hit is fatal but guard rejects player's forced surrender
                    else if (playerEntity.CurrentHealth > damage || !playerEntity.SurrenderToCityGuards(false))
                    {
                        if (shieldBlockSuccess && armorPartAbsorbed)
                        {
                            sounds.PlayShieldBlockSound(weapon, metalShield);
                        }
                        SendDamageToPlayer();
                    }
                }
                else
                {
                    if (shieldBlockSuccess && armorPartAbsorbed)
                    {
                        sounds.PlayShieldBlockSound(weapon, metalShield);
                    }
                    SendDamageToPlayer();
                }
            }

            return(damage);
        }
        protected void TrainingSkillPicker_OnItemPicked(int index, string skillName)
        {
            Mod  rrMod       = ModManager.Instance.GetMod("RoleplayRealism");
            bool skillPrices = rrMod.GetSettings().GetBool("RefinedTraining", "variableTrainingPrice");
            bool intensive   = rrMod.GetSettings().GetBool("RefinedTraining", "intensiveTraining");

            CloseWindow();
            List <DFCareer.Skills> trainingSkills = GetTrainingSkills();

            skillToTrain = trainingSkills[index];
            int trainingMax = Guild.GetTrainingMax(skillToTrain);
            int skillValue  = playerEntity.Skills.GetPermanentSkillValue(skillToTrain);

            if (skillValue > trainingMax)
            {
                // 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
            {
                // Calculate training price, modifying based on current skill value as well as player level if enabled
                trainingCost = Guild.GetTrainingPrice();
                if (skillPrices)
                {
                    float skillOfMax = 1 - ((float)skillValue / trainingMax);
                    trainingCost -= (int)(trainingCost * skillOfMax / 2);
                }

                // Offer training and cost to player
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(TrainingOfferId);
                int pos = tokens[0].text.IndexOf(" ");
                tokens[0].text = tokens[0].text.Substring(0, pos) + " " + skillToTrain + tokens[0].text.Substring(pos);

                intensiveCost = (trainingCost + (playerEntity.Level * 8) + 72) * 5;
                TextFile.Token[] trainingTokens =
                {
                    TextFile.CreateTextToken("Training your " + skillToTrain + " skill will cost %a gold for a single session."),      newLine, newLine,
                    TextFile.CreateTextToken("You can also pay extra to train intensively for five days if you wish,"),                newLine,
                    TextFile.CreateTextToken("with a training session each day, this will cost " + intensiveCost + " gold in total."), newLine, newLine,
                    TextFile.CreateTextToken("So, would you like to train your " + skillToTrain + " skill with me?"),                  newLine,
                };

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                if (intensive && skillValue < trainingMax - 4)
                {
                    messageBox.SetTextTokens(trainingTokens, this);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    messageBox.AddButton(weekButton);
                }
                else
                {
                    messageBox.SetTextTokens(tokens, this);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                }
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTrainingPayment_OnButtonClick;
                messageBox.Show();
            }
        }