Example #1
0
 public bool FitsItem(int itemId)
 {
     if (OptionType == 0)
     {
         return(true);
     }
     return(FitsItem(ItemConstants.GetMapleItemType(itemId)));
 }
Example #2
0
            public static PacketWriter ShowShop(ShopScript shop, int npcId)
            {
                List <ShopItem> items = shop.ShopItems;
                PacketWriter    pw    = new PacketWriter(SendHeader.NpcShop);

                pw.WriteByte(0);
                pw.WriteInt(0);
                pw.WriteInt(npcId);
                pw.WriteByte(0);
                pw.WriteShort((short)items.Count);

                foreach (ShopItem item in items)
                {
                    pw.WriteInt(item.Id);
                    pw.WriteInt(item.Price);
                    pw.WriteByte(0);
                    pw.WriteInt(item.ReqItemId);
                    pw.WriteInt(item.ReqItemQuantity);
                    pw.WriteInt(0);        //unk
                    pw.WriteInt(0);        //unk
                    pw.WriteInt(0);        //unk
                    pw.WriteZeroBytes(22); //v158
                    pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-2));
                    pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-1));
                    pw.WriteInt(item.Tab);
                    pw.WriteByte(0);
                    pw.WriteByte(0);
                    pw.WriteInt(0);
                    pw.WriteZeroBytes(3); //v158
                    MapleItemType itemType = ItemConstants.GetMapleItemType(item.Id);
                    if (itemType == MapleItemType.Bullet || itemType == MapleItemType.ThrowingStar)
                    {
                        pw.WriteZeroBytes(6);
                        pw.WriteShort((short)(BitConverter.DoubleToInt64Bits((double)item.Price) >> 48));
                        pw.WriteShort(item.BulletCount); //Todo, correct max amount
                    }
                    else
                    {
                        pw.WriteShort((short)item.DefaultQuantity);
                        pw.WriteShort((short)item.MaximumPurchase);
                    }
                    pw.WriteByte(0);
                    pw.WriteInt(0);
                    pw.WriteInt(0);
                    pw.WriteInt(0);
                    pw.WriteInt(0);

                    pw.WriteLong(9410165);
                    pw.WriteLong(9410166);
                    pw.WriteLong(9410167);
                    pw.WriteLong(9410168);
                    //pw.WriteBytes(Functions.HexToBytes("75968F000000000076968F000000000077968F000000000078968F0000000000"));//no idea
                }
                return(pw);
            }
Example #3
0
        private static bool IsArmorScrollable(int itemId)
        {
            MapleItemType type = ItemConstants.GetMapleItemType(itemId);

            switch (type)
            {
            case MapleItemType.Cap:
            case MapleItemType.Top:
            case MapleItemType.Overall:
            case MapleItemType.Legs:
            case MapleItemType.Shoes:
            case MapleItemType.Glove:
            case MapleItemType.Cape:
                return(true);
            }
            return(false);
        }
Example #4
0
        private static bool IsAccessoryScrollable(int itemId)
        {
            MapleItemType type = ItemConstants.GetMapleItemType(itemId);

            switch (type)
            {
            case MapleItemType.FaceAccessory:
            case MapleItemType.EyeAccessory:
            case MapleItemType.Earring:
            case MapleItemType.Ring:
            case MapleItemType.Pendant:
            case MapleItemType.Belt:
            case MapleItemType.Medal:
                return(true);
            }
            return(false);
        }
Example #5
0
        public void Recalculate(MapleCharacter chr)
        {
            int mhpX = 0, mmpX = 0;
            int mhpR = 0, mmpR = 0;
            int lv2mhp = 0, lv2mmp = 0;
            int strR = 0, dexR = 0, intR = 0, lukR = 0;
            int watk = 0, matk = 9;
            int damR = 100, pdR = 0;

            Str               = chr.Str + 5;
            Dex               = chr.Dex + 5;
            Int               = chr.Int + 5;
            Luk               = chr.Luk + 5;
            MinDamage         = 0; MaxDamage = 0;
            AsrR              = 0;
            RecoveryHp        = 0; RecoveryMp = 0;
            RecoveryHpR       = 0; RecoveryMpR = 0;
            RecoveryTime      = 0;
            watk              = 3; matk = 3;
            LifeStealR        = 0; LifeStealProp = 0;
            MpEaterR          = 0; MpEaterProp = 0;
            DoTTimeInc        = 0;
            CostMpR           = 0;
            ExpR              = 100; MesoR = 100; DropR = 100;
            PickPocketR       = 0;
            StunR             = 0;
            AmmoInc           = 0;
            MasteryR          = 0;
            BuffTimeR         = 100;
            PotionEffectR     = 100;
            ElixirEffectR     = 100;
            CritRate          = 5;
            ExpLossReductionR = 0;

            #region PassiveSkills
            IEnumerable <Skill> passiveSkills = chr.GetSkillList().Where(x => x.SkillId % 10000 < 1000);
            foreach (Skill skill in passiveSkills)
            {
                if (skill.Level < 1)
                {
                    continue;
                }
                WzCharacterSkill skillInfo = DataBuffer.GetCharacterSkillById(skill.SkillId);
                if (skillInfo == null)
                {
                    continue;
                }
                SkillEffect effect = skillInfo.GetEffect(skill.Level);
                if (effect == null)
                {
                    continue;
                }
                foreach (var kvp in effect.Info)
                {
                    switch (kvp.Key)
                    {
                    case CharacterSkillStat.mhpX:
                        mhpX += kvp.Value; break;

                    case CharacterSkillStat.mmpX:
                        mmpX += kvp.Value; break;

                    case CharacterSkillStat.mhpR:
                        mhpR += kvp.Value; break;

                    case CharacterSkillStat.mmpR:
                        mmpR += kvp.Value; break;

                    case CharacterSkillStat.lv2mhp:
                        lv2mhp += kvp.Value; break;

                    case CharacterSkillStat.lv2mmp:
                        lv2mmp += kvp.Value; break;

                    case CharacterSkillStat.strX:
                        Str += kvp.Value; break;

                    case CharacterSkillStat.dexX:
                        Dex += kvp.Value; break;

                    case CharacterSkillStat.intX:
                        Int += kvp.Value; break;

                    case CharacterSkillStat.lukX:
                        Luk += kvp.Value; break;

                    case CharacterSkillStat.asrR:
                        AsrR += kvp.Value; break;

                    case CharacterSkillStat.mastery:
                        MasteryR = Math.Max(MasteryR, kvp.Value);
                        break;

                    case CharacterSkillStat.costmpR:
                        CostMpR += kvp.Value; break;

                    case CharacterSkillStat.bufftimeR:
                        BuffTimeR += kvp.Value; break;

                    case CharacterSkillStat.padX:
                        watk += kvp.Value; break;

                    case CharacterSkillStat.madX:
                        matk += kvp.Value; break;

                    case CharacterSkillStat.pdR:
                        pdR += kvp.Value; break;

                    case CharacterSkillStat.damR:
                        damR += kvp.Value; break;

                    case CharacterSkillStat.cr:
                        CritRate += kvp.Value; break;
                    }
                }
            }
            #region Specific passive skill handling
            byte skillLevel;
            if (chr.IsWarrior)
            {
                if ((skillLevel = chr.GetSkillLevel(Swordman.IRON_BODY)) > 0)
                {
                    mhpR += DataBuffer.CharacterSkillBuffer[Swordman.IRON_BODY].GetEffect(skillLevel).Info[CharacterSkillStat.mhpR];
                }

                if (chr.IsFighter)
                {
                    if ((skillLevel = chr.GetSkillLevel(Crusader.SELF_RECOVERY)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[Crusader.SELF_RECOVERY].GetEffect(skillLevel).Info;
                        RecoveryHp += info[CharacterSkillStat.hp];
                        RecoveryMp += info[CharacterSkillStat.mp];
                    }
                }
                else if (chr.IsSpearman)
                {
                    if ((skillLevel = chr.GetSkillLevel(Berserker.LORD_OF_DARKNESS)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[Berserker.LORD_OF_DARKNESS].GetEffect(skillLevel).Info;
                        LifeStealProp += info[CharacterSkillStat.prop];
                        LifeStealR    += info[CharacterSkillStat.x];
                    }
                }
            }
            else if (chr.IsMagician)
            {
                if (chr.IsFirePoisonMage)
                {
                    if ((skillLevel = chr.GetSkillLevel(FirePoison2.SPELL_MASTERY)) > 0)
                    {
                        matk += DataBuffer.CharacterSkillBuffer[FirePoison2.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                    if ((skillLevel = chr.GetSkillLevel(FirePoison2.MP_EATER)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[FirePoison2.MP_EATER].GetEffect(skillLevel).Info;
                        MpEaterProp += info[CharacterSkillStat.prop];
                        MpEaterR    += info[CharacterSkillStat.x];
                    }
                }
                if (chr.IsIceLightningMage)
                {
                    if ((skillLevel = chr.GetSkillLevel(IceLightning2.MP_EATER)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[IceLightning2.MP_EATER].GetEffect(skillLevel).Info;
                        MpEaterProp += info[CharacterSkillStat.prop];
                        MpEaterR    += info[CharacterSkillStat.x];
                    }
                    if ((skillLevel = chr.GetSkillLevel(IceLightning2.SPELL_MASTERY)) > 0)
                    {
                        matk += DataBuffer.CharacterSkillBuffer[IceLightning2.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                }
                if (chr.IsCleric)
                {
                    if ((skillLevel = chr.GetSkillLevel(Cleric.MP_EATER)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[Cleric.MP_EATER].GetEffect(skillLevel).Info;
                        MpEaterProp += info[CharacterSkillStat.prop];
                        MpEaterR    += info[CharacterSkillStat.x];
                    }
                    if ((skillLevel = chr.GetSkillLevel(Cleric.SPELL_MASTERY)) > 0)
                    {
                        matk += DataBuffer.CharacterSkillBuffer[Cleric.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                    if ((skillLevel = chr.GetSkillLevel(Priest.DIVINE_PROTECTION)) > 0)
                    {
                        AsrR += DataBuffer.CharacterSkillBuffer[Priest.DIVINE_PROTECTION].GetEffect(skillLevel).Info[CharacterSkillStat.asrR];
                    }
                }
            }
            else if (chr.IsArcher)
            {
                if (chr.IsHunter)
                {
                    if ((skillLevel = chr.GetSkillLevel(Bowmaster.BOW_EXPERT)) > 0)
                    {
                        watk += DataBuffer.CharacterSkillBuffer[Bowmaster.BOW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                }
                else if (chr.IsCrossbowman)
                {
                    if ((skillLevel = chr.GetSkillLevel(Marksman.CROSSBOW_EXPERT)) > 0)
                    {
                        watk += DataBuffer.CharacterSkillBuffer[Marksman.CROSSBOW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                }
            }
            else if (chr.IsThief)
            {
                if (chr.IsAssassin)
                {
                    if ((skillLevel = chr.GetSkillLevel(Assassin.CLAW_MASTERY)) > 0)
                    {
                        AmmoInc += DataBuffer.CharacterSkillBuffer[Assassin.CLAW_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y];
                    }
                    if ((skillLevel = chr.GetSkillLevel(Hermit.ALCHEMIC_ADRENALINE)) > 0)
                    {
                        PotionEffectR += DataBuffer.CharacterSkillBuffer[Hermit.ALCHEMIC_ADRENALINE].GetEffect(skillLevel).Info[CharacterSkillStat.x] - 100;
                    }
                    if ((skillLevel = chr.GetSkillLevel(NightLord.CLAW_EXPERT)) > 0)
                    {
                        watk += DataBuffer.CharacterSkillBuffer[NightLord.CLAW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                }
                else if (chr.IsBandit)
                {
                    if ((skillLevel = chr.GetSkillLevel(Bandit.SHIELD_MASTERY)) > 0)
                    {
                        watk += DataBuffer.CharacterSkillBuffer[Bandit.SHIELD_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y];
                    }
                    if ((skillLevel = chr.GetSkillLevel(ChiefBandit.MESO_MASTERY)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[ChiefBandit.MESO_MASTERY].GetEffect(skillLevel).Info;
                        MesoR       += info[CharacterSkillStat.mesoR];
                        PickPocketR += info[CharacterSkillStat.u];
                    }
                    if ((skillLevel = chr.GetSkillLevel(Shadower.DAGGER_EXPERT)) > 0)
                    {
                        watk += DataBuffer.CharacterSkillBuffer[Shadower.DAGGER_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                    }
                }
            }
            else if (chr.IsDualBlade)
            {
                if ((skillLevel = chr.GetSkillLevel(DualBlade3p.LIFE_DRAIN)) > 0)
                {
                    var info = DataBuffer.CharacterSkillBuffer[DualBlade3p.LIFE_DRAIN].GetEffect(skillLevel).Info;
                    LifeStealR    += info[CharacterSkillStat.x];
                    LifeStealProp += info[CharacterSkillStat.prop];
                }
                if ((skillLevel = chr.GetSkillLevel(DualBlade4.KATARA_EXPERT)) > 0)
                {
                    watk += DataBuffer.CharacterSkillBuffer[DualBlade4.KATARA_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x];
                }
            }
            else if (chr.IsPirate)
            {
                if (chr.IsBrawler)
                {
                    if ((skillLevel = chr.GetSkillLevel(Brawler.PERSEVERANCE)) > 0)
                    {
                        var info = DataBuffer.CharacterSkillBuffer[Brawler.PERSEVERANCE].GetEffect(skillLevel).Info;
                        int x    = info[CharacterSkillStat.x];
                        RecoveryHpR += x;
                        RecoveryMpR += x;
                        RecoveryTime = info[CharacterSkillStat.y];
                    }
                    if ((skillLevel = chr.GetSkillLevel(Marauder.STUN_MASTERY)) > 0)
                    {
                        StunR += DataBuffer.CharacterSkillBuffer[Marauder.STUN_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.subProp];
                    }
                }
                else if (chr.IsGunslinger)
                {
                    if ((skillLevel = skillLevel = chr.GetSkillLevel(Gunslinger.GUN_MASTERY)) > 0)
                    {
                        AmmoInc += DataBuffer.CharacterSkillBuffer[Gunslinger.GUN_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y];
                    }
                }
            }
            else if (chr.IsCannonneer)
            {
                if ((skillLevel = chr.GetSkillLevel(Cannoneer3.BARREL_ROULETTE)) > 0)
                {
                    damR += DataBuffer.CharacterSkillBuffer[Cannoneer3.BARREL_ROULETTE].GetEffect(skillLevel).Info[CharacterSkillStat.damR];
                }
            }
            else if (chr.IsJett)
            {
                /*if ((skillLevel = chr.GetSkillLevel(Jett2.PERSEVERANCE)) > 0)
                 * {
                 *  var info = DataBuffer.CharacterSkillBuffer[Jett2.PERSEVERANCE].GetSkillEffect(skillLevel).Info;
                 *  int x = info[CharacterSkillStat.x];
                 *  RecoveryHpR += x;
                 *  RecoveryMpR += x;
                 *  RecoveryTime = info[CharacterSkillStat.y] * 1000;
                 * } */
            }
            #endregion
            #endregion

            #region Buffs
            foreach (Buff buff in chr.GetBuffs())
            {
                var buffInfo = buff.Effect.BuffInfo;
                foreach (var pair in buffInfo)
                {
                    //if (pair.Key == MapleBuffStat.ENHANCED_MAXHP || pair.Key == MapleBuffStat.STACKING_MAXHP)
                    //mhpX += pair.Value;
                    if (pair.Key == MapleBuffStat.MAXHP_R || pair.Key == MapleBuffStat.STACKING_MAXHP_R)
                    {
                        mhpR += pair.Value;
                    }
                    //else if (pair.Key == MapleBuffStat.ENHANCED_MAXMP || pair.Key == MapleBuffStat.STACKING_MAXMP)
                    //mmpX += pair.Value;
                    else if (pair.Key == MapleBuffStat.MAXMP_R || pair.Key == MapleBuffStat.STACKING_MAXMP_R)
                    {
                        mmpR += pair.Value;
                    }
                    //else if (pair.Key == MapleBuffStat.WATK || pair.Key == MapleBuffStat.ENHANCED_WATK || pair.Key == MapleBuffStat.STACKING_WATK)
                    //watk += pair.Value;
                    //else if (pair.Key == MapleBuffStat.MATK || pair.Key == MapleBuffStat.ENHANCED_MATK || pair.Key == MapleBuffStat.STACKING_MATK)
                    //matk += pair.Value;
                    //else if (pair.Key == MapleBuffStat.CRIT || pair.Key == MapleBuffStat.STACKING_CRIT)
                    //CritRate += pair.Value;
                    else if (pair.Key == MapleBuffStat.STACKING_STATS)
                    {
                        Str += pair.Value;
                        Dex += pair.Value;
                        Int += pair.Value;
                        Luk += pair.Value;
                    }
                    else if (pair.Key == MapleBuffStat.STACKING_STATS_R)
                    {
                        Str += (int)(chr.Str * (pair.Value / 100.0)); //todo: check if this isnt math.ceil
                        Dex += (int)(chr.Dex * (pair.Value / 100.0));
                        Int += (int)(chr.Int * (pair.Value / 100.0));
                        Luk += (int)(chr.Luk * (pair.Value / 100.0));
                    }
                    //else if (pair.Key == MapleBuffStat.HOLY_SYMBOL)
                    {
                        // ExpR += pair.Value;
                    }
                }
            }
            #endregion

            #region Equips
            foreach (MapleItem item in chr.Inventory.GetItemsFromInventory(MapleInventoryType.Equipped))
            {
                MapleEquip equip = item as MapleEquip;
                if (equip == null)
                {
                    continue;
                }
                mhpX += equip.IncMhp;
                mmpX += equip.IncMmp;
                Str  += equip.Str;
                Dex  += equip.Dex;
                Int  += equip.Int;
                Luk  += equip.Luk;
                watk += equip.Pad;
                matk += equip.Mad;
                //todo: potential stuff from here
            }
            #endregion

            MaxHp  = chr.MaxHp;
            MaxHp += lv2mhp * chr.Level;
            MaxHp += (int)((MaxHp) * (mhpR / 100.0));
            MaxHp += mhpX;
            if (chr.Hp > MaxHp)
            {
                chr.AddHP(-(chr.Hp - MaxHp));
            }

            MaxMp  = chr.MaxMp;
            MaxMp += (int)(chr.MaxMp * (double)(mmpR / 100.0));
            MaxMp += lv2mmp * chr.Level;
            MaxMp += mhpX;
            if (chr.Mp > MaxMp)
            {
                chr.AddMP(-(chr.Mp - MaxMp));
            }

            Str += (short)(chr.Str * (double)(strR / 100.0));
            Dex += (short)(chr.Dex * (double)(dexR / 100.0));
            Int += (short)(chr.Int * (double)(intR / 100.0));
            Luk += (short)(chr.Luk * (double)(lukR / 100.0));

            bool      mage                    = false;
            int       primaryStat             = 0;
            int       secondaryStat           = 0;
            MapleItem weapon                  = chr.Inventory.GetEquippedItem((short)MapleEquipPosition.Weapon);
            if (weapon == null)
            {
                MinDamage = 1;
                MaxDamage = 1;
                return;
            }
            MapleItemType weaponItemType = ItemConstants.GetMapleItemType(weapon.ItemId);
            switch ((chr.Job % 1000) / 100)
            {
            case 1:     //Warrior-type
                primaryStat   = Str;
                secondaryStat = Dex;
                break;

            case 2:     //Magician-type
            case 7:     //Luminous
                primaryStat   = Int;
                secondaryStat = Luk;
                mage          = true;
                break;

            case 3:     //Archer-type
                primaryStat   = Dex;
                secondaryStat = Str;
                break;

            case 4:     //Thief-type
                primaryStat   = Luk;
                secondaryStat = Dex;
                break;

            case 5:     //Pirate-type
                if (weaponItemType == MapleItemType.Gun || weaponItemType == MapleItemType.SoulShooter)
                {
                    primaryStat   = Dex;
                    secondaryStat = Str;
                }
                else     //counts for cannons too
                {
                    primaryStat   = Str;
                    secondaryStat = Dex;
                }
                break;

            case 6:     //Xenon
                primaryStat = (Str + Dex + Luk);
                break;
            }
            if (!mage)
            {
                damR += pdR; //TODO: check, Not sure about this
            }
            CalculateDamageRange(weaponItemType, primaryStat, secondaryStat, mage ? matk : watk, damR, chr.IsFighter);
        }
Example #6
0
        private static bool IsTwoHandedWeaponScrollable(int itemId)
        {
            MapleItemType type = ItemConstants.GetMapleItemType(itemId);

            return(type >= MapleItemType.TwoHandedSword && type <= MapleItemType.Fan);
        }