Example #1
0
            public static PacketWriter SpawnMapItem(MapleMapItem mapItem, Point sourcePosition, byte type, int ownerObjectId = 0)
            {
                PacketWriter pw = new PacketWriter();

                pw.WriteHeader(SendHeader.SpawnMapItem);

                bool meso = mapItem.Meso > 0;

                pw.WriteByte(0);
                pw.WriteByte(type); //0 = drop animation, 1 = visible, 2 = spawned, 3 = dissapearing
                pw.WriteInt(mapItem.ObjectId);
                pw.WriteBool(meso);
                pw.WriteZeroBytes(12);
                pw.WriteInt(meso ? mapItem.Meso : mapItem.Item.ItemId);
                pw.WriteInt(mapItem.OwnerId);
                pw.WriteByte((byte)mapItem.DropType);
                pw.WritePoint(mapItem.Position);
                pw.WriteInt(ownerObjectId); //Mob which dropped the item
                if (type != 2)
                {
                    pw.WritePoint(sourcePosition);
                    pw.WriteShort(0); //fh
                }
                pw.WriteBool(false);  //boss-drop style fly added in v143
                pw.WriteShort(0);
                if (!meso)
                {
                    pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-1));
                }
                pw.WriteBool(!mapItem.PlayerDrop);
                pw.WriteZeroBytes(10);
                return(pw);
            }
Example #2
0
        public PacketWriter Update()
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.ShowStatusInfo);

            pw.WriteByte(1);
            pw.WriteUShort(25672);
            pw.WriteByte((byte)State);
            switch (State)
            {
            case MapleQuestStatus.NotStarted:
                pw.WriteByte(0);
                break;

            case MapleQuestStatus.InProgress:
                pw.WriteMapleString(Data);
                break;

            case MapleQuestStatus.Completed:
                pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(DateTime.UtcNow));
                break;
            }
            return(pw);
        }
Example #3
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 #4
0
        public static PacketWriter UpdateSkills(List <Skill> skills)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.UpdateSkills);

            pw.WriteBool(true); //enable actions
            pw.WriteByte(0);
            pw.WriteByte(0);

            short count = (short)skills.Count;

            pw.WriteShort(count);
            for (int i = 0; i < count; i++)
            {
                pw.WriteInt(skills[i].SkillId);
                pw.WriteInt(skills[i].Level);
                pw.WriteInt(skills[i].MasterLevel);
                pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(skills[i].Expiration));
            }
            pw.WriteByte(0x2F);
            return(pw);
        }
        static PacketWriter ShowCharacters(MapleAccount acc)
        {
            List <MapleCharacter> chars = acc.GetCharsFromDatabase();
            PacketWriter          pw    = new PacketWriter(SendHeader.ShowCharacters);

            pw.WriteZeroBytes(5);
            pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(DateTime.UtcNow));
            pw.WriteByte((byte)chars.Count); //Char count
            foreach (MapleCharacter chr in chars)
            {
                MapleCharacter.AddCharEntry(pw, chr);
            }
            //pw.WriteHexString("00 00 04 00 00 00 00 00 00 00 30 2A F3 A2 FA 33 D0 01 60 42 F9 64 00 00 00 00 00");

            pw.WriteByte(acc.HasPic() ? (byte)1 : (byte)0); //pic state? 4 = refresh, 1 = normal, 0 = create new pic
            pw.WriteByte(0);
            pw.WriteInt(4);                                 //char slots
            pw.WriteInt(0);
            pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(DateTime.UtcNow));
            pw.WriteHexString("60 42 F9 64");
            pw.WriteInt(0); // 1 = namechange button
            return(pw);
        }
Example #6
0
        public static void AddItemInfo(PacketWriter pw, MapleItem item)
        {
            pw.WriteByte(item.Type);                               //TODO: pets = 3
            pw.WriteInt(item.ItemId);
            pw.WriteByte(0);                                       //TODO:UniqueID,
            //pw.WriteLong(uniqueId) if uniqueId = 1;
            pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-1)); //TODO: item expiration
            pw.WriteInt(-1);                                       //TODO: extended slots
            if (item.Type == 1)                                    //Equip
            {
                MapleEquip equip = (MapleEquip)item;
                MapleEquip.AddStats(equip, pw);

                pw.WriteInt(4);     //no clue
                pw.WriteByte(0xFF); //no clue

                pw.WriteMapleString(equip.Creator);
                pw.WriteByte((byte)equip.PotentialState);
                pw.WriteByte(equip.Enhancements);
                if (equip.PotentialState >= MaplePotentialState.Rare)
                {
                    pw.WriteUShort(equip.Potential1);
                    pw.WriteUShort(equip.Potential2);
                    pw.WriteUShort(equip.Potential3);
                }
                else
                {
                    pw.WriteZeroBytes(6); //Don't show the client the potentials if they're hidden
                }
                pw.WriteUShort(equip.BonusPotential1);
                pw.WriteUShort(equip.BonusPotential2);
                pw.WriteShort(0); //bonus pot 3
                pw.WriteShort(0);
                pw.WriteShort(0); //socket state
                pw.WriteShort(equip.Socket1);
                pw.WriteShort(equip.Socket2);
                pw.WriteShort(equip.Socket3);

                //if (!HasUniqueId)
                pw.WriteLong(equip.DbId);

                pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-2)); //don't know

                pw.WriteInt(-1);
                pw.WriteLong(0);                                       //new v142
                pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-2)); //new v142
                for (int i = 0; i < 5; i++)
                {
                    pw.WriteInt(0);
                }
                pw.WriteShort(0x1);
            }
            else
            {
                pw.WriteShort(item.Quantity);
                pw.WriteMapleString(item.Creator);
                pw.WriteShort((short)item.Flags);
                if (item.IsAmmo || item.IsFamiliarCard)
                {
                    pw.WriteLong(-1);
                }
            }
        }