void LaunchDaemon::_HandleGetLaunchTargets(BMessage* message) { uid_t user = _GetUserID(message); if (user < 0) return; BMessage reply; status_t status = B_OK; if (!fUserMode) { // Request the data from the user's daemon, too Session* session = FindSession(user); if (session != NULL) { BMessage request(B_GET_LAUNCH_TARGETS); status = request.AddInt32("user", 0); if (status == B_OK) { status = session->Daemon().SendMessage(&request, &reply); } if (status == B_OK) status = reply.what; } else status = B_NAME_NOT_FOUND; } if (status == B_OK) { TargetMap::const_iterator iterator = fTargets.begin(); for (; iterator != fTargets.end(); iterator++) reply.AddString("target", iterator->first); } reply.what = status; message->SendReply(&reply); }
Unit *RandomTarget(bool tank,bool onlyplayer, float dist) { if (_unit->GetAIInterface()->getAITargetsCount() == 0) return NULL; std::vector<Unit*> targetTable; TargetMap *targets = _unit->GetAIInterface()->GetAITargets(); for (TargetMap::iterator itr = targets->begin(); itr != targets->end(); itr++) { Unit *temp = _unit->GetMapMgr()->GetUnit(itr->first); if (_unit->GetDistance2dSq(temp) <= dist) { if (((!tank && temp != _unit->GetAIInterface()->GetNextTarget()) || tank) && (!onlyplayer || (onlyplayer && temp->GetTypeId() == TYPEID_PLAYER))) { targetTable.push_back(temp); } } } if (targetTable.empty()) return NULL; uint32 randt = RandomUInt(100)%targetTable.size(); Unit * randomtarget = targetTable[randt]; return randomtarget; }
void shatter() { TargetMap *targets = _unit->GetAIInterface()->GetAITargets(); if ( targets == NULL ) return; for ( TargetMap::iterator itr = targets->begin(); itr != targets->end(); itr++ ) { if ( _unit->GetMapMgr()->GetUnit(itr->first) == NULL || _unit->GetMapMgr()->GetUnit(itr->first)->GetTypeId() != TYPEID_PLAYER || _unit->GetMapMgr()->GetUnit(itr->first)->isDead() ) continue; Player* _plr = (Player*)(_unit->GetMapMgr()->GetUnit(itr->first)); for(set<Player*>::iterator itr2 = _plr->GetInRangePlayerSetBegin(); itr2 != _plr->GetInRangePlayerSetEnd(); ++itr2) { if ( (*itr2) != NULL && (*itr2) != _plr && (*itr2)->isAlive() && _plr->GetDistance2dSq( *itr2 ) <= 400.0f ) { int32 damage = int32(9000.0f - 21.5f * _plr->GetDistance2dSq(*itr2)); SpellEntry *tempspell = dbcSpell.LookupEntry( SHATTER ); if ( damage > 0 && tempspell != NULL) { tempspell->c_is_flags |= 0x00000040; tempspell->EffectBasePoints[0] = damage; _plr->CastSpell( *itr2, tempspell, true ); } } } _plr->RemoveAura( STONED ); } }
void stoned() { if (_unit->GetAIInterface()->getAITargetsCount() == 0) return; TargetMap *targets = _unit->GetAIInterface()->GetAITargets(); for (TargetMap::iterator itr = targets->begin(); itr != targets->end(); itr++) { Unit *temp = _unit->GetMapMgr()->GetUnit(itr->first); if ( temp != NULL && temp->GetTypeId() == TYPEID_PLAYER && temp->isAlive()) temp->CastSpell(temp, STONED, true); } }
void groundSlam() { if (_unit->GetAIInterface()->getAITargetsCount() == 0) return; TargetMap *targets = _unit->GetAIInterface()->GetAITargets(); for (TargetMap::iterator itr = targets->begin(); itr != targets->end(); itr++) { Unit *temp = _unit->GetMapMgr()->GetUnit(itr->first); if (temp->GetTypeId() == TYPEID_PLAYER && temp->isAlive()) { knockback(temp); temp->CastSpell(temp, GROUND_SLAM, true); } } }
void hurtfulStrike() { if (_unit->GetAIInterface()->getAITargetsCount() == 0) return; TargetMap *targets = _unit->GetAIInterface()->GetAITargets(); Unit *mUnit = _unit->GetAIInterface()->GetMostHated(); if ( mUnit == NULL || targets == NULL ) return; pair<Unit*, int32> currentTarget; currentTarget.first = NULL; currentTarget.second = -1; TargetMap::iterator it2 = targets->begin(); TargetMap::iterator itr; for( ; it2 != targets->end(); ) { itr = it2; ++it2; if( _unit->GetMapMgr()->GetUnit(itr->first) == NULL || _unit->GetMapMgr()->GetUnit(itr->first)->GetTypeId() != TYPEID_PLAYER || !_unit->GetMapMgr()->GetUnit(itr->first)->isAlive() || _unit->GetDistance2dSq(_unit->GetMapMgr()->GetUnit(itr->first)) >= 100.0f ) continue; if( itr->second > currentTarget.second && _unit->GetMapMgr()->GetUnit(itr->first) != mUnit ) { currentTarget.first = _unit->GetMapMgr()->GetUnit(itr->first); currentTarget.second = itr->second; } } if ( currentTarget.first == NULL && mUnit != NULL && _unit->GetDistance2dSq( mUnit ) <= 100.0f) currentTarget.first = mUnit; if ( currentTarget.first != NULL ) _unit->CastSpell(currentTarget.first, HURTFUL_STRIKE, true); }