mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
*Merge.
--HG-- branch : trunk
This commit is contained in:
@@ -1442,6 +1442,13 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
|
||||
uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i];
|
||||
uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets;
|
||||
|
||||
Unit::AuraList const& Auras = m_caster->GetAurasByType(SPELL_AURA_MOD_ABILITY_AFFECTED_TARGETS);
|
||||
for(Unit::AuraList::const_iterator j = Auras.begin();j != Auras.end(); ++j)
|
||||
{
|
||||
if((*j)->isAffectedOnSpell(m_spellInfo))
|
||||
unMaxTargets+=(*j)->GetModifier()->m_amount;
|
||||
}
|
||||
|
||||
if(m_originalCaster)
|
||||
{
|
||||
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
|
||||
@@ -3294,6 +3301,35 @@ void Spell::TakePower()
|
||||
m_caster->SetLastManaUse(getMSTime());
|
||||
}
|
||||
|
||||
void Spell::TakeAmmo()
|
||||
{
|
||||
if(m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Item *pItem = ((Player*)m_caster)->GetWeaponForAttack( RANGED_ATTACK );
|
||||
|
||||
// wands don't have ammo
|
||||
if(!pItem || pItem->IsBroken() || pItem->GetProto()->SubClass==ITEM_SUBCLASS_WEAPON_WAND)
|
||||
return;
|
||||
|
||||
if( pItem->GetProto()->InventoryType == INVTYPE_THROWN )
|
||||
{
|
||||
if(pItem->GetMaxStackCount()==1)
|
||||
{
|
||||
// decrease durability for non-stackable throw weapon
|
||||
((Player*)m_caster)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED);
|
||||
}
|
||||
else
|
||||
{
|
||||
// decrease items amount for stackable throw weapon
|
||||
uint32 count = 1;
|
||||
((Player*)m_caster)->DestroyItemCount( pItem, count, true);
|
||||
}
|
||||
}
|
||||
else if(uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID))
|
||||
((Player*)m_caster)->DestroyItemCount(ammo, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
uint8 Spell::CheckRuneCost(uint32 runeCostID)
|
||||
{
|
||||
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
@@ -5618,6 +5654,14 @@ void Spell::CalculateDamageDoneForAllTargets()
|
||||
}
|
||||
}
|
||||
|
||||
bool usesAmmo=true;
|
||||
Unit::AuraList const& Auras = m_caster->GetAurasByType(SPELL_AURA_ABILITY_CONSUME_NO_AMMO);
|
||||
for(Unit::AuraList::const_iterator j = Auras.begin();j != Auras.end(); ++j)
|
||||
{
|
||||
if((*j)->isAffectedOnSpell(m_spellInfo))
|
||||
usesAmmo=false;
|
||||
}
|
||||
|
||||
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
{
|
||||
TargetInfo &target = *ihit;
|
||||
@@ -5630,6 +5674,28 @@ void Spell::CalculateDamageDoneForAllTargets()
|
||||
if (!unit)
|
||||
continue;
|
||||
|
||||
if (usesAmmo)
|
||||
{
|
||||
bool ammoTaken=false;
|
||||
for (uint8 i=0;i<3;i++)
|
||||
{
|
||||
if (!(mask & 1<<i))
|
||||
continue;
|
||||
switch (m_spellInfo->Effect[i])
|
||||
{
|
||||
case SPELL_EFFECT_SCHOOL_DAMAGE:
|
||||
case SPELL_EFFECT_WEAPON_DAMAGE:
|
||||
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
|
||||
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
|
||||
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
|
||||
ammoTaken=true;
|
||||
TakeAmmo();
|
||||
}
|
||||
if (ammoTaken)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.missCondition==SPELL_MISS_NONE) // In case spell hit target, do all effect on that target
|
||||
target.damage += CalculateDamageDone(unit, mask, multiplier);
|
||||
else if (target.missCondition == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit)
|
||||
|
||||
Reference in New Issue
Block a user