mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
fix(core/dbc): improve ChrRace DBC handling (#14843)
Cherry pick of https://github.com/TrinityCore/TrinityCore/pull/24508 Co-authored-by: HelloKitty <5829095+HelloKitty@users.noreply.github.com>
This commit is contained in:
@@ -9968,9 +9968,15 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit* victim, uint32 /*damage*/, Au
|
||||
return true;
|
||||
}
|
||||
|
||||
void Unit::setPowerType(Powers new_powertype)
|
||||
void Unit::setPowerType(Powers new_powertype, bool sendUpdate/* = true*/)
|
||||
{
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype);
|
||||
if (getPowerType() == new_powertype)
|
||||
return;
|
||||
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE, new_powertype);
|
||||
|
||||
if (!sendUpdate)
|
||||
return;
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
@@ -15173,7 +15179,10 @@ uint32 Unit::GetCreatureType() const
|
||||
if (ssEntry && ssEntry->creatureType > 0)
|
||||
return ssEntry->creatureType;
|
||||
else
|
||||
return CREATURE_TYPE_HUMANOID;
|
||||
{
|
||||
ChrRacesEntry const* raceEntry = sChrRacesStore.AssertEntry(getRace());
|
||||
return raceEntry->CreatureType;
|
||||
}
|
||||
}
|
||||
else
|
||||
return ToCreature()->GetCreatureTemplate()->type;
|
||||
@@ -21277,25 +21286,6 @@ void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns c
|
||||
}
|
||||
}
|
||||
|
||||
uint8 Unit::getRace(bool original) const
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (original)
|
||||
return m_realRace;
|
||||
else
|
||||
return m_race;
|
||||
}
|
||||
|
||||
return GetByteValue(UNIT_FIELD_BYTES_0, 0);
|
||||
}
|
||||
|
||||
void Unit::setRace(uint8 race)
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
m_race = race;
|
||||
}
|
||||
|
||||
// Check if unit in combat with specific unit
|
||||
bool Unit::IsInCombatWith(Unit const* who) const
|
||||
{
|
||||
|
||||
@@ -39,6 +39,14 @@
|
||||
#define BASE_MAXDAMAGE 2.0f
|
||||
#define BASE_ATTACK_TIME 2000
|
||||
|
||||
enum UnitBytes0Offsets : uint8
|
||||
{
|
||||
UNIT_BYTES_0_OFFSET_RACE = 0,
|
||||
UNIT_BYTES_0_OFFSET_CLASS = 1,
|
||||
UNIT_BYTES_0_OFFSET_GENDER = 2,
|
||||
UNIT_BYTES_0_OFFSET_POWER_TYPE = 3
|
||||
};
|
||||
|
||||
enum UnitBytes1Offsets : uint8
|
||||
{
|
||||
UNIT_BYTES_1_OFFSET_STAND_STATE = 0,
|
||||
@@ -1432,12 +1440,21 @@ public:
|
||||
[[nodiscard]] uint8 GetLevel() const { return getLevel(); }
|
||||
uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return GetLevel(); }
|
||||
void SetLevel(uint8 lvl, bool showLevelChange = true);
|
||||
[[nodiscard]] uint8 getRace(bool original = false) const;
|
||||
void setRace(uint8 race);
|
||||
[[nodiscard]] uint32 getRaceMask() const { return 1 << (getRace(true) - 1); }
|
||||
[[nodiscard]] uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
|
||||
[[nodiscard]] uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
|
||||
void setRace(uint8 race) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, race); }
|
||||
[[nodiscard]] uint32 getRaceMask() const { return 1 << (getRace() - 1); }
|
||||
[[nodiscard]] uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
|
||||
void setClass(uint8 classId) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, classId); }
|
||||
[[nodiscard]] uint8 GetRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); }
|
||||
void SetRace(uint8 race) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, race); }
|
||||
[[nodiscard]] uint32 GetRaceMask() const { return 1 << (getRace() - 1); }
|
||||
[[nodiscard]] uint8 GetClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
|
||||
void SetClass(uint8 classId) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, classId); }
|
||||
[[nodiscard]] uint32 getClassMask() const { return 1 << (getClass() - 1); }
|
||||
[[nodiscard]] uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
|
||||
Gender getGender() const { return Gender(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER)); }
|
||||
void setGender(Gender gender) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender); }
|
||||
virtual Gender GetNativeGender() const { return getGender(); }
|
||||
virtual void SetNativeGender(Gender gender) { setGender(gender); }
|
||||
|
||||
[[nodiscard]] float GetStat(Stats stat) const { return float(GetUInt32Value(static_cast<uint16>(UNIT_FIELD_STAT0) + stat)); }
|
||||
void SetStat(Stats stat, int32 val) { SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_STAT0) + stat, val); }
|
||||
@@ -1468,8 +1485,8 @@ public:
|
||||
int32 ModifyHealth(int32 val);
|
||||
int32 GetHealthGain(int32 dVal);
|
||||
|
||||
[[nodiscard]] Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); }
|
||||
void setPowerType(Powers power);
|
||||
[[nodiscard]] Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); }
|
||||
void setPowerType(Powers power, bool sendUpdate = true);
|
||||
[[nodiscard]] uint32 GetPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power); }
|
||||
[[nodiscard]] uint32 GetMaxPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_MAXPOWER1) + power); }
|
||||
void SetPower(Powers power, uint32 val, bool withPowerUpdate = true, bool fromRegenerate = false);
|
||||
|
||||
Reference in New Issue
Block a user