///Оповещение о присоединении узла void BindNode (Node& child) { try { const char* target_name = child.Name (); if (!target_name) return; TargetMap::iterator iter = targets.find (target_name); if (iter == targets.end ()) return; Target& target = *iter->second; if (target.node) throw xtl::format_operation_exception ("", "Duplicate node for animation target '%s'", target_name); target.BindNode (&child); } catch (std::exception& e) { log.Printf ("%s\n at scene_graph::controllers::AnimationController::Impl::BindNode", e.what ()); } catch (...) { log.Printf ("uknown exception\n at scene_graph::controllers::AnimationController::Impl::BindNode"); } }
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 ); } }
Target* LaunchDaemon::FindTarget(const char* name) const { if (name == NULL) return NULL; TargetMap::const_iterator found = fTargets.find(BString(name).ToLower()); if (found != fTargets.end()) return found->second; return NULL; }
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 AddTarget (const char* target_name, TargetBlender& target_blender) { try { //получение родительского узла Node* root = owner.AttachedNode (); if (!root) throw xtl::format_operation_exception ("", "Animation node was detached"); //проверка корректности if (targets.find (target_name) != targets.end ()) throw xtl::format_operation_exception ("", "Animation target '%s' has already registered", target_name); //создание анимационной цели TargetPtr target (new Target (target_blender), false); //регистрация анимационной цели targets.insert_pair (target_name, target); //поиск потомка Node::Pointer node; if (!strcmp (root->Name (), target_name)) { node = root; } else { node = root->FindChild (target_name, NodeSearchMode_OnAllSublevels); } if (node) target->BindNode (node.get ()); } catch (std::exception& e) { log.Printf ("%s\n at scene_graph::controllers::AnimationController::Impl::AddTarget", e.what ()); } catch (...) { log.Printf ("uknown exception\n at scene_graph::controllers::AnimationController::Impl::AddTarget"); } }
///Удаление анимационной цели void RemoveTarget (const char* target_name) { if (!target_name) return; targets.erase (target_name); }
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 UnbindNode (Node& child) { const char* target_name = child.Name (); if (!target_name) return; TargetMap::iterator iter = targets.find (target_name); if (iter == targets.end ()) return; Target& target = *iter->second; if (target.node == &child) target.UnbindNode (); }
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); }
void NodeBlockLocals::addTargetDescriptionToInfoMap(TargetMap& classtargets, u32 scid) { UTI cuti = getNodeType(); u32 classNameId = m_state.getClassNameIdForUlamLocalsFilescope(cuti); //cut->getUlamTypeNameOnly(); std::string className = m_state.m_pool.getDataAsString(classNameId); u32 mangledNameId = m_state.getMangledClassNameIdForUlamLocalsFilescope(cuti); //cut->getUlamTypeMangledName(); std::string mangledName = m_state.m_pool.getDataAsString(mangledNameId); struct TargetDesc desc; desc.m_hasTest = false; desc.m_classType = UC_LOCALSFILESCOPE; desc.m_bitsize = 0; desc.m_loc = getNodeLocation(); desc.m_className = className; desc.m_structuredComment = "NONE"; classtargets.insert(std::pair<std::string, struct TargetDesc>(mangledName, desc)); } //addTargetDescriptionToInfoMap
void LaunchDaemon::_AddTarget(Target* target) { fTargets.insert(std::make_pair(target->Title(), target)); }