Skip to content
Permalink
Browse files

Server/Unit: Implement UNIT_FLAG_DISABLE_POWERS for creatures.

Signed-off-by: AriDEV <aridev666@gmail.com>
  • Loading branch information
AriDEV committed Nov 25, 2019
1 parent 8c70725 commit f884edf155922d90cf1e8cea3c0e5389f3e68e99
@@ -1271,6 +1271,12 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
}

if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_POWERS))
{
SetMaxHealth(0);
SetMaxPower(POWER_MANA, 0);
}

SetHealth(m_deathState == ALIVE ? curhealth : 0);

// checked at creature_template loading
@@ -11930,7 +11930,9 @@ void Unit::SetHealth(uint32 val)

void Unit::SetMaxHealth(uint32 val)
{
if (!val)
if (!val && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_POWERS))
val = 0;
else
val = 1;

uint32 health = GetHealth();
@@ -648,7 +648,7 @@ enum UnitFlags
UNIT_FLAG_SKINNABLE = 0x04000000,
UNIT_FLAG_MOUNT = 0x08000000,
UNIT_FLAG_UNK_28 = 0x10000000,
UNIT_FLAG_UNK_29 = 0x20000000, // used in Feing Death spell
UNIT_FLAG_DISABLE_POWERS = 0x20000000, // used in Feing Death spell
UNIT_FLAG_SHEATHE = 0x40000000,
UNIT_FLAG_UNK_31 = 0x80000000,
MAX_UNIT_FLAGS = 33
@@ -2304,7 +2304,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
if (aurApp->GetRemoveMode())
return;

target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); // blizz like 2.0.x
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_POWERS); // blizz like 2.0.x
target->SetFlag(UNIT_FIELD_FLAGS2, UNIT_FLAG2_FEIGN_DEATH); // blizz like 2.0.x
target->SetFlag(OBJECT_FIELD_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); // blizz like 2.0.x
target->AddUnitState(UNIT_STATE_DIED);
@@ -2319,7 +2319,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
target->SendMessageToSet(&data, true);
*/

target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); // blizz like 2.0.x
target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_POWERS); // blizz like 2.0.x
target->RemoveFlag(UNIT_FIELD_FLAGS2, UNIT_FLAG2_FEIGN_DEATH); // blizz like 2.0.x
target->RemoveFlag(OBJECT_FIELD_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); // blizz like 2.0.x
target->ClearUnitState(UNIT_STATE_DIED);
@@ -146,7 +146,7 @@ EnumName<UnitFlags> const unitFlags[MAX_UNIT_FLAGS] =
CREATE_NAMED_ENUM(UNIT_FLAG_SKINNABLE),
CREATE_NAMED_ENUM(UNIT_FLAG_MOUNT),
CREATE_NAMED_ENUM(UNIT_FLAG_UNK_28),
CREATE_NAMED_ENUM(UNIT_FLAG_UNK_29),
CREATE_NAMED_ENUM(UNIT_FLAG_DISABLE_POWERS),
CREATE_NAMED_ENUM(UNIT_FLAG_SHEATHE),
CREATE_NAMED_ENUM(UNIT_FLAG_UNK_31)
};
@@ -314,7 +314,7 @@ class spell_earthrager_ptah_explosion : public SpellScriptLoader
{
if (Unit* ptah = GetCaster())
{
ptah->SetFlag(UNIT_FIELD_FLAGS, uint32(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_UNK_29 | UNIT_FLAG_UNK_31));
ptah->SetFlag(UNIT_FIELD_FLAGS, uint32(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_DISABLE_POWERS | UNIT_FLAG_UNK_31));
ptah->SetFlag(UNIT_FIELD_FLAGS2, UNIT_FLAG2_FEIGN_DEATH);
}
}
@@ -323,7 +323,7 @@ class spell_earthrager_ptah_explosion : public SpellScriptLoader
{
if (Unit* ptah = GetCaster())
{
ptah->RemoveFlag(UNIT_FIELD_FLAGS, uint32(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_UNK_29 | UNIT_FLAG_UNK_31));
ptah->RemoveFlag(UNIT_FIELD_FLAGS, uint32(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_DISABLE_POWERS | UNIT_FLAG_UNK_31));
ptah->RemoveFlag(UNIT_FIELD_FLAGS2, UNIT_FLAG2_FEIGN_DEATH);
}
}
@@ -384,7 +384,7 @@ class boss_xt002 : public CreatureScript
heart->CastSpell(heart, SPELL_EXPOSED_HEART, false); // Channeled
heart->ChangeSeat(HEART_VEHICLE_SEAT_EXPOSED, true);
heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_POWERS);
}

events.CancelEvent(EVENT_SEARING_LIGHT);
@@ -419,7 +419,7 @@ class boss_xt002 : public CreatureScript

heart->ChangeSeat(HEART_VEHICLE_SEAT_NORMAL, false);
heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_POWERS);
heart->RemoveAurasDueToSpell(SPELL_EXPOSED_HEART);

if (!_hardMode)

0 comments on commit f884edf

Please sign in to comment.
You can’t perform that action at this time.