DB/Creature:

- Nuke the hacky column DeathState.
- Removed some hacks from Kologarn script, including some cleanup.
- Removed set deathstate command.

BIG thanks to Malcrom for replacing all creatures that had deathstate with proper dynamicflags/auras.
This commit is contained in:
kaelima
2011-06-27 20:22:53 +02:00
parent 8fc13f508f
commit 9a67aaa8b8
14 changed files with 88 additions and 179 deletions
+9 -35
View File
@@ -142,9 +142,8 @@ lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGrou
m_PlayerDamageReq(0), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0),
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_creatureInfo(NULL), m_creatureData(NULL),
m_formation(NULL)
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL)
{
m_regenTimer = CREATURE_REGEN_INTERVAL;
m_valuesCount = UNIT_END;
@@ -229,7 +228,7 @@ void Creature::SearchFormation()
void Creature::RemoveCorpse(bool setSpawnTime)
{
if ((getDeathState() != CORPSE && !m_isDeadByDefault) || (getDeathState() != ALIVE && m_isDeadByDefault))
if (getDeathState() != CORPSE)
return;
m_corpseRemoveTime = time(NULL);
@@ -471,9 +470,6 @@ void Creature::Update(uint32 diff)
}
case CORPSE:
{
if (m_isDeadByDefault)
break;
if (m_groupLootTimer && lootingGroupLowGUID)
{
// for delayed spells
@@ -504,15 +500,6 @@ void Creature::Update(uint32 diff)
}
case ALIVE:
{
if (m_isDeadByDefault)
{
if (m_corpseRemoveTime <= time(NULL))
{
RemoveCorpse(false);
sLog->outStaticDebug("Removing alive corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY));
}
}
Unit::Update(diff);
// creature can be dead after Unit::Update call
@@ -1082,7 +1069,6 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.currentwaypoint = 0;
data.curhealth = GetHealth();
data.curmana = GetPower(POWER_MANA);
data.is_dead = m_isDeadByDefault;
// prevent add data integrity problems
data.movementType = !m_respawnradius && GetDefaultMovementType() == RANDOM_MOTION_TYPE
? IDLE_MOTION_TYPE : GetDefaultMovementType();
@@ -1114,7 +1100,6 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< (uint32) (0) << ", " //currentwaypoint
<< GetHealth() << ", " //curhealth
<< GetPower(POWER_MANA) << ", " //curmana
<< (m_isDeadByDefault ? 1 : 0) << ", " //is_dead
<< GetDefaultMovementType() << ", " //default movement generator type
<< npcflag << ", "
<< unit_flags << ", "
@@ -1292,8 +1277,7 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
m_respawnradius = data->spawndist;
m_respawnDelay = data->spawntimesecs;
m_isDeadByDefault = data->is_dead;
m_deathState = m_isDeadByDefault ? DEAD : ALIVE;
m_deathState = ALIVE;
m_respawnTime = sObjectMgr->GetCreatureRespawnTime(m_DBTableGuid, GetInstanceId());
if (m_respawnTime) // respawn on Update
@@ -1404,7 +1388,7 @@ bool Creature::isVisibleForInState(WorldObject const* seer) const
if (!Unit::isVisibleForInState(seer))
return false;
if (isAlive() || (m_isDeadByDefault && m_deathState == CORPSE) || m_corpseRemoveTime > time(NULL))
if (isAlive() || m_corpseRemoveTime > time(NULL))
return true;
return false;
@@ -1495,7 +1479,9 @@ float Creature::GetAttackDistance(Unit const* pl) const
void Creature::setDeathState(DeathState s)
{
if ((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault))
Unit::setDeathState(s);
if (s == JUST_DIED)
{
m_corpseRemoveTime = time(NULL) + m_corpseDelay;
m_respawnTime = time(NULL) + m_respawnDelay + m_corpseDelay;
@@ -1503,11 +1489,7 @@ void Creature::setDeathState(DeathState s)
// always save boss respawn time at death to prevent crash cheating
if (sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY) || isWorldBoss())
SaveRespawnTime();
}
Unit::setDeathState(s);
if (s == JUST_DIED)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
@@ -1608,15 +1590,7 @@ void Creature::Respawn(bool force)
CreatureTemplate const *cinfo = GetCreatureInfo();
SelectLevel(cinfo);
if (m_isDeadByDefault)
{
setDeathState(JUST_DIED);
i_motionMaster.Clear();
ClearUnitState(uint32(UNIT_STAT_ALL_STATE));
LoadCreaturesAddon(true);
}
else
setDeathState(JUST_ALIVED);
setDeathState(JUST_ALIVED);
uint32 displayID = GetNativeDisplayId();
CreatureModelInfo const *minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
@@ -254,7 +254,6 @@ struct CreatureData
uint32 currentwaypoint;
uint32 curhealth;
uint32 curmana;
bool is_dead;
uint8 movementType;
uint8 spawnMask;
uint32 npcflag;
@@ -603,7 +602,6 @@ class Creature : public Unit, public GridObject<Creature>
void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
void RemoveCorpse(bool setSpawnTime = true);
bool isDeadByDefault() const { return m_isDeadByDefault; };
void ForcedDespawn(uint32 timeMSToDespawn = 0);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
@@ -656,7 +654,6 @@ class Creature : public Unit, public GridObject<Creature>
void SetFormation(CreatureGroup *formation) {m_formation = formation;}
Unit *SelectVictim();
void SetDeadByDefault (bool death_state) {m_isDeadByDefault = death_state;}
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() { return DisableReputationGain; }
@@ -713,7 +710,6 @@ class Creature : public Unit, public GridObject<Creature>
bool m_AlreadySearchedAssistance;
bool m_regenHealth;
bool m_AI_locked;
bool m_isDeadByDefault;
SpellSchoolMask m_meleeDamageSchoolMask;
uint32 m_originalEntry;
+10 -12
View File
@@ -1434,8 +1434,8 @@ void ObjectMgr::LoadCreatures()
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, "
// 11 12 13 14 15 16 17 18 19 20 21 22
"currentwaypoint, curhealth, curmana, DeathState, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags "
// 11 12 13 14 15 16 17 18 19 20 21
"currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, 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");
@@ -1494,15 +1494,14 @@ void ObjectMgr::LoadCreatures()
data.currentwaypoint= fields[11].GetUInt32();
data.curhealth = fields[12].GetUInt32();
data.curmana = fields[13].GetUInt32();
data.is_dead = fields[14].GetBool();
data.movementType = fields[15].GetUInt8();
data.spawnMask = fields[16].GetUInt8();
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();
data.movementType = fields[14].GetUInt8();
data.spawnMask = fields[15].GetUInt8();
data.phaseMask = fields[16].GetUInt16();
int16 gameEvent = fields[17].GetInt16();
uint32 PoolId = fields[18].GetUInt32();
data.npcflag = fields[19].GetUInt32();
data.unit_flags = fields[20].GetUInt32();
data.dynamicflags = fields[21].GetUInt32();
MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
if (!mapEntry)
@@ -1724,7 +1723,6 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float
data.currentwaypoint = 0;
data.curhealth = stats->GenerateHealth(cInfo);
data.curmana = stats->GenerateMana(cInfo);
data.is_dead = false;
data.movementType = cInfo->MovementType;
data.spawnMask = 1;
data.phaseMask = PHASEMASK_NORMAL;
@@ -498,7 +498,7 @@ namespace Trinity
bool operator()(Creature* u)
{
if (i_funit->GetTypeId() != TYPEID_PLAYER || !((Player*)i_funit)->isHonorOrXPTarget(u) ||
u->getDeathState() != CORPSE || u->isDeadByDefault() || u->isInFlight() ||
u->getDeathState() != CORPSE || u->isInFlight() ||
(u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1))) == 0 ||
(u->GetDisplayId() != u->GetNativeDisplayId()))
return false;
@@ -525,7 +525,7 @@ namespace Trinity
}
bool operator()(Creature* u)
{
if (u->getDeathState() != CORPSE || u->isInFlight() || u->isDeadByDefault() ||
if (u->getDeathState() != CORPSE || u->isInFlight() ||
(u->GetDisplayId() != u->GetNativeDisplayId()) ||
(u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL) != 0)
return false;
-1
View File
@@ -2516,7 +2516,6 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
|| (m_targets.GetUnitTarget()->getDeathState() == CORPSE
&& m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId()
&& m_targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT
&& !m_targets.GetUnitTarget()->ToCreature()->isDeadByDefault()
&& !(m_targets.GetUnitTarget()->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)
&& m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId()))))
{