mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
Core/Objects: Switch to using designated initializers instead of chaining functions for FindCreatureOptions
This commit is contained in:
@@ -863,9 +863,6 @@ void MovementInfo::OutDebug()
|
||||
TC_LOG_DEBUG("misc", "standingOnGameObjectGUID: {}", standingOnGameObjectGUID->ToString());
|
||||
}
|
||||
|
||||
FindCreatureOptions::FindCreatureOptions() = default;
|
||||
FindCreatureOptions::~FindCreatureOptions() = default;
|
||||
|
||||
WorldObject::WorldObject(bool isWorldObject) : Object(), WorldLocation(), LastUsedScriptID(0),
|
||||
m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||
m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_outdoors(false), m_liquidStatus(LIQUID_MAP_NO_WATER),
|
||||
|
||||
@@ -432,29 +432,8 @@ class FlaggedValuesArray32
|
||||
T_FLAGS m_flags;
|
||||
};
|
||||
|
||||
struct TC_GAME_API FindCreatureOptions
|
||||
struct FindCreatureOptions
|
||||
{
|
||||
FindCreatureOptions();
|
||||
~FindCreatureOptions();
|
||||
|
||||
FindCreatureOptions& SetCreatureId(uint32 creatureId) { CreatureId = creatureId; return *this; }
|
||||
FindCreatureOptions& SetStringId(std::string_view stringId) { StringId = stringId; return *this; }
|
||||
|
||||
FindCreatureOptions& SetIsAlive(bool isAlive) { IsAlive = isAlive; return *this; }
|
||||
FindCreatureOptions& SetIsInCombat(bool isInCombat) { IsInCombat = isInCombat; return *this; }
|
||||
FindCreatureOptions& SetIsSummon(bool isSummon) { IsSummon = isSummon; return *this; }
|
||||
|
||||
FindCreatureOptions& SetIgnorePhases(bool ignorePhases) { IgnorePhases = ignorePhases; return *this; }
|
||||
FindCreatureOptions& SetIgnoreNotOwnedPrivateObjects(bool ignoreNotOwnedPrivateObjects) { IgnoreNotOwnedPrivateObjects = ignoreNotOwnedPrivateObjects; return *this; }
|
||||
FindCreatureOptions& SetIgnorePrivateObjects(bool ignorePrivateObjects) { IgnorePrivateObjects = ignorePrivateObjects; return *this; }
|
||||
|
||||
FindCreatureOptions& SetHasAura(uint32 spellId) { AuraSpellId = spellId; return *this; }
|
||||
FindCreatureOptions& SetOwner(ObjectGuid ownerGuid) { OwnerGuid = ownerGuid; return *this; }
|
||||
FindCreatureOptions& SetCharmer(ObjectGuid charmerGuid) { CharmerGuid = charmerGuid; return *this; }
|
||||
FindCreatureOptions& SetCreator(ObjectGuid creatorGuid) { CreatorGuid = creatorGuid; return *this; }
|
||||
FindCreatureOptions& SetDemonCreator(ObjectGuid demonCreatorGuid) { DemonCreatorGuid = demonCreatorGuid; return *this; }
|
||||
FindCreatureOptions& SetPrivateObjectOwner(ObjectGuid privateObjectOwnerGuid) { PrivateObjectOwnerGuid = privateObjectOwnerGuid; return *this; }
|
||||
|
||||
Optional<uint32> CreatureId;
|
||||
Optional<std::string_view> StringId;
|
||||
|
||||
@@ -472,12 +451,6 @@ struct TC_GAME_API FindCreatureOptions
|
||||
Optional<ObjectGuid> CreatorGuid;
|
||||
Optional<ObjectGuid> DemonCreatorGuid;
|
||||
Optional<ObjectGuid> PrivateObjectOwnerGuid;
|
||||
|
||||
FindCreatureOptions(FindCreatureOptions const&) = delete;
|
||||
FindCreatureOptions(FindCreatureOptions&&) = delete;
|
||||
|
||||
FindCreatureOptions& operator=(FindCreatureOptions const&) = delete;
|
||||
FindCreatureOptions& operator=(FindCreatureOptions&&) = delete;
|
||||
};
|
||||
|
||||
class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
|
||||
@@ -68,7 +68,7 @@ struct boss_kazzara_the_hellforged : public BossAI
|
||||
scheduler.Schedule(1s + 500ms, [this](TaskContext /*context*/)
|
||||
{
|
||||
std::vector<Creature*> sunderedMobs;
|
||||
GetCreatureListWithOptionsInGrid(sunderedMobs, me, 50.0f, FindCreatureOptions().SetStringId("sundered_mob"));
|
||||
GetCreatureListWithOptionsInGrid(sunderedMobs, me, 50.0f, { .StringId = "sundered_mob" });
|
||||
for (Creature* sunderedMob : sunderedMobs)
|
||||
{
|
||||
if (!sunderedMob->IsAlive() || sunderedMob->IsInCombat())
|
||||
|
||||
@@ -476,8 +476,8 @@ public:
|
||||
|
||||
void OnConversationCreate(Conversation* conversation, Unit* creator) override
|
||||
{
|
||||
Creature* mathiasObject = GetClosestCreatureWithOptions(creator, 15.0f, FindCreatureOptions().SetIgnorePhases(true).SetCreatureId(NPC_MATHIAS_SHAW));
|
||||
Creature* vanessaObject = GetClosestCreatureWithOptions(creator, 15.0f, FindCreatureOptions().SetIgnorePhases(true).SetCreatureId(NPC_VANESSA_VANCLEEF));
|
||||
Creature* mathiasObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_MATHIAS_SHAW, .IgnorePhases = true });
|
||||
Creature* vanessaObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_VANESSA_VANCLEEF, .IgnorePhases = true });
|
||||
if (!mathiasObject || !vanessaObject)
|
||||
return;
|
||||
|
||||
@@ -589,8 +589,8 @@ public:
|
||||
|
||||
void OnConversationCreate(Conversation* conversation, Unit* creator) override
|
||||
{
|
||||
Creature* mathiasObject = GetClosestCreatureWithOptions(creator, 15.0f, FindCreatureOptions().SetIgnorePhases(true).SetCreatureId(NPC_MATHIAS_SHAW));
|
||||
Creature* vanessaObject = GetClosestCreatureWithOptions(creator, 15.0f, FindCreatureOptions().SetIgnorePhases(true).SetCreatureId(NPC_VANESSA_VANCLEEF));
|
||||
Creature* mathiasObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_MATHIAS_SHAW, .IgnorePhases = true });
|
||||
Creature* vanessaObject = GetClosestCreatureWithOptions(creator, 15.0f, { .CreatureId = NPC_VANESSA_VANCLEEF, .IgnorePhases = true });
|
||||
if (!mathiasObject || !vanessaObject)
|
||||
return;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ CreatureAI* GetPrivatePublicPairAISelector(Creature* creature)
|
||||
|
||||
static Creature* FindCreatureIgnorePhase(WorldObject const* obj, std::string_view stringId, float range = 100.0f)
|
||||
{
|
||||
return obj->FindNearestCreatureWithOptions(range, FindCreatureOptions().SetIgnorePhases(true).SetStringId(stringId));
|
||||
return obj->FindNearestCreatureWithOptions(range, { .StringId = stringId, .IgnorePhases = true });
|
||||
}
|
||||
|
||||
// ********************************************
|
||||
@@ -290,7 +290,7 @@ class spell_summon_sparring_partner : public SpellScript
|
||||
if (!caster)
|
||||
return;
|
||||
|
||||
Creature* partner = caster->FindNearestCreatureWithOptions(10.0f, FindCreatureOptions().SetIgnorePhases(true).SetStringId(caster->GetTeam() == ALLIANCE ? "q58209_cole" : "q59927_throg"));
|
||||
Creature* partner = FindCreatureIgnorePhase(caster, caster->GetTeam() == ALLIANCE ? "q58209_cole" : "q59927_throg", 10.0f);
|
||||
if (!partner)
|
||||
return;
|
||||
|
||||
@@ -1469,7 +1469,7 @@ struct npc_bo_beach_laying : public ScriptedAI
|
||||
{
|
||||
player->KilledMonsterCredit(me->GetEntry());
|
||||
|
||||
if (Creature* survivor = player->FindNearestCreatureWithOptions(50.0f, FindCreatureOptions().SetStringId("bo_beach").SetIgnorePhases(true)))
|
||||
if (Creature* survivor = FindCreatureIgnorePhase(player, "bo_beach", 50.0f))
|
||||
survivor->SummonPersonalClone(BoCloneSpawnPosition, TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
}
|
||||
}
|
||||
@@ -1491,7 +1491,7 @@ struct npc_mithran_dawntracker_beach_laying : public ScriptedAI
|
||||
{
|
||||
player->KilledMonsterCredit(me->GetEntry());
|
||||
|
||||
if (Creature* survivor = player->FindNearestCreatureWithOptions(50.0f, FindCreatureOptions().SetStringId("mithran_beach").SetIgnorePhases(true)))
|
||||
if (Creature* survivor = FindCreatureIgnorePhase(player, "mithran_beach", 50.0f))
|
||||
survivor->SummonPersonalClone(MithranCloneSpawnPosition, TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
}
|
||||
}
|
||||
@@ -1513,7 +1513,7 @@ struct npc_lana_jordan_beach_laying : public ScriptedAI
|
||||
{
|
||||
player->KilledMonsterCredit(me->GetEntry());
|
||||
|
||||
if (Creature* survivor = player->FindNearestCreatureWithOptions(50.0f, FindCreatureOptions().SetStringId("lana_jordan_beach").SetIgnorePhases(true)))
|
||||
if (Creature* survivor = FindCreatureIgnorePhase(player, "lana_jordan_beach", 50.0f))
|
||||
survivor->SummonPersonalClone(LanaCloneSpawnPosition, TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
}
|
||||
}
|
||||
@@ -1967,14 +1967,14 @@ public:
|
||||
player->CastSpell(player, SPELL_UPDATE_PHASE_SHIFT);
|
||||
player->CastSpell(player, summonSpellId);
|
||||
|
||||
if (Creature* survivor1 = player->FindNearestCreatureWithOptions(25.0f, FindCreatureOptions().SetStringId(survivor1StringId).SetIgnorePhases(true)))
|
||||
if (Creature* survivor1 = FindCreatureIgnorePhase(player, survivor1StringId, 25.0f))
|
||||
{
|
||||
Creature* survivor1Personal = survivor1->SummonPersonalClone(survivor1->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
survivor1Personal->SetScriptStringId("spawn_check");
|
||||
}
|
||||
if (Creature* survivor2 = player->FindNearestCreatureWithOptions(25.0f, FindCreatureOptions().SetStringId(survivor2StringId).SetIgnorePhases(true)))
|
||||
if (Creature* survivor2 = FindCreatureIgnorePhase(player, survivor2StringId, 25.0f))
|
||||
survivor2->SummonPersonalClone(survivor2->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
if (Creature* survivor3 = player->FindNearestCreatureWithOptions(25.0f, FindCreatureOptions().SetStringId(survivor3StringId).SetIgnorePhases(true)))
|
||||
if (Creature* survivor3 = FindCreatureIgnorePhase(player, survivor3StringId, 25.0f))
|
||||
survivor3->SummonPersonalClone(survivor3->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
|
||||
|
||||
break;
|
||||
@@ -2030,7 +2030,7 @@ class spell_summon_survivor_beach : public SpellScript
|
||||
if (!caster)
|
||||
return;
|
||||
|
||||
Creature* survivor = caster->FindNearestCreatureWithOptions(5.0f, FindCreatureOptions().SetIgnorePhases(true).SetStringId(caster->GetTeam() == ALLIANCE ? "q54952_garrick" : "q59931_grimaxe"));
|
||||
Creature* survivor = FindCreatureIgnorePhase(caster, caster->GetTeam() == ALLIANCE ? "q54952_garrick" : "q59931_grimaxe", 5.0f);
|
||||
if (!survivor)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user