Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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();
        }