Beispiel #1
0
        private void Drawing(DrawingContext ctx)
        {
            OverlaySettings settings = OverlaySettings.Instance;

            if (settings.OnlyDrawInForeground &&
                Imports.GetForegroundWindow() != Core.Memory.Process.MainWindowHandle)
            {
                return;
            }

            if (QuestLogManager.InCutscene)
            {
                return;
            }

            //Gameobject list is threadstatic, always need to pulse otherwise new objects wont show up
            GameObjectManager.Update();

            NVector3 mypos    = Core.Me.Location;
            Vector3  vecStart = new Vector3(mypos.X, mypos.Y, mypos.Z);
            int      myLevel  = Core.Me.ClassLevel;


            if (settings.DrawGameStats)
            {
                StringBuilder sb = new StringBuilder();

                GameObject currentTarget = Core.Me.CurrentTarget;


                sb.AppendLine("My Position: " + Core.Me.Location);
                if (currentTarget != null)
                {
                    sb.AppendLine("Current Target: " + currentTarget.Name + ", Distance: " +
                                  Math.Round(currentTarget.Distance(), 3));

                    NVector3 end    = currentTarget.Location;
                    Vector3  vecEnd = new Vector3(end.X, end.Y, end.Z);

                    ctx.DrawLine(vecStart, vecEnd, Color.DeepSkyBlue);
                }
                else
                {
                    sb.AppendLine("");
                }
                sb.AppendLine("");
                sb.AppendLine(string.Format("XP Per Hour: {0:F0}", GameStatsManager.XPPerHour));
                sb.AppendLine(string.Format("Deaths Per Hour: {0:F0}", GameStatsManager.DeathsPerHour));

                if (myLevel < 90)
                {
                    sb.AppendLine(string.Format("Time to Level: {0}", GameStatsManager.TimeToLevel));
                }

                sb.AppendLine(string.Format("TPS: {0:F2}", GameStatsManager.TicksPerSecond));

                sb.AppendLine();

                if (settings.UseShadowedText)
                {
                    ctx.DrawOutlinedText(sb.ToString(),
                                         settings.GameStatsPositionX,
                                         settings.GameStatsPositionY,
                                         settings.GameStatsForegroundColor,
                                         settings.GameStatsShadowColor,
                                         settings.GameStatsFontSize
                                         );
                }
                else
                {
                    ctx.DrawText(sb.ToString(),
                                 settings.GameStatsPositionX,
                                 settings.GameStatsPositionY,
                                 settings.GameStatsForegroundColor,
                                 settings.GameStatsFontSize
                                 );
                }

                ctx.DrawOutlinedBox(Core.Me.Location.Convert() + new Vector3(0, 1, 0), new Vector3(1),
                                    Color.FromArgb(255, Color.Blue));
            }

            if (settings.DrawHostilityBoxes || settings.DrawUnitLines || settings.DrawGameObjectBoxes || settings.DrawGameObjectLines)
            {
                foreach (GameObject obj in GameObjectManager.GameObjects)
                {
                    if (!obj.IsVisible)
                    {
                        continue;
                    }

                    if (settings.OnlyRenderTargetable)
                    {
                        if (obj.Type != GameObjectType.EventObject)
                        {
                            if (!obj.IsTargetable)
                            {
                                continue;
                            }
                        }
                    }



                    if (obj.Type == GameObjectType.Mount)
                    {
                        continue;
                    }

                    var name      = obj.Name;
                    var vecCenter = obj.Location.Convert() + new Vector3(0, 1, 0);


                    //.Where(i => i.Type == GameObjectType.GatheringPoint || i.Type == GameObjectType.BattleNpc || i.Type == GameObjectType.EventObject || i.Type == GameObjectType.Treasure || i.Type == GameObjectType.Pc)



                    var color = Color.FromArgb(150, Color.Blue);

                    //some generic objects. If you want to add a specific object it should probably go here or in it's own block below this.
                    if (obj.Type == GameObjectType.GatheringPoint || obj.Type == GameObjectType.EventObject || obj.Type == GameObjectType.Treasure)
                    {
                        if (obj.Type == GameObjectType.GatheringPoint)
                        {
                            color = Color.FromArgb(150, Color.BlueViolet);
                        }
                        if (obj.Type == GameObjectType.EventObject)
                        {
                            color = Color.FromArgb(150, Color.Fuchsia);
                        }
                        if (obj.Type == GameObjectType.Treasure)
                        {
                            color = Color.SandyBrown;
                        }

                        if (settings.DrawGameObjectNames && !string.IsNullOrEmpty(name))
                        {
                            ctx.Draw3DText(name, vecCenter);
                        }

                        if (settings.DrawGameObjectBoxes)
                        {
                            ctx.DrawOutlinedBox(vecCenter, new Vector3(1), Color.FromArgb(150, color));
                        }



                        //if (settings.DrawGameObjectLines)
                        //{
                        //    if (!settings.DrawGameObjectLinesLos || obj.InLineOfSight())
                        //        ctx.DrawLine(vecStart, vecCenter, Color.FromArgb(150, color));
                        //}
                    }

                    var u = obj as Character;
                    if (u != null)
                    {
                        var playerOrPlayerOwned = (!u.IsNpc || u.SummonerObjectId != GameObjectManager.EmptyGameObject);
                        if (!settings.DrawPlayers && playerOrPlayerOwned)
                        {
                            continue;
                        }

                        var hostilityColor = Color.FromArgb(150, Color.Green);

                        var uStatusFlags = u.StatusFlags;
                        if (uStatusFlags.HasFlag(StatusFlags.Hostile))
                        {
                            hostilityColor = Color.FromArgb(150, Color.Red);

                            //if (settings.DrawAggroRangeCircles)
                            //    ctx.DrawCircle(vecCenter, u.MyAggroRange, 64,
                            //                   Color.FromArgb(75, Color.DeepSkyBlue));
                        }

                        if (uStatusFlags == StatusFlags.None)
                        {
                            hostilityColor = Color.FromArgb(150, Color.Yellow);
                        }

                        if (uStatusFlags.HasFlag(StatusFlags.Friend) || uStatusFlags.HasFlag(StatusFlags.PartyMember) || uStatusFlags.HasFlag(StatusFlags.AllianceMember))
                        {
                            hostilityColor = Color.FromArgb(150, Color.Green);
                        }



                        if (playerOrPlayerOwned)
                        {
                            if (settings.DrawPlayerNames)
                            {
                                ctx.Draw3DText(name, vecCenter);
                            }
                        }
                        else
                        {
                            if (settings.DrawUnitNames)
                            {
                                if (!string.IsNullOrEmpty(name) && obj.IsTargetable)
                                {
                                    ctx.Draw3DText(name, vecCenter);
                                }
                            }
                        }



                        ctx.DrawOutlinedBox(vecCenter, new Vector3(1), Color.FromArgb(255, hostilityColor));
                    }
                }
            }


            //Profile curProfile = ProfileManager.CurrentProfile;
            //if (curProfile != null)
            //{
            //    if (settings.DrawHotspots)
            //    {
            //        GrindArea ga = QuestState.Instance.CurrentGrindArea;
            //        if (ga != null)
            //        {
            //            if (ga.Hotspots != null)
            //            {
            //                foreach (Hotspot hs in ga.Hotspots)
            //                {
            //                    var p = hs.Position;
            //                    Vector3 vec = new Vector3(p.X, p.Y, p.Z);
            //                    ctx.DrawCircle(vec, 10.0f, 32, Color.FromArgb(200, Color.Red));

            //                    if (!string.IsNullOrWhiteSpace(hs.Name))
            //                        ctx.Draw3DText("Hotspot: " + hs.Name, vec);
            //                    else
            //                    {
            //                        ctx.Draw3DText("Hotspot", vec);
            //                    }
            //                }
            //            }
            //        }

            //        // This is only used by grind profiles.
            //        if (curProfile.HotspotManager != null)
            //        {
            //            foreach (NVector3 p in curProfile.HotspotManager.Hotspots)
            //            {
            //                Vector3 vec = new Vector3(p.X, p.Y, p.Z);
            //                ctx.DrawCircle(vec, 10.0f, 32, Color.FromArgb(200, Color.Red));
            //                ctx.Draw3DText("Hotspot", vec);
            //            }
            //        }
            //    }

            //    if (settings.DrawBlackspots)
            //    {
            //        foreach (Blackspot bs in BlackspotManager.GetAllCurrentBlackspots())
            //        {
            //            var p = bs.Location;
            //            Vector3 vec = new Vector3(p.X, p.Y, p.Z);
            //            ctx.DrawCircle(vec, bs.Radius, 32, Color.FromArgb(200, Color.Black));

            //            if (!string.IsNullOrWhiteSpace(bs.Name))
            //                ctx.Draw3DText("Blackspot: " + bs.Name, vec);
            //            else
            //            {
            //                ctx.Draw3DText("Blackspot: " + vec, vec);
            //            }
            //        }
            //    }
            //}
        }
Beispiel #2
0
        private void Drawing(DrawingContext ctx)
        {
            if ((Variables.settings.OnlyForeground && Imports.GetForegroundWindow() != Core.Memory.Process.MainWindowHandle) || QuestLogManager.InCutscene)
            {
                return;
            }

            GameObjectManager.Update();

            NVector3 mypos    = Core.Me.Location;
            Vector3  vecStart = new Vector3(mypos.X, mypos.Y, mypos.Z);
            int      myLevel  = Core.Me.ClassLevel;
            String   mainName = locman.GetLocationString(WorldManager.ZoneId);

            if (Variables.settings.EnableStats) // Statistics.
            {
                StringBuilder sb    = new StringBuilder();
                StringBuilder alert = new StringBuilder();

                GameObject currentTarget = Core.Me.CurrentTarget;

                if (!Variables.settings.AlertObject.Equals(""))
                {
                    foreach (GameObject obj in GameObjectManager.GameObjects)
                    {
                        if (obj.Name.ToLower().Equals(Variables.settings.AlertObject.ToLower()) || (Variables.settings.AlertObject.Equals("*") && obj.Name.Length > 1))
                        {
                            String details = "";
                            if (Core.Me.IsFacing(obj))
                            {
                                details += "Facing!";
                            }
                            alert.AppendLine(obj.Name + ": " + Math.Floor(obj.Location.X) + " EW, " + Math.Floor(obj.Location.Y) + " ALTI, " + Math.Floor(obj.Location.Z) + " NS\n\tDistance: " + Math.Floor(Core.Me.Distance(obj.Location)) + " yalms " + details);
                        }
                    }
                }

                sb.AppendLine(mainName);
                sb.AppendLine(Math.Floor(Core.Me.Location.X) + " EW," + Math.Floor(Core.Me.Location.Y) + " ALTI," + Math.Floor(Core.Me.Location.Z) + " NS");

                if (currentTarget != null)
                {
                    sb.AppendLine("Current Target: " + currentTarget.Name + ", Distance: " +
                                  Math.Round(currentTarget.Distance(), 3));

                    sb.AppendLine("Can Attack: " + currentTarget.CanAttack.ToString());

                    NVector3 end    = currentTarget.Location;
                    Vector3  vecEnd = new Vector3(end.X, end.Y, end.Z);

                    ctx.DrawLine(vecStart, vecEnd, Color.DeepSkyBlue);
                }
                else
                {
                    sb.AppendLine("");
                }

                sb.AppendLine();

                if (true)
                {
                    ctx.DrawOutlinedText(sb.ToString(), Variables.settings.OverlayXPos, Variables.settings.OverlayYPos, Color.FromArgb(0, 255, 0), Color.FromArgb(0, 0, 0));
                    ctx.DrawOutlinedText(alert.ToString(), Variables.settings.AlertXPos, Variables.settings.AlertYPos, Color.FromArgb(255, 0, 0), Color.FromArgb(0, 0, 0));
                }
            }

            if (Variables.settings.EnableOverlay && false) // Target self.
            {
                ctx.DrawOutlinedBox(Core.Me.Location.Convert() + new Vector3(0, 1, 0), new Vector3(0.1f),
                                    Color.FromArgb(255, Color.Blue));
            }

            if (Variables.settings.EnableOverlay)
            {
                foreach (GameObject obj in GameObjectManager.GameObjects)
                {
                    //if (!obj.IsVisible)
                    //    continue;

                    //if (Variables.settings.EnableOverlay) // Only targetable?
                    //{
                    //    if (obj.Type != GameObjectType.EventObject)
                    //    {
                    //        if (!obj.IsTargetable)
                    //            continue;
                    //    }
                    //}



                    if (obj.Type == GameObjectType.Mount)
                    {
                        continue;
                    }

                    var name      = obj.Name;
                    var vecCenter = obj.Location.Convert() + new Vector3(0, 1, 0);


                    //.Where(i => i.Type == GameObjectType.GatheringPoint || i.Type == GameObjectType.BattleNpc || i.Type == GameObjectType.EventObject || i.Type == GameObjectType.Treasure || i.Type == GameObjectType.Pc)



                    var color = Color.FromArgb(150, Color.Blue);

                    //some generic objects. If you want to add a specific object it should probably go here or in it's own block below this.
                    if ((obj.Type == GameObjectType.GatheringPoint || obj.Type == GameObjectType.EventObject || obj.Type == GameObjectType.Treasure) && false) // Etc Objects.
                    {
                        if (obj.Type == GameObjectType.GatheringPoint)
                        {
                            color = Color.FromArgb(150, Color.BlueViolet);
                        }
                        if (obj.Type == GameObjectType.EventObject)
                        {
                            color = Color.FromArgb(150, Color.Fuchsia);
                        }
                        if (obj.Type == GameObjectType.Treasure)
                        {
                            color = Color.SandyBrown;
                        }

                        if (Variables.settings.EnableOverlay && !string.IsNullOrEmpty(name))
                        {
                            ctx.Draw3DText(name, vecCenter);
                        }

                        if (Variables.settings.EnableOverlay)
                        {
                            ctx.DrawOutlinedBox(vecCenter, new Vector3(0.1f), Color.FromArgb(150, color));
                        }



                        //if (Variables.settings.DrawGameObjectLines)
                        //{
                        //    if (!Variables.settings.DrawGameObjectLinesLos || obj.InLineOfSight())
                        //        ctx.DrawLine(vecStart, vecCenter, Color.FromArgb(150, color));
                        //}
                    }

                    var u = obj as Character;
                    if (u != null && false) // Draw all players? Draw NPC's.
                    {
                        var playerOrPlayerOwned = (!u.IsNpc || u.SummonerObjectId != GameObjectManager.EmptyGameObject);

                        /*if (!Variables.settings.DrawPlayers && playerOrPlayerOwned)
                         * {
                         *  continue;
                         * }*/

                        var hostilityColor = Color.FromArgb(150, Color.Green);

                        var uStatusFlags = u.StatusFlags;
                        if (uStatusFlags.HasFlag(StatusFlags.Hostile))
                        {
                            hostilityColor = Color.FromArgb(150, Color.Red);

                            //if (Variables.settings.DrawAggroRangeCircles)
                            //    ctx.DrawCircle(vecCenter, u.MyAggroRange, 64,
                            //                   Color.FromArgb(75, Color.DeepSkyBlue));
                        }

                        if (uStatusFlags == StatusFlags.None)
                        {
                            hostilityColor = Color.FromArgb(150, Color.Yellow);
                        }

                        if (uStatusFlags.HasFlag(StatusFlags.Friend) || uStatusFlags.HasFlag(StatusFlags.PartyMember) || uStatusFlags.HasFlag(StatusFlags.AllianceMember))
                        {
                            hostilityColor = Color.FromArgb(150, Color.Green);
                        }



                        if (playerOrPlayerOwned)
                        {
                            /*if (Variables.settings.DrawPlayerNames)
                             * {
                             *  ctx.Draw3DText(name, vecCenter);
                             * }*/
                        }
                        else
                        {
                            /*if (Variables.settings.DrawUnitNames)
                             * {
                             *  if (!string.IsNullOrEmpty(name) && obj.IsTargetable)
                             *      ctx.Draw3DText(name, vecCenter);
                             * }*/
                        }
                        ctx.DrawOutlinedBox(vecCenter, new Vector3(0.1f), Color.FromArgb(255, hostilityColor));
                    }
                    else if (u != null && Variables.settings.ShowTargetablePlayers)
                    {
                        var     playerOrPlayerOwned = (!u.IsNpc || u.SummonerObjectId != GameObjectManager.EmptyGameObject);
                        Boolean attackable          = u.CanAttack;

                        if (playerOrPlayerOwned && attackable)
                        {
                            ctx.DrawOutlinedBox(vecCenter, new Vector3(0.1f), Color.FromArgb(255, Color.Red));
                        }
                    }
                }
            }
        }