forked from andmer/simpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimcraftApis.cs
More file actions
499 lines (396 loc) · 13.6 KB
/
SimcraftApis.cs
File metadata and controls
499 lines (396 loc) · 13.6 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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Styx;
using Styx.WoWInternals.WoWObjects;
namespace Simcraft
{
public partial class SimcraftImpl
{
public MagicValueType anticipation_charges
{
get { return new MagicValueType(buff.anticipation.stack); }
}
public MagicValueType cooldown_react
{
get
{
return cooldown[_conditionSpell].up;
}
}
public MagicValueType primary_target
{
get { return new MagicValueType(Target1() == conditionUnit); }
}
public MagicValueType persistent_multiplier
{
get { return new MagicValueType(0); }
}
public MagicValueType remains
{
get { return debuff[_conditionSpell].remains; }
}
public MagicValueType duration
{
get { return spell[_conditionSpell].duration; }
}
public MagicValueType level
{
get { return new MagicValueType(Me.Level); }
}
public MagicValueType melee_range
{
get { return new MagicValueType(Me.IsWithinMeleeRangeOf(conditionUnit)); }
}
public MagicValueType facing
{
get { return target.facing; }
}
public MagicValueType execute_time
{
get
{
var ex = spell[_conditionSpell].execute_time;
return ex;
}
}
public MagicValueType enemies
{
get { return new MagicValueType(1000); }
}
public double cast_time
{
get { return spell[_conditionSpell].cast_time; }
}
public MagicValueType gcd
{
get { return MainCache["gcd"].GetValue(); }
}
public bool in_flight_to_target = false;
public bool in_flight = false;
public MagicValueType charges_fractional
{
get
{
var sp = spell[_conditionSpell].charges_fractional;
return sp;
}
}
public MagicValueType travel_time
{
get
{
var cDist = conditionUnit.Distance - conditionUnit.CombatReach;
var dDist = (Decimal) cDist;
dDist = Math.Max(dDist, 1);
return new MagicValueType(dDist / (Decimal)_conditionSpell.speed);
}
}
public MagicValueType spell_haste
{
get { return stat.spell_haste; }
}
public MagicValueType mastery_value
{
get { return stat.mastery_value; }
}
public MagicValueType shard_react
{
get
{
int ss = soul_shard;
return new MagicValueType(SoulShardTimer.IsRunning && SoulShardTimer.ElapsedMilliseconds < 2000);
}
}
public MagicValueType burning_ember
{
get
{
var be = LuaGet<int>("return UnitPower(\"player\", SPELL_POWER_BURNING_EMBERS, true)", 0);
return new MagicValueType((double) be/10);
}
}
public MagicValueType tick_time
{
get { return debuff[_conditionSpell].tick_time; }
}
public IEnumerable<WoWUnit> actives
{
get
{
var ranged = (_class == WoWClass.Mage || _class == WoWClass.Hunter || _class == WoWClass.Priest ||
_class == WoWClass.Warlock ||
(_class == WoWClass.Druid && StyxWoW.Me.Specialization == WoWSpec.DruidBalance));
//var ranged = _conditionSpell.max_range > 10;
if (ranged) return UnfriendlyUnitsNearTarget(8f);
return UnfriendlyUnitsNearMe(5f);
}
}
public String eclipse_direction
{
get
{
return LuaGet<String>("direction = GetEclipseDirection(); return direction;", 0);
}
}
public MagicValueType eclipse_change
{
get
{
double eclipse_amount = eclipse_energy.current;
double time_to_next_lunar, time_to_next_solar, eclipse_ch;
double M_PI = Math.PI;
double phi_lunar = Math.Asin(100.0/105.0);
double phi_solar = phi_lunar + M_PI;
double omega = 2*M_PI/40000;
//double balance_time = (20000 * (2 * M_PI - Math.Asin(eclipse_amount / 105))) / M_PI;
var dir = eclipse_direction;
double phi;
if (dir.Equals("moon"))
phi = 2*M_PI - Math.Asin(eclipse_amount/105) + M_PI;
else
phi = 2*M_PI + Math.Asin(eclipse_amount/105);
if (talent.euphoria.enabled) omega *= 2;
phi = phi%(2*M_PI);
if (eclipse_amount >= 100)
time_to_next_lunar = 0;
else
time_to_next_lunar = ((phi_lunar - phi + 2*M_PI)%(2*M_PI))/omega/1000;
if (eclipse_amount <= -100)
time_to_next_solar = 0;
else
time_to_next_solar = ((phi_solar - phi + 2*M_PI)%(2*M_PI))/omega/1000;
eclipse_ch = (M_PI - (phi%M_PI))/omega/1000;
//Write("energy {3} change: {0} next_solar: {1} next_lunar: {2} phi: {4}",eclipse_ch,time_to_next_solar,time_to_next_lunar,eclipse_energy.current,phi);
return new MagicValueType(eclipse_ch);
}
}
public MagicValueType lunar_max
{
get
{
double eclipse_amount = eclipse_energy.current;
double time_to_next_lunar, time_to_next_solar, eclipse_ch;
double M_PI = Math.PI;
double phi_lunar = Math.Asin(100.0/105.0);
double phi_solar = phi_lunar + M_PI;
double omega = 2*M_PI/40000;
//double balance_time = (20000 * (2 * M_PI - Math.Asin(eclipse_amount / 105))) / M_PI;
var dir = eclipse_direction;
double phi;
if (dir.Equals("moon"))
phi = 2*M_PI - Math.Asin(eclipse_amount/105) + M_PI;
else
phi = 2*M_PI + Math.Asin(eclipse_amount/105);
if (talent.euphoria.enabled) omega *= 2;
phi = phi%(2*M_PI);
if (eclipse_amount >= 100)
time_to_next_lunar = 0;
else
time_to_next_lunar = ((phi_lunar - phi + 2*M_PI)%(2*M_PI))/omega/1000;
if (eclipse_amount <= -100)
time_to_next_solar = 0;
else
time_to_next_solar = ((phi_solar - phi + 2*M_PI)%(2*M_PI))/omega/1000;
eclipse_ch = (M_PI - (phi%M_PI))/omega/1000;
return new MagicValueType(time_to_next_lunar);
}
}
public MagicValueType solar_max
{
get
{
double eclipse_amount = eclipse_energy.current;
double time_to_next_lunar, time_to_next_solar, eclipse_ch;
double M_PI = Math.PI;
double phi_lunar = Math.Asin(100.0/105.0);
double phi_solar = phi_lunar + M_PI;
double omega = 2*M_PI/40000;
//double balance_time = (20000 * (2 * M_PI - Math.Asin(eclipse_amount / 105))) / M_PI;
var dir = eclipse_direction;
double phi;
if (dir.Equals("moon"))
phi = 2*M_PI - Math.Asin(eclipse_amount/105) + M_PI;
else
phi = 2*M_PI + Math.Asin(eclipse_amount/105);
if (talent.euphoria.enabled) omega *= 2;
phi = phi%(2*M_PI);
if (eclipse_amount >= 100)
time_to_next_lunar = 0;
else
time_to_next_lunar = ((phi_lunar - phi + 2*M_PI)%(2*M_PI))/omega/1000;
if (eclipse_amount <= -100)
time_to_next_solar = 0;
else
time_to_next_solar = ((phi_solar - phi + 2*M_PI)%(2*M_PI))/omega/1000;
eclipse_ch = (M_PI - (phi%M_PI))/omega/1000;
return new MagicValueType(time_to_next_solar);
}
}
public MagicValueType time_to_die
{
get { return target.time_to_die; }
}
public MagicValueType position_front
{
get { return new MagicValueType(!Me.IsBehind(conditionUnit)); }
}
public MagicValueType damage_enabled
{
get { return new MagicValueType(!_damageEnabled); }
}
public MagicValueType aoe_enabled
{
get { return new MagicValueType(!_aoeEnabled); }
}
public MagicValueType cooldowns_enabled
{
get { return new MagicValueType(!_cdsEnabled); }
}
public MagicValueType ticking
{
get { return debuff[_conditionSpell].ticking; }
}
public MagicValueType channel_time
{
get { return spell[_conditionSpell].channel_time; }
}
public MagicValueType recharge_time
{
get { return spell[_conditionSpell].recharge_time; }
}
public MagicValueType ptr
{
get { return new MagicValueType(false); }
}
public MagicValueType miss_react
{
get { return new MagicValueType(true); }
}
public MagicValueType incanters_flow_dir
{
get { return new MagicValueType(buff.incanters_flow.dir); }
}
public MagicValueType damage
{
get
{
return health.deficit;
}
}
public WoWUnit prismatic_crystal
{
get
{
try
{
var m = Me.Minions.FirstOrDefault(ret => ret.Name.Equals("Prismatic Crystal"));
if (m == default(WoWUnit)) return Me;
return m;
}
catch (Exception e)
{
Write(e.ToString());
return Me;
}
}
}
public MagicValueType desired_targets
{
get { return new MagicValueType(1); }
}
public MagicValueType mind_harvest
{
get { return new MagicValueType(conditionUnit.MindHarvest() ? 1 : 0); }
}
public MagicValueType moving
{
get { return new MagicValueType(Me.IsMoving); }
}
public MagicValueType shadowy_apparitions_in_flight
{
get
{
var naps = apparitions.Where(ret => ret.ElapsedMilliseconds >= apparition_flight_time);
apparitions.RemoveAll(ret => naps.Contains(ret));
return new MagicValueType(apparitions.Count());
}
}
public WoWUnit current_target
{
get { return conditionUnit; }
}
public MagicValueType distance
{
get { return new MagicValueType(conditionUnit.Distance); }
}
public MagicValueType natural_shadow_word_death_range
{
get { return target.health.pct < 20; }
}
public MagicValueType active_enemies
{
get { return new MagicValueType(actives.Count()); }
}
public MagicValueType demonic_fury
{
get
{
var be = LuaGet<int>("return UnitPower(\"player\", SPELL_POWER_DEMONIC_FURY)", 0);
return new MagicValueType(be);
}
}
public MagicValueType shadow_orb
{
get
{
var be = LuaGet<int>("ret,_,_ = UnitPower(\"player\", SPELL_POWER_SHADOW_ORBS); return ret;", 0);
return new MagicValueType(be);
}
}
public MagicValueType soul_shard
{
get
{
int ss = (int) Me.CurrentSoulShards;
if (ss > o_soul_shard)
{
SoulShardTimer.Restart();
}
o_soul_shard = ss;
return new MagicValueType(ss);
}
}
public MagicValueType charges
{
get { return spell[_conditionSpell].charges; }
}
public int ticks_remain
{
get { return debuff[_conditionSpell].ticks_remain; }
}
public bool line_cd(double seconds)
{
if (!line_cds.ContainsKey(conditionName))
line_cds[conditionName] = new Stopwatch();
var b = !line_cds[conditionName].IsRunning || line_cds[conditionName].ElapsedMilliseconds/1000 > seconds;
//line_cds[conditionName].Restart();
return b;
}
public MagicValueType cast_regen
{
get
{
var cTime = spell[_conditionSpell].cast_time;
return main_resource.cast_regen(cTime);
}
}
public MagicValueType sync(String spell)
{
return new MagicValueType(true);
}
}
}