Exemplo n.º 1
0
        internal Mob(MapData.MapMobData pData)
        {
            mData = pData;
            mUniqueIdentifier = ++sUniqueCounter;
            mStance = (byte)((mData.Flags & MapData.MapMobData.EMapMobFlags.FacesLeft) != MapData.MapMobData.EMapMobFlags.None ? 0 : 1);
            mFoothold = mData.Foothold;
            mPosition = new Coordinates(mData.X, mData.Y);

            MobData mobData = Server.GetMobData(mData.MobIdentifier);
            mHealth = mMaxHealth = mobData.HP;
            mMana = mMaxMana = mobData.MP;
        }
Exemplo n.º 2
0
 public bool ReadCoordinates(out Coordinates pValue)
 {
     short x;
     short y;
     pValue = null;
     if (!ReadShort(out x) || !ReadShort(out y)) return false;
     pValue = new Coordinates(x, y);
     return true;
 }
Exemplo n.º 3
0
 public void WriteCoordinates(Coordinates pValue)
 {
     WriteShort(pValue.X);
     WriteShort(pValue.Y);
 }
Exemplo n.º 4
0
        public Player(Client pClient, DatabaseQuery pQuery)
        {
            mClient = pClient;
            mRandom = new Random();

            mIdentifier = (int)pQuery["identifier"];
            mName = (string)pQuery["name"];
            mGender = (byte)pQuery["gender"];
            mSkin = (byte)pQuery["skin"];
            mEyesIdentifier = (int)pQuery["eyes_identifier"];
            mHairIdentifier = (int)pQuery["hair_identifier"];
            mLevel = (byte)pQuery["level"];
            mJob = (ushort)pQuery["job"];
            mStrength = (ushort)pQuery["strength"];
            mDexterity = (ushort)pQuery["dexterity"];
            mIntellect = (ushort)pQuery["intellect"];
            mLuck = (ushort)pQuery["luck"];
            mHealth = (ushort)pQuery["health"];
            mMaxHealth = (ushort)pQuery["max_health"];
            mMana = (ushort)pQuery["mana"];
            mMaxMana = (ushort)pQuery["max_mana"];
            mAbilityPoints = (ushort)pQuery["ability_points"];
            mSkillPoints = (ushort)pQuery["skill_points"];
            mExperience = (int)pQuery["experience"];
            mFame = (ushort)pQuery["fame"];

            int mapIdentifier = (int)pQuery["map_identifier"];
            MapData mapData = Server.GetMapData(mapIdentifier);
            byte spawn = (byte)pQuery["map_spawn"];
            if (mapData.ForcedReturnMapIdentifier != MapData.INVALID_MAP_IDENTIFIER)
            {
                mapData = Server.GetMapData(mapData.ForcedReturnMapIdentifier);
                spawn = 0;
                if (mHealth == 0) mHealth = 50;
            }
            else if (mHealth == 0)
            {
                mapData = Server.GetMapData(mapData.ReturnMapIdentifier);
                spawn = 0;
                mHealth = 50;
            }
            mMap = Server.GetActiveMap(mapData.Identifier);
            mSpawn = spawn;
            mPosition = new Coordinates(mapData.Portals[spawn].X, mapData.Portals[spawn].Y);

            using (DatabaseQuery query = Database.Query("SELECT * FROM player_item WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                byte[] slots = new byte[(byte)EInventoryType.Count];
                slots[(byte)EInventoryType.Equipment] = (byte)pQuery["equipment_slots"];
                slots[(byte)EInventoryType.Use] = (byte)pQuery["use_slots"];
                slots[(byte)EInventoryType.Setup] = (byte)pQuery["setup_slots"];
                slots[(byte)EInventoryType.Etc] = (byte)pQuery["etc_slots"];
                slots[(byte)EInventoryType.Cash] = (byte)pQuery["cash_slots"];
                mItems = new PlayerItems((int)pQuery["mesos"], slots, query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_skill WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                mSkills = new PlayerSkills(query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_quest WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                mQuests = new PlayerQuests(query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_teleport WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                mTeleports = new PlayerTeleports(query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_card WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                mCards = new PlayerCards(query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_macro WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                mMacros = new PlayerMacros(query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_keymap WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                query.NextRow();
                mKeymap = new PlayerKeymap(query);
            }
            using (DatabaseQuery query = Database.Query("SELECT * FROM player_buddy WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier)))
            {
                mBuddies = new PlayerBuddies((byte)pQuery["buddy_slots"], query);
            }
        }