Esempio n. 1
0
        public static void RequestSpawn(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter != null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to spawn a character while being ingame.");
                c.Close();
                return;
            }

            byte selected_character = p.ReadByte();

            if (!c.getAccount().characters.ContainsKey(selected_character))
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Wrong target '{0}' has been selected by selection packet", selected_character);
                c.Close();
                return;
            }

            Character target = c.getAccount().characters[selected_character];

            c.getAccount().activeCharacter = target;

            WMap.Instance.addToCharacters(target);
            CharacterFunctions.setPlayerPosition(target, target.getPosition()[0], target.getPosition()[1], target.getMap());
            CharacterFunctions.calculateCharacterStatistics(target);
            StaticPackets.sendSystemMessageToClient(c, 1, Constants.WelcomeMessage);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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());
        }
Esempio n. 4
0
        public static void AttackDefendState(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(0x05);
            op.WriteShort(0x06);
            op.WriteByte(0x01);
            op.WriteByte(0x33);
            op.WriteByte(0x15);
            op.WriteByte(0x08);
            op.WriteInt(chr.getuID());
            op.WriteShort(p.ReadByte());
            op.WriteByte(0x10);
            op.WriteByte(0x29);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), op.ToArray());
        }
Esempio n. 5
0
        public static void SendMessage(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook SendMessage handling while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            int    messageType = p.ReadInt();          // identifier of message type maybe?
            string receiver    = p.ReadString(20);     // receiver name

            MiscFunctions.obscureString(receiver);
            if (!MySQLTool.NameTaken(receiver))
            {
                return;
            }
            int    messageLength = p.ReadInt();          // message length
            string message       = p.ReadString(messageLength);

            MiscFunctions.obscureString(message);

            OutPacket op = new OutPacket(20);

            op.WriteInt(20);
            op.WriteShort(4);
            op.WriteShort(0x53);
            op.WriteInt(718349825);
            op.WriteInt(chr.getuID());
            op.WriteInt(-1089732352);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 6
0
        public static void AttackDefendState(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(0x05);
            op.WriteShort(0x06);
            op.WriteByte(0x01);
            op.WriteByte(0x33);
            op.WriteByte(0x15);
            op.WriteByte(0x08);
            op.WriteInt(chr.getuID());
            op.WriteShort(p.ReadByte());
            op.WriteByte(0x10);
            op.WriteByte(0x29);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), op.ToArray());
        }
Esempio n. 7
0
        public static void LauncherValidate(MartialClient c, InPacket p)
        {
            byte pinLength = p.ReadByte();
            byte uNameLength = p.ReadByte();
            byte passWLength = p.ReadByte();
            p.ReadByte();
            string pin = MiscFunctions.obscureString(p.ReadString(4));
            string uN = MiscFunctions.obscureString(p.ReadString(16));
            string pW = MiscFunctions.obscureString(p.ReadString(12));

            Account account = new Account();
            if(account.Load(uN, pW, pin) != Account.AccountLoadErrors.Success)
            {
                c.WriteRawPacket(Constants.accDoesntExist);
                Logger.WriteLog(Logger.LogTypes.HEmi, "Authorization error for [{0} | {1} | {2}]", uN, pW, pin);
                c.Close();
                return;
            }
            Logger.WriteLog(Logger.LogTypes.HEmi, "User passed authorization [{0} | {1} | {2}]", uN, pW, pin);
            account.mClient = c;
            c.setAccount(account);
            account.LoadCharacters();

            if(c.getAccount().characters.Count() > 0)
            {
                c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), false).Concat(Constants.emptyAccount).ToArray());
            }
            c.WriteRawPacket(Constants.emptyAccount);
            c.WriteRawPacket(LoginPacketCreator.initAccount(c.getAccount()));
        }
Esempio n. 8
0
        public static void DeleteItem(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook deleteItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(2);
            if (!chr.getInventory().removeItem(decrypted[1]))
            {
                Console.WriteLine("qq cant remove");
                return;
            }

            OutPacket op = new OutPacket(20);

            op.WriteInt(20);
            op.WriteShort(0x04);
            op.WriteShort(0x15);
            op.WriteInt();
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(decrypted[0]);
            op.WriteByte(decrypted[1]);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 9
0
        public static void LauncherValidate(MartialClient c, InPacket p)
        {
            byte pinLength   = p.ReadByte();
            byte uNameLength = p.ReadByte();
            byte passWLength = p.ReadByte();

            p.ReadByte();
            string pin = MiscFunctions.obscureString(p.ReadString(4));
            string uN  = MiscFunctions.obscureString(p.ReadString(16));
            string pW  = MiscFunctions.obscureString(p.ReadString(12));

            Account account = new Account();

            if (account.Load(uN, pW, pin) != Account.AccountLoadErrors.Success)
            {
                c.WriteRawPacket(Constants.accDoesntExist);
                Logger.WriteLog(Logger.LogTypes.HEmi, "Authorization error for [{0} | {1} | {2}]", uN, pW, pin);
                c.Close();
                return;
            }
            Logger.WriteLog(Logger.LogTypes.HEmi, "User passed authorization [{0} | {1} | {2}]", uN, pW, pin);
            account.mClient = c;
            c.setAccount(account);
            account.LoadCharacters();

            if (c.getAccount().characters.Count() > 0)
            {
                c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), false).Concat(Constants.emptyAccount).ToArray());
            }
            c.WriteRawPacket(Constants.emptyAccount);
            c.WriteRawPacket(LoginPacketCreator.initAccount(c.getAccount()));
        }
Esempio n. 10
0
        public static void UnknownStatimizer(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(47);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteByte();
            op.WriteByte();
            op.WriteByte(1);
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();             // ok, there's some magic on those bytes, for ex. 3rd byte tells you, if you're able to trade in wild zone
            chr.getAccount().mClient.WriteRawPacket(op.ToArray());
        }
Esempio n. 11
0
        public static void HandleFriends(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook HandleFriends while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte communityIndex = p.ReadByte();
            string personName = MiscFunctions.obscureString(p.ReadString(16));

            Community com = chr.getCommunity();

            switch(managementType)
            {
                case 0:
                    case 1:
                    {
                        if(!com.addPersona(managementType, communityIndex, personName))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Sorry. Something went wrong!");
                            return;
                        }
                        break;
                    }
                case 2:
                    case 3:
                    {
                        if(!com.removePersona((byte)(managementType - 2), communityIndex))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Sorry. Something went wrong!");
                            return;
                        }
                        break;
                    }
                default:
                {
                    //tuffnucks you!
                    return;
                }
            }

            OutPacket op = new OutPacket(40);
            op.WriteInt(40);
            op.WriteShort(0x04);
            op.WriteShort(0x31);
            op.WriteInt(134652417);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(communityIndex);
            op.WritePaddedString(personName, 16);
            op.WriteInt(-1089495552);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 12
0
        public static void UpdateNews(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            if (chr.getGuild() == null)
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild news with char that ain't in guild");
                c.Close();
                return;
            }

            Guild guild = chr.getGuild();

            if (chr.getGuild() == null)
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild news with char that ain't in guild");
                c.Close();
                return;
            }

            GuildMember gMember = guild.findGuildMember(chr.getuID());

            if (gMember.getGuildRank() < 4)            // aint master?
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guildManagement with char that ain't a guild master");
                c.Close();
                return;
            }

            string news = MiscFunctions.obscureString(p.ReadString(195));

            guild.guildNews = news;

            guild.sendToGuildMembers(GuildPackets.getRefreshNewsGuildPacket(news));
        }
Esempio n. 13
0
        public static void MoveToInv(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte fromCargoIndex = p.ReadByte();
            byte toInvSlot      = p.ReadByte();
            byte toInvLine      = p.ReadByte();
            byte toInvRow       = p.ReadByte();

            Cargo     cargo = chr.getCargo();
            Inventory inv   = chr.getInventory();

            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toInvSlot, toInvLine, toInvRow);

            cargo.updateCargo();

            if (!cargo.getCargoSaved().ContainsKey((byte)fromCargoIndex))
            {
                Console.WriteLine("Cannot moveItemToInv [item missing]");
                return;
            }
            Item itemF = cargo.getCargoSaved()[(byte)fromCargoIndex];

            if (!inv.moveFromCargo(itemF, fromCargoIndex, toInvRow, toInvLine))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "do kurwy nendzy");
                return;
            }
            cargo.saveCargo();

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(45);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteByte(toInvSlot);
            op.WriteByte(toInvLine);
            op.WriteByte(toInvRow);
            op.WriteShort(-16625);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public static void Refresh(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(40);

            op.WriteInt(40);
            op.WriteShort(5);
            op.WriteShort(0x41);
            op.WriteInt(1);
            op.WriteShort(13413);
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(32);
            op.WriteInt(32);
            op.WriteShort(4);
            op.WriteShort(97);
            op.WriteInt(1);
            op.WriteShort(-15349);
            op.WriteShort((short)chr.getuID());
            op.WriteLong();
            op.WriteLong();
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(136);
            op.WriteInt(136);
            op.WriteShort(4);
            op.WriteShort(81);
            op.WriteInt(1);
            op.WriteShort(-15349);
            op.WriteShort((short)chr.getuID());
            op.WriteShort(1);
            op.WriteShort(30726);
            op.WriteString("PolishPoverty");
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteInt(5);
            op.WriteInt(937683714);             // those values.. lelellele
            op.WriteInt(680);
            op.WriteInt(939117056);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 16
0
        public static void MoveToVV(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter != null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while being ingame.");
                c.Close();
                return;
            }

            byte selected_character = p.ReadByte();

            if (!c.getAccount().characters.ContainsKey(selected_character))
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Wrong target '{0}' has been selected by packet", selected_character);
                c.Close();
                return;
            }

            Character target = c.getAccount().characters[selected_character];

            target.setPosition(new float[] { -1660, 2344 });
            target.setMap(1);

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(3);
            op.WriteShort(14);
            op.WriteByte(1);
            op.WriteByte(selected_character);
            op.WriteByte(6);
            op.WriteByte(8);
            op.WriteInt(1);             // map
            op.WriteFloat(-1660);       // X
            op.WriteFloat(2344);        // Y
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 17
0
        public static void ShortcutBar(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook bar skill while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte barIndex = p.ReadByte();
            byte actionID = p.ReadByte();

            p.Skip(2);
            int thingID = p.ReadInt();

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(17);
            op.WriteInt(135595521);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(barIndex);
            op.WriteByte(actionID);
            op.WriteInt(thingID);

            if (actionID >= 1 && actionID <= 4)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID);
            }
            else if (actionID == 6)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID + 256);
            }
            else if (actionID == 0)
            {
                chr.getSkillBar().removeFromSkillBar(barIndex);
            }
            else if (actionID == 5)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID + 512);
            }

            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 18
0
        public static void ReturnToSelection(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Hooked returnToSelection with null of activeCharacter");
                c.Close();
                return;
            }

            c.getAccount().activeCharacter.getInventory().updateInv();
            c.getAccount().activeCharacter.getInventory().saveInv();
            c.getAccount().activeCharacter.getCommunity().relistCommunities();
            CharacterFunctions.quitGameWorld(c);
            c.getAccount().relistCharacters();
            c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), true));
        }
Esempio n. 19
0
        public static void ItemCreate(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/item [itemid] [*amount]");
                return;
            }

            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            int itemID = 0;

            Int32.TryParse(cmd.commandArgs[0], out itemID);
            if (itemID < 200000000 || itemID > 299999999)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Item ID range goes from 200.000.000 - 299.999.999.");
                return;
            }
            if (ItemDataCache.Instance.getItemData(itemID).getID() == 0)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Selected item wasn't found.");
                return;
            }

            short itemQuantity = 1;

            Int16.TryParse(cmd.commandArgs[1], out itemQuantity);
            if (itemQuantity > short.MaxValue)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Items amount, can't be bigger than 100!");
                return;
            }

            c.WriteRawPacket(ItemPackets.createDroppedItem(WMap.Instance.items.Count, chr.getPosition()[0], chr.getPosition()[1], itemID, itemQuantity));
            StaticPackets.sendSystemMessageToClient(c, 1, "Item of ID: " + itemID + "|" + WMap.Instance.items.Count + "|" + itemQuantity + ", has been created at coords: ");
            StaticPackets.sendSystemMessageToClient(c, 1, chr.getPosition()[0] + ":" + chr.getPosition()[1] + ":" + chr.getMap() + "!");
            WMap.Instance.items.Add(WMap.Instance.items.Count, new Item(itemID, itemQuantity));
            return;
        }
Esempio n. 20
0
        public static void UseItem(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook useItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            p.Skip(1);
            byte usingIndex = p.ReadByte();
            Item item       = chr.getInventory().getItemBySeqIndexing(usingIndex);

            if (item == null)
            {
                Logger.LogCheat(Logger.HackTypes.Items, c, "Tried to use not existing item.");
                return;
            }

            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());

            if (!itemData.getClassUsable()[chr.getcClass() - 1])
            {
                Console.WriteLine("not for teh class..");
                return;
            }

            if (itemData.getMinLvl() > chr.getLevel() || itemData.getMaxLvl() < chr.getLevel())
            {
                Console.WriteLine("not for yar level..");
                return;
            }

            if (itemData.getFaction() != 0 && chr.getFaction() != itemData.getFaction())
            {
                Console.WriteLine("not for yah faction..");
                return;
            }

            p.Skip(2);
            MainItemUsage.useItem(chr, item, usingIndex, p);
        }
Esempio n. 21
0
        public static void Movement(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked Movement with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            p.Skip(4);
            byte[] locationToX = p.ReadBytes(4);
            byte[] locationToY = p.ReadBytes(4);
            p.Skip(1);
            byte movingMode = p.ReadByte();

            MoveCharacterPacket.HandleMovement(chr, locationToX, locationToY, movingMode);
        }
Esempio n. 22
0
        public static void ItemCreate(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/item [itemid] [*amount]");
                return;
            }

            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            int itemID = 0;
            Int32.TryParse(cmd.commandArgs[0], out itemID);
            if(itemID < 200000000 || itemID > 299999999)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Item ID range goes from 200.000.000 - 299.999.999.");
                return;
            }
            if(ItemDataCache.Instance.getItemData(itemID).getID() == 0)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Selected item wasn't found.");
                return;
            }

            short itemQuantity = 1;
            Int16.TryParse(cmd.commandArgs[1], out itemQuantity);
            if(itemQuantity > short.MaxValue)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Items amount, can't be bigger than 100!");
                return;
            }

            c.WriteRawPacket(ItemPackets.createDroppedItem(WMap.Instance.items.Count, chr.getPosition()[0], chr.getPosition()[1], itemID, itemQuantity));
            StaticPackets.sendSystemMessageToClient(c, 1, "Item of ID: " + itemID + "|" + WMap.Instance.items.Count + "|" + itemQuantity + ", has been created at coords: ");
            StaticPackets.sendSystemMessageToClient(c, 1, chr.getPosition()[0] + ":" + chr.getPosition()[1] + ":" + chr.getMap() + "!");
            WMap.Instance.items.Add(WMap.Instance.items.Count, new Item(itemID, itemQuantity));
            return;
        }
Esempio n. 23
0
        public static void MoveFromInv(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte fromInvIndex   = p.ReadByte();
            byte toCargoSlot    = p.ReadByte();
            byte toCargoLine    = p.ReadByte();
            byte toCargoRow     = p.ReadByte();

            Cargo cargo = chr.getCargo();

            Console.WriteLine("Cargo > {0} | {1} | {2} | {3} | {4}", managementType, fromInvIndex, toCargoSlot, toCargoLine, toCargoRow);
            if (!cargo.insertItemFromInventory(chr.getInventory(), fromInvIndex, toCargoRow, toCargoLine))
            {
                Console.WriteLine("da fuaaark");
                return;
            }

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(44);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(fromInvIndex);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            op.WriteByte(42);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 24
0
        public static void SellToNPC(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook sellToNPC while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(9);

            Item item = new Item();

            if (!chr.getInventory().sellItem(decrypted[5], decrypted[8], item))
            {
                Console.WriteLine("sell to npc teh problemz");
                return;
            }

            if (payedItems.Contains(item.getItemID()))
            {
                ItemData itemData  = ItemDataCache.Instance.getItemData(item.getItemID());
                int      itemPrice = itemData.getNpcPrice() * decrypted[8];
                chr.setCoin(chr.getCoin() + itemPrice);
            }

            OutPacket op = new OutPacket(32);

            op.WriteInt(32);
            op.WriteShort(0x04);
            op.WriteShort(0x14);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(0x01);
            op.WriteByte(decrypted[5]);
            op.WriteInt(decrypted[8]);
            op.WriteLong(chr.getCoin());
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 25
0
        public static void MoveFromInv(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte fromInvIndex = p.ReadByte();
            byte toCargoSlot = p.ReadByte();
            byte toCargoLine = p.ReadByte();
            byte toCargoRow = p.ReadByte();

            Cargo cargo = chr.getCargo();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3} | {4}", managementType, fromInvIndex, toCargoSlot, toCargoLine, toCargoRow);
            if(!cargo.insertItemFromInventory(chr.getInventory(), fromInvIndex, toCargoRow, toCargoLine))
            {
                Console.WriteLine("da fuaaark");
                return;
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(44);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(fromInvIndex);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            op.WriteByte(42);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 26
0
        public static void Move(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo movement while not being ingame.");
                c.Close();
                return;
            }

            byte      fromCargoIndex  = p.ReadByte();
            short     unknownMovement = p.ReadShort();
            byte      toCargoSlot     = p.ReadByte();
            byte      toCargoLine     = p.ReadByte();
            byte      toCargoRow      = p.ReadByte();
            Character chr             = c.getAccount().activeCharacter;
            Cargo     cargo           = chr.getCargo();

            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toCargoSlot, toCargoLine, toCargoRow);

            if (!cargo.moveItem(fromCargoIndex, toCargoSlot, toCargoRow, toCargoLine))
            {
                Console.WriteLine("problem with move item");
                return;
            }

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(46);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteShort(unknownMovement);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 27
0
        public static void Move(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo movement while not being ingame.");
                c.Close();
                return;
            }

            byte fromCargoIndex = p.ReadByte();
            short unknownMovement = p.ReadShort();
            byte toCargoSlot = p.ReadByte();
            byte toCargoLine = p.ReadByte();
            byte toCargoRow = p.ReadByte();
            Character chr = c.getAccount().activeCharacter;
            Cargo cargo = chr.getCargo();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toCargoSlot, toCargoLine, toCargoRow);

            if(!cargo.moveItem(fromCargoIndex, toCargoSlot, toCargoRow, toCargoLine))
            {
                Console.WriteLine("problem with move item");
                return;
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(46);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteShort(unknownMovement);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 28
0
        public static void StateVending(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook openVending while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte   stateType = p.ReadByte();
            string shopName  = p.ReadString(30);

            if (stateType == 1)
            {
                if (chr.getVending() != null)
                {
                    Console.WriteLine("u already have teh vending biach");
                    return;
                }

                chr.setVending(new Vending(chr, shopName));
                c.WriteRawPacket(VendingPackets.createVendorFrame(chr, 1, shopName));
                if (chr.getMap() == 1)
                {
                    WMap.Instance.getGrid(1).addToVendings(chr);
                }
            }
            else
            {
                chr.getVending().deleteVendor();
                chr.setVending(null);
                c.WriteRawPacket(VendingPackets.createVendorFrame(chr, 0));
            }

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), VendingPackets.getExtVending(chr));
        }
Esempio n. 29
0
        public static void ToggleMutationEffect(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked toggleMutationEffect with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte toggleType = p.ReadByte();

            OutPacket op = new OutPacket(20);

            op.WriteInt(20);
            op.WriteShort(0x05);
            op.WriteShort(0X7c);
            op.WriteInt(140235265);
            op.WriteInt(chr.getuID());
            op.WriteInt(toggleType == 0 ? 716251136 : 716251314);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr.getArea(), op.ToArray());
        }
Esempio n. 30
0
        public static void UpgradeItem(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook upgradeItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(10);
            byte oldItemIndex = decrypted[8];
            byte upgraderIndex = decrypted[9];
            Inventory inv=chr.getInventory();

            inv.updateInv();

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

            int oldItemHash = seq[oldItemIndex];
            int upgraderHash = seq[upgraderIndex];
            if(oldItemHash == -1 || upgraderHash == -1)
            {
                Console.WriteLine("can't upgrade items.. cause they don't exist o.o");
                return;
            }

            Item oldItem = items[oldItemHash];
            if(oldItem == null)
            {
                Console.WriteLine("Tried to use not existing item..");
                return;
            }
            if(oldItem.getQuantity() > 1)
            {
                Console.WriteLine("wtf..");
                return;
            }
            Item upgrader = items[upgraderHash];
            if(upgrader == null)
            {
                Console.WriteLine("Tried to use not existing item..");
                return;
            }

            Upgrade upgrade = Upgrades.Instance.getUpgradeClasse(oldItem.getItemID(), upgrader.getItemID());
            if(upgrade == null)
            {
                Console.WriteLine("not found dla {0} | {1}", oldItem.getItemID(), upgrader.getItemID());
                return;
            } else Console.WriteLine("znaleziony upgrade: {0} | {1}", upgrade.getOldit(), upgrade.getNewit());

            //if(!SkillMaster.canUpgrade(chr, upgrade.getUpgradeskill())){
            //	throw new InventoryException("Cannot upgrade item [your upgrade lvl is too low]");
            //}

            byte newItemIndex = 0;
            int newItemHash = -1;

            //change item
            oldItem.setItemID(upgrade.getNewit());
            oldItem.setQuantity(1);
            //position of new item
            newItemIndex=oldItemIndex;
            newItemHash = oldItemHash;

            //remove upgrader
            inv.removeItem(upgraderIndex, 1);
            if(inv.getSeq()[upgraderIndex] == -1)
            {
                Console.WriteLine("usuwamy itemek");
                c.WriteRawPacket(StaticPackets.getInventoryDeletePacket(chr, upgraderIndex, 1));
            } else Console.WriteLine("co kurwa");

            inv.saveInv();
            c.WriteRawPacket(StaticPackets.getUpgradePacket(chr, oldItem, newItemIndex, newItemHash));
        }
Esempio n. 31
0
        public static void Warp(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs.Length < 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true");
                return;
            }

            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            short goMap = -1;
            float goX = -1;
            float goY = -1;

            if(cmd.commandArgs.Length == 2)
            {
                switch(cmd.commandArgs[0].ToLower())
                {
                    case "npc":
                    {
                        int npcID = -1;
                        if(!Int32.TryParse(cmd.commandArgs[1], out npcID))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse NPC's ID.");
                            return;
                        }

                        if(WMap.Instance.getNpcs().ElementAtOrDefault(npcID) == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find NPC of ID " + npcID + "!");
                            return;
                        }

                        NPC npc = WMap.Instance.getNpcs()[npcID];

                        goMap = npc.getMap();
                        goX = npc.getPosition()[0];
                        goY = npc.getPosition()[1];
                        break;
                    }
                    /*case "mob":
                    {
                        int mobID = -1;
                        if(!Int32.TryParse(cmd.commandArgs[1], out mobID))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse Mob's ID.");
                            return;
                        }

                        Mob mob = WMap.Instance.getGrid(chr.getMap()).findMobByuID(mobID);
                        if(mob == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find Mob of ID " + mobID + "!");
                            return;
                        }

                        goMap = mob.getMap();
                        goX = mob.getPosition()[0];
                        goY = mob.getPosition()[1];
                        break;
                    }*/
                    case "player":
                    {
                        Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[1]);
                        if(player == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Player wasn't found.");
                            return;
                        }

                        goMap = player.getMap();
                        goX = player.getPosition()[0];
                        goY = player.getPosition()[1];
                        break;
                    }
                    default:
                    {
                        if(!MiscFunctions.IsNumeric(cmd.commandArgs[0]) || cmd.commandArgs[1] != "true" && !MiscFunctions.IsNumeric(cmd.commandArgs[1]))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true");
                            return;
                        }

                        Waypoint closestTown = null;
                        short _desiredMap = -1;
                        if(!Int16.TryParse(cmd.commandArgs[0], out _desiredMap))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired map's ID!");
                            return;
                        }

                        if(cmd.commandArgs[1] == "true")
                        {
                            closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(_desiredMap, new Waypoint(0, 0));
                            if(closestTown == null)
                            {
                                StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + "!");
                                return;
                            }
                        }
                        else if(MiscFunctions.IsNumeric(cmd.commandArgs[1]))
                        {
                            int _desiredTown = -1;
                            if(!Int32.TryParse(cmd.commandArgs[1], out _desiredTown))
                            {
                                StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired town's index!");
                                return;
                            }

                            closestTown = TownCoordsCache.Instance.getWaypointAtIndexForMap(_desiredMap, _desiredTown);
                            if(closestTown == null)
                            {
                                StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + " with index " + _desiredTown + "!");
                                return;
                            }
                        }

                        goMap = Convert.ToInt16(cmd.commandArgs[0]);
                        goX = closestTown.getX();
                        goY = closestTown.getY();
                        break;
                    }
                }
            }
            else if(cmd.commandArgs.Length == 3)
            {
                foreach(string parser in cmd.commandArgs)
                    if(!MiscFunctions.IsNumeric(parser))
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                        return;
                    }

                goMap = Convert.ToInt16(cmd.commandArgs[2]);
                goX = Convert.ToSingle(cmd.commandArgs[0]);
                goY = Convert.ToSingle(cmd.commandArgs[1]);
            } else return;

            CharacterFunctions.setPlayerPosition(c.getAccount().activeCharacter, goX, goY, goMap);
            return;
        }
Esempio n. 32
0
        public static void UseItem(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook useItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            p.Skip(1);
            byte usingIndex = p.ReadByte();
            Item item = chr.getInventory().getItemBySeqIndexing(usingIndex);
            if(item == null)
            {
                Logger.LogCheat(Logger.HackTypes.Items, c, "Tried to use not existing item.");
                return;
            }

            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());

            if(!itemData.getClassUsable()[chr.getcClass() - 1])
            {
                Console.WriteLine("not for teh class..");
                return;
            }

            if(itemData.getMinLvl() > chr.getLevel() || itemData.getMaxLvl() < chr.getLevel())
            {
                Console.WriteLine("not for yar level..");
                return;
            }

            if(itemData.getFaction() != 0 && chr.getFaction() != itemData.getFaction())
            {
                Console.WriteLine("not for yah faction..");
                return;
            }

            p.Skip(2);
            MainItemUsage.useItem(chr, item, usingIndex, p);
        }
Esempio n. 33
0
        public static void CastSkill(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cast skill while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte skillBarNumber = p.ReadByte();
            byte skillActivationType = p.ReadByte();
            p.Skip(14);
            byte chartargets = p.ReadByte();
            p.Skip(1);
            byte mobtargets = p.ReadByte();
            if((chartargets + mobtargets) > 8)
                return;
            p.Skip(1);
            int[] targetIds = new int[chartargets + mobtargets];
            for(int i = 0;i < targetIds.Length;i++)
            {
                targetIds[i] = p.ReadInt();
            }
            System.Console.WriteLine("{0} | {1} | {2} | {3} | {4}", skillBarNumber, skillActivationType, chartargets, mobtargets, string.Join(",", targetIds));

            //skillpckt1 is a packet of skilleffects e.g. buffs
            byte[] skillpckt1 = SkillPackets.getSkillEffectOnCharPacket(chr);
            //skillpckt2 is a packet of skill activation, different IDs and DMG
            byte[] skillpckt2 = new byte[52];
            //just for medi and turbo
            byte[] skillpckt3 = new byte[28];

            //SkillID
            byte[] skillid;
            int skillIDInt = SkillDataCache.Instance.getSkillIDFromCast(chr, (byte)(skillBarNumber));
            int skillidNoFake = skillIDInt;
            skillid = BitTools.intToByteArray(skillIDInt);

            //SkillMaster.canCastSkill(cur, skillidInt);
            SkillData skill = SkillDataCache.Instance.getSkill(skillIDInt);

            if(skill == null)
            {
                System.Console.WriteLine("Skill was null");
                return;
            }

            if(skill.getTargets() < chartargets + mobtargets)
            {
                System.Console.WriteLine("tried to hit moar than poss");
                return;
            }

            //TURBO AND MEDI
            if(skill.getTypeSpecific() == 6 || skill.getTypeSpecific() == 7)
            {
                if(skill.getTypeSpecific() == 6)
                {
                    skillpckt3 = SkillPackets.getMediPacket(chr, skillIDInt, skillActivationType);
                }
                else
                {
                    skillpckt3 = SkillPackets.getTurboPacket(chr, skillIDInt, skillActivationType == (byte)0xc8);
                    //if(skillActivationType == (byte)0xc8) chr.setTurboSpeed(((CastableSkill)skill).getSpeed());
                    //else chr.setTurboSpeed(0);
                }

                c.WriteRawPacket(skillpckt3);
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), skillpckt3);
                return;
            }

            //TARGETS
            int targets = chartargets + mobtargets;

            //COSTS
            chr.setCurHP(chr.getCurHP() - skill.getHealCost());
            chr.setCurMP((short)(chr.getCurMP() - skill.getManaCost()));
            chr.setCurSP((short)(chr.getCurSP() - skill.getStaminaCost()));

            Fightable target;

            //GET MAXIMUM CASTERS DMG
            int dmgInt = SkillDataCache.Instance.skillCastDmgCalculations(chr, skillIDInt);
            int totalDmg;
            int dmgType;

            //GET MAIN SKILL PACKET
            skillpckt2 = SkillPackets.getCastSkillPacket(chr, targets, skillidNoFake, skillActivationType);

            //ADD TARGET STUFF TO THE PACKET
            for(int aoe = 0;aoe < targets;aoe++)
            {
                //GET TARGET
                byte[] targetByteB = BitTools.intToByteArray(targetIds[aoe]);

                target = WMap.Instance.getGrid(chr.getMap()).getFightableNear(chr.getArea(), BitTools.byteArrayToInt(targetByteB));
                if(target == null)
                    continue;

                //check for distance
                //canCastToTarget((Location)chr, (Location)target);

                totalDmg = dmgInt;

                //DECREASE DMG BY DEF
                dmgType = SkillDataCache.Instance.skillCastDmgTypeCalculations(chr, target, skill.getTypeSpecific() == 2);
                totalDmg -= target.getDef();

                //CRIT
                if(dmgType == 2 || dmgType == 5)
                    totalDmg += chr.getCritDmg();

                //DMG TYPE FACTOR
                totalDmg *= (int)(SkillDataCache.Instance.getDmgFactorByType(dmgType) * SkillDataCache.Instance.getDmgFactorByClass(chr));

                if(totalDmg < 0) totalDmg = 0;

                //ATK THE TARGET FINALLY
                target.recDamage(chr.getuID(), totalDmg);

                int targetId = BitTools.byteArrayToInt(targetByteB);

                //COMPLETE THE TARGET IN THE PACKAGE
                skillpckt2 = SkillPackets.completeCastSkillPacket(skillpckt2, aoe, targetId, target.getCurHP(), target.getCurMP(), -totalDmg, chartargets, dmgType);

                if(chartargets > 0)
                    chartargets--;
            }

            //send skill packet to other players
            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), skillpckt2);

            //send skill packet to client
            c.WriteRawPacket(skillpckt2);

            //effects on char
            c.WriteRawPacket(skillpckt1);
            return;
        }
Esempio n. 34
0
        public static void CreateGuild(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            Guild guild = chr.getGuild();

            byte managementType = p.ReadByte(); // 0 - disband; 1 - create; 2 - donate; 3 - hat
            byte managementArg	= p.ReadByte(); // 1 - bang, 2 - mun, 3 - pa, 4 - nohing, 5 - dan, 6 - gak, 7 - gyo, 8 - gung
            string managementName = MiscFunctions.obscureString(p.ReadString(18));

            switch(managementType)
            {
                case 0:
                {
                    if(guild == null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild disband with char that ain't in guild");
                        c.Close();
                        return;
                    }

                    guild.Delete();
                    WMap.Instance.removeGuild(guild);
                    foreach(GuildMember i in guild.guildMembers)
                    {
                        Character tmp = i.getOnlineCharacter();
                        tmp.getAccount().mClient.WriteRawPacket(GuildPackets.quitGuildForInternal(tmp));
                        WMap.Instance.getGrid(tmp.getMap()).sendTo3x3Area(tmp, tmp.getArea(), GuildPackets.quitGuildForExternals(tmp));
                        tmp.setGuild(null);
                        i.setOnlineCharacter(null);
                    }
                    return;
                }
                case 1:
                {
                    if(guild != null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild create with char that is in guild");
                        c.Close();
                        return;
                    }

                    Guild newGuild = new Guild(managementArg, managementName);
                    c.WriteRawPacket(GuildPackets.createGuildResponse(chr, managementType, managementArg, managementName));
                    WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), GuildPackets.extCharGuild(chr));
                    return;
                }
                case 2:
                {
                    if(guild == null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild donate with char that ain't in guild");
                        c.Close();
                        return;
                    }

                    return;
                }
                case 3:
                {
                    if(guild == null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild hat change with char that ain't in guild");
                        c.Close();
                        return;
                    }

                    guild.guildHat = managementArg;
                    WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), GuildPackets.extCharGuild(chr));
                    c.WriteRawPacket(GuildPackets.refreshGuild(chr));
                    return;
                }
            }
            return;
        }
Esempio n. 35
0
        public static void Refresh(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(40);
            op.WriteInt(40);
            op.WriteShort(5);
            op.WriteShort(0x41);
            op.WriteInt(1);
            op.WriteShort(13413);
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(32);
            op.WriteInt(32);
            op.WriteShort(4);
            op.WriteShort(97);
            op.WriteInt(1);
            op.WriteShort(-15349);
            op.WriteShort((short)chr.getuID());
            op.WriteLong();
            op.WriteLong();
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(136);
            op.WriteInt(136);
            op.WriteShort(4);
            op.WriteShort(81);
            op.WriteInt(1);
            op.WriteShort(-15349);
            op.WriteShort((short)chr.getuID());
            op.WriteShort(1);
            op.WriteShort(30726);
            op.WriteString("PolishPoverty");
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteInt(5);
            op.WriteInt(937683714); // those values.. lelellele
            op.WriteInt(680);
            op.WriteInt(939117056);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 36
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);
        }
Esempio n. 37
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();
        }
Esempio n. 38
0
        public static void MoveToInv(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte fromCargoIndex = p.ReadByte();
            byte toInvSlot = p.ReadByte();
            byte toInvLine = p.ReadByte();
            byte toInvRow = p.ReadByte();

            Cargo cargo = chr.getCargo();
            Inventory inv = chr.getInventory();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toInvSlot, toInvLine, toInvRow);

            cargo.updateCargo();

            if(!cargo.getCargoSaved().ContainsKey((byte)fromCargoIndex))
            {
                Console.WriteLine("Cannot moveItemToInv [item missing]");
                return;
            }
            Item itemF = cargo.getCargoSaved()[(byte)fromCargoIndex];

            if(!inv.moveFromCargo(itemF, fromCargoIndex, toInvRow, toInvLine))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "do kurwy nendzy");
                return;
            }
            cargo.saveCargo();

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(45);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteByte(toInvSlot);
            op.WriteByte(toInvLine);
            op.WriteByte(toInvRow);
            op.WriteShort(-16625);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 39
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);
        }
Esempio n. 40
0
        public static void Chat(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked chat with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte   messageType   = (byte)p.ReadShort();
            string receiver      = MiscFunctions.obscureString(p.ReadString(17));
            byte   messageLength = (byte)p.ReadInt();

            if (messageLength > 65)
            {
                Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to send a message of size {0}", messageLength);
                c.Close();
                return;
            }
            string message = p.ReadString(messageLength);

            switch (messageType)
            {
            case 0: WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), StaticPackets.chatRelay(chr, messageType, message)); break;

            case 1:
            {
                if (receiver == null)
                {
                    return;
                }

                Character player = WMap.Instance.findPlayerByName(receiver);
                if (player == null)
                {
                    chr.getAccount().mClient.WriteRawPacket(StaticPackets.playerIsntConnected(chr));
                    break;
                }

                player.getAccount().mClient.WriteRawPacket(StaticPackets.chatRelay(chr, messageType, message));
                break;
            }

            case 6:                     // karma notice
            {
                if (chr.getKarmaMessagingTimes() == 0)
                {
                }

                WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                break;
            }

            case 7:                     // "GM Shout"
            {
                if (chr.getAccount().gmLvl == 0 && chr.getGMShoutMessagingCounts() == 0)
                {
                }

                WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                break;
            }

            case 9:                     // admin commands
            {
                string[] cmd = Regex.Split(message, " ");
                if (chr.getAccount().gmLvl == 0)
                {
                    Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse GM Command {0}", cmd[0]);
                    c.Close();
                    break;
                }

                if (cmd.Length == 0)
                {
                    Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse null GM Command");
                    c.Close();
                    break;
                }

                if (cmd[0][0] != '/')
                {
                    Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse command without '/' slash");
                    c.Close();
                    break;
                }

                CommandProcessor.ParseCommand(c, cmd);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Esempio n. 41
0
        public static void SellToNPC(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook sellToNPC while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(9);

            Item item = new Item();

            if(!chr.getInventory().sellItem(decrypted[5], decrypted[8], item))
            {
                Console.WriteLine("sell to npc teh problemz");
                return;
            }

            if(payedItems.Contains(item.getItemID()))
            {
                ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());
                int itemPrice = itemData.getNpcPrice() * decrypted[8];
                chr.setCoin(chr.getCoin() + itemPrice);
            }

            OutPacket op = new OutPacket(32);
            op.WriteInt(32);
            op.WriteShort(0x04);
            op.WriteShort(0x14);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(0x01);
            op.WriteByte(decrypted[5]);
            op.WriteInt(decrypted[8]);
            op.WriteLong(chr.getCoin());
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 42
0
        public static void UnknownStatimizer(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(47);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteByte();
            op.WriteByte();
            op.WriteByte(1);
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();
            op.WriteByte(); // ok, there's some magic on those bytes, for ex. 3rd byte tells you, if you're able to trade in wild zone
            chr.getAccount().mClient.WriteRawPacket(op.ToArray());
        }
Esempio n. 43
0
        public static void CreateGuild(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            Guild guild = chr.getGuild();

            byte   managementType = p.ReadByte();           // 0 - disband; 1 - create; 2 - donate; 3 - hat
            byte   managementArg  = p.ReadByte();           // 1 - bang, 2 - mun, 3 - pa, 4 - nohing, 5 - dan, 6 - gak, 7 - gyo, 8 - gung
            string managementName = MiscFunctions.obscureString(p.ReadString(18));

            switch (managementType)
            {
            case 0:
            {
                if (guild == null)
                {
                    Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild disband with char that ain't in guild");
                    c.Close();
                    return;
                }

                guild.Delete();
                WMap.Instance.removeGuild(guild);
                foreach (GuildMember i in guild.guildMembers)
                {
                    Character tmp = i.getOnlineCharacter();
                    tmp.getAccount().mClient.WriteRawPacket(GuildPackets.quitGuildForInternal(tmp));
                    WMap.Instance.getGrid(tmp.getMap()).sendTo3x3Area(tmp, tmp.getArea(), GuildPackets.quitGuildForExternals(tmp));
                    tmp.setGuild(null);
                    i.setOnlineCharacter(null);
                }
                return;
            }

            case 1:
            {
                if (guild != null)
                {
                    Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild create with char that is in guild");
                    c.Close();
                    return;
                }

                Guild newGuild = new Guild(managementArg, managementName);
                c.WriteRawPacket(GuildPackets.createGuildResponse(chr, managementType, managementArg, managementName));
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), GuildPackets.extCharGuild(chr));
                return;
            }

            case 2:
            {
                if (guild == null)
                {
                    Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild donate with char that ain't in guild");
                    c.Close();
                    return;
                }


                return;
            }

            case 3:
            {
                if (guild == null)
                {
                    Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild hat change with char that ain't in guild");
                    c.Close();
                    return;
                }

                guild.guildHat = managementArg;
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), GuildPackets.extCharGuild(chr));
                c.WriteRawPacket(GuildPackets.refreshGuild(chr));
                return;
            }
            }
            return;
        }
Esempio n. 44
0
 public static void InvalidVersion(MartialClient c, InPacket p)
 {
     c.WriteRawPacket(Constants.authFail);
     c.Close();
     return;
 }
Esempio n. 45
0
        public static void UpdateNews(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            if(chr.getGuild() == null)
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild news with char that ain't in guild");
                c.Close();
                return;
            }

            Guild guild = chr.getGuild();

            if(chr.getGuild() == null)
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild news with char that ain't in guild");
                c.Close();
                return;
            }

            GuildMember gMember = guild.findGuildMember(chr.getuID());

            if(gMember.getGuildRank() < 4) // aint master?
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guildManagement with char that ain't a guild master");
                c.Close();
                return;
            }

            string news = MiscFunctions.obscureString(p.ReadString(195));

            guild.guildNews = news;

            guild.sendToGuildMembers(GuildPackets.getRefreshNewsGuildPacket(news));
        }
Esempio n. 46
0
        public static void ShortcutBar(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook bar skill while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte barIndex = p.ReadByte();
            byte actionID = p.ReadByte();
            p.Skip(2);
            int thingID = p.ReadInt();

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(17);
            op.WriteInt(135595521);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(barIndex);
            op.WriteByte(actionID);
            op.WriteInt(thingID);

            if(actionID >= 1 && actionID <= 4)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID);
            }
            else if(actionID == 6)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID + 256);
            }
            else if(actionID == 0)
            {
                chr.getSkillBar().removeFromSkillBar(barIndex);
            }
            else if(actionID == 5)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID + 512);
            }

            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 47
0
        public static void Movement(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked Movement with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            p.Skip(4);
            byte[] locationToX = p.ReadBytes(4);
            byte[] locationToY = p.ReadBytes(4);
            p.Skip(1);
            byte movingMode = p.ReadByte();
            MoveCharacterPacket.HandleMovement(chr, locationToX, locationToY, movingMode);
        }
Esempio n. 48
0
        public static void SendMessage(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook SendMessage handling while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            int messageType = p.ReadInt(); // identifier of message type maybe?
            string receiver = p.ReadString(20); // receiver name
            MiscFunctions.obscureString(receiver);
            if(!MySQLTool.NameTaken(receiver))
            {

                return;
            }
            int messageLength = p.ReadInt(); // message length
            string message = p.ReadString(messageLength);
            MiscFunctions.obscureString(message);

            OutPacket op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteShort(4);
            op.WriteShort(0x53);
            op.WriteInt(718349825);
            op.WriteInt(chr.getuID());
            op.WriteInt(-1089732352);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 49
0
        public static void ToggleMutationEffect(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked toggleMutationEffect with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte toggleType = p.ReadByte();

            OutPacket op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteShort(0x05);
            op.WriteShort(0X7c);
            op.WriteInt(140235265);
            op.WriteInt(chr.getuID());
            op.WriteInt(toggleType == 0 ? 716251136 : 716251314);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr.getArea(), op.ToArray());
        }
Esempio n. 50
0
        public static void StateVending(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook openVending while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte stateType = p.ReadByte();
            string shopName = p.ReadString(30);

            if(stateType == 1)
            {
                if(chr.getVending() != null)
                {
                    Console.WriteLine("u already have teh vending biach");
                    return;
                }

                chr.setVending(new Vending(chr, shopName));
                c.WriteRawPacket(VendingPackets.createVendorFrame(chr, 1, shopName));
                if(chr.getMap() == 1)
                {
                    WMap.Instance.getGrid(1).addToVendings(chr);
                }
            } else {
                chr.getVending().deleteVendor();
                chr.setVending(null);
                c.WriteRawPacket(VendingPackets.createVendorFrame(chr, 0));
            }

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), VendingPackets.getExtVending(chr));
        }
Esempio n. 51
0
        public static void Chat(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked chat with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte messageType = (byte)p.ReadShort();
            string receiver = MiscFunctions.obscureString(p.ReadString(17));
            byte messageLength = (byte)p.ReadInt();
            if(messageLength > 65)
            {
                Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to send a message of size {0}", messageLength);
                c.Close();
                return;
            }
            string message = p.ReadString(messageLength);

            switch(messageType)
            {
                case 0: WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), StaticPackets.chatRelay(chr, messageType, message)); break;
                case 1:
                {
                    if(receiver == null)
                        return;

                    Character player = WMap.Instance.findPlayerByName(receiver);
                    if(player == null)
                    {
                        chr.getAccount().mClient.WriteRawPacket(StaticPackets.playerIsntConnected(chr));
                        break;
                    }

                    player.getAccount().mClient.WriteRawPacket(StaticPackets.chatRelay(chr, messageType, message));
                    break;
                }
                case 6: // karma notice
                {
                    if(chr.getKarmaMessagingTimes() == 0)
                    {

                    }

                    WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                    break;
                }
                case 7: // "GM Shout"
                {
                    if(chr.getAccount().gmLvl == 0 && chr.getGMShoutMessagingCounts() == 0)
                    {

                    }

                    WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                    break;
                }
                case 9: // admin commands
                {
                    string[] cmd = Regex.Split(message, " ");
                    if(chr.getAccount().gmLvl == 0)
                    {
                        Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse GM Command {0}", cmd[0]);
                        c.Close();
                        break;
                    }

                    if(cmd.Length == 0)
                    {
                        Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse null GM Command");
                        c.Close();
                        break;
                    }

                    if(cmd[0][0] != '/')
                    {
                        Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse command without '/' slash");
                        c.Close();
                        break;
                    }

                    CommandProcessor.ParseCommand(c, cmd);
                    break;
                }
                default:
                {
                    break;
                }
            }
        }
Esempio n. 52
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());
        }
Esempio n. 53
0
 public static void InvalidVersion(MartialClient c, InPacket p)
 {
     c.WriteRawPacket(Constants.authFail);
     c.Close();
     return;
 }
Esempio n. 54
0
        public static void BuyFromNPC(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to hook a NPC open while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(9);

            int npcID = BitConverter.ToInt32(decrypted, 0);

            if (WMap.Instance.getNpcs().ElementAtOrDefault(npcID) == null)
            {
                Logger.LogCheat(Logger.HackTypes.NPC, c, "Tried to hook NPC of uID {0}", npcID);
                return;
            }

            NPC npc = WMap.Instance.getNpcs()[npcID];

            OutPacket op = new OutPacket(56);

            op.WriteInt(56);
            op.WriteShort(4);
            op.WriteShort(19);
            op.WriteInt(1);
            op.WriteInt(c.getAccount().activeCharacter.getuID());

            if (decrypted[8] != 0)
            {
                int itemID = NPCDataCache.Instance.getNPCDataByuID(npcID, chr.getMap()).getItemFromSlot(decrypted[4]);
                if (itemID == -1)
                {
                    Console.WriteLine("Somebody tried to buy not existing item");
                    return;
                }

                ItemData itemData = ItemDataCache.Instance.getItemData(itemID);
                if (itemData == null)
                {
                    Console.WriteLine("Tried to buy not existing item");
                    return;
                }

                Item item = new Item(itemID, decrypted[8]);

                int itemPrice = 0;
                if (payedItems.Contains(itemData.getID()))
                {
                    itemPrice = itemData.getNpcPrice() * decrypted[8];
                    if (chr.getCoin() < itemPrice)
                    {
                        Console.WriteLine("Tried to buy free Gold Bars :3");
                        return;
                    }
                }

                Console.WriteLine("line {0} row {1}", decrypted[7], decrypted[6]);
                if (!chr.getInventory().buyItem(item, decrypted[7], decrypted[6]))
                {
                    Console.WriteLine("npc.. something went wrong");
                    return;
                }

                chr.setCoin(chr.getCoin() - itemPrice);

                op.WriteLong(chr.getCoin());
                op.WriteShort(0x01);
                op.WriteByte(decrypted[5]);
                op.WriteByte(decrypted[6]);
                op.WriteByte(decrypted[7]);
                op.WriteByte(chr.getVp());                 // vending points (?)
                op.WriteZero(18);
                op.WriteInt(itemID);
                op.WriteByte(decrypted[8]);
            }
            else
            {
                op.WriteInt(npcID);
                op.WriteInt();
                op.WriteInt(0x01);
                op.WriteInt();
                op.WriteInt();
                op.WriteInt(0);                 // -100% extra charge => free buying
                op.WriteInt(8388608);           // -100% discount => free selling
                op.WriteByte(0x80);
                op.WriteByte(0x3f);
                //op.WriteLong(1294138); // looks like.. areaID? for sure not modelID, or other shit, just the second short looks familiar
                //op.WriteLong(1); // must be 1 to open the shop o.o
                //op.WriteInt(64); // 0% ?
                //op.WriteInt(1065353216); // -100% extra charge => free buying
                //op.WriteInt(1065353216); // -100% discount => free selling

                /* IN TWO WORDS -> WEIRD SHIT HERE */
            }

            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 55
0
        public static void BuyFromNPC(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to hook a NPC open while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(9);

            int npcID = BitConverter.ToInt32(decrypted, 0);

            if(WMap.Instance.getNpcs().ElementAtOrDefault(npcID) == null)
            {
                Logger.LogCheat(Logger.HackTypes.NPC, c, "Tried to hook NPC of uID {0}", npcID);
                return;
            }

            NPC npc = WMap.Instance.getNpcs()[npcID];

            OutPacket op = new OutPacket(56);
            op.WriteInt(56);
            op.WriteShort(4);
            op.WriteShort(19);
            op.WriteInt(1);
            op.WriteInt(c.getAccount().activeCharacter.getuID());

            if(decrypted[8] != 0)
            {
                int itemID = NPCDataCache.Instance.getNPCDataByuID(npcID, chr.getMap()).getItemFromSlot(decrypted[4]);
                if(itemID == -1)
                {
                    Console.WriteLine("Somebody tried to buy not existing item");
                    return;
                }

                ItemData itemData = ItemDataCache.Instance.getItemData(itemID);
                if(itemData == null)
                {
                    Console.WriteLine("Tried to buy not existing item");
                    return;
                }

                Item item = new Item(itemID, decrypted[8]);

                int itemPrice = 0;
                if(payedItems.Contains(itemData.getID()))
                {
                    itemPrice = itemData.getNpcPrice() * decrypted[8];
                    if(chr.getCoin() < itemPrice)
                    {
                        Console.WriteLine("Tried to buy free Gold Bars :3");
                        return;
                    }
                }

                Console.WriteLine("line {0} row {1}", decrypted[7], decrypted[6]);
                if(!chr.getInventory().buyItem(item, decrypted[7], decrypted[6]))
                {
                    Console.WriteLine("npc.. something went wrong");
                    return;
                }

                chr.setCoin(chr.getCoin() - itemPrice);

                op.WriteLong(chr.getCoin());
                op.WriteShort(0x01);
                op.WriteByte(decrypted[5]);
                op.WriteByte(decrypted[6]);
                op.WriteByte(decrypted[7]);
                op.WriteByte(chr.getVp()); // vending points (?)
                op.WriteZero(18);
                op.WriteInt(itemID);
                op.WriteByte(decrypted[8]);
            }
            else
            {
                op.WriteInt(npcID);
                op.WriteInt();
                op.WriteInt(0x01);
                op.WriteInt();
                op.WriteInt();
                op.WriteInt(0); // -100% extra charge => free buying
                op.WriteInt(8388608); // -100% discount => free selling
                op.WriteByte(0x80);
                op.WriteByte(0x3f);
                //op.WriteLong(1294138); // looks like.. areaID? for sure not modelID, or other shit, just the second short looks familiar
                //op.WriteLong(1); // must be 1 to open the shop o.o
                //op.WriteInt(64); // 0% ?
                //op.WriteInt(1065353216); // -100% extra charge => free buying
                //op.WriteInt(1065353216); // -100% discount => free selling

                /* IN TWO WORDS -> WEIRD SHIT HERE */
            }

            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 56
0
        public static void CastSkill(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cast skill while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte skillBarNumber      = p.ReadByte();
            byte skillActivationType = p.ReadByte();

            p.Skip(14);
            byte chartargets = p.ReadByte();

            p.Skip(1);
            byte mobtargets = p.ReadByte();

            if ((chartargets + mobtargets) > 8)
            {
                return;
            }
            p.Skip(1);
            int[] targetIds = new int[chartargets + mobtargets];
            for (int i = 0; i < targetIds.Length; i++)
            {
                targetIds[i] = p.ReadInt();
            }
            System.Console.WriteLine("{0} | {1} | {2} | {3} | {4}", skillBarNumber, skillActivationType, chartargets, mobtargets, string.Join(",", targetIds));

            //skillpckt1 is a packet of skilleffects e.g. buffs
            byte[] skillpckt1 = SkillPackets.getSkillEffectOnCharPacket(chr);
            //skillpckt2 is a packet of skill activation, different IDs and DMG
            byte[] skillpckt2 = new byte[52];
            //just for medi and turbo
            byte[] skillpckt3 = new byte[28];

            //SkillID
            byte[] skillid;
            int    skillIDInt    = SkillDataCache.Instance.getSkillIDFromCast(chr, (byte)(skillBarNumber));
            int    skillidNoFake = skillIDInt;

            skillid = BitTools.intToByteArray(skillIDInt);

            //SkillMaster.canCastSkill(cur, skillidInt);
            SkillData skill = SkillDataCache.Instance.getSkill(skillIDInt);

            if (skill == null)
            {
                System.Console.WriteLine("Skill was null");
                return;
            }

            if (skill.getTargets() < chartargets + mobtargets)
            {
                System.Console.WriteLine("tried to hit moar than poss");
                return;
            }

            //TURBO AND MEDI
            if (skill.getTypeSpecific() == 6 || skill.getTypeSpecific() == 7)
            {
                if (skill.getTypeSpecific() == 6)
                {
                    skillpckt3 = SkillPackets.getMediPacket(chr, skillIDInt, skillActivationType);
                }
                else
                {
                    skillpckt3 = SkillPackets.getTurboPacket(chr, skillIDInt, skillActivationType == (byte)0xc8);
                    //if(skillActivationType == (byte)0xc8) chr.setTurboSpeed(((CastableSkill)skill).getSpeed());
                    //else chr.setTurboSpeed(0);
                }

                c.WriteRawPacket(skillpckt3);
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), skillpckt3);
                return;
            }

            //TARGETS
            int targets = chartargets + mobtargets;

            //COSTS
            chr.setCurHP(chr.getCurHP() - skill.getHealCost());
            chr.setCurMP((short)(chr.getCurMP() - skill.getManaCost()));
            chr.setCurSP((short)(chr.getCurSP() - skill.getStaminaCost()));

            Fightable target;

            //GET MAXIMUM CASTERS DMG
            int dmgInt = SkillDataCache.Instance.skillCastDmgCalculations(chr, skillIDInt);
            int totalDmg;
            int dmgType;

            //GET MAIN SKILL PACKET
            skillpckt2 = SkillPackets.getCastSkillPacket(chr, targets, skillidNoFake, skillActivationType);

            //ADD TARGET STUFF TO THE PACKET
            for (int aoe = 0; aoe < targets; aoe++)
            {
                //GET TARGET
                byte[] targetByteB = BitTools.intToByteArray(targetIds[aoe]);

                target = WMap.Instance.getGrid(chr.getMap()).getFightableNear(chr.getArea(), BitTools.byteArrayToInt(targetByteB));
                if (target == null)
                {
                    continue;
                }

                //check for distance
                //canCastToTarget((Location)chr, (Location)target);

                totalDmg = dmgInt;

                //DECREASE DMG BY DEF
                dmgType   = SkillDataCache.Instance.skillCastDmgTypeCalculations(chr, target, skill.getTypeSpecific() == 2);
                totalDmg -= target.getDef();

                //CRIT
                if (dmgType == 2 || dmgType == 5)
                {
                    totalDmg += chr.getCritDmg();
                }

                //DMG TYPE FACTOR
                totalDmg *= (int)(SkillDataCache.Instance.getDmgFactorByType(dmgType) * SkillDataCache.Instance.getDmgFactorByClass(chr));

                if (totalDmg < 0)
                {
                    totalDmg = 0;
                }

                //ATK THE TARGET FINALLY
                target.recDamage(chr.getuID(), totalDmg);

                int targetId = BitTools.byteArrayToInt(targetByteB);

                //COMPLETE THE TARGET IN THE PACKAGE
                skillpckt2 = SkillPackets.completeCastSkillPacket(skillpckt2, aoe, targetId, target.getCurHP(), target.getCurMP(), -totalDmg, chartargets, dmgType);

                if (chartargets > 0)
                {
                    chartargets--;
                }
            }

            //send skill packet to other players
            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), skillpckt2);

            //send skill packet to client
            c.WriteRawPacket(skillpckt2);

            //effects on char
            c.WriteRawPacket(skillpckt1);
            return;
        }
Esempio n. 57
0
        public static void UpgradeItem(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook upgradeItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[]    decrypted     = p.ReadBytes(10);
            byte      oldItemIndex  = decrypted[8];
            byte      upgraderIndex = decrypted[9];
            Inventory inv           = chr.getInventory();

            inv.updateInv();

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

            int oldItemHash  = seq[oldItemIndex];
            int upgraderHash = seq[upgraderIndex];

            if (oldItemHash == -1 || upgraderHash == -1)
            {
                Console.WriteLine("can't upgrade items.. cause they don't exist o.o");
                return;
            }

            Item oldItem = items[oldItemHash];

            if (oldItem == null)
            {
                Console.WriteLine("Tried to use not existing item..");
                return;
            }
            if (oldItem.getQuantity() > 1)
            {
                Console.WriteLine("wtf..");
                return;
            }
            Item upgrader = items[upgraderHash];

            if (upgrader == null)
            {
                Console.WriteLine("Tried to use not existing item..");
                return;
            }

            Upgrade upgrade = Upgrades.Instance.getUpgradeClasse(oldItem.getItemID(), upgrader.getItemID());

            if (upgrade == null)
            {
                Console.WriteLine("not found dla {0} | {1}", oldItem.getItemID(), upgrader.getItemID());
                return;
            }
            else
            {
                Console.WriteLine("znaleziony upgrade: {0} | {1}", upgrade.getOldit(), upgrade.getNewit());
            }

            //if(!SkillMaster.canUpgrade(chr, upgrade.getUpgradeskill())){
            //	throw new InventoryException("Cannot upgrade item [your upgrade lvl is too low]");
            //}

            byte newItemIndex = 0;
            int  newItemHash  = -1;

            //change item
            oldItem.setItemID(upgrade.getNewit());
            oldItem.setQuantity(1);
            //position of new item
            newItemIndex = oldItemIndex;
            newItemHash  = oldItemHash;

            //remove upgrader
            inv.removeItem(upgraderIndex, 1);
            if (inv.getSeq()[upgraderIndex] == -1)
            {
                Console.WriteLine("usuwamy itemek");
                c.WriteRawPacket(StaticPackets.getInventoryDeletePacket(chr, upgraderIndex, 1));
            }
            else
            {
                Console.WriteLine("co kurwa");
            }

            inv.saveInv();
            c.WriteRawPacket(StaticPackets.getUpgradePacket(chr, oldItem, newItemIndex, newItemHash));
        }
Esempio n. 58
0
        public static void DeleteItem(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook deleteItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted = p.ReadBytes(2);
            if(!chr.getInventory().removeItem(decrypted[1]))
            {
                Console.WriteLine("qq cant remove");
                return;
            }

            OutPacket op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteShort(0x04);
            op.WriteShort(0x15);
            op.WriteInt();
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(decrypted[0]);
            op.WriteByte(decrypted[1]);
            c.WriteRawPacket(op.ToArray());
        }
Esempio n. 59
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();
        }
Esempio n. 60
0
        public static void ReturnToSelection(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Hooked returnToSelection with null of activeCharacter");
                c.Close();
                return;
            }

            c.getAccount().activeCharacter.getInventory().updateInv();
            c.getAccount().activeCharacter.getInventory().saveInv();
            c.getAccount().activeCharacter.getCommunity().relistCommunities();
            CharacterFunctions.quitGameWorld(c);
            c.getAccount().relistCharacters();
            c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), true));
        }