mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 06:06:23 +00:00
refactor(Core): Make more use of helpers. (#19835)
* Init. * Reword. * Update codestyle script. Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com> * Add gameobject type ID check, reorder checks. * Add helper/codestyle check for unit type. * `IsUnit()` -> `IsCreature()` * Add `IsUnit()` method. * Use type mask. https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5 Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com> Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com> * Replace instances of `isType` with `IsUnit`. --------- Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
@@ -304,11 +304,11 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE:
|
||||
return true;
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE:
|
||||
if (!target || target->GetTypeId() != TYPEID_UNIT)
|
||||
if (!target || !target->IsCreature())
|
||||
return false;
|
||||
return target->GetEntry() == creature.id;
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE:
|
||||
if (!target || target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target || !target->IsPlayer())
|
||||
return false;
|
||||
if (classRace.class_id && classRace.class_id != target->ToPlayer()->getClass())
|
||||
return false;
|
||||
@@ -316,7 +316,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
|
||||
return false;
|
||||
return true;
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE:
|
||||
if (!source || source->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!source || !source->IsPlayer())
|
||||
return false;
|
||||
if (classRace.class_id && classRace.class_id != source->ToPlayer()->getClass())
|
||||
return false;
|
||||
@@ -324,7 +324,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
|
||||
return false;
|
||||
return true;
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH:
|
||||
if (!target || target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target || !target->IsPlayer())
|
||||
return false;
|
||||
return !target->HealthAbovePct(health.percent);
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD:
|
||||
@@ -371,7 +371,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
|
||||
return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount;
|
||||
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM:
|
||||
{
|
||||
if (!target || target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target || !target->IsPlayer())
|
||||
return false;
|
||||
|
||||
// DB data compatibility...
|
||||
@@ -1501,7 +1501,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
|
||||
continue;
|
||||
|
||||
// map specific case (BG in fact) expected player targeted damage/heal
|
||||
if (!unit || unit->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unit || !unit->IsPlayer())
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user