[10840] Implement server side part of SPELL_AURA_ADD_MECHANIC_ABILITIES (293) work.

Also fix stealth/invisibility visual affect flags changed at some 3.x switch.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
kb_z 2010-12-08 09:10:22 +03:00 committed by VladimirMangos
parent 1fef606dd8
commit 1b4210e38c
9 changed files with 69 additions and 18 deletions

View file

@ -343,7 +343,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
&Aura::HandleAuraModAllCritChance, //290 SPELL_AURA_MOD_ALL_CRIT_CHANCE
&Aura::HandleNoImmediateEffect, //291 SPELL_AURA_MOD_QUEST_XP_PCT implemented in Player::GiveXP
&Aura::HandleAuraOpenStable, //292 call stabled pet
&Aura::HandleNULL, //293 3 spells
&Aura::HandleAuraAddMechanicAbilities, //293 SPELL_AURA_ADD_MECHANIC_ABILITIES replaces target's action bars with a predefined spellset
&Aura::HandleNULL, //294 2 spells, possible prevent mana regen
&Aura::HandleUnused, //295 unused (3.2.2a)
&Aura::HandleNULL, //296 2 spells
@ -3928,7 +3928,7 @@ void Aura::HandleModStealth(bool apply, bool Real)
target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
if (target->GetTypeId()==TYPEID_PLAYER)
target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000);
target->SetByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_STEALTH);
// apply only if not in GM invisibility (and overwrite invisibility state)
if (target->GetVisibility()!=VISIBILITY_OFF)
@ -3970,7 +3970,7 @@ void Aura::HandleModStealth(bool apply, bool Real)
target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
if (target->GetTypeId()==TYPEID_PLAYER)
target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000);
target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_STEALTH);
// restore invisibility if any
if (target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
@ -4007,21 +4007,21 @@ void Aura::HandleInvisibility(bool apply, bool Real)
{
Unit *target = GetTarget();
if(apply)
if (apply)
{
target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
if(Real && target->GetTypeId()==TYPEID_PLAYER)
if (Real && target->GetTypeId()==TYPEID_PLAYER)
{
// apply glow vision
target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
target->SetByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
}
// apply only if not in GM invisibility and not stealth
if(target->GetVisibility() == VISIBILITY_ON)
if (target->GetVisibility() == VISIBILITY_ON)
{
// Aura not added yet but visibility code expect temporary add aura
target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
@ -4037,17 +4037,17 @@ void Aura::HandleInvisibility(bool apply, bool Real)
target->m_invisibilityMask |= (1 << (*itr)->GetModifier()->m_miscvalue);
// only at real aura remove and if not have different invisibility auras.
if(Real && target->m_invisibilityMask == 0)
if (Real && target->m_invisibilityMask == 0)
{
// remove glow vision
if(target->GetTypeId() == TYPEID_PLAYER)
target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
if (target->GetTypeId() == TYPEID_PLAYER)
target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
// apply only if not in GM invisibility & not stealthed while invisible
if(target->GetVisibility() != VISIBILITY_OFF)
if (target->GetVisibility() != VISIBILITY_OFF)
{
// if have stealth aura then already have stealth visibility
if(!target->HasAuraType(SPELL_AURA_MOD_STEALTH))
if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH))
target->SetVisibility(VISIBILITY_ON);
}
}
@ -7574,6 +7574,42 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real)
}
}
void Aura::HandleAuraAddMechanicAbilities(bool apply, bool Real)
{
if (!Real)
return;
Unit* target = GetTarget();
if (!target || target->GetTypeId() != TYPEID_PLAYER) // only players should be affected by this aura
return;
uint16 i_OverrideSetId = GetMiscValue();
const OverrideSpellDataEntry *spellSet = sOverrideSpellDataStore.LookupEntry(i_OverrideSetId);
if (!spellSet)
return;
if (apply)
{
// spell give the player a new castbar with some spells.. this is a clientside process..
// serverside just needs to register the new spells so that player isn't kicked as cheater
for (int i = 0; i < MAX_OVERRIDE_SPELLS; i++)
if (uint32 spellId = spellSet->Spells[i])
static_cast<Player*>(target)->addSpell(spellId, true, false, false, false);
target->SetUInt16Value(PLAYER_FIELD_BYTES2, 0, i_OverrideSetId);
}
else
{
target->SetUInt16Value(PLAYER_FIELD_BYTES2, 0, 0);
for (int i = 0; i < MAX_OVERRIDE_SPELLS; i++)
if (uint32 spellId = spellSet->Spells[i])
static_cast<Player*>(target)->removeSpell(spellId, false , false, false);
}
}
void Aura::HandleAuraOpenStable(bool apply, bool Real)
{
if(!Real || GetTarget()->GetTypeId() != TYPEID_PLAYER || !GetTarget()->IsInWorld())