コード例 #1
0
 public void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
 {
     for (int i = 0; i < Scripts.Count; ++i)
     {
         Scripts[i].OnWorldZoneEvent(EventName, Zone, Data);
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: Player.cs プロジェクト: webdes27/ZoZoo-WarEmu-v2
        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);
            }
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: 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);
            }
        }
コード例 #6
0
 public virtual void SetZone(ZoneMgr newZone)
 {
     if (newZone == null)
     {
         throw new NullReferenceException("NULL ZoneMgr was passed in SetZone.");
     }
     Zone = newZone;
 }
コード例 #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());
            }
        }
コード例 #8
0
ファイル: Player.cs プロジェクト: webdes27/ZoZoo-WarEmu-v2
        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);
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #12
0
ファイル: Player.cs プロジェクト: webdes27/ZoZoo-WarEmu-v2
        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);
                }
            }
        }
コード例 #13
0
        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);
        }
コード例 #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);
        }
コード例 #15
0
 public void ClearZone()
 {
     Zone = null;
 }
コード例 #16
0
        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
            });
        }
コード例 #17
0
ファイル: ScriptsInterface.cs プロジェクト: dzikun/WarEmu
 public void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
 {
     for (int i = 0; i < Scripts.Count; ++i)
         Scripts[i].OnWorldZoneEvent(EventName, Zone, Data);
 }
コード例 #18
0
ファイル: Player.cs プロジェクト: Necrosummon/WarEmu
        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);
            }
        }
コード例 #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]);
                }
            }
        }
コード例 #20
0
ファイル: AGeneralScript.cs プロジェクト: dzikun/WarEmu
        public virtual void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
        {

        }
コード例 #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);
        }
コード例 #22
0
 public virtual void OnWorldZoneEvent(string EventName, ZoneMgr Zone, object Data)
 {
 }
コード例 #23
0
ファイル: RegionMgr.cs プロジェクト: dzikun/WarEmu
        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;
        }