/// <summary> /// Insert a new character /// </summary> /// <param name="character"> /// The DBCharacter object to store /// </param> public static void AddCharacter(DBCharacter character) { try { using (IDbConnection conn = Connector.GetConnection()) { conn.Execute( "INSERT INTO characters (Name, FirstName, LastName, Textures0,Textures1,Textures2,Textures3,Textures4" + ",playfield, X,Y,Z,HeadingX,HeadingY,HeadingZ,HeadingW,Username) VALUES (@Name, @FirstName, " + "@LastName, @Textures0, @Textures1, @Textures3, @Textures4, @Playfield, @X, @Y, @Z, @HeadingX, @HeadingY, " + "@HeadingZ, @HeadingW, @Online,@username)", new { character.Name, character.FirstName, character.LastName, character.Textures0, character.Textures1, character.Textures2, character.Textures3, character.Textures4, character.Playfield, character.X, character.Y, character.Z, character.HeadingX, character.HeadingY, character.HeadingZ, character.HeadingW, Online = 0, username = character.Username }); } } catch (Exception e) { LogUtil.ErrorException(e); throw; } }
/// <summary> /// Write back the position of the Characer /// </summary> /// <param name="character"> /// DBCharacte object /// </param> public static void UpdatePosition(DBCharacter character) { try { using (IDbConnection conn = Connector.GetConnection()) { conn.Execute( "UPDATE characters SET X = @X, Y = @Y, Z = @Z, HeadingX=@hX, HeadingY=@hY, HeadingZ=@hZ, HeadingW=@hW WHERE id=@Id", new { character.X, character.Y, character.Z, character.Id, hX = character.HeadingX, hZ = character.HeadingZ, hY = character.HeadingY, hW = character.HeadingW }); } } catch (Exception e) { LogUtil.ErrorException(e); throw; } }
/// <summary> /// </summary> /// <returns> /// charID /// </returns> private int CreateNewChar() { DBCharacter newCharacter = new DBCharacter { FirstName = string.Empty, LastName = string.Empty, Name = this.Name, Username = this.AccountName, }; CharacterDao.Instance.Add(newCharacter); int charID = newCharacter.Id; #region Statistics switch (this.Breed) { case 0x1: /* solitus */ this.Abis = new[] { 6, 6, 6, 6, 6, 6 }; break; case 0x2: /* opifex */ this.Abis = new[] { 3, 3, 10, 6, 6, 15 }; break; case 0x3: /* nanomage */ this.Abis = new[] { 3, 10, 6, 15, 3, 3 }; break; case 0x4: /* atrox */ this.Abis = new[] { 15, 3, 3, 3, 10, 6 }; break; default: Console.WriteLine("unknown breed: {0}", this.Breed); break; } List<DBStats> stats = new List<DBStats>(); // Transmit GM level into stats table stats.Add( new DBStats { Type = 50000, Instance = charID, StatId = 215, StatValue = LoginDataDao.Instance.GetByUsername(this.AccountName).GM }); // Flags stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 0, StatValue = 0x00081241 }); // Level stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 54, StatValue = 1 }); // SEXXX stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 59, StatValue = this.Gender }); // Headmesh stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 64, StatValue = this.HeadMesh }); // MonsterScale stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 360, StatValue = this.MonsterScale }); // Visual Sex (even better ^^) stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 369, StatValue = this.Gender }); // Breed stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 4, StatValue = this.Breed }); // Visual Breed stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 367, StatValue = this.Breed }); // Profession / 60 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 60, StatValue = this.Profession }); // VisualProfession / 368 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 368, StatValue = this.Profession }); // Fatness / 47 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 47, StatValue = this.Fatness }); // Strength / 16 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 16, StatValue = this.Abis[0] }); // Psychic / 21 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 21, StatValue = this.Abis[1] }); // Sense / 20 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 20, StatValue = this.Abis[2] }); // Intelligence / 19 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 19, StatValue = this.Abis[3] }); // Stamina / 18 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 18, StatValue = this.Abis[4] }); // Agility / 17 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 17, StatValue = this.Abis[5] }); // Set HP and NP auf 1 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 1, StatValue = 1 }); stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 214, StatValue = 1 }); // NPCFamily / 455 stats.Add(new DBStats { Type = 50000, Instance = charID, StatId = 455, StatValue = 0 }); stats.Add( new DBStats { Type = 50000, Instance = charID, StatId = 389, StatValue = LoginDataDao.Instance.GetByUsername(this.AccountName).Expansions }); StatDao.Instance.BulkReplace(stats); #endregion return charID; }
/// <summary> /// </summary> /// <param name="startInSL"> /// </param> /// <param name="charid"> /// </param> public void SendNameToStartPlayfield(bool startInSL, int charid) { DBCharacter dbCharacter = new DBCharacter { Id = charid, Playfield = 4001, X = 850, Y = 43, Z = 565 }; if (!startInSL) { dbCharacter.Playfield = 4582; dbCharacter.X = 939; dbCharacter.Y = 20; dbCharacter.Z = 732; } CharacterDao.UpdatePosition(dbCharacter); CharacterDao.SetPlayfield(dbCharacter.Id, (int)IdentityType.Playfield, dbCharacter.Playfield); }
/// <summary> /// </summary> /// <returns> /// </returns> internal DBCharacter GetDBCharacter() { DBCharacter temp = new DBCharacter(); temp.FirstName = this.FirstName; temp.LastName = this.LastName; temp.HeadingW = this.RawHeading.wf; temp.HeadingX = this.RawHeading.xf; temp.HeadingY = this.RawHeading.yf; temp.HeadingZ = this.RawHeading.zf; temp.X = this.RawCoordinates.X; temp.Y = this.RawCoordinates.Y; temp.Z = this.RawCoordinates.Z; temp.Id = this.Identity.Instance; temp.Name = this.Name; temp.Online = 1; temp.Playfield = this.Playfield.Identity.Instance; return temp; }