public static void updateStatsAttributes(Character chr, short[] attributes = null, short sp = -1) { if(attributes != null) { chr.setStr(attributes[0]); chr.setDex(attributes[1]); chr.setVit(attributes[2]); chr.setInt(attributes[3]); chr.setAgi(attributes[4]); } if(sp != -1) { chr.setStatPoints(sp); } CharacterFunctions.calculateCharacterStatistics(chr); OutPacket p = new OutPacket(32); p.WriteInt(32); p.WriteShort(0x04); p.WriteShort(0x1d); p.WriteInt(0x01); p.WriteInt(chr.getuID()); p.WriteShort(0x01); p.WriteShort(chr.getStr()); // Strength p.WriteShort(chr.getDex()); // Dextery p.WriteShort(chr.getVit()); // Vitality p.WriteShort(chr.getInt()); // Intelligence p.WriteShort(chr.getAgi()); // Agility p.WriteShort(chr.getStatPoints()); // statusPoints p.WriteByte(0x40); p.WriteByte(0x2a); chr.getAccount().mClient.WriteRawPacket(p.ToArray()); }
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; }