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;