summaryrefslogtreecommitdiff
path: root/docs/factiontemplate.md
blob: 6c456ea81ae221f9545ca885ed69c6144df48bef (plain)
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
---
redirect_from: "/FactionTemplate"
---

# FactionTemplate

**FactionTemplate.dbc**

[`Back-to:DBC`](dbc-index.md)

This DBC contains information on all of the individual factions. A faction entry from this DBC contains all of the needed data to calculate hostility, friendliness, or neutrality to any other faction in this DBC.

**IMPORTANT: These values are only used for the [creature\_template](creature_template) and [gameobject\_template](gameobject\_template) tables.**

## **Structure**

| Field Nb | Name                                     | Type             |
|----------|------------------------------------------|------------------|
| 1        | ID                                       | Int              |
| 2        | Name (Ref to [Faction.dbc](Faction.dbc)) | Int              |
| 4        | ourMask                                  | Bitmask (4 bits) |
| 5        | friendlyMask                             | Bitmask (4 bits) |
| 6        | hostileMask                              | Bitmask (4 bits) |
| 7-10     | enemyFactions                            | Int              |
| 11-14    | friendFactions                           | Int              |

# **Explanations & Calculations**

Each different entry has different relations towards any other faction.

The easiest calculation when calculating hostility or friendliness is to look at the Friend factions and Enemy factions columns in the table below. If our faction has the other faction's ID in the Enemy factions list, then it is hostile to that faction (at least). The same thing applies for a friendliness check on the Friend factions column.

If our faction doesn't have the other faction's ID in the enemy or friend faction list, then we'll have to get more complicated in calculating hostility or friendliness.

First, let's define the four faction groups:

| ID | Bit | Name                              |
|----|-----|-----------------------------------|
| 0  | 1   | All players (and pets)            |
| 1  | 2   | Alliance players (and their pets) |
| 2  | 4   | Horde players (and their pets)    |
| 3  | 8   | Monster (Not a player nor a pet)  |

The first mask (ourMask) defines what type of faction we are dealing with. Eg, faction 1 (PLAYER, Human) has 3 as ourMask; that means that it has the first two bits set so it classifies as both 'All players' and 'Alliance players'.

The second mask (friendlyMask) defines what faction groups this faction is friendly with. That means that if this field contains the bit for a faction group, then it is friendly with that faction. Eg, faction 5 (PLAYER, Undead) has 4 as friendlyMask; that means that it has the third bit set so it is friendly with 'Horde players'.

The third mask (hostileMask) defines what faction groups this faction is hostile with. This faction will be hostile to any faction group whose bit is set in this field. For example, let's examine the first two Stormwind factions. The first one (faction 11) has hostileMask 12. The binary representation of this is 1100, with the third and fourth bits set. The second Stormwind faction (faction 12) has hostileMask 4. The binary representation of this is 0100, with the third bit set. Applying the formulas to these two values, we can see that faction 11 is hostile to Horde players and also anything that is not a player while faction 12 is only hostile to Horde players. Faction 12 will not aggro any creature that is part of the monster faction group.

For the mathematically inclined, the basic formula to test for friendliness is

``` cpp
(friendlyMask & other.ourMask) != 0 
```

...where other is another faction. The same thing applies for hostility:

``` cpp
(hostileMask & other.ourMask) != 0
```

For the not so mathematically inclined, we'll have to compare two binary numbers. 
First, you will need to convert all of the masks to binary form with four digits; so 1 becomes 0001, 2 becomes 0010, 3 becomes 0011, etc.

Second, line up the friendlyMask or hostileMask value with the ourMask value. For example:

``` cpp
     1100 //hostileMask of faction 11
     1000 //ourMask of faction 14
```

Next, perform a logical 'AND' on the two numbers, the bottom one with the one on top and follow these rules:

-   1 and 1 is 1
-   1 and 0 is 0
-   0 and 1 is 0
-   0 and 0 is 0
    So, continuing our example:

```
    1100
    1000
    ----
    1000
```

Finally, check the result that you get with the value 0. Only 0000 will equal 0, anything else will not equal 0. If the result **'does not**' equal 0, then the faction is hostile/friendly to the other faction. In our example, it is obvious that we do not have 0 (we have 8 in fact if you convert to base 10 again), so faction 11 is hostile to faction 14 and will aggro it.

From all of the above calculations, we notice that if ourMask for a faction is 0 (that means 0000), it will be neutral to everything (not necessarily friendly). If the friendlyMask for a faction is 0, then it will never be friendly to anything or anyone (unless it has other faction IDs in the Friend factions column in the table below). Finally, if the hostileMask for a faction is 0, it will never be hostile to anything or anyone (again there may be exceptions in the Enemy factions column in the table below).

To summarize, you should follow these steps to calculate if faction A is hostile to faction B:

1.  Look for faction B in the Enemy faction list of faction A in the table below
    -   If found, then faction A is hostile to faction B and you can stop
    -   If not found, then continue with the next steps
2.  Look up hostileMask for faction A in table below
3.  Look up ourMask for faction B in table below
4.  Do the and (&) operation on the two values
    -   If the result is 0, then faction A is not hostile to faction B (but not necessarily friendly either)
    -   If the result is not 0, then faction A IS hostile to faction B

And these steps to calculate if faction A is friendly to faction B:

1.  Look for faction B in the Friend faction list of faction A in the table below
    -   If found, then faction A is friendly to faction B and you can stop
    -   If not found, then continue with the next steps
2.  Look up friendlyMask for faction A in table below
3.  Look up ourMask for faction B in table below
4.  Do the and (&) operation on the two values
    -   If the result is 0, then faction A is not friendly to faction B (but not necessarily hostile either)
    -   If the result is not 0, then faction A IS friendly to faction B

# **Content**

**Version is : 3.3.5a**

| ID   | Name                                | ourMask | friendlyMask | hostileMask | Enemy Factions      | Friend Factions   |
|------|-------------------------------------|---------|--------------|-------------|---------------------|-------------------|
| 1    | PLAYER, Human                       | 3       | 2            | 12          |                     |                   |
| 2    | PLAYER, Orc                         | 5       | 4            | 10          |                     |                   |
| 3    | PLAYER, Dwarf                       | 3       | 2            | 12          |                     |                   |
| 4    | PLAYER, Night Elf                   | 3       | 2            | 12          |                     |                   |
| 5    | PLAYER, Undead                      | 5       | 4            | 10          |                     |                   |
| 6    | PLAYER, Tauren                      | 5       | 4            | 10          |                     |                   |
| 7    | Creature                            | 0       | 0            | 0           |                     |                   |
| 10   | Escortee                            | 3       | 2            | 0           |                     |                   |
| 11   | Stormwind                           | 3       | 2            | 12          |                     |                   |
| 12   | Stormwind                           | 2       | 2            | 4           |                     | 72                |
| 14   | Monster                             | 8       | 0            | 1           |                     |                   |
| 15   | Creature                            | 0       | 0            | 0           |                     | 7                 |
| 16   | Monster                             | 8       | 0            | 1           |                     | 14                |
| 17   | Defias Brotherhood                  | 8       | 0            | 1           |                     | 15                |
| 18   | Murloc                              | 8       | 0            | 1           |                     | 19                |
| 19   | Gnoll - Redridge                    | 8       | 0            | 1           |                     | 17                |
| 20   | Gnoll - Riverpaw                    | 8       | 0            | 1           |                     | 16                |
| 21   | Undead, Scourge                     | 8       | 0            | 1           |                     | 20                |
| 22   | Beast - Spider                      | 8       | 0            | 1           |                     | 22                |
| 23   | Gnomeregan Exiles                   | 2       | 2            | 4           |                     |                   |
| 24   | Worgen                              | 8       | 0            | 1           |                     | 24                |
| 25   | Kobold                              | 8       | 0            | 0           |                     | 25                |
| 26   | Kobold                              | 8       | 0            | 1           |                     | 25                |
| 27   | Defias Brotherhood                  | 8       | 0            | 1           | 1                   | 15                |
| 28   | Troll, Bloodscalp                   | 8       | 0            | 1           |                     | 26                |
| 29   | Orgrimmar                           | 4       | 4            | 2           |                     |                   |
| 30   | Troll, Skullsplitter                | 8       | 0            | 1           |                     | 27                |
| 31   | Prey                                | 0       | 0            | 0           | 973                 | 148 28            |
| 32   | Beast - Wolf                        | 0       | 0            | 0           | 28                  |                   |
| 33   | Escortee                            | 5       | 4            | 0           |                     |                   |
| 34   | Defias Brotherhood                  | 8       | 0            | 0           |                     | 15                |
| 35   | Friendly                            | 0       | 1            | 0           |                     | 31                |
| 36   | Trogg                               | 0       | 0            | 0           |                     | 32                |
| 37   | Troll, Frostmane                    | 8       | 0            | 1           |                     | 33                |
| 38   | Beast - Wolf                        | 8       | 0            | 1           | 28                  | 29                |
| 39   | Gnoll - Shadowhide                  | 8       | 0            | 1           |                     | 18                |
| 40   | Orc, Blackrock                      | 8       | 0            | 1           |                     | 34                |
| 41   | Villian                             | 8       | 0            | 1           | 36                  | 35                |
| 42   | Victim                              | 1       | 1            | 0           |                     | 36                |
| 43   | Villian                             | 8       | 0            | 0           | 36                  | 35                |
| 44   | Beast - Bear                        | 8       | 0            | 1           |                     | 37                |
| 45   | Ogre                                | 8       | 0            | 1           |                     | 38                |
| 46   | Kurzen's Mercenaries                | 8       | 0            | 1           |                     | 39                |
| 47   | Venture Company                     | 8       | 0            | 1           |                     | 41                |
| 48   | Beast - Raptor                      | 8       | 0            | 1           |                     | 42                |
| 49   | Basilisk                            | 8       | 0            | 1           |                     | 43                |
| 50   | Dragonflight, Green                 | 8       | 0            | 1           |                     | 44                |
| 51   | Lost Ones                           | 8       | 0            | 1           | 46 40               | 45                |
| 52   | Gizlock's Dummy                     | 8       | 0            | 0           | 770                 |                   |
| 53   | Human, Night Watch                  | 2       | 2            | 12          |                     | 49                |
| 54   | Dark Iron Dwarves                   | 8       | 0            | 1           |                     | 48                |
| 55   | Ironforge                           | 2       | 2            | 4           |                     | 47                |
| 56   | Human, Night Watch                  | 2       | 2            | 12          |                     | 49                |
| 57   | Ironforge                           | 3       | 2            | 12          |                     |                   |
| 58   | Creature                            | 8       | 0            | 0           |                     |                   |
| 59   | Trogg                               | 8       | 0            | 1           |                     | 32                |
| 60   | Dragonflight, Red                   | 8       | 0            | 1           |                     | 50                |
| 61   | Gnoll - Mosshide                    | 8       | 0            | 1           |                     | 51                |
| 62   | Orc, Dragonmaw                      | 8       | 0            | 1           | 1015 932 934        | 52                |
| 63   | Gnome - Leper                       | 8       | 0            | 1           |                     | 53                |
| 64   | Gnomeregan Exiles                   | 2       | 2            | 4           |                     |                   |
| 65   | Orgrimmar                           | 0       | 0            | 0           | 45                  | 76                |
| 66   | Leopard                             | 8       | 0            | 1           | 28                  | 55                |
| 67   | Scarlet Crusade                     | 8       | 0            | 1           |                     | 56                |
| 68   | Undercity                           | 4       | 4            | 2           |                     |                   |
| 69   | Ratchet                             | 0       | 0            | 0           |                     | 470               |
| 70   | Gnoll - Rothide                     | 8       | 0            | 1           |                     | 57                |
| 71   | Undercity                           | 5       | 4            | 10          |                     |                   |
| 72   | Beast - Gorilla                     | 8       | 0            | 1           |                     | 58                |
| 73   | Beast - Carrion Bird                | 8       | 0            | 1           |                     | 669               |
| 74   | Naga                                | 8       | 0            | 1           | 289                 | 60                |
| 76   | Dalaran                             | 0       | 2            | 4           |                     | 61                |
| 77   | Forlorn Spirit                      | 8       | 0            | 0           |                     |                   |
| 78   | Darkhowl                            | 8       | 0            | 1           |                     |                   |
| 79   | Darnassus                           | 3       | 2            | 12          |                     |                   |
| 80   | Darnassus                           | 2       | 2            | 4           |                     | 69                |
| 81   | Grell                               | 8       | 0            | 1           |                     | 64                |
| 82   | Furbolg                             | 8       | 0            | 1           |                     | 65                |
| 83   | Horde Generic                       | 4       | 4            | 2           |                     |                   |
| 84   | Alliance Generic                    | 2       | 2            | 4           |                     |                   |
| 85   | Orgrimmar                           | 5       | 4            | 10          |                     |                   |
| 86   | Gizlock's Charm                     | 0       | 1            | 0           | 769                 | 771               |
| 87   | Syndicate                           | 8       | 0            | 1           |                     | 70                |
| 88   | Hillsbrad Militia                   | 2       | 2            | 4           |                     | 71                |
| 89   | Scarlet Crusade                     | 8       | 0            | 1           | 20                  | 56                |
| 90   | Demon                               | 8       | 0            | 1           |                     | 73                |
| 91   | Elemental                           | 8       | 0            | 1           |                     | 74                |
| 92   | Spirit                              | 8       | 0            | 1           |                     |                   |
| 93   | Monster                             | 8       | 0            | 1           |                     |                   |
| 94   | Treasure                            | 0       | 8            | 0           |                     |                   |
| 95   | Gnoll - Mudsnout                    | 8       | 0            | 1           |                     | 78                |
| 96   | HIllsbrad, Southshore Mayor         | 2       | 2            | 0           |                     |                   |
| 97   | Syndicate                           | 8       | 0            | 0           | 79                  | 70                |
| 98   | Undercity                           | 4       | 4            | 10          |                     |                   |
| 99   | Victim                              | 8       | 0            | 0           |                     |                   |
| 100  | Treasure                            | 0       | 0            | 9           |                     |                   |
| 101  | Treasure                            | 0       | 8            | 4           |                     |                   |
| 102  | Treasure                            | 0       | 8            | 2           |                     |                   |
| 103  | Dragonflight, Black                 | 8       | 0            | 1           | 689                 | 80                |
| 104  | Thunder Bluff                       | 4       | 4            | 2           |                     |                   |
| 105  | Thunder Bluff                       | 5       | 4            | 10          |                     |                   |
| 106  | Horde Generic                       | 4       | 4            | 10          |                     |                   |
| 107  | Troll, Frostmane                    | 8       | 0            | 1           |                     |                   |
| 108  | Syndicate                           | 0       | 0            | 0           | 79                  | 70                |
| 109  | Quilboar, Razormane 2               | 8       | 0            | 1           |                     | 110 111           |
| 110  | Quilboar, Razormane 2               | 8       | 0            | 1           | 85                  | 110               |
| 111  | Quilboar, Bristleback               | 8       | 0            | 1           |                     | 85 111            |
| 112  | Quilboar, Bristleback               | 8       | 0            | 1           | 110                 | 85 111            |
| 113  | Escortee                            | 1       | 1            | 0           |                     |                   |
| 114  | Treasure                            | 0       | 0            | 1           |                     |                   |
| 115  | PLAYER, Gnome                       | 3       | 2            | 12          |                     |                   |
| 116  | PLAYER, Troll                       | 5       | 4            | 10          |                     |                   |
| 118  | Undercity                           | 4       | 4            | 2           |                     |                   |
| 119  | Bloodsail Buccaneers                | 8       | 0            | 1           |                     | 87                |
| 120  | Booty Bay                           | 0       | 0            | 0           |                     | 21                |
| 121  | Booty Bay                           | 1       | 0            | 8           |                     | 21                |
| 122  | Ironforge                           | 2       | 2            | 4           |                     |                   |
| 123  | Stormwind                           | 2       | 2            | 4           |                     |                   |
| 124  | Darnassus                           | 2       | 2            | 4           |                     |                   |
| 125  | Orgrimmar                           | 4       | 4            | 2           |                     |                   |
| 126  | Darkspear Trolls                    | 4       | 4            | 2           |                     |                   |
| 127  | Villian                             | 0       | 0            | 1           |                     |                   |
| 128  | Blackfathom                         | 8       | 0            | 1           |                     | 88                |
| 129  | Makrura                             | 8       | 0            | 1           |                     | 89                |
| 130  | Centaur, Kolkar                     | 8       | 0            | 1           |                     | 90                |
| 131  | Centaur, Galak                      | 8       | 0            | 1           |                     | 91                |
| 132  | Gelkis Clan Centaur                 | 8       | 0            | 1           |                     | 92                |
| 133  | Magram Clan Centaur                 | 8       | 0            | 1           |                     | 93                |
| 134  | Maraudine                           | 8       | 0            | 1           |                     | 94                |
| 148  | Monster                             | 8       | 0            | 1           |                     |                   |
| 149  | Theramore                           | 2       | 2            | 0           |                     |                   |
| 150  | Theramore                           | 3       | 2            | 12          |