-
Notifications
You must be signed in to change notification settings - Fork 761
Expand file tree
/
Copy pathsc_warlock.cpp
More file actions
1231 lines (1063 loc) · 39.3 KB
/
sc_warlock.cpp
File metadata and controls
1231 lines (1063 loc) · 39.3 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
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "simulationcraft.hpp"
#include "sc_warlock.hpp"
#include "sc_warlock_pets.hpp"
#include "util/util.hpp"
#include "class_modules/apl/warlock.hpp"
#include <queue>
namespace warlock
{
warlock_td_t::warlock_td_t( player_t* target, warlock_t& p )
: actor_target_data_t( target, &p ), soc_threshold( 0.0 ), warlock( p )
{
// Shared
dots.drain_life = target->get_dot( "drain_life", &p );
// Affliction
dots.corruption = target->get_dot( "corruption", &p );
dots.agony = target->get_dot( "agony", &p );
dots.drain_soul = target->get_dot( "drain_soul", &p );
dots.seed_of_corruption = target->get_dot( "seed_of_corruption", &p );
dots.unstable_affliction = target->get_dot( "unstable_affliction", &p );
dots.malefic_grasp = target->get_dot( "malefic_grasp", &p );
debuffs.haunt = make_buff( *this, "haunt", p.talents.haunt )
->set_refresh_behavior( buff_refresh_behavior::PANDEMIC )
->set_default_value_from_effect( 2 )
->set_cooldown( 0_ms )
->set_stack_change_callback( [ &p ]( buff_t* b, int, int cur ) {
p.haunt_target = ( cur == 0 ) ? nullptr : b->player;
} );
if ( p.talents.shadow_of_nathreza_1.ok() )
{
debuffs.haunt->set_tick_zero( false )
->set_period( p.talents.haunt->effectN( 5 ).period() )
->set_tick_callback( [ target, &p ]( buff_t*, int, timespan_t ) {
p.proc_actions.shadow_of_nathreza->execute_on_target( target );
if ( p.talents.shadow_of_nathreza_3.ok() )
helpers::trigger_wrath_of_nathreza( &p, target );
} );
}
// Demonology
debuffs.doom = make_buff( *this, "doom", p.talents.doom_debuff )
->set_stack_change_callback( [ &p ]( buff_t* b, int, int cur ) {
if ( cur == 0 )
{
p.proc_actions.doom_proc->execute_on_target( b->player );
}
} );
// Destruction
dots.immolate = target->get_dot( "immolate", &p );
debuffs.lake_of_fire = make_buff( *this, "lake_of_fire", p.talents.lake_of_fire_debuff )
->set_default_value_from_effect( 1 )
->set_refresh_behavior( buff_refresh_behavior::DURATION )
->set_max_stack( 1 );
debuffs.shadowburn = make_buff( *this, "shadowburn", p.talents.shadowburn )
->set_default_value( p.talents.shadowburn_2->effectN( 1 ).base_value() / 10 );
// Use havoc_debuff where we need the data but don't have the active talent
// Mayhem proc chance follows a Flat % RNG model, but has ICD
debuffs.havoc = make_buff( *this, "havoc", p.talents.havoc_debuff )
->set_duration( p.talents.mayhem.ok() ? p.talents.mayhem->effectN( 3 ).time_value() + p.talents.improved_havoc->effectN( 1 ).time_value() : p.talents.havoc->duration() )
->set_cooldown( p.talents.mayhem.ok() ? p.talents.mayhem->internal_cooldown() : 0_ms )
->set_chance( p.talents.mayhem.ok() ? p.talents.mayhem->effectN( 1 ).percent() : p.talents.havoc->proc_chance() )
->set_stack_change_callback( [ &p ]( buff_t* b, int, int cur ) {
if ( cur == 0 )
{
p.havoc_target = nullptr;
}
else
{
if ( p.havoc_target && p.havoc_target != b->player )
p.get_target_data( p.havoc_target )->debuffs.havoc->expire();
p.havoc_target = b->player;
}
range::for_each( p.havoc_spells, []( action_t* a ) { a->target_cache.is_valid = false; } );
} );
// Diabolist
debuffs.cloven_soul = make_buff( *this, "cloven_soul", p.hero.cloven_soul_debuff );
// Hellcaller
dots.wither = target->get_dot( "wither", &p );
debuffs.blackened_soul = make_buff( *this, "blackened_soul", p.hero.blackened_soul_trigger )
->set_duration( 0_ms )
->set_tick_zero( false )
->set_period( p.hero.blackened_soul_trigger->effectN( 1 ).period() )
->set_tick_callback( [ this, target ]( buff_t*, int, timespan_t ) {
warlock.proc_actions.blackened_soul->execute_on_target( target );
} )
->set_tick_behavior( buff_tick_behavior::REFRESH )
->set_freeze_stacks( true );
debuffs.wither = make_buff( *this, "wither", p.hero.wither_dot ); // Dummy debuff
// Soul Harvester
dots.soul_anathema = target->get_dot( "soul_anathema", &p );
dots.shared_fate = target->get_dot( "shared_fate", &p );
target->register_on_demise_callback( &p, [ this ]( player_t* ) { target_demise(); } );
}
void warlock_td_t::target_demise()
{
if ( !( target->is_enemy() ) )
return;
// Warlock gains only one shard at most per enemy that dies with UA, regardless of UA stacks
if ( dots.unstable_affliction->is_ticking() )
{
warlock.sim->print_log( "Player {} demised. Warlock {} gains a shard from Unstable Affliction.", target->name(), warlock.name() );
warlock.resource_gain( RESOURCE_SOUL_SHARD, warlock.talents.unstable_affliction_2->effectN( 1 ).base_value(), warlock.gains.unstable_affliction_refund );
}
if ( dots.drain_soul->is_ticking() )
{
warlock.sim->print_log( "Player {} demised. Warlock {} gains a shard from Drain Soul.", target->name(), warlock.name() );
warlock.resource_gain( RESOURCE_SOUL_SHARD, 1.0, warlock.gains.drain_soul );
}
if ( debuffs.haunt->check() )
{
warlock.sim->print_log( "Player {} demised. Warlock {} reset Haunt's cooldown.", target->name(), warlock.name() );
warlock.cooldowns.haunt->reset( true );
}
if ( debuffs.shadowburn->check() )
{
warlock.sim->print_log( "Player {} demised. Warlock {} gains 1 shard from Shadowburn.", target->name(), warlock.name() );
warlock.resource_gain( RESOURCE_SOUL_SHARD, debuffs.shadowburn->check_value(), warlock.gains.shadowburn_refund );
}
if ( warlock.hero.demonic_soul.ok() && warlock.hero.shared_fate.ok() )
{
warlock.sim->print_log( "Player {} demised. Warlock {} triggers Shared Fate on all targets in range.", target->name(), warlock.name() );
warlock.proc_actions.shared_fate->execute();
}
if ( warlock.hero.demonic_soul.ok() && warlock.hero.feast_of_souls.ok() )
{
if ( warlock.prd_rng.feast_of_souls->trigger() )
{
warlock.sim->print_log( "Player {} demised. Warlock {} triggers Feast of Souls.", target->name(), warlock.name() );
warlock.feast_of_souls_gain();
}
}
}
int warlock_td_t::count_affliction_dots() const
{
// NOTE: [Drain Soul, Malefic Grasp, Shared Fate, Soul Anathema] DoTs do not count (they do not affect effects influenced by this count)
int count = 0;
if ( dots.agony->is_ticking() )
count++;
if ( dots.corruption->is_ticking() )
count++;
// NOTE: 2026-02-17: Currently Wither is bugged and does not count
if ( !warlock.bugs && dots.wither->is_ticking() )
count++;
if ( dots.seed_of_corruption->is_ticking() )
count++;
// NOTE: UA counts as 1 dot does not matter how many stacks
if ( dots.unstable_affliction->is_ticking() )
count++;
return count;
}
warlock_t::warlock_t( sim_t* sim, util::string_view name, race_e r )
: parse_player_effects_t( sim, WARLOCK, name, r ),
havoc_target( nullptr ),
bugged_mayhem( false ),
havoc_spells(),
diabolic_ritual( 0 ),
demonic_art_buff_replaced( false ),
n_active_pets( 0 ),
warlock_pet_list( this ),
talents(),
hero(),
proc_actions(),
tier(),
cooldowns(),
buffs(),
gains(),
procs(),
rng_settings(),
initial_soul_shards(),
default_pet(),
disable_auto_felstorm( false ),
normalize_destruction_mastery( false ),
eye_explosion_instanced_bug_cb( true ),
eye_explosion_instanced_bug_sb( true ),
eye_explosion_instanced_bug_rof( false ),
tyrant_antoran_armaments_target_mul( 1.0 )
{
cooldowns.haunt = get_cooldown( "haunt" );
cooldowns.dark_harvest = get_cooldown( "dark_harvest" );
cooldowns.soul_fire = get_cooldown( "soul_fire" );
cooldowns.summon_doomguard = get_cooldown( "summon_doomguard" );
cooldowns.felstorm_icd = get_cooldown( "felstorm_icd" );
cooldowns.echo_of_sargeras = get_cooldown( "echo_of_sargeras_icd" );
cooldowns.blackened_soul = get_cooldown( "blackened_soul_icd" );
cooldowns.seeds_of_their_demise = get_cooldown( "seeds_of_their_demise_icd" );
resource_regeneration = regen_type::DYNAMIC;
regen_caches[ CACHE_HASTE ] = true;
regen_caches[ CACHE_SPELL_HASTE ] = true;
sim->register_heartbeat_event_callback( [ this ]( sim_t* ) {
// NOTE (2026-03-08): Wild Imps are currently bugged when updating Hellbent Commander stacks on demise.
// Hellbent Commander's stacks are updated to their correct value on each heartbeat update.
if ( bugs && talents.hellbent_commander.ok() )
{
const int expected_stacks = active_demon_count( !bugs );
const int current_stacks = buffs.hellbent_commander->check();
const int stack_diff = expected_stacks - current_stacks;
if ( stack_diff > 0 )
buffs.hellbent_commander->trigger( stack_diff );
else if (stack_diff < 0 )
buffs.hellbent_commander->decrement( std::abs( stack_diff ) );
if ( stack_diff != 0 )
{
this->sim->print_debug( "{} heartbeat event update {} buff stack number from stacks_before={} to stacks_after={}",
this->name(), buffs.hellbent_commander->name(), current_stacks, expected_stacks );
}
assert( ( buffs.hellbent_commander->check() == expected_stacks ) && "Incorrent Demon Count for Hellbent Commander" );
}
for ( auto pet : active_pets )
{
auto lock_pet = dynamic_cast<warlock_pet_t*>( pet );
if ( lock_pet == nullptr )
continue;
if ( lock_pet->is_sleeping() )
continue;
lock_pet->heartbeat_update_event();
}
} );
}
const spell_data_t* warlock_t::conditional_spell_lookup( bool fn, int id )
{
if ( !fn )
return spell_data_t::not_found();
return find_spell( id );
}
bool warlock_t::affliction() const
{ return specialization() == WARLOCK_AFFLICTION; }
bool warlock_t::demonology() const
{ return specialization() == WARLOCK_DEMONOLOGY; }
bool warlock_t::destruction() const
{ return specialization() == WARLOCK_DESTRUCTION; }
bool warlock_t::diabolist() const
{ return has_hero_tree( HERO_DIABOLIST ); }
bool warlock_t::hellcaller() const
{ return has_hero_tree( HERO_HELLCALLER ); }
bool warlock_t::soul_harvester() const
{ return has_hero_tree( HERO_SOUL_HARVESTER ); }
static void accumulate_seed_of_corruption( warlock_td_t* td, double amount )
{
td->soc_threshold -= amount;
if ( td->soc_threshold <= 0 )
td->dots.seed_of_corruption->cancel();
else if ( td->source->sim->log )
td->source->sim->print_log( "Remaining damage to explode Seed of Corruption on {} is {}.", td->target->name_str, td->soc_threshold );
}
void warlock_t::init_assessors()
{
player_t::init_assessors();
auto assessor_fn = [ this ]( result_amount_type, action_state_t* s ){
if ( get_target_data( s->target )->dots.seed_of_corruption->is_ticking() )
accumulate_seed_of_corruption( get_target_data( s->target ), s->result_total );
return assessor::CONTINUE;
};
assessor_out_damage.add( assessor::TARGET_DAMAGE - 1, assessor_fn );
for ( auto pet : pet_list )
{
pet->assessor_out_damage.add( assessor::TARGET_DAMAGE - 1, assessor_fn );
}
}
void warlock_t::init_finished()
{
parse_player_effects();
player_t::init_finished();
}
void warlock_t::invalidate_cache( cache_e c )
{
parse_player_effects_t::invalidate_cache( c );
switch ( c )
{
case CACHE_MASTERY:
if ( demonology() )
{
player_t::invalidate_cache( CACHE_PET_DAMAGE_MULTIPLIER );
player_t::invalidate_cache( CACHE_GUARDIAN_DAMAGE_MULTIPLIER );
}
break;
default:
break;
}
}
double warlock_t::composite_mastery() const
{
double m = parse_player_effects_t::composite_mastery();
if ( hero.shared_vessel.ok() )
{
if ( buffs.manifested_demonic_soul->check() )
m += hero.shared_vessel->effectN( 1 ).base_value();
}
return m;
}
// Used to determine how many Wild Imps are waiting to be spawned from Hand of Guldan
int warlock_t::get_spawning_imp_count()
{ return as<int>( wild_imp_spawns.size() ); }
// Function for returning the time until a certain number of imps will have spawned
// In the case where count is equal to or greater than number of incoming imps, time to last imp is returned
// Otherwise, time to the Nth imp spawn will be returned
// All other cases will return 0. A negative (or zero) count value will behave as "all"
timespan_t warlock_t::time_to_imps( int count )
{
timespan_t max = 0_ms;
if ( count >= as<int>( wild_imp_spawns.size() ) || count <= 0 )
{
for ( auto ev : wild_imp_spawns )
{
timespan_t ex = debug_cast<helpers::imp_delay_event_t*>( ev )->expected_time();
if ( ex > max )
max = ex;
}
return max;
}
else
{
std::priority_queue<timespan_t> shortest;
for ( auto ev : wild_imp_spawns )
{
timespan_t ex = debug_cast<helpers::imp_delay_event_t*>( ev )->expected_time();
if ( as<int>( shortest.size() ) >= count && ex < shortest.top() )
{
shortest.pop();
shortest.push( ex );
}
else if ( as<int>( shortest.size() ) < count )
{
shortest.push( ex );
}
}
if ( !shortest.empty() )
{
return shortest.top();
}
else
{
return 0_ms;
}
}
}
int warlock_t::active_demon_count( bool include_diabolist ) const
{
int count = 0;
for ( auto pet : this->pet_list )
{
auto lock_pet = dynamic_cast<warlock_pet_t*>( pet );
if ( lock_pet == nullptr )
continue;
if ( lock_pet->is_sleeping() )
continue;
// NOTE: 2026-02-17 Dibolist guardians seems to not count for some effects/talents (Sacrificed Souls and Hellbent Commander)
if ( !include_diabolist && lock_pet->is_diabolist_guardian )
continue;
count++;
}
return count;
}
std::pair<timespan_t, timespan_t> warlock_t::dreadstalkers_delay_duration_adjustment_helper( const player_t& target )
{
std::pair<timespan_t, timespan_t> ret;
timespan_t& delay = ret.first;
timespan_t& dur_adjust = ret.second;
const double dist = get_player_distance( target );
// The summon is considered at melee range if the distance is less than or equal to 5 yards
if ( dist > 5.0 )
{
// Set a randomized offset on first melee attacks after travel time. Make sure it's the same value for each dog so they're synced
delay = rng().range( 0_s, 1_s );
// Adjust the extra duration, that appear to be offset from the melee attack check in a correlated manner
// Despawn events appear to be offset from the melee attack check in a correlated manner
// Starting with this which mimics despawns on the "off-beats" compared to the 1s heartbeat for the melee attack, and taking into account the distance
// Last tested 2025-04-06
// The maximum despawn extra duration is 820ms. The initial offset point is 260ms, increasing 24ms with each yard
// There is some variance in the delay-duration_adj relation that can be modeled fairly closely using a normal distribution
dur_adjust = ( delay + timespan_t::from_millis( rng().gauss( 260.0, 25.0 ) + 24.0 * dist ) ) % 820_ms;
}
else
{
// There is no delay on the first melee attack when summoned from melee
delay = 0_ms;
// In this case the extra duration of the dreadstalkers can be assumed random between the minumum (0ms) and the maximum (820ms) (last tested 2025-04-06)
dur_adjust = timespan_t::from_millis( rng().range( 0.0, 820.0 ) );
}
return ret;
}
static std::string append_rng_option( warlock_t::rng_settings_t::rng_setting_t setting )
{
std::string str = "";
if ( setting.setting_value != setting.default_value )
str += "rng_" + setting.option_name + util::to_string( setting.setting_value ) + "\n";
return str;
}
std::string warlock_t::create_profile( save_e stype )
{
std::string profile_str = player_t::create_profile( stype );
if ( stype & SAVE_PLAYER )
{
if ( initial_soul_shards != 3 )
profile_str += "soul_shards=" + util::to_string( initial_soul_shards ) + "\n";
if ( !default_pet.empty() )
profile_str += "default_pet=" + default_pet + "\n";
if ( disable_auto_felstorm )
profile_str += "disable_felstorm=" + util::to_string( as<int>( disable_auto_felstorm ) ) + "\n";
if ( normalize_destruction_mastery )
profile_str +=
"normalize_destruction_mastery=" + util::to_string( as<int>( normalize_destruction_mastery ) ) + "\n";
if ( !eye_explosion_instanced_bug_cb )
profile_str +=
"eye_explosion_instanced_bug_cb=" + util::to_string( as<int>( eye_explosion_instanced_bug_cb ) ) + "\n";
if ( !eye_explosion_instanced_bug_sb )
profile_str +=
"eye_explosion_instanced_bug_sb=" + util::to_string( as<int>( eye_explosion_instanced_bug_sb ) ) + "\n";
if ( eye_explosion_instanced_bug_rof )
profile_str +=
"eye_explosion_instanced_bug_rof=" + util::to_string( as<int>( eye_explosion_instanced_bug_rof ) ) + "\n";
if ( tyrant_antoran_armaments_target_mul < 1.0 )
profile_str +=
"tyrant_antoran_armaments_target_mul=" + util::to_string( tyrant_antoran_armaments_target_mul ) + "\n";
rng_settings.for_each( [ &profile_str ]( auto& setting ) { profile_str += append_rng_option( setting ); } );
}
return profile_str;
}
void warlock_t::copy_from( player_t* source )
{
player_t::copy_from( source );
auto* p = debug_cast<warlock_t*>( source );
initial_soul_shards = p->initial_soul_shards;
default_pet = p->default_pet;
disable_auto_felstorm = p->disable_auto_felstorm;
normalize_destruction_mastery = p->normalize_destruction_mastery;
eye_explosion_instanced_bug_cb = p->eye_explosion_instanced_bug_cb;
eye_explosion_instanced_bug_sb = p->eye_explosion_instanced_bug_sb;
eye_explosion_instanced_bug_rof = p->eye_explosion_instanced_bug_rof;
tyrant_antoran_armaments_target_mul = p->tyrant_antoran_armaments_target_mul;
rng_settings = p->rng_settings;
}
stat_e warlock_t::convert_hybrid_stat( stat_e s ) const
{
// this converts hybrid stats that either morph based on spec or only work
// for certain specs into the appropriate "basic" stats
switch ( s )
{
case STAT_STR_AGI_INT:
case STAT_AGI_INT:
case STAT_STR_INT:
return STAT_INTELLECT;
case STAT_STR_AGI:
return STAT_NONE;
case STAT_SPIRIT:
return STAT_NONE;
case STAT_BONUS_ARMOR:
return STAT_NONE;
default:
return s;
}
}
pet_t* warlock_t::create_main_pet( util::string_view pet_name, util::string_view /* pet_type */ )
{
pet_t* p = find_pet( pet_name );
if ( p )
return p;
using namespace pets;
if ( pet_name == "felhunter" )
return new pets::base::felhunter_pet_t( this, pet_name );
if ( pet_name == "imp" )
return new pets::base::imp_pet_t( this, pet_name );
if ( pet_name == "sayaad" || pet_name == "incubus" || pet_name == "succubus" )
return new pets::base::sayaad_pet_t( this, pet_name );
if ( pet_name == "voidwalker" )
return new pets::base::voidwalker_pet_t( this, pet_name );
if ( pet_name == "felguard" && demonology() && talents.summon_felguard.ok() )
return new pets::demonology::felguard_pet_t( this, pet_name );
return nullptr;
}
std::unique_ptr<expr_t> warlock_t::create_pet_expression( util::string_view name_str )
{
if ( name_str == "last_cast_imps" )
{
return make_fn_expr( "last_cast_imps", [ this ]() {
return warlock_pet_list.wild_imps.n_active_pets( []( const pets::demonology::wild_imp_pet_t* pet ) {
return pet->resources.current[ RESOURCE_ENERGY ] < 32;
} );
} );
}
else if ( name_str == "two_cast_imps" )
{
return make_fn_expr( "two_cast_imps", [ this ]() {
return warlock_pet_list.wild_imps.n_active_pets( []( const pets::demonology::wild_imp_pet_t* pet ) {
return pet->resources.current[ RESOURCE_ENERGY ] < 48;
} );
} );
}
else if ( name_str == "last_cast_igb_imps" )
{
return make_fn_expr( "last_cast_igb_imps", [ this ]() {
return warlock_pet_list.wild_imps.n_active_pets( []( const pets::demonology::wild_imp_pet_t* pet ) {
return pet->resources.current[ RESOURCE_ENERGY ] < 32 && pet->buffs.imp_gang_boss->check();
} );
} );
}
else if ( name_str == "two_cast_igb_imps" )
{
return make_fn_expr( "two_cast_igb_imps", [ this ]() {
return warlock_pet_list.wild_imps.n_active_pets( []( const pets::demonology::wild_imp_pet_t* pet ) {
return pet->resources.current[ RESOURCE_ENERGY ] < 48 && pet->buffs.imp_gang_boss->check();
} );
} );
}
else if ( name_str == "igb_ratio" )
{
return make_fn_expr( "igb_ratio", [ this ]() {
auto igb_count = warlock_pet_list.wild_imps.n_active_pets( []( const pets::demonology::wild_imp_pet_t* pet ) {
return pet->buffs.imp_gang_boss->check();
} );
return igb_count / as<double>( buffs.wild_imps->stack() );
} );
}
return player_t::create_expression( name_str );
}
std::unique_ptr<expr_t> warlock_t::create_expression( util::string_view name_str )
{
// TODO: Remove time to shard expression?
if ( name_str == "time_to_shard" )
{
return make_fn_expr( name_str, [ this]() {
auto td = get_target_data( target );
dot_t* agony = td->dots.agony;
double active_agonies = get_active_dots( agony );
if ( sim->debug )
sim->out_debug.printf( "active agonies: %f", active_agonies );
if ( active_agonies == 0 || !agony->current_action )
{
return std::numeric_limits<double>::infinity();
}
action_state_t* agony_state = agony->current_action->get_state( agony->state );
timespan_t dot_tick_time = agony->current_action->tick_time( agony_state );
double creeping_death_mul = 1.0;
if ( talents.creeping_death.ok() )
{
if ( !bugs || talents.creeping_death.rank() < 2 )
creeping_death_mul *= 1.0 + talents.creeping_death->effectN( 1 ).percent();
else
creeping_death_mul *= 1.0 + ( talents.creeping_death->effectN( 1 ).percent() * 0.5 );
}
// Seeks to return the average expected time for the player to generate a single soul shard.
// TOCHECK regularly.
double average = 1.0 / ( ( rng_settings.agony_energize.setting_value * 0.5 ) * std::pow( active_agonies, -2.0 / 3.0 ) * creeping_death_mul )
* dot_tick_time.total_seconds() / active_agonies;
if ( sim->debug )
sim->out_debug.printf( "time to shard return: %f", average );
action_state_t::release( agony_state );
return average;
} );
}
else if ( name_str == "pet_count" )
{
return make_ref_expr( name_str, n_active_pets );
}
else if ( name_str == "last_cast_imps" )
{
return create_pet_expression( name_str );
}
else if ( name_str == "two_cast_imps" )
{
return create_pet_expression( name_str );
}
else if ( name_str == "last_cast_igb_imps" )
{
return create_pet_expression( name_str );
}
else if ( name_str == "two_cast_igb_imps" )
{
return create_pet_expression( name_str );
}
else if ( name_str == "igb_ratio" )
{
return create_pet_expression( name_str );
}
else if ( name_str == "havoc_active" )
{
return make_fn_expr( name_str, [ this ] { return havoc_target != nullptr; } );
}
else if ( name_str == "havoc_remains" )
{
return make_fn_expr( name_str, [ this ] {
return havoc_target ? get_target_data( havoc_target )->debuffs.havoc->remains().total_seconds() : 0.0;
} );
}
else if ( name_str == "incoming_imps" )
{
return make_fn_expr( name_str, [ this ] { return this->get_spawning_imp_count(); } );
}
else if ( name_str == "can_seed" )
{
std::vector<action_t*> soc_list;
for ( auto a : action_list )
{
if ( a->name_str == "seed_of_corruption" )
soc_list.push_back( a );
}
return make_fn_expr( name_str, [this, soc_list] {
std::vector<player_t*> no_dots;
if ( soc_list.empty() )
return false;
//All the actions should have the same target list, so do this once only
const auto& tl = soc_list[ 0 ]->target_list();
for ( auto t : tl )
{
if ( !get_target_data( t )->dots.seed_of_corruption->is_ticking() )
no_dots.push_back( t );
}
//If there are no targets without a seed already, this expression should be false
if ( no_dots.empty() )
return false;
//If all of the remaining unseeded targets have a seed in flight, we should also return false
for ( auto t : no_dots )
{
bool can_seed = true;
for ( auto s : soc_list )
{
if ( s->has_travel_events_for( t ) )
{
can_seed = false;
break;
}
}
if ( can_seed )
return true;
}
return false;
} );
}
else if ( name_str == "diabolic_ritual" )
{
return make_fn_expr( name_str, [ this ]()
{
return buffs.ritual_overlord->check() || buffs.ritual_mother->check() || buffs.ritual_pit_lord->check();
} );
}
else if ( name_str == "demonic_art" )
{
return make_fn_expr( name_str, [ this ]()
{
return buffs.art_overlord->check() || buffs.art_mother->check() || buffs.art_pit_lord->check();
} );
}
auto splits = util::string_split<util::string_view>( name_str, "." );
if ( splits.size() == 3 && splits[ 0 ] == "time_to_imps" && splits[ 2 ] == "remains" )
{
auto amt = splits[ 1 ] == "all" ? -1 : util::to_int( splits[ 1 ] );
return make_fn_expr( name_str, [ this, amt ]() {
return this->time_to_imps( amt );
} );
}
else if ( splits.size() == 2 && splits[ 0 ] == "dot_refreshable_count" )
{
enum class refreshable_dot_e
{
INVALID = -1,
WITHER,
IMMOLATE,
CORRUPTION,
AGONY,
UA,
SOC
};
unsigned action_id = 0;
refreshable_dot_e dot_sel = refreshable_dot_e::INVALID;
const auto& dot_name = splits[ 1 ];
if ( dot_name == "wither" )
{
if ( hero.wither.ok() )
{
dot_sel = refreshable_dot_e::WITHER;
action_id = hero.wither_direct->id();
}
}
else if ( dot_name == "immolate" )
{
if ( destruction() )
{
dot_sel = refreshable_dot_e::IMMOLATE;
action_id = warlock_base.immolate_old->id();
}
}
else if ( dot_name == "corruption" )
{
if ( affliction() )
{
dot_sel = refreshable_dot_e::CORRUPTION;
action_id = warlock_base.corruption->id();
}
}
else if ( dot_name == "agony" )
{
if ( affliction() )
{
dot_sel = refreshable_dot_e::AGONY;
action_id = talents.agony->id();
}
}
else if ( dot_name == "unstable_affliction" )
{
if ( affliction() )
{
dot_sel = refreshable_dot_e::UA;
action_id = talents.unstable_affliction->id();
}
}
else if ( dot_name == "seed_of_corruption" )
{
if ( affliction() )
{
dot_sel = refreshable_dot_e::SOC;
action_id = talents.seed_of_corruption->id();
}
}
else if ( dot_name == "immolate_or_wither" || dot_name == "wither_or_immolate" )
{
if ( hero.wither.ok() )
{
dot_sel = refreshable_dot_e::WITHER;
action_id = hero.wither_direct->id();
}
else if ( destruction() )
{
dot_sel = refreshable_dot_e::IMMOLATE;
action_id = warlock_base.immolate_old->id();
}
}
else if ( dot_name == "corruption_or_wither" || dot_name == "wither_or_corruption" )
{
if ( hero.wither.ok() )
{
dot_sel = refreshable_dot_e::WITHER;
action_id = hero.wither_direct->id();
}
else if ( affliction() )
{
dot_sel = refreshable_dot_e::CORRUPTION;
action_id = warlock_base.corruption->id();
}
}
action_t* action = nullptr;
if ( action_id != 0 )
{
for ( auto a : action_list )
{
if ( a->id == action_id )
{
action = a;
break;
}
}
}
return make_fn_expr( name_str, [ this, action, dot_sel ]()
{
size_t dot_refresh_targets = 0;
if ( !action || dot_sel == refreshable_dot_e::INVALID )
return dot_refresh_targets;
action_state_t* state = nullptr;
const auto& tl = action->target_list();
for ( auto t : tl )
{
warlock_td_t* tdata = get_target_data( t );
auto& dot = [ dot_sel, tdata ]() -> auto&
{
switch ( dot_sel )
{
case refreshable_dot_e::WITHER:
return tdata->dots.wither;
case refreshable_dot_e::IMMOLATE:
return tdata->dots.immolate;
case refreshable_dot_e::CORRUPTION:
return tdata->dots.corruption;
case refreshable_dot_e::AGONY:
return tdata->dots.agony;
case refreshable_dot_e::UA:
return tdata->dots.unstable_affliction;
case refreshable_dot_e::SOC:
return tdata->dots.seed_of_corruption;
default:
assert( false && "Unhandled refreshable_dot_e value" );
return tdata->dots.corruption;
}
}();
if ( dot == nullptr || !dot->is_ticking() )
{
dot_refresh_targets++;
continue;
}
if ( !state || state->action != dot->current_action )
{
if ( state )
action_state_t::release( state );
state = dot->current_action->get_state();
}
dot->current_action->snapshot_state( state, result_amount_type::DMG_OVER_TIME );
timespan_t new_duration = dot->current_action->composite_dot_duration( state );
if ( dot->current_action->dot_refreshable( dot, new_duration ) )
dot_refresh_targets++;
}
if ( state )
action_state_t::release( state );
return dot_refresh_targets;
} );
}
return player_t::create_expression( name_str );
}
/* ----------------------------------------------------------
* NOTE NOTE NOTE
* Applies DYNAMIC (Buffs, Debuffs, DoTs, or anything else that could change state during combat)
* effects that effect the player as a whole, IE: a % Crit Chance buff, all pet/guardian damage modifiers, and the likes
* NOTE NOTE NOTE
*
* This system can also handle passive effects, but increases sim initialization time!
*
* General Useage is parse_effects( buff, modifying_spell_1, modifying_spell_2, modifying_spell_3 );
*
* USEAGE EXAMPLES *
* -----------------
* Baseline effect with no affecting talents, or spells
* --
* parse_effects( warlock_base.affliction_warlock );
* --
****** This system CAN NOT handle buffs that modify other buffs and/or debuffs. ******
* Debuff
* --
* parse_target_effects( d_fn( &warlock_td_t::debuffs_t::fel_sunder ), talents.fell_sunder );
* --
* DoT
* --
* parse_target_effects( d_fn( &warlock_td_t::dots_t::unstable_affliction ), talents.unstable_affliction );
* --
* More advanced examples can be found in other modules that use this system.
* A few are sc_druid.cpp, sc_death_knight.cpp, and sc_demon_hunter.cpp
------------------------------------------------------------- */
void warlock_t::parse_player_effects()
{
// Shared
if ( !demonology() )
{
parse_effects( buffs.grimoire_of_sacrifice ); // 196099
}
// Affliction
if ( affliction() )
{
// Affliction Mastery
parse_effects( warlock_base.potent_afflictions ); // 77215
// Affliction Debuffs/DoTs
// NOTE: Shadow of Nathreza II (rank 2) only increases by 2% (as if it were rank 1) the
// effect #2 and #3 (pet and guardian damage) of the Haunt debuff damage bonus (bug)
parse_target_effects( d_fn( &warlock_td_t::debuffs_t::haunt ), talents.haunt );
}
// Demonology
if ( demonology() )
{
// Demonology Mastery
parse_effects( warlock_base.master_demonologist ); // 77219
// Demonology Buffs
parse_effects( buffs.hellbent_commander ); // 1281559
}
// Destruction
if ( destruction() )
{
}
// Diabolist
if ( diabolist() )
{
// Diabolist Buffs
parse_effects( buffs.abyssal_dominion ); // 456323