*Do not apply auras with 4th diminishing level

*Some fixes related to last commit.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-05-01 17:21:16 +02:00
parent 0f5a9cb46f
commit a098dc72fc
6 changed files with 79 additions and 84 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ enum ITEM_FLAGS
ITEM_FLAGS_THROWABLE = 0x00400000, // not used in game for check trow possibility, only for item in game tooltip
ITEM_FLAGS_SPECIALUSE = 0x00800000, // last used flag in 2.3.0
ITEM_FLAGS_BOA = 0x08000000, // bind on account
ITEM_FLAGS_NO_REAGENT_CAST = 0x10000000, // used by enchanting scrolls made with vellum
ITEM_FLAGS_TRIGGERED_CAST = 0x10000000, // used by enchanting scrolls made with vellum
ITEM_FLAGS_MILLABLE = 0x20000000
};
+1 -1
View File
@@ -6957,7 +6957,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
return;
}
Spell *spell = new Spell(this, spellInfo, false);
Spell *spell = new Spell(this, spellInfo,false);
spell->m_CastItem = item;
spell->m_cast_count = cast_count; //set count of casts
spell->m_currentBasePoints[0] = learning_spell_id;
+69 -71
View File
@@ -590,11 +590,8 @@ void Spell::FillTargetMap()
if(Guardian* pet = m_caster->GetGuardianPet())
tmpUnitMap.push_back(pet);
break;
case SPELL_EFFECT_ENCHANT_ITEM:
// add caster as unit target-needed by vellums to define who gets item
AddUnitTarget(m_caster, i);
break;
/*case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY:
/*case SPELL_EFFECT_ENCHANT_ITEM:
case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY:
case SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC:
case SPELL_EFFECT_DISENCHANT:
case SPELL_EFFECT_PROSPECTING:
@@ -3508,13 +3505,13 @@ void Spell::TakeReagents()
if(m_IsTriggeredSpell) // reagents used in triggered spell removed by original spell or don't must be removed.
return;
if (m_CastItem)
if (m_CastItem->GetProto()->Flags & ITEM_FLAGS_NO_REAGENT_CAST)
return;
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
// do not take reagents for these item casts
if (m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAGS_TRIGGERED_CAST)
return;
Player* p_caster = (Player*)m_caster;
if (p_caster->CanNoReagentCast(m_spellInfo))
return;
@@ -3636,8 +3633,8 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_DONT_REPORT;
// only check at first call, Stealth auras are already removed at second call
// for now, ignore triggered by aura spells
if( strict && !m_triggeredByAuraSpell)
// for now, ignore triggered spells
if( strict && !m_IsTriggeredSpell)
{
bool checkForm = true;
// Ignore form req aura
@@ -4923,73 +4920,77 @@ SpellCastResult Spell::CheckItems()
focusObject = ok; // game object found in range
}
// check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case.
if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo))
// do not take reagents for these item casts
if (!(m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAGS_TRIGGERED_CAST))
{
for(uint32 i=0;i<8;i++)
// check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case.
if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo))
{
if(m_spellInfo->Reagent[i] <= 0)
continue;
uint32 itemid = m_spellInfo->Reagent[i];
uint32 itemcount = m_spellInfo->ReagentCount[i];
// if CastItem is also spell reagent
if( m_CastItem && m_CastItem->GetEntry() == itemid )
for(uint32 i=0;i<8;i++)
{
ItemPrototype const *proto = m_CastItem->GetProto();
if(!proto)
return SPELL_FAILED_ITEM_NOT_READY;
for(int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s)
if(m_spellInfo->Reagent[i] <= 0)
continue;
uint32 itemid = m_spellInfo->Reagent[i];
uint32 itemcount = m_spellInfo->ReagentCount[i];
// if CastItem is also spell reagent
if( m_CastItem && m_CastItem->GetEntry() == itemid )
{
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);
if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2)
ItemPrototype const *proto = m_CastItem->GetProto();
if(!proto)
return SPELL_FAILED_ITEM_NOT_READY;
for(int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s)
{
++itemcount;
break;
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);
if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2)
{
++itemcount;
break;
}
}
}
if( !p_caster->HasItemCount(itemid,itemcount) )
return SPELL_FAILED_ITEM_NOT_READY; //0x54
}
if( !p_caster->HasItemCount(itemid,itemcount) )
return SPELL_FAILED_ITEM_NOT_READY; //0x54
}
}
// check totem-item requirements (items presence in inventory)
uint32 totems = 2;
for(int i=0;i<2;++i)
{
if(m_spellInfo->Totem[i] != 0)
// check totem-item requirements (items presence in inventory)
uint32 totems = 2;
for(int i=0;i<2;++i)
{
if( p_caster->HasItemCount(m_spellInfo->Totem[i],1) )
if(m_spellInfo->Totem[i] != 0)
{
totems -= 1;
continue;
if( p_caster->HasItemCount(m_spellInfo->Totem[i],1) )
{
totems -= 1;
continue;
}
}else
totems -= 1;
}
if(totems != 0)
return SPELL_FAILED_TOTEMS; //0x7C
// Check items for TotemCategory (items presence in inventory)
uint32 TotemCategory = 2;
for(int i=0;i<2;++i)
{
if(m_spellInfo->TotemCategory[i] != 0)
{
if( p_caster->HasItemTotemCategory(m_spellInfo->TotemCategory[i]) )
{
TotemCategory -= 1;
continue;
}
}
}else
totems -= 1;
}
if(totems != 0)
return SPELL_FAILED_TOTEMS; //0x7C
// Check items for TotemCategory (items presence in inventory)
uint32 TotemCategory = 2;
for(int i=0;i<2;++i)
{
if(m_spellInfo->TotemCategory[i] != 0)
{
if( p_caster->HasItemTotemCategory(m_spellInfo->TotemCategory[i]) )
{
else
TotemCategory -= 1;
continue;
}
}
else
TotemCategory -= 1;
if(TotemCategory != 0)
return SPELL_FAILED_TOTEM_CATEGORY; //0x7B
}
if(TotemCategory != 0)
return SPELL_FAILED_TOTEM_CATEGORY; //0x7B
// special checks for spell effects
for(int i = 0; i < 3; i++)
@@ -5018,7 +5019,7 @@ SpellCastResult Spell::CheckItems()
if (m_targets.getItemTarget()->GetOwner()!=m_caster)
return SPELL_FAILED_NOT_TRADEABLE;
// do not allow to enchant vellum from scroll made by vellum-prevent exploit
if (m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAGS_NO_REAGENT_CAST)
if (m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAGS_TRIGGERED_CAST)
return SPELL_FAILED_TOTEM_CATEGORY;
ItemPosCountVec dest;
uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 );
@@ -5665,15 +5666,12 @@ void Spell::CalculateDamageDoneForAllTargets()
}
}
bool usesAmmo = !m_IsTriggeredSpell || m_autoRepeat;
if (usesAmmo)
bool usesAmmo=true;
Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_ABILITY_CONSUME_NO_AMMO);
for(Unit::AuraEffectList::const_iterator j = Auras.begin();j != Auras.end(); ++j)
{
Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_ABILITY_CONSUME_NO_AMMO);
for(Unit::AuraEffectList::const_iterator j = Auras.begin();j != Auras.end(); ++j)
{
if((*j)->isAffectedOnSpell(m_spellInfo))
usesAmmo=false;
}
if((*j)->isAffectedOnSpell(m_spellInfo))
usesAmmo=false;
}
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
+1
View File
@@ -66,6 +66,7 @@ class TRINITY_DLL_SPEC Aura
int32 GetAuraDuration() const { return m_duration; }
void SetAuraDuration(int32 duration);
void RefreshAura(){ SetAuraDuration (m_maxduration); }
inline bool IsExpired() { if(!GetAuraDuration() && !(IsPermanent() || (IsPassive()))) return true; return false;};
void SendAuraUpdate();
uint8 GetAuraSlot() const { return m_auraSlot; }
+5 -9
View File
@@ -3688,15 +3688,10 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx)
// Handle vellums
if (itemTarget->IsWeaponVellum() || itemTarget->IsArmorVellum())
{
// item can be in trade slot and have owner diff. from caster
Player* item_owner = itemTarget->GetOwner();
if(!item_owner)
return;
// destroy one vellum from stack
uint32 count=1;
item_owner->DestroyItemCount(itemTarget,count,true);
unitTarget=item_owner;
p_caster->DestroyItemCount(itemTarget,count,true);
unitTarget=p_caster;
// and add a scroll
DoCreateItem(effect_idx,m_spellInfo->EffectItemType[effect_idx]);
itemTarget=NULL;
@@ -3704,8 +3699,9 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx)
}
else
{
// not grow at item use at item case
p_caster->UpdateCraftSkill(m_spellInfo->Id);
// do not increase skill if vellum used
if (!(m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAGS_TRIGGERED_CAST))
p_caster->UpdateCraftSkill(m_spellInfo->Id);
uint32 enchant_id = m_spellInfo->EffectMiscValue[effect_idx];
if (!enchant_id)
+2 -2
View File
@@ -3259,7 +3259,7 @@ void Unit::_UpdateSpells( uint32 time )
for(AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
{
if(!i->second->GetAuraDuration() && !(i->second->IsPermanent() || (i->second->IsPassive())))
if(i->second->IsExpired())
RemoveAura(i, AURA_REMOVE_BY_EXPIRE);
else
++i;
@@ -3673,7 +3673,7 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_
bool Unit::AddAura(Aura *Aur)
{
// aura doesn't apply effects-return
if (!Aur->GetEffectMask())
if (!Aur->GetEffectMask() || Aur->IsExpired())
{
delete Aur;
return false;