Skip to content

Commit 4de904b

Browse files
committed
[2768] Use SetFactionTemporary on a larger scale. Requires C-MaNGOS 12292
* Change all escort/ follow scripts to use SetFactionTemporary with RESTORE_RESPAWN to simplify and unify code * Change a few (not all) other scripts as well to use SetFactionTemporary instead of setFaction to have better scope control. * Use TOGGLE_FLAG modifiers to handle required UNIT_FLAG changes on faction change of DireMaul, Prince Tortheldrin so that he works properly now * Improve script for Aquementas a little bit, so that he will work if attacked by a player's pet
1 parent 8a05760 commit 4de904b

48 files changed

Lines changed: 75 additions & 149 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/escort_ai.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ void npc_escortAI::JustRespawned()
207207
// add a small delay before going to first waypoint, normal in near all cases
208208
m_uiWPWaitTimer = 2500;
209209

210-
if (m_creature->getFaction() != m_creature->GetCreatureInfo()->faction_A)
211-
m_creature->setFaction(m_creature->GetCreatureInfo()->faction_A);
212-
213210
Reset();
214211
}
215212

base/follower_ai.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ void FollowerAI::JustRespawned()
153153
if (!IsCombatMovement())
154154
SetCombatMovement(true);
155155

156-
if (m_creature->getFaction() != m_creature->GetCreatureInfo()->faction_A)
157-
m_creature->setFaction(m_creature->GetCreatureInfo()->faction_A);
158-
159156
Reset();
160157
}
161158

@@ -291,7 +288,7 @@ void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const
291288
m_leaderGuid = pLeader->GetObjectGuid();
292289

293290
if (uiFactionForFollower)
294-
m_creature->setFaction(uiFactionForFollower);
291+
m_creature->SetFactionTemporary(uiFactionForFollower, TEMPFACTION_RESTORE_RESPAWN);
295292

296293
m_pQuestForFollow = pQuest;
297294

scripts/eastern_kingdoms/arathi_highlands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bool QuestAccept_npc_professor_phizzlethorpe(Player* pPlayer, Creature* pCreatur
100100
{
101101
if (pQuest->GetQuestId() == QUEST_SUNKEN_TREASURE)
102102
{
103-
pCreature->setFaction(FACTION_ESCORT_N_NEUTRAL_PASSIVE);
103+
pCreature->SetFactionTemporary(FACTION_ESCORT_N_NEUTRAL_PASSIVE, TEMPFACTION_RESTORE_RESPAWN);
104104
DoScriptText(SAY_PROGRESS_1, pCreature, pPlayer);
105105

106106
if (npc_professor_phizzlethorpeAI* pEscortAI = dynamic_cast<npc_professor_phizzlethorpeAI*>(pCreature->AI()))

scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ struct MANGOS_DLL_DECL npc_rocknotAI : public npc_escortAI
630630
// spell by trap has effect61, this indicate the bar go hostile
631631

632632
if (Creature* pTmp = m_pInstance->GetSingleCreatureFromStorage(NPC_PHALANX))
633-
pTmp->setFaction(14);
633+
pTmp->SetFactionTemporary(14, TEMPFACTION_NONE);
634634

635635
// for later, this event(s) has alot more to it.
636636
// optionally, DONE can trigger bar to go hostile.

scripts/eastern_kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct MANGOS_DLL_DECL boss_emperor_dagran_thaurissanAI : public ScriptedAI
7070
{
7171
if (pPrincess->isAlive())
7272
{
73-
pPrincess->setFaction(FACTION_NEUTRAL);
73+
pPrincess->SetFactionTemporary(FACTION_NEUTRAL, TEMPFACTION_NONE);
7474
pPrincess->AI()->EnterEvadeMode();
7575
}
7676
}

scripts/eastern_kingdoms/blackrock_spire/instance_blackrock_spire.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ bool AreaTrigger_at_blackrock_spire(Player* pPlayer, AreaTriggerEntry const* pAt
574574
// Summon Nefarius and Rend for the dialogue event
575575
// Note: Nefarius and Rend need to be hostile and not attackable
576576
if (Creature* pNefarius = pPlayer->SummonCreature(NPC_LORD_VICTOR_NEFARIUS, aStadiumLocs[3].m_fX, aStadiumLocs[3].m_fY, aStadiumLocs[3].m_fZ, aStadiumLocs[3].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
577-
pNefarius->setFaction(FACTION_BLACK_DRAGON);
577+
pNefarius->SetFactionTemporary(FACTION_BLACK_DRAGON, TEMPFACTION_NONE);
578578
if (Creature* pRend = pPlayer->SummonCreature(NPC_REND_BLACKHAND, aStadiumLocs[4].m_fX, aStadiumLocs[4].m_fY, aStadiumLocs[4].m_fZ, aStadiumLocs[4].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
579579
pRend->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
580580

scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ struct MANGOS_DLL_DECL boss_vaelastraszAI : public ScriptedAI
224224
++m_uiSpeechNum;
225225
break;
226226
case 2:
227-
m_creature->setFaction(FACTION_HOSTILE);
227+
m_creature->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_RESTORE_RESPAWN);
228228

229229
if (m_playerGuid)
230230
{

scripts/eastern_kingdoms/ghostlands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool QuestAccept_npc_ranger_lilatha(Player* pPlayer, Creature* pCreature, const
145145
{
146146
if (pQuest->GetQuestId() == QUEST_CATACOMBS)
147147
{
148-
pCreature->setFaction(FACTION_SMOON_E);
148+
pCreature->SetFactionTemporary(FACTION_SMOON_E, TEMPFACTION_RESTORE_RESPAWN);
149149

150150
if (npc_ranger_lilathaAI* pEscortAI = dynamic_cast<npc_ranger_lilathaAI*>(pCreature->AI()))
151151
pEscortAI->Start(false, pPlayer, pQuest);

scripts/eastern_kingdoms/gnomeregan/gnomeregan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ struct MANGOS_DLL_DECL npc_blastmaster_emi_shortfuseAI : public npc_escortAI
347347
{
348348
case 1:
349349
DoScriptText(SAY_START, m_creature);
350-
m_creature->setFaction(FACTION_ESCORT_N_NEUTRAL_PASSIVE);
350+
m_creature->SetFactionTemporary(FACTION_ESCORT_N_NEUTRAL_PASSIVE, TEMPFACTION_RESTORE_RESPAWN);
351351
m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
352352
m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
353353
m_uiPhaseTimer = 5000;

scripts/eastern_kingdoms/hinterlands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ bool QuestAccept_npc_00x09hl(Player* pPlayer, Creature* pCreature, const Quest*
115115
if (pQuest->GetQuestId() == QUEST_RESQUE_OOX_09)
116116
{
117117
pCreature->SetStandState(UNIT_STAND_STATE_STAND);
118-
pCreature->setFaction((pPlayer->GetTeam() == ALLIANCE) ? FACTION_ESCORT_A_PASSIVE : FACTION_ESCORT_H_PASSIVE);
118+
pCreature->SetFactionTemporary(pPlayer->GetTeam() == ALLIANCE ? FACTION_ESCORT_A_PASSIVE : FACTION_ESCORT_H_PASSIVE, TEMPFACTION_RESTORE_RESPAWN);
119119

120120
DoScriptText(SAY_OOX_START, pCreature, pPlayer);
121121

0 commit comments

Comments
 (0)