本文整理汇总了C++中WorldObject::IsWithinDistInMap方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldObject::IsWithinDistInMap方法的具体用法?C++ WorldObject::IsWithinDistInMap怎么用?C++ WorldObject::IsWithinDistInMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldObject
的用法示例。
在下文中一共展示了WorldObject::IsWithinDistInMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScriptsProcess
//.........这里部分代码省略.........
{
if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
{
TC_LOG_ERROR("scripts", "%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, %s), skipping.",
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUID().ToString().c_str());
break;
}
worldObject = dynamic_cast<WorldObject*>(source);
}
else
{
player = source->ToPlayer();
if (player)
{
if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
{
TC_LOG_ERROR("scripts", "%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, %s), skipping.",
step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUID().ToString().c_str());
break;
}
worldObject = dynamic_cast<WorldObject*>(target);
}
else
{
TC_LOG_ERROR("scripts", "%s neither source nor target is player (Entry: %u, GUID: %s; target: Entry: %u, GUID: %s), skipping.",
step.script->GetDebugInfo().c_str(), source->GetEntry(), source->GetGUID().ToString().c_str(),
target->GetEntry(), target->GetGUID().ToString().c_str());
break;
}
}
// quest id and flags checked at script loading
if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->IsAlive()) &&
(step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
player->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID);
else
player->FailQuest(step.script->QuestExplored.QuestID);
break;
}
case SCRIPT_COMMAND_KILL_CREDIT:
// Source or target must be Player.
if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
{
if (step.script->KillCredit.Flags & SF_KILLCREDIT_REWARD_GROUP)
player->RewardPlayerAndGroupAtEvent(step.script->KillCredit.CreatureEntry, player);
else
player->KilledMonsterCredit(step.script->KillCredit.CreatureEntry);
}
break;
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
if (!step.script->RespawnGameobject.GOGuid)
{
TC_LOG_ERROR("scripts", "%s gameobject guid (datalong) is not specified.", step.script->GetDebugInfo().c_str());
break;
}
// Source or target must be WorldObject.
if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
{
GameObject* pGO = _FindGameObject(pSummoner, step.script->RespawnGameobject.GOGuid);
if (!pGO)
{
TC_LOG_ERROR("scripts", "%s gameobject was not found (guid: %u).", step.script->GetDebugInfo().c_str(), step.script->RespawnGameobject.GOGuid);
示例2: ScriptsProcess
//.........这里部分代码省略.........
{
if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
{
sLog->outError(LOG_FILTER_TSCR, "%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.",
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
break;
}
worldObject = dynamic_cast<WorldObject*>(source);
}
else
{
player = source->ToPlayer();
if (player)
{
if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
{
sLog->outError(LOG_FILTER_TSCR, "%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.",
step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
break;
}
worldObject = dynamic_cast<WorldObject*>(target);
}
else
{
sLog->outError(LOG_FILTER_TSCR, "%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.",
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow(),
target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
break;
}
}
// quest id and flags checked at script loading
if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) &&
(step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
player->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID);
else
player->FailQuest(step.script->QuestExplored.QuestID);
break;
}
case SCRIPT_COMMAND_KILL_CREDIT:
// Source or target must be Player.
if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
{
if (step.script->KillCredit.Flags & SF_KILLCREDIT_REWARD_GROUP)
player->RewardPlayerAndGroupAtEvent(step.script->KillCredit.CreatureEntry, player);
else
player->KilledMonsterCredit(step.script->KillCredit.CreatureEntry, 0);
}
break;
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
if (!step.script->RespawnGameobject.GOGuid)
{
sLog->outError(LOG_FILTER_TSCR, "%s gameobject guid (datalong) is not specified.", step.script->GetDebugInfo().c_str());
break;
}
// Source or target must be WorldObject.
if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
{
GameObject* pGO = _FindGameObject(pSummoner, step.script->RespawnGameobject.GOGuid);
if (!pGO)
{
sLog->outError(LOG_FILTER_TSCR, "%s gameobject was not found (guid: %u).", step.script->GetDebugInfo().c_str(), step.script->RespawnGameobject.GOGuid);