refactor(GameObjectAI): Change self-accessor to "me" (#9041)

This commit is contained in:
Kitzunu
2021-11-08 22:06:04 +01:00
committed by GitHub
parent 84b1295938
commit 24f9f993cc
10 changed files with 87 additions and 82 deletions

View File

@@ -164,10 +164,10 @@ class go_suppression_device : public GameObjectScript
switch (eventId)
{
case EVENT_SUPPRESSION_CAST:
if (go->GetGoState() == GO_STATE_READY)
if (me->GetGoState() == GO_STATE_READY)
{
go->CastSpell(nullptr, SPELL_SUPPRESSION_AURA);
go->SendCustomAnim(0);
me->CastSpell(nullptr, SPELL_SUPPRESSION_AURA);
me->SendCustomAnim(0);
}
_events.ScheduleEvent(EVENT_SUPPRESSION_CAST, 5000);
break;
@@ -188,7 +188,7 @@ class go_suppression_device : public GameObjectScript
_events.ScheduleEvent(EVENT_SUPPRESSION_RESET, 30000, 120000);
break;
case GO_JUST_DEACTIVATED: // This case prevents the Gameobject despawn by Disarm Trap
go->SetLootState(GO_READY);
me->SetLootState(GO_READY);
break;
}
}
@@ -207,10 +207,10 @@ class go_suppression_device : public GameObjectScript
if (_active)
return;
_active = true;
if (go->GetGoState() == GO_STATE_ACTIVE)
go->SetGoState(GO_STATE_READY);
go->SetLootState(GO_READY);
go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
if (me->GetGoState() == GO_STATE_ACTIVE)
me->SetGoState(GO_STATE_READY);
me->SetLootState(GO_READY);
me->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
_events.ScheduleEvent(EVENT_SUPPRESSION_CAST, 1000);
}
@@ -219,8 +219,8 @@ class go_suppression_device : public GameObjectScript
if (!_active)
return;
_active = false;
go->SetGoState(GO_STATE_ACTIVE);
go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
me->SetGoState(GO_STATE_ACTIVE);
me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
_events.CancelEvent(EVENT_SUPPRESSION_CAST);
}

View File

@@ -318,8 +318,8 @@ class go_chromaggus_lever : public GameObjectScript
_instance->HandleGameObject(ObjectGuid::Empty, true, go);
}
go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE | GO_FLAG_IN_USE);
go->SetGoState(GO_STATE_ACTIVE);
me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE | GO_FLAG_IN_USE);
me->SetGoState(GO_STATE_ACTIVE);
return true;
}

View File

@@ -2105,16 +2105,16 @@ public:
void Reset() override
{
go->SetLootState(GO_READY);
me->SetLootState(GO_READY);
_scheduler.Schedule(Seconds(1), [this](TaskContext /*context*/)
{
go->UseDoorOrButton();
go->CastSpell(nullptr, SPELL_MOLE_MACHINE_EMERGE);
me->UseDoorOrButton();
me->CastSpell(nullptr, SPELL_MOLE_MACHINE_EMERGE);
})
.Schedule(Seconds(4), [this](TaskContext /*context*/)
{
if (GameObject* trap = go->GetLinkedTrap())
if (GameObject* trap = me->GetLinkedTrap())
{
trap->UseDoorOrButton();
trap->SetLootState(GO_READY);

View File

@@ -273,7 +273,7 @@ public:
private:
void initBlyCrewMember(uint32 entry, float x, float y, float z)
{
if (Creature* crew = ObjectAccessor::GetCreature(*go, instance->GetGuidData(entry)))
if (Creature* crew = ObjectAccessor::GetCreature(*me, instance->GetGuidData(entry)))
{
crew->SetReactState(REACT_AGGRESSIVE);
crew->SetWalk(true);

View File

@@ -1013,7 +1013,7 @@ public:
{
if (reportUse)
{
uint32 gossipId = go->GetGOInfo()->GetGossipMenuId();
uint32 gossipId = me->GetGOInfo()->GetGossipMenuId();
bool _twilightSetAura = (player->HasAura(AURA_TWILIGHT_SET, player->GetGUID()) ? true : false);
bool _medallionAura = (player->HasAura(AURA_MEDALLION, player->GetGUID()) ? true : false);
bool _ringAura = (player->HasAura(AURA_RING, player->GetGUID()) ? true : false);
@@ -1023,19 +1023,19 @@ public:
case GOSSIPID_LESSER_WS:
{
if (!_twilightSetAura)
go->CastSpell(player, SPELL_PUNISHMENT);
me->CastSpell(player, SPELL_PUNISHMENT);
break;
}
case GOSSIPID_WS:
{
if (!_twilightSetAura || !_medallionAura)
go->CastSpell(player, SPELL_PUNISHMENT);
me->CastSpell(player, SPELL_PUNISHMENT);
break;
}
case GOSSIPID_GREATER_WS:
{
if (!_twilightSetAura || !_medallionAura || !_ringAura)
go->CastSpell(player, SPELL_PUNISHMENT);
me->CastSpell(player, SPELL_PUNISHMENT);
break;
}
default:
@@ -1054,19 +1054,19 @@ public:
switch (action)
{
case 0:
SummonNPC(go, player, RAND(NPC_TEMPLAR_WATER, NPC_TEMPLAR_FIRE, NPC_TEMPLAR_EARTH, NPC_TEMPLAR_AIR), SPELL_TEMPLAR_RANDOM);
SummonNPC(me, player, RAND(NPC_TEMPLAR_WATER, NPC_TEMPLAR_FIRE, NPC_TEMPLAR_EARTH, NPC_TEMPLAR_AIR), SPELL_TEMPLAR_RANDOM);
break;
case 1:
SummonNPC(go, player, NPC_TEMPLAR_FIRE, SPELL_TEMPLAR_FIRE);
SummonNPC(me, player, NPC_TEMPLAR_FIRE, SPELL_TEMPLAR_FIRE);
break;
case 2:
SummonNPC(go, player, NPC_TEMPLAR_WATER, SPELL_TEMPLAR_WATER);
SummonNPC(me, player, NPC_TEMPLAR_WATER, SPELL_TEMPLAR_WATER);
break;
case 3:
SummonNPC(go, player, NPC_TEMPLAR_EARTH, SPELL_TEMPLAR_EARTH);
SummonNPC(me, player, NPC_TEMPLAR_EARTH, SPELL_TEMPLAR_EARTH);
break;
case 4:
SummonNPC(go, player, NPC_TEMPLAR_AIR, SPELL_TEMPLAR_AIR);
SummonNPC(me, player, NPC_TEMPLAR_AIR, SPELL_TEMPLAR_AIR);
break;
default:
break;
@@ -1077,19 +1077,19 @@ public:
switch (action)
{
case 0:
SummonNPC(go, player, RAND(NPC_DUKE_WATER, NPC_DUKE_FIRE, NPC_DUKE_EARTH, NPC_DUKE_AIR), SPELL_DUKE_RANDOM);
SummonNPC(me, player, RAND(NPC_DUKE_WATER, NPC_DUKE_FIRE, NPC_DUKE_EARTH, NPC_DUKE_AIR), SPELL_DUKE_RANDOM);
break;
case 1:
SummonNPC(go, player, NPC_DUKE_FIRE, SPELL_DUKE_FIRE);
SummonNPC(me, player, NPC_DUKE_FIRE, SPELL_DUKE_FIRE);
break;
case 2:
SummonNPC(go, player, NPC_DUKE_WATER, SPELL_DUKE_WATER);
SummonNPC(me, player, NPC_DUKE_WATER, SPELL_DUKE_WATER);
break;
case 3:
SummonNPC(go, player, NPC_DUKE_EARTH, SPELL_DUKE_EARTH);
SummonNPC(me, player, NPC_DUKE_EARTH, SPELL_DUKE_EARTH);
break;
case 4:
SummonNPC(go, player, NPC_DUKE_AIR, SPELL_DUKE_AIR);
SummonNPC(me, player, NPC_DUKE_AIR, SPELL_DUKE_AIR);
break;
default:
break;
@@ -1100,19 +1100,19 @@ public:
switch (action)
{
case 0:
SummonNPC(go, player, RAND(NPC_ROYAL_WATER, NPC_ROYAL_FIRE, NPC_ROYAL_EARTH, NPC_ROYAL_AIR), SPELL_ROYAL_RANDOM);
SummonNPC(me, player, RAND(NPC_ROYAL_WATER, NPC_ROYAL_FIRE, NPC_ROYAL_EARTH, NPC_ROYAL_AIR), SPELL_ROYAL_RANDOM);
break;
case 1:
SummonNPC(go, player, NPC_ROYAL_FIRE, SPELL_ROYAL_FIRE);
SummonNPC(me, player, NPC_ROYAL_FIRE, SPELL_ROYAL_FIRE);
break;
case 2:
SummonNPC(go, player, NPC_ROYAL_WATER, SPELL_ROYAL_WATER);
SummonNPC(me, player, NPC_ROYAL_WATER, SPELL_ROYAL_WATER);
break;
case 3:
SummonNPC(go, player, NPC_ROYAL_EARTH, SPELL_ROYAL_EARTH);
SummonNPC(me, player, NPC_ROYAL_EARTH, SPELL_ROYAL_EARTH);
break;
case 4:
SummonNPC(go, player, NPC_ROYAL_AIR, SPELL_ROYAL_AIR);
SummonNPC(me, player, NPC_ROYAL_AIR, SPELL_ROYAL_AIR);
break;
default:
break;

View File

@@ -1101,7 +1101,7 @@ public:
bool GossipHello(Player* player, bool /*reportUse*/) override
{
bool hasKey = true;
if (LockEntry const* lock = sLockStore.LookupEntry(go->GetGOInfo()->goober.lockId))
if (LockEntry const* lock = sLockStore.LookupEntry(me->GetGOInfo()->goober.lockId))
{
hasKey = false;
for (uint32 i = 0; i < MAX_LOCK_CASE; ++i)
@@ -1124,18 +1124,18 @@ public:
return false;
_locked = true;
// Start Algalon event
go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
events.ScheduleEvent(EVENT_DESPAWN_CONSOLE, 5000);
if (Creature* brann = go->SummonCreature(NPC_BRANN_BRONZBEARD_ALG, BrannIntroSpawnPos))
if (Creature* brann = me->SummonCreature(NPC_BRANN_BRONZBEARD_ALG, BrannIntroSpawnPos))
brann->AI()->DoAction(ACTION_START_INTRO);
if (InstanceScript* instance = go->GetInstanceScript())
if (InstanceScript* instance = me->GetInstanceScript())
{
instance->SetData(DATA_ALGALON_SUMMON_STATE, 1);
if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetGuidData(GO_DOODAD_UL_SIGILDOOR_01)))
if (GameObject* sigil = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_DOODAD_UL_SIGILDOOR_01)))
sigil->SetGoState(GO_STATE_ACTIVE);
if (GameObject* sigil = ObjectAccessor::GetGameObject(*go, instance->GetGuidData(GO_DOODAD_UL_SIGILDOOR_02)))
if (GameObject* sigil = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_DOODAD_UL_SIGILDOOR_02)))
sigil->SetGoState(GO_STATE_ACTIVE);
}
@@ -1151,7 +1151,7 @@ public:
switch (events.ExecuteEvent())
{
case EVENT_DESPAWN_CONSOLE:
go->Delete();
me->Delete();
break;
}
}

View File

@@ -755,8 +755,8 @@ public:
bool IsFriendly(Unit* passenger)
{
return ((go->GetUInt32Value(GAMEOBJECT_FACTION) == WintergraspFaction[TEAM_HORDE] && passenger->getRaceMask() & RACEMASK_HORDE) ||
(go->GetUInt32Value(GAMEOBJECT_FACTION) == WintergraspFaction[TEAM_ALLIANCE] && passenger->getRaceMask() & RACEMASK_ALLIANCE));
return ((me->GetUInt32Value(GAMEOBJECT_FACTION) == WintergraspFaction[TEAM_HORDE] && passenger->getRaceMask() & RACEMASK_HORDE) ||
(me->GetUInt32Value(GAMEOBJECT_FACTION) == WintergraspFaction[TEAM_ALLIANCE] && passenger->getRaceMask() & RACEMASK_ALLIANCE));
}
Creature* IsValidVehicle(Creature* cVeh)
@@ -765,7 +765,7 @@ public:
if (Vehicle* vehicle = cVeh->GetVehicleKit())
if (Unit* passenger = vehicle->GetPassenger(0))
if (IsFriendly(passenger))
if (Creature* teleportTrigger = passenger->SummonTrigger(go->GetPositionX() - 60.0f, go->GetPositionY(), go->GetPositionZ() + 1.0f, cVeh->GetOrientation(), 1000))
if (Creature* teleportTrigger = passenger->SummonTrigger(me->GetPositionX() - 60.0f, me->GetPositionY(), me->GetPositionZ() + 1.0f, cVeh->GetOrientation(), 1000))
return teleportTrigger;
return nullptr;
@@ -777,7 +777,7 @@ public:
if (_checkTimer >= 1000)
{
for (uint8 i = 0; i < MAX_WINTERGRASP_VEHICLES; i++)
if (Creature* vehicleCreature = go->FindNearestCreature(vehiclesList[i], 3.0f, true))
if (Creature* vehicleCreature = me->FindNearestCreature(vehiclesList[i], 3.0f, true))
if (Creature* teleportTrigger = IsValidVehicle(vehicleCreature))
teleportTrigger->CastSpell(vehicleCreature, SPELL_VEHICLE_TELEPORT, true);

View File

@@ -119,8 +119,8 @@ public:
_timer += diff;
if (_timer > 5000)
{
go->CastSpell(nullptr, 9056);
go->DestroyForNearbyPlayers();
me->CastSpell(nullptr, 9056);
me->DestroyForNearbyPlayers();
_timer = 0;
}
}
@@ -295,7 +295,7 @@ public:
requireSummon = 0;
int8 count = urand(1, 3);
for (int8 i = 0; i < count; ++i)
go->SummonCreature(NPC_WINTERFIN_TADPOLE, go->GetPositionX() + cos(2 * M_PI * i / 3.0f) * 0.60f, go->GetPositionY() + sin(2 * M_PI * i / 3.0f) * 0.60f, go->GetPositionZ(), go->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
me->SummonCreature(NPC_WINTERFIN_TADPOLE, me->GetPositionX() + cos(2 * M_PI * i / 3.0f) * 0.60f, me->GetPositionY() + sin(2 * M_PI * i / 3.0f) * 0.60f, me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
}
void OnStateChanged(uint32 state, Unit* /*unit*/) override
@@ -306,7 +306,7 @@ public:
void UpdateAI(uint32 /*diff*/) override
{
if (go->isSpawned() && requireSummon == 2)
if (me->isSpawned() && requireSummon == 2)
SummonTadpoles();
}
@@ -319,7 +319,7 @@ public:
if (player->GetQuestStatus(QUEST_OH_NOES_THE_TADPOLES) == QUEST_STATUS_INCOMPLETE)
{
std::list<Creature*> cList;
GetCreatureListWithEntryInGrid(cList, go, NPC_WINTERFIN_TADPOLE, 5.0f);
GetCreatureListWithEntryInGrid(cList, me, NPC_WINTERFIN_TADPOLE, 5.0f);
for (std::list<Creature*>::const_iterator itr = cList.begin(); itr != cList.end(); ++itr)
{
player->KilledMonsterCredit(NPC_WINTERFIN_TADPOLE);
@@ -360,15 +360,15 @@ public:
{
timer = 0;
std::list<Player*> players;
Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f);
Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker);
Cell::VisitWorldObjects(go, searcher, 0.3f);
Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(me, 0.3f);
Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(me, players, checker);
Cell::VisitWorldObjects(me, searcher, 0.3f);
if (players.size() > 0)
{
std::list<Player*>::iterator itr = players.begin();
std::advance(itr, urand(0, players.size() - 1));
if (Creature* trigger = go->SummonTrigger((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), 0, 2000, true))
if (Creature* trigger = me->SummonTrigger((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), 0, 2000, true))
trigger->CastSpell(trigger, SPELL_FLAMES);
}
}
@@ -407,15 +407,15 @@ public:
{
timer = 0;
std::list<Player*> players;
Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f);
Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker);
Cell::VisitWorldObjects(go, searcher, 0.3f);
Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(me, 0.3f);
Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(me, players, checker);
Cell::VisitWorldObjects(me, searcher, 0.3f);
if (players.size() > 0)
{
std::list<Player*>::iterator itr = players.begin();
std::advance(itr, urand(0, players.size() - 1));
if (Creature* trigger = go->SummonTrigger((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), 0, 2000, true))
if (Creature* trigger = me->SummonTrigger((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), 0, 2000, true))
trigger->CastSpell(trigger, SPELL_HEAT);
}
}
@@ -509,7 +509,7 @@ public:
//Restart the current selected music
_currentMusicEvent = 0;
//Check zone to play correct music
if (go->GetAreaId() == SILVERMOON || go->GetAreaId() == UNDERCITY || go->GetAreaId() == ORGRIMMAR_1 || go->GetAreaId() == ORGRIMMAR_2 || go->GetAreaId() == THUNDERBLUFF)
if (me->GetAreaId() == SILVERMOON || me->GetAreaId() == UNDERCITY || me->GetAreaId() == ORGRIMMAR_1 || me->GetAreaId() == ORGRIMMAR_2 || me->GetAreaId() == THUNDERBLUFF)
{
switch (rnd)
{
@@ -529,7 +529,7 @@ public:
break;
}
}
else if (go->GetAreaId() == IRONFORGE_1 || go->GetAreaId() == IRONFORGE_2 || go->GetAreaId() == STORMWIND || go->GetAreaId() == EXODAR || go->GetAreaId() == DARNASSUS)
else if (me->GetAreaId() == IRONFORGE_1 || me->GetAreaId() == IRONFORGE_2 || me->GetAreaId() == STORMWIND || me->GetAreaId() == EXODAR || me->GetAreaId() == DARNASSUS)
{
switch (rnd)
{
@@ -549,7 +549,7 @@ public:
break;
}
}
else if (go->GetAreaId() == SHATTRATH)
else if (me->GetAreaId() == SHATTRATH)
{
rnd = urand(0, 5);
switch (rnd)
@@ -591,7 +591,7 @@ public:
// Play selected music
if (_currentMusicEvent != 0)
{
go->PlayDirectMusic(_currentMusicEvent);
me->PlayDirectMusic(_currentMusicEvent);
}
_events.ScheduleEvent(EVENT_BM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client
break;
@@ -649,7 +649,7 @@ public:
case EVENT_PDM_START_MUSIC:
if (!IsHolidayActive(HOLIDAY_PIRATES_DAY))
break;
go->PlayDirectMusic(MUSIC_PIRATE_DAY_MUSIC);
me->PlayDirectMusic(MUSIC_PIRATE_DAY_MUSIC);
_events.ScheduleEvent(EVENT_PDM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client (sniffed value)
break;
default:
@@ -704,7 +704,7 @@ public:
case EVENT_DFM_START_MUSIC:
if (!IsHolidayActive(HOLIDAY_DARKMOON_FAIRE_ELWYNN) || !IsHolidayActive(HOLIDAY_DARKMOON_FAIRE_THUNDER) || !IsHolidayActive(HOLIDAY_DARKMOON_FAIRE_SHATTRATH))
break;
go->PlayDirectMusic(MUSIC_DARKMOON_FAIRE_MUSIC);
me->PlayDirectMusic(MUSIC_DARKMOON_FAIRE_MUSIC);
_events.ScheduleEvent(EVENT_DFM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client (sniffed value)
break;
default:
@@ -761,18 +761,18 @@ public:
if (!IsHolidayActive(HOLIDAY_FIRE_FESTIVAL))
break;
Map::PlayerList const& players = go->GetMap()->GetPlayers();
Map::PlayerList const& players = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* player = itr->GetSource())
{
if (player->GetTeamId() == TEAM_HORDE)
{
go->PlayDirectMusic(EVENTMIDSUMMERFIREFESTIVAL_H, player);
me->PlayDirectMusic(EVENTMIDSUMMERFIREFESTIVAL_H, player);
}
else
{
go->PlayDirectMusic(EVENTMIDSUMMERFIREFESTIVAL_A, player);
me->PlayDirectMusic(EVENTMIDSUMMERFIREFESTIVAL_A, player);
}
}
}
@@ -1389,7 +1389,7 @@ public:
if (reportUse)
return false;
Unit* owner = go->GetOwner();
Unit* owner = me->GetOwner();
if (_stoneSpell == 0 || _stoneId == 0)
{
if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell))
@@ -1416,7 +1416,7 @@ public:
// Item has to actually be created to remove a charge on the well.
if (player->HasItemCount(_stoneId))
go->AddUse();
me->AddUse();
return true;
}