SpellDesc* ArcScriptCreatureAI::AddSpell(uint32 pSpellId, TargetType pTargetType, float pChance, float pCastTime, int32 pCooldown, float pMinRange, float pMaxRange, bool pStrictRange, char* pText, TextType pTextType, uint32 pSoundId) { //Cannot add twice same spell id SpellDesc* NewSpell = FindSpellById(pSpellId); if( NewSpell ) return NewSpell; //Find spell info from spell id SpellEntry* Info = dbcSpell.LookupEntry(pSpellId); #ifdef USE_DBC_SPELL_INFO float CastTime = ( Info->CastingTimeIndex ) ? GetCastTime(dbcSpellCastTime.LookupEntry(Info->CastingTimeIndex)) : pCastTime; int32 Cooldown = Info->RecoveryTime; float MinRange = ( Info->rangeIndex ) ? GetMinRange(dbcSpellRange.LookupEntry(Info->rangeIndex)) : pMinRange; float MaxRange = ( Info->rangeIndex ) ? GetMaxRange(dbcSpellRange.LookupEntry(Info->rangeIndex)) : pMaxRange; sLog.outColor(TYELLOW, "ArcScriptCreatureAI::AddSpell(%u) : casttime=%.1f cooldown=%d minrange=%.1f maxrange=%.1f\n", pSpellId, CastTime, Cooldown, MinRange, MaxRange); #else float CastTime = pCastTime; int32 Cooldown = pCooldown; float MinRange = pMinRange; float MaxRange = pMaxRange; #endif //Create new spell NewSpell = new SpellDesc(Info, NULL, pTargetType, pChance, CastTime, Cooldown, MinRange, MaxRange, pStrictRange, pText, pTextType, pSoundId); mSpells.push_back(NewSpell); return NewSpell; }
void AIUpdate() { SpellDesc* pShield = FindSpellById(OMOR_DEMONIC_SHIELD); if (GetHealthPercent() <= 20 && pShield != NULL && !pShield->mEnabled) { pShield->mEnabled = true; } Unit* pTarget = _unit->GetAIInterface()->getNextTarget(); if (pTarget != NULL) { if (GetRangeToUnit(pTarget) > 10.0f) { pTarget = GetBestPlayerTarget(TargetFilter_Closest); if (pTarget != NULL) { if (GetRangeToUnit(pTarget) > 10.0f) { pTarget = NULL; } else { ClearHateList(); _unit->GetAIInterface()->AttackReaction(pTarget, 500); _unit->GetAIInterface()->setNextTarget(pTarget); } } else return; } if (pTarget == NULL) { SpellDesc* pWhip = FindSpellById(OMOR_SHADOW_WHIP); // used for now if (pWhip != NULL) { pWhip->mLastCastTime = 0; CastSpellNowNoScheduling(pWhip); return; } } } ParentClass::AIUpdate(); SetCanMove(false); }