Ejemplo n.º 1
0
        // Holy Grail ftw
        public static void useItem(Character chr, Item item, byte usingIndex, InPacket p)
        {
            MartialClient c = chr.getAccount().mClient;
            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());
            Boolean shouldDecrease = false;
            string determined = null;
            int determiner = 0;
            if(itemData.getIsStackable()) shouldDecrease = true;
            else
            {
                if(itemData.getTimeToExpire() == 0)
                    shouldDecrease = true;
            }

            // well.. we don't care if it's handled by server.. let's just remove them & f**k haterz! qq
            if(shouldDecrease)
                if(!chr.getInventory().decrementItem(usingIndex))
                {
                    Console.WriteLine("something went wrong with decrement..");
                    return;
                }

            switch(itemData.getCategory())
            {
                case 1001: // healingz
                {
                    if(itemData.getHealHP() > 0 || itemData.getHealMana() > 0 || itemData.getHealStamina() > 0)
                        StaticPackets.releaseHealPacket(chr, (int)(chr.getCurHP() + itemData.getHealHP()), (short)(chr.getCurMP() + itemData.getHealMana()), (short)(chr.getCurSP() + itemData.getHealStamina()));
                    break;
                }
                case 1002: // skillz o.o
                {
                    StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "If you'd like to learn any skill, go to skills list and press CTRL+LMB.");
                    break;
                }
                case 1003: // teleport
                {
                    if(chr.getMap() == itemData.getTeleportMap() || chr.getMap() != itemData.getTeleportMap() && itemData.getSpecialEffect() != 0)
                        CharacterFunctions.setPlayerPosition(chr, itemData.getTeleportX(), itemData.getTeleportY(), (short)itemData.getTeleportMap());
                    break;
                }
                case 1007: // reset skills
                {
                    chr.getSkills().resetAll();
                    chr.getSkillBar().getSkillBar().Clear();
                    break;
                }
                case 1011: // effect potions
                {
                    chr.setEffect((byte)itemData.getSpecialEffect());
                    break;
                }
                case 1012: // tae potion
                {
                    break;
                }
                case 1013: // faction change
                {
                    if(chr.getFaction() == 0)
                        return;

                    chr.setFaction(chr.getFaction() == 1 ? (byte)2 : (byte)1);
                    break;
                }
                case 1015: // chuk amulet
                {
                    determiner = BitConverter.ToInt32(p.ReadBytes(4), 0);
                    if(determiner == 0) return;
                    ItemData determinedItem = ItemDataCache.Instance.getItemData(determiner);
                    if(determinedItem == null || determinedItem.getCategory() != 1003 || (determiner < 212100146 && determiner > 212100164 && determiner != 212100185 && determiner != 212100187))
                    {
                        Console.WriteLine("I CAN'T TURN 10 INTO 20 CHICKENZ");
                        return;
                    }
                    CharacterFunctions.setPlayerPosition(chr, determinedItem.getTeleportX(), determinedItem.getTeleportY(), (short)determinedItem.getTeleportMap());
                    break;
                }
                case 1016: // karma amulet
                {
                    chr.setKarmaMessagingTimes((short)(chr.getKarmaMessagingTimes()+1));
                    break;
                }
                case 1020: // name changer
                {
                    p.Skip(4);
                    string charName = MiscFunctions.obscureString(p.ReadString(16));
                    if(charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName))
                    {
                        StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "Wrong input " + charName + ".");
                        return;
                    }

                    chr.setName(charName);
                    determined = charName;

                    CharacterFunctions.refreshCharacterForTheWorld(chr);
                    break;
                }
                case 1021: // face changer
                {
                    chr.setFace((byte)itemData.getSpecialEffect());
                    break;
                }
                case 1024:
                {
                    // yy..?
                    break;
                }
                case 1031: // red castle
                {
                    determiner = BitConverter.ToInt32(p.ReadBytes(4), 0);
                    if(determiner == 0) return;
                    ItemData determinedItem = ItemDataCache.Instance.getItemData(determiner);
                    if(determinedItem == null || determinedItem.getCategory() != 56 || ((determiner < 273001255 && determiner > 273001257) && determiner != 283000472 && determiner != 283000543 && determiner != 283000575 && determiner != 283000614 && determiner != 283000934 && determiner != 283001078 && determiner != 283001373 && determiner != 283001376))
                    {
                        Console.WriteLine("I CAN'T TURN 10 INTO 20 CHICKENZ");
                        return;
                    }
                    CharacterFunctions.setPlayerPosition(chr, determinedItem.getTeleportX(), determinedItem.getTeleportY(), (short)determinedItem.getTeleportMap());
                    break;
                }
                default:
                {
                    StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "Feature not implemented yet");
                    return;
                }
            }

            OutPacket op = new OutPacket(52);
            op.WriteInt(52);
            op.WriteShort(0x04);
            op.WriteShort(0x05);
            op.WriteInt(140328705);
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(0x01);
            op.WriteByte(usingIndex);
            op.WriteInt(item.getQuantity());
            op.WriteInt(793149441);
            op.WriteInt(/*determiner > 0 ? determiner : 0*/);
            op.WritePaddedString(determined, 17);
            op.WriteByte(0x90);
            op.WriteByte(0xd2);
            op.WriteByte(0x2a);
            c.WriteRawPacket(op.ToArray());

            OutPacket ops = new OutPacket(40);
            ops.WriteInt(40);
            ops.WriteShort(0x05);
            ops.WriteShort(0x05);
            ops.WriteInt(779458561);
            ops.WriteInt(chr.getuID());
            ops.WriteInt(item.getItemID());
            ops.WritePaddedString(determined, 17);
            ops.WriteByte(0x9e);
            ops.WriteByte(0x0f);
            ops.WriteByte(0xbf);
            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), ops.ToArray());
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
 public static void releaseGeneralQuestPacket(Character chr, byte karma = 0x0, byte penance = 0x0, int fame = 0x0, long exp = 0x0, long money = 0x0, byte guildPos = 0x0, byte faction = 0x0)
 {
     OutPacket op = new OutPacket(64);
     op.WriteInt(64);
     op.WriteShort(0x05);
     op.WriteShort(0x3b);
     op.WriteInt(715218689);
     op.WriteInt(chr.getuID());
     op.WriteByte(0x0); // karma
     op.WriteByte(0x0); // penance
     op.WriteShort(); // ?
     op.WriteByte(FameNickNames.Instance.getFameNickID(fame != 0x0 ? fame : chr.getFame()) > 0 ? (byte)1 : (byte)0); // appear player name above the head
     op.WriteByte(FameNickNames.Instance.getFameNickID(fame != 0x0 ? fame : chr.getFame())); // fame nickname
     op.WriteByte(chr.getAccount().gmLvl > 0 ? (byte)1 : (byte)0); // blue nickname??
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteInt(fame != 0x0 ? fame : chr.getFame()); // fame
     op.WriteReversedLong(exp != 0x0 ? exp : chr.getExp()); // exp
     op.WriteLong(money != 0x0 ? money : chr.getCoin()); // money
     op.WriteByte(guildPos != 0x0 ? guildPos : (byte)0x0); // Guild Pos | TODO
     op.WriteByte(faction != 0x0 ? faction : chr.getFaction()); // Faction
     op.WriteByte(2); // 0 - gives an yellow message (?) | 1 - hides inventory
     Console.WriteLine(BitConverter.ToString(op.ToArray()));
     chr.getAccount().mClient.WriteRawPacket(op.ToArray());
 }
Ejemplo n.º 4
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();
        }