Exemplo n.º 1
0
        public static byte[] extCharPacket(Character chr)
        {
            byte[] cedata = new byte[616];
            short length = (short)cedata.Length;
            byte[] lengthbytes = BitTools.shortToByteArray(length);
            byte[] chID = BitTools.intToByteArray(chr.getuID());
            byte[] chName = Encoding.ASCII.GetBytes(chr.getName());
            byte[] xCoords = BitTools.floatToByteArray(chr.getPosition()[0]);
            byte[] yCoords = BitTools.floatToByteArray(chr.getPosition()[1]);

            cedata[0] = lengthbytes[0];
            cedata[1] = lengthbytes[1];
            cedata[4] = (byte)0x05;
            cedata[6] = (byte)0x01;
            cedata[8] = (byte)0x01;

            for(int i = 0;i < 4;i++) {
                cedata[i + 12] = chID[i]; //character ID
                cedata[i + 88] = xCoords[i]; //location x
                cedata[i + 92] = yCoords[i]; //location y
            }

            for(int i = 0;i < chName.Length;i++) {
                cedata[i + 20] = chName[i]; //characters Name
            }

            for(int i = 0;i < 16;i++) {
                cedata[37 + i] = (byte)0x30; //character packets have 16 times 30(0 in ASCII) in row. Mysteries of CRS.
            }

            if(chr.getcClass() == 2) {
                cedata[60] = (byte)0x02; //gender byte
                cedata[68] = (byte)0x02; //class byte
            }
            else {
                cedata[60] = (byte)0x01; //gender byte
                cedata[68] = (byte)chr.getcClass(); //class byte
            }

            cedata[54] = (byte)chr.getFaction(); //faction

            cedata[62] = (byte)chr.getFace();  //face

            cedata[74] = (byte)chr.getLevel();   //level

            //equip
            byte[] bytes;
            for(byte i = 0;i < 17;i++) {
                if(chr.getEquipment().getEquipments().ContainsKey(i)) {
                    bytes = BitTools.intToByteArray(chr.getEquipment().getEquipments()[i].getItemID());
                    for(int j = 0;j < 4;j++) {
                        cedata[100 + i * 12 + j] = bytes[j];
                    }
                }
            }

            //if(ch.getPt() != null && receiver.getPt() != null && ch.getPt().getPartyDuel() != null && ch.getPt().getPartyDuel() == receiver.getPt().getPartyDuel() && ch.isInPtDuel() && receiver.isInPtDuel()) cedata[480] = (byte)2;          //fakekao
            //else cedata[480] = (byte)ch.getKao();      //kao

            cedata[482] = (byte)chr.getEffect();   //size

            cedata[484] = (byte)FameNickNames.Instance.getFameNickID(chr.getFame()); //Fame title

            if(chr.getAccount().gmLvl > 0)
                cedata[486] = (byte)0x01; // gm name

            cedata[610] = (byte)0x50;
            cedata[611] = (byte)0x2a;

            return cedata;
        }
Exemplo n.º 2
0
        public static byte[] initCharPacket(Character chr)
        {
            OutPacket op = new OutPacket(653);
            op.WritePaddedString(chr.getName(), 17); // 0-16
            op.WriteRepeatedByte(0x30, 16); // 17-32
            op.WriteByte();
            op.WriteShort(chr.getFaction()); // 34-35
            op.WriteInt(chr.getFame()); // 36-39
            op.WriteShort(chr.getcClass() == 2 ? (byte)0x02 : (byte)0x01); // 40-41
            op.WriteShort(chr.getFace()); // 42-43
            op.WriteInt(1);
            op.WriteShort(chr.getcClass()); // 48-49
            op.WriteShort(157); // 50-51 ; 1 -> hide player nick above the head & toggles guild on [1] / off [0] | 157 for random 154 warrior [probably guildType or guildIcon!! (important!!)]
            op.WriteShort(2); // 52-53 ; 7 -> 137 monk // your guild pos master/member etc.
            op.WriteShort(chr.getLevel()); // 54-55
            op.WriteInt(chr.getCurHP()); // 56-59
            op.WriteInt(chr.getCurMP()); // 60-63 but wtf.. mana is short o.o
            op.WriteInt(chr.getMap()); // 64-67 let's guess.. a map?
            op.WriteFloat(chr.getPosition()[0]); // 68-71
            op.WriteFloat(chr.getPosition()[1]); // 72-75
            for(byte i = 0;i < 17;i++)
            {
                if(chr.getEquipment().getEquipments().ContainsKey(i))
                {
                    op.WriteByte();
                    op.WriteByte(chr.getEquipment().getEquipments()[i].getEnding() > 0 ? (byte)0xff : (byte)0);
                    op.WriteShort();
                    op.WriteInt(chr.getEquipment().getEquipments()[i].getItemID());
                    op.WriteInt(chr.getEquipment().getEquipments()[i].getEnding() > 0 ? (int)chr.getEquipment().getEquipments()[i].getEnding() / 1000 : 1);
                } else op.WriteZero(12);
            }

            op.Position = 465;
            op.WriteByte(70);

            op.Position = 314;
            for(byte i = 0;i < 16;i++)
            {
                /*if(character.getBuffs().getBuffs().ContainsKey(i)) {
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffSlot());
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffID());
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffTime());
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffValue());
                } else*/
                op.Skip(8);
            }

            op.Skip(16);

            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteByte(/*character.getKao()*/);
            op.WriteByte(/*character.getPenance()*/);
            op.WriteByte(chr.getEffect());
            op.WriteByte(0); // no explanation
            op.WriteByte(FameNickNames.Instance.getFameNickID(chr.getFame()));
            op.WriteByte(chr.getVp()); // 465
            op.WriteByte((byte)chr.getAccount().gmLvl); // 466
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // -> 1 -> tells the client that UI mutation effect should be toggled off | 468
            op.WriteByte((byte)(chr.getInvPages() - 3)); // inventory pages | 469
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteShort(0); /*weird PK thing*/ // 472 - 473 but in fact.. it has some date time etc.
            op.WriteLong(0); // 474 - 481

            op.Position = 560;
            op.WriteInt(1); // ok.. so this is kinda weird - last place where you've leveled / died with your character?
            op.WriteFloat(-2558); // unknown posX
            op.WriteFloat(8950); // unknown posY
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            for(int i = 0;i < chr.getCStats().Length;i++) op.WriteShort(chr.getCStats()[i]); // 576-577 / 578-579 / 580-581 / 582-583 / 584-585
            op.WriteShort(chr.getCurSP());
            op.WriteInt();
            op.WriteInt();

            op.WriteLong();
            op.WriteShort(chr.getStatPoints());
            op.WriteShort(chr.getSkillPoints()); // 606-607
            op.Position = 648;
            op.WriteByte(Convert.ToByte(chr.getDeleteState()));
            return op.ToArray();
        }