Exemplo n.º 1
0
 private bool CanGetItem(IMapleData item, MapleCharacter c)
 {
     if (item.GetChildByPath("gender") != null)
     {
         var gender = MapleDataTool.GetInt(item.GetChildByPath("gender"));
         if (gender != 2 && gender != (c.Gender ? 1 : 0))
         {
             return(false);
         }
     }
     if (item.GetChildByPath("job") != null)
     {
         var job = MapleDataTool.GetInt(item.GetChildByPath("job"));
         if (job < 100)
         {
             if (MapleJob.GetBy5ByteEncoding(job).JobId / 100 != c.Job.JobId / 100)
             {
                 return(false);
             }
         }
         else
         {
             if (job != c.Job.JobId)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 2
0
        private AbstractLoadedMapleLife LoadLife(IMapleData life, string id, string type)
        {
            var myLife = MapleLifeFactory.GetLife(int.Parse(id), type);

            myLife.Cy = MapleDataTool.GetInt(life.GetChildByPath("cy"));
            var dF = life.GetChildByPath("f");

            if (dF != null)
            {
                myLife.F = MapleDataTool.GetInt(dF);
            }
            myLife.Fh  = MapleDataTool.GetInt(life.GetChildByPath("fh"));
            myLife.Rx0 = MapleDataTool.GetInt(life.GetChildByPath("rx0"));
            myLife.Rx1 = MapleDataTool.GetInt(life.GetChildByPath("rx1"));
            var x = MapleDataTool.GetInt(life.GetChildByPath("x"));
            var y = MapleDataTool.GetInt(life.GetChildByPath("y"));

            myLife.Position = new Point(x, y);

            var hide = MapleDataTool.GetInt("hide", life, 0);

            if (hide == 1)
            {
                myLife.IsHide = true;
            }
            else if (hide > 1)
            {
                Console.WriteLine("Hide > 1 ({0})", hide);
            }
            return(myLife);
        }
Exemplo n.º 3
0
        public IMaplePortal MakePortal(PortalType type, IMapleData portal)
        {
            var ret = new MapleGenericPortal(type);

            LoadPortal(ret, portal);
            return(ret);
        }
Exemplo n.º 4
0
        public static byte GetHunger(int petId)
        {
            byte ret;

            if (PetHunger.TryGetValue(petId, out ret))
            {
                return(ret);
            }
            lock (PetHunger)
            {
                if (PetHunger.TryGetValue(petId, out ret))
                {
                    return(ret);
                }
                IMapleData hungerData = DataRoot.GetData("Pet/" + petId + ".img").GetChildByPath("info/hungry");
                ret = (byte)MapleDataTool.GetInt(hungerData, 1);

                if (PetHunger.ContainsKey(petId))
                {
                    PetHunger[petId] = ret;
                }
                else
                {
                    PetHunger.Add(petId, ret);
                }
                return(ret);
            }
        }
Exemplo n.º 5
0
        private void LoadPortal(MapleGenericPortal myPortal, IMapleData portal)
        {
            myPortal.PortalName  = MapleDataTool.GetString(portal.GetChildByPath("pn"));
            myPortal.TargetName  = MapleDataTool.GetString(portal.GetChildByPath("tn"));
            myPortal.TargetMapId = MapleDataTool.GetInt(portal.GetChildByPath("tm"));
            var x = MapleDataTool.GetInt(portal.GetChildByPath("x"));
            var y = MapleDataTool.GetInt(portal.GetChildByPath("y"));

            myPortal.Position = new Point(x, y);
            var script = MapleDataTool.GetString("script", portal, null);

            if (script != null && script.Equals(""))
            {
                script = null;
            }
            myPortal.ScriptName = script;
            if (myPortal.Type == PortalType.DoorPortal)
            {
                myPortal.PortalId = m_mNextDoorPortal;
                m_mNextDoorPortal++;
            }
            else
            {
                myPortal.PortalId = byte.Parse(portal.Name);
            }
        }
Exemplo n.º 6
0
        public static int ConvertToInt(string path, IMapleData data)
        {
            var d = data.GetChildByPath(path);

            if (d.GetType() == MapleDataType.String)
            {
                return(int.Parse(GetString(d)));
            }
            return(GetInt(d));
        }
Exemplo n.º 7
0
        public static Point GetPoint(string path, IMapleData data, Point def)
        {
            var pointData = data.GetChildByPath(path);

            if (pointData == null)
            {
                return(def);
            }

            return(GetPoint(pointData));
        }
Exemplo n.º 8
0
        public static string GetFullDataPath(IMapleData data)
        {
            var path = "";
            IMapleDataEntity myData = data;

            while (myData != null)
            {
                path   = myData.Name + "/" + path;
                myData = myData.Parent;
            }
            return(path.Substring(0, path.Length - 1));
        }
Exemplo n.º 9
0
        private MapleReactor LoadReactor(IMapleData reactor, string id)
        {
            var myReactor = new MapleReactor(MapleReactorFactory.GetReactor(int.Parse(id)), int.Parse(id));

            var x = MapleDataTool.GetInt(reactor.GetChildByPath("x"));
            var y = MapleDataTool.GetInt(reactor.GetChildByPath("y"));

            myReactor.Position = new Point(x, y);

            myReactor.Delay       = MapleDataTool.GetInt(reactor.GetChildByPath("reactorTime")) * 1000;
            myReactor.State       = 0;
            myReactor.ReactorName = MapleDataTool.GetString(reactor.GetChildByPath("name"), "");

            return(myReactor);
        }
Exemplo n.º 10
0
        public static int ConvertToInt(string path, IMapleData data, int def)
        {
            var d = data.GetChildByPath(path);

            if (d == null)
            {
                return(def);
            }
            if (d.GetType() == MapleDataType.String)
            {
                try
                {
                    return(int.Parse(GetString(d)));
                }
                catch
                {
                    return(def);
                }
            }
            return(GetInt(d, def));
        }
Exemplo n.º 11
0
        public static PetCommand GetPetCommand(int petId, int skillId)
        {
            PetCommand ret;
            var        key = Tuple.Create(petId, skillId);

            if (PetCommands.TryGetValue(key, out ret))
            {
                return(ret);
            }
            lock (PetCommands)
            {
                // see if someone else that's also synchronized has loaded the skill by now
                PetCommands.TryGetValue(key, out ret);
                if (ret == null)
                {
                    IMapleData skillData = DataRoot.GetData("Pet/" + petId + ".img");
                    int        prob      = 0;
                    int        inc       = 0;
                    if (skillData != null)
                    {
                        prob = MapleDataTool.GetInt("interact/" + skillId + "/prob", skillData, 0);
                        inc  = MapleDataTool.GetInt("interact/" + skillId + "/inc", skillData, 0);
                    }
                    ret = new PetCommand(petId, skillId, prob, inc);

                    if (PetCommands.ContainsKey(key))
                    {
                        PetCommands[key] = ret;
                    }
                    else
                    {
                        PetCommands.Add(key, ret);
                    }
                }
                return(ret);
            }
        }
Exemplo n.º 12
0
        public static List <CashItem> GetPackageItems(int itemId)
        {
            if (CashPackages.ContainsKey(itemId))
            {
                return(CashPackages[itemId]);
            }
            List <CashItem>    packageItems = new List <CashItem>();
            IMapleDataProvider dataProvider = MapleDataProviderFactory.GetDataProvider("Etc.wz");
            IMapleData         a            = dataProvider.GetData("CashPackage.img");

            foreach (var b in a.Children)
            {
                if (itemId == int.Parse(b.Name))
                {
                    foreach (var c in b.Children)
                    {
                        foreach (var d in c.Children)
                        {
                            int sn = MapleDataTool.GetInt("" + int.Parse(d.Name), c);
                            packageItems.Add(GetItem(sn));
                        }
                    }
                    break;
                }
            }

            if (CashPackages.ContainsKey(itemId))
            {
                CashPackages[itemId] = packageItems;
            }
            else
            {
                CashPackages.Add(itemId, packageItems);
            }

            return(packageItems);
        }
Exemplo n.º 13
0
 public MapleQuestRequirement(MapleQuest quest, MapleQuestRequirementType type, IMapleData data)
 {
     Type       = type;
     RequirData = data;
     m_mQuest   = quest;
 }
Exemplo n.º 14
0
 public static double GetDouble(IMapleData data) => (double)data.Data;
Exemplo n.º 15
0
 public static float GetFloat(IMapleData data) => (float)data.Data;
Exemplo n.º 16
0
 public static int ConvertToInt(IMapleData data)
 => data.GetType() == MapleDataType.String ? int.Parse(GetString(data)) : GetInt(data);
Exemplo n.º 17
0
 public static string GetString(IMapleData data, string def)
 => data == null || data.Data == null ? def : (string)data.Data;
Exemplo n.º 18
0
 public static Point GetPoint(IMapleData data) => (Point)data.Data;
Exemplo n.º 19
0
 public static Point GetPoint(string path, IMapleData data) => GetPoint(data.GetChildByPath(path));
Exemplo n.º 20
0
 public static string GetString(string path, IMapleData data, string def)
 => GetString(data.GetChildByPath(path), def);
Exemplo n.º 21
0
 public static Image GetImage(IMapleData data) => ((IMapleCanvas)data.Data).Picture;
Exemplo n.º 22
0
 public static short GetShort(IMapleData data) => (short)data.Data;
Exemplo n.º 23
0
 public static int GetInt(string path, IMapleData data, int def) => ConvertToInt(path, data, def);
Exemplo n.º 24
0
 public static int GetInt(IMapleData data, int def) => (int?)data?.Data ?? def;
Exemplo n.º 25
0
 public MapleMapFactory(IMapleDataProvider source, IMapleDataProvider stringSource)
 {
     m_mSource   = source;
     m_mNameData = stringSource.GetData("Map.img");
 }
Exemplo n.º 26
0
 public static int GetInt(IMapleData data) => (int)data.Data;
Exemplo n.º 27
0
 public static string GetString(string path, IMapleData data) => GetString(data.GetChildByPath(path));
Exemplo n.º 28
0
 public static short GetShort(IMapleData data, short def) => (short?)data?.Data ?? def;
Exemplo n.º 29
0
        public static Skill LoadFromData(int id, IMapleData data)
        {
            var ret       = new Skill(id);
            var isBuff    = false;
            var skillType = MapleDataTool.GetInt("skillType", data, -1);
            var elem      = MapleDataTool.GetString("elemAttr", data, null);

            if (elem != null)
            {
                ret.Element = Element.GetByChar(elem[0]);
            }
            else
            {
                ret.Element = Element.Neutral;
            }
            // unfortunatly this is only set for a few skills so we have to do some more to figure out if it's a buff &#65533;.o
            var effect = data.GetChildByPath("effect");

            if (skillType != -1)
            {
                if (skillType == 2)
                {
                    isBuff = true;
                }
            }
            else
            {
                var action = data.GetChildByPath("action");
                var hit    = data.GetChildByPath("hit");
                var ball   = data.GetChildByPath("ball");
                isBuff  = effect != null && hit == null && ball == null;
                isBuff |= action != null && MapleDataTool.GetString("0", action, "").Equals("alert2");
                switch (id)
                {
                case 1121006:     // rush
                case 1221007:     // rush
                case 1311005:     // sacrifice
                case 1321003:     // rush
                case 2111002:     // explosion
                case 2111003:     // poison mist
                case 2301002:     // heal
                case 3110001:     // mortal blow
                case 3210001:     // mortal blow
                case 4101005:     // drain
                case 4111003:     // shadow web
                case 4201004:     // steal
                case 4221006:     // smokescreen
                case 9101000:     // heal + dispel
                case 1121001:     // monster magnet
                case 1221001:     // monster magnet
                case 1321001:     // monster magnet
                case 5201006:     // Recoil Shot
                case 5111004:     // energy drain
                case 14111001:    // Shadow Web
                case 20001006:
                case 20001007:
                case 21000000:
                case 21001001:
                case 21000002:
                case 14101006:
                case 21100000:
                case 21100001:
                case 21120006:     //�荤�虫��杈�
                case 21100002:
                case 21100004:
                case 21110000:
                case 5221010:
                //case 21110002:
                case 21110003:
                case 21110006:
                case 21120001:
                case 21120002:
                case 21120004:
                case 21120005:

                case 21121008:
                    isBuff = false;
                    break;

                //楠�澹��㈢������
                case 12001004:     //flame
                case 11101002:     //缁�����
                case 21100005:     //杩����歌�
                case 11001004:     //soul
                case 14001005:     //dark soul?
                case 13001004:     //storm sprite
                case 15001003:
                case 5001005:
                case 14001003: // Dark Sight

                case 15000000: // Bullet Time
                case 15001004: // Lightning
                case 11101001: // Sword Booster
                case 11101003: // Rage
                case 11101004: // Soul Blade
                case 11101005: // Soul Rush
                case 12101000: // Meditation
                case 12101001: // Slow
                case 12101004: // Spell Booster
                case 12101005: // Elemental Reset
                case 13101001: // Bow Booster
                case 13101003: // Soul Arrow : Bow
                case 13101005: // Storm Brakes
                case 13101006: // Wind Walk
                case 14100005: // Vanish
                case 14101002: // Claw Booster
                case 14101003: // Haste
                case 15100004: // Energy Charge
                case 15101002: // Knuckle Booster
                case 15101006: // Lightning Charge
                case 11111001: // Combo Attack
                case 11111007: // Soul Charge
                case 12111002: // Seal is one
                case 13111004: // Puppet
                case 13111005: // Albatross
                case 14111000: // Shadow Partner
                case 15111001: // Energy Drain
                case 15111002: // Transformation
                case 15111005: // Speed Infusion
                case 15111006: // Spark
                case 15111007: // Shark Wave
                case 13001002: //focus
                case 12001001: // Magic Guard
                case 12001002: // Magic Armor
                case 11001001: // Iron Body
                case 12111004: //ifrit KoC
                case 10000012: // Blessing of the Spirit
                case 10001000: // Three Snails
                case 10001001: // Recovery
                case 10001002: // Nimble Feet
                case 10001003: // Legendary Spiri
                case 5221003:
                case 10001004: // Monster Rider
                case 10001005: // Echo of Hero
                case 1001:     // recovery
                case 1002:     // nimble feet
                case 1004:     // monster riding
                case 1005:     // echo of hero
                case 1001003:  // iron body
                case 1101004:  // sword booster
                case 1201004:  // sword booster
                case 1101005:  // axe booster
                case 1201005:  // bw booster
                case 1301004:  // spear booster
                case 1301005:  // polearm booster
                case 3101002:  // bow booster
                case 3201002:  // crossbow booster
                case 4101003:  // claw booster
                case 4201002:  // dagger booster
                case 1101007:  // power guard
                case 1201007:  // power guard
                case 1101006:  // rage
                case 1301006:  // iron will
                case 1301007:  // hyperbody
                case 1111002:  // combo attack
                case 1211006:  // blizzard charge bw
                case 1211004:  // fire charge bw
                case 1211008:  // lightning charge bw
                case 1221004:  // divine charge bw
                case 1211003:  // fire charge sword
                case 1211005:  // ice charge sword
                case 1211007:  // thunder charge sword
                case 1221003:  // holy charge sword
                case 1311008:  // dragon blood
                case 1121000:  // maple warrior
                case 1221000:  // maple warrior
                case 1321000:  // maple warrior
                case 2121000:  // maple warrior
                case 2221000:  // maple warrior
                case 2321000:  // maple warrior
                case 3121000:  // maple warrior
                case 3221000:  // maple warrior
                case 4121000:  // maple warrior
                case 4221000:  // maple warrior
                case 1121002:  // power stance
                case 1221002:  // power stance
                case 1321002:  // power stance
                case 1121010:  // enrage
                case 1321007:  // beholder
                case 1320008:  // beholder healing
                case 1320009:  // beholder buff
                case 2001002:  // magic guard
                case 2001003:  // magic armor
                case 2101001:  // meditation
                case 2201001:  // meditation
                case 2301003:  // invincible
                case 2301004:  // bless
                case 2111005:  // spell booster
                case 2211005:  // spell booster
                case 2311003:  // holy symbol
                case 2311006:  // summon dragon
                case 2121004:  // infinity
                case 2221004:  // infinity
                case 2321004:  // infinity
                case 2321005:  // holy shield
                case 2121005:  // elquines
                case 2221005:  // ifrit
                case 2321003:  // bahamut
                case 3121006:  // phoenix
                case 3221005:  // frostprey
                case 3111002:  // puppet
                case 3211002:  // puppet
                case 3111005:  // silver hawk
                case 3211005:  // golden eagle
                case 3001003:  // focus
                case 3101004:  // soul arrow bow
                case 3201004:  // soul arrow crossbow
                case 3121002:  // sharp eyes
                case 3221002:  // sharp eyes
                case 3121008:  // concentrate
                case 3221006:  // blind
                case 4001003:  // dark sight
                case 4101004:  // haste
                case 4201003:  // haste
                case 4111001:  // meso up
                case 4111002:  // shadow partner
                case 4121006:  // shadow stars
                case 4211003:  // pick pocket
                case 4211005:  // meso guard
                case 5111005:  // Transformation (Buccaneer)
                case 5121003:  // Super Transformation (Viper)
                case 5220002:  // wrath of the octopi
                case 5211001:  // Pirate octopus summon
                case 5211002:  // Pirate bird summon
                case 5221006:  // BattleShip
                case 9001000:  // haste
                case 9101001:  // super haste
                case 9101002:  // holy symbol
                case 9101003:  // bless
                case 9101004:  // hide
                case 9101008:  // hyper body
                case 1121011:  // hero's will
                case 1221012:  // hero's will
                case 1321010:  // hero's will
                case 2321009:  // hero's will
                case 2221008:  // hero's will
                case 2121008:  // hero's will
                case 3121009:  // hero's will
                case 3221008:  // hero's will
                case 4121009:  // hero's will
                case 4221008:  // hero's will
                case 2101003:  // slow
                case 2201003:  // slow
                case 2111004:  // seal
                case 2211004:  // seal
                case 1111007:  // armor crash
                case 1211009:  // magic crash
                case 1311007:  // power crash
                case 2311005:  // doom
                case 2121002:  // mana reflection
                case 2221002:  // mana reflection
                case 2321002:  // mana reflection
                case 2311001:  // dispel
                case 1201006:  // threaten
                case 4121004:  // ninja ambush
                case 4221004:  // ninja ambush
                case 21001003:
                case 20001001:
                case 20001002:
                case 20001004:
                case 20001005:

                case 20001010:
                case 20001011:
                case 21101003:
                case 21111001:

                //  case 1100002:
                case 21121000:
                case 21121003:
                case 21120007:
                //case 21110004:
                case 21111005:
                case 9001004:
                    isBuff = true;
                    break;
                }
            }
            var keydown = data.GetChildByPath("keydown");

            if (keydown != null)
            {
                ret.HasCharge = true;
            }
            foreach (var level in data.GetChildByPath("level"))
            {
                var statEffect = MapleStatEffect.LoadSkillEffectFromData(level, id, isBuff, level.Name);
                ret.m_effects.Add(statEffect);
            }
            ret.AnimationTime = 0;
            if (effect != null)
            {
                foreach (var effectEntry in effect)
                {
                    ret.AnimationTime += MapleDataTool.ConvertToInt("delay", effectEntry, 0);
                }
            }
            return(ret);
        }
Exemplo n.º 30
0
 public static string GetString(IMapleData data) => (string)data.Data;