示例#1
0
        /// <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);
        }
示例#2
0
        public static void Remove(Player plr, bool database)
        {
            Object obj = GetObjectTarget(plr);

            if (!obj.IsGameObject())
            {
                plr.SendClientMessage($"GAMEOBJECT REMOVE: Target is not a gameobject", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                return;
            }

            obj.RemoveFromWorld();

            if (database)
            {
                WorldMgr.Database.DeleteObject(obj.GetGameObject().Spawn);
            }
        }