aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgvcoman <none@none>2008-11-20 20:27:04 -0500
committergvcoman <none@none>2008-11-20 20:27:04 -0500
commit4495efa1aeaf58650dfcee95f709969cc33ce6c8 (patch)
tree844f5f69e73f6bcfd4b3bd306ca83bd38683e91e
parentdf6a8e5f8e11e914843db0dc9c41f3a415587cfd (diff)
* Don't allow pets to attack in melee if owner is pacified. This applies for possessed "pets" as well.
* Use proper spell ID in unsummoning possessed units on channeling interrupt. * Allow only once to init pet bar for CharmInfo * Export CharmInfo to be available to scripts * Allow to disable the melee attack command when initializing the pet action bar --HG-- branch : trunk
-rw-r--r--src/game/PetHandler.cpp7
-rw-r--r--src/game/PossessedAI.cpp4
-rw-r--r--src/game/Unit.cpp35
-rw-r--r--src/game/Unit.h5
4 files changed, 34 insertions, 17 deletions
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
index f95be3a9352..d912f42c22b 100644
--- a/src/game/PetHandler.cpp
+++ b/src/game/PetHandler.cpp
@@ -97,6 +97,13 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
break;
case COMMAND_ATTACK: //spellid=1792 //ATTACK
{
+ // Can't attack if owner is pacified
+ if (_player->HasAuraType(SPELL_AURA_MOD_PACIFY))
+ {
+ //pet->SendPetCastFail(spellid, SPELL_FAILED_PACIFIED);
+ //TODO: Send proper error message to client
+ return;
+ }
// only place where pet can be player
pet->clearUnitState(UNIT_STAT_FOLLOW);
uint64 selguid = _player->GetSelection();
diff --git a/src/game/PossessedAI.cpp b/src/game/PossessedAI.cpp
index 6b803303185..8abbb7f2603 100644
--- a/src/game/PossessedAI.cpp
+++ b/src/game/PossessedAI.cpp
@@ -24,7 +24,7 @@
void PossessedAI::AttackStart(Unit *u)
{
- if( !u )
+ if( !u || i_pet.GetCharmer()->HasAuraType(SPELL_AURA_MOD_PACIFY))
return;
if (i_pet.getVictim() && u != i_pet.getVictim())
@@ -95,7 +95,7 @@ void PossessedAI::UpdateAI(const uint32 diff)
_stopAttack(); // i_victimGuid == 0 && i_pet.getVictim() == NULL now
return;
}
- else if(i_pet.IsWithinCombatDist(i_pet.getVictim(), ATTACK_DISTANCE) && i_pet.isAttackReady())
+ else if(i_pet.IsWithinCombatDist(i_pet.getVictim(), ATTACK_DISTANCE) && i_pet.isAttackReady() && !i_pet.GetCharmer()->HasAuraType(SPELL_AURA_MOD_PACIFY))
{
i_pet.AttackerStateUpdate(i_pet.getVictim());
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 264b81bd0cd..c54ab4b7f0d 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -3421,15 +3421,8 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
// channeled spells are interrupted if they are not finished, even if they are delayed
if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id==spell_id))
{
- if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)
- m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
- m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false);
- m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL;
-
// Unsummon any summoned as possessed creatures on channel interrupt
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
- if (!spellInfo || !interrupted)
- return;
+ SpellEntry const *spellInfo = m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo;
for (int i = 0; i < 3; i++)
{
if (spellInfo->Effect[i] == SPELL_EFFECT_SUMMON &&
@@ -3442,6 +3435,11 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
((TemporarySummon*)GetCharm())->UnSummon();
}
}
+
+ if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)
+ m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
+ m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false);
+ m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL;
}
}
@@ -9820,7 +9818,7 @@ CharmInfo* Unit::InitCharmInfo(Unit *charm)
}
CharmInfo::CharmInfo(Unit* unit)
-: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0)
+: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0), m_barInit(false)
{
for(int i =0; i<4; ++i)
{
@@ -9831,6 +9829,9 @@ CharmInfo::CharmInfo(Unit* unit)
void CharmInfo::InitPetActionBar()
{
+ if (m_barInit)
+ return;
+
// the first 3 SpellOrActions are attack, follow and stay
for(uint32 i = 0; i < 3; i++)
{
@@ -9845,17 +9846,25 @@ void CharmInfo::InitPetActionBar()
PetActionBar[i + 3].Type = ACT_DISABLED;
PetActionBar[i + 3].SpellOrAction = 0;
}
+ m_barInit = true;
}
-void CharmInfo::InitEmptyActionBar()
+void CharmInfo::InitEmptyActionBar(bool withAttack)
{
- for(uint32 x = 1; x < 10; ++x)
+ if (m_barInit)
+ return;
+
+ for(uint32 x = 0; x < 10; ++x)
{
PetActionBar[x].Type = ACT_CAST;
PetActionBar[x].SpellOrAction = 0;
}
- PetActionBar[0].Type = ACT_COMMAND;
- PetActionBar[0].SpellOrAction = COMMAND_ATTACK;
+ if (withAttack)
+ {
+ PetActionBar[0].Type = ACT_COMMAND;
+ PetActionBar[0].SpellOrAction = COMMAND_ATTACK;
+ }
+ m_barInit = true;
}
void CharmInfo::InitPossessCreateSpells()
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 028c590c06f..e9e44804444 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -640,7 +640,7 @@ struct CharmSpellEntry
typedef std::list<Player*> SharedVisionList;
-struct CharmInfo
+struct TRINITY_DLL_SPEC CharmInfo
{
public:
explicit CharmInfo(Unit* unit);
@@ -657,7 +657,7 @@ struct CharmInfo
void InitPossessCreateSpells();
void InitCharmCreateSpells();
void InitPetActionBar();
- void InitEmptyActionBar();
+ void InitEmptyActionBar(bool withAttack = true);
//return true if successful
bool AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate = ACT_DECIDE);
void ToggleCreatureAutocast(uint32 spellid, bool apply);
@@ -671,6 +671,7 @@ struct CharmInfo
CommandStates m_CommandState;
ReactStates m_reactState;
uint32 m_petnumber;
+ bool m_barInit;
};
// for clearing special attacks