bool AIInterface::CanCastFuckingSpell(Unit* Target, AI_Spell* toCast, uint32 currentTime) { if(toCast->cooldown) { if((toCast->lastcast+toCast->cooldown) > currentTime) return false; } if(toCast->minHPPercentReq) if(Target->GetHealthPct() > toCast->minHPPercentReq) return false; if(toCast->ProcLimit) { if(toCast->ProcResetDelay) { if(toCast->ProcResetTimer <= currentTime) { toCast->procCounter = 0; toCast->ProcResetTimer = currentTime+toCast->ProcResetDelay; } } if(toCast->procCounter >= toCast->ProcLimit) return false; } float dist = fabs(m_Unit->CalcDistance(Target)); if(dist < toCast->mindist2cast) return false; if(toCast->maxdist2cast) if(dist > toCast->maxdist2cast) return false; if(toCast->info->powerType == POWER_TYPE_MANA) { int32 currentPower = m_Unit->GetPower(POWER_TYPE_MANA); int32 cost; if( toCast->info->ManaCostPercentage)//Percentage spells cost % of !!!BASE!!! mana cost = (m_Unit->GetUInt32Value(UNIT_FIELD_BASE_MANA)*toCast->info->ManaCostPercentage)/100; else cost = toCast->info->manaCost; cost += m_Unit->PowerCostMod[toCast->info->School];//this is not percent! cost += float2int32(cost*m_Unit->GetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+toCast->info->School)); //apply modifiers if( toCast->info->SpellGroupType ) { SM_FIValue(m_Unit->SM[SMT_COST][0], &cost, toCast->info->SpellGroupType); SM_PIValue(m_Unit->SM[SMT_COST][1], &cost, toCast->info->SpellGroupType); } if(cost > currentPower) return false; } return true; }
bool DoEffect(Unit* victim, SpellEntry* CastingSpell, uint32 flag, uint32 dmg, uint32 abs, int* dmg_overwrite, uint32 weapon_damage_type) { Aura* aura = mTarget->FindAuraByNameHash(SPELL_HASH_SLICE_AND_DICE); if(aura) { // Duration of 5 combo maximum int32 dur = 21 * MSTIME_SECOND; SM_FIValue(mTarget->SM_FDur, &dur, aura->GetSpellProto()->SpellGroupType); SM_PIValue(mTarget->SM_PDur, &dur, aura->GetSpellProto()->SpellGroupType); // Set new aura's duration, reset event timer and set client visual aura aura->SetDuration(dur); sEventMgr.ModifyEventTimeLeft(aura, EVENT_AURA_REMOVE, aura->GetDuration()); mTarget->ModVisualAuraStackCount(aura, 0); } return true; }