Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SharpDX.DirectInput;
- using System.Linq;
- using System.Text;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.Csavo // Plugin for showing density within 10 yards around each monster for area damage calculating purposes.
- {
- public class AreaDamageHelperPlugin : BasePlugin, IInGameWorldPainter, IKeyEventHandler // version 1.1 - April 11th, 2017
- {
- public bool Show { get; set; }
- public bool ShowEnabled { get; set; }
- public bool ShowLabel { get; set; }
- public bool ShowList { get; set; }
- public bool ShowAdCircle { get; set; }
- public bool ShowHitBox { get; set; }
- public int Distance { get; set; }
- public WorldDecoratorCollection MonstersInRangeLabel { get; set; }
- public WorldDecoratorCollection MonsterHitBox { get; set; }
- public IBrush CircleBrush { get; set; }
- public float XPos { get; set; }
- public float YPos { get; set; }
- public IFont TextFontList { get; set; }
- private StringBuilder textBuilder;
- public IKeyEvent ToggleKeyEvent { get; set; }
- public Key HotKey
- {
- get { return ToggleKeyEvent.Key; }
- set { ToggleKeyEvent = Hud.Input.CreateKeyEvent(true, value, false, false, false); }
- }
- public AreaDamageHelperPlugin()
- {
- Enabled = true;
- Show = false;
- ShowEnabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- HotKey = Key.F8;
- ShowLabel = true; // show density in area damage range for every alive monster
- ShowList = false; // show a list of all alive monsters on the screen with density in area damage range
- ShowAdCircle = false; // show the area damage range (Distance) as a circle
- ShowHitBox = false; // show monster hitbox
- Distance = 10; // distance for area damage is 10. only change this for testing
- XPos = Hud.Window.Size.Width * 0.01f;
- YPos = Hud.Window.Size.Height * 0.16f;
- TextFontList = Hud.Render.CreateFont("tahoma", 7f, 255, 180, 147, 109, false, false, 160, 0, 0, 0, true);
- textBuilder = new StringBuilder();
- MonstersInRangeLabel = new WorldDecoratorCollection(
- new GroundLabelDecorator(Hud) {
- BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0),
- TextFont = Hud.Render.CreateFont("tahoma", 6f, 255, 180, 147, 109, false, false, 160, 0, 0, 0, true),
- }
- );
- MonsterHitBox = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(51, 255, 255, 255, 0),
- Radius = -1
- }
- );
- CircleBrush = Hud.Render.CreateBrush(51, 255, 255, 255, 1, SharpDX.Direct2D1.DashStyle.Dash);
- }
- public void OnKeyEvent(IKeyEvent keyEvent)
- {
- if (keyEvent.IsPressed && ToggleKeyEvent.Matches(keyEvent))
- {
- Show = !Show;
- }
- }
- public void PaintWorld(WorldLayer layer)
- {
- if (ShowEnabled && Show)
- {
- textBuilder.Clear();
- var monsters = Hud.Game.AliveMonsters;
- foreach (var monster in monsters)
- {
- var count = Hud.Game.AliveMonsters.Count(m => (monster.FloorCoordinate.XYZDistanceTo(m.FloorCoordinate) - m.RadiusBottom) <= Distance);
- if (monster.IsOnScreen && ShowLabel)
- {
- MonstersInRangeLabel.Paint(layer, monster, monster.FloorCoordinate, (count - 1).ToString());
- }
- if (ShowAdCircle)
- {
- CircleBrush.DrawWorldEllipse(Distance, -1, monster.FloorCoordinate);
- }
- if (ShowHitBox)
- {
- MonsterHitBox.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
- }
- if (monster.IsOnScreen && ShowList)
- {
- var monsterTypeName = (monster.SnoMonster.NameLocalized).ToString();
- textBuilder.AppendFormat("{0}: {1}", monsterTypeName, (count - 1).ToString());
- textBuilder.AppendLine();
- }
- var layout = TextFontList.GetTextLayout(textBuilder.ToString());
- TextFontList.DrawText(layout, XPos, YPos);
- }
- }
- else return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement