forked from andmer/simpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimcraftImpl.cs
More file actions
848 lines (722 loc) · 28.1 KB
/
SimcraftImpl.cs
File metadata and controls
848 lines (722 loc) · 28.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
#region Honorbuddy
#endregion
#region System
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Media;
using CommonBehaviors.Actions;
using Simcraft.APL;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.TreeSharp;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Action = Styx.TreeSharp.Action;
#endregion
namespace Simcraft
{
public partial class SimcraftImpl
{
public delegate String RetrieveSpellDelegate();
private const int apparition_flight_time = 5000;
public static String logf;
private static readonly Mutex mut = new Mutex();
private readonly List<Stopwatch> apparitions = new List<Stopwatch>();
private readonly Dictionary<char, Stopwatch> line_cds = new Dictionary<char, Stopwatch>();
private readonly Stopwatch SoulShardTimer = new Stopwatch();
//<summary>_conditonSpell is the true name of the spell, non tokenized</summary>
private spell_data_t _conditionSpell;
private Mutex a = new Mutex();
public char conditionName = 'A';
public WoWUnit CycleTarget;
public char NameCount = Convert.ToChar(65);
private int o_soul_shard;
public WoWItem Potion;
public bool pyro_chain;
private Regex shorthand = new Regex("[^a-z_]");
public WoWUnit clickUnit { get; set; }
public static int combatIterationCount = 0;
public static MagicValueType SpellIsTargeting
{
get
{
return new MagicValueType(LuaGet<Boolean>(
"return SpellIsTargeting()", 0));
}
}
public ResourceProxy main_resource
{
get
{
switch (_class)
{
case WoWClass.Hunter:
return focus;
case WoWClass.Rogue:
return energy;
case WoWClass.Warrior:
return rage;
case WoWClass.Monk:
if (_spec == WoWSpec.MonkMistweaver) return mana;
return energy;
case WoWClass.Druid:
if (_spec == WoWSpec.DruidFeral) return energy;
if (_spec == WoWSpec.DruidGuardian) return rage;
return mana;
case WoWClass.DeathKnight:
return runic_power;
default:
return mana;
}
}
}
public MagicValueType PotionCooldown
{
get { return new MagicValueType(Potion.Cooldown); }
}
public void toggle_hkvar(String name)
{
if (!hotkeyVariables.ContainsKey(name)) hotkeyVariables[name] = false;
hotkeyVariables[name] = !hotkeyVariables[name];
LuaDoString("_G[\"sc_" + name + "\"] = " + hotkeyVariables[name] + "; print('" + name + " => " +
hotkeyVariables[name] + "');");
//true then _G[\""+name+"\"] = nil; print('Cds enabled') else _G[\""+name+"\"] = true; print('Cds disabled') end");
//Write("Toggled " + name + " to :" + hotkeyVariables[name]);
}
public bool hkvar(String name)
{
if (!hotkeyVariables.ContainsKey(name)) hotkeyVariables[name] = false;
return hotkeyVariables[name];
}
public static spell_data_t DBGetSpell(String name)
{
name = Tokenize(name);
//Write("tttt: "+name);
if (dbc.Spells.RelationContainsKey(name))
{
return dbc.Spells[dbc.Spells[name].Min()];
}
throw new MissingMemberException("DBGetSpell", name);
}
public static bool DBHasSpell(String name)
{
var n = Tokenize(name);
//if (n == "invoke_xuen") n = "invoke_xuen_the_white_tiger";
return dbc.Spells.RelationContainsKey(n);
}
public static spell_data_t DBGetClassSpell(String name)
{
name = Tokenize(name);
if (dbc.ClassSpells.ContainsKey(name))
{
return dbc.Spells[dbc.ClassSpells[name]];
}
if (dbc.Spells.RelationContainsKey(name))
{
return dbc.Spells[dbc.Spells[name].Min()];
}
throw new MissingMemberException("DBGetClassSpell", name);
}
public static bool DBHasClassSpell(String name)
{
var n = Tokenize(name);
return dbc.ClassSpells.ContainsKey(n);
}
public static spell_data_t DBGetTalentSpell(String name)
{
//var n = Tokenize(name);
return DBGetClassSpell(name);
}
public Composite CallActionList(String name, CanRunDecoratorDelegate del, String Reason)
{
return new Decorator(del ?? (ret => true), actions[name]);
}
public Composite CallActionList(String name, CanRunDecoratorDelegate del = null)
{
return new Decorator(del ?? (ret => true), actions[name]);
}
public Composite CallActionList(String name, String Reason)
{
CanRunDecoratorDelegate del = null;
return new Decorator(del ?? (ret => true), actions[name]);
}
public void start_line_cd()
{
if (!line_cds.ContainsKey(conditionName))
line_cds[conditionName] = new Stopwatch();
line_cds[conditionName].Restart();
}
public Composite StartPyroChain(CanRunDecoratorDelegate del = null, String reason = "")
{
var d = del ?? (ret => true);
return new Decorator(_ret =>
{
var r = d(_ret) && moving;
//LogDebug("start_pyro_chain" + " " + reason + " => " + r);
return r;
}, new Action(delegate
{
pyro_chain = true;
return RunStatus.Failure;
}));
}
public Composite StopPyroChain(CanRunDecoratorDelegate del = null, String reason = "")
{
var d = del ?? (ret => true);
return new Decorator(_ret =>
{
var r = d(_ret) && moving;
//LogDebug("stop_pyro_chain" + " " + reason + " => " + r);
return r;
}, new Action(delegate
{
pyro_chain = false;
return RunStatus.Failure;
}));
}
public Composite Wait(CanRunDecoratorDelegate del = null, String reason = "")
{
var d = del ?? (ret => true);
return new Decorator(_ret =>
{
var r = d(_ret) && moving;
//LogDebug("wait" + " " + reason + " => " + r);
return r;
}, new ActionAlwaysSucceed());
}
public static bool CanCast(String name, WoWUnit target, bool RangeCheck = false)
{
bool a;
a = !RangeCheck ? SpellManager.CanCast(name, target) : SpellManager.CanCast(name, target, true);
LogDebug("CanCast: "+name+" => "+a);
return a;
}
public Composite CycleTargets(String _spell, UnitCriteriaDelegate criteria, String Reason = "")
{
NameCount++;
//Write("looking for spell: " + _spell);
var actualSpell = LearnedSpellFromToken(_spell);
if (actualSpell == null)
{
Write("Couldnt find " + _spell + " in our spellbook or in the Simcraft table");
return new ActionAlwaysFail();
}
return new NamedComposite("" + NameCount, _spell,
new Action(delegate
{
CycleTarget = null;
conditionName = NameCount;
_conditionSpell = actualSpell;
foreach (var w in actives)
{
conditionUnit = w;
if (criteria(w) && (CanCast(actualSpell.name, w, true)))
{
CycleTarget = w;
return RunStatus.Failure;
}
}
return RunStatus.Failure;
}),
new Decorator(ret => CycleTarget != null,
new Action(delegate
{
if (CastSpell(actualSpell, CycleTarget, 3, Reason))
{
//LogDebug(_spell + " " + Reason + " => SUCCESS!");
return RunStatus.Success;
}
return RunStatus.Failure;
})));
}
public Composite Cast(String _spell, CanRunDecoratorDelegate del, GetUnitDelegate getTarget, String Reason)
{
NameCount++;
WoWUnit _target;
var actualSpell = LearnedSpellFromToken(_spell);
if (actualSpell == null)
{
Write("Couldnt find " + _spell + " in our spellbook or in the Simcraft table");
return new ActionAlwaysFail();
}
return new NamedComposite("" + NameCount, actualSpell.name,
new Action(delegate
{
_target = getTarget();
//if (_target != null && _target != Target1()) Write("Checking diff target");
conditionName = NameCount;
_conditionSpell = actualSpell;
conditionUnit = _target;
if (conditionUnit == null || conditionUnit == default(WoWUnit)) conditionUnit = Me.CurrentTarget;
return RunStatus.Failure;
}),
new Decorator(_ret =>
{
if (actualSpell.gcd > 0 && SpellManager.GlobalCooldown)
{
LogDebug("GCD Skip: "+actualSpell.name);
return false;
}
var d = del ?? (ret => true);
try
{
LogDebug(actualSpell.name + " if=" + Reason);
var r = d(_ret);
LogDebug(actualSpell.name + " => " + r);
if (!r) return false;
return (CanCast(actualSpell.name, conditionUnit));
}
catch (Exception)
{
//Write(conditionName + " " + _spell + " " + e.ToString());
return false;
}
},
new Action(delegate
{
clickUnit = conditionUnit;
//if (SpellManager.CanCast(spell.name, conditionUnit))
if (CastSpell(actualSpell, conditionUnit, 3, Reason))
{
//if (actualSpell.name.Contains("Fire")) Write("fire:"+conditionUnit.Guid.GetFriendlyString());
//LogDebug(_spell + " => SUCCESS!");
start_line_cd();
return RunStatus.Success;
}
else
{
LogDebug(_spell + " => FAIL!");
}
return RunStatus.Failure;
})));
}
public Composite Cast(String _spell, CanRunDecoratorDelegate del, String r)
{
return Cast(_spell, del, () => Target1(), r);
}
public Composite Cast(String _spell, GetUnitDelegate getTarget, String Reason)
{
return Cast(_spell, null, getTarget, Reason);
}
public Composite Cast(String _spell, String r)
{
return Cast(_spell, null, () => Target1(), r);
}
public bool IsPlayerSpell(uint spell)
{
return LuaGet<bool>("return IsPlayerSpell(" + spell + ");", 0)
;
}
public spell_data_t LearnedSpellFromToken(String token)
{
if (SimcNames.spells.ContainsKey(token))
{
var s = SimcNames.spells[token];
if (s.Count == 1) return dbc.Spells[s[0].V2];
foreach (var kv in s)
{
if (kv.V1 == WoWSpec.None || kv.V1 == Me.Specialization)
{
return dbc.Spells[kv.V2];
}
}
}
return null;
//throw new Exception("Token: "+token+" missing from SpellDB");
}
public Composite Cast(String _spell)
{
return Cast(_spell, null, null, "");
}
private static string UppercaseFirst(string s)
{
// Check for empty string.
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}
// Return char and concat substring.
return char.ToUpper(s[0]) + s.Substring(1);
}
public MagicValueType GetTime()
{
return MainCache["WoWTime"].GetValue();
}
public Composite UseItem(int id, CanRunDecoratorDelegate del = null, String Reason = "")
{
return new Decorator(del ?? (ret => true),
new Action(delegate
{
var item = Me.Inventory.Equipped.PhysicalItems.FirstOrDefault(it => it.ItemInfo.Id == id);
if (item == default(WoWItem)) return RunStatus.Failure;
;
if (item.Cooldown <= 0) item.Use();
return RunStatus.Failure;
}));
}
public Composite UseItem(int id, String Reason = "")
{
CanRunDecoratorDelegate del = null;
return new Decorator(del ?? (ret => true),
new Action(delegate
{
var item = Me.Inventory.Equipped.PhysicalItems.FirstOrDefault(it => it.ItemInfo.Id == id);
if (item == default(WoWItem)) return RunStatus.Failure;
;
if (item.Cooldown <= 0) item.Use();
return RunStatus.Failure;
}));
}
public Composite UsePotion(String name, CanRunDecoratorDelegate del = null, String Reason = "")
{
var n = UppercaseFirst(name.Split('_')[0]) + " " + UppercaseFirst(name.Split('_')[1]);
var item = Me.BagItems.FirstOrDefault(ret => ret.Name.Contains(n) && ret.Name.Contains("Potion"));
if (item == default(WoWItem)) return new ActionAlwaysFail();
return new PrioritySelector(new Action(context =>
{
Potion = item;
return RunStatus.Failure;
}), new Decorator(del ?? (ret => true),
new Action(delegate
{
if (item.Cooldown <= 0) LuaDoString("UseItemByName(\"" + item.Name + "\")");
return RunStatus.Failure;
})));
}
public Composite UsePotion(String name, String Reason = "")
{
return UsePotion(name, null, Reason);
}
public Composite PoolResource(String spell, CanRunDecoratorDelegate pool = null,
CanRunDecoratorDelegate del = null, WoWUnit target = null, String Reason = "")
{
return null;
/*return new Decorator(del ?? (ret => true),
new PrioritySelector(
new Decorator(ret => pool(null),
new Action(delegate
{
LuaDoString("_G[\"kane_spd\"] = \"" + "Pooling: " + spell + "\";");
//Write(DateTime.Now+": Pooling Energy for " + spell + " " + Energy.current + "/" + energy);
return RunStatus.Success;
})),
Cast(spell, del, target, Reason)
)
);*/
}
public SpellState IsUseableSpell(String name)
{
var i =
LuaGet<int>(
"usable, nomana = IsUsableSpell(\"" + name +
"\"); if (not usable) then if (not nomana) then return 1; else return 2; end else return 0;end", 0);
if (i == 1) return SpellState.CanNotCast;
if (i == 2) return SpellState.NoMana;
return SpellState.CanCast;
}
public static void LogDebug(String stuff)
{
if (Superlog) Write( LogLevel.Diagnostic, stuff);
}
public static void Write(LogLevel l, String format, params object[] pars)
{
try
{
Logging.Write(l, "<" + DateTime.Now.ToShortTimeString() + ">:" + format, pars);
}
catch (Exception e)
{
Logging.WriteException(e);
}
}
public static void Write(String format, params object[] pars)
{
Write(LogLevel.Normal, format, pars);
}
public class NamedComposite : PrioritySelector
{
public static String Sequence = "";
public String Name;
public NamedComposite(String name, String spell, params Composite[] children)
: base(children)
{
Name = name;
//Write(name + " = " + spell);
}
public override RunStatus Tick(object context)
{
var x = base.Tick(context);
if (x == RunStatus.Success) Sequence += Name;
return x;
}
}
#region [Spell / Logging]
public bool SpecialRequirementsCheck(spell_data_t spell)
{
if (spell.name.Equals("Plague Leech"))
{
return debuff.frost_fever.up && debuff.blood_plague.up;
}
if (spell.name.Equals("Blood Tap"))
{
return buff.blood_charge.stack >= 5;
}
return true;
}
public bool CastSpell(spell_data_t spell, WoWUnit u, int LC, String Reason)
{
if (!ValidUnit(u) || u == null)
return false;
if (!SpecialRequirementsCheck(spell)) return false;
//if (SpellManager.CanCast(spell.name, u))
if (SpellManager.Cast(spell.name, u))
{
LogDebug(spell.name + " Success!");
return true;
}
else
{
LogDebug(spell.name + " failed due to Cast");
return false;
}
}
#endregion [Spell / Logging]
#region [Surrounding Unit SimcraftImpl]
private static int _unfriendlyCache;
private static List<WoWUnit> unfriendlyCache = new List<WoWUnit>();
public GetUnitDelegate Target2
{
get
{
return () =>
{
var t3 = actives.Where(ret => ret.Guid != Target1().Guid).ToArray();
if (t3.Length == 0) return null;
return t3[0];
};
}
}
public GetUnitDelegate Target3
{
get
{
return () =>
{
var t3 = actives.Where(ret => ret.Guid != Target1().Guid).ToArray();
if (t3.Length < 2) return null;
return t3[1];
};
}
}
public GetUnitDelegate TargetSelf
{
get { return () => Me; }
}
public GetUnitDelegate Targetself
{
get
{
return () => Me;
}
}
public static List<WoWUnit> UnfriendlyUnits
{
get
{
if (_unfriendlyCache == iterationCounter) return unfriendlyCache;
_unfriendlyCache = iterationCounter;
unfriendlyCache = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => !u.IsDead
&& u.CanSelect
&& u.Attackable
&& !u.IsFriendly
&& u.Distance <= 40
).ToList();
return unfriendlyCache;
}
}
public static IEnumerable<WoWUnit> UnfriendlyUnitsNearTarget(float dist)
{
return
UnfriendlyUnits.Where(
u =>
u.Location.Distance(StyxWoW.Me.CurrentTarget.Location) <
dist + StyxWoW.Me.CurrentTarget.CombatReach);
}
public static IEnumerable<WoWUnit> UnfriendlyUnitsInSpellRange(spell_data_t s)
{
return
UnfriendlyUnits.Where(
u =>
u.Location.Distance(StyxWoW.Me.CurrentTarget.Location) <
s.max_range + StyxWoW.Me.CurrentTarget.CombatReach);
}
public static IEnumerable<WoWUnit> UnfriendlyUnitsNearMe(float dist)
{
return
UnfriendlyUnits.Where(
ret => ret.Distance < dist + +StyxWoW.Me.CurrentTarget.CombatReach + Me.CombatReach);
}
public static bool ValidUnit(WoWUnit u)
{
if (u == null || !u.IsValid)
{
return false;
}
if (!u.CanSelect)
{
return false;
}
return true;
}
#endregion [TargetU Checks]
#region Spell CD SimcraftImpl
public static TimeSpan GetSpellCooldown(spell_data_t spell)
{
var s = GetSpell(spell);
if (s == default(WoWSpell)) return TimeSpan.MaxValue;
return s.CooldownTimeLeft;
}
public static WoWSpell GetSpell(spell_data_t spell)
{
SpellFindResults results;
if (SpellManager.FindSpell((int) spell.id, out results))
{
if (results.Override != null)
return results.Override;
return results.Original;
}
return default(WoWSpell);
}
public static WoWSpell GetSpellByName(String Name)
{
SpellFindResults results;
if (SpellManager.FindSpell(Name, out results))
{
if (results.Override != null)
return results.Override;
return results.Original;
}
return default(WoWSpell);
}
public static bool GetSpellOnCooldown(spell_data_t spell)
{
var s = GetSpell(spell);
if (s == default(WoWSpell)) return false;
return s.Cooldown;
}
private static int luaCount = 1;
public class CachePair
{
public int Iteration;
public object Value;
}
static Dictionary<string, CachePair> luaValues = new Dictionary<string, CachePair>();
public static T LuaGet<T>(String lua, uint a)
{
if (!luaValues.ContainsKey(lua))
luaValues[lua] = new CachePair {Iteration = -1};
var lv = luaValues[lua];
if (lv.Iteration < iterationCounter || lv.Iteration > iterationCounter){
lv.Value = Lua.GetReturnVal<T>(lua, a);
lv.Iteration = iterationCounter;
luaCount++;
if (luaCount%100 == 0)
Write("luaavg:" + luaCount/inst.time);
LogDebug(lua+" => "+lv.Value);
}
return (T)lv.Value;
}
public static void LuaDoString(String lua)
{
luaCount++;
if (luaCount%1000 == 0)
Write("luaavg:" + luaCount/inst.time);
Lua.DoString(lua);
}
#endregion Spell CD
#region BuffProxy SimcraftImpl
public static int GetAuraStacks(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
{
var wantedAura = GetAura(unit, aura, fromMyAura);
if (wantedAura == null || !wantedAura.IsActive) return 0;
return (int) wantedAura.StackCount;
}
public static List<String> Mismatches = new List<string>();
public static WoWAura GetAura(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
{
//if (aura == null) return null;
if (unit != null)
{
LogDebug("Looking for "+aura.name);
var mismatch = 0;
foreach (var a in unit.GetAllAuras())
{
LogDebug(a.Name+" "+a.IsActive+" "+a.TimeLeft.TotalSeconds+" "+Me.HasAura((int)a.SpellId));
if (a.SpellId == aura.id &&
(!fromMyAura || a.CreatorGuid == Me.Guid || (Me.Pet != null && a.CreatorGuid == Me.Pet.Guid)))
return a;
if (a.Name.Equals(aura.name) && a.IsActive)
{
mismatch = a.SpellId;
}
}
if (mismatch > 0 &&
!Mismatches.Contains("We couldnt find " + aura.name + " by Id but there is an Aura with its name: " +
aura.id + " / " + mismatch))
{
Mismatches.Add("We couldnt find " + aura.name + " by Id but there is an Aura with its name: " +
aura.id + " / " + mismatch);
Write("We couldnt find " + aura.name + " by Id but there is an Aura with its name: " +
aura.id + " / " + mismatch);
}
}
return null;
}
public static TimeSpan GetAuraTimeLeft(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
{
var wantedAura = GetAura(unit, aura, fromMyAura);
if (wantedAura == null || !wantedAura.IsActive) return TimeSpan.Zero;
return wantedAura.TimeLeft;
}
public static bool CancelAura(spell_data_t aura, bool fromMyAura = false)
{
var wantedAura = GetAura(Me, aura, fromMyAura);
if (wantedAura == null || !wantedAura.IsActive) return false;
wantedAura.TryCancelAura();
return true;
}
public static bool GetAuraUp(WoWUnit unit, spell_data_t aura, bool fromMyAura = false)
{
var wantedAura = GetAura(unit, aura, fromMyAura);
if (wantedAura == null || !wantedAura.IsActive) return false;
return true;
}
public static bool GetAuraUp(WoWUnit unit, spell_data_t[] auras, bool fromMyAura = false)
{
foreach (var aura in auras)
{
var wantedAura = GetAura(unit, aura, fromMyAura);
if (wantedAura != null && wantedAura.IsActive) return true;
}
return true;
}
public static TimeSpan GetAuraTimeLeft(WoWUnit unit, spell_data_t[] auras, bool fromMyAura = false)
{
foreach (var aura in auras)
{
var wantedAura = GetAura(unit, aura, fromMyAura);
if (wantedAura != null && wantedAura.IsActive) return wantedAura.TimeLeft;
}
return TimeSpan.Zero;
}
#endregion
}
}