public void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
 {
     for (int i = 0; i < Scripts.Count; ++i)
     {
         Scripts[i].OnWorldZoneEvent(EventName, Zone, Data);
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
Arquivo: Player.cs Projeto: 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);
            }
        }
Exemplo n.º 6
0
 public virtual void SetZone(ZoneMgr newZone)
 {
     if (newZone == null)
     {
         throw new NullReferenceException("NULL ZoneMgr was passed in SetZone.");
     }
     Zone = newZone;
 }
Exemplo n.º 7
0
        private void AddNewObjects()
        {
            try
            {
                lock (_objectsToAdd)
                {
                    foreach (ObjectAdd obj in _objectsToAdd)
                    {
                        var plr = obj.Obj as Player;

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

                            GenerateOid(obj.Obj);

                            if (plr != null)
                            {
                                plr.InRegionChange = true;
                                if (!Players.Contains(plr))
                                {
                                    Players.Add(plr);
                                }
                            }
                        }

                        else
                        {
                            obj.Obj.Zone.RemoveObject(obj.Obj);
                        }

                        ZoneMgr mgr = GetZoneMgr(obj.ZoneId);
                        mgr.AddObject(obj.Obj);

                        if (obj.MustUpdateRange)
                        {
                            UpdateRange(obj.Obj);
                        }

                        if (plr != null)
                        {
                            //Bttlfront?.SendObjectives(plr);

                            ndbf?.SendObjectives(plr);
                            WorldMgr.SendCampaignStatus(plr);
                        }
                    }
                    _objectsToAdd.Clear();
                }
            }
            catch (Exception e)
            {
                Log.Error("AddNewObjects", e.ToString());
            }
        }
Exemplo n.º 8
0
        public void SafePinTeleport(UInt16 PinX, UInt16 PinY, UInt16 PinZ, UInt16 WorldO)
        {
            if (PinX == 0 || PinY == 0)
            {
                return;
            }

            Point3D World = ZoneMgr.CalculWorldPosition(Zone.Info, PinX, PinY, PinZ);

            SafeWorldTeleport((UInt32)World.X, (UInt32)World.Y, (UInt16)World.Z, WorldO);
        }
Exemplo n.º 9
0
        public PublicQuest CreatePQuest(PQuest_Info quest)
        {
            if (PublicQuests.ContainsKey(quest.Entry))
            {
                Log.Error("CreatePQuest", "Attempted to create public quest that was already contained: ZoneID:" + quest.ZoneId + " Entry: " + quest.Entry);
            }
            ZoneMgr     zone = GetZoneMgr(quest.ZoneId);
            PublicQuest obj  = new PublicQuest(quest);

            AddObject(obj, quest.ZoneId);
            PublicQuests.Add(quest.Entry, obj);
            return(obj);
        }
Exemplo n.º 10
0
        public Creature CreateCreature(uint Entry, ushort ZoneId, ushort Px, ushort Py, ushort Pz)
        {
            Creature_proto Proto = WorldMgr.GetCreatureProto((uint)Entry);

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

            Creature_spawn Spawn = new Creature_spawn();

            Spawn.Guid = (uint)WorldMgr.GenerateCreatureSpawnGUID();
            Spawn.BuildFromProto(Proto);
            Spawn.ZoneId = ZoneId;
            ZoneMgr.CalculWorldPosition(ZoneId, Px, Py, Pz, ref Spawn._WorldO, ref Spawn._WorldY, ref Spawn._WorldZ);
            return(CreateCreature(Spawn));
        }
Exemplo n.º 11
0
        public GameObject CreateGameObject(uint Entry, ushort ZoneId, ushort Px, ushort Py, ushort Pz)
        {
            GameObject_proto Proto = WorldMgr.GetGameObjectProto(Entry);

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

            GameObject_spawn Spawn = new GameObject_spawn();

            Spawn.Entry = Entry;
            Spawn.Guid  = (uint)WorldMgr.GenerateGameObjectSpawnGUID();
            Spawn.BuildFromProto(Proto);
            Spawn.ZoneId = ZoneId;
            ZoneMgr.CalculWorldPosition(ZoneId, Px, Py, Pz, ref Spawn.WorldX, ref Spawn.WorldY, ref Spawn.WorldZ);
            return(CreateGameObject(Spawn));
        }
Exemplo n.º 12
0
        public void Teleport(ZoneMgr NewZone, UInt32 WorldX, UInt32 WorldY, UInt16 WorldZ, UInt16 WorldO)
        {
            if (Zone == NewZone)
            {
                SafeWorldTeleport(WorldX, WorldY, WorldZ, WorldO);
            }
            else
            {
                _Value.WorldX   = (int)WorldX;
                _Value.WorldZ   = (int)WorldZ;
                _Value.WorldY   = (int)WorldY;
                _Value.WorldO   = WorldO;
                _Value.ZoneId   = NewZone.ZoneId;
                _Value.RegionId = NewZone.Info.Region;

                if (NewZone.Region.AddObject(this, NewZone.ZoneId))
                {
                    SendSwitchRegion(NewZone.ZoneId);
                }
            }
        }
        public static void F_PLAY_VOICE_OVER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.GetUint16(); // Unk
            ushort ZoneId = packet.GetUint16();

            Player Plr = cclient.Plr;

            if (Plr.Region == null)
            {
                return;
            }

            ZoneMgr Zone = Plr.Zone;

            if (Zone == null)
            {
                return;
            }

            List <PublicQuest> PQuests = Zone.PQuests;

            PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_UPDATE, 64);

            Out.WriteUInt32(0);
            Out.WriteByte(6);
            Out.WriteUInt32(ZoneId);
            Out.WriteUInt16((ushort)PQuests.Count);

            foreach (PublicQuest PQuest in PQuests)
            {
                Out.WriteUInt32(PQuest.Info.Entry);
                Out.WriteUInt16((ushort)PQuest.ActivePlayers.Count);
            }

            cclient.Plr.SendPacket(Out);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
 public void ClearZone()
 {
     Zone = null;
 }
        public static LootContainer GetScenarioLoot(Player player, int scenTier, ZoneMgr zone)
        {
            List <LootInfo> lootList = new List <LootInfo>();

            int corpseLevel  = scenTier * 10;
            int corpseRenown = scenTier * 10;

            // Scenario zones all have a war_world.zone_infos.type value of 1.
            // Note - if "1" refers to "instance" instead of "scenario", there could be problems
            // with players receiving scenario-restricted loot for a PVP kill made in an instance
            List <Loot_Group> lootGroups = CreatureService.GetLootGroupsByEvent(1);

            // This will be our narrowed down list of loot groups that are relevant to the kill in question.
            List <Loot_Group> candidateLootGroups = new List <Loot_Group>();

            // Whittle down the loot groups into a new candidate list, based on the killed player's career,
            // and whether the kill occurred in the correct zone (if any) and whether the player has the required quest (if any)
            foreach (Loot_Group lg in lootGroups)
            {
                if (lg == null)
                {
                    continue;
                }

                if (lg.ReqActiveQuest > 0)
                {
                    Character_quest quest = player.QtsInterface.GetQuest(lg.ReqActiveQuest);
                    if (quest == null || quest.IsDone())
                    {
                        continue;
                    }
                }

                if (lg.SpecificZone != 0 && zone.Info.ZoneId != lg.SpecificZone)
                {
                    continue;
                }

                candidateLootGroups.Add(lg);
            }

            // Generate items from remaining loot groups
            foreach (Loot_Group lg in candidateLootGroups)
            {
                if (lg == null)
                {
                    continue;
                }
                // roll for drops.
                for (int groupIndex = 0; groupIndex < lg.DropCount; groupIndex++)
                {
                    float roll = (float)StaticRandom.Instance.Next(0, 10000) / 10000;

                    if (roll <= lg.DropChance)
                    {
                        // Assemble valid drops from the group
                        List <Loot_Group_Item> candidateItems = new List <Loot_Group_Item>();

                        foreach (Loot_Group_Item lgi in lg.LootGroupItems)
                        {
                            if (lgi == null)
                            {
                                continue;
                            }

                            if (corpseLevel < lgi.MinRank || corpseLevel > lgi.MaxRank)
                            {
                                continue;
                            }

                            if (corpseRenown < lgi.MinRenown || corpseRenown > lgi.MaxRenown)
                            {
                                continue;
                            }

                            Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID);

                            if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm)
                            {
                                continue;
                            }

                            candidateItems.Add(lgi);
                        }

                        // If the loot group requires that the dropped loot be usable by a member of
                        // the killer's party, then remove non-compatible loot from the candidate list.
                        if (lg.ReqGroupUsable)
                        {
                            List <Player> members;

                            if (player.PriorityGroup != null)
                            {
                                members = player.PriorityGroup.GetPlayerListCopy();
                            }
                            else
                            {
                                members = new List <Player> {
                                    player
                                };
                            }
                            for (int itemIndex = 0; itemIndex < candidateItems.Count; ++itemIndex)
                            {
                                bool valid = false;

                                Item_Info curItem = ItemService.GetItem_Info(candidateItems[itemIndex].ItemID);

                                foreach (Player member in members)
                                {
                                    if (!ItemsInterface.CanUse(curItem, member, true, false))
                                    {
                                        continue;
                                    }

                                    // Usable by at least one member
                                    valid = true;
                                    break;
                                }

                                if (!valid)
                                {
                                    candidateItems.RemoveAt(itemIndex);
                                    --itemIndex;
                                }
                            }
                        }

                        // Now roll for an item from the candidate item list, and add it to the loots.
                        if (candidateItems.Count > 0)
                        {
                            Item_Info winningItem = ItemService.GetItem_Info(candidateItems[StaticRandom.Instance.Next(0, candidateItems.Count)].ItemID);
                            lootList.Add(new LootInfo(winningItem));
                        }
                    }
                }
            }

            return(lootList.Count <= 0 ? null : new LootContainer {
                LootInfo = lootList
            });
        }
Exemplo n.º 17
0
 public void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
 {
     for (int i = 0; i < Scripts.Count; ++i)
         Scripts[i].OnWorldZoneEvent(EventName, Zone, Data);
 }
Exemplo n.º 18
0
        public void Teleport(ZoneMgr NewZone, UInt32 WorldX, UInt32 WorldY, UInt16 WorldZ, UInt16 WorldO)
        {
            if (Zone == NewZone)
                SafeWorldTeleport(WorldX, WorldY, WorldZ, WorldO);
            else
            {
                _Value.WorldX = (int)WorldX;
                _Value.WorldZ = (int)WorldZ;
                _Value.WorldY = (int)WorldY;
                _Value.WorldO = WorldO;
                _Value.ZoneId = NewZone.ZoneId;
                _Value.RegionId = NewZone.Info.Region;

                if (NewZone.Region.AddObject(this, NewZone.ZoneId))
                    SendSwitchRegion(NewZone.ZoneId);
            }
        }
Exemplo n.º 19
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]);
                }
            }
        }
Exemplo n.º 20
0
        public virtual void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
        {

        }
Exemplo n.º 21
0
        public virtual bool SetPosition(ushort pinX, ushort pinY, ushort pinZ, ushort heading, ushort zoneId, bool sendState = false)
        {
            //Player plr = this as Player;

            bool updated  = false;
            bool doUpdate = false;

            if (zoneId != Zone.ZoneId)
            {
                ZoneMgr newZone = Region.GetZoneMgr(zoneId);

                if (newZone == null)
                {
                    return(false);
                }

                //plr?.DebugMessage("Moving from "+Zone.Info.Name+" to "+newZone.Info.Name, ChatLogFilters.CHATLOGFILTERS_ZONE_AREA, true);

                Zone.RemoveObject(this);
                newZone.AddObject(this);

                doUpdate = true;
            }

            if (doUpdate || pinX != X || pinY != Y || pinZ != Z || heading != Heading)
            {
                X       = pinX;
                Y       = pinY;
                Z       = pinZ;
                Heading = heading;

                //plr?.DebugMessage($"Moving to {X}, {Y}, {Z} in {Zone.Info.Name}", ChatLogFilters.CHATLOGFILTERS_ZONE_AREA, true);

                UpdateWorldPosition();
                UpdateOffset();

                if (!IsPlayer())
                {
                    IsMoving = true;
                    if (sendState)
                    {
                        GetUnit().StateDirty = true;
                    }
                }
                else
                {
                    ushort newOffsetX = (ushort)Math.Truncate((decimal)(X / 4096 + Zone.Info.OffX));
                    ushort newOffsetY = (ushort)Math.Truncate((decimal)(Y / 4096 + Zone.Info.OffY));

                    if (newOffsetX != XOffset || newOffsetY != YOffset)
                    {
                        return(false);
                    }
                }

                updated = Region.UpdateRange(this);
            }
            else if (!IsPlayer())
            {
                IsMoving = false;
            }

            return(updated);
        }
Exemplo n.º 22
0
 public virtual void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
 {
 }
Exemplo n.º 23
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;
        }