Example #1
0
        public static void HandleMovement(Character chr, byte[] tx, byte[] ty, byte mMode)
        {
            if(chr == null) {
                Logger.LogCheat(Logger.HackTypes.NullActive, chr.getAccount().mClient, "Wrong target has been selected by moving packet");
                chr.getAccount().mClient.Close();
                return;
            }

            Area lastArea = chr.getArea();
            Boolean nullify = false;
            if(lastArea == null)
                nullify = true;

            Area newArea = WMap.Instance.getGrid(chr.getMap()).getAreaByRound(chr.getPosition()[0], chr.getPosition()[1]);

            if(newArea == null)
            {
                CharacterFunctions.warpToNearestTown(chr);
                return;
            }

            if(!nullify) {
                if(lastArea != newArea) {
                    lastArea.removeCharacter(chr);
                    newArea.addCharacter(chr);
                    chr.setArea(newArea);
                }
            }
            else if(nullify) {
                newArea.addCharacter(chr);
                chr.setArea(newArea);
            }

            OutPacket p = new OutPacket(56);
            p.WriteInt(56);
            p.WriteShort(0x04);
            p.WriteShort(0x0d);
            p.WriteInt	();
            p.WriteInt	(chr.getuID());
            p.WriteFloat(chr.getPosition()[0]);
            p.WriteFloat(chr.getPosition()[1]);
            p.WriteBytes(tx); //2nd set
            p.WriteBytes(ty);
            p.WriteInt	(newArea.getaID());
            p.WriteShort();
            p.WriteByte	((byte)0x80);
            p.WriteByte	((byte)0x3f);
            p.WriteByte	(mMode);
            p.WriteByte	((byte)0x03);
            p.WriteByte	((byte)0x05);
            p.WriteByte	((byte)0x08);
            p.WriteInt	(chr.getCurHP());
            p.WriteShort(chr.getCurMP());
            p.WriteShort(chr.getCurSP());
            p.WriteInt(newArea.getRegionID());
            chr.getAccount().mClient.WriteRawPacket(p.ToArray());

            OutPacket externalMovement = new OutPacket(48);
            externalMovement.WriteInt(48);
            externalMovement.WriteShort(0x05);
            externalMovement.WriteShort(0x0d);
            externalMovement.WriteInt((newArea != lastArea) ? (0x01) : (-1084232447));
            externalMovement.WriteInt(chr.getuID());
            externalMovement.WriteInt(1078117293);
            externalMovement.WriteFloat(chr.getPosition()[0]);
            externalMovement.WriteFloat(chr.getPosition()[1]);
            externalMovement.WriteBytes(tx);
            externalMovement.WriteBytes(ty);
            externalMovement.WriteShort(mMode); // who knows? | 36
            externalMovement.WriteShort((short)newArea.getaID());
            externalMovement.WriteShort();
            externalMovement.WriteByte(0x80);
            externalMovement.WriteByte(0x3f);
            externalMovement.WriteInt((newArea != lastArea) ? (0x05) : (0x03));

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaMovement(chr, newArea, externalMovement.ToArray());

            bool areaTriggered = false;
            for(int i = 0;i < 3;i++)
            {
                for(int u = 0;u < 3;u++)
                {
                    Area nearCentral = WMap.Instance.getGrid(chr.getMap()).getArea(new int[] { newArea.getAreaPosition()[0] - 1 + i, newArea.getAreaPosition()[1] - 1 + u });
                    if(nearCentral == null) continue;
                    if(nearCentral.getAreaTriggers().Count() == 0) continue;
                    {
                        foreach(AreaTrigger areaTrigger in nearCentral.getAreaTriggers())
                        {
                            if((WMap.distance(chr.getPosition()[0], chr.getPosition()[1], areaTrigger.getFromPosition()[0], areaTrigger.getFromPosition()[1]) > 35)) continue;
                            if(!CharacterFunctions.isCharacterWearingItem(chr, areaTrigger.getRequiredItem())) continue;
                            try
                            {
                                areaTriggered = true;
                                CharacterFunctions.setPlayerPosition(chr, areaTrigger.getToPosition()[0], areaTrigger.getToPosition()[1], areaTrigger.gettMap());
                            }
                            catch(Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        }
                    }
                }
            }
            if(!areaTriggered) chr.setPosition(new float[] { (float)BitTools.byteArrayToFloat(tx), (float)BitTools.byteArrayToFloat(ty) });
        }
Example #2
0
        public static void initNPCsForCharacter(Character chr, List<NPC> npcs)
        {
            if(npcs.Count == 0)
                return;

            OutPacket all = new OutPacket((npcs.Count() * 589) + 30);
            all.WriteInt((npcs.Count() * 589) + 30);
            all.WriteShort(4);
            all.WriteShort(4);
            all.WriteByte(1);
            all.WriteInt(chr.getuID());
            all.WriteInt(chr.getArea().getaID());
            all.WriteFloat(chr.getPosition()[0]);
            all.WriteFloat(chr.getPosition()[1]);
            foreach(NPC npc in npcs)
            {
                all.WriteBytes(npc.npcSpawnChained(chr));
            }
            all.WriteByte();
            all.WriteInt(3560);
            chr.getAccount().mClient.WriteRawPacket(all.ToArray());

            Console.WriteLine("npc init package length: {0}", all.ToArray().Length);
        }
Example #3
0
        public static byte[] initCharacters(Account acc, bool backSpawn = false)
        {
            OutPacket all = new OutPacket((acc.characters.Count() * 653) + 8 + 3);
            all.WriteInt((acc.characters.Count() * 653) + 8 + 3);
            all.WriteShort(0x03);
            all.WriteShort((!backSpawn) ? ((byte)0x04) : ((byte)0x01));
            all.WriteBytes(new byte[] { (byte)0x01, (byte)0x01, (byte)0x01 });

            int multipier_keeper = 0x01;
            Boolean multiplied = false;

            foreach(Character chara in acc.characters.Values) {
                all.WriteBytes(CharacterPackets.initCharPacket(chara));

                if(multiplied)
                    multipier_keeper = (multipier_keeper * 2) + 1;
                if(!multiplied)
                    multiplied = true;
            }

            all.Position = 10;
            all.WriteByte((byte)multipier_keeper);
            return all.ToArray();
        }
Example #4
0
        public static void ViewInventory(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked viewInventory with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(28);
            op.WriteInt(28);
            op.WriteShort(0x04);
            op.WriteShort(0x1e);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(0xf8);
            op.WriteByte(0x01);

            p.Skip(4);

            op.WriteBytes(p.ReadBytes(4));
            op.WriteByte(0x9e);
            op.WriteByte(0x0f);
            op.WriteByte(0xbf);
            c.WriteRawPacket(op.ToArray());
        }
Example #5
0
        public static void MoveOrUnequip(MartialClient c, InPacket p)
        {
            Console.WriteLine("move or unequip");

            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook invManag while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(12);
            byte[] amountByte = { decrypted[8], decrypted[9], decrypted[10], decrypted[11] };
            int amount = BitTools.byteArrayToInt(amountByte);

            if(decrypted[0] == (byte)0x00)
            {
                if(!chr.getInventory().unequipItem(decrypted[1], decrypted[4], decrypted[3], chr.getEquipment()))
                {
                    Console.WriteLine("problem with unequipItem");
                    return;
                }

                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, decrypted[1], 0));
            }
            else
            {
                if(!chr.getInventory().moveItem(decrypted[1], decrypted[2], amount, decrypted[4], decrypted[3]))
                {
                    Console.WriteLine("problem with move item");
                    return;
                }
            }

            OutPacket op = new OutPacket(28);
            op.WriteInt(28);
            op.WriteShort(0x04);
            op.WriteShort(0x10);
            op.WriteInt();
            op.WriteInt(c.getAccount().activeCharacter.getuID());
            op.WriteShort(0x01);
            op.WriteBytes(new byte[] { decrypted[0], decrypted[1], decrypted[2], decrypted[3], decrypted[4] });
            op.WriteByte();
            op.WriteBytes(new byte[] { decrypted[8], decrypted[9], decrypted[10], decrypted[11] });
            c.WriteRawPacket(op.ToArray());

            CharacterFunctions.calculateCharacterStatistics(chr);
        }
Example #6
0
        public static void Equip(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook equip while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte changeType = p.ReadByte();
            byte[] swapSlots = p.ReadBytes(2);

            if(changeType == (byte)0x00)
            {
                if(!chr.getEquipment().swapEquips(swapSlots[0], swapSlots[1]))
                {
                    Logger.LogCheat(Logger.HackTypes.Equip, c, "Attempted to swap weapons, while one of them or even both are null.");
                    c.Close();
                    return;
                }

                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[0], chr.getEquipment().getEquipments()[swapSlots[0]].getItemID()));
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[1], chr.getEquipment().getEquipments()[swapSlots[1]].getItemID()));
            }
            else
            {
                if(!chr.getInventory().equipItem(swapSlots[0], swapSlots[1], chr.getEquipment()))
                {
                    Console.WriteLine("so sorz : >");
                    return;
                }

                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[1], chr.getEquipment().getEquipments()[swapSlots[1]].getItemID()));
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(0x04);
            op.WriteShort(0x0c);
            op.WriteInt(135593729);
            op.WriteInt(c.getAccount().activeCharacter.getuID());
            op.WriteShort(0x01);
            op.WriteByte(changeType);
            op.WriteBytes(swapSlots);
            c.WriteRawPacket(op.ToArray());

            CharacterFunctions.calculateCharacterStatistics(chr);
        }
Example #7
0
        public static void CraftItem(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook craftItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            int craftingID = p.ReadInt();
            int manualInventoryIndex = p.ReadInt(); // better to be sure, than be rzaah XD
            if(manualInventoryIndex < 0)
            {
                Console.WriteLine("manuel < 0");
                return;
            }

            Inventory inv = chr.getInventory();
            inv.updateInv();

            List<int> seq = new List<int>(inv.getSeqSaved());
            Dictionary<int, Item> items = new Dictionary<int, Item>(inv.getInvSaved());

            if(!items.ContainsKey(seq[manualInventoryIndex]))
            {
                Console.WriteLine("unknown item at index {0}", manualInventoryIndex);
                return;
            }
            Item item = items[seq[manualInventoryIndex]];

            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());
            if(itemData == null)
            {
                Console.WriteLine("unknown itemdata for item of ID {0}", item.getItemID());
                return;
            }

            if(itemData.getCategory() != 1010)
            {
                Console.WriteLine("dat shit ain't manual");
                return;
            }

            ManualData manual = ManualDataCache.Instance.getManualData(craftingID);
            if(manual == null)
            {
                Console.WriteLine("manual wasn't found..");
                return;
            }

            List<Item> providedMaterials = new List<Item>();
            List<int> providedMaterialID = new List<int>();
            List<int> providedMaterialQa = new List<int>();
            List<int> providedMaterialIndex = new List<int>();
            for(int i = 0;i < 8;i++)
            {
                int tempMaterialIndex = p.ReadInt();
                Console.WriteLine("indexez of provided mats {0}", tempMaterialIndex);
                if(tempMaterialIndex == -1)
                    break;
                if(seq.ElementAt(tempMaterialIndex) == -1)
                    return;
                if(!items.ContainsKey(seq[tempMaterialIndex]))
                    return;
                Item tempMaterial = items[seq[tempMaterialIndex]];
                if(tempMaterial == null)
                {
                    Console.WriteLine("unknown tempMaterial at index {0}", tempMaterialIndex);
                    return;
                }
                if(tempMaterial.getQuantity() < 1)
                {
                    Console.WriteLine("tempMaterial has less than 1 quantity :< {0}", tempMaterialIndex);
                    return;
                }
                providedMaterials.Add(tempMaterial);
                providedMaterialID.Add(tempMaterial.getItemID());
                providedMaterialQa.Add(tempMaterial.getQuantity());
                providedMaterialIndex.Add(tempMaterialIndex);
            }

            if(providedMaterials.Count == 0)
            {
                Console.WriteLine("playa doesn't supplied materials at all");
                return;
            }

            List<int> deductedAmount = new List<int>(providedMaterialQa);

            List<int> requiredMaterialID = manual.getRequiredMaterials();
            List<int> requiredMaterialQa = manual.getRequiredQuantities();
            for(int i=0;i<providedMaterials.Count;i++) // let's check if playa has satisfied our data provided manual <3
            {
                if(providedMaterialQa[i] < 1)
                    continue;
                for(int x=0;x<requiredMaterialID.Count;x++)
                {
                    if(requiredMaterialQa[x] <= 0)
                        continue;
                    if(requiredMaterialID[x] == providedMaterialID[i])
                    {
                        if(requiredMaterialQa[x] >= providedMaterialQa[i])
                        {
                            requiredMaterialQa[x] -= providedMaterialQa[i];
                            providedMaterialQa[i] = 0;
                        }
                        else
                        {
                            int tempQa = requiredMaterialQa[x];
                            requiredMaterialQa[x] = 0;
                            providedMaterialQa[i] -= tempQa;
                        }
                    }
                }
            }

            if(requiredMaterialQa.Sum() != 0)
            {
                Console.WriteLine("user hasn't applied all of the needed materialz, damn cheatz");
                return;
            }

            int craftedItemID = manual.getProducedItemID();

            p.Position = 73;
            int row = p.ReadByte();
            int line = p.ReadByte();
            if(!inv.craftItem(new Item(craftedItemID)))
            {
                Console.WriteLine("InvCraftItem > Cannot craft item");
                return;
            }

            for(int i = 0;i < providedMaterialIndex.Count;i++)
            {
                if(!inv._decrementItem(providedMaterialIndex[i], providedMaterialQa[i]))
                {
                    Console.WriteLine("damn..?");
                }
            }

            if(!inv._decrementItem(manualInventoryIndex))
            {
                Console.WriteLine("damn man, again, wut happend to u?");
            }

            OutPacket op = new OutPacket(168); // 'it has succeded all the checks n stuff now on to kfc.' - cause we all luv Rzaah
            op.WriteInt(168);
            op.WriteShort(0x04);
            op.WriteShort(0x28);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteInt(0x01);
            p.Position = 4;
            op.WriteBytes(p.ReadBytes(68));
            op.WriteInt(1);
            for(int i = 0;i < 8;i++)
            {
                if(providedMaterialIndex.Count > i)
                {
                    op.WriteInt(deductedAmount[i] - providedMaterialQa[i]);
                } else op.WriteInt(0);
            }
            /* end_time - TODO:
             * op.Position = 153;
             * op.WriteByte(0xff); */
            op.Position = 154;
            p.Position = 73;
            op.WriteShort(p.ReadShort());
            op.WriteInt(craftedItemID);
            /* end_time - TODO:
             * op.WriteInt(craftedItem.getExpiration()); */
            op.WriteInt(); // meanwhile..
            p.Position = 72;
            op.WriteBytes(p.ReadBytes(4));
            c.WriteRawPacket(op.ToArray());

            inv.saveInv();
        }