*Fix bug that missed/immuned/etc. shoots take no ammo.
*Handle SPELL_AURA_ABILITY_CONSUME_NO_AMMO --HG-- branch : trunk
This commit is contained in:
@@ -3285,6 +3285,35 @@ void Spell::TakePower()
|
|||||||
m_caster->SetLastManaUse(getMSTime());
|
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)
|
uint8 Spell::CheckRuneCost(uint32 runeCostID)
|
||||||
{
|
{
|
||||||
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||||
@@ -5609,6 +5638,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)
|
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||||
{
|
{
|
||||||
TargetInfo &target = *ihit;
|
TargetInfo &target = *ihit;
|
||||||
@@ -5621,6 +5658,28 @@ void Spell::CalculateDamageDoneForAllTargets()
|
|||||||
if (!unit)
|
if (!unit)
|
||||||
continue;
|
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
|
if (target.missCondition==SPELL_MISS_NONE) // In case spell hit target, do all effect on that target
|
||||||
target.damage += CalculateDamageDone(unit, mask, multiplier);
|
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)
|
else if (target.missCondition == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit)
|
||||||
|
|||||||
@@ -360,6 +360,7 @@ class Spell
|
|||||||
void cast(bool skipCheck = false);
|
void cast(bool skipCheck = false);
|
||||||
void finish(bool ok = true);
|
void finish(bool ok = true);
|
||||||
void TakePower();
|
void TakePower();
|
||||||
|
void TakeAmmo();
|
||||||
uint8 CheckRuneCost(uint32 runeCostID);
|
uint8 CheckRuneCost(uint32 runeCostID);
|
||||||
void TakeRunePower();
|
void TakeRunePower();
|
||||||
void TakeReagents();
|
void TakeReagents();
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ enum AuraType
|
|||||||
SPELL_AURA_MOD_DAMAGE_FROM_CASTER = 271,
|
SPELL_AURA_MOD_DAMAGE_FROM_CASTER = 271,
|
||||||
SPELL_AURA_272 = 272,
|
SPELL_AURA_272 = 272,
|
||||||
SPELL_AURA_273 = 273,
|
SPELL_AURA_273 = 273,
|
||||||
SPELL_AURA_274 = 274,
|
SPELL_AURA_ABILITY_CONSUME_NO_AMMO = 274,
|
||||||
SPELL_AURA_MOD_IGNORE_SHAPESHIFT = 275,
|
SPELL_AURA_MOD_IGNORE_SHAPESHIFT = 275,
|
||||||
SPELL_AURA_276 = 276, // Only "Test Mod Damage % Mechanic" spell, possible mod damage done
|
SPELL_AURA_276 = 276, // Only "Test Mod Damage % Mechanic" spell, possible mod damage done
|
||||||
SPELL_AURA_MOD_MAX_AFFECTED_TARGETS = 277,
|
SPELL_AURA_MOD_MAX_AFFECTED_TARGETS = 277,
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
|
|||||||
&Aura::HandleNoImmediateEffect, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
|
&Aura::HandleNoImmediateEffect, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
|
||||||
&Aura::HandleNULL, //272 reduce spell cast time?
|
&Aura::HandleNULL, //272 reduce spell cast time?
|
||||||
&Aura::HandleNULL, //273
|
&Aura::HandleNULL, //273
|
||||||
&Aura::HandleNULL, //274 proc free shot?
|
&Aura::HandleNoImmediateEffect, //274 SPELL_AURA_ABILITY_CONSUME_NO_AMMO implemented in spell::CalculateDamageDoneForAllTargets
|
||||||
&Aura::HandleNoImmediateEffect, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
|
&Aura::HandleNoImmediateEffect, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
|
||||||
&Aura::HandleNULL, //276 mod damage % mechanic?
|
&Aura::HandleNULL, //276 mod damage % mechanic?
|
||||||
&Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
|
&Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
|
||||||
@@ -3226,6 +3226,10 @@ void Aura::HandleAuraModDisarm(bool apply, bool Real)
|
|||||||
if (!Real)
|
if (!Real)
|
||||||
return;
|
return;
|
||||||
AuraType type = GetModifier()->m_auraname;
|
AuraType type = GetModifier()->m_auraname;
|
||||||
|
|
||||||
|
//Prevent handling aura mod twice
|
||||||
|
if(apply && m_target->GetAurasByType(type).size()>1)
|
||||||
|
return;
|
||||||
if(!apply && m_target->HasAuraType(type))
|
if(!apply && m_target->HasAuraType(type))
|
||||||
return;
|
return;
|
||||||
uint32 field, flag, slot;
|
uint32 field, flag, slot;
|
||||||
|
|||||||
@@ -4575,33 +4575,6 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
|
|||||||
// Add melee damage bonuses (also check for negative)
|
// Add melee damage bonuses (also check for negative)
|
||||||
m_caster->MeleeDamageBonus(unitTarget, &eff_damage, m_attackType, m_spellInfo);
|
m_caster->MeleeDamageBonus(unitTarget, &eff_damage, m_attackType, m_spellInfo);
|
||||||
m_damage+= eff_damage;
|
m_damage+= eff_damage;
|
||||||
|
|
||||||
// take ammo
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::EffectThreat(uint32 /*i*/)
|
void Spell::EffectThreat(uint32 /*i*/)
|
||||||
|
|||||||
Reference in New Issue
Block a user