diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-03-29 11:30:49 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-03-29 11:30:49 +0200 |
| commit | d611925dc7ab2b3f19c5ee9e0f75b8dfb6de1291 (patch) | |
| tree | 4428ac0728c043ca1cb4fc55427f87268ab4860c /src/server/game/Entities/Pet | |
| parent | c02b829788cb274a68b125aee4dab35b9a56a2b8 (diff) | |
Core/Units: Reduce differences between branches part 1 - unit updatefield accessors
Diffstat (limited to 'src/server/game/Entities/Pet')
| -rw-r--r-- | src/server/game/Entities/Pet/Pet.cpp | 50 | ||||
| -rw-r--r-- | src/server/game/Entities/Pet/Pet.h | 2 |
2 files changed, 25 insertions, 27 deletions
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 711feb9718c..26297f26f63 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -228,7 +228,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c setPetType(petInfo->Type); SetFaction(owner->GetFaction()); - SetUInt32Value(UNIT_CREATED_BY_SPELL, petInfo->CreatedBySpellId); + SetCreatedBySpell(petInfo->CreatedBySpellId); if (IsCritter()) { @@ -252,26 +252,22 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c SetDisplayId(petInfo->DisplayId); SetNativeDisplayId(petInfo->DisplayId); uint8 petlevel = petInfo->Level; - SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE); SetName(petInfo->Name); switch (getPetType()) { case SUMMON_PET: petlevel = owner->GetLevel(); - SetClass(CLASS_MAGE); - SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - // this enables popup window (pet dismiss, cancel) + ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED); // this enables popup window (pet dismiss, cancel) break; case HUNTER_PET: SetClass(CLASS_WARRIOR); SetGender(GENDER_NONE); SetSheath(SHEATH_STATE_MELEE); - SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, petInfo->WasRenamed ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); - - SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - // this enables popup window (pet abandon, cancel) + ReplaceAllPetFlags(petInfo->WasRenamed ? UNIT_PET_FLAG_CAN_BE_ABANDONED : (UNIT_PET_FLAG_CAN_BE_RENAMED | UNIT_PET_FLAG_CAN_BE_ABANDONED)); + ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED); // this enables popup window (pet abandon, cancel) SetMaxPower(POWER_HAPPINESS, GetCreatePowerValue(POWER_HAPPINESS)); SetPower(POWER_HAPPINESS, petInfo->Happiness); break; @@ -281,11 +277,11 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c break; } - SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped here + SetPetNameTimestamp(uint32(GameTime::GetGameTime())); // cast can't be helped here SetCreatorGUID(owner->GetGUID()); InitStatsForLevel(petlevel); - SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, petInfo->Experience); + SetPetExperience(petInfo->Experience); SynchronizeLevelWithOwner(); @@ -518,7 +514,7 @@ void Pet::SavePetToDB(PetSaveMode mode) stmt->setUInt8(6, GetReactState()); stmt->setUInt8(7, mode); stmt->setString(8, m_name); - stmt->setUInt8(9, HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED) ? 0 : 1); + stmt->setUInt8(9, HasPetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED) ? 0 : 1); stmt->setUInt32(10, curhealth); stmt->setUInt32(11, curmana); stmt->setUInt32(12, GetPower(POWER_HAPPINESS)); @@ -547,7 +543,7 @@ void Pet::FillPetInfo(PetStable::PetInfo* petInfo) const petInfo->Experience = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE); petInfo->ReactState = GetReactState(); petInfo->Name = GetName(); - petInfo->WasRenamed = !HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED); + petInfo->WasRenamed = !HasPetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED); petInfo->Health = GetHealth(); petInfo->Mana = GetPower(POWER_MANA); petInfo->Happiness = GetPower(POWER_HAPPINESS); @@ -592,19 +588,19 @@ void Pet::setDeathState(DeathState s) // overwrite virtual if (getPetType() == HUNTER_PET) { // pet corpse non lootable and non skinnable - SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE); - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + ReplaceAllDynamicFlags(UNIT_DYNFLAG_NONE); + RemoveUnitFlag(UNIT_FLAG_SKINNABLE); // lose happiness when died and not in BG/Arena if (!GetMap()->IsBattlegroundOrArena()) ModifyPower(POWER_HAPPINESS, -HAPPINESS_LEVEL_SIZE); - //SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); + //SetUnitFlag(UNIT_FLAG_STUNNED); } } else if (getDeathState() == ALIVE) { - //RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); + //RemoveUnitFlag(UNIT_FLAG_STUNNED); CastPetAuras(true); } } @@ -773,7 +769,7 @@ void Pet::GivePetXP(uint32 xp) nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); } // Not affected by special conditions - give it new XP - SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, petlevel < maxlevel ? newXP : 0); + SetPetExperience(petlevel < maxlevel ? newXP : 0); } void Pet::GivePetLevel(uint8 level) @@ -783,8 +779,8 @@ void Pet::GivePetLevel(uint8 level) if (getPetType() == HUNTER_PET) { - SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(level)*PET_XP_FACTOR)); + SetPetExperience(0); + SetPetNextLevelExperience(uint32(sObjectMgr->GetXPForLevel(level)*PET_XP_FACTOR)); } InitStatsForLevel(level); @@ -848,17 +844,17 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas SetMaxPower(POWER_HAPPINESS, GetCreatePowerValue(POWER_HAPPINESS)); SetPower(POWER_HAPPINESS, 166500); - SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); - SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(GetLevel()+1)*PET_XP_FACTOR)); - SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + SetPetNameTimestamp(0); + SetPetExperience(0); + SetPetNextLevelExperience(uint32(sObjectMgr->GetXPForLevel(GetLevel()+1)*PET_XP_FACTOR)); + ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE); if (cinfo->type == CREATURE_TYPE_BEAST) { SetClass(CLASS_WARRIOR); SetGender(GENDER_NONE); SetSheath(SHEATH_STATE_MELEE); - SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); + ReplaceAllPetFlags(UNIT_PET_FLAG_CAN_BE_RENAMED | UNIT_PET_FLAG_CAN_BE_ABANDONED); } return true; @@ -904,7 +900,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetAttackTime(OFF_ATTACK, BASE_ATTACK_TIME); SetAttackTime(RANGED_ATTACK, BASE_ATTACK_TIME); - SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); + SetModCastingSpeed(1.0f); //scale SetObjectScale(GetNativeObjectScale()); @@ -1885,7 +1881,7 @@ bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 return false; // Force regen flag for player pets, just like we do for players themselves - SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); + SetUnitFlag2(UNIT_FLAG2_REGENERATE_POWER); SetSheath(SHEATH_STATE_MELEE); GetThreatManager().Initialize(); diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index fb669dd943d..7828cdc23cb 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -83,6 +83,8 @@ class TC_GAME_API Pet : public Guardian HappinessState GetHappinessState(); void GivePetXP(uint32 xp); void GivePetLevel(uint8 level); + void SetPetExperience(uint32 xp) { SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, xp); } + void SetPetNextLevelExperience(uint32 xp) { SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, xp); } void SynchronizeLevelWithOwner(); bool HaveInDiet(ItemTemplate const* item) const; uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const; |
