// Creates the custom text-box after repairing an item.
 public void ShowCustomTextBox(bool toolBroke, DaggerfallUnityItem itemToRepair, bool cantRepair)
 {
     if (cantRepair)
     {
         TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.CreateTokens(
             TextFile.Formatting.JustifyCenter,
             "This " + itemToRepair.LongName + " is damaged beyond your abilities.",
             "You would be best to seek the skills of a professional at this point.");
         DaggerfallMessageBox itemTooDamagedText = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);
         itemTooDamagedText.SetTextTokens(tokens);
         itemTooDamagedText.ClickAnywhereToClose = true;
         uiManager.PushWindow(itemTooDamagedText);
     }
     else
     {
         TextFile.Token[]     tokens           = RTTextTokenHolder.ItemRepairTextTokens(GetItemID(), toolBroke, itemToRepair);
         DaggerfallMessageBox itemRepairedText = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);
         itemRepairedText.SetTextTokens(tokens);
         itemRepairedText.ClickAnywhereToClose = true;
         uiManager.PushWindow(itemRepairedText);
     }
 }
Beispiel #2
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 #3
0
        //generates pop-ups, either to indicate failed transaction
        //or to prompt with yes / no option
        void GeneratePopup(TransactionResult result, long amount = 0)
        {
            if (result == TransactionResult.NONE)
            {
                return;
            }

            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);

            messageBox.ClickAnywhereToClose = true;
            messageBox.SetTextTokens((int)result);

            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();
        }
Beispiel #4
0
        /// <summary>
        /// Schedule a quest message popup at end of task execution.
        /// Message may be split into multiple chunks to display on screen.
        /// </summary>
        /// <param name="id">ID of message,</param>
        /// <param name="immediate">Break quest execution at point of popup to display it immediately.</param>
        /// <returns>MessageBox. Will be top of display stack for chunked messages. Always null after using immediate flag.</returns>
        public DaggerfallMessageBox ShowMessagePopup(int id, bool immediate = false)
        {
            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());
            }

            // Push message boxes to stack
            for (int i = 0; i < chunks.Count; i++)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                messageBox.SetTextTokens(chunks[i], ExternalMCP);
                messageBox.ClickAnywhereToClose        = true;
                messageBox.AllowCancel                 = true;
                messageBox.ParentPanel.BackgroundColor = Color.clear;
                pendingMessageBoxStack.Push(messageBox);
            }

            // Show messages immediately if requested
            if (immediate)
            {
                QuestBreak = true;
                ShowPendingTaskMessages();
                return(null);
            }

            return(pendingMessageBoxStack.Peek());
        }
Beispiel #5
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 #6
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 #7
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 #8
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();
            }
        }