本文整理汇总了C++中ObjectGuid::IsUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGuid::IsUnit方法的具体用法?C++ ObjectGuid::IsUnit怎么用?C++ ObjectGuid::IsUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGuid
的用法示例。
在下文中一共展示了ObjectGuid::IsUnit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleAttackSwingOpcode
void WorldSession::HandleAttackSwingOpcode(WorldPacket & recv_data)
{
ObjectGuid guid;
recv_data >> guid;
DEBUG_LOG("WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.GetString().c_str());
Unit *pEnemy = ObjectAccessor::GetUnit(*_player, guid.GetRawValue());
if (!pEnemy)
{
if (!guid.IsUnit())
sLog.outError("WORLD: %s isn't player, pet or creature", guid.GetString().c_str());
else
sLog.outError("WORLD: Enemy %s not found", guid.GetString().c_str());
// stop attack state at client
SendAttackStop(NULL);
return;
}
if (!_player->canAttack(pEnemy))
{
sLog.outError("WORLD: Enemy %s is friendly",guid.GetString().c_str());
// stop attack state at client
SendAttackStop(pEnemy);
return;
}
_player->Attack(pEnemy,true);
}
示例2: HandleAttackSwingOpcode
void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Received opcode CMSG_ATTACKSWING %s", guid.GetString().c_str());
if (!guid.IsUnit())
{
sLog.outError("WORLD: %s isn't unit", guid.GetString().c_str());
return;
}
Unit* pEnemy = _player->GetMap()->GetUnit(guid);
if (!pEnemy)
{
sLog.outError("WORLD: Enemy %s not found", guid.GetString().c_str());
// stop attack state at client
SendAttackStop(NULL);
return;
}
if (_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
{
sLog.outError("WORLD: Enemy %s is friendly", guid.GetString().c_str());
// stop attack state at client
SendAttackStop(pEnemy);
return;
}
if (!pEnemy->isAlive())
{
// client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options
// stop attack state at client
SendAttackStop(pEnemy);
return;
}
_player->Attack(pEnemy, true);
}
示例3: HandleAttackSwingOpcode
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
{
ObjectGuid guid;
recv_data >> guid;
DEBUG_LOG("WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.GetString().c_str());
Unit *pEnemy = ObjectAccessor::GetUnit(*_player, guid);
if(!pEnemy)
{
if(!guid.IsUnit())
sLog.outError("WORLD: %u isn't player, pet or creature", guid.GetString().c_str());
else
sLog.outError( "WORLD: Enemy %s not found", guid.GetString().c_str());
// stop attack state at client
SendAttackStop(NULL);
return;
}
if(_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
{
sLog.outError( "WORLD: Enemy %s is friendly",guid.GetString().c_str());
// stop attack state at client
SendAttackStop(pEnemy);
return;
}
if(!pEnemy->isAlive())
{
// client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options
// stop attack state at client
SendAttackStop(pEnemy);
return;
}
_player->Attack(pEnemy,true);
}
示例4: HandleEjectPassenger
void WorldSession::HandleEjectPassenger(WorldPacket& data)
{
Vehicle* vehicle = _player->GetVehicleKit();
if (!vehicle)
{
data.rfinish(); // prevent warnings spam
TC_LOG_ERROR("network", "HandleEjectPassenger: %s is not in a vehicle!", GetPlayer()->GetGUID().ToString().c_str());
return;
}
ObjectGuid guid;
data >> guid;
if (guid.IsUnit())
{
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
if (!unit) // creatures can be ejected too from player mounts
{
TC_LOG_ERROR("network", "%s tried to eject %s from vehicle, but the latter was not found in world!", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str());
return;
}
if (!unit->IsOnVehicle(vehicle->GetBase()))
{
TC_LOG_ERROR("network", "%s tried to eject %s, but they are not in the same vehicle", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str());
return;
}
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(unit);
ASSERT(seat);
if (seat->IsEjectable())
unit->ExitVehicle();
else
TC_LOG_ERROR("network", "Player %u attempted to eject %s from non-ejectable seat.", GetPlayer()->GetGUIDLow(), guid.ToString().c_str());
}
else
TC_LOG_ERROR("network", "HandleEjectPassenger: %s tried to eject invalid %s ", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str());
}