Пример #1
0
        AbilityAffinityType CheckAbilityAffinity(HabProperties hpsAbility, string name, string hotkey, string buttonPos)
        {
            object abilityName;

            if (hpsAbility.TryGetValue("Name", out abilityName) && string.Equals(abilityName as string, name, StringComparison.OrdinalIgnoreCase))
            {
                // used when one ability can be replaced with another same looking ability
                // which leads to invalid hotkeys for that ability (example: Carrion Swarm)
                if ((hpsAbility.GetStringValue("Hotkey") == hotkey) &&
                    (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
                {
                    return(AbilityAffinityType.Clone);
                }
                else
                {
                    // used when hero has multiple abilities with the same name,
                    // which are added by triggers (example: Shadowraze)
                    // NOTE: must be later checked for user-defined hotkey existance to make sure
                    return(AbilityAffinityType.Variation);
                }
            }
            else
            {
                return(AbilityAffinityType.None);
            }
        }
Пример #2
0
        internal string GetAbilityClones(HabProperties hpsOriginalAbility, string hotkey)
        {
            string name      = hpsOriginalAbility.GetStringValue("Name");
            string art       = hpsOriginalAbility.GetStringValue("Art");
            string orgHotkey = hpsOriginalAbility.GetStringValue("Hotkey");
            string buttonPos = hpsOriginalAbility.GetStringValue("Buttonpos");

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
            {
                if ((hpsAbility.GetStringValue("Name") == name) &&
                    (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name)) &&
                    (hpsAbility.GetStringValue("Hotkey") == orgHotkey) &&
                    (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }
            }

            return(output);
        }
Пример #3
0
        // used when hero has multiple abilities with the same name,
        // which are added by triggers (example: Shadowraze)
        internal string GetAbilityVariations(HabProperties hpsOriginalAbility)
        {
            string name = hpsOriginalAbility.GetStringValue("Name");
            string art  = hpsOriginalAbility.GetStringValue("Art");
            string hotkey;

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
            {
                if ((hpsAbility.GetStringValue("Name") == name) &&
                    (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name)) &&
                    (hpsOriginalAbility.name != hpsAbility.name) &&
                    dcAbilitiesHotkeys.TryGetValue(hpsAbility.name, out hotkey))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }
            }

            return(output);
        }
Пример #4
0
        internal Dictionary <string, List <KeyValuePair <string, AbilityAffinityType> > > CollectAffinedAbilities()
        {
            SplashScreen splashScreen = new SplashScreen();

            splashScreen.Show();
            splashScreen.ShowText("Collecting affined abilities...");

            int progressCounter = 0;
            Dictionary <string, List <KeyValuePair <string, AbilityAffinityType> > > result = new Dictionary <string, List <KeyValuePair <string, AbilityAffinityType> > >((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase);

            foreach (string heroID in DHLOOKUP.dcHeroesTaverns.Keys)
            {
                HabProperties hpsHeroAbilities = DHLOOKUP.hpcUnitAbilities[heroID];

                List <string> abilList = hpsHeroAbilities.GetStringListValue("heroAbilList");
                foreach (string abilID in abilList)
                {
                    if (!result.ContainsKey(abilID))
                    {
                        HabProperties hpsAbilityProfile = DHLOOKUP.hpcAbilityProfiles[abilID];

                        string name   = hpsAbilityProfile.GetStringValue("Name");
                        string hotkey = hpsAbilityProfile.GetStringValue("Hotkey");
                        if (hotkey == "")
                        {
                            hotkey = hpsAbilityProfile.GetStringValue("Researchhotkey").Trim('"');
                        }
                        string buttonPos = hpsAbilityProfile.GetStringValue("Buttonpos");

                        List <KeyValuePair <string, AbilityAffinityType> > affinedAbilities = new List <KeyValuePair <string, AbilityAffinityType> >();
                        foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                        {
                            if (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                            {
                                AbilityAffinityType affinityType = CheckAbilityAffinity(hpsAbility, name, hotkey, buttonPos);

                                if (affinityType != AbilityAffinityType.None)
                                {
                                    affinedAbilities.Add(new KeyValuePair <string, AbilityAffinityType>(hpsAbility.name, affinityType));
                                }
                            }
                        }

                        // save affined abilities for current ability
                        result.Add(abilID, affinedAbilities);
                    }
                }

                splashScreen.ShowProgress((double)progressCounter++, (double)DHLOOKUP.dcHeroesTaverns.Keys.Count);
            }

            splashScreen.Close();

            return(result);
        }
Пример #5
0
        internal List <HabProperties> FindSameLookingComplexItem(HabProperties hpsItem)
        {
            if (sameLookingComplexItems == null)
            {
                sameLookingComplexItems = new Dictionary <string, List <HabProperties> >(ComplexItems.Count);
            }

            string itemArt = hpsItem.GetStringValue("art");

            List <HabProperties> hpsList;

            if (sameLookingComplexItems.TryGetValue(itemArt, out hpsList))
            {
                return(hpsList);
            }
            else
            {
                hpsList = new List <HabProperties>();
            }

            foreach (string codeID in ComplexItems.Keys)
            {
                HabProperties hpsCItem = DHLOOKUP.hpcItemProfiles[codeID];
                if (hpsCItem != null && hpsCItem.GetStringValue("art") == itemArt &&
                    IsItemNameSimilar(hpsItem, hpsCItem))
                {
                    hpsList.Add(hpsCItem);
                }
            }

            sameLookingComplexItems.Add(itemArt, hpsList);

            return(hpsList);
        }
Пример #6
0
        internal unit SellHero(HabProperties hps)
        {
            if (hps == null)
            {
                return(null);
            }

            string ID   = hps.GetStringValue("Name");
            unit   hero = Heroes.GetByUnit("ID", ID) as unit;

            if (hero != null && hero.IsDisposed)
            {
                if (Current.unit != null && Current.unit != hero &&
                    Current.unit.codeID == hero.codeID &&
                    !Current.unit.IsDisposed)
                {
                    Heroes.Remove(hero);
                    Heroes.Add(Current.unit);
                    hero = Current.unit;
                }
                else
                {
                    Heroes.Remove(hero);
                    hero = null;
                }
            }

            if (hero == null)
            {
                unit sellingTavern = null;

                // find the tavern that sold this hero

                string tavernID = DHLOOKUP.dcHeroesTaverns[hps.name];
                foreach (unit tavern in DHLOOKUP.taverns)
                {
                    if (tavern.ID == tavernID)
                    {
                        sellingTavern = tavern;
                    }
                }

                // create new hero

                hero          = new unit(hps.name);
                hero.DoSummon = true;
                hero.set_owningPlayer(Current.player, sellingTavern.x, sellingTavern.y);
                Heroes.Add(hero);

                // only new heroes process onsell event

                sellingTavern.OnSell(hero);

                // pay the gold for this hero

                Current.player.Gold = Current.player.Gold - hero.goldCost;
            }

            return(hero);
        }
Пример #7
0
        internal void InitList(List <unit> shops)
        {
            this.Width = this.width + 4;

            itemsLV.BeginUpdate();

            // init list

            itemsLV.Items.Clear();
            itemsLV.Groups.Clear();

            foreach (unit s in shops)
            {
                ListViewGroup Group = new ListViewGroup(s.codeID, s.ID);
                Group.Tag = s;

                itemsLV.Groups.Add(Group);

                DBSTRINGCOLLECTION      itemList;
                HabPropertiesCollection hpcItemProfiles;

                if (DHHELPER.IsNewVersionItemShop(s))
                {
                    itemList        = s.sellunits;
                    hpcItemProfiles = DHLOOKUP.hpcUnitProfiles;
                }
                else
                {
                    itemList        = s.sellitems;
                    hpcItemProfiles = DHLOOKUP.hpcItemProfiles;
                }


                foreach (string itemID in itemList)
                {
                    HabProperties hpsItem = hpcItemProfiles[itemID];

                    string iconName = hpsItem.GetStringValue("Art");
                    if (String.IsNullOrEmpty(iconName))
                    {
                        continue;
                    }

                    ListViewItem lvi_Item = new ListViewItem();

                    lvi_Item.ImageKey = iconName;
                    lvi_Item.Tag      = hpsItem;
                    lvi_Item.Group    = Group;

                    itemsLV.Items.Add(lvi_Item);
                }
            }

            itemsLV.EndUpdate();

            DisplayCaption();
        }
Пример #8
0
        internal void PickNewHero(string heroID)
        {
            HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[heroID];

            Heroes.RemoveByUnit("ID", hpsHero.GetStringValue("Name"));

            unit hero = SellHero(hpsHero);

            mainOwner.cbForm.manual_summon(hero);
        }
Пример #9
0
        private void load_hero_build(HabProperties hpsHero)
        {
            // set level
            Current.unit.Level = hpsHero.GetIntValue("Level");

            // set stats
            Current.unit.set_naked_attr(PrimAttrType.Str, hpsHero.GetIntValue("Str"));
            Current.unit.set_naked_attr(PrimAttrType.Agi, hpsHero.GetIntValue("Agi"));
            Current.unit.set_naked_attr(PrimAttrType.Int, hpsHero.GetIntValue("Int"));

            // get aquisition order
            HabPropertiesCollection hpcAcquisition = hpsHero.GetHpcValue("acquisition");

            // items
            List <string> items = hpsHero.GetStringListValue("items");

            // abilities
            List <string> abilities = hpsHero.GetStringListValue("abilities");

            // process acquisition order

            // make sure triggers will not screw things up
            Current.unit.Inventory.DisableMessages();

            for (int i = 0; i < hpcAcquisition.Count; i++)
            {
                HabProperties hpsAcquired = hpcAcquisition[i + ""];

                string codeID = hpsAcquired.GetStringValue("codeID");

                if (items.Contains(codeID))
                {
                    Current.unit.Inventory.put_item(new item(codeID), hpsAcquired.GetIntValue("slot"));
                }
                else
                if (abilities.Contains(codeID))
                {
                    DBABILITY ability = Current.unit.heroAbilities.GetByAlias(codeID);

                    int level = hpsAcquired.GetIntValue("level");
                    for (int j = 1; j <= level; j++)
                    {
                        ability.Level = j;
                    }
                }
            }

            // restore original state
            Current.unit.Inventory.EnableMessages();

            UpdateHeroLeveling();
        }
Пример #10
0
        private void heroTagGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[heroes[e.RowIndex]];

            switch (e.ColumnIndex)
            {
            case 0:     // image
                e.Value = DHRC.GetImage(hpsHero.GetStringValue("Art"));
                break;

            case 1:     // tag
                e.Value = hpsHeroTags.GetStringValue(hpsHero.name).Split(';')[0];
                break;

            case 2:     // name
                int length = hpsHeroTags.GetStringValue(hpsHero.name).Split(';').Length;
                if (length < 2)
                {
                    e.Value = hpsHero.GetStringValue("Propernames").Split(',')[0];
                }
                else
                {
                    e.Value = hpsHeroTags.GetStringValue(hpsHero.name).Split(';')[1];
                }
                break;

            case 3:     // 2nd name
                int len = hpsHeroTags.GetStringValue(hpsHero.name).Split(';').Length;
                if (len < 3)
                {
                    e.Value = hpsHero.GetStringValue("Name").Trim('"');
                }
                else
                {
                    e.Value = hpsHeroTags.GetStringValue(hpsHero.name).Split(';')[2];
                }
                break;
            }
        }
Пример #11
0
            internal UPGRADEPROFILE(DBUPGRADE u)
            {
                owner = u;

                hpsInitialData = DHMpqDatabase.UpgradeSlkDatabase["Profile"][u.codeID];

                ////////////////////////
                //  get codeID
                ////////////////////////

                this.m_codeID = hpsInitialData.name;

                ////////////////////////
                //  get name
                ////////////////////////

                this.name = hpsInitialData.GetStringListValue("Name");

                ////////////////////////
                //  get tip
                ////////////////////////

                tip = hpsInitialData.GetStringListValue("Tip");

                ////////////////////////
                //  get ubertip
                ////////////////////////

                ubertip = hpsInitialData.GetStringListValue("Ubertip");

                ////////////////////////
                //  get hotkey
                ////////////////////////

                this.hotkey = hpsInitialData.GetStringValue("Hotkey");

                ////////////////////////
                //  get slot priority
                ////////////////////////

                List <string> buttonpos = hpsInitialData.GetStringListValue("Buttonpos");

                slotPriority = RecordSlotComparer.get_slot(Convert.ToInt32(buttonpos[0]), Convert.ToInt32(buttonpos[1]));

                ////////////////////////
                //  get art
                ////////////////////////

                this.art = hpsInitialData.GetStringListValue("Art");
            }
Пример #12
0
        internal void LoadHeroBuild(string filename)
        {
            HabPropertiesCollection hpcBuild = new HabPropertiesCollection();

            hpcBuild.ReadFromFile(filename);

            try
            {
                HabProperties hpsHero = hpcBuild.GetByOrder(0);

                // load specified map if current map is empty
                if (Current.map == null)
                {
                    string mapfile = hpsHero.GetStringValue("Map");
                    if (File.Exists(mapfile))
                    {
                        LoadMap(mapfile);
                    }
                    else
                    {
                        MessageBox.Show(
                            "The map file '" + mapfile + "' specified in this hero build cannot be found." +
                            "\nYou can open this map manually (DotA map->Open...) and then try to load this hero build again");
                        return;
                    }
                }

                // pick specified hero
                hlForm.PickNewHero(hpsHero.name);

                if (!Current.unit.IsDisposed)
                {
                    load_hero_build(hpsHero);
                }
                else
                {
                    // delay this build until the hero
                    // will be found by hero provider
                    hpsProvidedHeroBuild = hpsHero;
                }

                UpdateRecentBuild(filename);
            }
            catch
            {
                MessageBox.Show("Invalid Hero Build file");
                return;
            }
        }
Пример #13
0
        private void heroesGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex >= heroes.Count)
            {
                return;
            }

            unit hero = heroes[e.RowIndex];

            if (hero.codeID == "AnyHero")
            {
                switch (e.ColumnIndex)
                {
                case 0:     // image
                    e.Value = null;
                    break;

                case 1:     // hero name
                    e.Value = "Any Hero (Nickname-only search)";
                    break;

                case 2:     // player
                    e.Value = hero.name;
                    break;
                }
            }
            else
            {
                HabProperties hpsHero = DHLOOKUP.hpcUnitProfiles[hero.codeID];
                switch (e.ColumnIndex)
                {
                case 0:     // image
                    e.Value = DHRC.GetImage(hpsHero.GetStringValue("Art"));
                    break;

                case 1:     // hero name
                    e.Value = hero.ID;
                    break;

                case 2:     // player
                    string nick;
                    heroNicksCache.TryGetValue(hero.codeID, out nick);
                    e.Value = nick + "";
                    break;
                }
            }
        }
Пример #14
0
        internal bool IsItemNameSimilar(HabProperties hpsItemA, HabProperties hpsItemB)
        {
            string[] name_partsA = hpsItemA.GetStringValue("Name").Split(' ');
            string[] name_partsB = hpsItemB.GetStringValue("Name").Split(' ');

            int matches = 0;

            for (int i = 0; i < name_partsA.Length; i++)
            {
                for (int j = 0; j < name_partsB.Length; j++)
                {
                    if (name_partsA[i] == name_partsB[j])
                    {
                        matches++;
                    }
                }
            }

            return(matches > 0);
        }
Пример #15
0
            internal DBUPGRADE(HabProperties hps)
            {
                hpsInitialData = hps.GetCopy();

                ////////////////////////
                //  get alias
                ////////////////////////

                this.name = hps.name;

                ////////////////////////
                //  get max level
                ////////////////////////

                this.max_level = hpsInitialData.GetIntValue("maxlevel");

                ////////////////////////
                //  get effects
                ////////////////////////

                effects = new List <DBEFFECT>(4);

                string effectID;

                for (int i = 1; i <= 4; i++)
                {
                    if ((effectID = hps.GetStringValue("effect" + i)) != "_")
                    {
                        DBEFFECT e = DBEFFECT.InitProperEffect(effectID,
                                                               hps.GetDoubleValue("base" + i),
                                                               hps.GetDoubleValue("mod" + i));

                        if (e != null)
                        {
                            effects.Add(e);
                        }
                    }
                }
            }
Пример #16
0
        private void creepsCmbB_SelectedIndexChanged(object sender, EventArgs e)
        {
            HabProperties hpsProfile = (sender as ComboBox).SelectedItem as HabProperties;

            if (hpsProfile != null)
            {
                creepArtPanel.BackgroundImage = DHRC.GetImage(hpsProfile.GetStringValue("Art"));

                HabProperties hpsBalance = hpcBalance[hpsProfile.name];

                int dice  = hpsBalance.GetIntValue("bountydice");
                int sides = hpsBalance.GetIntValue("bountysides");
                int plus  = hpsBalance.GetIntValue("bountyplus");

                creepGoldTextBox.Text  = "" + (dice + plus) + " - " + (dice * sides + plus);
                creepLevelTextBox.Text = hpsBalance.GetStringValue("level");
            }
            else
            {
                creepArtPanel.BackgroundImage = null;
                creepGoldTextBox.Text         = "";
                creepLevelTextBox.Text        = "";
            }
        }
Пример #17
0
        internal void SaveCustomKeys(string filename)
        {
            FileStream file = File.Create(filename);

            using (StreamWriter sr = new StreamWriter(file))
            {
                if (saveCommandHotkeysCB.Checked)
                {
                    sr.WriteLine("////////////");
                    sr.WriteLine("// Command Hotkeys");
                    sr.WriteLine("////////////");

                    sr.WriteLine("[CmdMove]");
                    sr.WriteLine("Tip=Move (|cffffcc00" + moveTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + moveTextBox.Tag + "");
                    sr.WriteLine("");

                    sr.WriteLine("[CmdStop]");
                    sr.WriteLine("Tip=Stop (|cffffcc00" + stopTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + stopTextBox.Tag + "");
                    sr.WriteLine("");

                    sr.WriteLine("[CmdHoldPos]");
                    sr.WriteLine("Tip=Hold Position (|cffffcc00" + holdTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + holdTextBox.Tag + "");
                    sr.WriteLine("");

                    sr.WriteLine("[CmdAttack]");
                    sr.WriteLine("Tip=Attack (|cffffcc00" + attackTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + attackTextBox.Tag + "");
                    sr.WriteLine("");

                    sr.WriteLine("[CmdPatrol]");
                    sr.WriteLine("Tip=Patrol (|cffffcc00" + patrolTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + patrolTextBox.Tag + "");
                    sr.WriteLine("");

                    sr.WriteLine("[CmdSelectSkill]");
                    sr.WriteLine("Tip=Hero Abilities (|cffffcc00" + selectSkillTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + selectSkillTextBox.Tag + "");
                    sr.WriteLine("");

                    sr.WriteLine("[CmdCancel]");
                    sr.WriteLine("Tip=Cancel (|cffffcc00" + cancelTextBox.Text + "|r)");
                    sr.WriteLine("Hotkey=" + cancelTextBox.Tag + "");
                    sr.WriteLine("");
                }

                foreach (string heroID in DHLOOKUP.dcHeroesTaverns.Keys)
                {
                    HabProperties hpsHeroProfile   = DHLOOKUP.hpcUnitProfiles[heroID];
                    HabProperties hpsHeroAbilities = DHLOOKUP.hpcUnitAbilities[heroID];
                    List <string> abilList         = hpsHeroAbilities.GetStringListValue("heroAbilList");

                    string output = "";
                    string name;
                    string hotkey;
                    foreach (string abilID in abilList)
                    {
                        name = DHLOOKUP.hpcAbilityProfiles.GetStringValue(abilID, "Name").Trim('"');

                        List <KeyValuePair <string, AbilityAffinityType> > affinedAbilities = dcAffinedAbilites[abilID];

                        // get user-defined hotkey for that ability
                        if (!dcAbilitiesHotkeys.TryGetValue(abilID, out hotkey))
                        {
                            // if hotkey was not found, check clones of that ability
                            foreach (KeyValuePair <string, AbilityAffinityType> kvp in affinedAbilities)
                            {
                                if (kvp.Value == AbilityAffinityType.Clone && dcAbilitiesHotkeys.TryGetValue(kvp.Key, out hotkey))
                                {
                                    break;
                                }
                            }
                        }

                        // if user-defined hotkey for this ability exists
                        if (hotkey != null)
                        {
                            // write hotkey for this ability
                            output += GetCustomKeyStringForAbility(abilID, name, hotkey);

                            // now check ability clones and write same hotkey for them
                            foreach (KeyValuePair <string, AbilityAffinityType> kvp in affinedAbilities)
                            {
                                if (kvp.Value == AbilityAffinityType.Clone)
                                {
                                    output += GetCustomKeyStringForAbility(kvp.Key, name, hotkey);
                                }
                            }
                        }

                        // check for ability variations and write their own user-defined hotkey
                        foreach (KeyValuePair <string, AbilityAffinityType> kvp in affinedAbilities)
                        {
                            if (kvp.Value == AbilityAffinityType.Variation)
                            {
                                if (dcAbilitiesHotkeys.TryGetValue(kvp.Key, out hotkey))
                                {
                                    output += GetCustomKeyStringForAbility(kvp.Key, name, hotkey);
                                }
                            }
                        }
                    }

                    /*if (dcAbilitiesHotkeys.TryGetValue(abilID, out hotkey))
                     * {
                     *  HabProperties hpsAbilityProfile = DHLOOKUP.hpcAbilityProfiles[abilID];
                     *
                     *  output += "\r\n// " + hpsAbilityProfile.GetStringValue("Name").Trim('"');
                     *  output += "\r\n[" + abilID + "]";
                     *  output += "\r\nHotkey=" + hotkey;
                     *  output += "\r\nResearchhotkey=" + hotkey;
                     *  output += "\r\nUnhotkey=" + hotkey;
                     *  output += "\r\n";
                     *
                     *  output += GetAbilityClones(hpsAbilityProfile, hotkey);
                     *  output += GetAbilityVariations(hpsAbilityProfile);
                     * }*/

                    if (output.Length > 0)
                    {
                        sr.WriteLine("////////////");
                        sr.WriteLine("// " + hpsHeroProfile.GetStringValue("Name").Trim('"'));
                        sr.WriteLine("////////////");
                        sr.WriteLine(output);
                    }
                }
            }
        }
Пример #18
0
        private void creepsCmbB_Format(object sender, ListControlConvertEventArgs e)
        {
            HabProperties hpsProfile = e.ListItem as HabProperties;

            e.Value = hpsProfile.GetStringValue("Name").Trim('"');
        }
Пример #19
0
 AbilityAffinityType CheckAbilityAffinity(HabProperties hpsAbility, string name, string hotkey, string buttonPos)
 {
     object abilityName;
     if (hpsAbility.TryGetValue("Name", out abilityName) && string.Equals(abilityName as string, name, StringComparison.OrdinalIgnoreCase))
     {
         // used when one ability can be replaced with another same looking ability
         // which leads to invalid hotkeys for that ability (example: Carrion Swarm)
         if ((hpsAbility.GetStringValue("Hotkey") == hotkey )
             && (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
             return AbilityAffinityType.Clone;
         else
             // used when hero has multiple abilities with the same name,
             // which are added by triggers (example: Shadowraze)
             // NOTE: must be later checked for user-defined hotkey existance to make sure
             return AbilityAffinityType.Variation;
     }
     else
         return AbilityAffinityType.None;
 }
Пример #20
0
        // used when hero has multiple abilities with the same name,
        // which are added by triggers (example: Shadowraze)
        internal string GetAbilityVariations(HabProperties hpsOriginalAbility)
        {
            string name = hpsOriginalAbility.GetStringValue("Name");
            string art = hpsOriginalAbility.GetStringValue("Art");
            string hotkey;

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                if ((hpsAbility.GetStringValue("Name") == name)
                    && (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                    && (hpsOriginalAbility.name != hpsAbility.name)
                    && dcAbilitiesHotkeys.TryGetValue(hpsAbility.name, out hotkey))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }

            return output;
        }
Пример #21
0
        internal string GetAbilityClones(HabProperties hpsOriginalAbility, string hotkey)
        {
            string name = hpsOriginalAbility.GetStringValue("Name");
            string art = hpsOriginalAbility.GetStringValue("Art");
            string orgHotkey = hpsOriginalAbility.GetStringValue("Hotkey");
            string buttonPos = hpsOriginalAbility.GetStringValue("Buttonpos");

            string output = "";

            foreach (HabProperties hpsAbility in DHLOOKUP.hpcAbilityProfiles)
                if ((hpsAbility.GetStringValue("Name") == name)
                    && (!DHLOOKUP.dcAbilitiesHeroes.ContainsKey(hpsAbility.name))
                    && (hpsAbility.GetStringValue("Hotkey") == orgHotkey)
                    && (hpsAbility.GetStringValue("Buttonpos") == buttonPos))
                {
                    output += "\r\n// " + name;
                    output += "\r\n[" + hpsAbility.name + "]";
                    output += "\r\nHotkey=" + hotkey;
                    output += "\r\nResearchhotkey=" + hotkey;
                    output += "\r\nUnhotkey=" + hotkey;
                    output += "\r\n";
                }

            return output;
        }
Пример #22
0
        internal void PrepareCreepsList()
        {
            DHMpqFile    jScript = DHRC.GetFile(MpqPath.Script.Custom);
            MemoryStream ms      = jScript.GetStream();

            byte[] buffer = ms.GetBuffer();
            string script;

            unsafe
            {
                fixed(byte *ptr = buffer)
                {
                    script = new string((sbyte *)ptr);
                }
            }

            List <HabProperties> list = new List <HabProperties>();

            foreach (HabProperties hpsUnit in hpcData)
            {
                HabProperties hpsBalance = hpcBalance[hpsUnit.name];
                if (hpsBalance.GetStringValue("Primary").Length > 1)
                {
                    continue;
                }

                HabProperties hpsProfile = hpcProfile[hpsUnit.name];
                if (hpsProfile == null)
                {
                    continue;
                }

                if (hpsUnit.GetStringValue("targType") != "ground")
                {
                    continue;
                }

                HabProperties hpsWeapons = hpcWeapons[hpsUnit.name];
                if (hpsWeapons == null)
                {
                    continue;
                }

                if (hpsWeapons.GetStringValue("weapTp1") == "_")
                {
                    continue;
                }

                HabProperties hpsUI = hpcUI[hpsUnit.name];
                if (hpsUI == null)
                {
                    continue;
                }

                if (!hpsUI.GetStringValue("file").StartsWith("units", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                if (!hpsWeapons.ContainsKey("mindmg1"))
                {
                    continue;
                }

                if (!script.Contains("'" + hpsUnit.name + "'") && !script.Contains(DHJassInt.id2int(hpsUnit.name) + ""))
                {
                    continue;
                }

                list.Add(hpsProfile);
            }

            creepsCmbB.DataSource = list;
        }
Пример #23
0
        internal void compactDump()
        {
            HabPropertiesCollection hpcHeroes = new HabPropertiesCollection();

            List <HabPropertiesCollection> unitHpcList = new List <HabPropertiesCollection>();

            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["Profile"]);
            unitHpcList.Add(DHMpqDatabase.UnitSlkDatabase["UnitAbilities"]);

            List <string> unitImages = new List <string>();

            HabPropertiesCollection hpcAbilities = new HabPropertiesCollection();

            List <HabPropertiesCollection> abilHpcList = new List <HabPropertiesCollection>();

            abilHpcList.Add(DHMpqDatabase.AbilitySlkDatabase["Profile"]);
            abilHpcList.Add(DHMpqDatabase.AbilitySlkDatabase["AbilityData"]);

            List <string> abilityImages = new List <string>();

            string imageName;

            foreach (unit tavern in DHLOOKUP.taverns)
            {
                foreach (string unitID in tavern.sellunits)
                {
                    HabProperties hps = new HabProperties();
                    foreach (HabPropertiesCollection hpc in unitHpcList)
                    {
                        hps.Merge(hpc[unitID]);
                    }

                    hps.name = unitID;

                    imageName = hps.GetStringValue("Art");
                    if (!string.IsNullOrEmpty(imageName) && !unitImages.Contains(imageName))
                    {
                        unitImages.Add(imageName);
                    }

                    List <string> abils = hps.GetStringListValue("heroAbilList");
                    foreach (string abilID in abils)
                    {
                        if (!hpcAbilities.ContainsKey(abilID))
                        {
                            HabProperties hpsAbilData = new HabProperties();
                            foreach (HabPropertiesCollection hpcAbilData in abilHpcList)
                            {
                                hpsAbilData.Merge(hpcAbilData[abilID]);
                            }

                            imageName = hpsAbilData.GetStringValue("Art");
                            if (!string.IsNullOrEmpty(imageName) && !abilityImages.Contains(imageName))
                            {
                                abilityImages.Add(imageName);
                            }

                            hpsAbilData.name = abilID;

                            hpcAbilities.Add(hpsAbilData);
                        }
                    }

                    hpcHeroes.Add(hps);
                }
            }

            List <string> filelist = new List <string>(2);

            if (heroesCB.Checked)
            {
                SaveImages(unitImages);
            }

            if (heroesAbilsCB.Checked)
            {
                SaveImages(abilityImages);
            }

            MessageBox.Show("Images extracted to " + ImageFolder);
        }