From 32c118095a4e384d783cb88ed6b93efad5139f38 Mon Sep 17 00:00:00 2001 From: Grindelwald <137000133@qq.com> Date: Sun, 12 May 2024 16:20:44 +0800 Subject: [PATCH] fix skin error --- src/game/Objects/Player.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 1cd8c574921..8cf4144ce1e 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -21466,6 +21466,12 @@ void Player::SetControlledBy(Unit* pWho) bool Player::ChangeRace(uint8 newRace) { + uint8 oldRace = GetRace(); + uint8 pClass = GetClass(); + uint8 gender = GetGender(); + uint8 team = GetTeam(); + Powers powertype = GetPowerType(); + if (IsSavingDisabled() || IsBot()) { sLog.Out(LOG_BASIC, LOG_LVL_ERROR, "Cannot change race of bot or temporary character!"); @@ -21476,7 +21482,6 @@ bool Player::ChangeRace(uint8 newRace) if (!info) return false; - uint8 oldRace = GetRace(); bool bChangeTeam = (TeamForRace(oldRace) != TeamForRace(newRace)); m_saveDisabled = true; @@ -21486,11 +21491,19 @@ bool Player::ChangeRace(uint8 newRace) return false; } + ResetSpells(); + // Change the race - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, newRace); LearnDefaultSpells(); SetFactionForRace(newRace); + SetFloatValue(OBJECT_FIELD_SCALE_X, ((newRace == RACE_TAUREN) ? 1.3f : 1.0f)); + SetUInt32Value(UNIT_FIELD_BYTES_0, ((newRace) | (pClass << 8) | (gender << 16) | (powertype << 24))); + SetUInt32Value(UNIT_FIELD_DISPLAYID, gender == GENDER_MALE ? info->displayId_m : info->displayId_f); + SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, gender == GENDER_MALE ? info->displayId_m : info->displayId_f); + SetUInt32Value(PLAYER_BYTES, 1 | (1 << 8) | (1 << 16) | (1 << 24)); + SetUInt32Value(PLAYER_BYTES_2, (1) | (0x02 << 24)); + SetByteValue(PLAYER_BYTES_2, 2, 7); // keep bank tabs if (!ChangeReputationsForRace(oldRace, newRace)) { @@ -21512,6 +21525,11 @@ bool Player::ChangeRace(uint8 newRace) RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); // Save with the new race + SetHealth(GetMaxHealth()); + + SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); + SetPower(POWER_RAGE, 0); + SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); m_saveDisabled = false; SaveToDB(); m_saveDisabled = true;