Code:
using System.Linq;
using System;
using System.Collections.Generic;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.iWin
{
public class iWin_CursorOnMonster : BasePlugin, IInGameTopPainter, IInGameWorldPainter
{
public IFont RedTextFont { get; set; }
public IFont YellowTextFont { get; set; }
public IFont OrangeTextFont { get; set; }
public IFont GreenTextFont { get; set; }
public IFont PurpleTextFont { get; set; }
public IFont distTextFont { get; set; }
public WorldDecoratorCollection TrashDecorator { get; set; }
public WorldDecoratorCollection ChampionDecorator { get; set; }
public WorldDecoratorCollection RareMinionDecorator { get; set; }
public WorldDecoratorCollection RareDecorator { get; set; }
public WorldDecoratorCollection UniqueDecorator { get; set; }
public WorldDecoratorCollection BossDecorator { get; set; }
public WorldDecoratorCollection BaseDecorator { get; set; }
public WorldDecoratorCollection inrangeDecorator { get; set; }
private MapShapeDecorator minMapShapeDecorator;
private IFont mcFont;
public float minYard
{
get { return minMapShapeDecorator.Radius; }
set { minMapShapeDecorator.Radius = value; }
}
private float _radius = -1;
public float Radius
{
get { return _radius; }
set
{
if (value == _radius || value < -1)
return;
_radius = value;
InitDecorators();
}
}
public iWin_CursorOnMonster()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
InitDecorators();
}
public void PaintTopInGame(ClipState clipState)
{
if (clipState != ClipState.BeforeClip) return;
if (Hud.Game.IsInTown) return;
int inrange = 0;
string mcText = "0";
var cursorScreenCoord = Hud.Window.CreateScreenCoordinate(Hud.Window.CursorX, Hud.Window.CursorY);
var CursorCoord = cursorScreenCoord.ToWorldCoordinate();
var monstersinrange = Hud.Game.AliveMonsters.Where(m => ((m.SummonerAcdDynamicId == 0 && m.IsElite) || !m.IsElite) && m.FloorCoordinate.XYDistanceTo(CursorCoord) <= minYard);
foreach (var monster in monstersinrange)
{
inrange++;
}
if (inrange > 0){
mcText = inrange.ToString();
}
if (inrange >= 10d && Hud.Game.RiftPercentage != 100)
{
if (inrange >= 10d && Hud.Game.RiftPercentage != 100) mcFont = YellowTextFont;
if (inrange >= 15d && Hud.Game.RiftPercentage != 100) mcFont = OrangeTextFont;
if (inrange >= 25d && Hud.Game.RiftPercentage != 100) mcFont = GreenTextFont;
if (inrange >= 30d && Hud.Game.RiftPercentage != 100) mcFont = PurpleTextFont;
}
else
{
mcFont = RedTextFont;
}
var mcX = Hud.Window.CursorX + 15f;
var mcY = Hud.Window.CursorY - 40f;
if (inrange > 0){
mcFont.DrawText(mcText, mcX, mcY);
}
distTextFont.DrawText(cursorScreenCoord.ToWorldCoordinate().XYDistanceTo(Hud.Game.Me.FloorCoordinate).ToString("F1") + "Y", cursorScreenCoord.Offset(0, -25));
}
public void PaintWorld(WorldLayer layer)
{
if (Hud.Game.IsInTown) return;
var cursorScreenCoord = Hud.Window.CreateScreenCoordinate(Hud.Window.CursorX, Hud.Window.CursorY);
var CursorCoord = cursorScreenCoord.ToWorldCoordinate();
BaseDecorator.Paint(layer, Hud.Game.Me, CursorCoord, null);
var MyPos = Hud.Game.Me.FloorCoordinate.ToScreenCoordinate();
var brush = Hud.Render.CreateBrush(50, 255, 255, 220, 3, SharpDX.Direct2D1.DashStyle.Dash, SharpDX.Direct2D1.CapStyle.Flat, SharpDX.Direct2D1.CapStyle.Flat);
brush.DrawLine(MyPos.X, MyPos.Y, Hud.Window.CursorX, Hud.Window.CursorY);
var monster = Hud.Game.SelectedMonster2 ?? Hud.Game.SelectedMonster1;
if (monster == null) {
if (Hud.Game.SpecialArea == SpecialArea.GreaterRift) inrangeDecorator.Paint(layer, Hud.Game.Me, CursorCoord, null);
return;
}
if (monster.SummonerAcdDynamicId != 0 && monster.IsElite) return;
if (!monster.Invisible && !monster.IsElite && (monster.SnoMonster.Priority != MonsterPriority.goblin) && (monster.SnoMonster.Priority != MonsterPriority.boss) && (monster.SnoMonster.Priority != MonsterPriority.keywarden))
{
TrashDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if (monster.Rarity == ActorRarity.Unique)
{
UniqueDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if (monster.SnoMonster.Priority == MonsterPriority.boss)
{
BossDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if (monster.Rarity == ActorRarity.Champion)
{
ChampionDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if (monster.Rarity == ActorRarity.RareMinion)
{
RareMinionDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if (monster.Rarity == ActorRarity.Rare)
{
RareDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if ((monster.Rarity == ActorRarity.Unique) && (monster.SnoMonster.Priority < MonsterPriority.keywarden))
{
UniqueDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
if (monster.SnoMonster.Priority == MonsterPriority.boss)
{
BossDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
}
}
private void InitDecorators()
{
RedTextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 0, 0, false, false, 250, 0, 0, 0, true);
YellowTextFont = Hud.Render.CreateFont("tahoma", 10, 255, 180, 147, 109, false, false, 250, 0, 0, 0, true);
OrangeTextFont = Hud.Render.CreateFont("tahoma", 12, 255, 255, 128, 0, false, false, 250, 0, 0, 0, true);
GreenTextFont = Hud.Render.CreateFont("tahoma", 14, 255, 0, 255, 0, false, false, 250, 0, 0, 0, true);
PurpleTextFont = Hud.Render.CreateFont("tahoma", 16, 255, 224, 20, 224, false, false, 250, 0, 0, 0, true);
distTextFont = Hud.Render.CreateFont("tahoma", 10, 255, 255, 255, 0, false, false, 250, 0, 0, 0, true);
int stroke = (Radius == -1) ? 0 : 5;
var TrashGroundBrush = Hud.Render.CreateBrush(90, 200, 200, 200, stroke);
TrashDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = TrashGroundBrush,
Radius = Radius
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 200, 200, 200, 3),
Radius = Radius
}
);
var EliteChampionGroundBrush = Hud.Render.CreateBrush(90, 64, 128, 255, stroke);
ChampionDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = EliteChampionGroundBrush,
Radius = Radius
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 64, 128, 255, 3),
Radius = Radius
}
);
var EliteMinionGroundBrush = Hud.Render.CreateBrush(90, 255, 216, 160, stroke);
RareMinionDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = EliteMinionGroundBrush,
Radius = Radius
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 255, 216, 160, 3),
Radius = Radius
}
);
var EliteLeaderGroundBrush = Hud.Render.CreateBrush(90, 255, 148, 20, stroke);
RareDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = EliteLeaderGroundBrush,
Radius = Radius
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 255, 148, 20, 3),
Radius = Radius
}
);
var EliteUniqueGroundBrush = Hud.Render.CreateBrush(90, 255, 140, 255, stroke);
UniqueDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = EliteUniqueGroundBrush,
Radius = Radius
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 255, 140, 255, 3),
Radius = Radius
}
);
var BossGroundBrush = Hud.Render.CreateBrush(90, 255, 96, 0, stroke);
BossDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = BossGroundBrush,
Radius = Radius
}
);
var BaseLineBrush = Hud.Render.CreateBrush(150, 255, 255, 255, 1, SharpDX.Direct2D1.DashStyle.Dash, SharpDX.Direct2D1.CapStyle.Flat, SharpDX.Direct2D1.CapStyle.Flat);
var BaseBrush = Hud.Render.CreateBrush(150, 255, 255, 255, 1);
var BaseGroundBrush = Hud.Render.CreateBrush(90, 200, 200, 200, stroke);
BaseDecorator = new WorldDecoratorCollection(
new MapShapeDecorator(Hud)
{
Brush = BaseLineBrush,
ShapePainter = new LineFromMeShapePainter(Hud),
Radius = 2
},
new MapShapeDecorator(Hud)
{
Brush = BaseBrush,
ShapePainter = new PlusShapePainter(Hud),
Radius = 2
},
new MapShapeDecorator(Hud)
{
Brush = BaseBrush,
ShapePainter = new PlusShapePainter(Hud),
Radius = 10
},
new MapShapeDecorator(Hud)
{
Brush = BaseBrush,
ShapePainter = new CircleShapePainter(Hud),
Radius = 5
},
new GroundCircleDecorator(Hud)
{
Brush = BaseGroundBrush,
Radius = Radius
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 200, 200, 200, 3),
Radius = Radius
}
);
inrangeDecorator = new WorldDecoratorCollection(
new GroundShapeDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 255, 55, 55, 3),
ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
ShapePainter = WorldStarShapePainter.NewCross(Hud),
Radius = 3.5f
},
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 255, 55, 55, 3),
Radius = 3.5f
}
);
minMapShapeDecorator = new MapShapeDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(150, 180, 147, 109, 1),
ShapePainter = new CircleShapePainter(Hud),
Radius = 17
};
}
}
}