bool ForemansBlackjack(uint32 i, Spell* pSpell) { Unit* target = pSpell->GetUnitTarget(); if(!pSpell->p_caster || !target || !target->IsCreature()) return true; // check to see that we have the correct creature Creature* c_target = TO_CREATURE(target); if(c_target->GetEntry() != 10556 || !c_target->HasAura(17743)) return true; // Start moving again if(target->GetAIInterface()) target->GetAIInterface()->StopMovement(0); // Remove Zzz aura c_target->RemoveAllAuras(); WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 12); data << uint32(6197) << c_target->GetGUID(); pSpell->p_caster->SendMessageToSet(&data, true); // send chat message char msg[100]; sprintf(msg, "Ow! Ok, I'll get back to work, %s", pSpell->p_caster->GetName()); target->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, msg); c_target->Emote(EMOTE_STATE_WORK_CHOPWOOD); // Add timed event to return lazy peon to Zzz after 5-10 minutes (spell 17743) SpellEntry* pSpellEntry = dbcSpell.LookupEntry(17743); sEventMgr.AddEvent(target , &Unit::EventCastSpell , target , pSpellEntry , EVENT_UNK, 300000 + RandomUInt(300000) , 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); return true; }
bool ForemansBlackjack(uint32 i, Spell *pSpell) { Unit * target = pSpell->GetUnitTarget(); if(!pSpell->p_caster || !target || target->GetTypeId() != TYPEID_UNIT) return true; // check to see that we have the correct creature Creature *c_target = TO_CREATURE(target); if(!c_target || c_target->GetEntry() != 10556 || !c_target->HasAura(18795)) return true; // Start moving again if(target->GetAIInterface()) target->GetAIInterface()->StopMovement(0); // Remove Zzz aura c_target->RemoveAllAuras(); // send chat message char msg[100]; sprintf(msg, "Ow! Ok, I'll get back to work, %s", pSpell->p_caster->GetName()); target->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, msg); // Increment the quest log sQuestMgr.OnPlayerKill( pSpell->p_caster, c_target ); // Add timed event to return lazy peon to Zzz after 5-10 minutes (spell 18795) SpellEntry * pSpellEntry = dbcSpell.LookupEntry(18795); sEventMgr.AddEvent( target ,&Unit::EventCastSpell , target , pSpellEntry , EVENT_UNK, 300000 + RandomUInt( 300000 ) , 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); return true; }
void OnCombatStart(Unit* pTarget) { SetDisplayWeapon(true, true); ParentClass::OnCombatStart(pTarget); mAliveAdds = 0; mLastYell = -1; for (int i = 0; i < 4; ++i) { Unit* pAdd = ForceCreatureFind(Adds[i]); if (pAdd != NULL && pAdd->isAlive()) { Unit* pTarget = GetBestPlayerTarget(); if (pTarget != NULL) { pAdd->GetAIInterface()->AttackReaction(pTarget, 200); } ++mAliveAdds; } } if (mAliveAdds > 1) { SetCanEnterCombat(false); SetBehavior(Behavior_Spell); SetCanMove(false); } }
SPELL_EFFECT_OVERRIDE_RETURNS AH_106199( Aura *aur, bool apply, uint8 i ) { Unit *target = aur->GetTarget(); if( i == 0 && target ) { //on dispel we jump to a new target if( aur->m_flags & WAS_REMOVED_ON_DISPEL ) { uint32 NewSpellId; if( RandomUInt( 70 ) ) NewSpellId = 106199; //Blood Corruption: Death else NewSpellId = 106200; //Blood Corruption: Earth AI_Spell sp; sp.spelltargetType = TTYPE_AT_RANGE_PLAYER_RANDOM; sp.minrange = 0.0f; sp.maxrange = 200; Unit *t = target->GetAIInterface()->FindTargetForSpellTargetType( &sp ); if( t ) t->CastSpell( t, NewSpellId, true ); } //on expire we apply our evil buff else { if( aur->GetSpellId() == 106199 ) target->CastSpell( target, 106201, true ); else target->CastSpell( target, 106213, true ); } } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
void AIUpdate() { if( spark_timer < getMSTime() ) { spark_timer = 0; _unit->UnRoot(); _unit->GetAIInterface()->disable_combat = false; _unit->m_invisible = false; _unit->UpdateVisibility(); for( uint8 i=0; i<SPARKS_COUNT; i++) if( sparks[i] != 0 ) { Unit* Spark = _unit->GetMapMgr()->GetUnit( sparks[i] ); if( Spark ) { Spark->RemoveAllAuras(); Spark->GetAIInterface()->MoveTo(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation()); Spark->Root(); Spark->GetAIInterface()->disable_combat = true; } } } if( spark_timer == 0 && spells.size() > 0 ) { for( uint8 i = 0; i<spells.size(); i++ ) { if( spells[i]->time < getMSTime() ) { if( Rand( spells[i]->chance ) ) { CastScriptSpell( spells[i] ); spells[i]->time = getMSTime() + spells[i]->timer; } } } } }
bool Dummy_Solarian_WrathOfTheAstromancer(uint32 pEffectIndex, Spell* pSpell) { Unit* Caster = pSpell->u_caster; if(!Caster) return true; Unit* Target = Caster->GetAIInterface()->getNextTarget(); if(!Target) return true; SpellEntry* SpellInfo = dbcSpell.LookupEntry(42787); if(!SpellInfo) return true; //Explode bomb after 6sec sEventMgr.AddEvent(Target, &Unit::EventCastSpell, Target, SpellInfo, EVENT_UNK, 6000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); return true; }
void OnCombatStart(Unit * mTarget) { _unit->GetAIInterface()->m_canMove = false; _unit->GetAIInterface()->disable_melee = true; _unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); Unit * antusul = NULLUNIT; antusul = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(1815.030029f, 686.817017f, 14.519000f, 8127); if(antusul) { if(antusul->isAlive()) { antusul->GetAIInterface()->AttackReaction(mTarget, 0, 0); antusul->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Lunch has arrived, my beutiful childern. Tear them to pieces!"); } } }
void AIUpdate() { if (!HasSummoned && _unit->GetHealthPct() <= 8) { Unit *Warchief = NULL; Warchief =_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_REND_BLACKHAND, 157.366516f, -419.779358f, 110.472336f, 3.056772f, false, false, 0, 0); if (Warchief != NULL) { if (_unit->GetAIInterface()->GetNextTarget() != NULL) { Warchief->GetAIInterface()->AttackReaction(_unit->GetAIInterface()->GetNextTarget(), 1, 0); } } HasSummoned = true; } float val = (float)RandomFloat(100.0f); SpellCast(val); }
void AIUpdate() { if (!HasSummoned && _unit->GetHealthPct() <= 25) { Unit *cGizrul = NULL; cGizrul =_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_GIZRUL, -195.100006f, -321.970001f, 65.424400f, 0.016500f, false, false, 0, 0); if (cGizrul != NULL) { if (_unit->GetAIInterface()->GetNextTarget() != NULL) { cGizrul->GetAIInterface()->AttackReaction(_unit->GetAIInterface()->GetNextTarget(), 1, 0); } } HasSummoned = true; } float val = (float)RandomFloat(100.0f); SpellCast(val); }
Unit* ArcScriptCreatureAI::GetSecondMostHatedTargetInArray(UnitArray& pTargetArray) { Unit* TargetUnit = NULL; Unit* MostHatedUnit = NULL; Unit* CurrentTarget = _unit->GetAIInterface()->GetNextTarget(); uint32 Threat = 0, HighestThreat = 0; for( UnitArray::iterator UnitIter = pTargetArray.begin(); UnitIter != pTargetArray.end(); ++UnitIter ) { TargetUnit = (*UnitIter); if( TargetUnit != CurrentTarget ) { Threat = TargetUnit->GetAIInterface()->getThreatByPtr(_unit); if( Threat > HighestThreat ) { MostHatedUnit = TargetUnit; HighestThreat = Threat; } } } return MostHatedUnit; }
void OnDamageTaken(Unit* mAttacker, float fAmount) { if( (int)( last_creation_hp - DISPARSE_HP ) >= _unit->GetHealthPct() ) { switch(rand()%2) { case 0: _unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The slightest spark shall be your undoing." ); break; case 1: _unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "No one is safe!" ); break; } spark_timer = getMSTime() + SPARK_PHASE_DURATION; last_creation_hp = _unit->GetHealthPct(); _unit->CastSpell(_unit, 52770, true);//disperse, dummy _unit->Root(); _unit->GetAIInterface()->disable_combat = false; _unit->m_invisible = false; _unit->UpdateVisibility(); //disparse for( uint8 i=0; i<SPARKS_COUNT; i++) if( sparks[i] != 0 ) { Unit* Spark = _unit->GetMapMgr()->GetUnit( sparks[i] ); if( Spark ) { uint32 spellid = heroic ? 59833 : 52667; Spark->CastSpell(Spark, spellid, true); Spark->UnRoot(); _unit->GetAIInterface()->disable_combat = false; Player* p_target = GetRandomPlayerTarget(); if( p_target ) { Spark->GetAIInterface()->MoveTo(p_target->GetPositionX(),p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation()); } } } } }
bool DeathGrip(uint32 i, Spell* s) { Unit* unitTarget = s->GetUnitTarget(); if(!s->u_caster || !s->u_caster->isAlive() || !unitTarget || !unitTarget->isAlive()) return false; // rooted units can't be death gripped if(unitTarget->isRooted()) return false; if(unitTarget->IsPlayer()) { Player* playerTarget = TO< Player* >(unitTarget); if(playerTarget->m_CurrentTransporter) // Blizzard screwed this up, so we won't. return false; s->SpellEffectPlayerPull(i); return false; } else { float posX, posY, posZ; float deltaX, deltaY; if(s->u_caster->GetPositionX() == 0.0f || s->u_caster->GetPositionY() == 0.0f) return false; deltaX = s->u_caster->GetPositionX() - unitTarget->GetPositionX(); deltaY = s->u_caster->GetPositionY() - unitTarget->GetPositionY(); if(deltaX == 0.0f || deltaY == 0.0f) return false; float d = sqrt(deltaX * deltaX + deltaY * deltaY) - s->u_caster->GetBoundingRadius() - unitTarget->GetBoundingRadius(); float alpha = atanf(deltaY / deltaX); if(deltaX < 0) alpha += M_PI_FLOAT; posX = d * cosf(alpha) + unitTarget->GetPositionX(); posY = d * sinf(alpha) + unitTarget->GetPositionY(); posZ = s->u_caster->GetPositionZ(); uint32 time = uint32((unitTarget->CalcDistance(s->m_caster) / ((unitTarget->m_runSpeed * 3.5) * 0.001f)) + 0.5); WorldPacket data(SMSG_MONSTER_MOVE, 60); data << unitTarget->GetNewGUID(); data << uint8(0); //VLack: the usual change in SMSG_MONSTER_MOVE packets, initial idea from Mangos data << unitTarget->GetPositionX(); data << unitTarget->GetPositionY(); data << unitTarget->GetPositionZ(); data << getMSTime(); data << uint8(0x00); data << uint32(0x00001000); data << time; data << uint32(1); data << posX << posY << posZ; if(unitTarget->IsCreature()) unitTarget->GetAIInterface()->StopMovement(2000); unitTarget->SendMessageToSet(&data, true); unitTarget->SetPosition(posX, posY, posZ, alpha, true); unitTarget->addStateFlag(UF_ATTACKING); unitTarget->smsg_AttackStart(unitTarget); unitTarget->setAttackTimer(time, false); unitTarget->setAttackTimer(time, true); unitTarget->GetAIInterface()->taunt(s->u_caster, true); } return true; }
bool ChatHandler::HandleAddAIAgentCommand(const char* args, WorldSession *m_session) { char* agent = strtok((char*)args, " "); if(!agent) return false; char* procEvent = strtok(NULL, " "); if(!procEvent) return false; char* procChance = strtok(NULL, " "); if(!procChance) return false; char* procCount = strtok(NULL, " "); if(!procCount) return false; char* spellId = strtok(NULL, " "); if(!spellId) return false; char* spellType = strtok(NULL, " "); if(!spellType) return false; char* spelltargetType = strtok(NULL, " "); if(!spelltargetType) return false; char* spellCooldown = strtok(NULL, " "); if(!spellCooldown) return false; char* floatMisc1 = strtok(NULL, " "); if(!floatMisc1) return false; char* Misc2 = strtok(NULL, " "); if(!Misc2) return false; Unit* target = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(m_session->GetPlayer()->GetSelection())); if(!target) { RedSystemMessage(m_session, "You have to select a Creature!"); return false; } std::stringstream qry; qry << "INSERT INTO ai_agents set entryId = '" << target->GetUInt32Value(OBJECT_FIELD_ENTRY) << "', AI_AGENT = '" << atoi(agent) << "', procEvent = '" << atoi(procEvent)<< "', procChance = '" << atoi(procChance)<< "', procCount = '" << atoi(procCount)<< "', spellId = '" << atoi(spellId)<< "', spellType = '" << atoi(spellType)<< "', spelltargetType = '" << atoi(spelltargetType)<< "', spellCooldown = '" << atoi(spellCooldown)<< "', floatMisc1 = '" << atof(floatMisc1)<< "', Misc2 ='" << atoi(Misc2)<< "'"; WorldDatabase.Execute( qry.str().c_str( ) ); AI_Spell * sp = new AI_Spell; sp->agent = atoi(agent); sp->procChance = atoi(procChance); /* sp->procCount = atoi(procCount);*/ sp->spell = dbcSpell.LookupEntry(atoi(spellId)); sp->spellType = atoi(spellType); sp->spelltargetType = atoi(spelltargetType); sp->floatMisc1 = (float)atof(floatMisc1); sp->Misc2 = (uint32)atof(Misc2); sp->cooldown = (uint32)atoi(spellCooldown); sp->procCount=0; sp->procCounter=0; sp->cooldowntime=0; sp->custom_pointer=false; sp->minrange = GetMinRange(dbcSpellRange.LookupEntry(dbcSpell.LookupEntry(atoi(spellId))->rangeIndex)); sp->maxrange = GetMaxRange(dbcSpellRange.LookupEntry(dbcSpell.LookupEntry(atoi(spellId))->rangeIndex)); if(sp->agent == AGENT_CALLFORHELP) target->GetAIInterface()->m_canCallForHelp = true; else if(sp->agent == AGENT_FLEE) target->GetAIInterface()->m_canFlee = true; else if(sp->agent == AGENT_RANGED) target->GetAIInterface()->m_canRangedAttack = true; else target->GetAIInterface()->addSpellToList(sp); return true; }
void WorldSession::HandleCharmForceCastSpell(WorldPacket & recvPacket) { DEBUG_LOG( "WORLD"," got CMSG_PET_CAST_SPELL." ); uint64 guid; uint32 spellid; uint8 counter, flags; Unit* caster; SpellCastTargets targets; list<AI_Spell*>::iterator itr; recvPacket >> guid >> counter >> spellid >> flags; SpellEntry *sp = dbcSpell.LookupEntry(spellid); // Summoned Elemental's Freeze if(spellid == 33395) { caster = _player->m_Summon; if( caster && TO_PET(caster)->GetAISpellForSpellId(spellid) == NULL ) return; } else { if(_player->m_CurrentVehicle) caster = _player->m_CurrentVehicle; else caster = _player->m_CurrentCharm; if( caster != NULL ) { if(caster->IsVehicle() && !caster->IsPlayer()) { CreatureProtoVehicle* vehpro = CreatureProtoVehicleStorage.LookupEntry(caster->GetEntry()); bool hasspell = false; for(int i = 0; i < 6; ++i) { if(vehpro->VehicleSpells[i] = spellid) { hasspell = true; break; } } if(!hasspell) { WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1); data << uint8(0); data << uint32(spellid); data << uint8(SPELL_FAILED_NOT_KNOWN); SendPacket(&data); // Send packet to owner return; } } else { for(itr = caster->GetAIInterface()->m_spells.begin(); itr != caster->GetAIInterface()->m_spells.end(); ++itr) { if( (*itr)->spell->Id == spellid ) break; } if( itr == caster->GetAIInterface()->m_spells.end() ) return; } } } if( caster == NULL || guid != caster->GetGUID()) { WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1); data << uint8(0); data << uint32(spellid); data << uint8(SPELL_FAILED_SPELL_UNAVAILABLE); SendPacket(&data); // Send packet to owner return; } if( caster->IsVehicle() && !_player->m_CurrentVehicle) { WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1); data << uint8(0); data << uint32(spellid); data << uint8(SPELL_FAILED_NOT_ON_TRANSPORT); SendPacket(&data); // Send packet to owner return; } targets.read(recvPacket, _player->GetGUID()); Spell* pSpell = new Spell(caster, sp, false, NULL); pSpell->prepare(&targets); }