Пример #1
0
        public bool Create(ulong guidlow, Player owner)
        {
            Contract.Assert(owner != null);

            Relocate(owner.GetPositionX(), owner.GetPositionY(), owner.GetPositionZ(), owner.GetOrientation());

            if (!IsPositionValid())
            {
                Log.outError(LogFilter.Player, "Corpse (guidlow {0}, owner {1}) not created. Suggested coordinates isn't valid (X: {2} Y: {3})",
                             guidlow, owner.GetName(), owner.GetPositionX(), owner.GetPositionY());
                return(false);
            }

            _Create(ObjectGuid.Create(HighGuid.Corpse, owner.GetMapId(), 0, guidlow));
            SetPhaseMask(owner.GetPhaseMask(), false);

            SetObjectScale(1);
            SetGuidValue(CorpseFields.Owner, owner.GetGUID());

            _cellCoord = GridDefines.ComputeCellCoord(GetPositionX(), GetPositionY());

            CopyPhaseFrom(owner);

            return(true);
        }
Пример #2
0
        public override void Visit(ICollection <WorldObject> objs)
        {
            List <Garrison.Plot> plots = i_garrison.GetPlots().ToList();

            if (!plots.Empty())
            {
                CellCoord cellCoord = i_cell.GetCellCoord();
                foreach (Garrison.Plot plot in plots)
                {
                    Position spawn = plot.PacketInfo.PlotPos;
                    if (cellCoord != GridDefines.ComputeCellCoord(spawn.GetPositionX(), spawn.GetPositionY()))
                    {
                        continue;
                    }

                    GameObject go = plot.CreateGameObject(i_map, i_garrison.GetFaction());
                    if (!go)
                    {
                        continue;
                    }

                    var cell = new Cell(cellCoord);
                    i_map.AddToGrid(go, cell);
                    go.AddToWorld();
                    ++i_gameObjects;
                }
            }
        }
Пример #3
0
        public bool LoadCorpseFromDB(ulong guid, SQLFields field)
        {
            //        0     1     2     3            4      5          6          7       8       9      10        11    12          13          14
            // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ? AND instanceId = ?

            float  posX  = field.Read <float>(0);
            float  posY  = field.Read <float>(1);
            float  posZ  = field.Read <float>(2);
            float  o     = field.Read <float>(3);
            ushort mapId = field.Read <ushort>(4);

            _Create(ObjectGuid.Create(HighGuid.Corpse, mapId, 0, guid));

            SetObjectScale(1.0f);
            SetDisplayId(field.Read <uint>(5));
            StringArray items = new StringArray(field.Read <string>(6), ' ');

            for (uint index = 0; index < EquipmentSlot.End; ++index)
            {
                SetItem(index, uint.Parse(items[(int)index]));
            }

            uint bytes1 = field.Read <uint>(7);
            uint bytes2 = field.Read <uint>(8);

            SetRace((Race)((bytes1 >> 8) & 0xFF));
            SetSex((Gender)((bytes1 >> 16) & 0xFF));
            SetSkin((byte)((bytes1 >> 24) & 0xFF));
            SetFace((byte)(bytes2 & 0xFF));
            SetHairStyle((byte)((bytes2 >> 8) & 0xFF));
            SetHairColor((byte)((bytes2 >> 16) & 0xFF));
            SetFacialHairStyle((byte)((bytes2 >> 24) & 0xFF));
            SetFlags((CorpseFlags)field.Read <byte>(9));
            SetCorpseDynamicFlags((CorpseDynFlags)field.Read <byte>(10));
            SetOwnerGUID(ObjectGuid.Create(HighGuid.Player, field.Read <ulong>(14)));
            SetFactionTemplate(CliDB.ChrRacesStorage.LookupByKey(m_corpseData.RaceID).FactionID);

            m_time = field.Read <uint>(11);

            uint instanceId = field.Read <uint>(13);

            // place
            SetLocationInstanceId(instanceId);
            SetMapId(mapId);
            Relocate(posX, posY, posZ, o);

            if (!IsPositionValid())
            {
                Log.outError(LogFilter.Player, "Corpse ({0}, owner: {1}) is not created, given coordinates are not valid (X: {2}, Y: {3}, Z: {4})",
                             GetGUID().ToString(), GetOwnerGUID().ToString(), posX, posY, posZ);
                return(false);
            }

            _cellCoord = GridDefines.ComputeCellCoord(GetPositionX(), GetPositionY());
            return(true);
        }
Пример #4
0
        public bool LoadCorpseFromDB(ulong guid, SQLFields field)
        {
            //        0     1     2     3            4      5          6          7       8       9      10        11    12          13          14
            // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ? AND instanceId = ?

            float  posX  = field.Read <float>(0);
            float  posY  = field.Read <float>(1);
            float  posZ  = field.Read <float>(2);
            float  o     = field.Read <float>(3);
            ushort mapId = field.Read <ushort>(4);

            _Create(ObjectGuid.Create(HighGuid.Corpse, mapId, 0, guid));

            SetObjectScale(1.0f);
            SetUInt32Value(CorpseFields.DisplayId, field.Read <uint>(5));
            _LoadIntoDataField(field.Read <string>(6), (int)CorpseFields.Item, EquipmentSlot.End);
            SetUInt32Value(CorpseFields.Bytes1, field.Read <uint>(7));
            SetUInt32Value(CorpseFields.Bytes2, field.Read <uint>(8));
            SetUInt32Value(CorpseFields.Flags, field.Read <byte>(9));
            SetUInt32Value(CorpseFields.DynamicFlags, field.Read <byte>(10));
            SetGuidValue(CorpseFields.Owner, ObjectGuid.Create(HighGuid.Player, field.Read <ulong>(14)));
            CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(GetGuidValue(CorpseFields.Owner));

            if (characterInfo != null)
            {
                SetUInt32Value(CorpseFields.FactionTemplate, CliDB.ChrRacesStorage.LookupByKey(characterInfo.RaceID).FactionID);
            }

            m_time = field.Read <uint>(11);

            uint instanceId = field.Read <uint>(13);

            // place
            SetLocationInstanceId(instanceId);
            SetMapId(mapId);
            Relocate(posX, posY, posZ, o);

            if (!IsPositionValid())
            {
                Log.outError(LogFilter.Player, "Corpse ({0}, owner: {1}) is not created, given coordinates are not valid (X: {2}, Y: {3}, Z: {4})",
                             GetGUID().ToString(), GetOwnerGUID().ToString(), posX, posY, posZ);
                return(false);
            }

            _cellCoord = GridDefines.ComputeCellCoord(GetPositionX(), GetPositionY());
            return(true);
        }
Пример #5
0
        public void LoadAreaTriggerSpawns()
        {
            uint oldMSTime = Time.GetMSTime();
            // Load area trigger positions (to put them on the server)
            //                                            0        1              2             3      4     5     6     7            8              9        10
            SQLResult templates = DB.World.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup FROM `areatrigger`");

            if (!templates.IsEmpty())
            {
                do
                {
                    ulong         spawnId       = templates.Read <ulong>(0);
                    AreaTriggerId areaTriggerId = new(templates.Read <uint>(1), templates.Read <byte>(2) == 1);
                    WorldLocation location      = new(templates.Read <uint>(3), templates.Read <float>(4), templates.Read <float>(5), templates.Read <float>(6), templates.Read <float>(7));

                    if (GetAreaTriggerTemplate(areaTriggerId) == null)
                    {
                        Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger that doesn't exist: Id: {areaTriggerId.Id}, IsServerSide: {areaTriggerId.IsServerSide} for SpawnId {spawnId}");
                        continue;
                    }

                    if (!GridDefines.IsValidMapCoord(location))
                    {
                        Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed an invalid position: SpawnId: {spawnId}, MapId: {location.GetMapId()}, Position: {location}");
                        continue;
                    }

                    AreaTriggerSpawn spawn = new();
                    spawn.SpawnId  = spawnId;
                    spawn.Id       = areaTriggerId;
                    spawn.Location = new WorldLocation(location);

                    spawn.PhaseUseFlags = templates.Read <byte>(8);
                    spawn.PhaseId       = templates.Read <uint>(9);
                    spawn.PhaseGroup    = templates.Read <uint>(10);

                    // Add the trigger to a map::cell map, which is later used by GridLoader to query
                    CellCoord cellCoord = GridDefines.ComputeCellCoord(spawn.Location.GetPositionX(), spawn.Location.GetPositionY());
                    if (!_areaTriggerSpawnsByLocation.ContainsKey((spawn.Location.GetMapId(), cellCoord.GetId())))
                    {
                        _areaTriggerSpawnsByLocation[(spawn.Location.GetMapId(), cellCoord.GetId())] = new SortedSet <ulong>();
Пример #6
0
        public bool Create(ulong guidlow, Player owner)
        {
            Cypher.Assert(owner != null);

            Relocate(owner.GetPositionX(), owner.GetPositionY(), owner.GetPositionZ(), owner.GetOrientation());

            if (!IsPositionValid())
            {
                Log.outError(LogFilter.Player, "Corpse (guidlow {0}, owner {1}) not created. Suggested coordinates isn't valid (X: {2} Y: {3})",
                             guidlow, owner.GetName(), owner.GetPositionX(), owner.GetPositionY());
                return(false);
            }

            _Create(ObjectGuid.Create(HighGuid.Corpse, owner.GetMapId(), 0, guidlow));

            SetObjectScale(1);
            SetOwnerGUID(owner.GetGUID());

            _cellCoord = GridDefines.ComputeCellCoord(GetPositionX(), GetPositionY());

            PhasingHandler.InheritPhaseShift(this, owner);

            return(true);
        }
Пример #7
0
        public void LoadAreaTriggerSpawns()
        {
            uint oldMSTime = Time.GetMSTime();
            // Load area trigger positions (to put them on the server)
            //                                            0        1              2             3      4     5     6     7            8              9        10
            SQLResult templates = DB.World.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, " +
                                                 //11     12          13          14          15          16          17          18
                                                 "Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ScriptName FROM `areatrigger`");

            if (!templates.IsEmpty())
            {
                do
                {
                    ulong            spawnId       = templates.Read <ulong>(0);
                    AreaTriggerId    areaTriggerId = new(templates.Read <uint>(1), templates.Read <byte>(2) == 1);
                    WorldLocation    location      = new(templates.Read <uint>(3), templates.Read <float>(4), templates.Read <float>(5), templates.Read <float>(6), templates.Read <float>(7));
                    AreaTriggerTypes shape         = (AreaTriggerTypes)templates.Read <byte>(11);

                    if (GetAreaTriggerTemplate(areaTriggerId) == null)
                    {
                        Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger that doesn't exist: Id: {areaTriggerId.Id}, IsServerSide: {areaTriggerId.IsServerSide} for SpawnId {spawnId}");
                        continue;
                    }

                    if (!GridDefines.IsValidMapCoord(location))
                    {
                        Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed an invalid position: SpawnId: {spawnId}, MapId: {location.GetMapId()}, Position: {location}");
                        continue;
                    }

                    if (shape >= AreaTriggerTypes.Max)
                    {
                        Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger SpawnId: {spawnId} with invalid shape {shape}.");
                        continue;
                    }

                    AreaTriggerSpawn spawn = new();
                    spawn.SpawnId  = spawnId;
                    spawn.Id       = areaTriggerId;
                    spawn.Location = new WorldLocation(location);

                    spawn.PhaseUseFlags = templates.Read <byte>(8);
                    spawn.PhaseId       = templates.Read <uint>(9);
                    spawn.PhaseGroup    = templates.Read <uint>(10);

                    spawn.Shape.TriggerType = shape;
                    unsafe
                    {
                        for (var i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
                        {
                            spawn.Shape.DefaultDatas.Data[i] = templates.Read <float>(12 + i);
                        }
                    }

                    spawn.ScriptId = Global.ObjectMgr.GetScriptId(templates.Read <string>(18));

                    // Add the trigger to a map::cell map, which is later used by GridLoader to query
                    CellCoord cellCoord = GridDefines.ComputeCellCoord(spawn.Location.GetPositionX(), spawn.Location.GetPositionY());
                    if (!_areaTriggerSpawnsByLocation.ContainsKey((spawn.Location.GetMapId(), cellCoord.GetId())))
                    {
                        _areaTriggerSpawnsByLocation[(spawn.Location.GetMapId(), cellCoord.GetId())] = new SortedSet <ulong>();