/
Unit.h
2660 lines (2283 loc) · 132 KB
/
Unit.h
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
/*
* This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* \addtogroup game
* @{
* \file
*/
#ifndef __UNIT_H
#define __UNIT_H
#include "Common.h"
#include "Object.h"
#include "Opcodes.h"
#include "SpellAuraDefines.h"
#include "UpdateFields.h"
#include "SharedDefines.h"
#include "ThreatManager.h"
#include "HostileRefManager.h"
#include "FollowerReference.h"
#include "FollowerRefManager.h"
#include "Utilities/EventProcessor.h"
#include "MotionMaster.h"
#include "DBCStructure.h"
#include "WorldPacket.h"
#include "Timer.h"
#include "AI/CreatureAI.h"
#include <list>
enum SpellInterruptFlags
{
SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01,
SPELL_INTERRUPT_FLAG_DAMAGE = 0x02,
SPELL_INTERRUPT_FLAG_INTERRUPT = 0x04,
SPELL_INTERRUPT_FLAG_AUTOATTACK = 0x08,
SPELL_INTERRUPT_FLAG_ABORT_ON_DMG = 0x10, // _complete_ interrupt on direct damage
// SPELL_INTERRUPT_UNK = 0x20 // unk, 564 of 727 spells having this spell start with "Glyph"
};
enum SpellChannelInterruptFlags
{
CHANNEL_FLAG_DAMAGE = 0x0002,
CHANNEL_FLAG_MOVEMENT = 0x0008,
CHANNEL_FLAG_TURNING = 0x0010,
CHANNEL_FLAG_DAMAGE2 = 0x0080,
CHANNEL_FLAG_DELAY = 0x4000
};
enum SpellAuraInterruptFlags
{
AURA_INTERRUPT_FLAG_UNK0 = 0x00000001, // 0 removed when getting hit by a negative spell?
AURA_INTERRUPT_FLAG_DAMAGE = 0x00000002, // 1 removed by any damage
AURA_INTERRUPT_FLAG_UNK2 = 0x00000004, // 2
AURA_INTERRUPT_FLAG_MOVE = 0x00000008, // 3 removed by any movement
AURA_INTERRUPT_FLAG_TURNING = 0x00000010, // 4 removed by any turning
AURA_INTERRUPT_FLAG_ENTER_COMBAT = 0x00000020, // 5 removed by entering combat
AURA_INTERRUPT_FLAG_NOT_MOUNTED = 0x00000040, // 6 removed by unmounting
AURA_INTERRUPT_FLAG_NOT_ABOVEWATER = 0x00000080, // 7 removed by entering water
AURA_INTERRUPT_FLAG_NOT_UNDERWATER = 0x00000100, // 8 removed by leaving water
AURA_INTERRUPT_FLAG_NOT_SHEATHED = 0x00000200, // 9 removed by unsheathing
AURA_INTERRUPT_FLAG_TALK = 0x00000400, // 10 talk to npc / loot? action on creature
AURA_INTERRUPT_FLAG_USE = 0x00000800, // 11 mine/use/open action on gameobject
AURA_INTERRUPT_FLAG_MELEE_ATTACK = 0x00001000, // 12 removed by attack
AURA_INTERRUPT_FLAG_UNK13 = 0x00002000, // 13
AURA_INTERRUPT_FLAG_UNK14 = 0x00004000, // 14
AURA_INTERRUPT_FLAG_UNK15 = 0x00008000, // 15 removed by casting a spell?
AURA_INTERRUPT_FLAG_UNK16 = 0x00010000, // 16
AURA_INTERRUPT_FLAG_MOUNTING = 0x00020000, // 17 removed by mounting
AURA_INTERRUPT_FLAG_NOT_SEATED = 0x00040000, // 18 removed by standing up (used by food and drink mostly and sleep/Fake Death like)
AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000, // 19 leaving map/getting teleported
AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION = 0x00100000, // 20 removed by auras that make you invulnerable, or make other to loose selection on you
AURA_INTERRUPT_FLAG_UNK21 = 0x00200000, // 21
AURA_INTERRUPT_FLAG_TELEPORTED = 0x00400000, // 22
AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT = 0x00800000, // 23 removed by entering pvp combat
AURA_INTERRUPT_FLAG_DIRECT_DAMAGE = 0x01000000, // 24 removed by any direct damage
AURA_INTERRUPT_FLAG_LANDING = 0x02000000, // 25 removed by hitting the ground or water
AURA_INTERRUPT_FLAG_UNK26 = 0x04000000, // 26
AURA_INTERRUPT_FLAG_DAMAGE2 = 0x08000000, // 27 removed by damage spells + removed by damage, other than .. (diseases, Censure)
AURA_INTERRUPT_FLAG_ENTER_COMBAT2 = 0x10000000, // 28
AURA_INTERRUPT_FLAG_UNK29 = 0x20000000, // 29
AURA_INTERRUPT_FLAG_UNK30 = 0x40000000, // 30
AURA_INTERRUPT_FLAG_LEAVE_COMBAT = 0x80000000, // 31 removed by leaving combat
};
enum SpellPartialResist
{
SPELL_PARTIAL_RESIST_NONE = 0, // 0%, full hit
SPELL_PARTIAL_RESIST_PCT_10, // 10%
SPELL_PARTIAL_RESIST_PCT_20, // 20%
SPELL_PARTIAL_RESIST_PCT_30, // 30%
SPELL_PARTIAL_RESIST_PCT_40, // 40%
SPELL_PARTIAL_RESIST_PCT_50, // 50%
SPELL_PARTIAL_RESIST_PCT_60, // 60%
SPELL_PARTIAL_RESIST_PCT_70, // 70%
SPELL_PARTIAL_RESIST_PCT_80, // 80%
SPELL_PARTIAL_RESIST_PCT_90, // 90%
SPELL_PARTIAL_RESIST_PCT_100, // 100%, full resist
};
#define NUM_SPELL_PARTIAL_RESISTS 11
enum SpellModOp
{
SPELLMOD_DAMAGE = 0,
SPELLMOD_DURATION = 1,
SPELLMOD_THREAT = 2,
SPELLMOD_EFFECT1 = 3,
SPELLMOD_CHARGES = 4,
SPELLMOD_RANGE = 5,
SPELLMOD_RADIUS = 6,
SPELLMOD_CRITICAL_CHANCE = 7,
SPELLMOD_ALL_EFFECTS = 8,
SPELLMOD_NOT_LOSE_CASTING_TIME = 9,
SPELLMOD_CASTING_TIME = 10,
SPELLMOD_COOLDOWN = 11,
SPELLMOD_EFFECT2 = 12,
// spellmod 13 unused
SPELLMOD_COST = 14,
SPELLMOD_CRIT_DAMAGE_BONUS = 15,
SPELLMOD_RESIST_MISS_CHANCE = 16,
SPELLMOD_JUMP_TARGETS = 17,
SPELLMOD_CHANCE_OF_SUCCESS = 18, // Only used with SPELL_AURA_ADD_FLAT_MODIFIER and affects proc spells
SPELLMOD_ACTIVATION_TIME = 19,
SPELLMOD_EFFECT_PAST_FIRST = 20,
SPELLMOD_GLOBAL_COOLDOWN = 21,
SPELLMOD_DOT = 22,
SPELLMOD_EFFECT3 = 23,
SPELLMOD_SPELL_BONUS_DAMAGE = 24,
// spellmod 25 unused
SPELLMOD_FREQUENCY_OF_SUCCESS = 26, // Only used with SPELL_AURA_ADD_PCT_MODIFIER and affects used on proc spells
SPELLMOD_MULTIPLE_VALUE = 27,
SPELLMOD_RESIST_DISPEL_CHANCE = 28,
SPELLMOD_SPELL_COST_REFUND_ON_FAIL = 30,
};
#define MAX_SPELLMOD 32
enum SpellFacingFlags
{
SPELL_FACING_FLAG_INFRONT = 0x0001
};
#define BASE_MELEERANGE_OFFSET 1.33f
#define BASE_MINDAMAGE 1.0f
#define BASE_MAXDAMAGE 2.0f
#define BASE_ATTACK_TIME 2000
#define BASE_BLOCK_DAMAGE_PERCENT 30
#define SCALE_SPELLPOWER_HEALING 1.88f
// byte value (UNIT_FIELD_BYTES_1,0)
enum UnitStandStateType
{
UNIT_STAND_STATE_STAND = 0,
UNIT_STAND_STATE_SIT = 1,
UNIT_STAND_STATE_SIT_CHAIR = 2,
UNIT_STAND_STATE_SLEEP = 3,
UNIT_STAND_STATE_SIT_LOW_CHAIR = 4,
UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5,
UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6,
UNIT_STAND_STATE_DEAD = 7,
UNIT_STAND_STATE_KNEEL = 8,
UNIT_STAND_STATE_CUSTOM = 9 // Depends on model animation. Submerge, freeze, hide, hibernate, rest
};
#define MAX_UNIT_STAND_STATE 10
// byte flags value (UNIT_FIELD_BYTES_1,1)
// This corresponds to free talent points (pet case)
// byte flags value (UNIT_FIELD_BYTES_1,2)
enum UnitStandFlags
{
UNIT_STAND_FLAGS_UNK1 = 0x01,
UNIT_STAND_FLAGS_CREEP = 0x02,
UNIT_STAND_FLAGS_UNK3 = 0x04,
UNIT_STAND_FLAGS_UNK4 = 0x08,
UNIT_STAND_FLAGS_UNK5 = 0x10,
UNIT_STAND_FLAGS_ALL = 0xFF
};
// byte flags value (UNIT_FIELD_BYTES_1,3)
enum UnitBytes1_Flags
{
UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01,
UNIT_BYTE1_FLAG_FLY_ANIM = 0x02, // Creature that can fly and are not on the ground appear to have this flag. If they are on the ground, flag is not present.
UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04,
UNIT_BYTE1_FLAG_ALL = 0xFF
};
// byte value (UNIT_FIELD_BYTES_2,0) // TODO - solve conflicting with SharedDefines.h enum SheathTypes
enum SheathState
{
SHEATH_STATE_UNARMED = 0, // non prepared weapon
SHEATH_STATE_MELEE = 1, // prepared melee weapon
SHEATH_STATE_RANGED = 2 // prepared ranged weapon
};
#define MAX_SHEATH_STATE 3
// byte flags value (UNIT_FIELD_BYTES_2,1)
enum UnitPVPStateFlags
{
UNIT_BYTE2_FLAG_PVP = 0x01,
UNIT_BYTE2_FLAG_UNK1 = 0x02,
UNIT_BYTE2_FLAG_FFA_PVP = 0x04,
UNIT_BYTE2_FLAG_SUPPORTABLE = 0x08, // allows for being targeted for healing/bandaging by friendlies
UNIT_BYTE2_FLAG_AURAS = 0x10, // show possitive auras as positive, and allow its dispel
UNIT_BYTE2_FLAG_UNK5 = 0x20, // show negative auras as positive, *not* allowing dispel (at least for pets)
UNIT_BYTE2_FLAG_UNK6 = 0x40,
UNIT_BYTE2_FLAG_UNK7 = 0x80
};
// byte flags value (UNIT_FIELD_BYTES_2,2)
enum UnitRename
{
UNIT_CAN_BE_RENAMED = 0x01,
UNIT_CAN_BE_ABANDONED = 0x02,
};
// byte flags value (UNIT_FIELD_BYTES_2,3) See enum ShapeshiftForm in SharedDefines.h
#define CREATURE_MAX_SPELLS 10
enum Swing
{
NOSWING = 0,
SINGLEHANDEDSWING = 1,
TWOHANDEDSWING = 2
};
enum VictimState
{
VICTIMSTATE_UNAFFECTED = 0, // seen in relation with HITINFO_MISS
VICTIMSTATE_NORMAL = 1,
VICTIMSTATE_DODGE = 2,
VICTIMSTATE_PARRY = 3,
VICTIMSTATE_INTERRUPT = 4,
VICTIMSTATE_BLOCKS = 5,
VICTIMSTATE_EVADES = 6,
VICTIMSTATE_IS_IMMUNE = 7,
VICTIMSTATE_DEFLECTS = 8
};
enum HitInfo
{
HITINFO_NORMALSWING = 0x00000000,
HITINFO_UNK0 = 0x00000001, // req correct packet structure
HITINFO_NORMALSWING2 = 0x00000002,
HITINFO_LEFTSWING = 0x00000004,
HITINFO_UNK3 = 0x00000008,
HITINFO_MISS = 0x00000010,
HITINFO_ABSORB = 0x00000020, // absorbed damage
HITINFO_ABSORB2 = 0x00000040, // absorbed damage
HITINFO_RESIST = 0x00000080, // resisted atleast some damage
HITINFO_RESIST2 = 0x00000100, // resisted atleast some damage
HITINFO_CRITICALHIT = 0x00000200, // critical hit
// 0x00000400
// 0x00000800
// 0x00001000
HITINFO_BLOCK = 0x00002000, // blocked damage
// 0x00004000
// 0x00008000
HITINFO_GLANCING = 0x00010000,
HITINFO_CRUSHING = 0x00020000,
HITINFO_NOACTION = 0x00040000, // guessed
// 0x00080000
// 0x00100000
HITINFO_SWINGNOHITSOUND = 0x00200000, // guessed
// 0x00400000
HITINFO_UNK22 = 0x00800000
};
struct FactionTemplateEntry;
struct Modifier;
struct SpellEntry;
struct SpellEntryExt;
class Aura;
class SpellAuraHolder;
class Creature;
class Spell;
class DynamicObject;
class GameObject;
class Item;
class Pet;
class PetAura;
class Totem;
class VehicleInfo;
struct SpellImmune
{
uint32 type;
uint32 spellId;
};
typedef std::list<SpellImmune> SpellImmuneList;
enum UnitModifierType
{
BASE_VALUE = 0,
BASE_EXCLUSIVE = 1,
BASE_PCT = 2,
TOTAL_VALUE = 3,
TOTAL_PCT = 4,
MODIFIER_TYPE_END = 5
};
enum WeaponDamageRange
{
MINDAMAGE,
MAXDAMAGE
};
enum DamageTypeToSchool
{
RESISTANCE,
DAMAGE_DEALT,
DAMAGE_TAKEN
};
enum AuraRemoveMode
{
AURA_REMOVE_BY_DEFAULT,
AURA_REMOVE_BY_STACK, // at replace by similar aura
AURA_REMOVE_BY_CANCEL,
AURA_REMOVE_BY_DISPEL,
AURA_REMOVE_BY_DEATH,
AURA_REMOVE_BY_DELETE, // use for speedup and prevent unexpected effects at player logout/pet unsummon (must be used _only_ after save), delete.
AURA_REMOVE_BY_SHIELD_BREAK, // when absorb shield is removed by damage, heal absorb debuf
AURA_REMOVE_BY_EXPIRE, // at duration end
AURA_REMOVE_BY_TRACKING, // aura is removed because of a conflicting tracked aura
};
// Spell triggering settings for CastSpell that enable us to skip some checks so that we can investigate spell specific settings
enum TriggerCastFlags : uint32
{
TRIGGERED_NONE = 0x00000000, // Not Triggered
TRIGGERED_OLD_TRIGGERED = 0x00000001, // Legacy bool support TODO: Restrict usage as much as possible.
TRIGGERED_IGNORE_HIT_CALCULATION = 0x00000002, // Will ignore calculating hit in SpellHitResult
TRIGGERED_IGNORE_UNSELECTABLE_FLAG = 0x00000004, // Ignores UNIT_FLAG_NOT_SELECTABLE in CheckTarget
TRIGGERED_INSTANT_CAST = 0x00000008, // Will ignore any cast time set in spell entry
TRIGGERED_AUTOREPEAT = 0x00000010, // Will signal spell system that this is internal autorepeat call
TRIGGERED_IGNORE_UNATTACKABLE_FLAG = 0x00000020, // Ignores UNIT_FLAG_NOT_ATTACKABLE in CheckTarget
TRIGGERED_FULL_MASK = 0xFFFFFFFF
};
enum UnitMods
{
UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existing order, it's accessed by index values of Stats enum.
UNIT_MOD_STAT_AGILITY,
UNIT_MOD_STAT_STAMINA,
UNIT_MOD_STAT_INTELLECT,
UNIT_MOD_STAT_SPIRIT,
UNIT_MOD_HEALTH,
UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_ALTERNATIVE must be in existing order, it's accessed by index values of Powers enum.
UNIT_MOD_RAGE,
UNIT_MOD_FOCUS,
UNIT_MOD_ENERGY,
UNIT_MOD_HAPPINESS, // REQUIRED for fast indexing to work.
UNIT_MOD_RUNE,
UNIT_MOD_RUNIC_POWER,
UNIT_MOD_SOUL_SHARDS,
UNIT_MOD_ECLIPSE,
UNIT_MOD_HOLY_POWER,
UNIT_MOD_ALTERNATIVE,
UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existing order, it's accessed by index values of SpellSchools enum.
UNIT_MOD_RESISTANCE_HOLY,
UNIT_MOD_RESISTANCE_FIRE,
UNIT_MOD_RESISTANCE_NATURE,
UNIT_MOD_RESISTANCE_FROST,
UNIT_MOD_RESISTANCE_SHADOW,
UNIT_MOD_RESISTANCE_ARCANE,
UNIT_MOD_ATTACK_POWER,
UNIT_MOD_ATTACK_POWER_RANGED,
UNIT_MOD_DAMAGE_MAINHAND,
UNIT_MOD_DAMAGE_OFFHAND,
UNIT_MOD_DAMAGE_RANGED,
UNIT_MOD_END,
// synonyms
UNIT_MOD_STAT_START = UNIT_MOD_STAT_STRENGTH,
UNIT_MOD_STAT_END = UNIT_MOD_STAT_SPIRIT + 1,
UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR,
UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1,
UNIT_MOD_POWER_START = UNIT_MOD_MANA,
UNIT_MOD_POWER_END = UNIT_MOD_ALTERNATIVE + 1
};
static_assert(UNIT_MOD_POWER_END - UNIT_MOD_POWER_START == MAX_POWERS, "Power-related UnitMods are not updated.");
enum BaseModGroup
{
CRIT_PERCENTAGE,
RANGED_CRIT_PERCENTAGE,
OFFHAND_CRIT_PERCENTAGE,
SHIELD_BLOCK_DAMAGE_VALUE,
BASEMOD_END
};
enum BaseModType
{
FLAT_MOD,
PCT_MOD,
MOD_END
};
enum DeathState
{
ALIVE = 0, // show as alive
JUST_DIED = 1, // temporary state at die, for creature auto converted to CORPSE, for player at next update call
CORPSE = 2, // corpse state, for player this also meaning that player not leave corpse
DEAD = 3, // for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state
JUST_ALIVED = 4, // temporary state at resurrection, for creature auto converted to ALIVE, for player at next update call
};
// internal state flags for some auras and movement generators, other.
enum UnitState
{
// persistent state (applied by aura/etc until expire)
UNIT_STAT_MELEE_ATTACKING = 0x00000001, // unit is melee attacking someone Unit::Attack
UNIT_STAT_ATTACK_PLAYER = 0x00000002, // unit attack player or player's controlled unit and have contested pvpv timer setup, until timer expire, combat end and etc
UNIT_STAT_DIED = 0x00000004, // Unit::SetFeignDeath
UNIT_STAT_STUNNED = 0x00000008, // Aura::HandleAuraModStun
UNIT_STAT_ROOT = 0x00000010, // Aura::HandleAuraModRoot
UNIT_STAT_ISOLATED = 0x00000020, // area auras do not affect other players, Aura::HandleAuraModSchoolImmunity
UNIT_STAT_CONTROLLED = 0x00000040, // Aura::HandleAuraModPossess
// persistent movement generator state (all time while movement generator applied to unit (independent from top state of movegen)
UNIT_STAT_TAXI_FLIGHT = 0x00000080, // player is in flight mode (in fact interrupted at far teleport until next map telport landing)
UNIT_STAT_DISTRACTED = 0x00000100, // DistractedMovementGenerator active
// persistent movement generator state with non-persistent mirror states for stop support
// (can be removed temporary by stop command or another movement generator apply)
// not use _MOVE versions for generic movegen state, it can be removed temporary for unit stop and etc
UNIT_STAT_CONFUSED = 0x00000200, // ConfusedMovementGenerator active/onstack
UNIT_STAT_CONFUSED_MOVE = 0x00000400,
UNIT_STAT_ROAMING = 0x00000800, // RandomMovementGenerator/PointMovementGenerator/WaypointMovementGenerator active (now always set)
UNIT_STAT_ROAMING_MOVE = 0x00001000,
UNIT_STAT_CHASE = 0x00002000, // ChaseMovementGenerator active
UNIT_STAT_CHASE_MOVE = 0x00004000,
UNIT_STAT_FOLLOW = 0x00008000, // FollowMovementGenerator active
UNIT_STAT_FOLLOW_MOVE = 0x00010000,
UNIT_STAT_FLEEING = 0x00020000, // FleeMovementGenerator/TimedFleeingMovementGenerator active/onstack
UNIT_STAT_FLEEING_MOVE = 0x00040000,
// More room for other MMGens
// High-Level states (usually only with Creatures)
UNIT_STAT_NO_COMBAT_MOVEMENT = 0x01000000, // Combat Movement for MoveChase stopped
UNIT_STAT_RUNNING = 0x02000000, // SetRun for waypoints and such
UNIT_STAT_WAYPOINT_PAUSED = 0x04000000, // Waypoint-Movement paused genericly (ie by script)
UNIT_STAT_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator
// masks (only for check)
// can't move currently
UNIT_STAT_CAN_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED,
// stay by different reasons
UNIT_STAT_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
UNIT_STAT_DISTRACTED,
// stay or scripted movement for effect( = in player case you can't move by client command)
UNIT_STAT_NO_FREE_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
UNIT_STAT_TAXI_FLIGHT |
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
// not react at move in sight or other
UNIT_STAT_CAN_NOT_REACT = UNIT_STAT_STUNNED | UNIT_STAT_DIED |
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
// AI disabled by some reason
UNIT_STAT_LOST_CONTROL = UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_CONTROLLED,
// above 2 state cases
UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL = UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_LOST_CONTROL,
// masks (for check or reset)
// for real move using movegen check and stop (except unstoppable flight)
UNIT_STAT_MOVING = UNIT_STAT_ROAMING_MOVE | UNIT_STAT_CHASE_MOVE | UNIT_STAT_FOLLOW_MOVE | UNIT_STAT_FLEEING_MOVE,
UNIT_STAT_RUNNING_STATE = UNIT_STAT_CHASE_MOVE | UNIT_STAT_FLEEING_MOVE | UNIT_STAT_RUNNING,
UNIT_STAT_ALL_STATE = 0xFFFFFFFF,
UNIT_STAT_ALL_DYN_STATES = UNIT_STAT_ALL_STATE & ~(UNIT_STAT_NO_COMBAT_MOVEMENT | UNIT_STAT_RUNNING | UNIT_STAT_WAYPOINT_PAUSED | UNIT_STAT_IGNORE_PATHFINDING),
};
enum UnitMoveType
{
MOVE_WALK = 0,
MOVE_RUN = 1,
MOVE_RUN_BACK = 2,
MOVE_SWIM = 3,
MOVE_SWIM_BACK = 4,
MOVE_TURN_RATE = 5,
MOVE_FLIGHT = 6,
MOVE_FLIGHT_BACK = 7,
MOVE_PITCH_RATE = 8
};
#define MAX_MOVE_TYPE 9
enum CombatRating
{
CR_WEAPON_SKILL = 0,
CR_DEFENSE_SKILL = 1, // obsolete
CR_DODGE = 2,
CR_PARRY = 3,
CR_BLOCK = 4,
CR_HIT_MELEE = 5,
CR_HIT_RANGED = 6,
CR_HIT_SPELL = 7,
CR_CRIT_MELEE = 8,
CR_CRIT_RANGED = 9,
CR_CRIT_SPELL = 10,
CR_HIT_TAKEN_MELEE = 11, // obsolete
CR_HIT_TAKEN_RANGED = 12, // obsolete
CR_HIT_TAKEN_SPELL = 13, // obsolete
CR_CRIT_TAKEN_MELEE = 14, // COMBAT_RATING_RESILIENCE_CRIT_TAKEN obsolete
CR_RESILIENCE_DAMAGE_TAKEN = 15, // old CR_CRIT_TAKEN_RANGED
CR_CRIT_TAKEN_SPELL = 16, // obsolete
CR_HASTE_MELEE = 17,
CR_HASTE_RANGED = 18,
CR_HASTE_SPELL = 19,
CR_WEAPON_SKILL_MAINHAND = 20, // obsolete
CR_WEAPON_SKILL_OFFHAND = 21, // obsolete
CR_WEAPON_SKILL_RANGED = 22, // obsolete
CR_EXPERTISE = 23,
CR_ARMOR_PENETRATION = 24,
CR_MASTERY = 25
};
#define MAX_COMBAT_RATING 26
/// internal used flags for marking special auras - for example some dummy-auras
enum UnitAuraFlags
{
UNIT_AURAFLAG_ALIVE_INVISIBLE = 0x1, // aura which makes unit invisible for alive
};
enum UnitVisibility
{
VISIBILITY_OFF = 0, // absolute, not detectable, GM-like, can see all other
VISIBILITY_ON = 1,
VISIBILITY_GROUP_STEALTH = 2, // detect chance, seen and can see group members
VISIBILITY_GROUP_INVISIBILITY = 3, // invisibility, can see and can be seen only another invisible unit or invisible detection unit, set only if not stealthed, and in checks not used (mask used instead)
VISIBILITY_GROUP_NO_DETECT = 4, // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break
VISIBILITY_REMOVE_CORPSE = 5 // special totally not detectable visibility for force delete object while removing a corpse
};
// Value masks for UNIT_FIELD_FLAGS
enum UnitFlags
{
UNIT_FLAG_UNK_0 = 0x00000001,
UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable
UNIT_FLAG_DISABLE_MOVE = 0x00000004,
UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state
UNIT_FLAG_RENAME = 0x00000010,
UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP
UNIT_FLAG_UNK_6 = 0x00000040,
UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE
UNIT_FLAG_OOC_NOT_ATTACKABLE = 0x00000100, // 2.0.8 - (OOC Out Of Combat) Can not be attacked when not in combat. Removed if unit for some reason enter combat (flag probably removed for the attacked and it's party/group only)
UNIT_FLAG_PASSIVE = 0x00000200, // makes you unable to attack everything. Almost identical to our "civilian"-term. Will ignore it's surroundings and not engage in combat unless "called upon" or engaged by another unit.
UNIT_FLAG_LOOTING = 0x00000400, // loot animation
UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8
UNIT_FLAG_PVP = 0x00001000, // changed in 3.0.3
UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1
UNIT_FLAG_UNK_14 = 0x00004000, // 2.0.8
UNIT_FLAG_UNK_15 = 0x00008000, // related to jerky movement in water?
UNIT_FLAG_UNK_16 = 0x00010000, // removes attackable icon
UNIT_FLAG_PACIFIED = 0x00020000, // 3.0.3 ok
UNIT_FLAG_STUNNED = 0x00040000, // 3.0.3 ok
UNIT_FLAG_IN_COMBAT = 0x00080000,
UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag
UNIT_FLAG_DISARMED = 0x00200000, // 3.0.3, disable melee spells casting..., "Required melee weapon" added to melee spells tooltip.
UNIT_FLAG_CONFUSED = 0x00400000,
UNIT_FLAG_FLEEING = 0x00800000,
UNIT_FLAG_POSSESSED = 0x01000000, // remote control e.g. Eyes of the Beast: let master use melee attack, make unit unselectable via mouse for master in world (as if it was own character)
UNIT_FLAG_NOT_SELECTABLE = 0x02000000,
UNIT_FLAG_SKINNABLE = 0x04000000,
UNIT_FLAG_MOUNT = 0x08000000,
UNIT_FLAG_UNK_28 = 0x10000000,
UNIT_FLAG_UNK_29 = 0x20000000, // used in Feing Death spell
UNIT_FLAG_SHEATHE = 0x40000000,
UNIT_FLAG_UNK_31 = 0x80000000 // set skinnable icon and also changes color of portrait
};
// Value masks for UNIT_FIELD_FLAGS_2
enum UnitFlags2
{
UNIT_FLAG2_FEIGN_DEATH = 0x00000001,
UNIT_FLAG2_UNK1 = 0x00000002, // Hides body and body armor. Weapons and shoulder and head armor still visible
UNIT_FLAG2_UNK2 = 0x00000004,
UNIT_FLAG2_COMPREHEND_LANG = 0x00000008,
UNIT_FLAG2_CLONED = 0x00000010, // Used in SPELL_AURA_MIRROR_IMAGE
UNIT_FLAG2_UNK5 = 0x00000020,
UNIT_FLAG2_FORCE_MOVE = 0x00000040,
UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, // also shield case
UNIT_FLAG2_UNK8 = 0x00000100,
UNIT_FLAG2_UNK9 = 0x00000200,
UNIT_FLAG2_DISARM_RANGED = 0x00000400,
UNIT_FLAG2_REGENERATE_POWER = 0x00000800,
UNIT_FLAG2_WORGEN_TRANSFORM = 0x00080000, // transform to worgen
UNIT_FLAG2_WORGEN_TRANSFORM2 = 0x00100000, // transform to worgen, but less animation?
UNIT_FLAG2_WORGEN_TRANSFORM3 = 0x00200000 // transform to worgen, but less animation?
};
/// Non Player Character flags
enum NPCFlags
{
UNIT_NPC_FLAG_NONE = 0x00000000,
UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100%
UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok
UNIT_NPC_FLAG_UNK1 = 0x00000004,
UNIT_NPC_FLAG_UNK2 = 0x00000008,
UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100%
UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100%
UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100%
UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100%
UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor
UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100%
UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed
UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100%
UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100%
UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100%
UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed
UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed
UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100%
UNIT_NPC_FLAG_BANKER = 0x00020000, // 100%
UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions
UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100%
UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100%
UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100%
UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100%
UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode
UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click), dynamic, set at loading and don't must be set in DB
UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000, // players with mounts that have vehicle data should have it set
};
// used in most movement packets (send and received), 30 bits in client
enum MovementFlags
{
MOVEFLAG_NONE = 0x00000000,
MOVEFLAG_FORWARD = 0x00000001,
MOVEFLAG_BACKWARD = 0x00000002,
MOVEFLAG_STRAFE_LEFT = 0x00000004,
MOVEFLAG_STRAFE_RIGHT = 0x00000008,
MOVEFLAG_TURN_LEFT = 0x00000010,
MOVEFLAG_TURN_RIGHT = 0x00000020,
MOVEFLAG_PITCH_UP = 0x00000040,
MOVEFLAG_PITCH_DOWN = 0x00000080,
MOVEFLAG_WALK_MODE = 0x00000100, // Walking
MOVEFLAG_LEVITATING = 0x00000200,
MOVEFLAG_ROOT = 0x00000400,
MOVEFLAG_FALLING = 0x00000800,
MOVEFLAG_FALLINGFAR = 0x00001000,
MOVEFLAG_PENDINGSTOP = 0x00002000,
MOVEFLAG_PENDINGSTRAFESTOP = 0x00004000,
MOVEFLAG_PENDINGFORWARD = 0x00008000,
MOVEFLAG_PENDINGBACKWARD = 0x00010000,
MOVEFLAG_PENDINGSTRAFELEFT = 0x00020000,
MOVEFLAG_PENDINGSTRAFERIGHT = 0x00040000,
MOVEFLAG_PENDINGROOT = 0x00080000,
MOVEFLAG_SWIMMING = 0x00100000, // appears with fly flag also
MOVEFLAG_ASCENDING = 0x00200000, // swim up also
MOVEFLAG_DESCENDING = 0x00400000, // swim down also
MOVEFLAG_CAN_FLY = 0x00800000, // can fly in 3.3?
MOVEFLAG_FLYING = 0x01000000, // Actual flying mode
MOVEFLAG_SPLINE_ELEVATION = 0x02000000, // used for flight paths
MOVEFLAG_WATERWALKING = 0x04000000, // prevent unit from falling through water
MOVEFLAG_SAFE_FALL = 0x08000000, // active rogue safe fall spell (passive)
MOVEFLAG_HOVER = 0x10000000,
MOVEFLAG_LOCAL_DIRTY = 0x20000000,
};
// flags that use in movement check for example at spell casting
MovementFlags const movementFlagsMask = MovementFlags(
MOVEFLAG_FORWARD | MOVEFLAG_BACKWARD | MOVEFLAG_STRAFE_LEFT | MOVEFLAG_STRAFE_RIGHT |
MOVEFLAG_PITCH_UP | MOVEFLAG_PITCH_DOWN |
MOVEFLAG_FALLING | MOVEFLAG_FALLINGFAR | MOVEFLAG_ASCENDING |
MOVEFLAG_FLYING | MOVEFLAG_SPLINE_ELEVATION
);
MovementFlags const movementOrTurningFlagsMask = MovementFlags(
movementFlagsMask | MOVEFLAG_TURN_LEFT | MOVEFLAG_TURN_RIGHT
);
// 12 bits in client
enum MovementFlags2
{
MOVEFLAG2_NONE = 0x0000,
MOVEFLAG2_NO_STRAFE = 0x0001,
MOVEFLAG2_NO_JUMPING = 0x0002,
MOVEFLAG2_FULLSPEEDTURNING = 0x0004,
MOVEFLAG2_FULLSPEEDPITCHING = 0x0008,
MOVEFLAG2_ALLOW_PITCHING = 0x0010,
MOVEFLAG2_UNK4 = 0x0020,
MOVEFLAG2_UNK5 = 0x0040,
MOVEFLAG2_UNK6 = 0x0080, // transport related
MOVEFLAG2_UNK7 = 0x0100,
MOVEFLAG2_INTERP_MOVEMENT = 0x0200,
MOVEFLAG2_INTERP_TURNING = 0x0400,
MOVEFLAG2_INTERP_PITCHING = 0x0800,
MOVEFLAG2_INTERP_MASK = MOVEFLAG2_INTERP_MOVEMENT | MOVEFLAG2_INTERP_TURNING | MOVEFLAG2_INTERP_PITCHING
};
class MovementInfo
{
public:
MovementInfo() : moveFlags(MOVEFLAG_NONE), moveFlags2(MOVEFLAG2_NONE), time(0),
t_time(0), t_seat(-1), t_time2(0), s_pitch(0.0f), fallTime(0), splineElevation(0.0f), byteParam(0) {}
// Read/Write methods
void Read(ByteBuffer& data, Opcodes opcode);
void Write(ByteBuffer& data, Opcodes opcode) const;
// Movement flags manipulations
void AddMovementFlag(MovementFlags f) { moveFlags |= f; }
void RemoveMovementFlag(MovementFlags f) { moveFlags &= ~f; }
bool HasMovementFlag(MovementFlags f) const { return (moveFlags & f) != 0; }
bool HasMovementFlag2(MovementFlags2 f) const { return (moveFlags2 & f) != 0; }
MovementFlags GetMovementFlags() const { return MovementFlags(moveFlags); }
void SetMovementFlags(MovementFlags f) { moveFlags = f; }
MovementFlags2 GetMovementFlags2() const { return MovementFlags2(moveFlags2); }
void AddMovementFlags2(MovementFlags2 f) { moveFlags2 |= f; }
// Position manipulations
Position const* GetPos() const { return &pos; }
void SetTransportData(ObjectGuid guid, float x, float y, float z, float o, uint32 time, int8 seat)
{
t_guid = guid;
t_pos.x = x;
t_pos.y = y;
t_pos.z = z;
t_pos.o = o;
t_time = time;
t_seat = seat;
}
void ClearTransportData()
{
t_guid = ObjectGuid();
t_pos.x = 0.0f;
t_pos.y = 0.0f;
t_pos.z = 0.0f;
t_pos.o = 0.0f;
t_time = 0;
t_seat = -1;
}
ObjectGuid const& GetGuid() const { return guid; }
ObjectGuid const& GetGuid2() const { return guid2; }
ObjectGuid const& GetTransportGuid() const { return t_guid; }
Position const* GetTransportPos() const { return &t_pos; }
int8 GetTransportSeat() const { return t_seat; }
uint32 GetTransportTime() const { return t_time; }
uint32 GetTransportTime2() const { return t_time2; }
uint32 GetFallTime() const { return fallTime; }
int8 GetByteParam() const { return byteParam; }
void ChangeOrientation(float o) { pos.o = o; }
void ChangePosition(float x, float y, float z, float o) { pos.x = x; pos.y = y; pos.z = z; pos.o = o; }
void UpdateTime(uint32 _time) { time = _time; }
uint32 GetTime(){ return time; }
struct JumpInfo
{
JumpInfo() : velocity(0.f), sinAngle(0.f), cosAngle(0.f), xyspeed(0.f) {}
float velocity, sinAngle, cosAngle, xyspeed;
};
// used only for SMSG_PLAYER_MOVE currently
struct StatusInfo
{
StatusInfo() : hasFallData(false), hasFallDirection(false), hasOrientation(false),
hasPitch(false), hasSpline(false), hasSplineElevation(false),
hasTimeStamp(false), hasTransportTime2(false), hasTransportTime3(false) { }
bool hasFallData : 1;
bool hasFallDirection : 1;
bool hasOrientation : 1;
bool hasPitch : 1;
bool hasSpline : 1;
bool hasSplineElevation : 1;
bool hasTimeStamp : 1;
bool hasTransportTime2 : 1;
bool hasTransportTime3 : 1;
};
JumpInfo const& GetJumpInfo() const { return jump; }
StatusInfo const& GetStatusInfo() const { return si; }
float GetSplineElevation() const { return splineElevation; }
float GetPitch() const { return s_pitch; }
private:
// common
ObjectGuid guid;
ObjectGuid guid2;
uint32 moveFlags; // see enum MovementFlags
uint16 moveFlags2; // see enum MovementFlags2
uint32 time;
Position pos;
// transport
ObjectGuid t_guid;
Position t_pos;
uint32 t_time;
int8 t_seat;
uint32 t_time2;
// swimming and flying
float s_pitch;
// last fall time
uint32 fallTime;
// jumping
JumpInfo jump;
// spline
float splineElevation;
// status info
StatusInfo si;
int8 byteParam;
};
inline WorldPacket& operator<< (WorldPacket& buf, MovementInfo const& mi)
{
mi.Write(buf, buf.GetOpcode());
return buf;
}
inline WorldPacket& operator>> (WorldPacket& buf, MovementInfo& mi)
{
mi.Read(buf, buf.GetOpcode());
return buf;
}
namespace Movement
{
class MoveSpline;
}
/**
* The different available diminishing return levels.
* \see DiminishingReturn
*/
enum DiminishingLevels
{
DIMINISHING_LEVEL_1 = 0, //< Won't make a difference to stun duration
DIMINISHING_LEVEL_2 = 1, //< Reduces stun time by 50%
DIMINISHING_LEVEL_3 = 2, //< Reduces stun time by 75%
DIMINISHING_LEVEL_IMMUNE = 3 //< The target is immune to the DiminishingGrouop
};
/**
* Structure to keep track of diminishing returns, for more information
* about the idea behind diminishing returns, see: http://www.wowwiki.com/Diminishing_returns
* \see Unit::GetDiminishing
* \see Unit::IncrDiminishing
* \see Unit::ApplyDiminishingToDuration
* \see Unit::ApplyDiminishingAura
*/
struct DiminishingReturn
{
DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count)
: DRGroup(group), stack(0), hitTime(t), hitCount(count)
{}
/**
* Group that this diminishing return will affect
*/
DiminishingGroup DRGroup: 16;
/**
* Seems to be how many times this has been stacked, modified in
* Unit::ApplyDiminishingAura
*/
uint16 stack: 16;
/**
* Records at what time the last hit with this DiminishingGroup was done, if it's
* higher than 15 seconds (ie: 15 000 ms) the DiminishingReturn::hitCount will be reset
* to DiminishingLevels::DIMINISHING_LEVEL_1, which will do no difference to the duration
* of the stun etc.
*/
uint32 hitTime;
/**
* Records how many times a spell of this DiminishingGroup has hit, this in turn
* decides how how long the duration of the stun etc is.
*/
uint32 hitCount;
};
// At least some values expected fixed and used in auras field, other custom
enum MeleeHitOutcome
{
MELEE_HIT_EVADE = 0,
MELEE_HIT_MISS = 1,
MELEE_HIT_DODGE = 2, // used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_BLOCK = 3, // used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_PARRY = 4, // used as misc in SPELL_AURA_IGNORE_COMBAT_RESULT
MELEE_HIT_GLANCING = 5,
MELEE_HIT_CRIT = 6,
MELEE_HIT_CRUSHING = 7,
MELEE_HIT_NORMAL = 8,
};
enum UnitCombatDieSide
{
UNIT_COMBAT_DIE_MISS,
UNIT_COMBAT_DIE_RESIST,
UNIT_COMBAT_DIE_DODGE,
UNIT_COMBAT_DIE_PARRY,
UNIT_COMBAT_DIE_DEFLECT,
UNIT_COMBAT_DIE_BLOCK,
UNIT_COMBAT_DIE_GLANCE,
UNIT_COMBAT_DIE_CRIT,
UNIT_COMBAT_DIE_CRUSH,
UNIT_COMBAT_DIE_HIT,
};
#define NUM_UNIT_COMBAT_DIE_SIDES (UNIT_COMBAT_DIE_HIT + 1)
// A little helper func for a nice attack table debug output
inline const char* UnitCombatDieSideText(UnitCombatDieSide side)
{
switch (side)
{
case UNIT_COMBAT_DIE_MISS: return "MISS";
case UNIT_COMBAT_DIE_RESIST: return "RESIST";
case UNIT_COMBAT_DIE_DODGE: return "DODGE";
case UNIT_COMBAT_DIE_PARRY: return "PARRY";
case UNIT_COMBAT_DIE_DEFLECT: return "DEFLECT";
case UNIT_COMBAT_DIE_BLOCK: return "BLOCK";
case UNIT_COMBAT_DIE_GLANCE: return "GLANCE";
case UNIT_COMBAT_DIE_CRIT: return "CRIT";
case UNIT_COMBAT_DIE_CRUSH: return "CRUSH";
case UNIT_COMBAT_DIE_HIT: return "HIT";
}
return "INVALID";
}
struct CleanDamage
{
CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {}
uint32 damage;
WeaponAttackType attackType;
MeleeHitOutcome hitOutCome;
};
// Struct for use in Unit::CalculateMeleeDamage
// Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode
struct CalcDamageInfo
{
Unit* attacker; // Attacker
Unit* target; // Target for damage
SpellSchoolMask damageSchoolMask;
uint32 damage;
uint32 absorb;
uint32 resist;
uint32 blocked_amount;
uint32 HitInfo;
uint32 TargetState;
// Helper
WeaponAttackType attackType; //
uint32 procAttacker;
uint32 procVictim;
uint32 procEx;
uint32 cleanDamage; // Used only for rage calculation
MeleeHitOutcome hitOutCome; // TODO: remove this field (need use TargetState)
};
// Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode
struct SpellNonMeleeDamage
{
SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, SpellSchoolMask _schoolMask)
: target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), schoolMask(_schoolMask),
absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0)
{}
Unit* target;
Unit* attacker;
uint32 SpellID;
uint32 damage;
SpellSchoolMask schoolMask;
uint32 absorb;
uint32 resist;
bool physicalLog;
bool unused;