예제 #1
0
        public void UpdateNonMutationAbilityDescription(string category, ActivatedAbilityEntry ability, bool bAddCooldownOnly = false)
        {
            if (!this.Categories.ContainsKey(category))
            {
                Debug.Log("QudUX Mod: Couldn't find any data for activated ability category '" + category + "'. Activated ability description for " + this.SimplifiedAbilityName(ability.DisplayName) + " won't be updated.");
                return;
            }
            List <Egcb_AbilityDataEntry> abilityData = this.Categories[category];
            string deleteLines   = null;
            string deletePhrases = null;

            foreach (Egcb_AbilityDataEntry abilityDataEntry in abilityData)
            {
                if (abilityDataEntry.Name == this.SimplifiedAbilityName(ability.DisplayName))
                {
                    string description = string.Empty;
                    deleteLines   = abilityDataEntry.DeleteLines;
                    deletePhrases = abilityDataEntry.DeletePhrases;
                    if (!string.IsNullOrEmpty(abilityDataEntry.CustomDescription))
                    {
                        description = abilityDataEntry.CustomDescription;
                    }
                    else if (bAddCooldownOnly)
                    {
                        description = this.VanillaDescriptionText.ContainsKey(ability.ID) ? this.VanillaDescriptionText[ability.ID] : ability.Description;
                    }
                    else if (!string.IsNullOrEmpty(abilityDataEntry.SkillName))
                    {
                        if (SkillFactory.Factory.PowersByClass.ContainsKey(abilityDataEntry.SkillName))
                        {
                            PowerEntry skill = SkillFactory.Factory.PowersByClass[abilityDataEntry.SkillName];
                            description = skill.Description;
                        }
                    }
                    description = description.TrimEnd('\r', '\n', ' ');
                    if (!string.IsNullOrEmpty(description))
                    {
                        if (!string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                        {
                            string adjustedCooldownString = this.GetCooldownString(abilityDataEntry.BaseCooldown);
                            if (!string.IsNullOrEmpty(adjustedCooldownString))
                            {
                                description += "\n\n" + adjustedCooldownString;
                            }
                        }
                        if (!this.VanillaDescriptionText.ContainsKey(ability.ID))
                        {
                            this.VanillaDescriptionText.Add(ability.ID, ability.Description);
                        }
                        ability.Description = description;
                    }
                    break;
                }
            }
            if (!this.VanillaDescriptionText.ContainsKey(ability.ID))
            {
                this.VanillaDescriptionText.Add(ability.ID, ability.Description);
            }
            ability.Description = Egcb_AbilityData.SpecialFormatDescription(ability.Description, deleteLines, deletePhrases);
        }
예제 #2
0
        public void CheckEnabled()
        {
            ActivatedAbilities    ObjectsAbilityList = Object.GetPart <ActivatedAbilities>();
            ActivatedAbilityEntry Wrestle            = ObjectsAbilityList.GetAbilityByCommand("wm-WrestleCommand");
            ActivatedAbilityEntry HipThrow           = ObjectsAbilityList.GetAbilityByCommand("wm-HipThrowCommand");
            ActivatedAbilityEntry Suplex             = ObjectsAbilityList.GetAbilityByCommand("wm-SuplexCommand");
            ActivatedAbilityEntry Subdue             = ObjectsAbilityList.GetAbilityByCommand("wm-SubdueCommand");
            ActivatedAbilityEntry RavageLimb         = ObjectsAbilityList.GetAbilityByCommand("wm-RavageLimbCommand");

            if (WrestleCommand != null)
            {
                Wrestle.Enabled = ShouldEnable();
            }
            if (HipThrowCommand != null)
            {
                HipThrow.Enabled = ShouldEnable();
            }
            if (SuplexCommand != null)
            {
                Suplex.Enabled = ShouldEnable();
            }
            if (SubdueCommand != null)
            {
                Subdue.Enabled = ShouldEnable();
            }
            if (RavageLimbCommand != null)
            {
                RavageLimb.Enabled = ShouldEnable();
            }
        }
예제 #3
0
            /// <summary>
            /// Creates an ability description for a non-mutation ability. Generally these are loaded
            /// from a combination of AbilityExtenderData.xml, SkillFactory skill/power descriptions,
            /// or the hard-coded activated ability description when one exists. Cooldown information
            /// is also appended to the description.
            /// </summary>
            public List <string> MakeNonMutationAbilityDescription(string category, ActivatedAbilityEntry ability, bool bAddCooldownOnly = false)
            {
                if (!this.Categories.ContainsKey(category))
                {
                    LogUnique($"(Warning) Activated ability description for '{SimplifiedAbilityName(ability?.DisplayName)}'"
                              + $" won't be updated. (Couldn't find any data for activated ability category '{category}')");
                    return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
                }
                List <AbilityXmlInfo> abilityData = this.Categories[category];

                foreach (AbilityXmlInfo abilityDataEntry in abilityData)
                {
                    if (abilityDataEntry.Name == SimplifiedAbilityName(ability.DisplayName))
                    {
                        string description   = string.Empty;
                        string deleteLines   = abilityDataEntry.DeleteLines;
                        string deletePhrases = abilityDataEntry.DeletePhrases;
                        if (!string.IsNullOrEmpty(abilityDataEntry.CustomDescription))
                        {
                            description = abilityDataEntry.CustomDescription;
                        }
                        else if (bAddCooldownOnly)
                        {
                            description = ability.Description;
                        }
                        else if (!string.IsNullOrEmpty(abilityDataEntry.SkillName))
                        {
                            if (SkillFactory.Factory.PowersByClass.ContainsKey(abilityDataEntry.SkillName))
                            {
                                PowerEntry skill = SkillFactory.Factory.PowersByClass[abilityDataEntry.SkillName];
                                description = skill.Description;
                            }
                        }
                        description = description.TrimEnd('\r', '\n', ' ');
                        if (string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(ability.Description)) //just in case
                        {
                            description = ability.Description;
                            description = description.TrimEnd('\r', '\n', ' ');
                        }
                        if (!string.IsNullOrEmpty(description))
                        {
                            if (!string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                            {
                                if (string.IsNullOrEmpty(abilityDataEntry.NoCooldownReduction) || abilityDataEntry.NoCooldownReduction != "true")
                                {
                                    string baseCooldown   = GetAdjustedBaseCooldown(abilityDataEntry);
                                    string cooldownString = this.GetCooldownString(baseCooldown);
                                    if (!string.IsNullOrEmpty(cooldownString))
                                    {
                                        description += "\n\n" + cooldownString;
                                    }
                                }
                            }
                        }
                        return(SpecialFormatDescription(description, deleteLines, deletePhrases, ability));
                    }
                }
                return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
            }
예제 #4
0
            /// <summary>
            /// Determines what kind of ability this is and whether it needs to be handed off to another
            /// method in order to generate a better ability description.
            /// </summary>
            public List <string> MakeDescription(AbilityNode abilityNode)
            {
                string category = abilityNode?.Ability?.Class;
                ActivatedAbilityEntry ability = abilityNode?.Ability;

                if (ability != null && !string.IsNullOrEmpty(category))
                {
                    try
                    {
                        if (category == "Mental Mutation" || category == "Mutation" || category == "Physical Mutation")
                        {
                            return(this.MakeMutationAbilityDescription(category, ability));
                        }
                        //handle other ability descriptions
                        else
                        {
                            bool hasMeaningfulDescription;
                            if (AbilityNarrator.AbilitiesWithoutRealDescriptions.Contains(ability.ID))
                            {
                                hasMeaningfulDescription = false;
                            }
                            else
                            {
                                string vanillaDescription = ability.Description;
                                string simplifiedName     = SimplifiedAbilityName(ability.DisplayName);
                                hasMeaningfulDescription = !string.IsNullOrEmpty(vanillaDescription) &&
                                                           ability.DisplayName != vanillaDescription &&
                                                           simplifiedName != vanillaDescription &&
                                                           !simplifiedName.StartsWith(vanillaDescription);
                            }
                            if (!hasMeaningfulDescription)
                            {
                                AbilityNarrator.AbilitiesWithoutRealDescriptions.Add(ability.ID);
                                return(this.MakeNonMutationAbilityDescription(category, ability));
                            }
                            else //already has a meaningful description. Append cooldown info to the existing description.
                            {
                                return(this.AddCooldownToPrexistingAbilityDescription(category, ability));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogUnique("(Error) Unable to update ability description for "
                                  + $"ability '{ability?.DisplayName}' [{ability?.Command}].\n  Exception: {ex}");
                    }
                }
                try
                {
                    return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
                }
                catch (Exception ex)
                {
                    LogUnique($"(Warning) Couldn't recognize ability '{ability?.DisplayName}' "
                              + $"[{ability?.Command}], so it's description was not updated.\n  Exception: {ex}");
                }
                return(new List <string>());
            }
예제 #5
0
        public override bool Mutate(GameObject GO, int Level)
        {
            Unmutate(GO);
            ActivatedAbilities part = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            ReadEmotionsActivatedAbilityID = part.AddAbility(DisplayName, "CommandReadEmotions", "Mental Mutation", "#");
            ReadEmotionsActivatedAbility   = part.AbilityByGuid[ReadEmotionsActivatedAbilityID];
            return(true);
        }
        public override bool Mutate(GameObject GO, int Level)
        {
            Unmutate(GO);
            ActivatedAbilities part = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            SWForceChokeActivatedAbilityID = part.AddAbility("Force Choke", "CommandSWForceChoke", "Mental Mutation", "#");
            SWForceChokeActivatedAbility   = part.AbilityByGuid[SWForceChokeActivatedAbilityID];
            return(true);
        }
예제 #7
0
        public override void Register(GameObject Object)
        {
            Object.RegisterPartEvent((IPart)this, "BeforeApplyDamage");
            Object.RegisterPartEvent((IPart)this, "EndTurn");
            ActivatedAbilities part = Object.GetPart("ActivatedAbilities") as ActivatedAbilities;

            this.ChargeCellsActivatedAbilityID = part.AddAbility("Charge Cells", "CommandKoboldChargeCells", "Kobold Power", 0, true, false, "Toggle to consume hunger and charge equipped cells each turn", "~", false, false);
            this.ChargeCellsActivatedAbility   = part.AbilityByGuid[this.ChargeCellsActivatedAbilityID];
            base.Register(Object);
        }
예제 #8
0
 public override bool RemoveSkill(GameObject GO)
 {
     if (ActivatedAbilityID != Guid.Empty)
     {
         ActivatedAbilities activatedAbilities = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;
         activatedAbilities.RemoveAbility(ActivatedAbilityID);
         pActivatedAbility = null;
     }
     return(true);
 }
예제 #9
0
        public override bool FireEvent(Event E)
        {
            if (E.ID == "GetInventoryActions")
            {
                E.GetParameter <EventParameterGetInventoryActions>("Actions").AddAction("Water", 'W', false, "&WW&yater", "CommandWater");
            }
            // else if (E.ID == "OwnerGetInventoryActions")
            // {
            //     GameObject GO = E.GetGameObjectParameter("Object");
            //     if(GO.GetPart<acegiak_Seed>() != null){

            //     }
            //     E.GetParameter<EventParameterGetInventoryActions>("Actions").AddAction("Water", 'W', false, "&WW&yater", "CommandWater", 5);
            // }
            else if (E.ID == "CommandWater")
            {
                // if(ParentObject.Equipped == null){
                //     Popup.Show("You must have a watering can equipped to water.");
                // }
                GameObject who = E.GetGameObjectParameter("Owner");
                if (who == null)
                {
                    who = ParentObject.Equipped;
                }
                if (who == null)
                {
                    who = ParentObject;
                }
                Water(who);
                E.RequestInterfaceExit();
            }
            else
            if (E.ID == "Equipped")
            {
                GameObject         GO   = E.GetGameObjectParameter("EquippingObject");
                ActivatedAbilities part = GO.GetPart <ActivatedAbilities>();
                if (part != null)
                {
                    ActivatedAbilityID = part.AddAbility("Water", "CommandWater", "Gear");
                    ActivatedAbilityEntry activatedAbilityEntry = part.AbilityByGuid[ActivatedAbilityID];
                    GO.RegisterPartEvent(this, "CommandWater");
                }
            }
            else if (E.ID == "Unequipped")
            {
                GameObject         GO   = E.GetGameObjectParameter("UnequippingObject");
                ActivatedAbilities part = GO.GetPart <ActivatedAbilities>();
                if (part != null)
                {
                    part.RemoveAbility(ActivatedAbilityID);
                    GO.UnregisterPartEvent(this, "CommandWater");
                }
            }
            return(base.FireEvent(E));
        }
        public override bool Mutate(GameObject GO, int Level)
        {
            ActivatedAbilities part = GO.GetPart <ActivatedAbilities>();

            if (part != null)
            {
                this.ActivatedAbilityID = part.AddAbility("Evolve", "CommandEvolve", "Physical Mutation", -1, false, false, "Evolve from liquid.", string.Empty + (object)'\x0003', false);
                this.ActivatedAbility   = part.AbilityByGuid[this.ActivatedAbilityID];
            }
            return(base.Mutate(GO, Level));
        }
예제 #11
0
        public override bool AddSkill(GameObject GO)
        {
            ActivatedAbilities activatedAbilities = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            if (activatedAbilities != null)
            {
                ActivatedAbilityID = activatedAbilities.AddAbility("Polearm Lunge [&Wattack&y]", "CommandAcegiakPolearmLunge", "Skill", "You strike out with a polearm to attack a foe two spaces away.", string.Empty + '\u0010');
                pActivatedAbility  = activatedAbilities.AbilityByGuid[ActivatedAbilityID];
            }
            return(true);
        }
예제 #12
0
        public override bool AddSkill(GameObject GO)
        {
            ActivatedAbilities pAA = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            if (pAA != null)
            {
                ActivatedAbilityID = pAA.AddAbility("Repel Attackers", "CommandAcegiakPolearmRepel", "Skill","When attacking with a polearm you push enemies away from you.", ">", null, true,true);
                Ability = pAA.AbilityByGuid[ActivatedAbilityID];
            }

            return true;
        }
예제 #13
0
        public override bool AddSkill(GameObject GO)
        {
            ActivatedAbilities pAA = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            if (pAA != null)
            {
                ActivatedAbilityID = pAA.AddAbility("Double Grip", "CommandAcegiakPolearmGrip", "Skill", "You wield your polearm with two hands for additional damage.", "G", null, true, false);
                Ability            = pAA.AbilityByGuid[ActivatedAbilityID];
            }

            return(true);
        }
예제 #14
0
        public bool AddSkill(GameObject GO)
        {
            ActivatedAbilities pAA = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            if (pAA != null)
            {
                ActivatedAbilityID = pAA.AddAbility("Hit The Gas", "CommandAcegiakGasGasGas", "Maneuvers", -1, "While gassing it you move 2-4 spaces each turn.", "-");
                Ability            = pAA.AbilityByGuid[ActivatedAbilityID];
            }

            return(true);
        }
예제 #15
0
        public override bool Mutate(GameObject GO, int Level)
        {
            this.ParentObject.ApplyEffect((Effect) new Phased(9999));
            ActivatedAbilities part = GO.GetPart("ActivatedAbilities") as ActivatedAbilities;

            if (part != null)
            {
                this.UnphaseActivatedAbilityID = part.AddAbility("Unphase", "CommandUnphase", "Physical Mutation", true, false);
                this.UnphaseActivatedAbility   = part.AbilityByGuid[this.UnphaseActivatedAbilityID];
            }
            this.ChangeLevel(Level);
            return(base.Mutate(GO, Level));
        }
예제 #16
0
 public void TryUpdate(string category, ActivatedAbilityEntry ability)
 {
     if (ability == null || string.IsNullOrEmpty(category))
     {
         return;
     }
     try
     {
         //always update mutation descriptions because they can include changing Level text, etc.
         if (category == "Mental Mutation" || category == "Mutation" || category == "Physical Mutation")
         {
             this.UpdateMutationAbilityDescription(category, ability);
         }
         //handle other ability descriptions
         else
         {
             bool hasMeaningfulDescription;
             if (Egcb_AbilityData.AbilitiesWithoutRealDescriptions.Contains(ability.ID))
             {
                 hasMeaningfulDescription = false;
             }
             else
             {
                 string vanillaDescription = this.VanillaDescriptionText.ContainsKey(ability.ID) ? this.VanillaDescriptionText[ability.ID] : ability.Description;
                 string simplifiedName     = this.SimplifiedAbilityName(ability.DisplayName);
                 hasMeaningfulDescription = !string.IsNullOrEmpty(vanillaDescription) &&
                                            ability.DisplayName != vanillaDescription &&
                                            simplifiedName != vanillaDescription &&
                                            !simplifiedName.StartsWith(vanillaDescription);
             }
             if (!hasMeaningfulDescription)
             {
                 Egcb_AbilityData.AbilitiesWithoutRealDescriptions.Add(ability.ID);
                 this.UpdateNonMutationAbilityDescription(category, ability);
             }
             else //already has a meaningful description. Append cooldown info to the existing description.
             {
                 this.AddCooldownToPrexistingAbilityDescription(category, ability);
             }
         }
     }
     catch (Exception ex)
     {
         string abilityName = ability?.DisplayName;
         string abilityCmd  = ability?.Command;
         string abilityInfo = "'" + (string.IsNullOrEmpty(abilityName) ? "NULL" : abilityName) + "' [" + (string.IsNullOrEmpty(abilityCmd) ? "NULL" : abilityCmd) + "]";
         Debug.Log("QudUX Mod: Unable to update ability description for ability " + abilityInfo + ".\n  Exception: " + ex.ToString());
     }
 }
예제 #17
0
        private static void RenderSingleAbility(ActivatedAbilityEntry activatedAbilityEntry)
        {
            // Pretty much a copy-paste from the disassembled code.
            string value  = "<color=white>";
            string value2 = "yellow";

            if (activatedAbilityEntry.Cooldown > 0)
            {
                value = "<color=grey>";
                Sidebar.SB.Append(value);
                Sidebar.FormatToRTF(activatedAbilityEntry.DisplayName, Sidebar.SB, "FF");
                Sidebar.SB.Append(" [");
                Sidebar.SB.Append((int)Math.Ceiling((double)((float)activatedAbilityEntry.Cooldown / 10f)));
                Sidebar.SB.Append("]");
                value2 = "grey";
            }
            else
            {
                if (!activatedAbilityEntry.Enabled)
                {
                    value  = "<color=grey>";
                    value2 = "grey";
                }
                if (activatedAbilityEntry.Toggleable && !activatedAbilityEntry.ToggleState)
                {
                    value = "<color=red>";
                }
                if (activatedAbilityEntry.Toggleable && activatedAbilityEntry.ToggleState)
                {
                    value = "<color=green>";
                }
                Sidebar.SB.Append(value);
                Sidebar.FormatToRTF(activatedAbilityEntry.DisplayName, Sidebar.SB, "FF");
            }
            Sidebar.SB.Append("</color>");
            if (!string.IsNullOrEmpty(activatedAbilityEntry.Command) && AbilityManager.commandToKey.ContainsKey(activatedAbilityEntry.Command))
            {
                Sidebar.SB.Append(" <<color=");
                Sidebar.SB.Append(value2);
                Sidebar.SB.Append(">");
                Keyboard.MetaToString(AbilityManager.commandToKey[activatedAbilityEntry.Command], Sidebar.SB);
                Sidebar.SB.Append("</color>>");
            }
            Sidebar.SB.Append("    ");
        }
예제 #18
0
 public override bool FireEvent(Event E)
 {
     if (E.ID == "BeginTakeAction")
     {
         CheckConstricted();
         if (Constricted != null && !ParentObject.pBrain.HasGoal("FleeLocation"))
         {
             ParentObject.pBrain.Goals.Clear();
         }
     }
     else if (E.ID == "ObjectEnteredAdjacentCell")
     {
         GameObject gameObjectParameter = E.GetGameObjectParameter("Object");
         if (gameObjectParameter != null && ParentObject.pBrain.IsHostileTowards(gameObjectParameter))
         {
             CheckConstricted();
             if (Constricted == null && !gameObjectParameter.MakeSave("Strength", 20, null, null, "Constrictment"))
             {
                 Constrict(gameObjectParameter, null);
             }
         }
     }
     else if (E.ID == "EnteredCell")
     {
         if (Constricted != null)
         {
             if (ParentObject.CurrentCell != null)
             {
                 if (Constricted.CurrentCell != null && Constricted.CurrentCell != ParentObject.CurrentCell)
                 {
                     Constricted.CurrentCell.RemoveObject(Constricted);
                 }
                 if (!ParentObject.CurrentCell.Objects.Contains(Constricted))
                 {
                     ParentObject.CurrentCell.AddObject(Constricted);
                 }
             }
             Constricted.FireEvent(Event.New("ConstrictDragged", "Object", ParentObject));
             ParentObject.FireEvent(Event.New("ConstricterDragged", "Object", Constricted));
         }
         CheckConstricted();
     }
     else if (E.ID == "BeginBeingTaken")
     {
         EndAllConstriction();
     }
     else if (E.ID == "AIGetOffensiveMutationList")
     {
         CheckConstricted();
         if (Constricted == null)
         {
             int intParameter = E.GetIntParameter("Distance");
             ActivatedAbilityEntry ActivatedAbility = MyActivatedAbility(ActivatedAbilitiesID);
             if (ActivatedAbility != null && ActivatedAbility.Cooldown <= 0 && intParameter <= 1)
             {
                 GameObject gameObjectParameter2 = E.GetGameObjectParameter("Target");
                 if (gameObjectParameter2.PhaseAndFlightMatches(ParentObject))
                 {
                     List <AICommandList> list = E.GetParameter("List") as List <AICommandList>;
                     list.Add(new AICommandList("CommandConstrict", 1));
                 }
             }
         }
     }
     // Allows both player and AI to direction a cell to activate the mutation on
     else if (E.ID == "CommandConstrict")
     {
         // AddPlayerMessage("Phase: check frozen");
         if (!ParentObject.CheckFrozen())
         {
             return(true);
         }
         CheckConstricted();
         Cell cell = base.PickDirection(null);
         // AddPlayerMessage("Phase: CooldownSet");
         if (cell != null)
         {
             CooldownMyActivatedAbility(ActivatedAbilitiesID, 15);
         }
         {
             GameObject combatTarget = cell.GetCombatTarget(ParentObject, false, false, false, null, true, true, false, null);
             // AddPlayerMessage("Phase: Combat target grabbed");
             if (combatTarget != null && combatTarget != ParentObject)
             {
                 if (Constricted != null)
                 {
                     // AddPlayerMessage("Phase: end constrict");
                     EndConstriction(Constricted, null, null);
                 }
                 // AddPlayerMessage("Phase: start constrict");
                 Constrict(combatTarget, null);
             }
         }
     }
     return(base.FireEvent(E));
 }
예제 #19
0
 public void AddCooldownToPrexistingAbilityDescription(string category, ActivatedAbilityEntry ability)
 {
     this.UpdateNonMutationAbilityDescription(category, ability, true);
 }
예제 #20
0
            /// <summary>
            /// Converts a description string into a list of lines that can be written to the Console
            /// UI. Also does a few special things:
            ///  * Adds a vertical line (|) to the beginning of each line, which connects to form a
            ///    visual separator between the ability list and the descriptions written to the screen
            ///  * Deletes lines or phrases that were manually marked in AbilityExtenderData.xml for
            ///    deletion (typically because they either aren't relevant to the activated ability,
            ///    or because the description would otherwise be too long to fit on screen)
            /// </summary>
            public static List <string> SpecialFormatDescription(string description, string lineDeletionClues = null, string phraseDeletionClues = null, ActivatedAbilityEntry SourceAbility = null)
            {
                if (string.IsNullOrEmpty(description))
                {
                    if (SourceAbility != null)
                    {
                        LogUnique($"(FYI) Could not find a description for activated ability '{SimplifiedAbilityName(SourceAbility.DisplayName)}'."
                                  + " A description won't be shown on the Manage Abilities screen.");
                    }
                    return(new List <string>());
                }
                if (!string.IsNullOrEmpty(lineDeletionClues) || !string.IsNullOrEmpty(phraseDeletionClues) || description.Contains(" reputation "))
                {
                    string cleansedDescription = string.Empty;
                    foreach (string _line in description.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
                    {
                        string line             = _line;
                        bool   shouldDeleteLine = false;
                        //remove any custom lines from the description that were configured in AbilityExtenderData.xml
                        if (!string.IsNullOrEmpty(lineDeletionClues))
                        {
                            foreach (string deletionClue in lineDeletionClues.Split('~'))
                            {
                                if (line.StartsWith(deletionClue))
                                {
                                    shouldDeleteLine = true;
                                    break;
                                }
                            }
                        }
                        //remove any custom phrases from the description that were configured in AbilityExtenderData.xml
                        if (!string.IsNullOrEmpty(phraseDeletionClues))
                        {
                            foreach (string deletionClue in phraseDeletionClues.Split('~'))
                            {
                                if (line.Contains(deletionClue))
                                {
                                    line = line.Replace(deletionClue, "");
                                }
                            }
                        }
                        //remove reputation lines, because they aren't relevant to activated ability descriptions
                        if (!shouldDeleteLine && line.Contains(" reputation "))
                        {
                            if (line[0] == '+' || line[0] == '-')
                            {
                                string[] words = line.Split(' ');
                                if (words.Length >= 2 && words[1] == "reputation")
                                {
                                    shouldDeleteLine = true;
                                }
                            }
                        }
                        if (shouldDeleteLine == false)
                        {
                            cleansedDescription += (string.IsNullOrEmpty(cleansedDescription) ? "" : "\n") + line;
                        }
                    }
                    description = cleansedDescription;
                }

                List <string> descriptionLines = StringFormat.ClipTextToArray(description, MaxWidth: 32, KeepNewlines: true);

                if (descriptionLines.Count > 22)
                {
                    LogUnique($"(Warning) Part of the activated ability description for '{SimplifiedAbilityName(SourceAbility?.DisplayName)}'"
                              + " was discarded because it didn't fit on the Manage Abilities screen.");
                    descriptionLines = descriptionLines.GetRange(0, 22);
                }
                bool foundTextEnd = false;

                for (int i = descriptionLines.Count - 1; i >= 0; i--)
                {
                    if (!foundTextEnd) //get rid of any blank lines at the end
                    {
                        if (ColorUtility.StripFormatting(descriptionLines[i]).Trim().Length < 1)
                        {
                            descriptionLines.RemoveAt(i);
                            continue;
                        }
                        else
                        {
                            foundTextEnd = true;
                        }
                    }
                    descriptionLines[i] = "{{K|\u00b3}}" + descriptionLines[i];
                    int length    = ColorUtility.StripFormatting(descriptionLines[i]).Length;
                    int padNeeded = 34 - length;
                    if (padNeeded > 0)
                    {
                        descriptionLines[i] = descriptionLines[i] + "{{y|" + string.Empty.PadRight(padNeeded) + "}}";
                    }
                }
                return(descriptionLines);
            }
예제 #21
0
            /// <summary>
            /// Creates an ability description for a mutation. The description is constructed from the
            /// mutation description and the GetLevelText() for the mutation at its current level.
            /// Cooldown information is also appended to the description.
            /// </summary>
            /// TODO: Determine if the Level logic has changed with the new chimera rapid advancements.
            ///       For example, will level return 6 if that's my actual level, or will it return
            ///       5 if my mutation level is restricted based on my character level?
            public List <string> MakeMutationAbilityDescription(string category, ActivatedAbilityEntry ability)
            {
                if (!this.Categories.ContainsKey(category))
                {
                    LogUnique($"(FYI) Activated ability description for '{SimplifiedAbilityName(ability?.DisplayName)}'"
                              + $" won't be updated because QudUX didn't recognize it's activated ability category, '{category}'");
                    return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
                }
                List <AbilityXmlInfo> abilityData = this.Categories[category];

                foreach (AbilityXmlInfo abilityDataEntry in abilityData)
                {
                    if (abilityDataEntry.Name == SimplifiedAbilityName(ability.DisplayName))
                    {
                        //match AbilityDataEntry to the Ability name
                        BaseMutation abilitySourceMutation = null;
                        BaseMutation secondaryMatch        = null;
                        foreach (BaseMutation playerMutation in this.PlayerMutations)
                        {
                            MutationEntry mutationEntry = playerMutation.GetMutationEntry();
                            if (mutationEntry != null && mutationEntry.DisplayName == abilityDataEntry.MutationName)
                            {
                                abilitySourceMutation = playerMutation;
                                break;
                            }
                            if (playerMutation.DisplayName == abilityDataEntry.MutationName)
                            {
                                secondaryMatch = playerMutation; //less desirable match method, but necessary for some NPC mutations that don't have a MutationEntry
                            }
                        }
                        if (abilitySourceMutation == null && secondaryMatch != null)
                        {
                            abilitySourceMutation = secondaryMatch;
                        }
                        if (abilitySourceMutation == null)
                        {
                            LogUnique($"(FYI) Mutation activated ability '{SimplifiedAbilityName(ability?.DisplayName)}'"
                                      + $" in category '{category}' has no description available in game and no backup description"
                                      + " provided by QudUX, so a description won't be shown on the Manage Abilities screen.");
                            break;
                        }

                        string abilityDescription = abilitySourceMutation.GetDescription() + "\n\n" + abilitySourceMutation.GetLevelText(abilitySourceMutation.Level);
                        abilityDescription = abilityDescription.TrimEnd('\r', '\n', ' ');
                        //updated Cooldown based on wisdom:
                        if (abilityDescription.Contains("Cooldown:") || !string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                        {
                            if (string.IsNullOrEmpty(abilityDataEntry.NoCooldownReduction) || abilityDataEntry.NoCooldownReduction != "true")
                            {
                                string   updatedDescription      = string.Empty;
                                string   extractedCooldownString = GetAdjustedBaseCooldown(abilityDataEntry);
                                string[] descriptionParts        = abilityDescription.Split('\n');
                                foreach (string descriptionPart in descriptionParts)
                                {
                                    if (descriptionPart.Contains("Cooldown:"))
                                    {
                                        string[] words = descriptionPart.Split(' ');
                                        foreach (string word in words)
                                        {
                                            int o;
                                            if (int.TryParse(word, out o))
                                            {
                                                extractedCooldownString = this.GetCooldownString(word);
                                                break;
                                            }
                                        }
                                        if (string.IsNullOrEmpty(extractedCooldownString))
                                        {
                                            updatedDescription += (updatedDescription != string.Empty ? "\n" : string.Empty) + descriptionPart; //restore line in case we didn't find the number (should never happen)
                                        }
                                    }
                                    else
                                    {
                                        updatedDescription += (updatedDescription != string.Empty ? "\n" : string.Empty) + descriptionPart;
                                    }
                                }
                                abilityDescription = updatedDescription + (!string.IsNullOrEmpty(extractedCooldownString) ? "\n\n" + extractedCooldownString : string.Empty);
                            }
                        }
                        return(SpecialFormatDescription(abilityDescription, abilityDataEntry.DeleteLines, abilityDataEntry.DeletePhrases, ability));
                    }
                }
                return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
            }
예제 #22
0
        public void UpdateMutationAbilityDescription(string category, ActivatedAbilityEntry ability)
        {
            if (!this.Categories.ContainsKey(category))
            {
                Debug.Log("QudUX Mod: Couldn't find any data for activated ability category '" + category + "'. Activated ability description for " + this.SimplifiedAbilityName(ability.DisplayName) + " won't be updated.");
                return;
            }
            List <Egcb_AbilityDataEntry> abilityData = this.Categories[category];

            foreach (Egcb_AbilityDataEntry abilityDataEntry in abilityData)
            {
                if (abilityDataEntry.Name == this.SimplifiedAbilityName(ability.DisplayName))
                {
                    //match AbilityDataEntry to the Ability name
                    BaseMutation abilitySourceMutation = null;
                    BaseMutation secondaryMatch        = null;
                    foreach (BaseMutation playerMutation in this.PlayerMutations)
                    {
                        MutationEntry mutationEntry = playerMutation.GetMutationEntry();
                        if (mutationEntry != null && mutationEntry.DisplayName == abilityDataEntry.MutationName)
                        {
                            abilitySourceMutation = playerMutation;
                            break;
                        }
                        if (playerMutation.DisplayName == abilityDataEntry.MutationName)
                        {
                            secondaryMatch = playerMutation; //less desirable match method, but necessary for some NPC mutations that don't have a MutationEntry
                        }
                    }
                    if (abilitySourceMutation == null && secondaryMatch != null)
                    {
                        abilitySourceMutation = secondaryMatch;
                    }
                    if (abilitySourceMutation == null)
                    {
                        Debug.Log("QudUX Mod: Unexpectedly failed to load mutation description data for '" + this.SimplifiedAbilityName(ability.DisplayName) + "' activated ability.");
                        continue;
                    }
                    if (!this.VanillaDescriptionText.ContainsKey(ability.ID))
                    {
                        this.VanillaDescriptionText.Add(ability.ID, ability.Description);
                    }
                    ability.Description = abilitySourceMutation.GetDescription() + "\n\n" + abilitySourceMutation.GetLevelText(abilitySourceMutation.Level);
                    ability.Description = ability.Description.TrimEnd('\r', '\n', ' ');
                    //updated Cooldown based on wisdom:
                    if (ability.Description.Contains("Cooldown:") || !string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                    {
                        string   updatedDescription      = string.Empty;
                        string   extractedCooldownString = !string.IsNullOrEmpty(abilityDataEntry.BaseCooldown) ? this.GetCooldownString(abilityDataEntry.BaseCooldown) : string.Empty;
                        string[] descriptionParts        = ability.Description.Split('\n');
                        foreach (string descriptionPart in descriptionParts)
                        {
                            if (descriptionPart.Contains("Cooldown:"))
                            {
                                string[] words = descriptionPart.Split(' ');
                                foreach (string word in words)
                                {
                                    int o;
                                    if (int.TryParse(word, out o))
                                    {
                                        extractedCooldownString = this.GetCooldownString(word);
                                        break;
                                    }
                                }
                                if (string.IsNullOrEmpty(extractedCooldownString))
                                {
                                    updatedDescription += (updatedDescription != string.Empty ? "\n" : string.Empty) + descriptionPart; //restore line in case we didn't find the number (should never happen)
                                }
                            }
                            else
                            {
                                updatedDescription += (updatedDescription != string.Empty ? "\n" : string.Empty) + descriptionPart;
                            }
                        }
                        ability.Description = updatedDescription + (!string.IsNullOrEmpty(extractedCooldownString) ? "\n\n" + extractedCooldownString : string.Empty);
                    }
                    ability.Description = Egcb_AbilityData.SpecialFormatDescription(ability.Description, abilityDataEntry.DeleteLines, abilityDataEntry.DeletePhrases);
                    break;
                }
            }
        }
예제 #23
0
 /// <summary>
 /// Called if an ability already has a description defined in game - this will generally
 /// only add cooldown information to that existing description (unless we've explicitly
 /// defined a CustomDescription override for this ability in AbilityExtenderData.xml
 /// </summary>
 public List <string> AddCooldownToPrexistingAbilityDescription(string category, ActivatedAbilityEntry ability)
 {
     return(this.MakeNonMutationAbilityDescription(category, ability, true));
 }