Advertisement
Guest User

MonstersCountPlugin.cs.cs

a guest
Jan 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using SharpDX.DirectInput;
  2. using System.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using Turbo.Plugins.Default;
  6.  
  7. namespace Turbo.Plugins.glq
  8. {
  9. using System.Text;
  10.  
  11. // by 我想静静 黑白灰 小米 Jack Céparou
  12. public class MonstersCountPlugin : BasePlugin, IInGameTopPainter, IInGameWorldPainter, IKeyEventHandler
  13. {
  14. public IFont DefaultTextFont { get; set; }
  15. public IFont OrangeTextFont { get; set; }
  16. public IFont RedTextFont { get; set; }
  17. public WorldDecoratorCollection StatisticalRangeDecorator { get; set; }
  18. public WorldDecoratorCollection MaxStatisticalRangeDecorator { get; set; }
  19. private float currentYard;
  20. public float BaseYard
  21. {
  22. get { return baseMapShapeDecorator.Radius; }
  23. set {
  24. baseMapShapeDecorator.Radius = value;
  25. currentYard = BaseYard;
  26. }
  27. }
  28. public float MaxYard
  29. {
  30. get { return maxMapShapeDecorator.Radius; }
  31. set { maxMapShapeDecorator.Radius = value; }
  32. }
  33. public bool ShowCircle { get; set; }
  34. public IKeyEvent ToggleKeyEvent { get; set; }
  35. public bool ShowMonstersCount { get; set; }
  36.  
  37. public bool ShowTotalProgression { get; set; }
  38. public bool ShowTrashProgression { get; set; }
  39. public bool ShowEliteProgression { get; set; }
  40. public bool ShowRareMinionProgression { get; set; }
  41. public bool ShowRiftGlobeProgression { get; set; }
  42.  
  43. public bool ShowLlocustCount { get; set; }
  44. public bool ShowHauntedCount { get; set; }
  45. public bool ShowPalmedCount { get; set; }
  46. public bool ShowPhoenixedCount { get; set; }
  47. public bool ShowStrongarmedCount { get; set; }
  48. public bool ShowTime { get; set; }
  49. public bool ToggleEnable { get; set; }
  50. public float XWidth { get; set; }
  51. public float YHeight { get; set; }
  52.  
  53. private IFont currentFont;
  54. private bool TurnedOn;
  55.  
  56. private MapShapeDecorator baseMapShapeDecorator;
  57. private MapShapeDecorator maxMapShapeDecorator;
  58.  
  59. private StringBuilder textBuilder;
  60.  
  61. public MonstersCountPlugin()
  62. {
  63. Enabled = true;
  64. ShowCircle = true;
  65. ToggleEnable = true;
  66. }
  67.  
  68. public override void Load(IController hud)
  69. {
  70. base.Load(hud);
  71. ToggleKeyEvent = Hud.Input.CreateKeyEvent(true, Key.LeftControl, true, false, false);
  72. DefaultTextFont = Hud.Render.CreateFont("tahoma", 9, 255, 180, 147, 109, false, false, 250, 0, 0, 0, true);
  73. OrangeTextFont = Hud.Render.CreateFont("tahoma", 9, 255, 255, 128, 0, false, false, 250, 0, 0, 0, true);
  74. RedTextFont = Hud.Render.CreateFont("tahoma", 9, 255, 255, 0, 0, false, false, 250, 0, 0, 0, true);
  75.  
  76. TurnedOn = false;
  77. ShowMonstersCount = true;
  78. ShowTotalProgression = true;
  79. ShowTrashProgression = true;
  80. ShowEliteProgression = true;
  81. ShowRareMinionProgression = true;
  82. ShowRiftGlobeProgression = true;
  83. ShowTime = true;
  84. ShowLlocustCount = true;
  85. ShowHauntedCount = true;
  86. ShowPalmedCount = true;
  87. ShowPhoenixedCount = false;
  88. ShowStrongarmedCount = true;
  89.  
  90. XWidth = 0.84f;
  91. YHeight = 0.61f;
  92. textBuilder = new StringBuilder();
  93.  
  94. baseMapShapeDecorator = new MapShapeDecorator(Hud)
  95. {
  96. Brush = Hud.Render.CreateBrush(150, 180, 147, 109, 1),
  97. ShapePainter = new CircleShapePainter(Hud),
  98. Radius = 40,
  99. };
  100. StatisticalRangeDecorator = new WorldDecoratorCollection(baseMapShapeDecorator);
  101. currentYard = BaseYard;
  102. maxMapShapeDecorator = new MapShapeDecorator(Hud)
  103. {
  104. Brush = Hud.Render.CreateBrush(150, 180, 147, 109, 1),
  105. ShapePainter = new CircleShapePainter(Hud),
  106. Radius = 120,
  107. };
  108. MaxStatisticalRangeDecorator = new WorldDecoratorCollection(maxMapShapeDecorator);
  109. }
  110.  
  111. public void OnKeyEvent(IKeyEvent keyEvent)
  112. {
  113. if (keyEvent.IsPressed && ToggleKeyEvent.Matches(keyEvent) && ToggleEnable)
  114. {
  115. TurnedOn = !TurnedOn;
  116. currentYard = TurnedOn ? MaxYard : BaseYard;
  117. }
  118. }
  119.  
  120. public void PaintWorld(WorldLayer layer)
  121. {
  122. if (Hud.Game.IsInTown || !ShowCircle) return;
  123. if (TurnedOn)
  124. {
  125. MaxStatisticalRangeDecorator.Paint(layer, null, Hud.Game.Me.FloorCoordinate, null);
  126. }
  127. else
  128. {
  129. StatisticalRangeDecorator.Paint(layer, null, Hud.Game.Me.FloorCoordinate, null);
  130. }
  131. }
  132.  
  133. public void PaintTopInGame(ClipState clipState)
  134. {
  135. if (clipState != ClipState.BeforeClip) return;
  136. var inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  137. var inGR = Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  138. if (DefaultTextFont == null)
  139. {
  140. return;
  141. }
  142.  
  143. double totalMonsterRiftProgression = 0;
  144. double TrashMonsterRiftProgression = 0;
  145. double EliteProgression = 0;
  146. double RareMinionProgression = 0;
  147. double RiftGlobeProgression = 0;
  148.  
  149. int monstersCount = 0;
  150. int EliteCount = 0;
  151. int RareMinionCount = 0;
  152. int ElitePackCount = 0;
  153. // locust
  154. int locustCount = 0;
  155. int ElitelocustCount = 0;
  156. // haunted
  157. int hauntedCount = 0;
  158. int ElitehauntedCount = 0;
  159. //Palmed
  160. int palmedCount = 0;
  161. int ElitepalmedCount = 0;
  162. //Phoenixed BUG? http://turbohud.freeforums.net/thread/3945/monster-phoenixed
  163. int phoenixedCount = 0;
  164. int ElitephoenixedCount = 0;
  165. //Strongarmed Obsolete
  166. int strongarmedCount = 0;
  167. int ElitestrongarmedCount = 0;
  168. float XPos = Hud.Window.Size.Width * XWidth;
  169. float YPos = Hud.Window.Size.Height * YHeight;
  170.  
  171. var monsters = Hud.Game.AliveMonsters.Where(m => ((m.SummonerAcdDynamicId == 0 && m.IsElite) || !m.IsElite) && m.FloorCoordinate.XYDistanceTo(Hud.Game.Me.FloorCoordinate) <= currentYard);
  172. Dictionary<IMonster, string> eliteGroup = new Dictionary<IMonster, string>();
  173. foreach (var monster in monsters)
  174. {
  175. var Elite = monster.Rarity == ActorRarity.Rare || monster.Rarity == ActorRarity.Champion || monster.Rarity == ActorRarity.Unique || monster.Rarity == ActorRarity.Boss;
  176. monstersCount++;
  177. if (!monster.IsElite)
  178. {
  179. if (inRift) TrashMonsterRiftProgression += monster.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  180. }
  181. else
  182. {
  183. if (monster.Rarity == ActorRarity.RareMinion)
  184. {
  185. RareMinionCount++;
  186. if (inRift) RareMinionProgression += monster.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  187. }
  188. else
  189. {
  190. if (monster.Rarity == ActorRarity.Unique || monster.Rarity == ActorRarity.Boss)
  191. {
  192. EliteCount++;
  193. ElitePackCount++;
  194. }
  195.  
  196. if (monster.Rarity == ActorRarity.Champion)
  197. {
  198. EliteCount++;
  199. eliteGroup.Add(monster, String.Join(", ", monster.AffixSnoList));
  200. if (inRift) EliteProgression += monster.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  201. }
  202.  
  203. if (monster.Rarity == ActorRarity.Rare)
  204. {
  205. EliteCount++;
  206. ElitePackCount++;
  207. if (inRift)
  208. {
  209. EliteProgression += 4 * 1.15d;
  210. EliteProgression += monster.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  211. }
  212. }
  213. }
  214. }
  215. if (monster.Locust && ShowLlocustCount)
  216. {
  217. locustCount++;
  218. if (Elite) ElitelocustCount++;
  219. }
  220. if (monster.Haunted && ShowHauntedCount)
  221. {
  222. hauntedCount++;
  223. if (Elite) ElitehauntedCount++;
  224. }
  225. if (monster.Palmed && ShowPalmedCount)
  226. {
  227. palmedCount++;
  228. if (Elite) ElitepalmedCount++;
  229. }
  230. if (monster.Phoenixed && ShowPhoenixedCount)
  231. {
  232. phoenixedCount++;
  233. if (Elite) ElitephoenixedCount++;
  234. }
  235. if (monster.Strongarmed && ShowStrongarmedCount)
  236. {
  237. strongarmedCount++;
  238. if (Elite) ElitestrongarmedCount++;
  239. }
  240. }
  241. Dictionary<IMonster, string> eliteGroup1 = eliteGroup.OrderBy(p => p.Value).ToDictionary(p => p.Key, o => o.Value);
  242. if (monstersCount == 0) return;
  243. var actors = Hud.Game.Actors.Where(x => x.SnoActor.Kind == ActorKind.RiftOrb);
  244. foreach (var actor in actors)
  245. {
  246. RiftGlobeProgression += 1.15d;
  247. }
  248. string preStr = null;
  249. foreach (var elite in eliteGroup1)
  250. {
  251. if (elite.Key.Rarity == ActorRarity.Champion)
  252. {
  253. if (preStr != elite.Value)
  254. {
  255.  
  256. EliteProgression += 3 * 1.15f;
  257. ElitePackCount++;
  258. }
  259. preStr = elite.Value;
  260. }
  261. }
  262. textBuilder.Clear();
  263. if (ShowMonstersCount)
  264. {
  265. textBuilder.AppendFormat("{0} 미터 몬스터 숫자: {1}", currentYard, monstersCount);
  266. textBuilder.AppendLine();
  267. if (EliteCount > 0) textBuilder.AppendFormat("Elite: {0}(Pack: {1})", EliteCount, ElitePackCount);
  268. if (RareMinionCount > 0) textBuilder.AppendFormat("Minion: {0}", RareMinionCount);
  269. textBuilder.AppendLine();
  270. textBuilder.AppendLine();
  271. }
  272.  
  273. if (inRift)
  274. {
  275. totalMonsterRiftProgression = TrashMonsterRiftProgression + EliteProgression + RareMinionProgression + RiftGlobeProgression;
  276. long totalTime = (long)totalMonsterRiftProgression * 90000000;
  277. long TrashTime = (long)TrashMonsterRiftProgression * 90000000;
  278. long EliteTime = (long)EliteProgression * 90000000;
  279. long RareMinionTime = (long)RareMinionProgression * 90000000;
  280. long RiftGlobeTime = (long)RiftGlobeProgression * 90000000;
  281. if (totalMonsterRiftProgression > 0 && ShowTotalProgression)
  282. {
  283. if (ShowTime && inGR)
  284. {
  285. textBuilder.AppendFormat("TotalRP: {0}% = {1}", totalMonsterRiftProgression.ToString("f2"), ValueToString((long)totalTime, ValueFormat.LongTime));
  286. }
  287. else
  288. {
  289. textBuilder.AppendFormat("TotalRP: {0}%", totalMonsterRiftProgression.ToString("f2"));
  290. }
  291. textBuilder.AppendLine();
  292. }
  293.  
  294. if (TrashMonsterRiftProgression > 0 && ShowTrashProgression)
  295. {
  296. if (ShowTime && inGR)
  297. {
  298. textBuilder.AppendFormat("TrashRP: {0}% = {1}", TrashMonsterRiftProgression.ToString("f2"), ValueToString((long)TrashTime, ValueFormat.LongTime));
  299. }
  300. else
  301. {
  302. textBuilder.AppendFormat("TrashRP: {0}%", TrashMonsterRiftProgression.ToString("f2"));
  303. }
  304. textBuilder.AppendLine();
  305. }
  306. if (EliteProgression > 0 && ShowEliteProgression)
  307. {
  308. if (ShowTime && inGR)
  309. {
  310. textBuilder.AppendFormat("EliteRP: {0}% = {1}", EliteProgression.ToString("f2"), ValueToString((long)EliteTime, ValueFormat.LongTime));
  311. }
  312. else
  313. {
  314. textBuilder.AppendFormat("EliteRP: {0}%", EliteProgression.ToString("f2"));
  315. }
  316. textBuilder.AppendLine();
  317. }
  318. if (RareMinionProgression > 0 && ShowRareMinionProgression)
  319. {
  320. if (ShowTime && inGR)
  321. {
  322. textBuilder.AppendFormat("MinionRP: {0}% = {1}", RareMinionProgression.ToString("f2"), ValueToString((long)RareMinionTime, ValueFormat.LongTime));
  323. }
  324. else
  325. {
  326. textBuilder.AppendFormat("MinionRP: {0}%", RareMinionProgression.ToString("f2"));
  327. }
  328. textBuilder.AppendLine();
  329. }
  330. if (RiftGlobeProgression > 0 && ShowRiftGlobeProgression)
  331. {
  332. if (ShowTime && inGR)
  333. {
  334. textBuilder.AppendFormat("GlobeRP: {0}% = {1}", RiftGlobeProgression.ToString("f2"), ValueToString((long)RiftGlobeTime, ValueFormat.LongTime));
  335. }
  336. else
  337. {
  338. textBuilder.AppendFormat("GlobeRP: {0}%", RiftGlobeProgression.ToString("f2"));
  339. }
  340. textBuilder.AppendLine();
  341. }
  342. textBuilder.AppendLine();
  343. }
  344. if (locustCount > 0 && ShowLlocustCount)
  345. {
  346. textBuilder.AppendFormat("Locust: {0}/{1}", locustCount, monstersCount);
  347. if (ElitelocustCount > 0) textBuilder.AppendFormat(" (Elite: {0}/{1})", ElitelocustCount, EliteCount);
  348. textBuilder.AppendLine();
  349. }
  350. if (hauntedCount > 0 && ShowHauntedCount)
  351. {
  352. textBuilder.AppendFormat("Haunted: {0}/{1}", hauntedCount, monstersCount);
  353. if (ElitehauntedCount > 0) textBuilder.AppendFormat(" (Elite: {0}/{1})", ElitehauntedCount, EliteCount);
  354. textBuilder.AppendLine();
  355. }
  356. if (palmedCount > 0 && ShowPalmedCount)
  357. {
  358. textBuilder.AppendFormat("Palmed: {0}/{1}", palmedCount, monstersCount);
  359. if (ElitepalmedCount > 0) textBuilder.AppendFormat(" (Elite: {0}/{1})", ElitepalmedCount, EliteCount);
  360. textBuilder.AppendLine();
  361. }
  362. if (phoenixedCount > 0 && ShowPhoenixedCount)
  363. {
  364. textBuilder.AppendFormat("Phoenixed: {0}/{1}", phoenixedCount, monstersCount);
  365. if (ElitephoenixedCount > 0) textBuilder.AppendFormat(" (Elite: {0}/{1})", ElitephoenixedCount, EliteCount);
  366. textBuilder.AppendLine();
  367. }
  368. if (strongarmedCount > 0 && ShowStrongarmedCount)
  369. {
  370. textBuilder.AppendFormat("Strongarmed: {0}/{1}", strongarmedCount, monstersCount);
  371. if (ElitestrongarmedCount > 0) textBuilder.AppendFormat(" (Elite: {0}/{1})", ElitestrongarmedCount, EliteCount);
  372. textBuilder.AppendLine();
  373. }
  374.  
  375. if (totalMonsterRiftProgression >= 100d - Hud.Game.RiftPercentage && Hud.Game.RiftPercentage != 100 || TrashMonsterRiftProgression >= 100d - Hud.Game.RiftPercentage && Hud.Game.RiftPercentage != 100)
  376. {
  377. if (totalMonsterRiftProgression >= 100d - Hud.Game.RiftPercentage && Hud.Game.RiftPercentage != 100) currentFont = OrangeTextFont;
  378. if (TrashMonsterRiftProgression >= 100d - Hud.Game.RiftPercentage && Hud.Game.RiftPercentage != 100) currentFont = RedTextFont;
  379. }
  380. else
  381. {
  382. currentFont = DefaultTextFont;
  383. }
  384. var layout = currentFont.GetTextLayout(textBuilder.ToString());
  385. currentFont.DrawText(layout, XPos, YPos);
  386. }
  387. }
  388. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement