Ejemplo n.º 1
0
        private void ReloadMobs(GamePlayer player, ushort region, string arg1, string arg2)
        {
            if (region == 0)
            {
                log.Info("Region reload not supported from console.");
                return;
            }

            ChatUtil.SendSystemMessage(player, "Reloading Mobs:  " + arg1 + ", " + arg2 + " ...");

            int count = 0;

            foreach (GameNPC mob in WorldMgr.GetNPCsFromRegion(region))
            {
                if (!mob.LoadedFromScript)
                {
                    if (arg1 == "all")
                    {
                        mob.RemoveFromWorld();

                        Mob mobs = GameServer.Database.FindObjectByKey <Mob>(mob.InternalID);
                        if (mobs != null)
                        {
                            mob.LoadFromDatabase(mobs);
                            mob.AddToWorld();
                            count++;
                        }
                    }

                    if (arg1 == "realm")
                    {
                        eRealm realm = eRealm.None;
                        if (arg2 == "None")
                        {
                            realm = eRealm.None;
                        }
                        if (arg2 == "Albion")
                        {
                            realm = eRealm.Albion;
                        }
                        if (arg2 == "Midgard")
                        {
                            realm = eRealm.Midgard;
                        }
                        if (arg2 == "Hibernia")
                        {
                            realm = eRealm.Hibernia;
                        }

                        if (mob.Realm == realm)
                        {
                            mob.RemoveFromWorld();

                            Mob mobs = GameServer.Database.FindObjectByKey <Mob>(mob.InternalID);
                            if (mobs != null)
                            {
                                mob.LoadFromDatabase(mobs);
                                mob.AddToWorld();
                                count++;
                            }
                        }
                    }

                    if (arg1 == "name")
                    {
                        if (mob.Name == arg2)
                        {
                            mob.RemoveFromWorld();

                            Mob mobs = GameServer.Database.FindObjectByKey <Mob>(mob.InternalID);
                            if (mobs != null)
                            {
                                mob.LoadFromDatabase(mobs);
                                mob.AddToWorld();
                                count++;
                            }
                        }
                    }

                    if (arg1 == "model")
                    {
                        if (mob.Model == Convert.ToUInt16(arg2))
                        {
                            mob.RemoveFromWorld();

                            WorldObject mobs = GameServer.Database.FindObjectByKey <WorldObject>(mob.InternalID);
                            if (mobs != null)
                            {
                                mob.LoadFromDatabase(mobs);
                                mob.AddToWorld();
                                count++;
                            }
                        }
                    }
                }
            }

            ChatUtil.SendSystemMessage(player, count + " mobs reloaded!");
        }