private void CHARACTER_CREATE(CMSG_INTERNAL_CHARACTERCREATE cpkt) { //Argument with creation data given by the authentication server CharCreationArgument argument = new CharCreationArgument(); argument.CharName = cpkt.Name; argument.WeaponName = cpkt.WeaponName; argument.WeaponAffix = cpkt.WeaponAffix; argument.FaceDetails = cpkt.FaceDetails; argument.UserId = cpkt.UserId; //Only normans are supported by this time Character character = null; Saga.Factory.CharacterConfiguration.IDefaultCharacterSettings settings = Singleton.CharacterConfiguration.Normans; try { //CHECK IF NAME ALREADY EXISTS if (Singleton.Database.VerifyNameExists(cpkt.Name.ToUpperInvariant())) { SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE(); spkt.Result = 0xA; spkt.SessionId = cpkt.SessionId; this.Send((byte[])spkt); } //CREATE CHARACTER AND IF FAILED SENT ERROR MESSAGE else if (!settings.create(out character, argument)) { SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE(); spkt.Result = 0x4; spkt.SessionId = cpkt.SessionId; this.Send((byte[])spkt); } //SUCCESSFULL CREATION else { SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE(); spkt.CharatcerId = character.ModelId; spkt.SessionId = cpkt.SessionId; this.Send((byte[])spkt); } } //DATABASE ERROR catch (Exception e) { Console.WriteLine(e); Console.ReadKey(); SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE(); spkt.Result = 0x6; spkt.SessionId = cpkt.SessionId; this.Send((byte[])spkt); } }
bool IDefaultCharacterSettings.create(out Character character, CharCreationArgument e) { //--------------------------------------------------------------------------- //Create temp character to contain our changes //--------------------------------------------------------------------------- Character tempChar = new Character(null, 0, 0); tempChar.Name = e.CharName; tempChar.FaceDetails = e.FaceDetails; //--------------------------------------------------------------------------- //Set race spefic positions //--------------------------------------------------------------------------- //Set default last location from character configuration tempChar.lastlocation = DefaultSaveLocation; //Set default save location from character configuration tempChar.savelocation = DefaultSaveLocation; //Set default starting location from character configuration tempChar.map = DefaultLocation.map; tempChar.Position = DefaultLocation.coords; //--------------------------------------------------------------------------- //Add inventory items //--------------------------------------------------------------------------- Rag2Item item; if (Singleton.Item.TryGetItemWithCount(4075, 10, out item)) tempChar.container.Add(item); if (Singleton.Item.TryGetItemWithCount(16061, 1, out item)) tempChar.container.Add(item); if (Singleton.Item.TryGetItemWithCount(4074, 1, out item)) tempChar.container.Add(item); if (Singleton.Item.TryGetItemWithCount(4076, 1, out item)) tempChar.container.Add(item); if (Singleton.Item.TryGetItemWithCount(4252, 1, out item)) tempChar.container.Add(item); if (Singleton.Item.TryGetItemWithCount(4253, 1, out item)) tempChar.container.Add(item); //--------------------------------------------------------------------------- //Add a weapon to your character //--------------------------------------------------------------------------- tempChar.weapons[0] = new Weapon(); tempChar.weapons[0]._weaponname = e.WeaponName; tempChar.weapons[0]._weapontype = 1; tempChar.weapons[0]._augeskill = 150001; tempChar.weapons[0]._weaponlevel = 1; tempChar.weapons[0]._suffix = e.WeaponAffix; tempChar.weapons[0]._active = 1; if (Singleton.Weapons.TryGetWeaponInfo(tempChar.weapons[0]._weapontype, tempChar.weapons[0]._weaponlevel, out tempChar.weapons[0].Info)) tempChar.weapons[0]._durabillity = (ushort)tempChar.weapons[0].Info.max_durabillity; //--------------------------------------------------------------------------- //Create a character by adding it to the database. //If the character is created than add the new skills to the database //--------------------------------------------------------------------------- if (Singleton.Database.TransactionInsert(tempChar, e.UserId)) { Singleton.Database.InsertNewSkill(tempChar.ModelId, 1407401, 1); Singleton.Database.InsertNewSkill(tempChar.ModelId, 1406901, 1); character = tempChar; return tempChar.ModelId > 0; } else { character = tempChar; return false; } }