Пример #1
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);
            }
        }
Пример #2
0
        public static bool Health(Player plr, int healthPercent)
        {
            Object target = plr.CbtInterface.GetCurrentTarget();

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

            GameObject go = target.GetGameObject();

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

            return(true);
        }
Пример #3
0
        public override void OnInteract(Object Obj, Player Target, InteractMenu Menu)
        {
            Objects.GameObject go = Obj.GetGameObject();

            float dx = go.Spawn.WorldX - Target._Value.WorldX;
            float dy = go.Spawn.WorldY - Target._Value.WorldY;

            double heading = Math.Atan2(-dx, dy);

            if (heading < 0)
            {
                heading += 4096;
            }

            const int distance = (int)((float)5 * 13.2f);
            double    angle    = heading;
            double    targetX  = go.Spawn.WorldX - (Math.Sin(angle) * distance);
            double    targetY  = go.Spawn.WorldY + (Math.Cos(angle) * distance);

            int newX;
            int newY;

            if (targetX > 0)
            {
                newX = (int)targetX;
            }
            else
            {
                newX = 0;
            }

            if (targetY > 0)
            {
                newY = (int)targetY;
            }
            else
            {
                newY = 0;
            }

            Target.IntraRegionTeleport((uint)newX, (uint)newY, (ushort)go.Spawn.WorldZ, (ushort)Target._Value.WorldO);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
0
        public void HandleEvent(Objective_Type type, uint entry, int count, bool suppressGroupBroadcast = false)
        {
            Player player = _Owner as Player;

            if (!suppressGroupBroadcast)
            {
                if (player?.PriorityGroup != null)
                {
                    Group currentGroup = player.PriorityGroup;

                    foreach (Player member in currentGroup.GetPlayersCloseTo(player, 150))
                    {
                        if (member != player)
                        {
                            member.QtsInterface.HandleEvent(type, entry, count, true);
                        }
                    }
                }
            }

            if (_Owner is Pet && _Owner.GetPet().Owner != null)
            {
                _Owner.GetPet().Owner.QtsInterface.HandleEvent(type, entry, count, true);
            }

            // Check every quest a player has...
            foreach (KeyValuePair <ushort, Character_quest> questKp in Quests)
            {
                // For each objective in every quest...
                foreach (Character_Objectives objective in questKp.Value._Objectives)
                {
                    if (objective.Objective == null)
                    {
                        continue;
                    }

                    // RB   7/4/2016    Allow objectives to be completed in an order
                    if (objective.Objective.PreviousObj > 0)
                    {
                        Character_Objectives previousObjective = questKp.Value._Objectives.FirstOrDefault(o => o.Objective.Guid == objective.Objective.PreviousObj);
                        if (previousObjective != null && !previousObjective.IsDone())
                        {
                            continue;
                        }
                    }

                    if (objective.Objective.ObjType == (uint)type && !objective.IsDone())
                    {
                        if (objective.Objective.PQArea > 0)
                        {
                            bool skip = true;

                            if (player.CurrentKeep != null && player.CurrentKeep.Realm == player.Realm && player.CurrentKeep.Info.PQuest != null && player.CurrentKeep.Info.PQuest.Entry == objective.Objective.PQArea)
                            {
                                skip = false;
                            }

                            else if (PublicQuest != null && PublicQuest.Info.Entry == objective.Objective.PQArea)
                            {
                                skip = false;
                            }

                            if (skip)
                            {
                                continue;
                            }
                        }

                        if (!string.IsNullOrEmpty(objective.Objective.inZones))
                        {
                            string[] temp = objective.Objective.inZones.Split(',');
                            if (temp != null && (player.Zone == null || !temp.Contains("" + player.Zone.ZoneId)))
                            {
                                continue;
                            }
                        }


                        bool canAdd   = false;
                        int  newCount = objective.Count;

                        switch (type)
                        {
                        case Objective_Type.QUEST_SPEAK_TO:
                        case Objective_Type.QUEST_KILL_MOB:
                        case Objective_Type.QUEST_PROTECT_UNIT:
                            if (objective.Objective.Creature != null && entry == objective.Objective.Creature.Entry)
                            {
                                canAdd    = true;
                                newCount += count;
                            }
                            break;

                        case Objective_Type.QUEST_KILL_GO:
                            if (objective.Objective.GameObject != null && entry == objective.Objective.GameObject.Entry)
                            {
                                canAdd    = true;
                                newCount += count;
                            }
                            break;

                        case Objective_Type.QUEST_KILL_PLAYERS:
                            if (objective.Objective != null)
                            {
                                int result;

                                if (int.TryParse(objective.Objective.ObjID, out result))
                                {
                                    if (result == 0 || ((result >> ((byte)entry - 1)) & 1) == 1)
                                    {
                                        canAdd    = true;
                                        newCount += count;
                                    }
                                }
                            }
                            break;

                        case Objective_Type.QUEST_GET_ITEM:
                        case Objective_Type.QUEST_USE_ITEM:
                            if (objective.Objective.Item != null && entry == objective.Objective.Item.Entry)
                            {
                                canAdd   = true;
                                newCount = _Owner.GetPlayer().ItmInterface.GetItemCount(entry);
                            }
                            break;

                        case Objective_Type.QUEST_USE_GO:
                            if (objective.Objective.GameObject != null && entry == objective.Objective.GameObject.Entry)
                            {
                                // This will turn off Interactable flag on clicked GO, some more work can be
                                // done with GO despawning and UNKs[3] unk modification
                                // Default respawn time: 60 seconds
                                Object target = player.CbtInterface.GetCurrentTarget();
                                if (target != null)
                                {
                                    GameObject go = target.GetGameObject();
                                    if (go != null && go.IsGameObject())
                                    {
                                        if (go.Spawn.AllowVfxUpdate == 1)
                                        {
                                            go.VfxState = 1;
                                        }
                                        go.Interactable = false;
                                        go.EvtInterface.AddEvent(MakeGOInteractable, 60000, 1, target);
                                    }
                                }

                                canAdd    = true;
                                newCount += count;
                            }
                            break;

                        case Objective_Type.QUEST_WIN_SCENARIO:
                            if (objective.Objective.Scenario != null && entry == objective.Objective.Scenario.ScenarioId)
                            {
                                canAdd    = true;
                                newCount += count;
                            }
                            break;

                        case Objective_Type.QUEST_CAPTURE_BO:
                            if (objective.Objective.BattleFrontObjective != null && entry == objective.Objective.BattleFrontObjective.Entry)
                            {
                                canAdd    = true;
                                newCount += count;
                            }
                            break;

                        case Objective_Type.QUEST_CAPTURE_KEEP:
                            if (objective.Objective.Keep != null && entry == objective.Objective.Keep.KeepId)
                            {
                                canAdd    = true;
                                newCount += count;
                            }
                            break;

                        default:
                            if (objective.Objective.Guid == entry)
                            {
                                canAdd    = true;
                                newCount += count;
                            }
                            break;
                        }

                        if (canAdd)
                        {
                            objective.Count     = newCount;
                            questKp.Value.Dirty = true;
                            SendQuestUpdate(questKp.Value);
                            CharMgr.Database.SaveObject(questKp.Value);

                            if (objective.IsDone())
                            {
                                Creature finisher;

                                foreach (Object obj in _Owner.ObjectsInRange)
                                {
                                    if (obj.IsCreature())
                                    {
                                        finisher = obj.GetCreature();
                                        if (QuestService.HasQuestToFinish(finisher.Entry, questKp.Value.Quest.Entry))
                                        {
                                            finisher.SendMeTo(_Owner.GetPlayer());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }