void AuraInterface::UpdateAuraStateAuras(uint32 oldflag) { if( oldflag == AURASTATE_FLAG_STUNNED && m_Unit->IsPlayer() && m_Unit->HasDummyAura(SPELL_HASH_PRIMAL_TENACITY) && TO_PLAYER(m_Unit)->GetShapeShift() == FORM_CAT ) { for(uint32 i = 0; i < TOTAL_AURAS; i++) { if(m_auras.find(i) != m_auras.end()) { if( m_auras.at(i)->GetSpellProto()->NameHash == SPELL_HASH_PRIMAL_TENACITY ) { Aura* aura = new Aura(m_auras.at(i)->GetSpellProto(), -1, TO_OBJECT(this), TO_UNIT(this)); RemoveAuraBySlot(i); aura->AddMod(232, -31, 5, 0); aura->AddMod(SPELL_AURA_DUMMY, 0, 0, 2); aura->AddMod(SPELL_AURA_ADD_PCT_MODIFIER, -51, 14, 2); AddAura(aura); continue; } if( m_auras.at(i)->m_applied) // try to apply m_auras.at(i)->ApplyModifiers(true); if( m_auras.at(i)->m_applied) // try to remove, if we lack the aurastate m_auras.at(i)->RemoveIfNecessary(); } } } else { for(uint32 i = 0; i < TOTAL_AURAS; i++) { if(m_auras.find(i) != m_auras.end()) { if( !m_auras.at(i)->m_applied) // try to apply m_auras.at(i)->ApplyModifiers(true); if( m_auras.at(i)->m_applied) // try to remove, if we lack the aurastate m_auras.at(i)->RemoveIfNecessary(); } } } }
void MountedChampionAI::executeEvent(uint32 eventID) { uint32 timer = 0; switch (eventID) { case EVENT_SPELL_CHARGE: { if (Unit* pUnit = SelectTarget(SELECT_TARGET_FARTHEST)) { DoResetThreat(); me->AddThreat(pUnit, 5.0f); DoCast(pUnit, SPELL_CHARGE, true); } timer = 5000; }break; case EVENT_SPELL_SHIELD_BREAKER: { if (Unit* pUnit = SelectTarget(SELECT_TARGET_FARTHEST)) DoCast(pUnit, SPELL_SHIELD_BREAKER, true); timer = 7 * IN_MILLISECONDS; }break; case EVENT_SPELL_SHIELD: { Aura* pAura = me->GetAura(SPELL_SHIELD); if (!pAura || pAura->GetStackAmount() < 3) { DoCast(SPELL_SHIELD); timer = urand(4 * IN_MILLISECONDS, 5 * IN_MILLISECONDS); } else timer = urand(1 * IN_MILLISECONDS, 2 * IN_MILLISECONDS); }break; } if (eventID && timer) eventMap.ScheduleEvent(eventID, timer); }
void AIUpdate() { // Let's see if we are netted Aura* a = _unit->FindAura(38177); if(a != NULL) { Unit* Caster = a->GetUnitCaster(); if(Caster->IsPlayer()) { QuestLogEntry* qle = TO_PLAYER(Caster)->GetQuestLogForEntry(10747); if(qle != NULL) { // casting the spell that will create the item for the player _unit->CastSpell(Caster, 38178, true); _unit->Despawn(1000, 360000); } } } }
bool ChatHandler::HandleAuraUpdateRemove(const char* args, WorldSession* m_session) { if (!args) return false; char* pArgs = strtok((char*)args, " "); if (!pArgs) return false; uint8 VisualSlot = (uint8)atoi(pArgs); Player* Pl = m_session->GetPlayer(); Aura* AuraPtr = Pl->FindAura(Pl->m_auravisuals[VisualSlot]); if (!AuraPtr) { SystemMessage(m_session, "No auraid found in slot %u", VisualSlot); return true; } SystemMessage(m_session, "SMSG_AURA_UPDATE (remove): VisualSlot %u - SpellID 0", VisualSlot); AuraPtr->Remove(); return true; }
SPELL_EFFECT_OVERRIDE_RETURNS AH_642( Aura *aur, bool apply, uint8 i ) { if( apply == true && aur->GetSpellProto()->eff[i].EffectApplyAuraName == SPELL_AURA_SCHOOL_IMMUNITY ) { //remove dots from target Unit *t = aur->GetTarget(); for(uint32 x=MAX_POSITIVE_AURAS; x<MAX_NEGATIVE_AURAS1(t); x++) { Aura *pAura = t->m_auras[i]; if( pAura != aur && pAura != NULL && !pAura->IsPassive() && !pAura->IsPositive() && !(pAura->GetSpellProto()->Attributes & ATTRIBUTES_IGNORE_INVULNERABILITY) ) pAura->Remove(); } t->RemoveAurasByInterruptFlag( AURA_INTERRUPT_ON_INVINCIBLE ); for(uint32 i = 0; i < SCHOOL_COUNT; i++) if( aur->mod->m_miscValue & (1<<i) ) t->RemoveAurasOfSchool(i, false, true); //hmm, script this if you need. Cyclone does not need to remove DOTS, just make you immune to dmg } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
void UpdateAI(uint32 const diff) { events.Update(diff); switch (events.ExecuteEvent()) { case EVENT_DUMMY_RECAST_DEFEND: switch (me->GetEntry()) { case NPC_CHARGE_TARGET: { if (!me->HasAura(SPELL_CHARGE_DEFEND)) DoCast(SPELL_CHARGE_DEFEND); break; } case NPC_RANGED_TARGET: { Aura* defend = me->GetAura(SPELL_RANGED_DEFEND); if (!defend || defend->GetStackAmount() < 3 || defend->GetDuration() <= 8000) DoCast(SPELL_RANGED_DEFEND); break; } } isVulnerable = false; events.ScheduleEvent(EVENT_DUMMY_RECAST_DEFEND, 5000); break; case EVENT_DUMMY_RESET: if (UpdateVictim()) { EnterEvadeMode(); events.ScheduleEvent(EVENT_DUMMY_RESET, 10000); } break; } if (!UpdateVictim()) return; if (!me->HasUnitState(UNIT_STATE_STUNNED)) me->SetControlled(true, UNIT_STATE_STUNNED); }
/** * @brief Applies the Deserter Debuff to a player * * This function applies a Deserter Debuff of the given type (Instance or BG) to the * selected player, with the provided duration in seconds. * * @param handler The ChatHandler, passed by the system. * @param args The provided duration in seconds. * @param isInstance provided by the relaying functions, so we don't have * to write that much code :) * * @return true if everything was correct, false if an error occured. * * Example Usage: * @code * .deserter instance add 3600 (one hour) * -or- * .deserter bg add 3600 (one hour) * @endcode */ static bool HandleDeserterAdd(ChatHandler* handler, char const* args, bool isInstance) { if (!*args) return false; Player* player = handler->getSelectedPlayer(); if (!player) { handler->SendSysMessage(LANG_NO_CHAR_SELECTED); handler->SetSentErrorMessage(true); return false; } char* timeStr = strtok((char*)args, " "); if (!timeStr) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } uint32 time = atoi(timeStr); if (!time) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } Aura* aura = player->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, player); if (!aura) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } aura->SetDuration(time * IN_MILLISECONDS); return true; }
void HandleScriptEffect(SpellEffIndex effIndex) { Unit* caster = GetCaster(); Unit* unitTarget = GetHitUnit(); if (!unitTarget) return; uint32 spellId = 0; int32 basePoint = 0; Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras(); for (Unit::AuraApplicationMap::iterator i = Auras.begin(); i != Auras.end(); ++i) { Aura* aura = i->second->GetBase(); if (aura->GetCasterGUID() != caster->GetGUID()) continue; // Search only Serpent Sting, Viper Sting, Scorpid Sting auras flag96 familyFlag = aura->GetSpellProto()->SpellFamilyFlags; if (!(familyFlag[1] & 0x00000080 || familyFlag[0] & 0x0000C000)) continue; if (AuraEffect const * aurEff = aura->GetEffect(0)) { // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting. if (familyFlag[0] & 0x4000) { int32 TickCount = aurEff->GetTotalTicks(); spellId = HUNTER_SPELL_CHIMERA_SHOT_SERPENT; basePoint = aurEff->GetAmount() * TickCount * 40 / 100; } // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting. else if (familyFlag[1] & 0x00000080) { int32 TickCount = aura->GetEffect(0)->GetTotalTicks(); spellId = HUNTER_SPELL_CHIMERA_SHOT_VIPER; // Amount of one aura tick basePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 100 ; int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50 ; if (basePoint > casterBasePoint) basePoint = casterBasePoint; basePoint = basePoint * TickCount * 60 / 100; } // Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute. else if (familyFlag[0] & 0x00008000) spellId = HUNTER_SPELL_CHIMERA_SHOT_SCORPID; // ?? nothing say in spell desc (possibly need addition check) //if (familyFlag & 0x0000010000000000LL || // dot // familyFlag & 0x0000100000000000LL) // stun //{ // spellId = 53366; // 53366 Chimera Shot - Wyvern //} // Refresh aura duration aura->RefreshDuration(); } break; } if (spellId) caster->CastCustomSpell(unitTarget, spellId, &basePoint, 0, 0, false); }
bool PlayerbotClassAI::castDispel (uint32 dispelSpell, Unit *dTarget, bool checkFirst, bool castExistingAura, bool skipFriendlyCheck, bool skipEquipStanceCheck) { if (dispelSpell == 0 || !dTarget ) return false; //if (!canCast(dispelSpell, dTarget, true)) return false; //Needless cpu cycles wasted, usually a playerbot can cast a dispell const SpellEntry *dSpell = GetSpellStore()->LookupEntry(dispelSpell); if (!dSpell) return false; for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++i) { if (dSpell->Effect[i] != (uint32)SPELL_EFFECT_DISPEL) continue; uint32 dispel_type = dSpell->EffectMiscValue[i]; uint32 dispelMask = GetDispellMask(DispelType(dispel_type)); Unit::AuraMap const& auras = dTarget->GetOwnedAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++) { Aura * aura = itr->second; AuraApplication * aurApp = aura->GetApplicationOfTarget(dTarget->GetGUID()); if (!aurApp) continue; if ((1<<aura->GetSpellProto()->Dispel) & dispelMask) { if(aura->GetSpellProto()->Dispel == DISPEL_MAGIC) { bool positive = aurApp->IsPositive() ? (!(aura->GetSpellProto()->AttributesEx & SPELL_ATTR0_UNK7)) : false; // do not remove positive auras if friendly target // negative auras if non-friendly target if(positive == dTarget->IsFriendlyTo(GetPlayerBot())) continue; } // If there is a successfull match return, else continue searching. if (CastSpell(dSpell, dTarget, checkFirst, castExistingAura, skipFriendlyCheck, skipEquipStanceCheck)) { return true; } } } } return false; }
void SpellHitTarget(Unit* who, SpellInfo const* spell) { if (spell->Id == SPELL_UNLEASHED_LIGHT_HELPER) { if (who->HasAura(SPELL_LIGHT_ESSENCE_HELPER)) { // need to do the things in this order, else players might have 100 charges of Powering Up without anything happening Aura* pAura = who->GetAura(SPELL_POWERING_UP_HELPER); if (pAura) { pAura->ModStackAmount(int(spell->Effects[EFFECT_0].CalcValue() * 0.001) - 1); who->CastSpell(who, SPELL_POWERING_UP_HELPER, true); } else { who->CastSpell(who, SPELL_POWERING_UP_HELPER, true); if (Aura* pTemp = who->GetAura(SPELL_POWERING_UP_HELPER)) pTemp->ModStackAmount(int(spell->Effects[EFFECT_0].CalcValue() * 0.001) - 1); } } } }
/// Spell Target Handling for type 38: Dummy Target (Server-side script effect) void Spell::SpellTargetDummyTarget(uint32 i, uint32 j) { //TargetsList *tmpMap=&m_targetUnits[i]; if( m_spellInfo->Id == 51699 ) { if( p_caster ) { Aura* aur = p_caster->FindAura( 52916 ); if( aur && aur->GetUnitCaster() ) { _AddTargetForced(aur->GetUnitCaster()->GetGUID(), i); return; } } } else if( m_spellInfo->Id == 12938 ) { //FIXME:this ll be immortal targets FillAllTargetsInArea(i,m_targets.m_destX,m_targets.m_destY,m_targets.m_destZ,GetDBCCastTime(i)); } _AddTargetForced(m_caster->GetGUID(), i); }
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { PreventDefaultAction(); Unit* caster = eventInfo.GetActor(); Unit* target = eventInfo.GetProcTarget(); // try to find spell Flame Shock on the target AuraEffect* flameShock = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, flag128(0x10000000), caster->GetGUID()); if (!flameShock) return; Aura* flameShockAura = flameShock->GetBase(); int32 maxDuration = flameShockAura->GetMaxDuration(); int32 newDuration = flameShockAura->GetDuration() + aurEff->GetAmount() * IN_MILLISECONDS; flameShockAura->SetDuration(newDuration); // is it blizzlike to change max duration for FS? if (newDuration > maxDuration) flameShockAura->SetMaxDuration(newDuration); }
void HandleScript(SpellEffIndex /*effIndex*/) { if (!(GetHitCreature() && GetHitCreature()->IsAlive())) return; Aura *unstable = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE); if (unstable != NULL) { Aura *targetAura = GetHitCreature()->GetAura(SPELL_UNSTABLE_OOZE); if (targetAura != NULL) unstable->ModStackAmount(targetAura->GetStackAmount()); else unstable->ModStackAmount(1); // no idea why, but this does not trigger explosion on retail (only small+large do) } // just for safety GetHitCreature()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); GetHitCreature()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); GetHitCreature()->DespawnOrUnsummon(); }
void HandleScriptEffect(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); if (Unit* unitTarget = GetHitUnit()) if (AuraEffect const * aurEff = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE,SPELLFAMILY_DRUID, 0x00000002, 0, 0, caster->GetGUID())) { Aura* aura = aurEff->GetBase(); uint32 countMin = aura->GetMaxDuration(); uint32 countMax = 18000; if (caster->HasAura(DRUID_INCREASED_MOONFIRE_DURATION)) countMax += 3000; if (caster->HasAura(DRUID_NATURES_SPLENDOR)) countMax += 3000; if (countMin < countMax) { aura->SetDuration(uint32(aura->GetDuration() + 3000)); aura->SetMaxDuration(countMin + 3000); } } }
bool AuraInterface::BuildAuraUpdateAllPacket(WorldPacket* data) { if(!m_auras.size()) return false; bool res = false; Aura* aur = NULL; for (uint32 i=0; i<MAX_AURAS; i++) { if(m_auras.find(i) != m_auras.end()) { res = true; aur = m_auras.at(i); aur->BuildAuraUpdate(); uint8 flags = aur->GetAuraFlags(); *data << uint8(aur->m_auraSlot); int32 stack = aur->stackSize; if(aur->procCharges > stack && stack != 0) stack = aur->procCharges; if(stack < 0) { *data << uint32(0); continue; } *data << uint32(aur->GetSpellId()); *data << uint8(flags); *data << uint8(aur->GetUnitCaster() ? aur->GetUnitCaster()->getLevel() : 0); *data << uint8(stack); if(!(flags & AFLAG_NOT_GUID)) FastGUIDPack(*data, aur->GetCasterGUID()); if(flags & AFLAG_HAS_DURATION) { *data << aur->GetDuration(); *data << aur->GetTimeLeft(); } } } return res; }
////////////////////////////////////////////////////////////// /// This function handles CMSG_SPIRIT_HEALER_ACTIVATE: ////////////////////////////////////////////////////////////// void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) { if(!_player->IsInWorld() ||!_player->isDead()) return; GetPlayer( )->DeathDurabilityLoss(0.25); GetPlayer( )->ResurrectPlayer(); Aura *aur = GetPlayer()->FindAura(15007); if(aur) // If the player already have the aura, just extend it. { GetPlayer()->SetAurDuration(15007,aur->GetDuration()); } else // else add him one, that f****r, he think he will get away!? { SpellEntry *spellInfo = sSpellStore.LookupEntry( 15007 );//resurrectin sickness SpellCastTargets targets; targets.m_unitTarget = GetPlayer()->GetGUID(); Spell*sp=new Spell(_player,spellInfo,true,NULL); sp->prepare(&targets); } GetPlayer( )->SetUInt32Value(UNIT_FIELD_HEALTH, GetPlayer()->GetUInt32Value(UNIT_FIELD_MAXHEALTH)/2); }
Aura *Aura::create(TCODZip &zip){ StatType type = (StatType)zip.getInt(); Aura *aura = NULL; switch(type){ case NONE: break; case TOTALSTR: aura = new StrBoost(0,0); break; case TOTALPOWER: aura = new PowerBoost(0,0); break; case TOTALDEX: aura = new DexBoost(0,0); break; case TOTALINTEL: aura = new IntBoost(0,0); break; case TOTALDODGE: aura = new DodgeBoost(0,0); break; case TOTALDR: aura = new DRBoost(0,0); break; case HEALTH: aura = new HealAura(0,0); break; case MAXHEALTH: aura = new HealthBoost(0,0); break; case LIGHT: aura = new LightBoost(0,0); break; case SHIELD: aura = new ShieldAura(0,0); break; case REFLECTION: aura = new ReflectionAura(0); break; case ABSORPTION: aura = new AbsorptionAura(0,0); break; case DAMAGING_AURA: aura = new DamagingAura(0,0,0,false); break; case DOOM: aura = new DoomAura(0,0); break; } aura->load(zip); return aura; }
bool SkyShatterRegalia(uint32 i, Spell* s) { // Shaman - Skyshatter Regalia - Two Piece Bonus // it checks for earth, air, water, fire totems and triggers Totemic Mastery spell 38437. if(!s->p_caster) return false; if(s->p_caster->summonhandler.HasSummonInSlot(0) && s->p_caster->summonhandler.HasSummonInSlot(1) && s->p_caster->summonhandler.HasSummonInSlot(2) && s->p_caster->summonhandler.HasSummonInSlot(3)) { Aura* aur = sSpellFactoryMgr.NewAura(dbcSpell.LookupEntry(38437), 5000, s->p_caster, s->p_caster, true); for(uint32 j = 0; j < 3; j++) aur->AddMod(aur->GetSpellProto()->eff[j].EffectApplyAuraName, aur->GetSpellProto()->eff[j].EffectBasePoints + 1, aur->GetSpellProto()->eff[j].EffectMiscValue, j); s->p_caster->AddAura(aur); } return true; }
bool DoEffect(Unit* victim, SpellInfo* CastingSpell, uint32 flag, uint32 dmg, uint32 abs, int* dmg_overwrite, uint32 weapon_damage_type) { Aura* aura = mTarget->getAuraWithId(mSpell->Id); if (aura == NULL) return true; Unit* caster = static_cast<Player*>(aura->GetCaster()); if (caster == NULL) { mTarget->RemoveAuraByNameHash(mSpell->custom_NameHash); return true; } int32 value = aura->GetModAmount(0); caster->CastSpell(mTarget, 33110, value, true); int32 count = mTarget->GetAuraStackCount(mSpell->Id); if (count <= 1) return true; Player* plr = static_cast<Player*>(mTarget); Group* grp = plr->GetGroup(); if (grp == NULL) return true; Player* new_plr = grp->GetRandomPlayerInRangeButSkip(plr, 40.0f, plr); mTarget->RemoveAllAuraByNameHash(mSpell->custom_NameHash); if (new_plr != NULL) caster->CastSpell(new_plr, mSpell, value, count - 1, true); return true; }
bool AI_SUPPORT_TOWER::TryNerfCast( Unit *target ) { // TickNow = GetTickCount(); if( target->IsPlayer() && TickNow > SpellInstances[ STSI_ENEMY_NERF1 ].cooldown_finished ) { Aura *a = target->FindAura( SpellBook[ STSI_ENEMY_NERF1 ].spell_id ); if( a != NULL && a->GetDuration() < SpellBook[ STSI_ENEMY_NERF1 ].spell_duration_fixed ) { a->Remove(); a = NULL; } if( a == NULL ) { CastSpellBookSpell( STSI_ENEMY_NERF1, target ); return true; } } if( target->IsPlayer() && TickNow > SpellInstances[ STSI_ENEMY_NERF2 ].cooldown_finished && RollDiceForSpellCast( STSI_ENEMY_NERF2 ) == true ) { Aura *a = target->FindAura( SpellBook[ STSI_ENEMY_NERF2 ].spell_id ); if( a != NULL && a->GetDuration() < SpellBook[ STSI_ENEMY_NERF1 ].spell_duration_fixed ) { a->Remove(); a = NULL; } if( a == NULL ) { CastSpellBookSpell( STSI_ENEMY_NERF2, target ); return true; } } return false; }
bool Spell_arcane_torrent(Unit* caster, std::list<Unit*> &, SpellCastTargets const&, SpellEntry const *spellInfo, uint32 effectIndex) { if (effectIndex != 0) return true; switch (spellInfo->Id) { case 28730: // Arcane Torrent (Mana) case 33390: // Arcane Torrent (mana Wretched Devourer) { Aura* dummy = caster->GetDummyAura(28734); if (dummy) { int32 bp = (2.17*caster->getLevel() + 9.136) * dummy->GetStackAmount(); caster->CastCustomSpell(caster, 28733, &bp, NULL, NULL, true); caster->RemoveAurasDueToSpell(28734); } break; } // Arcane Torrent (Energy) case 25046: { // Search Mana Tap auras on caster Aura* dummy = caster->GetDummyAura(28734); if (dummy) { int32 bp = dummy->GetStackAmount() * 10; caster->CastCustomSpell(caster, 25048, &bp, NULL, NULL, true); caster->RemoveAurasDueToSpell(28734); } break; } } return true; }
void HandleScript(SpellEffIndex /*effIndex*/) { if (!GetCaster() || !GetHitCreature() || !GetHitCreature()->isAlive()) return; Aura* unstable = NULL; if (!GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) { GetCaster()->CastSpell(GetCaster(), SPELL_UNSTABLE_OOZE, true); if (unstable = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) if (Aura* targetAura = GetHitCreature()->GetAura(SPELL_UNSTABLE_OOZE)) unstable->ModStackAmount(targetAura->GetStackAmount()); } else if (unstable = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) { if (Aura* targetAura = GetHitCreature()->GetAura(SPELL_UNSTABLE_OOZE)) unstable->ModStackAmount(targetAura->GetStackAmount()); else unstable->ModStackAmount(1); } GetHitCreature()->DespawnOrUnsummon(); }
bool AI_SUPPORT_TOWER::TryBeneficCast( Unit *target ) { if( target->IsPlayer() && TickNow > SpellInstances[ STSI_TEAM_BUFF1 ].cooldown_finished ) { Aura *a = target->FindAura( SpellBook[ STSI_TEAM_BUFF1 ].spell_id ); if( a != NULL && a->GetDuration() < SpellBook[ STSI_TEAM_BUFF1 ].spell_duration_fixed ) { a->Remove(); a = NULL; } if( a == NULL ) { CastSpellBookSpell( STSI_TEAM_BUFF1, target ); return true; } } if( target->IsPlayer() && TickNow > SpellInstances[ STSI_TEAM_BUFF2 ].cooldown_finished ) { Aura *a = target->FindAura( SpellBook[ STSI_TEAM_BUFF2 ].spell_id ); if( a != NULL && a->GetDuration() < SpellBook[ STSI_TEAM_BUFF2 ].spell_duration_fixed ) { a->Remove(); a = NULL; } if( a == NULL ) { CastSpellBookSpell( STSI_TEAM_BUFF2, target ); return true; } } if( target->GetUInt32Value( UNIT_FIELD_HEALTH ) < target->GetUInt32Value( UNIT_FIELD_MAXHEALTH )&& TickNow > SpellInstances[ STSI_TEAM_HEAL ].cooldown_finished ) { Aura *a = target->FindAura( SpellBook[ STSI_TEAM_HEAL ].spell_id ); if( a != NULL && a->GetDuration() < SpellBook[ STSI_TEAM_HEAL ].spell_duration_fixed ) { a->Remove(); a = NULL; } if( a == NULL ) { CastSpellBookSpell( STSI_TEAM_HEAL, target ); return true; } } //try to remove nerf so only weakest would be active on our players near us // target->RemoveAura( 14535 ); return false; }
void EnterCombat(Unit* victim) { DoCastAOE(SPELL_ABILITATE_BALANCE_BAR); if (instance) { instance->DoCastSpellOnPlayers(SPELL_ABILITATE_BALANCE_BAR); instance->SetData(DATA_RHYOLITH_EVENT, IN_PROGRESS); } direction = 25; phase1=true; steertimer = 0; me->SetReactState(REACT_PASSIVE); me->SendMovementWalkMode(); moving = true; me->SetSpeed(MOVE_WALK, 0.5f, true); me->SetSpeed(MOVE_RUN, 0.5f, true); me->SetWalk(true); obsidian = me->AddAura(SPELL_OBSIDIAN_ARMOR, me); if (obsidian) obsidian->SetStackAmount(80); DoZoneInCombat(me); leftfoot = me->SummonCreature(LEFT_FOOT_RHYOLITH, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 12.0f, 0,TEMPSUMMON_MANUAL_DESPAWN); if (leftfoot) { leftfoot->EnterVehicle(me, 0); leftfoot->ClearUnitState(UNIT_STATE_ONVEHICLE); } rightfoot = me->SummonCreature(RIGHT_FOOT_RHYOLITH, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 12.0f, 0,TEMPSUMMON_MANUAL_DESPAWN); if (rightfoot) { rightfoot->EnterVehicle(me, 1); rightfoot->ClearUnitState(UNIT_STATE_ONVEHICLE); } events.ScheduleEvent(EVENT_UPDATE_PATH, 2000, 0, 0); events.ScheduleEvent(EVENT_STOMP, 2000, 0, 0); }
bool CloakOfShadows(uint8_t /*effectIndex*/, Spell* s) { Unit* unitTarget = s->GetUnitTarget(); if (!unitTarget || !unitTarget->isAlive()) return false; Aura* pAura; for (uint32 j = MAX_NEGATIVE_AURAS_EXTEDED_START; j < MAX_NEGATIVE_AURAS_EXTEDED_END; ++j) { pAura = unitTarget->m_auras[j]; if (pAura != NULL && !pAura->IsPassive() && !pAura->IsPositive() && !(pAura->GetSpellInfo()->getAttributes() & ATTRIBUTES_IGNORE_INVULNERABILITY) && pAura->GetSpellInfo()->getSchool() != 0 ) pAura->Remove(); } return true; }
void UpdateAI(const uint32 uiDiff) { //despawn after 1 hour timer if(!IsFirstTime) { if(m_uiDespawnTimer < uiDiff) { IsFirstTime = true; DoStopAttack(); CombatStopped = true; m_creature->RemoveAllAuras(); m_creature->setFaction(35); //friendly events.Reset(); //schedule says SayEvents.Reset(); SayEvents.ScheduleEvent(SAYEVENT_END1, 0); SayEvents.ScheduleEvent(SAYEVENT_END2, (10)*IN_MILLISECONDS); SayEvents.ScheduleEvent(SAYEVENT_END3, (10+8)*IN_MILLISECONDS); } else m_uiDespawnTimer -= uiDiff; } SayEvents.Update(uiDiff); while (uint32 eventId = SayEvents.ExecuteEvent()) { switch (eventId) { case SAYEVENT_END1: DoScriptText(SAY_END_1, m_creature); break; case SAYEVENT_END2: DoScriptText(SAY_END_2, m_creature); break; case SAYEVENT_END3: DoScriptText(SAY_END_3, m_creature); m_creature->SetVisibility(VISIBILITY_OFF); EnterEvadeMode(); break; case SAYEVENT_ENTER1: DoScriptText(SAY_ENTER_1, m_creature); break; case SAYEVENT_ENTER2: DoScriptText(SAY_ENTER_2, m_creature); break; case SAYEVENT_ENTER3: DoScriptText(SAY_ENTER_3, m_creature); HasSaidBeginningStuff = true; break; case SAYEVENT_DEFEATED1: DoScriptText(SAY_DEFEATED_1, m_creature); break; case SAYEVENT_DEFEATED2: DoScriptText(SAY_DEFEATED_2, m_creature); break; case SAYEVENT_DEFEATED3: DoScriptText(SAY_DEFEATED_3, m_creature); break; case SAYEVENT_DEFEATED4: DoScriptText(SAY_DEFEATED_4, m_creature); break; case SAYEVENT_DEFEATED5: DoScriptText(SAY_DEFEATED_5, m_creature); m_creature->SetVisibility(VISIBILITY_OFF); EnterEvadeMode(); break; default: break; } } if (CombatStopped || !m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (IsOutOfCombatArea(m_creature)) { EnterEvadeMode(); return; } //check for phase 2 at 20% health if(!IsPhase2) { if(m_creature->GetHealthPercent() < 20.0f) { IsPhase2 = true; DoScriptText(SAY_START_PHASE_2, m_creature); events.CancelEvent(EVENT_SUMMON_STARS); events.CancelEvent(EVENT_SUMMON_CONSTELLATION); UnSummonAllCreatures(); //4 black holes in square pattern const float pos[4][2] = {{10,0}, {-10,0}, {0,10}, {0,-10}}; for (int i = 0; i < 4; i++) DoSpawnCreature(NPC_BLACK_HOLE, pos[i][0], pos[i][1], 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 1000); DoScriptText(SAY_SUMMON_STARS, m_creature); events.ScheduleEvent(EVENT_SUMMON_STARS,SUMMON_STARS_TIMER); } } //switch targets to next top aggro if phase punch stacks >= 5 if (Unit *TopAggro = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO_PLAYER, 0)) { Aura *aur = TopAggro->GetAura(SPELL_PHASE_PUNCH, EFFECT_INDEX_0); if (aur && aur->GetStackAmount() >= 5) if (Unit *NextTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO_PLAYER, 1)) m_creature->Attack(NextTarget, true); } events.Update(uiDiff); while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_BERSERK: DoCast(m_creature, SPELL_BERSERK); //events.ScheduleEvent(EVENT_BERSERK, 10*IN_MILLISECONDS); DoScriptText(SAY_BERSERK, m_creature); DoScriptText(EMOTE_BERSERK, m_creature); break; case EVENT_QUANTUM_STRIKE: DoCast(m_creature->getVictim(), HEROIC(SPELL_QUANTUM_STRIKE, SPELL_QUANTUM_STRIKE_H)); events.ScheduleEvent(EVENT_QUANTUM_STRIKE, QUANTUM_STRIKE_TIMER); break; case EVENT_PHASE_PUNCH: DoCast(m_creature->getVictim(), SPELL_PHASE_PUNCH); events.ScheduleEvent(EVENT_PHASE_PUNCH, PHASE_PUNCH_TIMER); break; case EVENT_ASCEND_TO_HEAVENS: DoCast(m_creature->getVictim(), SPELL_ASCEND_TO_HEAVENS); events.ScheduleEvent(EVENT_ASCEND_TO_HEAVENS, 5*IN_MILLISECONDS); //just in case they survive... hehehe break; case EVENT_SUMMON_STARS: if(!IsPhase2) { size_t n_stars = CurrSummons.count(NPC_COLLAPSING_STAR); if (n_stars > MAX_STARS) //shouldnt happen break; for(size_t i = 0; i < MAX_STARS-n_stars; i++) //respawn missing stars { float x, y; GetRandomPointInCircle(30.0f, x, y); DoSpawnCreature(NPC_COLLAPSING_STAR, x, y, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 1000); } if (MAX_STARS-n_stars > 0) //summoned at least one DoScriptText(SAY_SUMMON_STARS, m_creature); events.ScheduleEvent(EVENT_SUMMON_STARS, SUMMON_STARS_TIMER); } break; case EVENT_SUMMON_CONSTELLATION: if (CurrSummons.count(NPC_LIVING_CONSTELLATION) > MAX_CONSTELLATIONS) //just to avoid infinite summons break; for(int i=0; i<3; i++) { float x, y; GetRandomPointInCircle(30.0f, x, y); DoSpawnCreature(NPC_LIVING_CONSTELLATION, x, y, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 1000); } events.ScheduleEvent(EVENT_SUMMON_CONSTELLATION, SUMMON_CONSTELLATION_TIMER); break; case EVENT_COSMIC_SMASH: //TODO: mark destination point (don't know the spell) DoScriptText(EMOTE_COSMIC_SMASH, m_creature); events.ScheduleEvent(EVENT_COSMIC_SMASH_EFFECT, 2*IN_MILLISECONDS); events.ScheduleEvent(EVENT_COSMIC_SMASH, COSMIC_SMASH_TIMER); break; case EVENT_COSMIC_SMASH_EFFECT: for (int i = 0; i < HEROIC(1, 3); i++) { float x, y; GetRandomPointInCircle(30.0f, x, y); m_creature->CastSpell(m_creature->GetPositionX()+x, m_creature->GetPositionY()+y, m_creature->GetPositionZ()+0.5f, HEROIC(SPELL_COSMIC_SMASH, SPELL_COSMIC_SMASH_H), true); } break; default: break; } } DoMeleeAttackIfReady(); }
bool PlayerbotClassAI::castSelfCCBreakers (uint32 castList[]) { uint32 dispelSpell = 0; Player *dTarget = GetPlayerBot(); /* dispelSpell = (uint32) R_ESCAPE_ARTIST; // this is script effect, Unit::AuraMap const& auras = dTarget->GetOwnedAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++) { Aura * aura = itr->second; AuraApplication * aurApp = aura->GetApplicationOfTarget(dTarget->GetGUID()); if (!aurApp) continue; if ( ( aura->GetSpellProto()->Mechanic == MECHANIC_SNARE ) || ( aura->GetSpellProto()->Mechanic == MECHANIC_ROOT ) ) { if(aura->GetSpellProto()->Dispel == DISPEL_MAGIC) { bool positive = aurApp->IsPositive() ? (!(aura->GetSpellProto()->AttributesEx & SPELL_ATTR0_UNK7)) : false; // do not remove positive auras if friendly target // negative auras if non-friendly target if(positive == dTarget->IsFriendlyTo(caster)) continue; } return castSpell(dispelSpell, dTarget); } } return false; */ // racial abilities /* if( GetPlayerBot()->getRace() == RACE_BLOODELF && !pTarget->HasAura( ARCANE_TORRENT,0 ) && castSpell( ARCANE_TORRENT,pTarget ) ) { //GetPlayerBot()->Say("Arcane Torrent!", LANG_UNIVERSAL); } else if( GetPlayerBot()->getRace() == RACE_HUMAN && (GetPlayerBot()->HasUnitState( UNIT_STAT_STUNNED ) || GetPlayerBot()->HasAuraType( SPELL_AURA_MOD_FEAR ) || GetPlayerBot()->HasAuraType( SPELL_AURA_MOD_DECREASE_SPEED ) || GetPlayerBot()->HasAuraType( SPELL_AURA_MOD_CHARM )) && castSpell( EVERY_MAN_FOR_HIMSELF, GetPlayerBot() ) ) { //GetPlayerBot()->Say("EVERY MAN FOR HIMSELF!", LANG_UNIVERSAL); } else if( GetPlayerBot()->getRace() == RACE_UNDEAD_PLAYER && (GetPlayerBot()->HasAuraType( SPELL_AURA_MOD_FEAR ) || GetPlayerBot()->HasAuraType( SPELL_AURA_MOD_CHARM )) && castSpell( WILL_OF_THE_FORSAKEN, GetPlayerBot() ) ) { // GetPlayerBot()->Say("WILL OF THE FORSAKEN!", LANG_UNIVERSAL); } else if( GetPlayerBot()->getRace() == RACE_DWARF && GetPlayerBot()->HasAuraState( AURA_STATE_DEADLY_POISON ) && castSpell( STONEFORM, GetPlayerBot() ) ) { //GetPlayerBot()->Say("STONEFORM!", LANG_UNIVERSAL); } else if( GetPlayerBot()->getRace() == RACE_GNOME && (GetPlayerBot()->HasUnitState( UNIT_STAT_STUNNED ) || GetPlayerBot()->HasAuraType( SPELL_AURA_MOD_DECREASE_SPEED )) && castSpell( ESCAPE_ARTIST, GetPlayerBot() ) ) { // GetPlayerBot()->Say("ESCAPE ARTIST!", LANG_UNIVERSAL); } */ for (uint8 j = 0; j < sizeof (castList); j++) { dispelSpell = castList[j]; if (dispelSpell == 0 || !dTarget->HasSpell(dispelSpell) || !CanCast(dispelSpell, dTarget, true)) continue; SpellEntry const *dSpell = GetSpellStore()->LookupEntry(dispelSpell); if (!dSpell) continue; for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++i) { if (dSpell->Effect[i] != (uint32)SPELL_EFFECT_DISPEL && dSpell->Effect[i] != (uint32)SPELL_EFFECT_APPLY_AURA) continue; if (dSpell->Effect[i] == (uint32)SPELL_EFFECT_APPLY_AURA && ( (dSpell->EffectApplyAuraName[i] != (uint32) SPELL_AURA_MECHANIC_IMMUNITY) || (dSpell->EffectApplyAuraName[i] != (uint32) SPELL_AURA_DISPEL_IMMUNITY) )) continue; Unit::AuraMap const& auras = dTarget->GetOwnedAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++) { Aura * aura = itr->second; AuraApplication * aurApp = aura->GetApplicationOfTarget(dTarget->GetGUID()); if (!aurApp) continue; if (aura->GetSpellProto() && ( (dSpell->Effect[i] == (uint32)SPELL_EFFECT_DISPEL && ((1<<aura->GetSpellProto()->Dispel) & GetDispellMask(DispelType(dSpell->EffectMiscValue[i]))) ) || (dSpell->EffectApplyAuraName[i] == (uint32) SPELL_AURA_MECHANIC_IMMUNITY && ( GetAllSpellMechanicMask(aura->GetSpellProto()) & ( 1 << dSpell->EffectMiscValue[i]) ) ) || (dSpell->EffectApplyAuraName[i] == (uint32) SPELL_AURA_DISPEL_IMMUNITY && ( (1<<aura->GetSpellProto()->Dispel) & GetDispellMask(DispelType(dSpell->EffectMiscValue[i])) ) ) ) ) { if(aura->GetSpellProto()->Dispel == DISPEL_MAGIC) { bool positive = aurApp->IsPositive() ? (!(aura->GetSpellProto()->AttributesEx & SPELL_ATTR0_UNK7)) : false; if(positive)continue; } return CastSpell(dispelSpell, dTarget, false); } } } } return false; }
void DynamicObject::UpdateTargets() { if(m_aliveDuration == 0) return; if(m_aliveDuration >= 100) { FactionRangeList::iterator itr = m_inRangeOppFactions.begin(); FactionRangeList::iterator iend = m_inRangeOppFactions.end(); Unit * target; Aura * pAura; float radius = powf(m_floatValues[DYNAMICOBJECT_RADIUS], 2); while(itr != iend) { target = *itr; ++itr; // skip units already hit, their range will be tested later if(targets.find(target) != targets.end()) continue; if(GetDistanceSq(target) <= radius) { pAura = new Aura(m_spellProto, m_aliveDuration, u_caster, target); for(uint32 i = 0; i < 3; ++i) { if(m_spellProto->Effect[i] == 27) { pAura->AddMod(m_spellProto->EffectApplyAuraName[i], m_spellProto->EffectBasePoints[i]+1, m_spellProto->EffectMiscValue[i], i); } } target->AddAura(pAura); if(p_caster) p_caster->HandleProc(PROC_ON_CAST_SPECIFIC_SPELL | PROC_ON_CAST_SPELL,target, m_spellProto); // add to target list targets.insert(target); } } // loop the targets, check the range of all of them DynamicObjectList::iterator jtr = targets.begin(); DynamicObjectList::iterator jtr2; DynamicObjectList::iterator jend = targets.end(); while(jtr != jend) { target = *jtr; jtr2 = jtr; ++jtr; if(GetDistanceSq(target) > radius) { targets.erase(jtr2); target->RemoveAura(m_spellProto->Id); } } m_aliveDuration -= 100; } else { m_aliveDuration = 0; } if(m_aliveDuration == 0) { DynamicObjectList::iterator jtr = targets.begin(); DynamicObjectList::iterator jend = targets.end(); Unit * target; while(jtr != jend) { target = *jtr; ++jtr; target->RemoveAura(m_spellProto->Id); } Remove(); } }
void DynamicObject::UpdateTargets() { if(m_aliveDuration == 0) return; if(m_aliveDuration >= 100) { Unit* target; Aura* pAura; float radius = m_floatValues[ DYNAMICOBJECT_RADIUS ] * m_floatValues[ DYNAMICOBJECT_RADIUS ]; // Looking for targets in the Object set for(std::set< Object* >::iterator itr = m_objectsInRange.begin(); itr != m_objectsInRange.end(); ++itr) { Object* o = *itr; if(!o->IsUnit() || !TO< Unit* >(o)->isAlive()) continue; target = TO< Unit* >(o); if(!isAttackable(u_caster, target, !(m_spellProto->c_is_flags & SPELL_FLAG_IS_TARGETINGSTEALTHED))) continue; // skip units already hit, their range will be tested later if(targets.find(target->GetGUID()) != targets.end()) continue; if(GetDistanceSq(target) <= radius) { pAura = sSpellFactoryMgr.NewAura(m_spellProto, m_aliveDuration, u_caster, target, true); for(uint32 i = 0; i < 3; ++i) { if(m_spellProto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA) { pAura->AddMod(m_spellProto->EffectApplyAuraName[i], m_spellProto->EffectBasePoints[i] + 1, m_spellProto->EffectMiscValue[i], i); } } target->AddAura(pAura); if(p_caster) { p_caster->HandleProc(PROC_ON_CAST_SPECIFIC_SPELL | PROC_ON_CAST_SPELL, target, m_spellProto); p_caster->m_procCounter = 0; } // add to target list targets.insert(target->GetGUID()); } } // loop the targets, check the range of all of them DynamicObjectList::iterator jtr = targets.begin(); DynamicObjectList::iterator jtr2; DynamicObjectList::iterator jend = targets.end(); while(jtr != jend) { target = GetMapMgr() ? GetMapMgr()->GetUnit(*jtr) : NULL; jtr2 = jtr; ++jtr; if((target != NULL) && (GetDistanceSq(target) > radius)) { target->RemoveAura(m_spellProto->Id); targets.erase(jtr2); } } m_aliveDuration -= 100; } else { m_aliveDuration = 0; } if(m_aliveDuration == 0) { Remove(); } }
void DynamicObject::UpdateTargets() { if(m_aliveDuration == 0) return; if(m_aliveDuration >= 100) { std::set<Object*>::iterator itr = GetInRangeSetBegin(),itr2; std::set<Object*>::iterator iend = GetInRangeSetEnd(); Unit * target; Aura * pAura; float radius = m_floatValues[DYNAMICOBJECT_RADIUS]*m_floatValues[DYNAMICOBJECT_RADIUS]; this->AquireInrangeLock(); //make sure to release lock before exit function ! while(itr != iend) { // target = *itr; // ++itr; itr2 = itr; ++itr; if( !( (*itr2)->IsUnit() ) || ! static_cast< Unit* >( *itr2 )->isAlive() || ( static_cast< Creature* >( *itr2 )->IsTotem() && !static_cast< Unit* >( *itr2 )->IsPlayer() ) ) continue; target = static_cast< Unit* >( *itr2 ); if( !isAttackable( p_caster, target, !(m_spellProto->c_is_flags & SPELL_FLAG_IS_TARGETINGSTEALTHED) ) ) continue; // skip units already hit, their range will be tested later if(targets.find(target->GetGUID()) != targets.end()) continue; if(GetDistanceSq(target) <= radius) { pAura = AuraPool.PooledNew(); pAura->Init(m_spellProto, m_aliveDuration, u_caster, target, true); for(uint32 i = 0; i < 3; ++i) { if(m_spellProto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA) { pAura->AddMod(m_spellProto->EffectApplyAuraName[i], m_spellProto->EffectBasePoints[i]+1, m_spellProto->EffectMiscValue[i], i); } } target->AddAura(pAura, m_spellScript); if(p_caster) { p_caster->HandleProc(PROC_ON_CAST_SPECIFIC_SPELL | PROC_ON_CAST_SPELL,target, m_spellProto); p_caster->m_procCounter = 0; } // add to target list targets.insert(target->GetGUID()); } } this->ReleaseInrangeLock(); // loop the targets, check the range of all of them DynamicObjectList::iterator jtr = targets.begin(); DynamicObjectList::iterator jtr2; DynamicObjectList::iterator jend = targets.end(); while(jtr != jend) { target = GetMapMgr() ? GetMapMgr()->GetUnit(*jtr) : NULL; jtr2 = jtr; ++jtr; if(GetDistanceSq(target) > radius) { target->RemoveAura(m_spellProto->Id); targets.erase(jtr2); } } m_aliveDuration -= 100; } else { m_aliveDuration = 0; } if(m_aliveDuration == 0) { Remove(); } }