Esempio n. 1
0
        public static void GeneratePQuestObjective(PQuest_Objective Obj, PQuest_Info Q)
        {
            switch ((Objective_Type)Obj.Type)
            {
            case Objective_Type.QUEST_KILL_PLAYERS:
            {
                if (Obj.Description.Length < 1)
                {
                    Obj.Description = "Enemy Players";
                }
            }
            break;

            case Objective_Type.QUEST_SPEAK_TO:
                goto case Objective_Type.QUEST_KILL_MOB;

            case Objective_Type.QUEST_PROTECT_UNIT:
                goto case Objective_Type.QUEST_KILL_MOB;

            case Objective_Type.QUEST_KILL_MOB:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.Creature = CreatureService.GetCreatureProto(ObjID);
                }

                if (Obj.Description.Length < 1 && Obj.Creature != null)
                {
                    Obj.Description = Obj.Creature.Name;
                }
            }
            break;

            case Objective_Type.QUEST_KILL_GO:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.GameObject = GameObjectService.GetGameObjectProto(ObjID);
                }

                if (Obj.Description.Length < 1 && Obj.GameObject != null)
                {
                    Obj.Description = "Destroy " + Obj.Creature.Name;
                }
            }
            break;

            case Objective_Type.QUEST_USE_GO:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.GameObject = GameObjectService.GetGameObjectProto(ObjID);
                }

                if (Obj.Description.Length < 1 && Obj.GameObject != null)
                {
                    Obj.Description = "Use " + Obj.GameObject.Name;
                }
            }
            break;

            case Objective_Type.QUEST_GET_ITEM:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.Item = ItemService.GetItem_Info(ObjID);
                }
            }
            break;
            }
        }
        public static void LoadRegionSpawns()
        {
            long      InvalidSpawns = 0;
            Zone_Info Info = null;
            ushort    X, Y = 0;
            Dictionary <string, int> RegionCount = new Dictionary <string, int>();

            {
                Creature_spawn Spawn;
                foreach (KeyValuePair <uint, Creature_spawn> Kp in CreatureService.CreatureSpawns)
                {
                    Spawn       = Kp.Value;
                    Spawn.Proto = CreatureService.GetCreatureProto(Spawn.Entry);
                    if (Spawn.Proto == null)
                    {
                        Log.Debug("LoadRegionSpawns", "Invalid Creature Proto (" + Spawn.Entry + "), spawn Guid(" + Spawn.Guid + ")");
                        ++InvalidSpawns;
                        continue;
                    }

                    Info = ZoneService.GetZone_Info(Spawn.ZoneId);
                    if (Info != null)
                    {
                        X = (ushort)(Spawn.WorldX >> 12);
                        Y = (ushort)(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;
                    }
                }
            }

            {
                GameObject_spawn Spawn;
                foreach (KeyValuePair <uint, GameObject_spawn> Kp in GameObjectService.GameObjectSpawns)
                {
                    Spawn       = Kp.Value;
                    Spawn.Proto = GameObjectService.GetGameObjectProto(Spawn.Entry);
                    if (Spawn.Proto == null)
                    {
                        Log.Debug("LoadRegionSpawns", "Invalid GameObject Proto (" + Spawn.Entry + "), spawn Guid(" + Spawn.Guid + ")");
                        ++InvalidSpawns;
                        continue;
                    }

                    Info = ZoneService.GetZone_Info(Spawn.ZoneId);
                    if (Info != null)
                    {
                        X = (ushort)(Spawn.WorldX >> 12);
                        Y = (ushort)(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.Debug("Region", "[" + Counts.Key + "] : " + Counts.Value);
            }
        }