Esempio n. 1
0
        /// <summary>
        /// Gets the zone of given id, lazy loading it if necessary.
        /// </summary>
        /// <param name="zoneId">Id of the zone to get</param>
        /// <returns>Zone or null if zone info does not exists</returns>
        public ZoneMgr GetZoneMgr(ushort zoneId)
        {
            Zone_Info info = GetZone_Info(zoneId);

            if (info == null)
            {
                return(null);
            }

            ZoneMgr mgr = null;

            foreach (ZoneMgr z in ZonesMgr)
            {
                if (z != null && z.Info.ZoneId == zoneId)
                {
                    mgr = z;
                    break;
                }
            }

            if (mgr == null)
            {
                mgr = new ZoneMgr(this, info);
                ZonesMgr.Add(mgr);
            }

            return(mgr);
        }
Esempio n. 2
0
        private void UpdateMove(long tick)
        {
            if (MovementSpeed == 0 || _unit != null && _unit.IsDisabled || _unit != null && _unit.IsStaggered)
            {
                return;
            }

            long deltaMs = tick - _moveStartTime;

            uint newWorldPosX = (uint)Point2D.Lerp(_startWorldPos.X, _destWorldPos.X, GetMoveFactor(deltaMs));
            uint newWorldPosY = (uint)Point2D.Lerp(_startWorldPos.Y, _destWorldPos.Y, GetMoveFactor(deltaMs));

            Zone_Info destZone = _unit.Region.GetZone((ushort)(newWorldPosX >> 12), (ushort)(newWorldPosY >> 12));

            if (destZone == null)
            {
                return;
            }

            ushort pinX = _unit.Zone.CalculPin(newWorldPosX, true);
            ushort pinY = _unit.Zone.CalculPin(newWorldPosY, false);
            ushort pinZ = (ushort)Point2D.Lerp(_startWorldPos.Z, _destWorldPos.Z, GetMoveFactor(deltaMs));

            _unit.SetPosition(pinX, pinY, pinZ, _unit.Heading, destZone.ZoneId);

            if (tick > _moveStartTime + _moveDuration)
            {
                if (MoveState == EMoveState.Move)
                {
                    MoveState = EMoveState.None;
                }
                _moveDuration = 0;
            }
        }
Esempio n. 3
0
File: Player.cs Progetto: uvbs/DoR
        public void Teleport(UInt16 ZoneID, UInt32 WorldX, UInt32 WorldY, UInt16 WorldZ, UInt16 WorldO)
        {
            Log.Info("Player", "Teleport : " + ZoneID + "," + WorldX + "," + WorldY + "," + WorldZ);


            // ADDED THIS TO GIVE ME INFO// also use this kind of thing for portal not open
            SendLocalizeString("ZoneID=" + ZoneID + "," + WorldX + "," + WorldY + "," + WorldZ + "," + WorldO, GameData.Localized_text.CHAT_TAG_DEFAULT);


            Zone_Info Info = WorldMgr.GetZone_Info(ZoneID);

            if (Info == null)
            {
                return;
            }

            // Change Region , so change thread and maps
            if (Zone == null || Zone.Info.Region != Info.Region)
            {
                RegionMgr NewRegion = WorldMgr.GetRegion(Info.Region, true);
                if (NewRegion != null)
                {
                    ZoneMgr NewZone = NewRegion.GetZoneMgr(Info.ZoneId, true);
                    Teleport(NewZone, WorldX, WorldY, WorldZ, WorldO);
                }
            }
            else // Teleport in current Zone
            {
                SafeWorldTeleport(WorldX, WorldY, WorldZ, WorldO);
            }
        }
Esempio n. 4
0
        public bool AddObject(Object Obj, UInt16 ZoneId, bool MustUpdateRange = false)
        {
            Zone_Info Info = GetZone_Info(ZoneId);

            if (Info == null)
            {
                Log.Error("RegionMgr", "Invalid Zone Id : " + ZoneId);
                return(false);
            }

            if (Obj.Region == null || (Obj.Region != null && Obj.Region != this))
            {
                if (Obj.Region != null)
                {
                    Obj.Region.RemoveObject(Obj);
                }

                GenerateOid(Obj);
            }

            ZoneMgr Mgr = GetZoneMgr(ZoneId, true);

            Mgr.AddObject(Obj);

            if (MustUpdateRange)
            {
                UpdateRange(Obj);
            }

            return(true);
        }
Esempio n. 5
0
        static public void LoadPublicQuests()
        {
            Zone_Info Zone = null;

            foreach (PQuest_Info Info in _PQuests.Values)
            {
                Zone = GetZone_Info(Info.ZoneId);
                if (Zone == null)
                {
                    continue;
                }


                if (!_PQuest_Objectives.TryGetValue(Info.Entry, out Info.Objectives))
                {
                    Info.Objectives = new List <PQuest_Objective>();
                }
                else
                {
                    foreach (PQuest_Objective Obj in Info.Objectives)
                    {
                        Obj.Quest = Info;
                        GeneratePQuestObjective(Obj, Obj.Quest);
                    }
                }

                GetRegionCell(Zone.Region, (ushort)((float)(Info.PinX / 4096) + Zone.OffX), (ushort)((float)(Info.PinY / 4096) + Zone.OffY)).AddPQuest(Info);
            }
        }
Esempio n. 6
0
        public void Teleport(UInt16 ZoneID, UInt32 WorldX, UInt32 WorldY, UInt16 WorldZ, UInt16 WorldO)
        {
            Log.Info("Player", "Teleport : " + ZoneID + "," + WorldX + "," + WorldY + "," + WorldZ);

            Zone_Info Info = WorldMgr.GetZone_Info(ZoneID);

            if (Info == null)
            {
                return;
            }

            // Change Region , so change thread and maps
            if (Zone == null || Zone.Info.Region != Info.Region)
            {
                RegionMgr NewRegion = WorldMgr.GetRegion(Info.Region, true);
                if (NewRegion != null)
                {
                    ZoneMgr NewZone = NewRegion.GetZoneMgr(Info.ZoneId, true);
                    Teleport(NewZone, WorldX, WorldY, WorldZ, WorldO);
                }
            }
            else // Teleport in current Zone
            {
                SafeWorldTeleport(WorldX, WorldY, WorldZ, WorldO);
            }
        }
Esempio n. 7
0
 public ZoneMgr(RegionMgr Region, Zone_Info Info)
 {
     this.Region   = Region;
     this.ZoneId   = Info.ZoneId;
     this.Info     = Info;
     this.Running  = true;
     this.AreaInfo = AreaMapMgr.GetAreaInfo(Info.ZoneId);
 }
Esempio n. 8
0
 public ZoneMgr(RegionMgr Region, Zone_Info Info)
 {
     this.Region     = Region;
     this.ZoneId     = Info.ZoneId;
     this.Info       = Info;
     this.Running    = true;
     this.ClientInfo = ClientFileMgr.GetZoneInfo(Info.ZoneId);
 }
Esempio n. 9
0
        /// <summary>
        /// Sets offline/online players coordinates in database (player_name byte byte ZoneID , uint WorldX, uint WorldY, uint WorldZ)
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool TeleportSet(Player plr, ref List <string> values)
        {
            string playerName = GetString(ref values);
            int    zoneID     = GetZoneId(plr, ref values);

            if (zoneID == -1)
            {
                return(false);
            }
            int worldX = GetInt(ref values);
            int worldY = GetInt(ref values);
            int worldZ = GetInt(ref values);

            Zone_Info zone = ZoneService.GetZone_Info((ushort)zoneID);

            if (zone == null)
            {
                zone = ZoneService._Zone_Info[0];
            }

            var existingChar = CharMgr.GetCharacter(Player.AsCharacterName(playerName), false);

            if (existingChar == null)
            {
                plr.SendClientMessage("Player with name '" + values[0] + "' not found.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
                return(true);
            }

            var player = Player.GetPlayer(playerName);

            GMCommandLog log = new GMCommandLog
            {
                PlayerName = plr.Name,
                AccountId  = (uint)plr.Client._Account.AccountId,
                Command    = "TELEPORT offline player '" + existingChar.Name + "' TO " + zoneID + " " + worldX + " " + worldY,
                Date       = DateTime.Now
            };

            CharMgr.Database.AddObject(log);

            if (player != null)
            {
                player.Teleport((ushort)zoneID, (uint)worldX, (uint)worldY, (ushort)worldZ, 0);
            }

            existingChar.Value.WorldX   = worldX;
            existingChar.Value.WorldY   = worldY;
            existingChar.Value.WorldZ   = worldZ;
            existingChar.Value.ZoneId   = zone.ZoneId;
            existingChar.Value.RegionId = zone.Region;

            CharMgr.Database.SaveObject(existingChar.Value);
            CharMgr.Database.ForceSave();

            return(true);
        }
Esempio n. 10
0
        // Recall state just moves the target repeatedly towards its owner without sending any state updates
        // TODO: Move towards offset position (back-rear)
        private void UpdateRecall(long tick)
        {
            long deltaMs = tick - _lastRecallMove;

            _lastRecallMove = tick;

            // Stationary pets should not perform any moves
            if (MovementSpeed == 0)
            {
                return;
            }

            if (_nextRecallSend < tick)
            {
                _nextRecallSend = tick + 7500;
                UpdateMovementState(null);
            }

            Vector2 destVect = new Vector2(_unit.WorldPosition.X - FollowTarget.WorldPosition.X, _unit.WorldPosition.Y - FollowTarget.WorldPosition.Y);

            float distance = destVect.Magnitude;

            // Within tolerance for recall move
            if (distance < 60)
            {
                Pet pet = _unit as Pet;
                if (pet != null && pet.IsHeeling)
                {
                    pet.IsHeeling = false;
                    pet.AiInterface.Debugger?.SendClientMessage("[MR]: Successfully recalled. No longer ignoring enemies.");
                }
                return;
            }

            // Total time required to move fully towards the target
            _moveDuration = (distance / _totalSpeed) * 1000;

            // Lerp alpha is capped to 1, so the move will never overshoot the target
            uint newWorldPosX = (uint)Point2D.Lerp(_unit.WorldPosition.X, FollowTarget.WorldPosition.X, GetMoveFactor(deltaMs));
            uint newWorldPosY = (uint)Point2D.Lerp(_unit.WorldPosition.Y, FollowTarget.WorldPosition.Y, GetMoveFactor(deltaMs));

            Zone_Info destZone = _unit.Region.GetZone((ushort)(newWorldPosX >> 12), (ushort)(newWorldPosY >> 12));

            if (destZone == null)
            {
                return;
            }

            ushort pinX = _unit.Zone.CalculPin(newWorldPosX, true);
            ushort pinY = _unit.Zone.CalculPin(newWorldPosY, false);
            ushort pinZ = (ushort)Point2D.Lerp(_unit.WorldPosition.Z, FollowTarget.WorldPosition.Z, GetMoveFactor(deltaMs));

            _unit.SetPosition(pinX, pinY, pinZ, _unit.Heading, destZone.ZoneId);
        }
Esempio n. 11
0
        public WorldZoneInfo GetZoneInfoCache(string Zone)
        {
            Zone_Info entry = CharacterDB.SelectObject <Zone_Info>("Name='" + CharacterDB.Escape(Zone) + "'");

            WorldZoneInfo ZoneInfo = new WorldZoneInfo();

            ZoneInfo.ZoneFileName = entry.Name;
            ZoneInfo.Description  = GetTextCache(entry.Desc);
            ZoneInfo.DisplayName  = GetTextCache(entry.DisplayName);

            return(ZoneInfo);
        }
Esempio n. 12
0
        public static ushort CalculPin(Zone_Info Info, int WorldPos, bool x)
        {
            ushort Pin = 0;

            int BaseOffset = x ? Info.OffX << 12 : Info.OffY << 12;

            if (BaseOffset <= WorldPos)
            {
                Pin = (ushort)(WorldPos - BaseOffset);
            }

            return(Pin);
        }
Esempio n. 13
0
        static public UInt16 CalculPin(Zone_Info Info, int WorldPos, bool x)
        {
            UInt16 Pin = 0;

            int BaseOffset = x ? Info.OffX << 12 : Info.OffY << 12;

            if (BaseOffset <= WorldPos)
            {
                Pin = (UInt16)(WorldPos - BaseOffset);
            }

            return(Pin);
        }
Esempio n. 14
0
        /// <summary>
        /// Translates coordinates in a zone to world coordinates.
        /// Converts Pin into World Coordinates
        /// </summary>
        /// <param name="Info">Zone data</param>
        /// <param name="PinX">X coordinate in zone (as seen in map in game)</param>
        /// <param name="PinY">Y coordinate in zone (as seen in map in game)</param>
        /// <param name="PinZ">Z coordinate in zone (as seen in map in game)</param>
        /// <returns>World coordinates</returns>
        public static Point3D GetWorldPosition(Zone_Info Info, ushort PinX, ushort PinY, ushort PinZ)
        {
            int x = PinX > 32768 ? PinX - 32768 : PinX;
            int y = PinY > 32768 ? PinY - 32768 : PinY;

            Point3D worldPosition = new Point3D(0, 0, 0)
            {
                X = (int)CalcOffset(Info, PinX, true) + (x & 0x00000FFF),
                Y = (int)CalcOffset(Info, PinY, false) + (y & 0x00000FFF),
                Z = PinZ
            };

            return(worldPosition);
        }
Esempio n. 15
0
        static public void LoadChapters()
        {
            Log.Success("LoadChapters", "Loading Zone from Chapters");

            long InvalidChapters = 0;

            Zone_Info Zone = null;

            foreach (Chapter_Info Info in _Chapters.Values)
            {
                Zone = GetZone_Info(Info.ZoneId);

                if (Zone == null || (Info.PinX <= 0 && Info.PinY <= 0))
                {
                    Log.Debug("LoadChapters", "Chapter (" + Info.Entry + ")[" + Info.Name + "] Invalid");
                    ++InvalidChapters;
                }
                else
                {
                    List <Chapter_Reward> Rewards;
                    if (_Chapters_Reward.TryGetValue(Info.Entry, out Rewards))
                    {
                        Info.Rewards = Rewards;
                    }
                    else
                    {
                        Info.Rewards = new List <Chapter_Reward>();
                    }

                    foreach (Chapter_Reward Reward in Info.Rewards.ToArray())
                    {
                        Reward.Item    = GetItem_Info(Reward.ItemId);
                        Reward.Chapter = Info;

                        if (Reward.Item == null)
                        {
                            Info.Rewards.Remove(Reward);
                        }
                    }

                    GetRegionCell(Zone.Region, (ushort)((float)(Info.PinX / 4096) + Zone.OffX), (ushort)((float)(Info.PinY / 4096) + Zone.OffY)).AddChapter(Info);
                }
            }

            if (InvalidChapters > 0)
            {
                Log.Error("LoadChapters", "[" + InvalidChapters + "] Invalid Chapter(s)");
            }
        }
Esempio n. 16
0
        static public Point3D CalculWorldPosition(Zone_Info Info, UInt16 PinX, UInt16 PinY, UInt16 PinZ)
        {
            int     x             = PinX > 32768 ? PinX - 32768 : PinX;
            int     y             = PinY > 32768 ? PinY - 32768 : PinY;
            Point3D WorldPosition = new Point3D(0, 0, 0);


            WorldPosition.X = (int)((int)CalcOffset(Info, PinX, true) + ((int)((int)x) & 0x00000FFF));
            WorldPosition.Y = (int)((int)CalcOffset(Info, PinY, false) + ((int)((int)y) & 0x00000FFF));
            WorldPosition.Z = PinZ / 2;
            if (Info.ZoneId == 161)
            {
                WorldPosition.Z = (32768 + PinZ) / 2;
            }

            return(WorldPosition);
        }
        /// <summary>
        /// Retrieves a zone id from a gm command parameter.
        /// </summary>
        /// <param name="player">GM</param>
        /// <param name="values">Command arguments</param>
        /// <returns>Existing zone ID or -1 if not found (an error has been sent)</returns>
        public static int GetZoneId(Player player, ref List <string> values)
        {
            string zoneName = GetString(ref values);
            int    zoneID;

            if (int.TryParse(zoneName, out zoneID))
            {
                Zone_Info info = ZoneService.GetZone_Info((ushort)zoneID);
                if (info != null)
                {
                    return(zoneID);
                }
                player.SendMessage("Could not find zone for id " + zoneID, ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
                return(-1);
            }

            List <Zone_Info> results = new List <Zone_Info>();

            foreach (Zone_Info zone in ZoneService._Zone_Info)
            {
                if (zone.Name.ToLower().Contains(zoneName.ToLower()))
                {
                    results.Add(zone);
                }
            }
            if (results.Count == 0)
            {
                player.SendMessage("Could not find zone for name " + zoneName, ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
            }
            else if (results.Count > 1)
            {
                string[] names = new string[results.Count];
                for (int i = 0; i < results.Count; i++)
                {
                    names[i] = results[i].Name;
                }
                player.SendMessage($"Several zones match '{zoneName}' : {string.Join(",", names)}" + zoneID, ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
            }
            else
            {
                return(results[0].ZoneId);
            }
            return(-1);
        }
Esempio n. 18
0
        public void Move(Point3D destWorldPos)
        {
            Vector2 destVect = new Vector2(_unit.WorldPosition.X - destWorldPos.X, _unit.WorldPosition.Y - destWorldPos.Y);

            float distance = destVect.Magnitude;

            if (distance <= MOVE_TOLERANCE_UNITS)
            {
                if (MoveState == EMoveState.Move)
                {
                    MoveState = EMoveState.None;
                }
                return;
            }

            _startWorldPos.SetCoordsFrom(_unit.WorldPosition);
            _destWorldPos.SetCoordsFrom(destWorldPos);

            Zone_Info destZone = _unit.Region.GetZone((ushort)(destWorldPos.X >> 12), (ushort)(destWorldPos.Y >> 12));

            if (destZone == null)
            {
                return;
            }

            _destZoneId = destZone.ZoneId;

            _unit.Heading = _unit.WorldPosition.GetHeading(_destWorldPos);

            _unit.AiInterface.Debugger?.SendClientMessage("MOVE: Start: " + _startWorldPos + " End: " + _destWorldPos + " New Heading: " + _unit.Heading + " Speed: " + _totalSpeed);

            if (MovementSpeed > 0)
            {
                _moveStartTime = TCPManager.GetTimeStampMS();
                _moveDuration  = (distance / _totalSpeed) * 1000;
            }

            if (MoveState == EMoveState.None)
            {
                MoveState = EMoveState.Move;
            }

            UpdateMovementState(null);
        }
Esempio n. 19
0
        public List <ZoneMgr> GetRangedZone(int XOffset, int YOffset, int Range)
        {
            List <ZoneMgr> Mgrs = new List <ZoneMgr>();

            lock (ZonesMgr)
            {
                foreach (ZoneMgr Mgr in ZonesMgr)
                {
                    Zone_Info zone = Mgr.Info;

                    if ((zone.OffX - Range <= XOffset && zone.OffX + MAX_CELLS > XOffset) && (zone.OffY - Range <= YOffset && zone.OffY + MAX_CELLS > YOffset))
                    {
                        Mgrs.Add(Mgr);
                    }
                }
            }

            return(Mgrs);
        }
Esempio n. 20
0
        static public void CalculWorldPosition(UInt16 ZoneID, ushort PinX, ushort PinY, ushort PinZ, ref int WorldX, ref int WorldY, ref int WorldZ)
        {
            Zone_Info Info = WorldMgr.GetZone_Info(ZoneID);

            if (Info == null)
            {
                return;
            }

            int x = PinX > 32768 ? PinX - 32768 : PinX;
            int y = PinY > 32768 ? PinY - 32768 : PinY;

            WorldX = (int)((int)CalcOffset(Info, PinX, true) + ((int)((int)x) & 0x00000FFF));
            WorldY = (int)((int)CalcOffset(Info, PinY, false) + ((int)((int)y) & 0x00000FFF));
            WorldZ = PinZ;
            if (Info.ZoneId == 161)
            {
                WorldZ += 16384;
            }
        }
Esempio n. 21
0
        public InstanceObject(Instance instance, Instance_Object info)
        {
            Info     = info;
            Instance = instance;
            Name     = info.Name;
            Zone_Info zone = ZoneService.GetZone_Info(instance.Info.ZoneID);

            X = (ushort)(info.WorldX - (zone.OffX << 12));
            Y = (ushort)(info.WorldY - (zone.OffY << 12));
            Z = (ushort)info.WorldZ;
            WorldPosition.X = (int)info.WorldX;
            WorldPosition.Y = (int)info.WorldY;
            WorldPosition.Z = (int)info.WorldZ;

            XOffset = (ushort)Math.Truncate((decimal)(X / 4096 + zone.OffX));
            YOffset = (ushort)Math.Truncate((decimal)(Y / 4096 + zone.OffY));

            IsActive = true;
            VfxState = (byte)info.VfxState;
        }
Esempio n. 22
0
        public void CheckZone(Object Obj)
        {
            Zone_Info Info = GetZone(Obj.XOffset, Obj.YOffset);

            if (Info != null && Info != Obj.Zone.Info)
            {
                AddObject(Obj, Info.ZoneId);
            }

            CellMgr CurCell = Obj._Cell;
            CellMgr NewCell = GetCell(Obj.XOffset, Obj.YOffset);

            if (NewCell != null && NewCell != CurCell)
            {
                if (CurCell != null) // Si l'objet est sur un cell, on le supprime
                {
                    CurCell.RemoveObject(Obj);
                }

                NewCell.AddObject(Obj); // On l'ajoute dans le nouveau cell
            }
        }
Esempio n. 23
0
        public ushort CheckZone(Object obj)
        {
            Zone_Info info = GetZone(obj.XOffset, obj.YOffset);

            if (info != null && info != obj.Zone.Info)
            {
                AddObject(obj, info.ZoneId);
            }

            CellMgr curCell = obj._Cell;
            CellMgr newCell = GetCell(obj.XOffset, obj.YOffset);

            if (newCell == null || newCell == curCell)
            {
                return(info?.ZoneId ?? 0);
            }

            curCell?.RemoveObject(obj);
            newCell.AddObject(obj); // On l'ajoute dans le nouveau cell

            return(info?.ZoneId ?? 0);
        }
Esempio n. 24
0
        public void Teleport(Point3D destWorldPos)
        {
            Zone_Info destZone = _unit.Region.GetZone((ushort)(destWorldPos.X >> 12), (ushort)(destWorldPos.Y >> 12));

            if (destZone == null)
            {
                return;
            }

            ushort pinX = _unit.Zone.CalculPin((uint)destWorldPos.X, true);
            ushort pinY = _unit.Zone.CalculPin((uint)destWorldPos.Y, false);
            ushort pinZ = (ushort)destWorldPos.Z;

            _destWorldPos.SetCoordsFrom(destWorldPos);

            _forcePositionUpdate = true;

            _unit.SetPosition(pinX, pinY, pinZ, _unit.Heading, destZone.ZoneId);

            UpdateMovementState(null);

            _forcePositionUpdate = false;
        }
Esempio n. 25
0
        public ZoneMgr GetZoneMgr(UInt16 ZoneId, bool Create)
        {
            Zone_Info Info = GetZone_Info(ZoneId);

            if (Info == null)
            {
                return(null);
            }

            ZoneMgr Mgr = null;

            lock (ZonesMgr)
            {
                Mgr = ZonesMgr.Find(zone => zone != null && zone.Info.ZoneId == ZoneId);
                if (Mgr == null && Create) // Si la zone n'a pas encore été lancée
                {
                    Mgr = new ZoneMgr(this, Info);
                    ZonesMgr.Add(Mgr);
                }
            }

            return(Mgr);
        }
Esempio n. 26
0
        public bool AddObject(Object obj, ushort zoneId, bool mustUpdateRange = false)
        {
            Zone_Info info = GetZone_Info(zoneId);

            if (info == null)
            {
                Log.Error("RegionMgr", "AddObject: Unable to add object " + obj.Name + " to invalid Zone with ID : " + zoneId);
                return(false);
            }

            ObjectAdd add = new ObjectAdd
            {
                Obj             = obj,
                ZoneId          = zoneId,
                MustUpdateRange = mustUpdateRange
            };

            //obj.MovementZone = GetZoneMgr(zoneId);

            lock (_objectsToAdd)
                _objectsToAdd.Add(add);

            return(true);
        }
Esempio n. 27
0
        static public void LoadRegionSpawns()
        {
            long      InvalidSpawns = 0;
            Zone_Info Info = null;
            ushort    X, Y = 0;
            Dictionary <string, int> RegionCount = new Dictionary <string, int>();

            foreach (Creature_spawn Spawn in CreatureSpawns.Values)
            {
                Spawn.Proto = GetCreatureProto(Spawn.Entry);
                if (Spawn.Proto == null)
                {
                    Log.Debug("LoadRegionSpawns", "Invalid Creature Proto (" + Spawn.Entry + "), spawn Guid(" + Spawn.Guid + ")");
                    ++InvalidSpawns;
                    continue;
                }

                Info = GetZone_Info(Spawn.ZoneId);
                if (Info != null)
                {
                    X = (UInt16)(Spawn.WorldX >> 12);
                    Y = (UInt16)(Spawn.WorldY >> 12);

                    GetRegionCell(Info.Region, X, Y).AddSpawn(Spawn);

                    if (!RegionCount.ContainsKey(Info.Name))
                    {
                        RegionCount.Add(Info.Name, 0);
                    }

                    ++RegionCount[Info.Name];
                }
                else
                {
                    Log.Debug("LoadRegionSpawns", "ZoneId (" + Spawn.ZoneId + ") invalid, Spawn Guid(" + Spawn.Guid + ")");
                    ++InvalidSpawns;
                }
            }

            foreach (GameObject_spawn Spawn in GameObjectSpawns.Values)
            {
                Spawn.Proto = GetGameObjectProto(Spawn.Entry);
                if (Spawn.Proto == null)
                {
                    Log.Debug("LoadRegionSpawns", "Invalid GameObject Proto (" + Spawn.Entry + "), spawn Guid(" + Spawn.Guid + ")");
                    ++InvalidSpawns;
                    continue;
                }

                Info = GetZone_Info(Spawn.ZoneId);
                if (Info != null)
                {
                    X = (UInt16)(Spawn.WorldX >> 12);
                    Y = (UInt16)(Spawn.WorldY >> 12);

                    GetRegionCell(Info.Region, X, Y).AddSpawn(Spawn);

                    if (!RegionCount.ContainsKey(Info.Name))
                    {
                        RegionCount.Add(Info.Name, 0);
                    }

                    ++RegionCount[Info.Name];
                }
                else
                {
                    Log.Debug("LoadRegionSpawns", "ZoneId (" + Spawn.ZoneId + ") invalid, Spawn Guid(" + Spawn.Guid + ")");
                    ++InvalidSpawns;
                }
            }

            if (InvalidSpawns > 0)
            {
                Log.Error("LoadRegionSpawns", "[" + InvalidSpawns + "] Invalid Spawns");
            }

            foreach (KeyValuePair <string, int> Counts in RegionCount)
            {
                Log.Success("Region", "[" + Counts.Key + "] : " + Counts.Value);
            }
        }
        public static void F_INIT_PLAYER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            Player Plr = cclient.Plr;

            if (Plr == null)
            {
                return;
            }

            if (!Plr.IsInWorld()) // If the player is not on a map, then we add it to the map
            {
                ushort zoneId   = Plr.Info.Value.ZoneId;
                ushort regionId = (ushort)Plr.Info.Value.RegionId;

                Zone_Info info = ZoneService.GetZone_Info(zoneId);
                if (info?.Type == 0)
                {
                    RegionMgr region = WorldMgr.GetRegion(regionId, true);
                    if (region.AddObject(Plr, zoneId, true))
                    {
                        return;
                    }
                }
                else if (info?.Type == 4 || info?.Type == 5 || info?.Type == 6) // login into a instance
                {
                    if (!WorldMgr.InstanceMgr.ZoneIn(Plr, (byte)info?.Type))    // cant login into the instace port to exit
                    {
                        Instance_Info II;
                        InstanceService._InstanceInfo.TryGetValue(zoneId, out II);
                        Zone_jump ExitJump = ZoneService.GetZoneJump(II.exitzonejup);
                        if (ExitJump == null)
                        {
                            Log.Error("Exit Jump in Instance", " " + zoneId + " missing!");
                        }
                        else
                        {
                            if (ExitJump.Type == 4)
                            {
                                WorldMgr.InstanceMgr.ZoneIn(Plr, 4, ExitJump);
                            }
                            else
                            {
                                Plr.Teleport(ExitJump.ZoneID, ExitJump.WorldX, ExitJump.WorldY, ExitJump.WorldZ, ExitJump.WorldO);
                            }
                        }
                    }
                    return;
                }

                // Warp a player to their bind point if they attempt to load into a scenario map.
                RallyPoint rallyPoint = RallyPointService.GetRallyPoint(Plr.Info.Value.RallyPoint);

                if (rallyPoint != null)
                {
                    Plr.Teleport(rallyPoint.ZoneID, rallyPoint.WorldX, rallyPoint.WorldY, rallyPoint.WorldZ, rallyPoint.WorldO);
                }

                else
                {
                    CharacterInfo cInfo = CharMgr.GetCharacterInfo(Plr.Info.Career);
                    Plr.Teleport(cInfo.ZoneId, (uint)cInfo.WorldX, (uint)cInfo.WorldY, (ushort)cInfo.WorldZ,
                                 (ushort)cInfo.WorldO);
                }
            }
            else
            {
                Plr.Loaded = false;
                Plr.StartInit();
            }
        }
Esempio n. 29
0
 static public uint CalcOffset(Zone_Info Info, UInt16 Pin, bool x)
 {
     return((UInt32)Math.Truncate((decimal)(Pin / 4096 + (x ? Info.OffX : Info.OffY))) << 12);
 }
Esempio n. 30
0
        static public void RemoveDoubleSpawns()
        {
            uint Space = 250;

            int[] Removed = new int[255];

            Zone_Info Info = null;

            foreach (CellSpawns[,] Cell in _RegionCells.Values)
            {
                for (int i = 0; i < Cell.GetLength(0); ++i)
                {
                    for (int y = 0; y < Cell.GetLength(1); ++y)
                    {
                        if (Cell[i, y] == null)
                        {
                            continue;
                        }

                        foreach (Creature_spawn Sp in Cell[i, y].CreatureSpawns.ToArray())
                        {
                            if (Sp.Proto == null || GetStartQuests(Sp.Proto.Entry) != null)
                            {
                                continue;
                            }

                            if (Info == null || Info.ZoneId != Sp.ZoneId)
                            {
                                Info = GetZone_Info(Sp.ZoneId);
                            }

                            foreach (Creature_spawn SubSp in Cell[i, y].CreatureSpawns.ToArray())
                            {
                                if (SubSp.Proto == null || Sp.Entry != SubSp.Entry || Sp == SubSp)
                                {
                                    continue;
                                }

                                if (ZoneMgr.CalculPin(Info, Sp.WorldX, true) > ZoneMgr.CalculPin(Info, SubSp.WorldX, true) + Space || ZoneMgr.CalculPin(Info, Sp.WorldX, true) < ZoneMgr.CalculPin(Info, SubSp.WorldX, true) - Space)
                                {
                                    continue;
                                }

                                if (ZoneMgr.CalculPin(Info, Sp.WorldY, false) > ZoneMgr.CalculPin(Info, SubSp.WorldY, false) + Space || ZoneMgr.CalculPin(Info, Sp.WorldY, false) < ZoneMgr.CalculPin(Info, SubSp.WorldY, false) - Space)
                                {
                                    continue;
                                }

                                /*if (Sp.WorldZ > SubSp.WorldZ/2 + Space || Sp.WorldZ < SubSp.WorldZ/2 - Space)
                                 *  continue;*/

                                Removed[SubSp.ZoneId]++;
                                SubSp.Proto = null;
                                Database.DeleteObject(SubSp);
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < 255; ++i)
            {
                if (Removed[i] != 0)
                {
                    Log.Info("Removed", "Zone : " + i + " : " + Removed[i]);
                }
            }
        }