예제 #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);
        }
예제 #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);
        }
예제 #3
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);
        }
예제 #4
0
        public void LoadCharacters()
        {
            using (var con = new MySqlConnection(MasterServer.Instance.SqlConnection.mConnectionString))
                using (var cmd = con.CreateCommand())
                {
                    con.Open();
                    cmd.CommandText = "SELECT * FROM chars WHERE ownerID = " + aID + " LIMIT 5";
                    using (var reader = cmd.ExecuteReader())
                    {
                        List <int> ids = new List <int>();

                        for (int i = 0; i < 5; i++)
                        {
                            if (!reader.Read())
                            {
                                break;
                            }

                            ids.Add(reader.GetInt32(0));
                        }

                        foreach (int id in ids)
                        {
                            Character chr = new Character();
                            chr.setcID(id);

                            if (chr.Load(this) == 0)
                            {
                                Logger.WriteLog(Logger.LogTypes.Error, "Could not load character with ID {0}.", chr.getuID());
                                continue;
                            }

                            chr.setAccount(this);
                            MySQLTool.loadEq(chr);
                            MySQLTool.loadInv(chr);
                            MySQLTool.loadCargo(chr);
                            MySQLTool.loadSkills(chr);
                            MySQLTool.loadSkillBar(chr);
                            MySQLTool.loadCommunities(chr);
                            CharacterFunctions.calculateCharacterStatistics(chr);
                            this.appendToCharacters(chr);
                        }
                    }
                }
        }
예제 #5
0
        public static void CreateNewCharacter(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;
            }

            if (c.getAccount().characters.Count() == 5)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while characters count is 5.");
                c.Close();
                return;
            }

            string charName = MiscFunctions.obscureString(p.ReadString(18));

            if (charName == null)
            {
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }
            if (charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName))
            {
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            byte face = (byte)p.ReadShort();

            if (face < 1 || face > 7)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with face no {0}", face);
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            short unknownShit = p.ReadShort();             // but let's check it

            if (unknownShit > 0)
            {
                Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit);
            }

            short unknownShit2 = p.ReadShort();

            if (unknownShit2 > 0)
            {
                Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit2);
            }

            byte cClass = (byte)p.ReadShort();

            if (cClass < 1 || cClass > 4)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with class no {0}", cClass);
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            byte[] stats      = { (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort() };
            byte   statPoints = (byte)p.ReadShort();

            if (stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + statPoints > 55)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with weird amount of attributes.");
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            Character newChr = new Character();

            newChr.setName(charName);
            newChr.setFace(face);
            newChr.setcClass(cClass);
            newChr.setStr(stats[0]);
            newChr.setDex(stats[1]);
            newChr.setVit(stats[2]);
            newChr.setAgi(stats[3]);
            newChr.setInt(stats[4]);
            newChr.setStatPoints(statPoints);

            newChr.setAccount(c.getAccount());
            if (newChr.Create() == true)
            {
                CharacterFunctions.createEquipments(newChr);
                CharacterFunctions.createInventories(newChr);
                CharacterFunctions.calculateCharacterStatistics(newChr);
                newChr.setCurHP(newChr.getMaxHP());
                newChr.setCurMP(newChr.getMaxMP());
                newChr.setCurSP(newChr.getMaxSP());
                c.getAccount().appendToCharacters(newChr);
                c.WriteRawPacket(Constants.createNewCharacter);
                return;
            }

            c.WriteRawPacket(Constants.createNCharNameTaken);
            return;
        }