Beispiel #1
0
        static void DeserializeObject(WORLDMSG msgID, BinReader data)
        {
            string str  = data.ReadString();
            Type   type = dbTypes.GetType(str);

            if (type == null)
            {
                throw new Exception("Failed to deserialize " + str + ": type == null");
            }
            uint     ObjectID = data.ReadUInt32();
            DBObject obj      = GetDBObject(type, ObjectID);

            if (obj != null)
            {
                obj.Deserialize(data);
                // we will probably never deserialized an existing object
                Console.WriteLine("woooah! WorldServer deserialized a " + str + " that already exists. Notify something!");
            }
            else
            {
                obj = (DBObject)Activator.CreateInstance(type);
                obj.Deserialize(data);
                AddDBObject(obj);
            }

            if (type == typeof(DBCharacter))
            {
                int         n = data.ReadInt32();
                DBCharacter c = (DBCharacter)obj;
                if (n > 0)
                {
                    c.Items = new DBItem[n];
                    for (int i = 0; i < n; i++)
                    {
                        ObjectID = data.ReadUInt32();
                        DBItem item = (DBItem)GetDBObject(typeof(DBItem), ObjectID);
                        if (item == null)
                        {
                            item = new DBItem();
                            item.Deserialize(data);
                            AddDBObject(item);
                        }
                        else
                        {
                            item.Deserialize(data);
                        }
                        item.Template = (DBItemTemplate)GetDBObject(typeof(DBItemTemplate), item.TemplateID);
                        if (item.Template == null)
                        {
                            Console.WriteLine("Missing Item Template " + item.TemplateID);
                        }
                        c.Items[i] = item;
                    }
                }
                else
                {
                    c.Items = null;
                }
            }
        }
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        public override bool Read()
        {
            this.DoNotDoTimers = true;
            DBCharacter daochar = CharacterDao.GetById(this.Identity.Instance).FirstOrDefault();

            if (daochar != null)
            {
                this.Name           = daochar.Name;
                this.LastName       = daochar.LastName;
                this.FirstName      = daochar.FirstName;
                this.RawCoordinates = new Vector3 {
                    X = daochar.X, Y = daochar.Y, Z = daochar.Z
                };
                this.RawHeading = new Quaternion(daochar.HeadingX, daochar.HeadingY, daochar.HeadingZ, daochar.HeadingW);
            }

            foreach (int nano in UploadedNanosDao.ReadNanos(this.Identity.Instance))
            {
                this.UploadedNanos.Add(new UploadedNano()
                {
                    NanoId = nano
                });
            }

            this.BaseInventory.Read();
            base.Read();
            this.DoNotDoTimers = false;

            // Implement error checking
            return(true);
        }
Beispiel #3
0
 public PlayerObject(DBCharacter c) : base()
 {
     m_character               = c;
     m_nextLevelExp            = c.Level * 1000;
     m_character.Health        = c.Health;
     m_character.MaxHealth     = c.MaxHealth;
     m_character.Power         = c.Power;
     m_character.MaxPower      = c.MaxPower;
     m_character.Strength      = c.Strength;
     m_character.BaseStrength  = c.BaseStrength;
     m_character.Stamina       = c.Stamina;
     m_character.BaseStamina   = c.BaseStamina;
     m_character.Agility       = c.Agility;
     m_character.BaseAgility   = c.BaseAgility;
     m_character.Intellect     = c.Intellect;
     m_character.BaseIntellect = c.BaseIntellect;
     m_character.Spirit        = c.Spirit;
     m_character.BaseSpirit    = c.BaseSpirit;
     m_scale       = c.Scale;
     m_displayID   = c.DisplayID;
     m_playerFlags = 0;
     m_accessLevel = ACCESSLEVEL.NORMAL;
     Inventory     = new PlayerInventory(this);
     if (c.Items != null)
     {
         foreach (DBItem item in c.Items)
         {
             Inventory.CreateItem(item);
         }
     }
     ObjectManager.AddWorldObject(this);
 }
Beispiel #4
0
 /// <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;
     }
 }
Beispiel #5
0
        public override void Execute(MySqlConnection connection)
        {
            String query = "SELECT * FROM muonline.characters WHERE account='matias9'";

            //create mysql command
            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = query;
            cmd.Connection  = connection;

            try
            {
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    this.DBCharacter = new Data.DBCharacter();
                    this.DBCharacter.load(dataReader);
                }
                else
                {
                    Logging.LogManager.DefaultLogger.Warn("PlayerLoadTask could not read");
                }

                //close Data Reader
                dataReader.Close();
                Logging.LogManager.DefaultLogger.Trace("PlayerLoadTask executed");
            }
            catch (MySqlException ex)
            {
                Logging.LogManager.DefaultLogger.Error(ex.Message);
                Logging.LogManager.DefaultLogger.Error(ex.StackTrace);
            }
        }
        public WorldClient(DBCharacter character)
        {
            m_character = character;
            m_player    = WorldServer.Scripts.GetNewPlayerObject(character);

            WorldServer.AddClient(this);
        }
Beispiel #7
0
        static void OnPlayerEnterWorld(WORLDMSG msgID, BinReader data)
        {
            uint        id          = data.ReadUInt32();
            ACCESSLEVEL accesslevel = (ACCESSLEVEL)data.ReadByte();
            DBCharacter c           = (DBCharacter)DBManager.GetDBObject(typeof(DBCharacter), id);

            if (c == null)
            {
                Console.WriteLine("Failed to enter world with id " + id + ". WorldServer is missing Character object");
                return;
            }
            WorldClient client = new WorldClient(c);
            MapInstance map    = (MapInstance)m_maps[c.WorldMapID];

            if (map == null)
            {
                Console.WriteLine("Worldserver is not handling " + c.WorldMapID + "!");
                client.LeaveWorld();
                return;
            }
            map.SetObjectPositionInBounds(client.Player);
            //client.CreatePlayerObject();
            client.Player.AccessLvl = accesslevel;
            map.Enter(client.Player);
        }
Beispiel #8
0
        public void CreateCharacter(DBCharacter Char)
        {
            Log.Info("CreateCharacter", "Creation du personnage : " + Char.Name);

            Database.AddObject(Char);
            AddCharacter(new CharacterInfo(Char));
        }
Beispiel #9
0
            static bool OnGuildSetONote(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild tguild = client.Character.Guild;

                if (tguild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }
                DBCharacter tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), data.ReadString());

                if (tChar == null)
                {
                    return(true);
                }
                DBGuildMembers tMember = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), tChar.ObjectId);

                if (tMember == null)
                {
                    Chat.System(client, "No member found for " + tChar.Name);
                    return(true);
                }
                tMember.OfficerNote = data.ReadString();
                DataServer.Database.SaveObject(tMember);
                SendRoster(client, tguild);
                return(true);
            }             //OnGuildRoster
        private void SendEnterWorld(DBCharacter c)
        {
            WorldPacket pkg = new WorldPacket(WORLDMSG.PLAYER_ENTER_WORLD);

            pkg.Write(c.ObjectId);
            Send(pkg);
        }
Beispiel #11
0
        /// <summary>
        /// </summary>
        /// <param name="charId">
        /// </param>
        /// <returns>
        /// </returns>
        public static DBLoginData GetByCharacterId(int charId)
        {
            DBCharacter character = null;

            try
            {
                using (IDbConnection conn = Connector.GetConnection())
                {
                    character = CharacterDao.GetById(charId).First();
                    DynamicParameters p = new DynamicParameters();
                    p.Add("username", character.Username);
                    return(conn.Query <DBLoginData>("SELECT * FROM login WHERE Username=@username", p).First());
                }
            }
            catch (Exception)
            {
                if (character == null)
                {
                    LogUtil.Debug("No character " + charId + " in database. huh?");
                }
                else
                {
                    LogUtil.Debug("No Account found for Character " + character.Name + " (" + character.Id + ")");
                }

                throw;
            }
        }
Beispiel #12
0
            static bool OnGuildLeader(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if (client.Character.GuildRank != 0)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (tChar == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                    return(true);
                }

                else if (client.Character.GuildID != tChar.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }

                DBGuildMembers tMember = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), tChar.ObjectId);

                if (tMember == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.INTERNAL);
                    return(true);
                }

                tChar.GuildRank            = 0;
                tMember.Rank               = 0;
                guild.Leader               = tChar.ObjectId;
                client.Character.GuildRank = 1;
                DBGuildMembers oldLeader = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), client.Character.ObjectId);

                if (oldLeader == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.INTERNAL);
                    return(true);
                }
                oldLeader.Rank = 1;

                SendToWorld(client, tChar);
                SendToWorld(client, client.Character);

                GuildMessage(guild, tChar.Name + " has been promoted to the rank of " + guild.getRankName(tChar.GuildRank) + " by " + client.Character.Name);
                SendRoster(client, guild);
                return(true);
            }            //OnGuildLeader
Beispiel #13
0
        public static void PlayerLogin(LoginClient client, uint id)
        {
            if (client.Account == null)
            {
                client.Close("Tried to login with a character without an account.");
                return;
            }
            DataObject[] chars = DataServer.Database.SelectObjects(typeof(DBCharacter), "Character_ID = '" + id + "'");
            if (chars.Length == 0)
            {
                client.Close("Failed to find character in database?");
                return;
            }
            DBCharacter c = (DBCharacter)chars[0];

            if (c.AccountID != client.Account.ObjectId)
            {
                client.Close("Tried to login another account's character.");
                return;
            }
            client.Character = c;
            if (c.WorldMapID == 0)
            {
                client.Close(c.Name + " is missing world map id.");
                return;
            }
            client.WorldConnection = (WorldConnection)m_worldMapServer[c.WorldMapID];
            if (client.WorldConnection == null)
            {
                client.Close("Missing worldserver for world map id " + c.WorldMapID);
                return;
            }
            m_loginCharacters[id] = client;
            client.OnEnterWorld();
        }
Beispiel #14
0
        /// <summary>
        /// </summary>
        /// <param name="startInSL">
        /// </param>
        /// <param name="charid">
        /// </param>
        public void SendNameToStartPlayfield(bool startInSL, int charid)
        {
            int playfield, x, y, z;

            if (startInSL)
            {
                playfield = 4001;
                x         = 850;
                y         = 43;
                z         = 565;
            }
            else
            {
                playfield = 4582;
                x         = 939;
                y         = 20;
                z         = 732;
            }

            DBCharacter character = CharacterDao.Instance.Get(charid);

            if (character != null)
            {
                CharacterDao.Instance.Save(
                    character // woo....
                    ,
                    new { Id = charid, Playfield = playfield, X = x, Y = y, Z = z });

                CharacterDao.Instance.SetPlayfield(charid, (int)IdentityType.Playfield, playfield);
            }
        }
Beispiel #15
0
        /// <summary>
        /// </summary>
        /// <param name="charId">
        /// </param>
        /// <exception cref="Exception">
        /// </exception>
        public void CreateCharacter(int charId)
        {
            this.character = new Character(new Identity {
                Type = IdentityType.CanbeAffected, Instance = charId
            }, this);
            IEnumerable <DBCharacter> daochar = CharacterDao.GetById(charId);

            if (daochar.Count() == 0)
            {
                throw new Exception("Character " + charId.ToString() + " not found.");
            }

            if (daochar.Count() > 1)
            {
                throw new Exception(
                          daochar.Count().ToString() + " Characters with id " + charId.ToString()
                          + " found??? Check Database setup!");
            }

            DBCharacter character = daochar.First();

            this.character.Name        = character.Name;
            this.character.LastName    = character.LastName;
            this.character.FirstName   = character.FirstName;
            this.character.Coordinates = new AOCoord(character.X, character.Y, character.Z);
            this.character.Heading     = new Quaternion(
                character.HeadingX, character.HeadingY, character.HeadingZ, character.HeadingW);
            this.character.Playfield = this.server.PlayfieldById(character.Playfield);
            this.Playfield           = this.character.Playfield;
            this.Playfield.Entities.Add(this.character);
            this.character.Stats.Read();
            this.character.BaseInventory.Read();
        }
Beispiel #16
0
            static bool OnGuildInvite(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.INVITE) != (uint)GUILDFLAGS.INVITE)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter character = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (character == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                }

                else
                {
                    LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(character.ObjectId);
                    if (targetClient != null)
                    {
//						targetClient.Character.LastGuildID=client.Character.GuildID;
                        if (targetClient.Character.LastGuildInviterID != 0)
                        {
                            SendResult(client, 1, name, (int)GUILDRESULT.ALREADY_INVITED_TO_GUILD_S);
                            return(true);
                        }

                        if (targetClient.Character.GuildID != 0)
                        {
                            SendResult(client, 1, targetClient.Character.Name, (int)GUILDRESULT.ALREADY_IN_GUILD_S);
                            return(true);
                        }

                        targetClient.Character.LastGuildInviterID = client.Character.ObjectId;

                        BinWriter gpkg = LoginClient.NewPacket(SMSG.GUILD_INVITE);
                        gpkg.Write(client.Character.Name);
                        gpkg.Write(guild.Name);
                        targetClient.Send(gpkg);
                        SendResult(client, 1, name, (int)GUILDRESULT.SUCCESS);
                    }
                    else
                    {
                        Chat.System(client, name + " is not currently online");
                    }
                }

                return(true);
            }            //OnGuildInvite
Beispiel #17
0
        private void SendEnterWorld(DBCharacter c, ACCESSLEVEL accesslevel)
        {
            WorldPacket pkg = new WorldPacket(WORLDMSG.PLAYER_ENTER_WORLD);

            pkg.Write(c.ObjectId);
            pkg.Write((byte)accesslevel);
            Send(pkg);
        }
        private void SendDBObject(DBCharacter obj)
        {
            WorldPacket pkg = new WorldPacket(WORLDMSG.DESERIALIZE_OBJ);

            pkg.Write(obj.GetType().ToString());
            pkg.Write(obj.ObjectId);
            obj.Serialize(pkg);
            obj.SerializeItems(pkg);
            Send(pkg);
        }
Beispiel #19
0
        public static void SendToWorld(LoginClient client, DBCharacter tChar)
        {
            ScriptPacket scrpkg = new ScriptPacket(SCRMSG.GUILDUPDATE);

            scrpkg.Write(tChar.ObjectId);
            scrpkg.Write(tChar.GuildID);
            scrpkg.Write(tChar.GuildRank);
            client.WorldConnection.Send(scrpkg);
            return;
        }
Beispiel #20
0
            static bool OnGuildDemote(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.DEMOTE) != (uint)GUILDFLAGS.DEMOTE)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (tChar == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                    return(true);
                }

                else if (client.Character.GuildID != tChar.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }
                //		2					1
                if (tChar.GuildRank <= client.Character.GuildRank)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.RANK_TO_HIGH);
                    return(true);
                }
                else if (tChar.GuildRank >= guild.MaxRank)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.RANK_TO_LOW);
                    return(true);
                }

                DBGuildMembers tMember = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), tChar.ObjectId);

                if (tMember != null)
                {
                    tChar.GuildRank++;
                }
                tMember.Rank++;
                SendToWorld(client, tChar);
                GuildMessage(guild, tChar.Name + "has been demoted to the rank of " + guild.getRankName(tChar.GuildRank) + " by " + client.Character.Name);
                SendRoster(client, guild);
                return(true);
            }            //OnGuildDemote
Beispiel #21
0
            static bool OnGuildRemove(LoginClient client, CMSG msgID, BinReader data)
            {
                DBGuild guild = client.Character.Guild;

                if (guild == null || client.Character.GuildID == 0)
                {
                    SendResult(client, 2, " ", (int)GUILDRESULT.NOT_IN_GUILD);
                    return(true);
                }

                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.DEMOTE) != (uint)GUILDFLAGS.DEMOTE)
                {
                    SendResult(client, 1, " ", (int)GUILDRESULT.PERMISSIONS);
                    ; return(true);
                }

                string name = data.ReadString();

                DBCharacter tChar = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), name.ToLower());

                if (tChar == null)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_FOUND);
                    return(true);
                }

                else if (client.Character.GuildID != tChar.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }
                //		2					1
                if (tChar.GuildRank <= client.Character.GuildRank)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.RANK_TO_HIGH);
                    return(true);
                }

                DBGuildMembers member = (DBGuildMembers)DataServer.Database.FindObjectByKey(typeof(DBGuildMembers), tChar.ObjectId);

                if (member == null || member.GuildID != client.Character.GuildID)
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.NOT_IN_GUILD_S);
                    return(true);
                }
                if (RemoveMember(member, client))
                {
                    Chat.System(client, "You have removed " + tChar.Name + " from the guild");
                }
                else
                {
                    SendResult(client, 1, name, (int)GUILDRESULT.INTERNAL);
                }
                return(true);
            }            //OnGuildRemove
 private void Send(DBCharacter c)
 {
     if (c.Items != null)
     {
         foreach (DBItem item in c.Items)
         {
             Send(item.Template);
         }
     }
     SendDBObject(c);
 }
        public static void PlayerLogin(LoginClient client, uint id)
        {
            if (client.Account == null)
            {
                client.Close("Tried to login with a character without an account.");
                return;
            }
            DataObject[] chars = DataServer.Database.SelectObjects(typeof(DBCharacter), "Character_ID = '" + id + "'");
            if (chars.Length == 0)
            {
                client.Close("Failed to find character in database?");
                return;
            }
            DBCharacter c = (DBCharacter)chars[0];

            if (c.AccountID != client.Account.ObjectId)
            {
                client.Close("Tried to login another account's character.");
                return;
            }
            client.Character = c;
            if (client.Character.GuildID != 0)
            {
                DBGuild guild = (DBGuild)DataServer.Database.FindObjectByKey((typeof(DBGuild)), client.Character.GuildID);
                if (guild != null)
                {
                    client.Character.Guild     = guild;
                    client.Character.GuildName = guild.Name;
                }
                else
                {
                    client.Character.GuildID   = 0;
                    client.Character.GuildRank = 0;
                    client.Character.GuildName = " ";
                }
            }
            string[] RemoteIP = client.RemoteEndPoint.ToString().Split(':');
            client.Account.LastIP = RemoteIP[0];
            if (c.WorldMapID == 0)
            {
                client.Close(c.Name + " is missing world map id.");
                return;
            }
            client.WorldConnection = (WorldConnection)m_worldMapServer[c.WorldMapID];
            if (client.WorldConnection == null)
            {
                client.Close("Missing worldserver for world map id " + c.WorldMapID);
                return;
            }
            m_loginCharacters[id] = client;
            FriendIsOnline(client);
            client.OnEnterWorld();
//			client.WorldConnection.OnEnterWorld(client.Character, client.Account.AccessLvl);
        }
Beispiel #24
0
        public GamePlayer(DBCharacter c) : base(c)
        {
            if (base.Health < 0)
            {
                base.Dead = true;
            }
            saveEvent = new GamePlayerSaveEvent(this);
            EventManager.AddEvent(saveEvent);

            playerregen = new PlayerRegen(this);
            EventManager.AddEvent(playerregen);
        }
Beispiel #25
0
        /// <summary>
        /// </summary>
        /// <param name="charId">
        /// </param>
        /// <exception cref="Exception">
        /// </exception>
        public void CreateCharacter(int charId)
        {
            DBCharacter character = CharacterDao.Instance.Get(charId);

            if (character == null)
            {
                throw new Exception("Character " + charId + " not found.");
            }

            // TODO: Save playfield type into Character table and use it accordingly
            IPlayfield pf =
                this.server.PlayfieldById(
                    new Identity()
            {
                Type = IdentityType.Playfield, Instance = character.Playfield
            });

            if (
                Pool.Instance.GetObject <Character>(
                    new Identity()
            {
                Type = IdentityType.CanbeAffected, Instance = charId
            }) == null)
            {
                this.Controller.Character = new Character(
                    pf.Identity,
                    new Identity {
                    Type = IdentityType.CanbeAffected, Instance = charId
                },
                    this.Controller);
                this.controller.Character.Read();
            }
            else
            {
                this.Controller.Character =
                    Pool.Instance.GetObject <Character>(
                        new Identity()
                {
                    Type = IdentityType.CanbeAffected, Instance = charId
                });
                this.Controller.Character.Reconnect(this);
                LogUtil.Debug(DebugInfoDetail.Engine, "Reconnected to Character " + charId);
            }

            // Stop pending logouts
            this.Controller.Character.StopLogoutTimer();

            this.Controller.Character.Playfield = pf;
            this.Playfield = pf;
            this.Controller.Character.Stats.Read();
            this.controller.Character.Stats[StatIds.visualprofession].BaseValue = (uint)this.controller.Character.Stats[StatIds.profession].Value;
        }
        public void UpdatePlayerObject(WorldObject obj, bool self, DBCharacter m_character)
        {
            w.Write((byte)1);
            w.Write(0);
            w.Write((byte)0);
            w.Write((byte)2);
            w.Write(obj.GUID);
            w.Write((byte)obj.ObjectType);
            w.Write(0);
            w.Write(0);
            w.WriteVector(obj.Position);
            w.Write(obj.Facing);
            w.Write(obj.WalkSpeed);
            w.Write(obj.RunningSpeed);
            w.Write(obj.RunBackSpeed);
            w.Write(obj.SwimSpeed);
            w.Write(obj.SwimBackSpeed);
            w.Write(obj.TurnRate);
            if (self == true)
            {
                w.Write(1);
            }
            else
            {
                w.Write(0);
            }
            w.Write(1);
            w.Write(0);
            w.Write(0);
            w.Write(0);

            c = 0;

            Add((int)OBJECTFIELDS.GUID, obj.GUID);
            Add((int)OBJECTFIELDS.HIER_TYPE, (long)obj.HierType);
            Add((int)OBJECTFIELDS.SCALE, (float)1.0);



            BinWriter pkg = new BinWriter();

            pkg.Write((int)w.BaseStream.Length);
            pkg.Write(w.GetBuffer());
            Send(SMSG.UPDATE_OBJECT, pkg, m_character);



            /*pkg.Write((int)w.BaseStream.Length);
             * pkg.Write(ZLib.Compress(w.GetBuffer(), 0, (int)w.BaseStream.Length));
             * Send(SMSG.UPDATE_OBJECT, pkg);*/
        }
Beispiel #27
0
        /// <summary>
        /// </summary>
        /// <param name="charId">
        /// </param>
        /// <exception cref="Exception">
        /// </exception>
        public void CreateCharacter(int charId)
        {
            IEnumerable <DBCharacter> daochar = CharacterDao.GetById(charId);

            if (daochar.Count() == 0)
            {
                throw new Exception("Character " + charId + " not found.");
            }

            if (daochar.Count() > 1)
            {
                throw new Exception(
                          daochar.Count() + " Characters with id " + charId + " found??? Check Database setup!");
            }

            DBCharacter character = daochar.First();
            IPlayfield  pf        = this.server.PlayfieldById(character.Playfield);

            if (pf.Entities.GetObject <Character>(
                    new Identity()
            {
                Type = IdentityType.CanbeAffected, Instance = charId
            }) == null)
            {
                this.character = new Character(
                    pf.Entities,
                    new Identity {
                    Type = IdentityType.CanbeAffected, Instance = charId
                },
                    this);
            }
            else
            {
                this.character =
                    pf.Entities.GetObject <Character>(
                        new Identity()
                {
                    Type = IdentityType.CanbeAffected, Instance = charId
                });
                this.character.Reconnect(this);
                LogUtil.Debug("Reconnected to Character " + charId);
            }

            // Stop pending logouts
            this.character.StopLogoutTimer();

            this.character.Playfield = pf;
            this.Playfield           = pf;
            this.character.Stats.Read();
        }
 public void Send(SMSG msgID, BinWriter data, DBCharacter m_character)
 {
     try
     {
         ServerPacket pkg = new ServerPacket(msgID);
         pkg.Write(data.GetBuffer(), 0, (int)data.BaseStream.Length);
         pkg.Finish();
         pkg.AddDestination(m_character.ObjectId);
         WorldServer.Send(pkg);
     }
     catch (Exception exp)
     {
         DebugLogger.Log("", exp);
     }
 }
Beispiel #29
0
        //		[UpdateValueAttribute(PLAYERFIELDS.SKILL_INFO, ArraySize=384)]
        //		protected uint [] m_skill_info;

        public PlayerObject(DBCharacter c) : base()
        {
            m_character                     = c;
            m_character.Health              = c.Health;
            m_character.MaxHealth           = c.MaxHealth;
            m_character.Power               = c.Power;
            m_character.MaxPower            = c.MaxPower;
            m_character.Strength            = c.Strength;
            m_character.BaseStrength        = c.BaseStrength;
            m_character.Stamina             = c.Stamina;
            m_character.BaseStamina         = c.BaseStamina;
            m_character.Agility             = c.Agility;
            m_character.BaseAgility         = c.BaseAgility;
            m_character.Intellect           = c.Intellect;
            m_character.BaseIntellect       = c.BaseIntellect;
            m_character.Spirit              = c.Spirit;
            m_character.BaseSpirit          = c.BaseSpirit;
            m_character.AttackPower         = c.AttackPower;
            m_character.AttackPowerModifier = c.AttackPowerModifier;
            m_character.GuildID             = c.GuildID;
            m_character.GuildRank           = c.GuildRank;
            m_character.GuildTimeStamp      = WorldClock.GetTimeStamp();


            m_scale           = c.Scale;
            m_displayID       = c.DisplayID;
            m_nativedisplayID = c.DisplayID;
            m_playerFlags     = 0;
            m_accessLevel     = ACCESSLEVEL.NORMAL;
            m_baseattacktime  = 2000;
            //			m_skill_info = new uint[384];
            //			m_skill_info[0] = 133;	//Just for a test, Mage spell fireball
            Inventory = new PlayerInventory(this);
            if (c.Items != null)
            {
                foreach (DBItem item in c.Items)
                {
                    Inventory.CreateItem(item);
                }
            }
            StatManager.CalculateNextLevelExp(this);
            StatManager.CalculateNewStats(this);

            ObjectManager.AddWorldObject(this);
            EventManager.AddEvent(new AggrMonsterEvent(this));
            EventManager.AddEvent(new RoamingEvent(this));
        }
Beispiel #30
0
            static bool OnGiveTabard(LoginClient client, string input)
            {
                if (client.Character.GuildID == 0 || client.Character.GuildRank > 1)
                {
                    Chat.System(client, "Only a guild leader or first officer may give out tabards");
                    return(true);
                }
                if (client.Character.Guild.Color == 0xFFFFFFFF)
                {
                    Chat.System(client, "You must first purchase a tabard from a tabard vendor before you can give them out");
                    return(true);
                }
                string[] split = input.Split(' ');
                if (split.Length < 2)
                {
                    return(false);
                }
                DBCharacter targetmember = (DBCharacter)DataServer.Database.FindObjectByKey(typeof(DBCharacter), split[1]);

                if (targetmember == null)
                {
                    Chat.System(client, "Player not found"); return(true);
                }

                if (targetmember.GuildID != client.Character.GuildID)
                {
                    Chat.System(client, "That player is not a member of your guild");
                    return(true);
                }

                DBItem newItem = new DBItem();

                newItem.OwnerID    = targetmember.ObjectId;
                newItem.OwnerSlot  = 18;
                newItem.TemplateID = 343;
                DataServer.Database.AddNewObject(newItem);
                DataServer.Database.FillObjectRelations(newItem);
                client.WorldConnection.Send(newItem);

                ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM);

                Item.Write(targetmember.ObjectId);
                Item.Write(newItem.ObjectId);
                Item.Write((int)0);
                client.WorldConnection.Send(Item);
                return(true);
            }
Beispiel #31
0
        public void CreateCharacter(DBCharacter Char)
        {
            Log.Info("CreateCharacter", "Creation du personnage : " + Char.Name);

            Database.AddObject(Char);
            AddCharacter(new CharacterInfo(Char));
        }
Beispiel #32
0
        private bool _Online = false; // True si le joueur est en jeu

        #endregion Fields

        #region Constructors

        public CharacterInfo(DBCharacter Character)
        {
            _Character = Character;
        }