-
Notifications
You must be signed in to change notification settings - Fork 762
Expand file tree
/
Copy pathaction.cpp
More file actions
5540 lines (4714 loc) · 170 KB
/
action.cpp
File metadata and controls
5540 lines (4714 loc) · 170 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
// ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to natehieter@gmail.com
// ==========================================================================
#include "action/action.hpp"
#include "action/action_callback.hpp"
#include "action/action_state.hpp"
#include "action/dot.hpp"
#include "buff/buff.hpp"
#include "dbc/data_enums.hh"
#include "dbc/dbc.hpp"
#include "dbc/sc_spell_info.hpp"
#include "player/action_priority_list.hpp"
#include "player/actor_target_data.hpp"
#include "player/pet.hpp"
#include "player/player.hpp"
#include "player/player_collected_data.hpp"
#include "player/player_event.hpp"
#include "player/stats.hpp"
#include "report/decorators.hpp"
#include "sim/cooldown.hpp"
#include "sim/cooldown_waste_data.hpp"
#include "sim/event.hpp"
#include "sim/expressions.hpp"
#include "sim/proc.hpp"
#include "sim/sim.hpp"
#include "util/generic.hpp"
#include "util/io.hpp"
#include "util/util.hpp"
#include <utility>
// ==========================================================================
// Action
// ==========================================================================
namespace
{ // anonymous namespace
/**
* Hack to bypass some of the full execution chain to be able to re-use normal actions with
* specialized execution modes (off gcd, cast while casting). Will directly execute the action
* (instead of going through schedule_execute processing), and parts of our execution chain where
* relevant (e.g., line cooldown, stats tracking, gcd triggering for cast while casting).
*/
void do_execute( action_t* action, execute_type type )
{
// Schedule off gcd or cast while casting ready event before the action executes.
// This prevents the action from scheduling ready events with non-zero delay
// (for example as a result of the cooldown thresholds update).
if ( type == execute_type::OFF_GCD )
{
action->player->schedule_off_gcd_ready( timespan_t::zero() );
}
else if ( type == execute_type::CAST_WHILE_CASTING )
{
action->player->schedule_cwc_ready( timespan_t::zero() );
}
// Check if the target has died or gone out of range between now and when this was queued
// If this is the case, we shouldn't continue with attempting to execute it
if ( !action->target_ready( action->target ) )
{
action->sim->print_debug( "{} skipping queued do_execute for {} due to failing target_ready() check", *action->player, *action );
}
else
{
if ( !action->quiet )
{
action->player->iteration_executed_foreground_actions++;
action->total_executions++;
action->player->sequence_add( action, action->target, [ action ]( std::string&, std::string& t_str ) {
t_str = action->target->name_str;
} );
}
action->execute();
action->line_cooldown->start();
// If the ability has a GCD, we need to start it
action->start_gcd();
}
if ( action->player->queueing == action )
{
action->player->queueing = nullptr;
}
}
struct queued_action_execute_event_t : public event_t
{
action_t* action;
execute_type type;
queued_action_execute_event_t( action_t* a, timespan_t t, execute_type type_ )
: event_t( *a->sim, t ), action( a ), type( type_ )
{ }
const char* name() const override
{ return "Queued-Action-Execute"; }
void execute() override
{
action->queue_event = nullptr;
// Sanity check assert to catch violations. Will only trigger (if ever) with off gcd actions,
// and even then only in the case of bugs.
assert( action->cooldown->ready <= sim().current_time() );
// On very very rare occasions, charge-based cooldowns (which update through an event, but
// indicate readiness through cooldown_t::ready) can have their recharge event and the
// queued-action-execute event occur on the same timestamp in such a way that the events flip to
// the wrong order (queued-action-execute comes before recharge event). If this is the case, we
// need to flip them around to ensure that the sim internal state checks do not fail. The
// solution is to simply recreate the queued-action-execute event on the same timestamp, which
// will once again flip the ordering (i.e., lets the recharge event occur first).
if ( action->cooldown->charges > 1 && action->cooldown->current_charge == 0 && action->cooldown->recharge_event &&
action->cooldown->recharge_event->remains() == timespan_t::zero() )
{
action->queue_event = make_event<queued_action_execute_event_t>( sim(), action, timespan_t::zero(), type );
// Note, processing ends here
return;
}
if ( type == execute_type::FOREGROUND )
{
player_t* actor = action->player;
if ( !action->ready() || !action->target_ready( action->target ) )
{
if ( action->starved_proc )
{
action->starved_proc->occur();
}
actor->queueing = nullptr;
if ( !actor->readying )
{
actor->schedule_ready( actor->available() );
}
// This is an extremely rare event, only seen in a handful of specs with abilities on cooldown that have
// conditional activation requirements or dynamic cost adjustments.
if ( action->queue_failed_proc )
action->queue_failed_proc->occur();
actor->iteration_executed_foreground_actions--;
action->total_executions--;
// If it's the first iteration (where we capture sample sequence) adjust the captured sequence to indicate the
// queue failed
if ( ( sim().iterations <= 1 && sim().current_iteration == 0 ) ||
( sim().iterations > 1 && actor->nth_iteration() == 1 ) )
{
// Find the last action sequence entry that matches the current action
auto& seq = actor->collected_data.action_sequence;
auto it = std::find_if( seq.rbegin(), seq.rend(),
[ this ]( const player_collected_data_t::action_sequence_data_t& s ) {
return s.action == action && !s.queue_failed;
} );
if ( it != seq.rend() )
( *it ).queue_failed = true;
}
}
else
{
action->schedule_execute();
}
}
// Other execute types are specialized, and need separate handling
else
{
do_execute( action, type );
}
}
};
// Action Execute Event =====================================================
struct action_execute_event_t : public player_event_t
{
action_t* action;
action_state_t* execute_state;
bool has_cast_time;
action_execute_event_t( action_t* a, timespan_t time_to_execute, action_state_t* state = nullptr )
: player_event_t( *a->player, time_to_execute ),
action( a ),
execute_state( state ),
has_cast_time( time_to_execute > timespan_t::zero() )
{
if ( sim().debug )
{
sim().print_debug( "New Action Execute Event: {} {} time_to_execute={} (target={}, marker={})", *p(), *a,
time_to_execute, ( state ) ? state->target->name() : a->target->name(),
( a->marker ) ? a->marker : '0' );
}
}
const char* name() const override
{
return "Action-Execute";
}
#ifndef NDEBUG
const char* debug() const override { return action ? action->name() : name(); }
#endif
~action_execute_event_t() override
{
// Ensure we properly release the carried execute_state even if this event
// is never executed.
if ( execute_state )
{
action_state_t::release( execute_state );
}
}
void execute() override
{
player_t* target = action->target;
// Pass the carried execute_state to the action. This saves us a few
// cycles, as we don't need to make a copy of the state to pass to
// action -> pre_execute_state.
if ( execute_state )
{
target = execute_state->target;
action->pre_execute_state = execute_state;
execute_state = nullptr;
}
action->execute_event = nullptr;
// Note, presumes that if the action is instant, it will still be ready, since it was ready on
// the (near) previous event. Does check target sleepiness, since technically there can be
// several damage events on the same timestamp one of which will kill the target.
bool can_execute = true;
if ( has_cast_time )
can_execute = ( action->background || action->ready() ) && action->target_ready( target );
else
can_execute = !target->is_sleeping();
if ( sim().distance_targeting_enabled && !action->execute_targeting( action ) )
can_execute = false;
// If auto attacks are triggered during a channel, they are rescheduled normally but deal no damage
if ( !action->special && !action->proc && p()->channeling && p()->channeling->interrupt_auto_attack )
{
can_execute = false;
p()->procs.delayed_aa_channel->occur();
if ( action->repeating )
{
action->schedule_execute();
}
}
if ( can_execute )
{
// Action target must follow any potential pre-execute-state target if it differs from the
// current (default) target of the action.
action->set_target( target );
action->execute();
}
else
{
// Release assigned pre_execute_state, since we are not calling action->execute() (that does
// it automatically)
if ( action->pre_execute_state )
{
action_state_t::release( action->pre_execute_state );
action->pre_execute_state = nullptr;
}
}
assert( !action->pre_execute_state );
if ( action->background )
return;
if ( !p()->channeling )
{
if ( p()->readying )
{
throw sc_runtime_error( fmt::format(
"{} non-channeling {} is trying to overwrite player-ready-event upon execute.", *p(), *action ) );
}
p()->schedule_ready( timespan_t::zero() );
}
if ( p()->channeling )
{
p()->current_execute_type = execute_type::CAST_WHILE_CASTING;
p()->schedule_cwc_ready( timespan_t::zero() );
}
else if ( p()->gcd_ready > sim().current_time() )
{
// We are not channeling and there's still time left on GCD.
p()->current_execute_type = execute_type::OFF_GCD;
assert( p()->off_gcd == nullptr );
p()->schedule_off_gcd_ready( timespan_t::zero() );
}
}
};
} // unnamed namespace
action_t::options_t::options_t()
: moving( -1 ),
wait_on_ready( -1 ),
max_cycle_targets(),
target_number(),
interrupt(),
chain(),
cycle_targets(),
cycle_players(),
interrupt_immediate(),
if_expr_str(),
target_if_str(),
interrupt_if_expr_str(),
early_chain_if_expr_str(),
cancel_if_expr_str(),
sync_str(),
target_str()
{
}
action_t::action_t( action_e ty, util::string_view token, player_t* p )
: action_t(ty, token, p, spell_data_t::nil())
{
}
action_t::action_t( action_e ty, util::string_view token, player_t* p, const spell_data_t* s )
: s_data( s ? s : spell_data_t::nil() ),
s_data_reporting( spell_data_t::nil() ),
sim( p->sim ),
type( ty ),
name_str( util::tokenize_fn( token ) ),
name_str_reporting(),
player( p ),
target( p->target ),
item(),
weapon(),
default_target( p->target ),
school( SCHOOL_NONE ),
original_school( SCHOOL_NONE ),
id(),
internal_id( p->get_action_id( name_str ) ),
resource_current( RESOURCE_NONE ),
aoe(),
dual(),
callbacks( true ),
caster_callbacks( true ),
target_callbacks( true ),
suppress_caster_procs(),
suppress_target_procs(),
enable_proc_from_suppressed(),
allow_class_ability_procs(),
not_a_proc(),
special(),
channeled(),
apply_channel_lag( true ),
sequence(),
quiet(),
background(),
use_off_gcd(),
use_while_casting(),
usable_while_casting(),
can_have_one_button_penalty(),
cooldown_allow_casting_success( true ),
interrupt_auto_attack( true ),
reset_auto_attack(),
ignore_false_positive(),
action_skill( p->base.skill ),
direct_tick(),
treat_as_periodic(),
ignores_armor(),
repeating(),
harmful( true ),
proc(),
is_interrupt(),
is_precombat(),
initialized(),
may_hit( true ),
may_miss( true ),
may_dodge(),
may_parry(),
may_glance(),
may_block(),
may_crit(),
tick_may_crit(),
tick_zero(),
tick_on_application(),
hasted_ticks(),
consume_per_tick_(),
rolling_periodic(),
split_aoe_damage(),
reduced_aoe_targets( 0.0 ),
full_amount_targets( 0 ),
normalize_weapon_speed(),
ground_aoe(),
round_base_dmg( true ),
dynamic_tick_action( true ), // WoD updates everything on tick by default. If you need snapshotted values for a
// periodic effect, use persistent multipliers.
track_cd_waste(),
cd_waste_data(),
interrupt_immediate_occurred(),
hit_any_target(),
crit_any_target(),
ground_aoe_duration( timespan_t::zero() ),
ap_type( attack_power_type::NONE ),
dot_behavior( DOT_REFRESH_DURATION ),
ability_lag( 0_ms, 0_ms ),
min_gcd(),
gcd_type( gcd_haste_type::NONE ),
trigger_gcd( p->base_gcd ),
range( -1.0 ),
radius( -1.0 ),
weapon_power_mod(),
attack_power_mod(),
spell_power_mod(),
amount_delta(),
base_execute_time(),
base_tick_time(),
dot_duration(),
hasted_dot_duration(),
dot_max_stack( 1 ),
dot_ignore_stack(),
base_costs(),
max_base_costs(),
base_costs_per_tick(),
base_dd_min(),
base_dd_max(),
base_td(),
base_dd_multiplier( 1.0 ),
base_td_multiplier( 1.0 ),
base_multiplier( 1.0 ),
base_hit(),
base_crit(),
crit_chance_multiplier( 1.0 ),
base_crit_bonus(),
crit_bonus_multiplier( 1.0 ),
base_dd_adder(),
base_td_adder(),
weapon_multiplier( 0.0 ),
chain_multiplier( 1.0 ),
chain_bonus_damage(),
base_aoe_multiplier( 1.0 ),
base_recharge_multiplier( 1.0 ),
base_recharge_rate_multiplier( 1.0 ),
dynamic_recharge_multiplier( 1.0 ),
dynamic_recharge_rate_multiplier( 1.0 ),
base_teleport_distance(),
travel_speed(),
travel_delay(),
min_travel_time(),
energize_amount(),
movement_directionality( movement_direction_type::NONE ),
parent_dot(),
child_action(),
tick_action(),
execute_action(),
impact_action(),
gain( p->get_gain( name_str ) ),
energize_type( action_energize::NONE ),
energize_resource( RESOURCE_NONE ),
cooldown( p->get_cooldown( name_str, this ) ),
internal_cooldown( p->get_cooldown( name_str + "_internal", this ) ),
stats( p->get_stats( name_str, this ) ),
execute_event(),
queue_event(),
time_to_execute(),
time_to_travel(),
last_resource_cost(),
num_targets_hit(),
marker(),
last_used(),
option(),
interrupt_global(),
if_expr(),
target_if_mode( TARGET_IF_NONE ),
target_if_expr(),
interrupt_if_expr(),
early_chain_if_expr(),
cancel_if_expr( nullptr ),
sync_action(),
signature_str(),
target_specific_dot( false ),
target_specific_debuff( false ),
target_debuff( spell_data_t::nil() ),
action_list(),
starved_proc(),
queue_failed_proc(),
total_executions(),
line_cooldown( new cooldown_t( "line_cd", *p ) ),
signature(),
execute_state(),
pre_execute_state(),
snapshot_flags(),
update_flags( STATE_TGT_MUL_DA | STATE_TGT_MUL_TA | STATE_TGT_CRIT ),
target_cache(),
options(),
state_cache(),
travel_events()
{
assert( option.cycle_targets == 0 );
assert( !name_str.empty() && "Abilities must have valid name_str entries!!" );
if ( sim->initialized && player->nth_iteration() > 0 )
{
sim->error( "{} {} created after simulator initialization.", *player, *this );
}
if ( player->nth_iteration() > 0 )
{
sim->error( "{} creating {} ouside of the first iteration", *player, *this );
assert( false );
}
if ( sim->debug )
sim->print_debug( "{} creates {}", *player, *this );
if ( !player->initialized )
{
throw sc_initialization_error( fmt::format( "{} being created before player_t::init().", *this ) );
}
player->action_list.push_back( this );
if ( data().ok() )
{
parse_spell_data( data() );
}
if ( s_data == spell_data_t::not_found() )
{
// this is super-spammy, may just want to disable this after we're sure this section is working as intended.
if ( sim->debug )
{
sim->error( "{} attempting to use {} without the meeting requirements, ignoring.", *player, *this );
}
background = true;
}
add_option( opt_string_warn( "if", option.if_expr_str ) );
add_option( opt_string_warn( "interrupt_if", option.interrupt_if_expr_str ) );
add_option( opt_string_warn( "early_chain_if", option.early_chain_if_expr_str ) );
add_option( opt_string_warn( "cancel_if", option.cancel_if_expr_str ) );
add_option( opt_bool( "interrupt", option.interrupt ) );
add_option( opt_bool( "interrupt_global", interrupt_global ) );
add_option( opt_bool( "chain", option.chain ) );
add_option( opt_bool( "cycle_targets", option.cycle_targets ) );
add_option( opt_bool( "cycle_players", option.cycle_players ) );
add_option( opt_int( "max_cycle_targets", option.max_cycle_targets ) );
add_option( opt_string_warn( "target_if", option.target_if_str ) );
add_option( opt_bool( "moving", option.moving ) );
add_option( opt_string( "sync", option.sync_str ) );
add_option( opt_bool( "wait_on_ready", option.wait_on_ready ) );
add_option( opt_string( "target", option.target_str ) );
add_option( opt_timespan( "line_cd", line_cooldown->duration ) );
add_option( opt_float( "action_skill", action_skill ) );
// Interrupt_immediate forces a channeled action to interrupt on tick (if requested), even if the
// GCD has not elapsed.
add_option( opt_bool( "interrupt_immediate", option.interrupt_immediate ) );
add_option( opt_bool( "use_off_gcd", use_off_gcd ) );
add_option( opt_bool( "use_while_casting", use_while_casting ) );
add_option( opt_string( "can_have_one_button_penalty", option.can_have_one_button_penalty_str ) );
add_option( opt_string( "cooldown_allow_casting_success", option.cooldown_allow_casting_success_str ) );
}
action_t::~action_t()
{
delete execute_state;
delete pre_execute_state;
while ( state_cache != nullptr )
{
action_state_t* s = state_cache;
state_cache = s->next;
delete s;
}
}
static bool is_direct_damage_effect( const spelleffect_data_t& effect )
{
static constexpr effect_type_t types[] = {
E_HEAL, E_SCHOOL_DAMAGE, E_HEALTH_LEECH,
E_NORMALIZED_WEAPON_DMG, E_WEAPON_DAMAGE, E_WEAPON_PERCENT_DAMAGE
};
return range::contains( types, effect.type() );
}
static bool is_periodic_damage_effect( const spelleffect_data_t& effect )
{
static constexpr effect_subtype_t subtypes[] = {
A_PERIODIC_DAMAGE, A_PERIODIC_LEECH, A_PERIODIC_HEAL, A_PERIODIC_HEAL_PCT
};
return effect.type() == E_APPLY_AURA &&
range::contains( subtypes, effect.subtype() );
}
bool action_t::has_direct_damage_effect( const spell_data_t& spell )
{
return range::any_of( spell.effects(), is_direct_damage_effect );
}
bool action_t::has_periodic_damage_effect( const spell_data_t& spell )
{
return range::any_of( spell.effects(), is_periodic_damage_effect );
}
bool action_t::does_direct_damage() const
{
return has_direct_damage_effect( data() ) || base_dd_min > 0 || spell_power_mod.direct > 0 ||
attack_power_mod.direct > 0 || weapon_multiplier > 0;
}
bool action_t::does_periodic_damage() const
{
return has_periodic_damage_effect( data() ) ||
( ( base_td > 0 || spell_power_mod.tick > 0 || attack_power_mod.tick > 0 || rolling_periodic ) &&
dot_duration > 0_ms );
}
/**
* Parse spell data values and write them into corresponding action_t members.
*/
void action_t::parse_spell_data( const spell_data_t& spell_data )
{
assert( spell_data.ok() && "parse_spell_data: no spell to parse" );
id = spell_data.id();
base_execute_time = spell_data.cast_time();
range = spell_data.max_range();
travel_delay = spell_data.missile_delay();
min_travel_time = spell_data.missile_min_duration();
trigger_gcd = spell_data.gcd();
school = spell_data.get_school_type();
// non-abilities have hasted gcd by default
if ( ( !spell_data.flags( spell_attribute::SX_ABILITY ) &&
!spell_data.flags( spell_attribute::SX_RANGED_ABILITY ) ) ||
player->get_passive_value( spell_data, "hasted_gcd" )[ 1 ] )
{
// use actor's primary stat to determine attack or spell haste
if ( player->convert_hybrid_stat( STAT_STR_AGI_INT ) == STAT_INTELLECT )
{
gcd_type = gcd_haste_type::SPELL_CAST_SPEED;
}
else
{
// 1s gcd melee class abilities don't get hasted
if ( spell_data.dmg_class() == SPELL_TYPE_MELEE && spell_data.affected_by_label( 16 ) && trigger_gcd == 1_s )
gcd_type = gcd_haste_type::NONE;
else
gcd_type = gcd_haste_type::ATTACK_HASTE;
}
}
// parse attributes
suppress_caster_procs = spell_data.flags( spell_attribute::SX_SUPPRESS_CASTER_PROCS );
suppress_target_procs = spell_data.flags( spell_attribute::SX_SUPPRESS_TARGET_PROCS );
enable_proc_from_suppressed = spell_data.flags( spell_attribute::SX_ENABLE_PROCS_FROM_SUPPRESSED );
tick_may_crit = spell_data.flags( spell_attribute::SX_TICK_MAY_CRIT );
// check for either spell or melee haste flag. separate if distinction becomes relevant.
hasted_ticks = spell_data.flags( spell_attribute::SX_DOT_HASTED ) ||
spell_data.flags( spell_attribute::SX_DOT_HASTED_MELEE );
tick_on_application = spell_data.flags( spell_attribute::SX_TICK_ON_APPLICATION );
hasted_dot_duration = spell_data.flags( spell_attribute::SX_DURATION_HASTED );
rolling_periodic = spell_data.flags( spell_attribute::SX_ROLLING_PERIODIC );
treat_as_periodic = spell_data.flags( spell_attribute::SX_TREAT_AS_PERIODIC );
ignores_armor = spell_data.flags( spell_attribute::SX_TREAT_AS_PERIODIC ); // TODO: better way to parse this?
may_miss = !spell_data.flags( spell_attribute::SX_ALWAYS_HIT );
allow_class_ability_procs = spell_data.flags( spell_attribute::SX_ALLOW_CLASS_ABILITY_PROCS );
not_a_proc = spell_data.flags( spell_attribute::SX_NOT_A_PROC );
if ( spell_data.flags( spell_attribute::SX_REFRESH_EXTENDS_DURATION ) )
dot_behavior = dot_behavior_e::DOT_REFRESH_PANDEMIC;
if ( spell_data.flags( spell_attribute::SX_FIXED_TRAVEL_TIME ) )
travel_delay += spell_data.missile_speed();
else
travel_speed = spell_data.missile_speed();
if ( has_direct_damage_effect( spell_data ) )
may_crit = !spell_data.flags( spell_attribute::SX_CANNOT_CRIT );
if ( has_periodic_damage_effect( spell_data ) && spell_data.max_stacks() > 1 )
dot_max_stack = spell_data.max_stacks();
cooldown->duration = timespan_t::zero();
// Default Weapon Assignment
if ( spell_data.flags( spell_attribute::SX_REQ_MAIN_HAND ) )
{
weapon = &( player->main_hand_weapon );
}
else if ( spell_data.flags( spell_attribute::SX_REQ_OFF_HAND ) )
{
weapon = &( player->off_hand_weapon );
}
if ( spell_data.charge_cooldown() > timespan_t::zero() )
{
cooldown->category = true;
cooldown->duration = spell_data.charge_cooldown();
cooldown->charges = spell_data.charges();
if ( spell_data.internal_cooldown() > timespan_t::zero() )
internal_cooldown->duration = spell_data.internal_cooldown();
else if ( spell_data.cooldown() > timespan_t::zero() )
internal_cooldown->duration = spell_data.cooldown();
}
else if ( spell_data.cooldown() > timespan_t::zero() )
{
cooldown->duration = spell_data.cooldown();
}
if ( cooldown->duration != 0_ms && player->get_passive_value( spell_data, "hasted_cooldown" )[ 1 ] )
cooldown->hasted = true;
// -1 is uncapped, <-1 is "unknown", 1 is 'limit 1'
if ( spell_data.max_targets() == -1 || spell_data.max_targets() > 1 )
aoe = spell_data.max_targets();
for ( const auto& pd : spell_data.powers() )
{
if ( pd.aura_id() != 0 ) // check aura if exists
{
auto aura_spell = player->find_specialization_spell( pd.aura_id() );
if ( !aura_spell->ok() || !aura_spell->flags( SX_PASSIVE ) )
aura_spell = player->find_talent_spell( talent_tree::CLASS, pd.aura_id() );
if ( !aura_spell->ok() || !aura_spell->flags( SX_PASSIVE ) )
aura_spell = player->find_talent_spell( talent_tree::SPECIALIZATION, pd.aura_id() );
if ( !aura_spell->ok() || !aura_spell->flags( SX_PASSIVE ) )
aura_spell = player->find_talent_spell( talent_tree::HERO, pd.aura_id() );
if ( !aura_spell->ok() || !aura_spell->flags( SX_PASSIVE ) )
continue;
}
if ( resource_current == RESOURCE_NONE )
resource_current = pd.resource();
// no aura at all, or we have a matching aura
auto cost_array = player->get_passive_value( pd, "cost" );
if ( pd._cost != 0 || pd._pct_cost == 0 )
{
base_costs[ pd.resource() ] = cost_array;
}
else // use _pct_cost
{
base_costs[ pd.resource() ] =
floor( pd.cost() * player->resources.base[ pd.resource() ] * cost_array[ 2 ] );
}
max_base_costs[ pd.resource() ] = pd.max_cost();
if ( pd._cost_per_tick != 0 )
{
base_costs_per_tick[ pd.resource() ] = ( pd.cost_per_tick() + cost_array[ 1 ] ) * cost_array[ 2 ];
}
else if ( pd._pct_cost_per_tick != 0 )
{
base_costs_per_tick[ pd.resource() ] =
floor( pd.cost_per_tick() * player->resources.base[ pd.resource() ] * cost_array[ 2 ] );
}
else
{
base_costs_per_tick[ pd.resource() ] = 0.0;
}
}
// handle parsed base damage modifiers
auto base_dd_mod = player->get_passive_value( spell_data, "direct_damage" );
base_dd_adder += base_dd_mod[ 1 ];
base_dd_multiplier *= base_dd_mod[ 2 ];
auto base_td_mod = player->get_passive_value( spell_data, "periodic_damage" );
base_td_adder += base_td_mod[ 1 ];
base_td_multiplier *= base_td_mod[ 2 ];
// handle parsed crit modifiers
auto crit_mod = player->get_passive_value( spell_data, "crit" );
base_crit += crit_mod[ 1 ];
crit_chance_multiplier *= crit_mod[ 2 ];
auto crit_bonus_mod = player->get_passive_value( spell_data, "crit_bonus" );
base_crit_bonus += crit_bonus_mod[ 1 ];
crit_bonus_multiplier *= crit_bonus_mod[ 2 ];
// handle mechanic modifiers (currently only bleed is found in relevant spell data)
// as the effect (subtype 276) is player scoped, we call get_passive_player_value()
// only the spell's mechanic field is checked, the effect's mechanic field is not sufficient for this effect subtype
if ( spell_data.mechanic() )
{
auto mechanic_mul = player->get_passive_player_value( 1.0, "mechanic_damage_done", spell_data.mechanic() );
base_dd_multiplier *= mechanic_mul;
base_td_multiplier *= mechanic_mul;
}
for ( const spelleffect_data_t& ed : spell_data.effects() )
{
parse_effect_data( ed );
}
}
void action_t::parse_effect_direct_mods( const spelleffect_data_t& spelleffect_data, bool item_scaling )
{
spell_power_mod.direct = spelleffect_data.sp_coeff();
attack_power_mod.direct = spelleffect_data.ap_coeff();
amount_delta = spelleffect_data.m_delta();
if ( !item_scaling )
{
if ( !spelleffect_data.sp_coeff() && !spelleffect_data.ap_coeff() )
{
base_dd_min = spelleffect_data.min( player, player->level() );
base_dd_max = spelleffect_data.max( player, player->level() );
}
}
else
{
base_dd_min = spelleffect_data.min( item );
base_dd_max = spelleffect_data.max( item );
}
radius = spelleffect_data.radius_max();
}
void action_t::parse_effect_periodic_mods( const spelleffect_data_t& spelleffect_data, bool item_scaling )
{
spell_power_mod.tick = spelleffect_data.sp_coeff();
attack_power_mod.tick = spelleffect_data.ap_coeff();
if ( !item_scaling )
{
if ( !spelleffect_data.sp_coeff() && !spelleffect_data.ap_coeff() )
{
base_td = spelleffect_data.average( player, player->level() );
}
}
else
{
base_td = spelleffect_data.average( item );
}
radius = spelleffect_data.radius_max();
dot_ignore_stack = spelleffect_data.flags( spelleffect_attribute::EX_SUPPRESS_STACKING );
}
void action_t::parse_effect_period( const spelleffect_data_t& spelleffect_data )
{
if ( spelleffect_data.period() > timespan_t::zero() )
{
base_tick_time = player->get_passive_value( spelleffect_data, "period" );
dot_duration = player->get_passive_value( *spelleffect_data.spell(), "duration" );
}
}
// action_t::parse_effect_data ==============================================
void action_t::parse_effect_data( const spelleffect_data_t& spelleffect_data )
{
if ( !spelleffect_data.ok() )
{
return;
}
// Only use item level-based scaling if there's no max scaling level defined for the spell
bool item_scaling = item && data().max_scaling_level() == 0;
// Technically, there could be both a single target and an aoe effect in a single spell, but that
// probably will never happen.
if ( spelleffect_data.chain_target() > 1 )
{
aoe = spelleffect_data.chain_target();
chain_multiplier = spelleffect_data.chain_multiplier();
}
switch ( spelleffect_data.type() )
{
// Direct Damage
case E_SCHOOL_DAMAGE:
case E_HEALTH_LEECH:
parse_effect_direct_mods( spelleffect_data, item_scaling );
break;
case E_NORMALIZED_WEAPON_DMG:
normalize_weapon_speed = true;
SC_FALLTHROUGH;
case E_WEAPON_DAMAGE:
if ( weapon == nullptr )
{
weapon = &( player->main_hand_weapon );
}
base_dd_min = item_scaling ? spelleffect_data.min( item ) : spelleffect_data.min( player, player->level() );
base_dd_max = item_scaling ? spelleffect_data.max( item ) : spelleffect_data.max( player, player->level() );
radius = spelleffect_data.radius_max();
break;
case E_WEAPON_PERCENT_DAMAGE:
if ( weapon == nullptr )
{
weapon = &( player->main_hand_weapon );
}
weapon_multiplier = item_scaling ? spelleffect_data.min( item ) : spelleffect_data.min( player, player->level() );
radius = spelleffect_data.radius_max();
break;
// Dot
case E_PERSISTENT_AREA_AURA:
radius = spelleffect_data.radius_max();
if ( radius < 0 )
radius = spelleffect_data.radius();
break;
case E_APPLY_AURA:
switch ( spelleffect_data.subtype() )
{
case A_PERIODIC_DAMAGE:
case A_PERIODIC_LEECH:
parse_effect_periodic_mods( spelleffect_data, item_scaling );
SC_FALLTHROUGH;
case A_PERIODIC_ENERGIZE:
if ( spelleffect_data.subtype() == A_PERIODIC_ENERGIZE && energize_type == action_energize::NONE && spelleffect_data.period() > timespan_t::zero() )
{
energize_type = action_energize::PER_TICK;
energize_resource = spelleffect_data.resource_gain_type();
energize_amount = spelleffect_data.resource( energize_resource );
}
SC_FALLTHROUGH;
case A_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
case A_PERIODIC_HEALTH_FUNNEL:
case A_PERIODIC_MANA_LEECH:
case A_PERIODIC_DAMAGE_PERCENT:
case A_PERIODIC_DUMMY:
case A_PERIODIC_TRIGGER_SPELL:
parse_effect_period( spelleffect_data );
break;
case A_SCHOOL_ABSORB:
spell_power_mod.direct = spelleffect_data.sp_coeff();
attack_power_mod.direct = spelleffect_data.ap_coeff();
amount_delta = spelleffect_data.m_delta();
base_dd_min = item_scaling ? spelleffect_data.min( item ) : spelleffect_data.min( player, player->level() );
base_dd_max = item_scaling ? spelleffect_data.max( item ) : spelleffect_data.max( player, player->level() );
radius = spelleffect_data.radius_max();
break;
default:
break;
}
break;
case E_ENERGIZE:
if ( energize_type == action_energize::NONE )
{
energize_type = action_energize::ON_HIT;
energize_resource = spelleffect_data.resource_gain_type();
energize_amount = spelleffect_data.resource( energize_resource );
}
break;
case E_CREATE_AREA_TRIGGER: // Spawn Area Triggers
ground_aoe_duration = spelleffect_data.spell()->duration();
break;
default:
break;
}
}
// action_t::set_school =====================================================
void action_t::set_school( school_e new_school )
{
if ( school != new_school )
{
sim->print_debug( "{} changing school for {} from {} to {}", *player, *this, school, new_school );
school = new_school;
}
// Decompose school into base types. Note that if get_school() is overridden (e.g., to dynamically
// alter spell school), then base_schools must be manually updated, to cover the dynamic case.
base_schools.clear();
for ( school_e target_school = SCHOOL_ARCANE; target_school < SCHOOL_MAX_PRIMARY; ++target_school )
{
if ( dbc::is_school( new_school, target_school ) )
{
base_schools.push_back( target_school );
}
}
}
void action_t::set_school_override( school_e new_school )
{
assert( original_school == SCHOOL_NONE && "Cannot override a school that is already overridden." );
sim->print_debug( "{} adding school override for {} of {}", *player, *this, new_school );
original_school = get_school();
set_school( new_school );
}
void action_t::clear_school_override()
{
assert( original_school != SCHOOL_NONE && "No school override currently exists" );