BuffDialog.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. using Client.MirSounds;
  4. namespace Client.MirScenes.Dialogs
  5. {
  6. public class BuffDialog : MirImageControl
  7. {
  8. public List<ClientBuff> Buffs = new List<ClientBuff>();
  9. protected MirButton _expandCollapseButton;
  10. protected MirLabel _buffCountLabel;
  11. protected List<MirImageControl> _buffList = new List<MirImageControl>();
  12. protected bool _fadedOut, _fadedIn;
  13. protected int _buffCount;
  14. protected long _nextFadeTime;
  15. public Func<bool> GetExpandedParameter;
  16. public Action<bool> SetExpandedParameter;
  17. private bool ExpandedBuffWindow
  18. {
  19. get { return GetExpandedParameter(); }
  20. set { SetExpandedParameter(value); }
  21. }
  22. protected const long FadeDelay = 55;
  23. protected const float FadeRate = 0.2f;
  24. public BuffDialog()
  25. {
  26. Index = 20;
  27. Library = Libraries.Prguse2;
  28. Movable = false;
  29. Size = new Size(44, 34);
  30. Location = new Point(Settings.ScreenWidth - 170, 0);
  31. Sort = true;
  32. Opacity = 0f;
  33. _fadedOut = true;
  34. _expandCollapseButton = new MirButton
  35. {
  36. Index = 7,
  37. HoverIndex = 8,
  38. Size = new Size(16, 15),
  39. Library = Libraries.Prguse2,
  40. Parent = this,
  41. PressedIndex = 9,
  42. Sound = SoundList.ButtonA,
  43. Opacity = 0f
  44. };
  45. _expandCollapseButton.Click += (o, e) =>
  46. {
  47. if (_buffCount == 1)
  48. {
  49. ExpandedBuffWindow = true;
  50. }
  51. else
  52. {
  53. ExpandedBuffWindow = !ExpandedBuffWindow;
  54. }
  55. UpdateWindow();
  56. };
  57. _buffCountLabel = new MirLabel
  58. {
  59. Parent = this,
  60. AutoSize = true,
  61. DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
  62. Font = new Font(Settings.FontName, 10F, FontStyle.Bold),
  63. NotControl = true,
  64. Sort = true,
  65. Visible = false,
  66. ForeColour = Color.Yellow,
  67. OutLineColour = Color.Black,
  68. };
  69. }
  70. public void CreateBuff(ClientBuff buff)
  71. {
  72. var buffImage = BuffImage(buff.Type);
  73. var buffLibrary = Libraries.BuffIcon;
  74. if (buffImage >= 20000)
  75. {
  76. buffImage -= 20000;
  77. buffLibrary = Libraries.MagIcon;
  78. }
  79. if (buffImage >= 10000)
  80. {
  81. buffImage -= 10000;
  82. buffLibrary = Libraries.Prguse2;
  83. }
  84. var image = new MirImageControl
  85. {
  86. Library = buffLibrary,
  87. Parent = this,
  88. Visible = true,
  89. Sort = false,
  90. Index = buffImage
  91. };
  92. _buffList.Insert(0, image);
  93. UpdateWindow();
  94. }
  95. public void RemoveBuff(int buffId)
  96. {
  97. _buffList[buffId].Dispose();
  98. _buffList.RemoveAt(buffId);
  99. UpdateWindow();
  100. }
  101. public void Process()
  102. {
  103. if (!Visible) return;
  104. if (_buffList.Count != _buffCount)
  105. {
  106. UpdateWindow();
  107. }
  108. for (var i = 0; i < _buffList.Count; i++)
  109. {
  110. var image = _buffList[i];
  111. var buff = Buffs[i];
  112. var buffImage = BuffImage(buff.Type);
  113. var buffLibrary = Libraries.BuffIcon;
  114. //ArcherSpells - VampireShot,PoisonShot
  115. if (buffImage >= 20000)
  116. {
  117. buffImage -= 20000;
  118. buffLibrary = Libraries.MagIcon;
  119. }
  120. if (buffImage >= 10000)
  121. {
  122. buffImage -= 10000;
  123. buffLibrary = Libraries.Prguse2;
  124. }
  125. var location = new Point(Size.Width - 10 - 23 - (i * 23) + ((10 * 23) * (i / 10)), 6 + ((i / 10) * 24));
  126. image.Location = new Point(location.X, location.Y);
  127. image.Hint = ExpandedBuffWindow ? BuffString(buff) : CombinedBuffText();
  128. image.Index = buffImage;
  129. image.Library = buffLibrary;
  130. if (ExpandedBuffWindow || !ExpandedBuffWindow && i == 0)
  131. {
  132. image.Visible = true;
  133. image.Opacity = 1f;
  134. }
  135. else
  136. {
  137. image.Visible = false;
  138. image.Opacity = 0.6f;
  139. }
  140. if (buff.Paused || buff.Infinite || !(Math.Round((buff.ExpireTime - CMain.Time) / 1000D) <= 5))
  141. continue;
  142. var time = (buff.ExpireTime - CMain.Time) / 100D;
  143. if (Math.Round(time) % 10 < 5)
  144. image.Index = -1;
  145. }
  146. if (IsMouseOver(CMain.MPoint))
  147. {
  148. if (_buffCount == 0 || (!_fadedIn && CMain.Time <= _nextFadeTime))
  149. return;
  150. Opacity += FadeRate;
  151. _expandCollapseButton.Opacity += FadeRate;
  152. if (Opacity > 1f)
  153. {
  154. Opacity = 1f;
  155. _expandCollapseButton.Opacity = 1f;
  156. _fadedIn = true;
  157. _fadedOut = false;
  158. }
  159. _nextFadeTime = CMain.Time + FadeDelay;
  160. }
  161. else
  162. {
  163. if (!_fadedOut && CMain.Time <= _nextFadeTime)
  164. return;
  165. Opacity -= FadeRate;
  166. _expandCollapseButton.Opacity -= FadeRate;
  167. if (Opacity < 0f)
  168. {
  169. Opacity = 0f;
  170. _expandCollapseButton.Opacity = 0f;
  171. _fadedOut = true;
  172. _fadedIn = false;
  173. }
  174. _nextFadeTime = CMain.Time + FadeDelay;
  175. }
  176. }
  177. private void UpdateWindow()
  178. {
  179. _buffCount = _buffList.Count;
  180. var baseImage = 20;
  181. var heightOffset = Location.Y;
  182. //foreach (var dialog in GameScene.Scene.BuffDialogs)
  183. //{
  184. // if (dialog.Category == Category) break;
  185. // if (dialog.Buffs.Count > 0)
  186. // {
  187. // heightOffset += dialog.Size.Height;
  188. // }
  189. //}
  190. if (_buffCount > 0 && ExpandedBuffWindow)
  191. {
  192. var oldWidth = Size.Width;
  193. if (_buffCount <= 10)
  194. Index = baseImage + _buffCount - 1;
  195. else if (_buffCount > 10)
  196. Index = baseImage + 10;
  197. else if (_buffCount > 20)
  198. Index = baseImage + 11;
  199. else if (_buffCount > 30)
  200. Index = baseImage + 12;
  201. else if (_buffCount > 40)
  202. Index = baseImage + 13;
  203. var newX = Location.X - Size.Width + oldWidth;
  204. var newY = heightOffset;
  205. Location = new Point(newX, newY);
  206. _buffCountLabel.Visible = false;
  207. _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
  208. Size = new Size((_buffCount > 10 ? 10 : _buffCount) * 23, 24 + (_buffCount / 10) * 24);
  209. }
  210. else if (_buffCount > 0 && !ExpandedBuffWindow)
  211. {
  212. var oldWidth = Size.Width;
  213. Index = 20;
  214. var newX = Location.X - Size.Width + oldWidth;
  215. var newY = heightOffset;
  216. Location = new Point(newX, newY);
  217. _buffCountLabel.Visible = true;
  218. _buffCountLabel.Text = $"{_buffCount}";
  219. _buffCountLabel.Location = new Point(Size.Width / 2 - _buffCountLabel.Size.Width / 2, Size.Height / 2 - 10);
  220. _buffCountLabel.BringToFront();
  221. _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
  222. Size = new Size(44, 34);
  223. }
  224. }
  225. public string BuffString(ClientBuff buff)
  226. {
  227. string text = RegexFunctions.SeperateCamelCase(buff.Type.ToLocalizedString()) + "\n";
  228. bool overridestats = false;
  229. switch (buff.Type)
  230. {
  231. case BuffType.GameMaster:
  232. GMOptions options = (GMOptions)buff.Values[0];
  233. if (options.HasFlag(GMOptions.GameMaster)) text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Invisible);
  234. if (options.HasFlag(GMOptions.Superman)) text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Superman);
  235. if (options.HasFlag(GMOptions.Observer)) text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Observer);
  236. break;
  237. case BuffType.MentalState:
  238. switch (buff.Values[0])
  239. {
  240. case 0:
  241. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AgressiveFullDamageCantShootOverWalls);
  242. break;
  243. case 1:
  244. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TrickShotMinimalDamage);
  245. break;
  246. case 2:
  247. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GroupModeMediumDamageDontStealAgro);
  248. break;
  249. }
  250. break;
  251. case BuffType.Hiding:
  252. case BuffType.ClearRing:
  253. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InvisibleToManyMonsters);
  254. break;
  255. case BuffType.MoonLight:
  256. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InvisibleToPlayersAndMonstersAtDistance);
  257. break;
  258. case BuffType.EnergyShield:
  259. overridestats = true;
  260. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ChanceGainHpWhenAttacked), buff.Stats[Stat.EnergyShieldPercent], buff.Stats[Stat.EnergyShieldHPGain]);
  261. break;
  262. case BuffType.DarkBody:
  263. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InvisibleToManyMonstersAbleToMove);
  264. break;
  265. case BuffType.VampireShot:
  266. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GivesVampiricAbility);
  267. break;
  268. case BuffType.PoisonShot:
  269. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GivesPoisonAbility);
  270. break;
  271. case BuffType.Concentration:
  272. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.IncreaseElementExtractionChance);
  273. break;
  274. case BuffType.MagicBooster:
  275. overridestats = true;
  276. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.IncreaseMcAndConsumption), buff.Stats[Stat.MinMC], buff.Stats[Stat.MaxMC], buff.Stats[Stat.ManaPenaltyPercent]);
  277. break;
  278. case BuffType.Transform:
  279. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DisguisesYourAppearance);
  280. break;
  281. case BuffType.Mentee:
  282. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LearnSkillPointsTwiceAsQuick);
  283. break;
  284. case BuffType.Guild:
  285. text += GameScene.Scene.GuildDialog.ActiveStats;
  286. break;
  287. case BuffType.Blindness:
  288. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ReducesVisibility);
  289. break;
  290. case BuffType.Newbie:
  291. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildMemberBoost);
  292. break;
  293. }
  294. if (!overridestats)
  295. {
  296. foreach (var val in buff.Stats.Values)
  297. {
  298. var c = val.Value < 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Decreases) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Increases);
  299. var strKey = val.Key.ToLocalizedString();
  300. var sign = "";
  301. if (val.Key.ToString().Contains("Percent"))
  302. sign = "%";
  303. else if (val.Key.ToString().Contains("Multiplier"))
  304. sign = "x";
  305. var txt = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.BuffEffect), c, strKey, val.Value, sign);
  306. text += txt;
  307. }
  308. }
  309. if (buff.Paused)
  310. {
  311. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExpirePaused);
  312. }
  313. else if (buff.Infinite)
  314. {
  315. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExpireNever);
  316. }
  317. else
  318. {
  319. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.Expire), Functions.PrintTimeSpanFromSeconds(Math.Round((buff.ExpireTime - CMain.Time) / 1000D)));
  320. }
  321. if (!string.IsNullOrEmpty(buff.Caster)) text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CasterName), buff.Caster);
  322. return text;
  323. }
  324. private string CombinedBuffText()
  325. {
  326. string text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ActiveBuffs);
  327. var stats = new Stats();
  328. for (var i = 0; i < _buffList.Count; i++)
  329. {
  330. var buff = Buffs[i];
  331. stats.Add(buff.Stats);
  332. }
  333. foreach (var val in stats.Values)
  334. {
  335. var c = val.Value < 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Decreases) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Increases);
  336. var strKey = val.Key.ToLocalizedString();
  337. var sign = "";
  338. if (val.Key.ToString().Contains("Percent"))
  339. sign = "%";
  340. else if (val.Key.ToString().Contains("Multiplier"))
  341. sign = "x";
  342. var txt = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.BuffEffect), c, strKey, val.Value, sign);;
  343. text += txt;
  344. }
  345. return text;
  346. }
  347. private int BuffImage(BuffType type)
  348. {
  349. switch (type)
  350. {
  351. //Skills
  352. case BuffType.Fury:
  353. return 76;
  354. case BuffType.Rage:
  355. return 49;
  356. case BuffType.ImmortalSkin:
  357. return 80;
  358. case BuffType.CounterAttack:
  359. return 7;
  360. case BuffType.MagicBooster:
  361. return 73;
  362. case BuffType.MagicShield:
  363. return 30;
  364. case BuffType.Hiding:
  365. case BuffType.ClearRing:
  366. return 17;
  367. case BuffType.Haste:
  368. return 60;
  369. case BuffType.SoulShield:
  370. return 13;
  371. case BuffType.BlessedArmour:
  372. return 14;
  373. case BuffType.ProtectionField:
  374. return 50;
  375. case BuffType.UltimateEnhancer:
  376. return 35;
  377. case BuffType.Curse:
  378. return 45;
  379. case BuffType.EnergyShield:
  380. return 57;
  381. case BuffType.SwiftFeet:
  382. return 67;
  383. case BuffType.LightBody:
  384. return 68;
  385. case BuffType.MoonLight:
  386. return 65;
  387. case BuffType.DarkBody:
  388. return 70;
  389. case BuffType.Concentration:
  390. return 96;
  391. case BuffType.VampireShot:
  392. return 100;
  393. case BuffType.PoisonShot:
  394. return 102;
  395. case BuffType.MentalState:
  396. return 199;
  397. //Monster
  398. case BuffType.RhinoPriestDebuff:
  399. return 217;
  400. case BuffType.Blindness:
  401. return 226;
  402. //Special
  403. case BuffType.GameMaster:
  404. return 173;
  405. case BuffType.General:
  406. return 182;
  407. case BuffType.Exp:
  408. return 260;
  409. case BuffType.Drop:
  410. return 162;
  411. case BuffType.Gold:
  412. return 168;
  413. case BuffType.Knapsack:
  414. case BuffType.BagWeight:
  415. return 235;
  416. case BuffType.Transform:
  417. return 241;
  418. case BuffType.Mentor:
  419. case BuffType.Mentee:
  420. return 248;
  421. case BuffType.Lover:
  422. return 201;
  423. case BuffType.Guild:
  424. return 203;
  425. case BuffType.Rested:
  426. return 240;
  427. case BuffType.TemporalFlux:
  428. return 261;
  429. case BuffType.Skill:
  430. return 200;
  431. case BuffType.Newbie:
  432. return 182;
  433. //Stats
  434. case BuffType.Impact:
  435. return 249;
  436. case BuffType.Magic:
  437. return 165;
  438. case BuffType.Taoist:
  439. return 250;
  440. case BuffType.Storm:
  441. return 170;
  442. case BuffType.HealthAid:
  443. return 161;
  444. case BuffType.ManaAid:
  445. return 169;
  446. case BuffType.Defence:
  447. return 166;
  448. case BuffType.MagicDefence:
  449. return 158;
  450. case BuffType.WonderDrug:
  451. return 252;
  452. default:
  453. return 0;
  454. }
  455. }
  456. }
  457. //UNFINISHED
  458. public class ClientPoisonBuff
  459. {
  460. public PoisonType Type;
  461. public string Caster;
  462. public int Value;
  463. public int TickSpeed;
  464. public long ExpireTime;
  465. }
  466. public sealed class PoisonBuffDialog : MirImageControl
  467. {
  468. public List<ClientPoisonBuff> Buffs = new List<ClientPoisonBuff>();
  469. private MirButton _expandCollapseButton;
  470. private MirLabel _buffCountLabel;
  471. private List<MirImageControl> _buffList = new List<MirImageControl>();
  472. private bool _fadedOut, _fadedIn;
  473. private int _buffCount;
  474. private long _nextFadeTime;
  475. private const long FadeDelay = 55;
  476. private const float FadeRate = 0.2f;
  477. public PoisonBuffDialog()
  478. {
  479. Index = 40;
  480. Library = Libraries.Prguse2;
  481. Movable = false;
  482. Size = new Size(44, 34);
  483. Location = new Point(Settings.ScreenWidth - 170, 0);
  484. Sort = true;
  485. Opacity = 0f;
  486. _fadedOut = true;
  487. _expandCollapseButton = new MirButton
  488. {
  489. Index = 7,
  490. HoverIndex = 8,
  491. Size = new Size(16, 15),
  492. Library = Libraries.Prguse2,
  493. Parent = this,
  494. PressedIndex = 9,
  495. Sound = SoundList.ButtonA,
  496. Opacity = 0f
  497. };
  498. _expandCollapseButton.Click += (o, e) =>
  499. {
  500. if (_buffCount == 1)
  501. {
  502. Settings.ExpandedBuffWindow = true;
  503. }
  504. else
  505. {
  506. Settings.ExpandedBuffWindow = !Settings.ExpandedBuffWindow;
  507. }
  508. UpdateWindow();
  509. };
  510. _buffCountLabel = new MirLabel
  511. {
  512. Parent = this,
  513. AutoSize = true,
  514. DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
  515. Font = new Font(Settings.FontName, 10F, FontStyle.Bold),
  516. NotControl = true,
  517. Sort = true,
  518. Visible = false,
  519. ForeColour = Color.Yellow,
  520. OutLineColour = Color.Black,
  521. };
  522. }
  523. public void CreateBuff(ClientPoisonBuff buff)
  524. {
  525. var buffImage = BuffImage(buff.Type);
  526. var buffLibrary = Libraries.BuffIcon;
  527. if (buffImage >= 20000)
  528. {
  529. buffImage -= 20000;
  530. buffLibrary = Libraries.MagIcon;
  531. }
  532. if (buffImage >= 10000)
  533. {
  534. buffImage -= 10000;
  535. buffLibrary = Libraries.Prguse2;
  536. }
  537. var image = new MirImageControl
  538. {
  539. Library = buffLibrary,
  540. Parent = this,
  541. Visible = true,
  542. Sort = false,
  543. Index = buffImage
  544. };
  545. _buffList.Insert(0, image);
  546. UpdateWindow();
  547. }
  548. public string BuffString(ClientPoisonBuff buff)
  549. {
  550. string text = RegexFunctions.SeperateCamelCase(buff.Type.ToLocalizedString()) + "\n";
  551. switch (buff.Type)
  552. {
  553. case PoisonType.Green:
  554. {
  555. var tick = buff.TickSpeed / 1000;
  556. var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
  557. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ReceiveDamageEveryTick), buff.Value, tick, tickName);
  558. }
  559. break;
  560. case PoisonType.Red:
  561. {
  562. var tick = buff.TickSpeed / 1000;
  563. var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
  564. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ReducesArmourRatePerTick), tick, tickName);
  565. }
  566. break;
  567. case PoisonType.Slow:
  568. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ReducesMovementSpeed);
  569. break;
  570. case PoisonType.Frozen:
  571. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsCastingMovingAttacking);
  572. break;
  573. case PoisonType.Stun:
  574. {
  575. var tick = buff.TickSpeed / 1000;
  576. var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
  577. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DamageReceivedIncrease), tick, tickName);
  578. }
  579. break;
  580. case PoisonType.Paralysis:
  581. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsMoveAndAttack);
  582. break;
  583. case PoisonType.DelayedExplosion:
  584. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TickingTimeBomb);
  585. break;
  586. case PoisonType.Bleeding:
  587. {
  588. var tick = buff.TickSpeed / 1000;
  589. var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
  590. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RecieveDamageEveryTime), buff.Value, tick, tickName);
  591. }
  592. break;
  593. case PoisonType.LRParalysis:
  594. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsMoveAttackCancelOnHit);
  595. break;
  596. case PoisonType.Blindness:
  597. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CausesTemporaryBlindness);
  598. break;
  599. case PoisonType.Dazed:
  600. text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsAttacking);
  601. break;
  602. }
  603. text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.Expire), Functions.PrintTimeSpanFromSeconds(Math.Round((buff.ExpireTime - CMain.Time) / 1000D)));
  604. if (!string.IsNullOrEmpty(buff.Caster)) text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CasterName), buff.Caster);
  605. return text;
  606. }
  607. private int BuffImage(PoisonType type)
  608. {
  609. switch (type)
  610. {
  611. case PoisonType.Green:
  612. return 221;
  613. case PoisonType.Red:
  614. return 222;
  615. case PoisonType.Slow:
  616. return 225;
  617. case PoisonType.Frozen:
  618. return 223;
  619. case PoisonType.Stun:
  620. return 224;
  621. case PoisonType.Paralysis:
  622. return 233;
  623. case PoisonType.DelayedExplosion:
  624. return 229;
  625. case PoisonType.Bleeding:
  626. return 231;
  627. case PoisonType.LRParalysis:
  628. return 233;
  629. case PoisonType.Blindness:
  630. return 226;
  631. case PoisonType.Dazed:
  632. return 230;
  633. default:
  634. return 0;
  635. }
  636. }
  637. public void Process()
  638. {
  639. if (!Visible) return;
  640. if (_buffList.Count != _buffCount)
  641. {
  642. UpdateWindow();
  643. }
  644. for (var i = 0; i < _buffList.Count; i++)
  645. {
  646. var image = _buffList[i];
  647. var buff = Buffs[i];
  648. var buffImage = BuffImage(buff.Type);
  649. var buffLibrary = Libraries.BuffIcon;
  650. //ArcherSpells - VampireShot,PoisonShot
  651. if (buffImage >= 20000)
  652. {
  653. buffImage -= 20000;
  654. buffLibrary = Libraries.MagIcon;
  655. }
  656. if (buffImage >= 10000)
  657. {
  658. buffImage -= 10000;
  659. buffLibrary = Libraries.Prguse2;
  660. }
  661. var location = new Point(Size.Width - 10 - 23 - (i * 23) + ((10 * 23) * (i / 10)), 6 + ((i / 10) * 24));
  662. image.Location = new Point(location.X, location.Y);
  663. image.Hint = Settings.ExpandedBuffWindow ? BuffString(buff) : CombinedBuffText();
  664. image.Index = buffImage;
  665. image.Library = buffLibrary;
  666. if (Settings.ExpandedBuffWindow || !Settings.ExpandedBuffWindow && i == 0)
  667. {
  668. image.Visible = true;
  669. image.Opacity = 1f;
  670. }
  671. else
  672. {
  673. image.Visible = false;
  674. image.Opacity = 0.6f;
  675. }
  676. if (!(Math.Round((buff.ExpireTime - CMain.Time) / 1000D) <= 5))
  677. continue;
  678. var time = (buff.ExpireTime - CMain.Time) / 100D;
  679. if (Math.Round(time) % 10 < 5)
  680. image.Index = -1;
  681. }
  682. if (IsMouseOver(CMain.MPoint))
  683. {
  684. if (_buffCount == 0 || (!_fadedIn && CMain.Time <= _nextFadeTime))
  685. return;
  686. Opacity += FadeRate;
  687. _expandCollapseButton.Opacity += FadeRate;
  688. if (Opacity > 1f)
  689. {
  690. Opacity = 1f;
  691. _expandCollapseButton.Opacity = 1f;
  692. _fadedIn = true;
  693. _fadedOut = false;
  694. }
  695. _nextFadeTime = CMain.Time + FadeDelay;
  696. }
  697. else
  698. {
  699. if (!_fadedOut && CMain.Time <= _nextFadeTime)
  700. return;
  701. Opacity -= FadeRate;
  702. _expandCollapseButton.Opacity -= FadeRate;
  703. if (Opacity < 0f)
  704. {
  705. Opacity = 0f;
  706. _expandCollapseButton.Opacity = 0f;
  707. _fadedOut = true;
  708. _fadedIn = false;
  709. }
  710. _nextFadeTime = CMain.Time + FadeDelay;
  711. }
  712. }
  713. private void UpdateWindow()
  714. {
  715. _buffCount = _buffList.Count;
  716. var baseImage = 20;
  717. var heightOffset = 36;
  718. if (_buffCount > 0 && Settings.ExpandedBuffWindow)
  719. {
  720. var oldWidth = Size.Width;
  721. if (_buffCount <= 10)
  722. Index = baseImage + _buffCount - 1;
  723. else if (_buffCount > 10)
  724. Index = baseImage + 10;
  725. else if (_buffCount > 20)
  726. Index = baseImage + 11;
  727. else if (_buffCount > 30)
  728. Index = baseImage + 12;
  729. else if (_buffCount > 40)
  730. Index = baseImage + 13;
  731. var newX = Location.X - Size.Width + oldWidth;
  732. var newY = heightOffset;
  733. Location = new Point(newX, newY);
  734. _buffCountLabel.Visible = false;
  735. _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
  736. Size = new Size((_buffCount > 10 ? 10 : _buffCount) * 23, 24 + (_buffCount / 10) * 24);
  737. }
  738. else if (_buffCount > 0 && !Settings.ExpandedBuffWindow)
  739. {
  740. var oldWidth = Size.Width;
  741. Index = 20;
  742. var newX = Location.X - Size.Width + oldWidth;
  743. var newY = heightOffset;
  744. Location = new Point(newX, newY);
  745. _buffCountLabel.Visible = true;
  746. _buffCountLabel.Text = $"{_buffCount}";
  747. _buffCountLabel.Location = new Point(Size.Width / 2 - _buffCountLabel.Size.Width / 2, Size.Height / 2 - 10);
  748. _buffCountLabel.BringToFront();
  749. _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
  750. Size = new Size(44, 34);
  751. }
  752. }
  753. private string CombinedBuffText()
  754. {
  755. string text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ActivePoisons);
  756. return text;
  757. }
  758. }
  759. }