void OnLoad() { if (_unit->IsPet()) { Pet* s = TO< Pet* >(_unit); Player* owner = s->GetPetOwner(); float owner_bonus = static_cast<float>(owner->GetDamageDoneMod(SCHOOL_SHADOW) * 0.375f); // 37.5% s->BaseAttackType = SCHOOL_SHADOW; // Melee hits are supposed to do damage with the shadow school s->SetBaseAttackTime(MELEE, 1500); // Shadowfiend is supposed to do 10 attacks, sometimes it can be 11 s->SetMinDamage(s->GetMinDamage() + owner_bonus); s->SetMaxDamage(s->GetMaxDamage() + owner_bonus); s->BaseDamage[0] += owner_bonus; s->BaseDamage[1] += owner_bonus; Unit* uTarget = s->GetMapMgr()->GetUnit(owner->GetTargetGUID()); if ((uTarget != NULL) && isAttackable(owner, uTarget)) { s->GetAIInterface()->AttackReaction(uTarget, 1); s->GetAIInterface()->setNextTarget(uTarget); } } }
void Spell::FillTargetMap(uint32 i) { //Spell::prepare() has already a m_caster->IsInWorld() check so if now the caster is no more in world something bad happened. ARCEMU_ASSERT(m_caster->IsInWorld()); uint32 TargetType = 0; TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetA[i], i); //never get info from B if it is 0 :P if(m_spellInfo->EffectImplicitTargetB[i] != 0) TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetB[i], i); if(TargetType & SPELL_TARGET_NOT_IMPLEMENTED) return; if(TargetType & SPELL_TARGET_NO_OBJECT) //summon spells that appear infront of caster { HandleTargetNoObject(); return; } //always add this guy :P if(!(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF | SPELL_TARGET_AREA_CURTARGET | SPELL_TARGET_AREA_CONE | SPELL_TARGET_OBJECT_SELF | SPELL_TARGET_OBJECT_PETOWNER))) { Object* target = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); AddTarget(i, TargetType, target); } if(TargetType & SPELL_TARGET_OBJECT_SELF) AddTarget(i, TargetType, m_caster); if(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF)) //targetted aoe AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //TODO: arcemu, doesn't support summon slots? /*if (TargetType & SPELL_TARGET_OBJECT_CURTOTEMS && u_caster != NULL) for (uint32 i=1; i<5; ++i) //totem slots are 1, 2, 3, 4 AddTarget(i, TargetType, u_caster->m_summonslot[i]);*/ if(TargetType & SPELL_TARGET_OBJECT_CURPET && p_caster != NULL) AddTarget(i, TargetType, p_caster->GetSummon()); if(TargetType & SPELL_TARGET_OBJECT_PETOWNER) { uint64 guid = m_targets.m_unitTarget; if(GET_TYPE_FROM_GUID(guid) == HIGHGUID_TYPE_PET) { Pet* p = m_caster->GetMapMgr()->GetPet(GET_LOWGUID_PART(guid)); if(p != NULL) AddTarget(i, TargetType, p->GetPetOwner()); } } //targets party, not raid if((TargetType & SPELL_TARGET_AREA_PARTY) && !(TargetType & SPELL_TARGET_AREA_RAID)) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddPartyTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_RAID) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddRaidTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets, (TargetType & SPELL_TARGET_AREA_PARTY) ? true : false); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_CHAIN) AddChainTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //target cone if(TargetType & SPELL_TARGET_AREA_CONE) AddConeTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); if(TargetType & SPELL_TARGET_OBJECT_SCRIPTED) AddScriptedOrSpellFocusTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); }
/// Fill the target map with the targets /// the targets are specified with numbers and handled accordingly void Spell::FillTargetMap(uint32 i) { if(!m_caster->IsInWorld()) return; uint32 TargetType = SPELL_TARGET_NONE; // Get our info from A regardless of nullity TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetA[i], i); //never get info from B if it is 0 :P if(m_spellInfo->EffectImplicitTargetB[i] != 0) TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetB[i], i); if(TargetType & SPELL_TARGET_NOT_IMPLEMENTED) return; if(TargetType & SPELL_TARGET_NO_OBJECT) //summon spells that appear infront of caster { HandleTargetNoObject(); return; } //always add this guy :P if(!(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF | SPELL_TARGET_AREA_CURTARGET | SPELL_TARGET_AREA_CONE | SPELL_TARGET_OBJECT_SELF | SPELL_TARGET_OBJECT_PETOWNER))) { Object* target = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget); AddTarget(i, TargetType, target); } if(TargetType & SPELL_TARGET_OBJECT_SELF) AddTarget(i, TargetType, m_caster); if(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF)) //targetted aoe AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); if (TargetType & SPELL_TARGET_OBJECT_CURTOTEMS && u_caster != NULL) { std::vector<Creature*> m_totemList; u_caster->FillSummonList(m_totemList, SUMMON_TYPE_TOTEM); for(std::vector<Creature*>::iterator itr = m_totemList.begin(); itr != m_totemList.end(); itr++) AddTarget(i, TargetType, *itr); } if(TargetType & SPELL_TARGET_OBJECT_CURPET && p_caster != NULL) AddTarget(i, TargetType, p_caster->GetSummon()); if(TargetType & SPELL_TARGET_OBJECT_PETOWNER) { uint64 guid = m_targets.m_unitTarget; if(GUID_HIPART(guid) == HIGHGUID_TYPE_PET) { Pet* p = m_caster->GetMapMgr()->GetPet(GUID_LOPART(guid)); if(p != NULL) AddTarget(i, TargetType, p->GetPetOwner()); } } //targets party, not raid if((TargetType & SPELL_TARGET_AREA_PARTY) && !(TargetType & SPELL_TARGET_AREA_RAID)) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddPartyTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_RAID) { if(p_caster == NULL && !m_caster->IsPet() && (!m_caster->IsCreature() || !m_caster->IsTotem())) AddAOETargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //npcs else AddRaidTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets, (TargetType & SPELL_TARGET_AREA_PARTY) ? true : false); //players/pets/totems } if(TargetType & SPELL_TARGET_AREA_CHAIN) AddChainTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); //target cone if(TargetType & SPELL_TARGET_AREA_CONE) AddConeTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); if(TargetType & SPELL_TARGET_OBJECT_SCRIPTED) AddScriptedOrSpellFocusTargets(i, TargetType, GetRadius(i), m_spellInfo->MaxTargets); }