Exemple #1
0
        /// <summary>
        /// Delete the target <(0=World,1=Database)>
        /// </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 NpcRemove(Player plr, ref List <string> values)
        {
            Object obj = GetObjectTarget(plr);

            if (!obj.IsCreature())
            {
                return(false);
            }

            int database = GetInt(ref values);

            obj.Dispose();

            if (database > 0)
            {
                Creature_spawn spawn = obj.GetCreature().Spawn;
                WorldMgr.Database.DeleteObject(spawn);

                GMCommandLog log = new GMCommandLog();
                log.PlayerName = plr.Name;
                log.AccountId  = (uint)plr.Client._Account.AccountId;
                log.Command    = "REMOVE CREATURE " + spawn.Entry + " " + spawn.Guid + " AT " + spawn.ZoneId + " " + spawn.WorldX + " " + spawn.WorldY;
                log.Date       = DateTime.Now;
                CharMgr.Database.AddObject(log);
            }

            plr.SendClientMessage("NPC REMOVE: Removed " + obj.GetCreature().Spawn.Guid);

            return(true);
        }
Exemple #2
0
        public override void OnDie(Object Obj)
        {
            // Respawn the orginal npc
            Creature_proto Proto = CreatureService.GetCreatureProto((uint)32);

            if (Proto == null)
            {
                return;
            }

            Obj.UpdateWorldPosition();

            Creature_spawn Spawn = new Creature_spawn();

            Spawn.Guid   = (uint)CreatureService.GenerateCreatureSpawnGUID();
            Proto.Model1 = Obj.GetCreature().Spawn.Proto.Model1;
            Proto.Model2 = Obj.GetCreature().Spawn.Proto.Model2;
            Spawn.BuildFromProto(Proto);
            Spawn.WorldO  = Obj.Heading;
            Spawn.WorldY  = Obj.WorldPosition.Y;
            Spawn.WorldZ  = Obj.WorldPosition.Z;
            Spawn.WorldX  = Obj.WorldPosition.X;
            Spawn.ZoneId  = Obj.Zone.ZoneId;
            Spawn.Faction = 65;

            Creature c = Obj.Region.CreateCreature(Spawn);

            //  Set the new NPC to dead, there should be a method to do this perhaps.
            c.Health = 0;

            c.States.Add(3); // Death State

            PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECT_DEATH);

            Out.WriteUInt16(c.Oid);
            Out.WriteByte(1);
            Out.WriteByte(0);
            Out.WriteUInt16(0);
            Out.Fill(0, 6);
            c.DispatchPacket(Out, true);

            //  Make it respawn
            c.EvtInterface.AddEvent(c.RezUnit, 30000 + c.Level * 1000, 1); // 30 seconde Rez

            // Remove the old npc
            Obj.Destroy();

            return;
        }
Exemple #3
0
        /// <summary>
        /// This method allow setting level for selected NPC.
        /// Works for normal NPC and PQ NPCs :)
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// </summary>
        public static bool NpcLevel(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null)
            {
                return(false);
            }
            int nPCLevel = GetInt(ref values);

            Creature creature = target.GetCreature();

            creature.Spawn.Level = (byte)nPCLevel;

            if (creature.PQSpawnId == null)
            {
                WorldMgr.Database.SaveObject(creature.Spawn);
            }
            else
            {
                PQuest_Spawn pQSpawn = WorldMgr.Database.SelectObject <PQuest_Spawn>("pquest_spawns_ID='" + creature.PQSpawnId + "'");
                pQSpawn.Level = (byte)nPCLevel;
                WorldMgr.Database.SaveObject(pQSpawn);
            }

            creature.RezUnit();
            return(true);
        }
Exemple #4
0
        public static bool NpcPermaAnimScript(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null)
            {
                return(false);
            }
            int animID = GetInt(ref values);

            var Out = new PacketOut((byte)Opcodes.F_ANIMATION);

            Out.WriteUInt16(target.Oid);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteUInt16((ushort)animID);

            plr.DispatchPacket(Out, true);

            Creature creature = target.GetCreature();

            creature.Spawn.Emote = (byte)animID;

            if (creature.PQSpawnId == null)
            {
                WorldMgr.Database.SaveObject(creature.Spawn);
            }
            else
            {
                PQuest_Spawn pQSpawn = WorldMgr.Database.SelectObject <PQuest_Spawn>("pquest_spawns_ID='" + creature.PQSpawnId + "'");
                pQSpawn.Emote = (byte)animID;
                WorldMgr.Database.SaveObject(pQSpawn);
            }
            return(true);
        }
Exemple #5
0
        /// <summary>
        /// Sets armor piece color <slotIndex (0=all), pri_tint, sec_tint (from tintpalette_equipment.csv)>
        /// </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 NpcTint(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null || !target.IsCreature())
            {
                return(false);
            }

            int slotIndex = GetInt(ref values);
            int pri       = GetInt(ref values);
            int sec       = GetInt(ref values);
            var creature  = target.GetCreature();

            foreach (var item in creature.ItmInterface.Items.Where(e => e != null && e.SlotId != 0))
            {
                if (slotIndex != 0 && item.SlotId != slotIndex)
                {
                    continue;
                }

                item._PrimaryColor               = (ushort)pri;
                item._SecondaryColor             = (ushort)sec;
                item.CreatureItem.PrimaryColor   = (ushort)pri;
                item.CreatureItem.SecondaryColor = (ushort)sec;
                WorldMgr.Database.SaveObject(item.CreatureItem);
            }
            WorldMgr.Database.ForceSave();
            creature.ItmInterface.SendEquipped(null);

            return(true);
        }
        /// <summary>
        /// Changes the current faction of selected Unit (byte Faction)
        /// </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 ModifyFaction(Player plr, ref List <string> values)
        {
            byte faction = (byte)GetInt(ref values);
            byte save    = (byte)(values.Count > 0 ? GetInt(ref values) : 0);

            Object obj = GetObjectTarget(plr);

            RegionMgr region = obj.Region;
            ushort    zoneId = obj.Zone.ZoneId;

            obj.RemoveFromWorld();
            obj.GetUnit().SetFaction(faction);
            region.AddObject(obj.GetUnit(), zoneId, true);

            if (save > 0)
            {
                if (obj.IsCreature())
                {
                    Creature crea = obj.GetCreature();
                    crea.Spawn.Faction = faction;
                    WorldMgr.Database.SaveObject(crea.Spawn);
                }
            }

            return(true);
        }
Exemple #7
0
        public static bool NpcChangeSpawnPlace(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null && !target.IsCreature())
            {
                return(false);
            }

            target.GetCreature().MvtInterface.Move(plr.WorldPosition);

            Creature creature = target.GetCreature();

            if (creature != null)
            {
                plr.UpdateWorldPosition();

                if (creature.PQSpawnId == null)
                {
                    creature.Spawn.Dirty  = true;
                    creature.Spawn.WorldX = plr._Value.WorldX;
                    creature.Spawn.WorldY = plr._Value.WorldY;
                    creature.Spawn.WorldZ = plr._Value.WorldZ;
                    creature.Spawn.WorldO = plr._Value.WorldO;

                    WorldMgr.Database.SaveObject(creature.Spawn);
                }
                else
                {
                    PQuest_Spawn pQSpawn = WorldMgr.Database.SelectObject <PQuest_Spawn>("pquest_spawns_ID='" + creature.PQSpawnId + "'");

                    pQSpawn.Dirty  = true;
                    pQSpawn.WorldX = plr._Value.WorldX;
                    pQSpawn.WorldY = plr._Value.WorldY;
                    pQSpawn.WorldZ = plr._Value.WorldZ;
                    pQSpawn.WorldO = plr._Value.WorldO;

                    WorldMgr.Database.SaveObject(pQSpawn);
                }
            }

            return(false);
        }
Exemple #8
0
        /// <summary>
        /// Move target to my position
        /// </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 NpcCome(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null || !target.IsCreature())
            {
                return(false);
            }

            target.GetCreature().MvtInterface.Move(plr.WorldPosition);
            return(true);
        }
Exemple #9
0
        public override void OnInteract(Object Obj, Player Target, InteractMenu Menu)
        {
            // Make sure the player has the quest and hasn't already finished the objectives.
            if (!Target.GetPlayer().QtsInterface.HasQuest(30003) || Target.GetPlayer().QtsInterface.HasFinishQuest(30003))
            {
                return;
            }

            // Spawn the bad npc
            Creature_proto Proto = CreatureService.GetCreatureProto((uint)31);

            if (Proto == null)
            {
                return;
            }

            Obj.UpdateWorldPosition();

            Creature_spawn Spawn = new Creature_spawn();

            Spawn.Guid   = (uint)CreatureService.GenerateCreatureSpawnGUID();
            Proto.Model1 = Obj.GetCreature().Spawn.Proto.Model1;
            Proto.Model2 = Obj.GetCreature().Spawn.Proto.Model2;
            Spawn.BuildFromProto(Proto);
            Spawn.WorldO  = Obj.Heading;
            Spawn.WorldY  = Obj.WorldPosition.Y;
            Spawn.WorldZ  = Obj.WorldPosition.Z;
            Spawn.WorldX  = Obj.WorldPosition.X;
            Spawn.ZoneId  = Obj.Zone.ZoneId;
            Spawn.Faction = 129;

            Creature c = Obj.Region.CreateCreature(Spawn);

            c.EvtInterface.AddEventNotify(EventName.OnDie, RemoveAdds);

            // Remove the old npc
            Obj.Destroy();

            return;
        }
        public override void OnInteract(Object Obj, Player Target, InteractMenu Menu)
        {
            // Make sure the player has the quest and hasn't already finished the objectives.
            if (!Target.GetPlayer().QtsInterface.HasQuest(30001) || Target.GetPlayer().QtsInterface.HasFinishQuest(30001))
            {
                return;
            }

            Target.GetPlayer().QtsInterface.HandleEvent(Objective_Type.QUEST_UNKNOWN, 1314, 1, true);

            Creature c    = Obj.GetCreature();
            Random   rand = new Random();

            //  Make the villager say something
            Double chance = rand.NextDouble();

            if (chance >= 0.8)
            {
                c.Say("Thanks for saving me!", SystemData.ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY);
            }
            else if (chance >= 0.6)
            {
                c.Say("Phew, that was close!", SystemData.ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY);
            }
            else if (chance >= 0.4)
            {
                c.Say("Ahh, run for your life!", SystemData.ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY);
            }
            else if (chance >= 0.2)
            {
                c.Say("I could have taken him myself!", SystemData.ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY);
            }
            else
            {
                c.Say("Please help my friend!", SystemData.ChatLogFilters.CHATLOGFILTERS_MONSTER_SAY);
            }


            //  Make the villager run to either the start or the village
            chance = rand.NextDouble();
            if (chance >= 0.5)
            {
                c.GetCreature().MvtInterface.Move(22347, 53688, 7425);
            }
            else
            {
                c.GetCreature().MvtInterface.Move(15548, 51104, 7228);
            }
        }
Exemple #11
0
        /// <summary>
        /// Converts selected Object to a Instance spawn <objective id>
        /// </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 InstanceConvert(Player plr, ref List <string> values)
        {
            //<BossId> <spawngroup> <realm>

            int bossId     = GetInt(ref values);
            int spawngroup = GetInt(ref values);
            int realm      = GetInt(ref values);

            //creatures only atm
            Object obj = GetObjectTarget(plr);

            if (!obj.IsCreature())
            {
                return(false);
            }
            obj.Dispose();

            Creature_spawn spawn = obj.GetCreature().Spawn;

            WorldMgr.Database.DeleteObject(spawn);

            Instance_Spawn newSpawn = new Instance_Spawn();

            newSpawn.Instance_spawns_ID = Guid.NewGuid().ToString();
            newSpawn.Entry           = spawn.Entry;
            newSpawn.WorldO          = (ushort)spawn.WorldO;
            newSpawn.WorldY          = spawn.WorldY;
            newSpawn.WorldZ          = spawn.WorldZ;
            newSpawn.WorldX          = spawn.WorldX;
            newSpawn.ZoneID          = (ushort)spawn.ZoneId;
            newSpawn.Emote           = spawn.Emote;
            newSpawn.Level           = spawn.Level;
            newSpawn.SpawnGroupID    = (uint)spawngroup;
            newSpawn.ConnectedbossId = (uint)bossId;
            newSpawn.Realm           = (byte)realm;


            WorldMgr.Database.AddObject(newSpawn);

            return(true);
        }
Exemple #12
0
        /// <summary>
        /// This method allow comversion of normal NPC to Event NPC.
        /// Not working yet.
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// </summary>
        public static bool NpcEventConvert(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

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

            Creature creature = target.GetCreature();

            return(false);

            /*if (creature != null)
             * {
             *  creature.Spawn.Enabled = (byte)enable;
             *  WorldMgr.Database.SaveObject(creature.Spawn);
             *  creature.Dispose();
             * }
             *
             * return true;*/
        }
Exemple #13
0
        /// <summary>
        /// This method allow disabling NPC spawn for selected NPC.
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// </summary>
        public static bool NpcDisable(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null)
            {
                return(false);
            }
            int enable = 0;

            Creature creature = target.GetCreature();

            if (creature != null)
            {
                creature.Spawn.Dirty   = true;
                creature.Spawn.Enabled = (byte)enable;
                WorldMgr.Database.SaveObject(creature.Spawn);
                creature.Dispose();
            }

            return(true);
        }
Exemple #14
0
        /// <summary>
        /// This method allow setting current health of NPC or GO
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// </summary>
        public static bool NpcHealth(Player plr, ref List <string> values)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

            if (target == null)
            {
                return(false);
            }
            int healthPercent = GetInt(ref values);

            Creature   creature = target.GetCreature();
            GameObject go       = target.GetGameObject();

            if (creature != null)
            {
                creature.Health = Convert.ToUInt32(creature.TotalHealth * healthPercent / 100);
            }
            if (go != null)
            {
                go.Health = Convert.ToUInt32(go.TotalHealth * healthPercent / 100);
            }

            return(true);
        }
Exemple #15
0
        /// <summary>
        /// Converts selected Object to a PQ spawn <objective id>
        /// </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 PqConvert(Player plr, ref List <string> values)
        {
            int objective = GetInt(ref values);
            int type      = GetInt(ref values);

            //creatures only atm
            Object obj = GetObjectTarget(plr);

            switch (type)
            {
            case 1:
                if (!obj.IsCreature())
                {
                    return(false);
                }
                obj.Dispose();

                Creature_spawn spawn = obj.GetCreature().Spawn;
                WorldMgr.Database.DeleteObject(spawn);

                PQuest_Spawn newSpawn = new PQuest_Spawn();
                //Added pquest_spawns_ID here as it is required to correctly save it to DB after this field was
                //added in PQuest_spawn.cs
                newSpawn.pquest_spawns_ID = Guid.NewGuid().ToString();
                newSpawn.Entry            = spawn.Entry;
                newSpawn.Objective        = (uint)objective;
                newSpawn.Type             = 1; // npc
                newSpawn.WorldO           = spawn.WorldO;
                newSpawn.WorldY           = spawn.WorldY;
                newSpawn.WorldZ           = spawn.WorldZ;
                newSpawn.WorldX           = spawn.WorldX;
                newSpawn.ZoneId           = spawn.ZoneId;
                newSpawn.Emote            = spawn.Emote;
                newSpawn.Level            = spawn.Level;

                WorldMgr.Database.AddObject(newSpawn);
                break;

            case 2:
                if (!obj.IsGameObject())
                {
                    return(false);
                }
                obj.Dispose();

                GameObject_spawn gospawn = obj.GetGameObject().Spawn;
                WorldMgr.Database.DeleteObject(gospawn);

                PQuest_Spawn newSpawngo = new PQuest_Spawn();
                newSpawngo.pquest_spawns_ID = Guid.NewGuid().ToString();
                newSpawngo.Entry            = gospawn.Entry;
                newSpawngo.Objective        = (uint)objective;
                newSpawngo.Type             = 2; // go
                newSpawngo.WorldO           = gospawn.WorldO;
                newSpawngo.WorldY           = gospawn.WorldY;
                newSpawngo.WorldZ           = gospawn.WorldZ;
                newSpawngo.WorldX           = gospawn.WorldX;
                newSpawngo.ZoneId           = gospawn.ZoneId;
                newSpawngo.Unks             = gospawn.Unks;

                WorldMgr.Database.AddObject(newSpawngo);
                break;

            case 3:
                if (!obj.IsGameObject())
                {
                    return(false);
                }

                GameObject_spawn gointspawn = obj.GetGameObject().Spawn;

                PQuest_Spawn newSpawnintgo = new PQuest_Spawn();
                newSpawnintgo.pquest_spawns_ID = Guid.NewGuid().ToString();
                newSpawnintgo.Entry            = ((GameObject)obj).Spawn.Guid;
                newSpawnintgo.Objective        = (uint)objective;
                newSpawnintgo.Type             = 3; // change interaction of a spawned go
                WorldMgr.Database.AddObject(newSpawnintgo);
                break;
            }



            return(true);
        }