[8826] Set creatures PvP state flag based on creature faction and rename related enum

Condition with custom flag civilian and player team only is not sufficient. This update also disallow use *_addon -table (second byte of bytes2) to set flag manually (small chance it may be needed)

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2009-11-17 15:40:24 +01:00
parent bc5fb40867
commit 84432d8459
4 changed files with 12 additions and 12 deletions

View file

@ -306,14 +306,13 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
SetCanModifyStats(true);
UpdateAllStats();
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A);
if (factionTemplate) // check and error show at loading templates
// checked and error show at loading templates
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A))
{
FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction);
if (factionEntry)
if( !(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) &&
(factionEntry->team == ALLIANCE || factionEntry->team == HORDE) )
if (factionTemplate->factionFlags & FACTION_TEMPLATE_FLAG_PVP)
SetPvP(true);
else
SetPvP(false);
}
for(int i=0; i < CREATURE_MAX_SPELLS; ++i)
@ -1971,12 +1970,12 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (cainfo->bytes2 != 0)
{
// 0 SheathState
// 1 Bytes2Flags
// 1 UnitPVPStateFlags Set at Creature::UpdateEntry (SetPvp())
// 2 UnitRename Pet only, so always 0 for default creature
// 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura
SetByteValue(UNIT_FIELD_BYTES_2, 0, uint8(cainfo->bytes2 & 0xFF));
SetByteValue(UNIT_FIELD_BYTES_2, 1, uint8((cainfo->bytes2 >> 8) & 0xFF));
//SetByteValue(UNIT_FIELD_BYTES_2, 1, uint8((cainfo->bytes2 >> 8) & 0xFF));
//SetByteValue(UNIT_FIELD_BYTES_2, 2, uint8((cainfo->bytes2 >> 16) & 0xFF));
SetByteValue(UNIT_FIELD_BYTES_2, 2, 0);
//SetByteValue(UNIT_FIELD_BYTES_2, 3, uint8((cainfo->bytes2 >> 24) & 0xFF));

View file

@ -268,6 +268,7 @@ enum SpawnMask
enum FactionTemplateFlags
{
FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP
FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats
};

View file

@ -195,7 +195,7 @@ enum SheathState
#define MAX_SHEATH_STATE 3
// byte (1 from 0..3) of UNIT_FIELD_BYTES_2
enum UnitBytes2_Flags
enum UnitPVPStateFlags
{
UNIT_BYTE2_FLAG_PVP = 0x01,
UNIT_BYTE2_FLAG_UNK1 = 0x02,

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8825"
#define REVISION_NR "8826"
#endif // __REVISION_NR_H__