aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthenecromancer <none@none>2010-01-13 10:45:34 +0100
committerthenecromancer <none@none>2010-01-13 10:45:34 +0100
commit8c5ece6420944d8d4b6f76bacde3a21a63c61db8 (patch)
treebf7fa5021498bce73583142a3f7aa4f38c55e93f
parentb98fc794e4cdf64f79b6ec45bdb0ab2f55313a41 (diff)
Implement effect for aura #243 (temporary faction change)
--HG-- branch : trunk
-rw-r--r--src/game/SpellAuraDefines.h2
-rw-r--r--src/game/SpellAuraEffects.cpp24
-rw-r--r--src/game/SpellAuraEffects.h1
-rw-r--r--src/game/Unit.cpp30
4 files changed, 43 insertions, 14 deletions
diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h
index 3a3942e9840..9a79dafe1d9 100644
--- a/src/game/SpellAuraDefines.h
+++ b/src/game/SpellAuraDefines.h
@@ -287,7 +287,7 @@ enum AuraType
SPELL_AURA_MOD_EXPERTISE = 240,
SPELL_AURA_FORCE_MOVE_FORWARD = 241,
SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING = 242,
- SPELL_AURA_243 = 243,
+ SPELL_AURA_MOD_FACTION = 243,
SPELL_AURA_COMPREHEND_LANGUAGE = 244,
SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL = 245,
SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK = 246,
diff --git a/src/game/SpellAuraEffects.cpp b/src/game/SpellAuraEffects.cpp
index 6c2dd451239..56a1e78fd40 100644
--- a/src/game/SpellAuraEffects.cpp
+++ b/src/game/SpellAuraEffects.cpp
@@ -298,7 +298,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE
&AuraEffect::HandleForceMoveForward, //241 SPELL_AURA_FORCE_MOVE_FORWARD Forces the player to move forward
&AuraEffect::HandleNULL, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING - 2 test spells: 44183 and 44182
- &AuraEffect::HandleNULL, //243 faction reaction override spells
+ &AuraEffect::HandleAuraModFaction, //243 SPELL_AURA_MOD_FACTION
&AuraEffect::HandleComprehendLanguage, //244 SPELL_AURA_COMPREHEND_LANGUAGE
&AuraEffect::HandleNoImmediateEffect, //245 SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL
&AuraEffect::HandleNoImmediateEffect, //246 SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK implemented in Spell::EffectApplyAura
@@ -5997,6 +5997,28 @@ void AuraEffect::HandleAuraEmpathy(AuraApplication const * aurApp, uint8 mode, b
target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
}
+void AuraEffect::HandleAuraModFaction(AuraApplication const * aurApp, uint8 mode, bool apply) const
+{
+ if(!(mode & AURA_EFFECT_HANDLE_REAL))
+ return;
+
+ Unit * target = aurApp->GetTarget();
+
+ if(apply)
+ {
+ target->setFaction(GetMiscValue());
+ if(target->GetTypeId()==TYPEID_PLAYER)
+ target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
+ }
+ else
+ {
+ target->RestoreFaction();
+ if(target->GetTypeId()==TYPEID_PLAYER)
+ target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
+ }
+}
+
+
void AuraEffect::HandleComprehendLanguage(AuraApplication const * aurApp, uint8 mode, bool apply) const
{
if(!(mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK))
diff --git a/src/game/SpellAuraEffects.h b/src/game/SpellAuraEffects.h
index 75e061da5fe..3adf009e388 100644
--- a/src/game/SpellAuraEffects.h
+++ b/src/game/SpellAuraEffects.h
@@ -255,6 +255,7 @@ class TRINITY_DLL_SPEC AuraEffect
void HandleBindSight(AuraApplication const * aurApp, uint8 mode, bool apply) const;
void HandleForceReaction(AuraApplication const * aurApp, uint8 mode, bool apply) const;
void HandleAuraEmpathy(AuraApplication const * aurApp, uint8 mode, bool apply) const;
+ void HandleAuraModFaction(AuraApplication const * aurApp, uint8 mode, bool apply) const;
void HandleComprehendLanguage(AuraApplication const * aurApp, uint8 mode, bool apply) const;
void HandleAuraConvertRune(AuraApplication const * aurApp, uint8 mode, bool apply) const;
void HandleAuraLinked(AuraApplication const * aurApp, uint8 mode, bool apply) const;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 25d50607e9a..78e8ece31bd 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -8564,11 +8564,14 @@ bool Unit::IsHostileTo(Unit const* unit) const
//= PvP states
// Green/Blue (can't attack)
- if(pTester->GetTeam()==pTarget->GetTeam())
- return false;
+ if (!pTester->HasAuraType(SPELL_AURA_MOD_FACTION) && !pTarget->HasAuraType(SPELL_AURA_MOD_FACTION))
+ {
+ if(pTester->GetTeam()==pTarget->GetTeam())
+ return false;
- // Red (can attack) if true, Blue/Yellow (can't attack) in another case
- return pTester->IsPvP() && pTarget->IsPvP();
+ // Red (can attack) if true, Blue/Yellow (can't attack) in another case
+ return pTester->IsPvP() && pTarget->IsPvP();
+ }
}
// faction base cases
@@ -8581,7 +8584,7 @@ bool Unit::IsHostileTo(Unit const* unit) const
return true;
// PvC forced reaction and reputation case
- if(tester->GetTypeId() == TYPEID_PLAYER)
+ if(tester->GetTypeId() == TYPEID_PLAYER && !tester->HasAuraType(SPELL_AURA_MOD_FACTION))
{
// forced reaction
if(target_faction->faction)
@@ -8596,7 +8599,7 @@ bool Unit::IsHostileTo(Unit const* unit) const
}
}
// CvP forced reaction and reputation case
- else if(target->GetTypeId() == TYPEID_PLAYER)
+ else if(target->GetTypeId() == TYPEID_PLAYER && !target->HasAuraType(SPELL_AURA_MOD_FACTION))
{
// forced reaction
if(tester_faction->faction)
@@ -8676,11 +8679,14 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
//= PvP states
// Green/Blue (non-attackable)
- if(pTester->GetTeam()==pTarget->GetTeam())
- return true;
+ if (!pTester->HasAuraType(SPELL_AURA_MOD_FACTION) && !pTarget->HasAuraType(SPELL_AURA_MOD_FACTION))
+ {
+ if(pTester->GetTeam()==pTarget->GetTeam())
+ return true;
- // Blue (friendly/non-attackable) if not PVP, or Yellow/Red in another case (attackable)
- return !pTarget->IsPvP();
+ // Blue (friendly/non-attackable) if not PVP, or Yellow/Red in another case (attackable)
+ return !pTarget->IsPvP();
+ }
}
// faction base cases
@@ -8693,7 +8699,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
return false;
// PvC forced reaction and reputation case
- if (tester->GetTypeId() == TYPEID_PLAYER)
+ if (tester->GetTypeId() == TYPEID_PLAYER && !tester->HasAuraType(SPELL_AURA_MOD_FACTION))
{
// forced reaction
if (target_faction->faction)
@@ -8708,7 +8714,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
}
}
// CvP forced reaction and reputation case
- else if (target->GetTypeId() == TYPEID_PLAYER)
+ else if (target->GetTypeId() == TYPEID_PLAYER && !target->HasAuraType(SPELL_AURA_MOD_FACTION))
{
// forced reaction
if (tester_faction->faction)