Esempio n. 1
0
        public byte[] npcSpawn(Character character)
        {
            OutPacket initNPCData = new OutPacket(615);

            initNPCData.WriteInt(615);
            initNPCData.WriteShort(0x04);
            initNPCData.WriteShort(0x04);
            initNPCData.WriteByte(0x01);
            initNPCData.WriteInt(character.getuID());
            initNPCData.WriteInt(character.getArea().getaID());
            initNPCData.WriteFloat(character.getPosition()[0]);
            initNPCData.WriteFloat(character.getPosition()[1]);
            initNPCData.WriteByte(3);
            initNPCData.WriteInt(this.uID);
            initNPCData.WriteInt();
            initNPCData.WritePaddedString(this.getName(), 16);
            initNPCData.Skip(18);
            initNPCData.WriteInt(this.getModule());
            initNPCData.Skip(10);
            initNPCData.WriteInt(this.getmID());
            initNPCData.Skip(16);
            initNPCData.WriteFloat(this.npcPosition[0]);
            initNPCData.WriteFloat(this.npcPosition[1]);
            initNPCData.Skip(502);
            initNPCData.WriteByte(0x22);
            initNPCData.WriteByte(0x08);
            return(initNPCData.ToArray());
        }
Esempio n. 2
0
        public byte[] npcSpawnChained(Character chr)
        {
            OutPacket initNPCData = new OutPacket(589);

            initNPCData.WriteByte(3);
            initNPCData.WriteInt(this.uID);
            initNPCData.WriteInt();
            initNPCData.WritePaddedString(this.getName(), 16);
            initNPCData.Skip(18);
            initNPCData.WriteInt(this.getModule());
            initNPCData.Skip(10);
            initNPCData.WriteInt(this.getmID());
            initNPCData.Skip(16);
            initNPCData.WriteFloat(this.npcPosition[0]);
            initNPCData.WriteFloat(this.npcPosition[1]);
            return(initNPCData.ToArray());
        }
Esempio n. 3
0
        public void OnEquipItem(ClientSession cs, InPacket ip)
        {
            int    LoginIDLen = ip.ReadInt();
            string LoginID    = ip.ReadUnicodeString(LoginIDLen);

            ip.ReadInt(); // 00 00 00 00
            byte CharNum = ip.ReadByte();

            for (byte i = 0; i < CharNum; i++)
            {
                byte TargetChar = ip.ReadByte();
                int  EquipCount = ip.ReadInt();

                int MyCharPos = -1;
                for (int t = 0; t < cs.MyCharacter.MyChar.Length; t++)
                {
                    if (cs.MyCharacter.MyChar[t].CharType == TargetChar)
                    {
                        MyCharPos = t;
                    }
                }

                // 내가 가진 캐릭터 목록에 없다
                if (MyCharPos == -1)
                {
                    continue;
                }

                //Array.Resize(ref cs.MyCharacter.MyChar[MyCharPos].Equip, EquipCount);
                int len = cs.MyCharacter.MyChar[MyCharPos].Equip.Length;
                for (int j = 0; j < EquipCount; j++)
                {
                    int kind   = 0;
                    int ItemID = ip.ReadInt();
                    ip.ReadInt();  // 00 00 00 01
                    int ItemUID = ip.ReadInt();
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadByte(); // 00 00 00
                    ip.ReadByte(); //
                    ip.ReadByte(); //

                    /*
                     * helm 0
                     * upper 1
                     * lower 2
                     * Weapon 3
                     * gloves 8
                     * shoes 9
                     * Circlet 10
                     * Wings 12
                     * Mask 11
                     * cloak 13
                     * Stompers 14
                     * Shields 15
                     */
                    DataSet ds3 = new DataSet();
                    Database.Query(ref ds3, "SELECT   `Kind` FROM  `gc`.`goodsinfolist` WHERE `GoodsID` = '{0}'", ItemID);
                    if (ds3.Tables[0].Rows.Count == 0)
                    {
                        LogFactory.GetLog("EQUIPS").LogWarning("ITEM NAO EXISTE!");
                        kind = 0;
                    }
                    else
                    {
                        kind = Convert.ToInt32(ds3.Tables[0].Rows[0]["Kind"].ToString());
                    }
                    int type = 0;
                    if (kind == 0)
                    {
                        type = 0;
                    }
                    if (kind == 1)
                    {
                        type = 1;
                    }
                    if (kind == 2)
                    {
                        type = 2;
                    }
                    if (kind == 3)
                    {
                        type = 3;
                    }
                    if (kind == 8)
                    {
                        type = 4;
                    }
                    if (kind == 9)
                    {
                        type = 5;
                    }
                    if (kind == 13)
                    {
                        type = 6;
                    }
                    //cs.MyCharacter.MyChar[MyCharPos].Equip[j].ItemID = ItemID;
                    DataSet ds2 = new DataSet();
                    Database.Query(ref ds2, "SELECT itemID FROM gc.equipment WHERE LoginUID = '{0}' AND CharType = '{1}' AND ItemUID = '{2}'", cs.LoginUID, MyChar[MyCharPos].CharType, ItemUID);
                    if (ds2.Tables[0].Rows.Count == 0)
                    {
                        DataSet ds = new DataSet();
                        Database.Query(ref ds, "INSERT INTO gc.equipment ( LoginUID, CharType, ItemType, ItemID,ItemUID) VALUES ( '{0}', '{1}', '{2}', '{3}' ,'{4}')", cs.LoginUID, MyChar[MyCharPos].CharType, type, ItemID, ItemUID);
                    }
                    else
                    {
                        DataSet ds = new DataSet();
                        Database.Query(ref ds, "UPDATE   `gc`.`equipment` SET  `ItemID` = '{0}' WHERE `LoginUID` = '{1}'   AND `CharType` = '{2}'   AND `ItemType` = '{3}'", ItemID, cs.LoginUID, MyChar[MyCharPos].CharType, type);
                    }
                    if (EquipCount > len)
                    {
                        for (int k = 0; k < EquipCount; k++)
                        {
                            len++;
                        }
                    }
                    LogFactory.GetLog("EQUIPAMENTOS").LogInfo("ATUAL TYPE: " + type);
                    if (type > len)
                    {
                        for (int h = 0; h < type; h++)
                        {
                            type--;
                            LogFactory.GetLog("EQUIPAMENTOS").LogInfo("ATUAL TYPE: " + type);
                        }
                    }
                    Array.Resize(ref cs.MyCharacter.MyChar[MyCharPos].Equip, len);
                    cs.MyCharacter.MyChar[MyCharPos].TotalEquips++;
                    LogFactory.GetLog("EQUIPS").LogInfo("TOTAL: " + cs.MyCharacter.MyChar[MyCharPos].TotalEquips);
                    cs.MyCharacter.MyChar[MyCharPos].Equip[type].ItemID  = ItemID;
                    cs.MyCharacter.MyChar[MyCharPos].Equip[type].ItemUID = ItemUID;

                    //Array.Resize(ref cs.MyCharacter.MyChar[MyCharPos].Equip, EquipCount++);

                    /*cs.MyCharacter.MyChar[MyCharPos].Equip[type].ItemID = ItemID;
                     * cs.MyCharacter.MyChar[MyCharPos].Equip[type].ItemUID = ItemUID;*/
                }

                // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                ip.Skip(99);
            }

            // 패킷 구조 똑같이 보내면 된다.
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_EQUIP_ITEM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length * 2);
                oPacket.WriteUnicodeString(cs.Login);
                oPacket.WriteInt(0);
                oPacket.WriteByte((byte)cs.MyCharacter.MyChar.Length);

                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteByte(); // 00 00 00
                        oPacket.WriteByte(); //
                        oPacket.WriteByte(); //
                    }

                    // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                    oPacket.Skip(99);
                }

                oPacket.WriteInt(0); // 그냥

                oPacket.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }

            if (cs.CurrentRoom == null)
            {
                return;
            }

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_EQUIP_ITEM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length);
                oPacket.WriteUnicodeString(cs.Login);

                oPacket.WriteByte(2); // ???

                oPacket.WriteInt(cs.MyCharacter.MyChar.Length);
                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(0); // 00 00 00 00
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteByte(); // 00 00 00
                        oPacket.WriteByte(); //
                        oPacket.WriteByte(); //
                    }

                    oPacket.Skip(61);
                    oPacket.WriteHexString("FF FF");
                    oPacket.Skip(32);
                    oPacket.WriteInt(cs.LoginUID);
                }

                for (int i = 0; i < 6; i++)
                {
                    if (cs.CurrentRoom.Slot[i].Active == true)
                    {
                        oPacket.CompressAndAssemble(cs.CurrentRoom.Slot[i].cs.CRYPT_KEY, cs.CurrentRoom.Slot[i].cs.CRYPT_HMAC, cs.CurrentRoom.Slot[i].cs.CRYPT_PREFIX, cs.CurrentRoom.Slot[i].cs.CRYPT_COUNT);
                        cs.CurrentRoom.Slot[i].cs.Send(oPacket);
                        oPacket.CancelAssemble();
                    }
                }
            }
        }
Esempio n. 4
0
        public void OnEquipItem(ClientSession cs, InPacket ip)
        {
            int    LoginIDLen = ip.ReadInt();
            string LoginID    = ip.ReadUnicodeString(LoginIDLen);

            ip.ReadInt(); // 00 00 00 00
            byte CharNum = ip.ReadByte();

            for (byte i = 0; i < CharNum; i++)
            {
                byte TargetChar = ip.ReadByte();
                int  EquipCount = ip.ReadInt();

                int MyCharPos = -1;
                for (int t = 0; t < cs.MyCharacter.MyChar.Length; t++)
                {
                    if (cs.MyCharacter.MyChar[t].CharType == TargetChar)
                    {
                        MyCharPos = t;
                    }
                }

                // 내가 가진 캐릭터 목록에 없다
                if (MyCharPos == -1)
                {
                    continue;
                }

                Array.Resize(ref cs.MyCharacter.MyChar[MyCharPos].Equip, EquipCount);

                for (int j = 0; j < EquipCount; j++)
                {
                    int ItemID = ip.ReadInt();
                    ip.ReadInt();  // 00 00 00 01
                    int ItemUID = ip.ReadInt();
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadInt();  // 00 00 00 00
                    ip.ReadByte(); // 00 00 00
                    ip.ReadByte(); //
                    ip.ReadByte(); //

                    cs.MyCharacter.MyChar[MyCharPos].Equip[j].ItemID  = ItemID;
                    cs.MyCharacter.MyChar[MyCharPos].Equip[j].ItemUID = ItemUID;
                }

                // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                ip.Skip(99);
            }

            // 패킷 구조 똑같이 보내면 된다.
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_EQUIP_ITEM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length * 2);
                oPacket.WriteUnicodeString(cs.Login);
                oPacket.WriteInt(0);
                oPacket.WriteByte((byte)cs.MyCharacter.MyChar.Length);

                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteByte(); // 00 00 00
                        oPacket.WriteByte(); //
                        oPacket.WriteByte(); //
                    }

                    // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                    oPacket.Skip(99);
                }

                oPacket.WriteInt(0); // 그냥

                oPacket.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }

            // 내가 지금 방에 입장하고 있으면 방 인원한테 장비가 바뀌었다고 알려준다.
            if (cs.CurrentRoom == null)
            {
                return;
            }

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_EQUIP_ITEM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length);
                oPacket.WriteUnicodeString(cs.Login);

                oPacket.WriteByte(2); // ???

                oPacket.WriteInt(cs.MyCharacter.MyChar.Length);
                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(0); // 00 00 00 00
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteInt();  // 00 00 00 00
                        oPacket.WriteByte(); // 00 00 00
                        oPacket.WriteByte(); //
                        oPacket.WriteByte(); //
                    }

                    oPacket.Skip(61);
                    oPacket.WriteHexString("FF FF");
                    oPacket.Skip(32);
                    oPacket.WriteInt(cs.LoginUID);
                }

                // 방에 있는 모든 유저에게 전송해야함.
                for (int i = 0; i < 6; i++)
                {
                    if (cs.CurrentRoom.Slot[i].Active == true)
                    {
                        oPacket.CompressAndAssemble(cs.CurrentRoom.Slot[i].cs.CRYPT_KEY, cs.CurrentRoom.Slot[i].cs.CRYPT_HMAC, cs.CurrentRoom.Slot[i].cs.CRYPT_PREFIX, cs.CurrentRoom.Slot[i].cs.CRYPT_COUNT);
                        cs.CurrentRoom.Slot[i].cs.Send(oPacket); // 패킷 보내고
                        oPacket.CancelAssemble();                // 다시 패킷 복구
                    }
                }
            }
        }