My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
//
// Default CatModelSimulatorScript
//
// Yawning <yawninglol at gmail.com>
//
// Elements from:
// Alaron v2 (After Buffs Edition), 15 Oct 2010
// Leafkiller's testing/scripts
// Mihir's testing
// SimulationCraft (r4522, level 80 profile)
// Toskk's testing/scripts
//
// WARNING: This routine is invoked every time the Simulator thinks it's a good idea
// to query the user for input. While the temptation may be there to pop open a window
// and render fractals, doing so is strongly advised against.
//
// Usage: In the "Custom Strategy Arguments:" box enter the following
// [ ] default script (empty)
// [atramedes ] default script, atramedes fight
// [air=ddd ground=ddd iground=ddd] allows the user to specify airPhase, groundPhase and initialGround phase lengths for Atramedes
// For example: [atramedes air=30 ground=85 iground=90] would define a 30 second air phase, 85 second ground phase with
// an initial 90 second ground phase. Only integer values are supported.
// [valiona ] Valiona and Theralion style target swap fight (120 sec per target, 10 sec swap time)
// [adds ] Tank and spank with periodic adds
// [addsCount=ddd addsInterval=ddd addsTimeToDie=ddd] allows the user to specify the number of adds, the spawn interval and time to die
// For example: [adds addsCount=7 addsInterval=60 addsTimeToDie=15] would define 7 adds, every 60 seconds, with the adds
// despawning after 15 seconds. Coincidentally these are the default parameters.
//
// Notes:
// * The generic adds modeling will produce quite a large amount of output since it will
// report damage stats for every single add separately.
// * The generic adds modeling is currently setup to return errors if less than 3 adds per
// iteration are desired since the action side of the script only knows how to face-roll
// swipe. If someone comes up with a coherent strategy for "2 targets, need to DPS both",
// this restriction can be removed.
//

import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;

private String mDefaultTarget;
private int mDefaultTargetLevel;
private int mLevel;
private boolean mHasTier_11_4pc;
private boolean mHasTier_12_4pc;
private boolean mHasTier_13_4pc;
private boolean mIsModelingUnholyFrenzy;
private boolean mIsModelingShatteringThrow;
private boolean mIsModelingInterrupts;
private boolean mIsModelingAggressiveFeralCharge;
private boolean mIsModelingFrontalAttacks;
private boolean mNeedToMangle;
private boolean mNeedToFF;
private double mEncounterDuration;
private double mFeralChargeTotalTime;

private ArrayList mPassiveProcs;
private ArrayList mOnUseProcs;
private boolean mHasOnUseProcs;
private SimulationProcStatus mUnheededWarning;

// Variables for emulating Atramedes ground/air phases. Times were taken from DBM.
private boolean mAtramedes = false;
private boolean mAtramedesInAirPhase = false;
private double mAtramedesInitialGroundDuration = 90;
private double mAtramedesAirDuration = 31.5;
private double mAtramedesGroundDuration= 85;

// Variables for emulating a two target encounter similar to V&T.
private boolean mValiona = false;
private boolean mValionaActive = false;
private String mValionaOffTarget;
private double mValionaPhaseDuration = 120;
private double mValionaSwitchDuration = 10; // Don't remember how long Engulfing Magic/Dazzling Destruction + the other landing takes.

// Generic add fight.
private boolean mAdds = false;
private int mAddsLevel;
private int mAddsCount = 7; // 7 adds.
private double mAddsInterval = 60; // 60 second interval.
private double mAddsTimeToDie = 15; // 15 second lifespan.
private int mAddsIndex = 0; // Index used for reporting.

public void onSimulationBegin(IStatus stat, String args) {
// Optional initialization hook. Called at the start of a fight.
CatModelSimState status = (CatModelSimState) stat;

//
// Certain model options and parameters do not change through the lifetime of a run.
//
// We can save time by figuring out certain things now and avoid repeatedly recalcuating things.
//
mEncounterDuration = status.getTimeRemaining();

mDefaultTarget = status.getTarget();
mDefaultTargetLevel = status.getTargetLevel();
mLevel = status.getLevel();
mHasTier_11_4pc = status.hasTier_11_4pc();
mHasTier_12_4pc = status.hasTier_12_4pc();
mHasTier_13_4pc = status.hasTier_13_4pc();
mIsModelingUnholyFrenzy = status.getUnholyFrenzyCD() < mEncounterDuration;
mIsModelingShatteringThrow = status.getShatteringThrowCD() < mEncounterDuration;
mIsModelingInterrupts = status.shouldSkullBash();
mIsModelingAggressiveFeralCharge = status.shouldAggressiveFeralCharge();
mIsModelingFrontalAttacks = status.isFrontalAttackOnly();
mFeralChargeTotalTime = status.getFeralChargeTotalTime();

mNeedToMangle = status.shouldMangle();
mNeedToFF = status.shouldFF();

//
// Get a list of procs being modeled so we can easily query the status or trigger them as needed.
//
// Notes:
// * Janino does not support Java 1.5 style for loops, so use java.util.Iterator.
// * All of the Engineering tinkers are shit compared to any other "on use" effect, so de-prioritize
// them so that all other options are chosen first.
//
mPassiveProcs = new ArrayList();
mOnUseProcs = new ArrayList();
ArrayList onUseTinkers = new ArrayList();
for (Iterator iter = status.getProcStatusMap().entrySet().iterator(); iter.hasNext(); ) {
Map.Entry procEntry = (Map.Entry) iter.next();
String name = (String) procEntry.getKey();
SimulationProcStatus procStatus = (SimulationProcStatus) procEntry.getValue();

if (procStatus.isOnUse()) {
if (name.equals("Synapse Springs") || name.equals("Tazik Shocker"))
onUseTinkers.add(procStatus);
else
mOnUseProcs.add(procStatus);
} else {
if (name.equals("Unheeded Warning"))
mUnheededWarning = procStatus;
mPassiveProcs.add(procStatus);
}
}
mOnUseProcs.addAll(onUseTinkers); // The list is FIFO, so this forces Tinkers to be used last.
mHasOnUseProcs = !mOnUseProcs.isEmpty();

//
// Specific Encounter Simulation Initialization
//

StringTokenizer st = new StringTokenizer(args);
while (st.hasMoreTokens()) {
String token = st.nextToken();
if (token.equals("atramedes")) {
mAtramedes = true;
} else if (token.matches("air=\\d+")) {
mAtramedesAirDuration = Double.parseDouble(token.split("=")[1]);
} else if (token.matches("ground=\\d+")) {
mAtramedesGroundDuration = Double.parseDouble(token.split("=")[1]);
} else if (token.matches("iground=\\d+")) {
mAtramedesInitialGroundDuration = Double.parseDouble(token.split("=")[1]);
} else if (token.equals("valiona")) {
mValiona = true;
} else if (token.equals("adds")) {
mAdds = true;
} else if (token.matches("addsCount=\\d+")) {
mAddsCount = Integer.parseInt(token.split("=")[1]);
} else if (token.matches("addsInterval=\\d+")) {
mAddsInterval = Double.parseDouble(token.split("=")[1]);
} else if (token.matches("addsTimeToDie=\\d+")) {
mAddsTimeToDie = Double.parseDouble(token.split("=")[1]);
}
}

if (mAtramedes && mValiona || mAtramedes && mAdds || mValiona && mAdds)
throw new RuntimeException("Only one special encounter may be specified");

if (mAtramedes) {
// Do some sanity checking, and then schedule the utility timer which does the heavy lifting.
mAtramedesInAirPhase = (mAtramedesInitialGroundDuration <= 0);
if (mAtramedesAirDuration <= 0 || mAtramedesGroundDuration <= 0)
throw new RuntimeException("Air/Ground phases must have a positive duration");

boolean air = !mAtramedesInAirPhase; // Start off on the ground.
status.scheduleUtilityTimer(mAtramedesInitialGroundDuration);
for (double time = mAtramedesInitialGroundDuration; time < status.getTimeRemaining(); ) {
double schedTime = air ? mAtramedesAirDuration : mAtramedesGroundDuration;
time += schedTime;
status.scheduleUtilityTimer(time);
air = !air;
}
}

if (mValiona) {
mValionaActive = true;
status.newTarget("Yawninalion", mDefaultTargetLevel, status.getTimeRemaining(), true);
status.setTargetActive("Yawninalion", false);
mValionaOffTarget = "Yawninalion";
for (double time = mValionaPhaseDuration; time < status.getTimeRemaining(); time += mValionaPhaseDuration)
status.scheduleUtilityTimer(time);
}

if (mAdds) {
mAddsLevel = Math.max(mDefaultTargetLevel - 1, 85); // Boss level - 1, or level 85, whichever is greater.
if (mAddsCount < 3)
throw new RuntimeException("Generic Add fights must have 3 or more adds");
if (mAddsInterval <= 0)
throw new RuntimeException("Add interval must have a postive duration");
if (mAddsTimeToDie <= 0)
throw new RuntimeException("Add lifespan must have a positive duration");

for (double time = mAddsInterval; time < status.getTimeRemaining(); time += mAddsInterval)
status.scheduleUtilityTimer(time);
}

// EXAMPLE - Spawn a bunch of adds that we can Swipe.
// for (int i = 0; i < 5; i++) {
// status.newTarget("Yawningstrasza Whelp Nr. " + (i + 1), 87, status.getTimeRemaining(), false);
// }
// status.setTargetFacing("Yawningstrasza Whelp Nr. 1", true); // There's always that one mob that the tank fails at flipping.

// Example - Spawn a target with a linked BitW range with Yawningstrasza, and mark it as unattackable.
// status.newTarget("Yawningstrasza's Exposed Head", 88, status.getTimeRemaining(), true);
// status.setTargetActive("Yawningstrasza's Exposed Head", false);

// EXAMPLE - Spawn a second target that we can swap to at our leisure, with 90% BitW time.
// status.newTarget("Yawnitron", 88, status.getTimeRemaining(), status.getTimeRemaining() * 0.9);
}

public void onUtilityTimerFire(IStatus stat) {
// Utility timer, called at specific times if status.scheduleUtilityTimer() is used.
CatModelSimState status = (CatModelSimState) stat;

//
// Atramedes Encounter Simulation
//
if (mAtramedes) {
if (mAtramedesInAirPhase == false) {
// Air -> Ground
status.setTargetActive(mDefaultTarget, false); // Mark the target as unattackable.
status.scheduleIdleTime(mAtramedesAirDuration); // Let the Simulator know that we won't be doing anything.
} else {
// Ground -> Air
status.setTargetActive(mDefaultTarget, true); // Mark the target as attackable.
}
mAtramedesInAirPhase = !mAtramedesInAirPhase;
}

//
// Valiona and Theralion Encounter Simulation
//
if (mValiona) {
status.setTargetActive(mValionaOffTarget, mValionaActive);
status.setTargetActive(mDefaultTarget, !mValionaActive);
mValionaActive = !mValionaActive;
status.scheduleIdleTime(mValionaSwitchDuration); // Let the Simulator know that we won't be doing anything.
}

//
// Generic Add Fight
//
if (mAdds) {
// Note: These adds don't have a Blood In The Water range since all it will do is clutter up output.
// If this is ever relevant, in the future, it's a one line change though.
for (int i = 0; i < mAddsCount; i++) {
status.newTarget("Yawningstrasza Whelp Nr. " + (mAddsIndex + i + 1), mAddsLevel, mAddsTimeToDie, false);
}
mAddsIndex += mAddsCount;
}
}

//
// Determine what action to take if any.
//
// Valid return values:
// null
// Action.NONE (Same as returning null)
//
// Off GCD:
// Action.BERSERK
// Action.TIGERSFURY
// Action.FERALCHARGE
// Action.SKULLBASH
// Action.POTION
// Action.HEROISM
// Action.UNHOLYFRENZY
// Action.SHATTERINGTHROW
// Action.RUNAWAY (Gain distance to allow Feral Charge use)
// Action.AUTOATTACK_START
// Action.AUTOATTACK_STOP
//
// On GCD:
// Action.POUNCE
// Action.RAVAGE
// Action.CLAW
// Action.MANGLE
// Action.RAKE
// Action.SHRED
// Action.RIP
// Action.BITE
// Action.MAIM
// Action.ROAR
// Action.FERALFF
//

public IAction getAction(IStatus stat) {
CatModelSimState status = (CatModelSimState) stat;

//
// If we don't have a target, go back to the boss.
//
if (status.getTarget() == null) {
if (mValiona) {
// Valiona/Theralion just requires us to ping pong between them. Easy.
if (mValionaActive)
status.setTarget(mDefaultTarget);
else
status.setTarget(mValionaOffTarget);

// I could be paranoid and check target here to ensure that the target is set, but
// there's no point since there will only be 2 targets for this sim mode.
} else if (status.setTarget(mDefaultTarget) == false) {
// Hmm, main target isn't attackable. I could look at our target list and pick something else
// but behavior is encounter specific. For now sit around with our thumb up our ass.
return null;
}
}

//
// Query/derive a few common options for convenience.
//

double timeToDie = status.getTimeToDie();

int energy = status.getEnergy();
int energyCap = status.getEnergyCap();
double timeToEnergyCap = (energyCap - energy) * status.getEnergyTickInterval();

boolean isInGCD = status.isInGCD();
boolean isOoCUp = status.isOoCUp();
boolean isBerserkUp = status.isBerserkUp();
boolean isTigersFuryUp = status.isTigersFuryUp();

double tigersFuryCD = status.getTigersFuryCD();
boolean canTF = (!isBerserkUp && tigersFuryCD == 0.0);
boolean canBerserk = (status.getBerserkCD() == 0.0);
double berserkBaseDuration = status.getBerserkBaseDuration();

//
// External Abilities/events
//

// Heroism
//
// Note: This doesn't handle "encounters that would result in non-integer uses of heroism"
// at all. Defining default behavior for that case is more a matter of personal taste.
if (status.getHeroismCD() == 0.0) {
// Use Heroism as soon as combat starts.
if (status.getElapsedTime() > 0)
return Action.HEROISM;

// If the mob will die as heroism is falling off if we use it now, use it.
if (timeToDie <= 40)
return Action.HEROISM;

// If we will get a full heroism in at the end of the fight if we use it now, use it.
if (timeToDie >= 600 + 40)
return Action.HEROISM;
}

// Shattering throw
if (mIsModelingShatteringThrow && status.getShatteringThrowCD() == 0.0) {
// If heroism is up, use it.
if (status.isHeroismUp())
return Action.SHATTERINGTHROW;

// If the mob will die as Shattering Throw is falling off if we use it now, use it.
if (timeToDie < 10)
return Action.SHATTERINGTHROW;

// If we will get the full Shattering Throw in at the end of the fight if we use it now, use it.
if (timeToDie >= 300 + 10)
return Action.SHATTERINGTHROW;
}

// Unholy Frenzy
//
// Just simulate the DK using this on cooldown for now. More sophisticated things
// like stacking it with Berserk or Heroism could be done.
if (mIsModelingUnholyFrenzy && status.getUnholyFrenzyCD() == 0.0)
return Action.UNHOLYFRENZY;

// EXAMPLE - Simulate forced DPS stop.
// if (status.getElapsedTime() > 30 && status.getElapsedTime() < 60) {
// // Stop the swing timer.
// if (status.isAutoAttackEnabled()) return Action.AUTOATTACK_STOP;
//
// return null;
// }

//
// Druid abilities that are off the GCD
//

// Feral Charge to get Stampede up if we are not in combat.
if (!status.isInCombat() && status.getFeralChargeCD() == 0.0)
return Action.FERALCHARGE;

// Feral Charge to get Stampede up if we can.
if (mIsModelingAggressiveFeralCharge && status.canFeralCharge())
return Action.FERALCHARGE;

// Don't bother trying to do anything else if we are out of melee range.
if (!status.isInMeleeRange()) return null;

// Start the swing timer if needed.
if (!status.isAutoAttackEnabled())
return Action.AUTOATTACK_START;

// Potion of Tol'vir
if (status.canPotion()) {
// Pre-potion.
if (!status.isInCombat())
return Action.POTION;

if (status.isHeroismUp() || timeToDie < 40 || (status.getHeroismCD() > timeToDie && isBerserkUp))
return Action.POTION;
}

// If the target is casting, interrupt it if we can.
if (mIsModelingInterrupts && status.isTargetCasting() && status.getSkullBashCD() == 0.0) {
// Use Tiger's Fury to get energy to interrupt if needed.
if (energy < status.getSkullBashCost())
if (canTF == true)
return Action.TIGERSFURY;
else
return null; // Can't interrupt, insufficient energy.

return Action.SKULLBASH;
}

// Start pooling energy for interrupts.
boolean interruptSoon = false;
if (mIsModelingInterrupts) {
double timeToNextCast = status.nextCastIn();

// Only bother pooling assuming we can manage to interrupt.
if (status.getSkullBashCD() <= timeToNextCast + status.getTargetCastTime()) {
// Use base energy regen instead of energyPerSec to be somewhat conservative.
double skullBashCost = status.getSkullBashCost();
double poolReqTime = skullBashCost / 10;
double expectedEnergyRegen = timeToNextCast * 10;

// Pool assuming we do not have OoC up, and next cast is soon.
if (timeToNextCast <= poolReqTime) {
if (!isOoCUp && energy + expectedEnergyRegen < status.getShredCost() + skullBashCost) {
return null;
}

// Determine if it's "safe" to allow Ferocious Bite
int biteCost = (isOoCUp) ? 0 : status.getFerociousBiteCost();
int extraEnergy = Math.min(25, energy - biteCost);

if (energy - (biteCost + extraEnergy) + expectedEnergyRegen < skullBashCost)
interruptSoon = true;
}
}
}

// Note: Ensuring that we are off the GCD will allow for one more ability while the buff is up.
if (mLevel == 80) {
if (energy <= 26 && canTF == true && !isInGCD)
return Action.TIGERSFURY;
} else {
// Clean up TF logic since having separate conditionals was not honoring Yawning's "!status.isStampedeUp()" change
if (mHasTier_13_4pc) {
// TF a little sooner if 4 piece T13. This is very touchy and falls off fast if you up it beyond 45 energy, but is is substantial at 45 energy.
// On Mihir's profile it is a 190 dps increase with no in combat FC and with a 1 second travel time it is a 175 dps increase.
if (energy <= 45 && canTF == true && !isOoCUp && !isInGCD && !status.isStampedeUp())
return Action.TIGERSFURY;
} else {
if (energy <= 35 && canTF == true && !isOoCUp && !isInGCD)
return Action.TIGERSFURY;
}
}

// Since Berserk does not clip Tiger's Fury anymore, stacking is ideal but makes this encounter sensitive.
// For now Berserk whenever we are at the correct energy level, and when it won't push back the next TF.
// The difference between the two appears to be < 10 DPS.
//
// Note: As of 4.1 Berserk is not on the GCD. However, using it when in a GCD is a minor DPS loss.
if (canBerserk && !status.isInGCD()) {
if (status.isTigersFuryUp())
return Action.BERSERK;

if (timeToDie < berserkBaseDuration && tigersFuryCD > 6)
return Action.BERSERK;
}

// Sync "On Use" trinkets with Tiger's Fury. Syncing with Berserk takes care of itself, since
// we will (almost) always Berserk when TF is up.
//
// Note: This causes a slight uptime loss if you have multiple on use effects on the linked lockout
// (like the Engineering tinker), but a quick test shows that this behavior is a fairly heafty DPS
// gain over blindly using effects on cooldown. Trinket valuation is even more encounter duration
// sensitive, but that mimics what happens when actually playing so it's probably ok.
if (mHasOnUseProcs && isTigersFuryUp) {
for (Iterator iter = mOnUseProcs.iterator(); iter.hasNext(); ) {
SimulationProcStatus proc = (SimulationProcStatus) iter.next();

if (proc.getCD() == 0.0) proc.trigger();
}
}

//
// Druid abilities that are on the GCD
//

// Skip processing all of these if we're stuck in a GCD.
if (isInGCD) return handleStampedeConditions(status, interruptSoon);

//
// Query/Derive the rest of the common information that we need.
//
// Note: We delay this till we're past the events that are off GCD because none of them factor into
// the decicison process at all till this point.
//

int cps = status.getComboPoints();

boolean isInBloodInTheWaterRange = status.isInBloodInTheWaterRange();

boolean isStampedeUp = status.isStampedeUp();
boolean isMangleUp = status.isMangleUp();
boolean isRakeUp = status.isRakeUp();
boolean isRipUp = status.isRipUp();
boolean isSavageRoarUp = status.isSavageRoarUp();

double ripRemaining = status.getRipRemaining();
double srRemaining = status.getSavageRoarRemaining();
double rakeRemaining = status.getRakeRemaining();
double ripSRSyncTimer = (double) Math.abs(ripRemaining - srRemaining);

//
// AoE:
//

if (status.getTargetCount() > 3) {
return handleMassAoE(status);
}

//
// Openers:
//

// EXAMPLE - Ravage if Stampede is not up (Don't do this, it sucks).
// if (status.isInCombat() == false && status.isStampedeUp() == false)
// return Action.RAVAGE;

// EXAMPLE - Open with Pounce (Don't do this, it sucks.).
// if (status.isInCombat() == false)
// return Action.POUNCE;

//
// Raid debuffs:
//

// Mangle if the 4T11 bonus is about to fall off.
if (mHasTier_11_4pc && status.getTier_11_4pcRemaining() <= 4)
return Action.MANGLE;

// Faerie Fire if it's not up.
if (mNeedToFF && status.getFeralFFCD() == 0.0 && (status.getFeralFFStacks() < 3 || status.getFeralFFRemaining() <= 1))
return Action.FERALFF;

// Mangle to get debuff up.
if ((!isMangleUp || status.getMangleRemaining() <= 2) && mNeedToMangle)
return Action.MANGLE;

//
// Ravage/Blood in the Water:
//

// Ravage if Stampede will drop during the next globals...we don't want to lose the free Ravage.
if (isStampedeUp && status.getStampedeRemaining() <= 2.0)
return Action.RAVAGE;

// Handle Blood in the Water as long as using the Bite won't cause us to miss a interrupt.
if (!interruptSoon && isInBloodInTheWaterRange) {
// Ferocious Bite to extend Rip if we are at > 0 cps, are in BitW range, and Rip is about to fall.
if (cps >= 1 && isRipUp && ripRemaining <= 2.1)
return Action.BITE;

// Ferocious Bite if we are at 5 cps, Rip is up, and we are in BitW range.
// Note: Worrying about overwriting a TFed Rip is DPS neutral at best.
if (cps == 5 && isRipUp)
return Action.BITE;
}

//
// Regular Rotation:
//

// Mangle/Shred if you can utilize Glyph of Bloodletting to extend Rip.
if (ripRemaining <= 4 && isRipUp && !isInBloodInTheWaterRange && status.getRipGlyphExtRemaining() > 0) {
return mIsModelingFrontalAttacks ? Action.MANGLE : Action.SHRED;
}

// Rip at 5 CP if enemy will live for 3 ticks and Rip has 2sec or less.
if (cps == 5 && timeToDie >= 6 && (!isRipUp || ripRemaining < 2.0) && (isBerserkUp || ripRemaining + 2 <= tigersFuryCD))
return Action.RIP;

// Rip if the the existing one does not have TF.
//
// Notes:
// * This appears to be a net loss with 4T12, even holding off on it when Berserk is about to come off CD.
// * A quick check also shows this to be totally DPS neutral in 4T11 setups due to the fact that direct damage was buffed.
// if (!mHasTier_12_4pc && cps == 5 && timeToDie >= 6 && isTigersFuryUp && !status.isRipTFed())
// return Action.RIP;

// Bite if Berserk is up, and Rip/SR have non-zero time remaining.
// Note: This is *mostly* for 4T12 however it appears to be a slight gain even without the set bonus.
if (isBerserkUp) {
if (cps == 5 && energy > status.getFerociousBiteCost() && ripRemaining > 5 && srRemaining >= 3)
return Action.BITE;
}

// Clip Rake if the existing Rake has < 9 sec left, and we have TF up.
// Per Mihir/Leafkiller - Substantial gain. At 85, across a vast array of gear points 9.0 sec appears optimal.
// In 4.3, just refresh it if it has not been TFed. Probably a priority question for the 6 second window vs. Ravage!
if (timeToDie >= 8.5 && isTigersFuryUp && !status.isRakeTFed())
return Action.RAKE;

// Rake if the enemy will live for the full duration of Rake and Rake has 3sec or less.
// Allow for slight pushback on Rake refresh depending on the TF CD since it's a marginal gain (adjusted for 4.3).
if (timeToDie >= 8.5 && (!isRakeUp || rakeRemaining < 3.0) && (isBerserkUp || rakeRemaining <= tigersFuryCD || energy >= 71))
return Action.RAKE;

// Direct damage CP generator on OOC.
if (isOoCUp)
return (!mIsModelingFrontalAttacks) ? Action.SHRED : Action.MANGLE;

// Savage Roar if it's down or about to drop.
if (cps > 0 && (!isSavageRoarUp || srRemaining <= 2))
return Action.ROAR;

// Ravage if we have 4T13, have Stampede up, and Tiger's Fury is off cooldown.
// Note: Clipping Stampede is bad. Rake/SR uptime matter more than wasting a Ravage even with one use.
if (mHasTier_13_4pc && isStampedeUp && tigersFuryCD < 1.0)
return Action.RAVAGE;

// Rip/SR Desync; If Rip has 12s or less left, you have 5 CPs, and SR will expire within 3s of Rip expiring, go ahead and SR now.
// Note: Per Toskk removing this entirely can produce higher DPS though it's CP generation(?) dependent.
// In 4.2 it appears that not doing this tends to produce higher DPS, though the difference is marginal at best in obnoxiously good gear.
//if (cps == 5 && timeToDie >= 9 && (ripRemaining <= 12 && ripSRSyncTimer <= 3))
// return Action.ROAR;
// 4.3 Putting desyncing back into the rotation. The window is bigger than one might expect and it is not balanced.
// This increases Rip and SR uptime very slightly - and in 4.3 both are valuable
if (cps == 5 && timeToDie >= 9 && ripRemaining <= 12 && (srRemaining <= ripRemaining + 6))
return Action.ROAR;


// Direct damage CP generator if Unheeded Warning is up.
// Note: This is gear dependent. It's a gain at 359 gear, but DPS neutral/a loss in better gear.
// No point in trying to optimise the proc further. Increasing the priority above this point is a massive loss.
// if (mUnheededWarning != null && mUnheededWarning.isUp()) {
// if (mHasTier_11_4pc && status.getTier_11_4pcStacks() < 3)
// return Action.MANGLE;
//
// return (!mIsModelingFrontalAttacks) ? Action.SHRED : Action.MANGLE;
// }

if (!interruptSoon) {
// Ferocious Bite if they'll die soon.
if (cps == 5 && timeToDie <= 7)
return Action.BITE;

// Ferocious Bite if you have 5 cp's and FB/SR have more than <Number here> sec left on their timers.
// Note: Leafkiller says 12 sec for 85. Toskk says 14 sec for 85.
if (!isBerserkUp || energy < 25) {
if (mLevel == 80) {
if (cps == 5 && ripRemaining >= 8 && srRemaining >= 4)
return Action.BITE;
} else {
// As of 4.2 PTR, this is a minor gain again.
if (cps == 5 && ripRemaining >= 14 && srRemaining >= 10)
return Action.BITE;
}
}
}

// (Leaf) Try to use stampede as soon as viable without waiting for TF to come of of cooldown.
// With no mid-enocounter ravages this is dps neutral but with mid-encounter ravages, this is substantial.
// Using Mihir's profile, and a 2 second travel time, this is more than 100dps, with 1 second travel time it is more than 600dps.
// The point is to use a ravage asap so you don't delay casting TF, which happens from FCed FCs - so the more often you FC, the more important this change is.
if (mHasTier_13_4pc && isStampedeUp && !isOoCUp && timeToEnergyCap >= 1.0)
return Action.RAVAGE;

// Ravage If Stampede/TF is up and OoC is not, and I won't energy cap
if (isStampedeUp && !isOoCUp && isTigersFuryUp && timeToEnergyCap >= 1.0)
return Action.RAVAGE;

// Mangle if the 4T11 bonus is not at 3 stacks.
if (mHasTier_11_4pc && status.getTier_11_4pcStacks() < 3)
return Action.MANGLE;

if (!mIsModelingFrontalAttacks) {
// Shred aggressively if Tiger's Fury or Berserk are up
if (isTigersFuryUp || isBerserkUp)
return Action.SHRED;

// Shred is we need combo points for Rip or SR
if ((cps < 5 && ripRemaining <= 3) || (cps == 0 && srRemaining <= 2))
return Action.SHRED;

// Shred if we need to burn energy off so we can TF without capping.
if (tigersFuryCD <= 3)
return Action.SHRED;

// Shred if they're going to die within one Rake.
if (timeToDie <= 8.5)
return Action.SHRED;

// Fallback Shred to prevent energy capping.
if (timeToEnergyCap <= 1.0)
return Action.SHRED;
} else {
// Mangle aggressively if Tiger's Fury or Berserk are up
if (isTigersFuryUp || isBerserkUp)
return Action.MANGLE;

// Mangle is we need combo points for Rip or SR
if ((cps < 5 && ripRemaining <= 3) || (cps == 0 && srRemaining <= 2))
return Action.MANGLE;

// Mangle if we need to burn energy off so we can TF without capping.
if (tigersFuryCD <= 3)
return Action.MANGLE;

// Mangle if they're going to die within one Rake.
if (timeToDie <= 8.5)
return Action.MANGLE;

// Fallback Mangle to prevent energy capping.
if (timeToEnergyCap <= 1.0)
return Action.MANGLE;
}

return handleStampedeConditions(status, interruptSoon);
}

private IAction handleStampedeConditions(CatModelSimState status, boolean interruptSoon) {
//
// Allow Stampede + Ravage! when out of opener.
//
double travelTime = mFeralChargeTotalTime;

// Only bother attempting to run away if it's desired behavior, you don't need to interrupt "soon"
// and the boss has a normal hit box.
if (!mIsModelingAggressiveFeralCharge || interruptSoon || travelTime == 0) return null;

// Only run out if Feral Charge is off CD or will come off CD during travel time.
//
// Note: This is hyper aggressive and is probably somewhat unrealistic.
if (status.getFeralChargeCD() > travelTime) return null;

// Running away right as you are about to cast Tranquility or Rebirth is a DPS loss, avoid it.
//
// Note: The engine will force the "player" to hold the GCD for Rebirth/Tranquility so include
// some padding when figuring out if we can do this or not. (Kludge, I should clean the implementation up.)
if (status.nextUtilityCastIn() < travelTime + 2) return null;

// If running out will cause you to miss an interrupt, don't do it.
if (mIsModelingInterrupts && status.nextCastIn() < travelTime) return null;

// Running out when cooldowns are up is retarded, don't do that either.
if (status.isBerserkUp() || status.isTigersFuryUp()) return null;

// Per Leafkiller: Ensuring Rake won't fall off when off target is a minimal gain.
//
// Note: This is extremely minor since it doesn't get triggered that often.
if (status.getRakeRemaining() < travelTime + 2.9) return null;

// If 4T13 is being modeled and GoTF is specified, ensure that Tiger's Fury won't come off cooldown
// while traveling, or when you're trying to consume your Feral Charge sourced Stampede, because losing
// glyph value due to travel time or Stampede procs due to clipping is a massive DPS loss.
if (mHasTier_13_4pc && status.getTigersFuryCD() < travelTime + 3.0) return null;

return Action.RUNAWAY;
}

private IAction handleMassAoE(CatModelSimState status) {
//
// AoE with a utterly obsence number of targets.
//

int energy = status.getEnergy();
int energyCap = status.getEnergyCap();
double timeToEnergyCap = (energyCap - energy) * status.getEnergyTickInterval();

boolean isOoCUp = status.isOoCUp();

boolean isStampedeUp = status.isStampedeUp();
boolean isTigersFuryUp = status.isTigersFuryUp();

// Ravage if Stampede will drop during the next globals...we don't want to lose the free Ravage.
if (isStampedeUp && status.getStampedeRemaining() <= 2.0)
return Action.RAVAGE;

// If we can Swipe, faceroll that button hard.
if (energy >= status.getSwipeCost())
return Action.SWIPE;

// Ravage If Stampede/TF is up and OoC is not, and I won't energy cap
if (isStampedeUp && !isOoCUp && isTigersFuryUp && timeToEnergyCap >= 1.0)
return Action.RAVAGE;

// Sigh, ok, we're energy starved, might as well Feral FF things if we can.
// Note: The behavior implemented here is closer to using Feral FF with a mouse over macro.
if (mNeedToFF && status.getFeralFFCD() == 0.0) {
List targetList = status.getTargetList();
for (Iterator iter = targetList.iterator(); iter.hasNext(); ) {
status.setTarget((String) iter.next());
if (status.getFeralFFStacks() < 3 || status.getFeralFFRemaining() <= 1) {
status.setTargetAfterAction(mDefaultTarget); // Go back to our default target after we FF.
return Action.FERALFF;
}
}

// Well, we couldn't find anything to FF, back to the boss.
status.setTarget(mDefaultTarget);
}

return null;
}

Change log

r1088 by roy.d.albert on Jan 13, 2012   Diff
CatModelSimulator.script:
* Small change that helps with Rip/SR
uptime.
Go to: 
Project members, sign in to write a code review

Older revisions

r1087 by roy.d.albert on Jan 12, 2012   Diff
CatModelSimulator changes:
* Add in new desyncing of SR and Rip.
* Tweak the Rake refresh code for on-
use effects that are lined up with TF
r1086 by yawninglol on Jan 12, 2012   Diff
CatModelSimulator changes:
 * Re-add leafkiller's changes from
r1084 that I removed in my failed
attempt to fix the file history.
r1085 by yawninglol on Jan 12, 2012   Diff
Reverse merging the previous version
to get the revision history back.
I'll re-add changes from r1084 after
this.
All revisions of this file

File info

Size: 32049 bytes, 832 lines
Powered by Google Project Hosting