Example #1
0
        public string GetSpellName(int spellId)
        {
            if (spellId <= 0)
            {
                return(string.Empty);
            }

            if (SpellNames.ContainsKey(spellId))
            {
                return(SpellNames[spellId]);
            }
            else
            {
                string name = Wow.GetSpellNameById(spellId);

                if (!string.IsNullOrWhiteSpace(name))
                {
                    SpellNames.TryAdd(spellId, name);
                    return(name);
                }

                SpellNames.TryAdd(spellId, "unk");
                return("unk");
            }
        }
Example #2
0
        public void Load(string value)
        {
            var lines = File.ReadAllLines(value);

            foreach (var line in lines)
            {
                if (line.ToLower().Contains("example") || line.ToLower().Contains("[spells]"))
                {
                    //Ignore
                }
                else
                {
                    var temp = line.Split('_');
                    SpellNames.Add(temp[0]);
                    Health.Add(Convert.ToInt32(temp[1]));
                    SpellKeys.Add(temp[2]);
                    CastTime.Add(Convert.ToInt32(temp[3]));
                    Mana.Add(Convert.ToInt32(temp[4]));
                    Range.Add(Convert.ToInt32(temp[5]));
                    Type.Add(temp[6]);
                    Combo.Add(Convert.ToInt32(temp[7]));
                    MinDistance.Add(Convert.ToInt32(temp[8]));
                    EnemyHealth.Add(Convert.ToInt32(temp[9]));
                }
            }
        }
Example #3
0
        public void CreateSQLINSERTStatement(uint weenieClassID, IList <WeeniePropertiesSpellBook> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_spell_book` (`object_Id`, `spell`, `probability`)");

            var lineGenerator = new Func <int, string>(i =>
            {
                string label = null;

                if (SpellNames != null)
                {
                    SpellNames.TryGetValue((uint)input[i].Spell, out label);
                }

                return($"{weenieClassID}, {input[i].Spell.ToString().PadLeft(5)}, {input[i].Probability.ToString("0.######", CultureInfo.InvariantCulture).PadLeft(6)})  /* {label} */");
            });

            ValuesWriter(input.Count, lineGenerator, writer);
        }
Example #4
0
        /// <summary>
        /// Loads all data. Should be positioned on the start
        /// if the second data hunk.
        /// </summary>
        /// <param name="dataReader"></param>
        public ExecutableData(IDataReader dataReader)
        {
            // TODO: For now we search the offset of the filelist manually
            //       until we decode all of the data.
            dataReader.Position = (int)dataReader.FindString("0Map_data.amb", 0) - 184;

            // TODO ...
            FileList   = new FileList(dataReader);
            WorldNames = new WorldNames(dataReader);
            Messages   = new Messages(dataReader);
            if (dataReader.ReadDword() != 0)
            {
                throw new AmbermoonException(ExceptionScope.Data, "Invalid executable data.");
            }
            AutomapNames   = new AutomapNames(dataReader);
            OptionNames    = new OptionNames(dataReader);
            SongNames      = new SongNames(dataReader);
            SpellTypeNames = new SpellTypeNames(dataReader);
            SpellNames     = new SpellNames(dataReader);
            LanguageNames  = new LanguageNames(dataReader);
            ClassNames     = new ClassNames(dataReader);
            RaceNames      = new RaceNames(dataReader);
            AbilityNames   = new AbilityNames(dataReader);
            AttributeNames = new AttributeNames(dataReader);
            AbilityNames.AddShortNames(dataReader);
            AttributeNames.AddShortNames(dataReader);
            ItemTypeNames = new ItemTypeNames(dataReader);
            AilmentNames  = new AilmentNames(dataReader);
            UITexts       = new UITexts(dataReader);

            // TODO: There is a bunch of binary data (gfx maybe?)

            // TODO: Then finally the item data comes ...

            // TODO ...
        }
Example #5
0
        private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
        {
            if (!sender.IsMe)
            {
                return;
            }

            if (SpellNames.Contains(args.SData.Name.ToLower()))
            {
                PassiveStacks = 2;
                passiveTimer  = Environment.TickCount + 3000;
                LastSpellTime = Environment.TickCount;
            }

            if (args.SData.Name.Equals("BlindMonkQOne", StringComparison.InvariantCultureIgnoreCase))
            {
                castQAgain = false;
                Core.DelayAction(delegate { castQAgain = true; }, 2900);
            }

            if (R.IsReady() && Flash.IsReady())
            {
                var target = InsecMenu.GetCheckBoxValue("insecMode")
                                 ? TargetSelector.SelectedTarget
                                 : TargetSelector.GetTarget(R.Range, DamageType.Physical);

                if (target == null)
                {
                    return;
                }
                if (args.SData.Name.Equals("BlindMonkRKick", StringComparison.InvariantCultureIgnoreCase) &&
                    InsecMenu.GetKeyBindValue("insecflash"))
                {
                    Core.DelayAction(delegate { Flash.Cast(GetInsecPos(target)); }, 80);
                }
            }

            if (args.SData.Name.Equals("summonerflash", StringComparison.InvariantCultureIgnoreCase) &&
                insecComboStep != InsecComboStepSelect.None)
            {
                var target = InsecMenu.GetCheckBoxValue("insecMode")
                                 ? TargetSelector.SelectedTarget
                                 : TargetSelector.GetTarget(Q.Range, DamageType.Physical);

                insecComboStep = InsecComboStepSelect.Pressr;

                Core.DelayAction(delegate { R.Cast(target); }, 80);
            }
            if (args.SData.Name.Equals("BlindMonkQTwo", StringComparison.InvariantCultureIgnoreCase))
            {
                waitingForQ2 = true;
                Core.DelayAction(delegate { waitingForQ2 = false; }, 3000);
            }
            if (args.SData.Name.Equals("BlindMonkRKick", StringComparison.InvariantCultureIgnoreCase))
            {
                insecComboStep = InsecComboStepSelect.None;
            }

            switch (args.SData.Name.ToLower())
            {
            case "blindmonkqone":
                LastQ         = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                break;

            case "blindmonkwone":
                LastW         = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                break;

            case "blindmonkeone":
                LastE         = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                break;

            case "blindmonkqtwo":
                LastQ2        = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                CheckQ        = false;
                break;

            case "blindmonkwtwo":
                LastW2        = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                break;

            case "blindmonketwo":
                LastQ         = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                break;

            case "blindmonkrkick":
                LastR         = Environment.TickCount;
                LastSpell     = Environment.TickCount;
                PassiveStacks = 2;
                break;
            }
        }
Example #6
0
        private void CreateSQLINSERTStatement(IList <WeeniePropertiesEmoteAction> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_emote_action` (`emote_Id`, `order`, `type`, `delay`, `extent`, `motion`, `message`, `test_String`, `min`, `max`, `min_64`, `max_64`, `min_Dbl`, `max_Dbl`, " +
                             "`stat`, `display`, `amount`, `amount_64`, `hero_X_P_64`, `percent`, `spell_Id`, `wealth_Rating`, `treasure_Class`, `treasure_Type`, `p_Script`, `sound`, `destination_Type`, `weenie_Class_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`, " +
                             "`obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)");

            var lineGenerator = new Func <int, string>(i =>
            {
                string typeLabel = Enum.GetName(typeof(EmoteType), input[i].Type);
                if (typeLabel != null)
                {
                    typeLabel = $" /* {typeLabel} */";
                }

                string motionLabel = null;
                if (input[i].Motion.HasValue)
                {
                    motionLabel = Enum.GetName(typeof(MotionCommand), input[i].Motion.Value);
                    if (motionLabel != null)
                    {
                        motionLabel = $" /* {motionLabel} */";
                    }
                }

                string spellIdLabel = null;
                if (SpellNames != null && input[i].SpellId.HasValue)
                {
                    SpellNames.TryGetValue((uint)input[i].SpellId.Value, out spellIdLabel);
                    if (spellIdLabel != null)
                    {
                        spellIdLabel = $" /* {spellIdLabel} */";
                    }
                }

                string pScriptLabel = null;
                if (input[i].PScript.HasValue)
                {
                    pScriptLabel = Enum.GetName(typeof(PlayScript), input[i].PScript.Value);
                    if (pScriptLabel != null)
                    {
                        pScriptLabel = $" /* {pScriptLabel} */";
                    }
                }

                string soundLabel = null;
                if (input[i].Sound.HasValue)
                {
                    soundLabel = Enum.GetName(typeof(Sound), input[i].Sound.Value);
                    if (soundLabel != null)
                    {
                        soundLabel = $" /* {soundLabel} */";
                    }
                }

                string weenieClassIdLabel = null;
                if (input[i].WeenieClassId.HasValue && WeenieNames != null)
                {
                    WeenieNames.TryGetValue(input[i].WeenieClassId.Value, out weenieClassIdLabel);
                    if (weenieClassIdLabel != null)
                    {
                        weenieClassIdLabel = $" /* {weenieClassIdLabel} */";
                    }
                }

                string destinationTypeLabel = null;
                if (input[i].DestinationType.HasValue)
                {
                    destinationTypeLabel = Enum.GetName(typeof(DestinationType), input[i].DestinationType.Value);
                    if (destinationTypeLabel != null)
                    {
                        destinationTypeLabel = $" /* {destinationTypeLabel} */";
                    }
                }

                string telelocLabel = null;
                if (input[i].ObjCellId.HasValue && input[i].ObjCellId.Value > 0)
                {
                    telelocLabel = $" /* @teleloc 0x{input[i].ObjCellId.Value:X8} [{TrimNegativeZero(input[i].OriginX.Value):F6} {TrimNegativeZero(input[i].OriginY.Value):F6} {TrimNegativeZero(input[i].OriginZ.Value):F6}] {TrimNegativeZero(input[i].AnglesW.Value):F6} {TrimNegativeZero(input[i].AnglesX.Value):F6} {TrimNegativeZero(input[i].AnglesY.Value):F6} {TrimNegativeZero(input[i].AnglesZ.Value):F6} */";
                }

                string statLabel = null;
                if (input[i].Stat.HasValue)
                {
                    switch ((EmoteType)input[i].Type)
                    {
                    case EmoteType.AwardLevelProportionalSkillXP:
                    case EmoteType.AwardSkillPoints:
                    case EmoteType.AwardSkillXP:

                    case EmoteType.InqSkillStat:
                    case EmoteType.InqRawSkillStat:
                    case EmoteType.InqSkillTrained:
                    case EmoteType.InqSkillSpecialized:
                    case EmoteType.UntrainSkill:
                        statLabel = $" /* Skill.{(Skill)input[i].Stat.Value} */";
                        break;

                    case EmoteType.DecrementIntStat:
                    case EmoteType.IncrementIntStat:
                    case EmoteType.InqIntStat:
                    case EmoteType.SetIntStat:
                        statLabel = $" /* PropertyInt.{(PropertyInt)input[i].Stat.Value} */";
                        break;

                    case EmoteType.InqAttributeStat:
                    case EmoteType.InqRawAttributeStat:
                        statLabel = $" /* PropertyAttribute.{(PropertyAttribute)input[i].Stat.Value} */";
                        break;

                    case EmoteType.InqBoolStat:
                    case EmoteType.SetBoolStat:
                        statLabel = $" /* PropertyBool.{(PropertyBool)input[i].Stat.Value} */";
                        break;

                    case EmoteType.InqFloatStat:
                    case EmoteType.SetFloatStat:
                        statLabel = $" /* PropertyFloat.{(PropertyFloat)input[i].Stat.Value} */";
                        break;

                    case EmoteType.InqInt64Stat:
                    case EmoteType.SetInt64Stat:
                        statLabel = $" /* PropertyInt64.{(PropertyInt64)input[i].Stat.Value} */";
                        break;

                    case EmoteType.InqSecondaryAttributeStat:
                    case EmoteType.InqRawSecondaryAttributeStat:
                        statLabel = $" /* PropertyAttribute2nd.{(PropertyAttribute2nd)input[i].Stat.Value} */";
                        break;

                    case EmoteType.InqStringStat:
                        statLabel = $" /* PropertyString.{(PropertyString)input[i].Stat.Value} */";
                        break;

                    default:
                        break;
                    }
                }

                string amountLabel = null;
                if (input[i].Amount.HasValue)
                {
                    switch ((EmoteType)input[i].Type)
                    {
                    case EmoteType.AddCharacterTitle:
                        amountLabel = $" /* {(CharacterTitle)input[i].Amount.Value} */";
                        break;

                    case EmoteType.AddContract:
                    case EmoteType.RemoveContract:
                        amountLabel = $" /* {(ContractId)input[i].Amount.Value} */";
                        break;

                    default:
                        break;
                    }
                }

                string treasureClassLabel = null;
                if (input[i].TreasureClass.HasValue)
                {
                    treasureClassLabel = Enum.GetName(typeof(TreasureClass), input[i].TreasureClass.Value);
                    if (treasureClassLabel != null)
                    {
                        treasureClassLabel = $" /* {treasureClassLabel} */";
                    }
                }

                string treasureTypeLabel = null;
                if (input[i].TreasureType.HasValue)
                {
                    treasureTypeLabel = Enum.GetName(typeof(TreasureType), input[i].TreasureType.Value);
                    if (treasureTypeLabel != null)
                    {
                        treasureTypeLabel = $" /* {treasureTypeLabel} */";
                    }
                }

                string paletteLabel = null;
                if (input[i].Palette.HasValue)
                {
                    paletteLabel = Enum.GetName(typeof(PaletteTemplate), input[i].Palette.Value);
                    if (paletteLabel != null)
                    {
                        paletteLabel = $" /* {paletteLabel} */";
                    }
                }

                return
                ("@parent_id, " +
                 $"{input[i].Order.ToString().PadLeft(2)}, " +
                 $"{input[i].Type.ToString().PadLeft(3)}{typeLabel}, " +
                 $"{input[i].Delay:0.######}, " +
                 $"{input[i].Extent:0.######}, " +
                 $"{(input[i].Motion.HasValue ? "0x" : "")}{input[i].Motion:X8}{motionLabel}, " +
                 $"{GetSQLString(input[i].Message)}, " +
                 $"{GetSQLString(input[i].TestString)}, " +
                 $"{input[i].Min}, " +
                 $"{input[i].Max}, " +
                 $"{input[i].Min64}, " +
                 $"{input[i].Max64}, " +
                 $"{input[i].MinDbl}, " +
                 $"{input[i].MaxDbl}, " +
                 $"{input[i].Stat}{statLabel}, " +
                 $"{input[i].Display}, " +
                 $"{input[i].Amount}{amountLabel}, " +
                 $"{input[i].Amount64}, " +
                 $"{input[i].HeroXP64}, " +
                 $"{input[i].Percent}, " +
                 $"{input[i].SpellId}{spellIdLabel}, " +
                 $"{input[i].WealthRating}, " +
                 $"{input[i].TreasureClass}{treasureClassLabel}, " +
                 $"{input[i].TreasureType}{treasureTypeLabel}, " +
                 $"{input[i].PScript}{pScriptLabel}, " +
                 $"{input[i].Sound}{soundLabel}, " +
                 $"{input[i].DestinationType}{destinationTypeLabel}, " +
                 $"{input[i].WeenieClassId}{weenieClassIdLabel}, " +
                 $"{input[i].StackSize}, " +
                 $"{input[i].Palette}{paletteLabel}, " +
                 $"{input[i].Shade:0.######}, " +
                 $"{input[i].TryToBond}, " +
                 $"{(input[i].ObjCellId.HasValue ? "0x" : "")}{input[i].ObjCellId:X8}{telelocLabel}, " +
                 $"{TrimNegativeZero(input[i].OriginX):0.######}, " +
                 $"{TrimNegativeZero(input[i].OriginY):0.######}, " +
                 $"{TrimNegativeZero(input[i].OriginZ):0.######}, " +
                 $"{TrimNegativeZero(input[i].AnglesW):0.######}, " +
                 $"{TrimNegativeZero(input[i].AnglesX):0.######}, " +
                 $"{TrimNegativeZero(input[i].AnglesY):0.######}, " +
                 $"{TrimNegativeZero(input[i].AnglesZ):0.######})");
            });

            ValuesWriter(input.Count, lineGenerator, writer);
        }
Example #7
0
        private void CreateSQLINSERTStatement(IList <WeeniePropertiesEmoteAction> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_emote_action` (`emote_Id`, `order`, `type`, `delay`, `extent`, `motion`, `message`, `test_String`, `min`, `max`, `min_64`, `max_64`, `min_Dbl`, `max_Dbl`, " +
                             "`stat`, `display`, `amount`, `amount_64`, `hero_X_P_64`, `percent`, `spell_Id`, `wealth_Rating`, `treasure_Class`, `treasure_Type`, `p_Script`, `sound`, `destination_Type`, `weenie_Class_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`, " +
                             "`obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)");

            var lineGenerator = new Func <int, string>(i =>
            {
                string typeLabel = Enum.GetName(typeof(EmoteType), input[i].Type);
                if (typeLabel != null)
                {
                    typeLabel = $" /* {typeLabel} */";
                }

                string motionLabel = null;
                if (input[i].Motion.HasValue)
                {
                    motionLabel = Enum.GetName(typeof(MotionCommand), input[i].Motion.Value);
                    if (motionLabel != null)
                    {
                        motionLabel = $" /* {motionLabel} */";
                    }
                }

                string spellIdLabel = null;
                if (SpellNames != null && input[i].SpellId.HasValue)
                {
                    SpellNames.TryGetValue((uint)input[i].SpellId.Value, out spellIdLabel);
                    if (spellIdLabel != null)
                    {
                        spellIdLabel = $" /* {spellIdLabel} */";
                    }
                }

                string pScriptLabel = null;
                if (input[i].PScript.HasValue)
                {
                    pScriptLabel = Enum.GetName(typeof(PlayScript), input[i].PScript.Value);
                    if (pScriptLabel != null)
                    {
                        pScriptLabel = $" /* {pScriptLabel} */";
                    }
                }

                string soundLabel = null;
                if (input[i].Sound.HasValue)
                {
                    soundLabel = Enum.GetName(typeof(Sound), input[i].Sound.Value);
                    if (soundLabel != null)
                    {
                        soundLabel = $" /* {soundLabel} */";
                    }
                }

                string weenieClassIdLabel = null;
                if (input[i].WeenieClassId.HasValue && WeenieNames != null)
                {
                    WeenieNames.TryGetValue(input[i].WeenieClassId.Value, out weenieClassIdLabel);
                    if (weenieClassIdLabel != null)
                    {
                        weenieClassIdLabel = $" /* {weenieClassIdLabel} */";
                    }
                }

                string destinationTypeLabel = null;
                if (input[i].DestinationType.HasValue)
                {
                    destinationTypeLabel = Enum.GetName(typeof(DestinationType), input[i].DestinationType.Value);
                    if (destinationTypeLabel != null)
                    {
                        destinationTypeLabel = $" /* {destinationTypeLabel} */";
                    }
                }

                string telelocLabel = null;
                if (input[i].ObjCellId.HasValue && input[i].ObjCellId.Value > 0)
                {
                    telelocLabel = $" /* @teleloc 0x{input[i].ObjCellId.Value:X8} [{input[i].OriginX.Value:F6} {input[i].OriginY.Value:F6} {input[i].OriginZ.Value:F6}] {input[i].AnglesW.Value:F6} {input[i].AnglesX.Value:F6} {input[i].AnglesY.Value:F6} {input[i].AnglesZ.Value:F6} */";
                }

                return
                ("@parent_id, " +
                 $"{input[i].Order.ToString().PadLeft(2)}, " +
                 $"{input[i].Type.ToString().PadLeft(3)}{typeLabel}, " +
                 $"{input[i].Delay}, " +
                 $"{input[i].Extent}, " +
                 $"{input[i].Motion}{motionLabel}, " +
                 $"{GetSQLString(input[i].Message)}, " +
                 $"{GetSQLString(input[i].TestString)}, " +
                 $"{input[i].Min}, " +
                 $"{input[i].Max}, " +
                 $"{input[i].Min64}, " +
                 $"{input[i].Max64}, " +
                 $"{input[i].MinDbl}, " +
                 $"{input[i].MaxDbl}, " +
                 $"{input[i].Stat}, " +
                 $"{input[i].Display}, " +
                 $"{input[i].Amount}, " +
                 $"{input[i].Amount64}, " +
                 $"{input[i].HeroXP64}, " +
                 $"{input[i].Percent}, " +
                 $"{input[i].SpellId}{spellIdLabel}, " +
                 $"{input[i].WealthRating}, " +
                 $"{input[i].TreasureClass}, " +
                 $"{input[i].TreasureType}, " +
                 $"{input[i].PScript}{pScriptLabel}, " +
                 $"{input[i].Sound}{soundLabel}, " +
                 $"{input[i].DestinationType}{destinationTypeLabel}, " +
                 $"{input[i].WeenieClassId}{weenieClassIdLabel}, " +
                 $"{input[i].StackSize}, " +
                 $"{input[i].Palette}, " +
                 $"{input[i].Shade}, " +
                 $"{input[i].TryToBond}, " +
                 $"{input[i].ObjCellId}{telelocLabel}, " +
                 $"{input[i].OriginX}, " +
                 $"{input[i].OriginY}, " +
                 $"{input[i].OriginZ}, " +
                 $"{input[i].AnglesW}, " +
                 $"{input[i].AnglesX}, " +
                 $"{input[i].AnglesY}, " +
                 $"{input[i].AnglesZ})");
            });

            ValuesWriter(input.Count, lineGenerator, writer);
        }