* 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
This commit is contained in:
gvcoman
2008-11-20 20:27:04 -05:00
parent df6a8e5f8e
commit 4495efa1ae
4 changed files with 34 additions and 17 deletions

View File

@@ -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();

View File

@@ -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());

View File

@@ -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()

View File

@@ -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