DB-Schema/World/creature: Added possibility to override npcflag, unit_flags, dynamicflags in creature table
Core/Player: Fixed bad query in previous revision --HG-- branch : trunk
This commit is contained in:
@@ -367,17 +367,21 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data)
|
||||
else
|
||||
setFaction(cInfo->faction_A);
|
||||
|
||||
uint32 npcflag, unit_flags, dynamicflags;
|
||||
ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
|
||||
|
||||
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
|
||||
SetUInt32Value(UNIT_NPC_FLAGS,cInfo->npcflag | sGameEventMgr.GetNPCFlag(this));
|
||||
SetUInt32Value(UNIT_NPC_FLAGS, npcflag | sGameEventMgr.GetNPCFlag(this));
|
||||
else
|
||||
SetUInt32Value(UNIT_NPC_FLAGS,cInfo->npcflag);
|
||||
SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
|
||||
|
||||
SetAttackTime(BASE_ATTACK, cInfo->baseattacktime);
|
||||
SetAttackTime(OFF_ATTACK, cInfo->baseattacktime);
|
||||
SetAttackTime(RANGED_ATTACK,cInfo->rangeattacktime);
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_FLAGS,cInfo->unit_flags);
|
||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS,cInfo->dynamicflags);
|
||||
SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
|
||||
|
||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags);
|
||||
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
@@ -1008,7 +1012,7 @@ void Creature::SaveToDB()
|
||||
return;
|
||||
}
|
||||
|
||||
SaveToDB(GetMapId(), data->spawnMask,GetPhaseMask());
|
||||
SaveToDB(GetMapId(), data->spawnMask, GetPhaseMask());
|
||||
}
|
||||
|
||||
void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
@@ -1019,6 +1023,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
CreatureData& data = sObjectMgr.NewOrExistCreatureData(m_DBTableGuid);
|
||||
|
||||
uint32 displayId = GetNativeDisplayId();
|
||||
uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS);
|
||||
uint32 unit_flags = GetUInt32Value(UNIT_FIELD_FLAGS);
|
||||
uint32 dynamicflags = GetUInt32Value(UNIT_DYNAMIC_FLAGS);
|
||||
|
||||
// check if it's a custom model and if not, use 0 for displayId
|
||||
CreatureInfo const *cinfo = GetCreatureInfo();
|
||||
@@ -1027,6 +1034,15 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
|
||||
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
|
||||
displayId = 0;
|
||||
|
||||
if (npcflag == cinfo->npcflag)
|
||||
npcflag = 0;
|
||||
|
||||
if (unit_flags == cinfo->unit_flags)
|
||||
unit_flags = 0;
|
||||
|
||||
if (dynamicflags == cinfo->dynamicflags)
|
||||
dynamicflags = 0;
|
||||
}
|
||||
|
||||
// data->guid = guid don't must be update at save
|
||||
@@ -1050,6 +1066,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
data.movementType = !m_respawnradius && GetDefaultMovementType() == RANDOM_MOTION_TYPE
|
||||
? IDLE_MOTION_TYPE : GetDefaultMovementType();
|
||||
data.spawnMask = spawnMask;
|
||||
data.npcflag = npcflag;
|
||||
data.unit_flags = unit_flags;
|
||||
data.dynamicflags = dynamicflags;
|
||||
|
||||
// updated in DB
|
||||
SQLTransaction trans = WorldDatabase.BeginTransaction();
|
||||
@@ -1075,7 +1094,10 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
<< GetHealth() << "," //curhealth
|
||||
<< GetPower(POWER_MANA) << "," //curmana
|
||||
<< (m_isDeadByDefault ? 1 : 0) << "," //is_dead
|
||||
<< GetDefaultMovementType() << ")"; //default movement generator type
|
||||
<< GetDefaultMovementType() << "," //default movement generator type
|
||||
<< npcflag << ","
|
||||
<< unit_flags << ","
|
||||
<< dynamicflags << ")";
|
||||
|
||||
trans->Append(ss.str().c_str());
|
||||
|
||||
|
||||
@@ -247,6 +247,9 @@ struct CreatureData
|
||||
bool is_dead;
|
||||
uint8 movementType;
|
||||
uint8 spawnMask;
|
||||
uint32 npcflag;
|
||||
uint32 unit_flags; // enum UnitFlags mask values
|
||||
uint32 dynamicflags;
|
||||
bool dbData;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user