diff options
author | megamage <none@none> | 2009-05-19 01:23:52 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-05-19 01:23:52 -0500 |
commit | 2a2eff190c2ab9c0fb2f1e7b99209c36ab42eb46 (patch) | |
tree | 0ae8f681da4e01a710b8667118532881f4a35685 /src | |
parent | 833ceee7c52df5e7437d45d2970c5c30cb97e633 (diff) |
*Fix some bugs about pet spells: such as cannot cast/cannot autocast.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Pet.cpp | 40 | ||||
-rw-r--r-- | src/game/Pet.h | 7 | ||||
-rw-r--r-- | src/game/Spell.cpp | 22 | ||||
-rw-r--r-- | src/game/Unit.cpp | 34 |
4 files changed, 46 insertions, 57 deletions
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index a1db50ee67a..24d71ca631f 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -272,12 +272,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool } else { - _LoadSpells(); - _LoadSpellCooldowns(); - LearnPetPassives(); - InitLevelupSpellsForLevel(); - CastPetAuras(current); - // Load action bar data if (!is_temporary_summoned) { @@ -297,17 +291,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool m_charmInfo->GetActionBarEntry(index)->Type = atol((*iter).c_str()); ++iter; m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str()); - - // patch for old data where some spells have ACT_DECIDE but should have ACT_CAST - // so overwrite old state - if(SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_charmInfo->GetActionBarEntry(index)->SpellOrAction)) - { - if (spellInfo && spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) - m_charmInfo->GetActionBarEntry(index)->Type = ACT_DISABLED; - - if(m_charmInfo->GetActionBarEntry(index)->Type == ACT_ENABLED) - ToggleAutocast(spellInfo->Id, true); - } + if(m_charmInfo->GetActionBarEntry(index)->Type == ACT_ENABLED && !IsAutocastableSpell(m_charmInfo->GetActionBarEntry(index)->SpellOrAction)) + m_charmInfo->GetActionBarEntry(index)->Type = ACT_PASSIVE; } //init teach spells @@ -323,6 +308,12 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool else break; } + + _LoadSpells(); + _LoadSpellCooldowns(); + LearnPetPassives(); + InitLevelupSpellsForLevel(); + CastPetAuras(current); } } @@ -1249,10 +1240,6 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel return false; } - // same spells don't have autocast option - if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) - active = ACT_DISABLED; - PetSpellMap::iterator itr = m_spells.find(spell_id); if (itr != m_spells.end()) { @@ -1285,10 +1272,10 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel if(active == ACT_DECIDE) //active was not used before, so we save it's autocast/passive state here { - if(IsPassiveSpell(spell_id)) - newspell.active = ACT_PASSIVE; - else + if(IsAutocastableSpell(spell_id)) newspell.active = ACT_DISABLED; + else + newspell.active = ACT_PASSIVE; } else newspell.active = active; @@ -1344,8 +1331,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel if (IsPassiveSpell(spell_id)) CastSpell(this, spell_id, true); else - //m_charmInfo->AddSpellToAB(oldspell_id, spell_id); - m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active); + m_charmInfo->AddSpellToAB(oldspell_id, spell_id); if(newspell.active == ACT_ENABLED) ToggleAutocast(spell_id, true); @@ -1668,7 +1654,7 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) void Pet::ToggleAutocast(uint32 spellid, bool apply) { - if(IsPassiveSpell(spellid)) + if(!IsAutocastableSpell(spellid)) return; PetSpellMap::iterator itr = m_spells.find(spellid); diff --git a/src/game/Pet.h b/src/game/Pet.h index 6ae7ddc64e9..a92d53cecdb 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -70,10 +70,9 @@ enum PetSpellType struct PetSpell { - ActiveStates active : 16; - - PetSpellState state : 8; - PetSpellType type : 8; + ActiveStates active; + PetSpellState state; + PetSpellType type; }; enum ActionFeedback diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 5a68a5dee95..8f74606cda1 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4649,28 +4649,25 @@ SpellCastResult Spell::CheckPetCast(Unit* target) if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo)) return SPELL_FAILED_AFFECTING_COMBAT; - if(m_caster->GetTypeId()==TYPEID_UNIT && (((Creature*)m_caster)->isPet() || m_caster->isCharmed())) - { //dead owner (pets still alive when owners ressed?) - if(m_caster->GetCharmerOrOwner() && !m_caster->GetCharmerOrOwner()->isAlive()) - return SPELL_FAILED_CASTER_DEAD; + if(Unit *owner = m_caster->GetCharmerOrOwner()) + if(!owner->isAlive()) + return SPELL_FAILED_CASTER_DEAD; if(!target && m_targets.getUnitTarget()) target = m_targets.getUnitTarget(); - bool need = false; - for(uint32 i = 0;i<3;i++) + for(uint32 i = 0; i < 3; ++i) { - if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ALLY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ANY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_PARTY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_DST_TARGET_ENEMY) + if(spellmgr.SpellTargetType[m_spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET + || spellmgr.SpellTargetType[m_spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET) { - need = true; if(!target) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + m_targets.setUnitTarget(target); break; } } - if(need) - m_targets.setUnitTarget(target); Unit* _target = m_targets.getUnitTarget(); @@ -4685,7 +4682,6 @@ SpellCastResult Spell::CheckPetCast(Unit* target) //cooldown if(((Creature*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) return SPELL_FAILED_NOT_READY; - } return CheckCast(true); } @@ -4816,8 +4812,8 @@ bool Spell::CanAutoCast(Unit* target) } else if ( IsAreaAuraEffect( m_spellInfo->Effect[j] )) { - if( target->HasAuraEffect(m_spellInfo->Id, j) ) - return false; + if( target->HasAuraEffect(m_spellInfo->Id, j) ) + return false; } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index df78769efe2..97791d48417 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11762,20 +11762,26 @@ void CharmInfo::InitCharmCreateSpells() else { ActiveStates newstate; - bool onlyselfcast = true; - - if(!spellInfo) onlyselfcast = false; - for(uint32 i = 0;i<3 && onlyselfcast;++i) //non existent spell will not make any problems as onlyselfcast would be false -> break right away + if(spellInfo) { - if(spellInfo->EffectImplicitTargetA[i] != TARGET_UNIT_CASTER && spellInfo->EffectImplicitTargetA[i] != 0) - onlyselfcast = false; - } - - if(onlyselfcast || !IsPositiveSpell(spellId)) //only self cast and spells versus enemies are autocastable - newstate = ACT_DISABLED; - else - newstate = ACT_PASSIVE; + if(!IsAutocastableSpell(spellId)) + newstate = ACT_PASSIVE; + else + { + bool autocast = false; + for(uint32 i = 0; i < 3 && !autocast; ++i) + if(spellmgr.SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET) + autocast = true; + if(autocast) + { + newstate = ACT_ENABLED; + ToggleCreatureAutocast(spellId, true); + } + else + newstate = ACT_DISABLED; + } + } AddSpellToAB(0, spellId, newstate); } } @@ -11799,7 +11805,9 @@ bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate) PetActionBar[i].SpellOrAction = newid; if (!oldid) { - if (newstate == ACT_DECIDE) + if(!IsAutocastableSpell(newid)) + PetActionBar[i].Type = ACT_PASSIVE; + else if (newstate == ACT_DECIDE) PetActionBar[i].Type = ACT_DISABLED; else PetActionBar[i].Type = newstate; |