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:
@@ -781,6 +781,9 @@ CREATE TABLE `creature` (
|
||||
`curmana` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`DeathState` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`MovementType` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`npcflag` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`unit_flags` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`dynamicflags` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`guid`),
|
||||
KEY `idx_map` (`map`),
|
||||
KEY `idx_id` (`id`)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE `creature`
|
||||
ADD COLUMN `npcflag` int(10) unsigned NOT NULL DEFAULT '0' AFTER `MovementType`,
|
||||
ADD COLUMN `unit_flags` int(10) unsigned NOT NULL DEFAULT '0' AFTER `npcflag`,
|
||||
ADD COLUMN `dynamicflags` int(10) unsigned NOT NULL DEFAULT '0' AFTER `unit_flags`;
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -18086,7 +18086,7 @@ void Player::_SaveInventory(SQLTransaction& trans)
|
||||
bagTestGUID = test2->GetGUIDLow();
|
||||
sLog.outError("Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState());
|
||||
// according to the test that was just performed nothing should be in this slot, delete
|
||||
trans->PAppend("DELETE FROM character_inventory WHERE bag=%u AND slot=%u", bagTestGUID, item->GetSlot());
|
||||
trans->PAppend("DELETE FROM character_inventory WHERE bag=%u AND slot=%u AND guid=%u", bagTestGUID, item->GetSlot(), lowGuid);
|
||||
// also THIS item should be somewhere else, cheat attempt
|
||||
item->FSetState(ITEM_REMOVED); // we are IN updateQueue right now, can't use SetState which modifies the queue
|
||||
DeleteRefundReference(item->GetGUIDLow());
|
||||
|
||||
@@ -1074,6 +1074,25 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 /*team*/, const CreatureInfo *cinfo, co
|
||||
return display_id;
|
||||
}
|
||||
|
||||
void ObjectMgr::ChooseCreatureFlags(const CreatureInfo *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data /*= NULL*/)
|
||||
{
|
||||
npcflag = cinfo->npcflag;
|
||||
unit_flags = cinfo->unit_flags;
|
||||
dynamicflags = cinfo->dynamicflags;
|
||||
|
||||
if (data)
|
||||
{
|
||||
if (data->npcflag)
|
||||
npcflag = data->npcflag;
|
||||
|
||||
if (data->unit_flags)
|
||||
unit_flags = data->unit_flags;
|
||||
|
||||
if (data->dynamicflags)
|
||||
dynamicflags = data->dynamicflags;
|
||||
}
|
||||
}
|
||||
|
||||
CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_id)
|
||||
{
|
||||
CreatureModelInfo const *minfo = GetCreatureModelInfo(display_id);
|
||||
@@ -1241,7 +1260,9 @@ void ObjectMgr::LoadCreatures()
|
||||
// 4 5 6 7 8 9 10 11
|
||||
"equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint,"
|
||||
// 12 13 14 15 16 17 18 19
|
||||
"curhealth, curmana, DeathState, MovementType, spawnMask, phaseMask, event, pool_entry "
|
||||
"curhealth, curmana, DeathState, MovementType, spawnMask, phaseMask, event, pool_entry,"
|
||||
// 20 21 22
|
||||
"creature.npcflag, creature.unit_flags, creature.dynamicflags "
|
||||
"FROM creature LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
|
||||
"LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
|
||||
|
||||
@@ -1313,6 +1334,9 @@ void ObjectMgr::LoadCreatures()
|
||||
data.phaseMask = fields[17].GetUInt16();
|
||||
int16 gameEvent = fields[18].GetInt16();
|
||||
uint32 PoolId = fields[19].GetUInt32();
|
||||
data.npcflag = fields[20].GetUInt32();
|
||||
data.unit_flags = fields[21].GetUInt32();
|
||||
data.dynamicflags = fields[22].GetUInt32();
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
|
||||
if (!mapEntry)
|
||||
@@ -1359,19 +1383,19 @@ void ObjectMgr::LoadCreatures()
|
||||
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
|
||||
{
|
||||
if (!mapEntry || !mapEntry->IsDungeon())
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",guid,data.id);
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", guid, data.id);
|
||||
}
|
||||
|
||||
if (data.spawndist < 0.0f)
|
||||
{
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id);
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.", guid, data.id);
|
||||
data.spawndist = 0.0f;
|
||||
}
|
||||
else if (data.movementType == RANDOM_MOTION_TYPE)
|
||||
{
|
||||
if (data.spawndist == 0.0f)
|
||||
{
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).",guid,data.id);
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).", guid, data.id);
|
||||
data.movementType = IDLE_MOTION_TYPE;
|
||||
}
|
||||
else if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
|
||||
@@ -1381,17 +1405,23 @@ void ObjectMgr::LoadCreatures()
|
||||
{
|
||||
if (data.spawndist != 0.0f)
|
||||
{
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.",guid,data.id);
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.", guid, data.id);
|
||||
data.spawndist = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.phaseMask == 0)
|
||||
{
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id);
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
|
||||
data.phaseMask = 1;
|
||||
}
|
||||
|
||||
if (data.npcflag & UNIT_NPC_FLAG_SPELLCLICK)
|
||||
{
|
||||
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with npcflag UNIT_NPC_FLAG_SPELLCLICK (%u) set, it is expected to be set by code handling `npc_spellclick_spells` content.", guid, data.id, UNIT_NPC_FLAG_SPELLCLICK);
|
||||
data.npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
|
||||
}
|
||||
|
||||
//if (entry == 32307 || entry == 32308)
|
||||
/*if (entry == 30739 || entry == 30740)
|
||||
{
|
||||
@@ -1414,7 +1444,7 @@ void ObjectMgr::LoadCreatures()
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %lu creatures", (unsigned long)mCreatureDataMap.size());
|
||||
sLog.outString(">> Loaded %u creatures", (uint32)mCreatureDataMap.size());
|
||||
}
|
||||
|
||||
void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data)
|
||||
@@ -1563,6 +1593,10 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float
|
||||
data.spawnMask = 1;
|
||||
data.phaseMask = PHASEMASK_NORMAL;
|
||||
data.dbData = false;
|
||||
data.npcflag = cInfo->npcflag;
|
||||
data.unit_flags = cInfo->unit_flags;
|
||||
data.dynamicflags = cInfo->dynamicflags;
|
||||
|
||||
|
||||
AddCreatureToGrid(guid, &data);
|
||||
|
||||
|
||||
@@ -628,6 +628,7 @@ class ObjectMgr
|
||||
CreatureModelInfo const *GetCreatureModelInfo(uint32 modelid);
|
||||
CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id);
|
||||
uint32 ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data = NULL);
|
||||
static void ChooseCreatureFlags(const CreatureInfo *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data = NULL);
|
||||
EquipmentInfo const *GetEquipmentInfo(uint32 entry);
|
||||
static CreatureDataAddon const *GetCreatureAddon(uint32 lowguid)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user