本文整理汇总了C++中CBaseEntity::GetOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::GetOwner方法的具体用法?C++ CBaseEntity::GetOwner怎么用?C++ CBaseEntity::GetOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::GetOwner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FrameStageNotify
void __stdcall FrameStageNotify(ClientFrameStage_t curStage)
{
originalFrameStageNotify(interfaces::client, curStage);
if (curStage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
{
if (cvar::misc_skinchanger)
{
player_info_t info;
CBaseEntity* local = interfaces::entitylist->GetClientEntity(interfaces::engine->GetLocalPlayer());
if (!local
|| local->GetLifeState() != LIFE_ALIVE
|| !interfaces::engine->GetPlayerInfo(local->GetIndex(), &info))
return;
for (int i = 1; i <= interfaces::entitylist->GetHighestEntityIndex(); i++)
{
if (i == local->GetIndex())
continue;
CBaseEntity* entity = interfaces::entitylist->GetClientEntity(i);
if (!entity)
continue;
std::string modelName = interfaces::modelinfo->GetModelName(entity->GetModel());
if (modelName.find(charenc("models/weapons")) == std::string::npos)
continue;
CBaseEntity* owner = interfaces::entitylist->GetClientEntityFromHandle(entity->GetOwner());
if (!owner
|| owner != local)
continue;
CBaseCombatWeapon* weapon = (CBaseCombatWeapon*)entity;
if (!weapon)
return;
if (!weapon->IsKnife())
{
weapon->SetPattern(info, config.skincfg[weapon->GetItemDefinitionIndex()].skin, config.skincfg[weapon->GetItemDefinitionIndex()].wear, config.skincfg[weapon->GetItemDefinitionIndex()].seed, config.skincfg[weapon->GetItemDefinitionIndex()].stattrak, config.skincfg[weapon->GetItemDefinitionIndex()].name);
}
else
{
if (cvar::misc_knifechanger)
{
if (cvar::misc_knifechanger_model == 0)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_BAYONET;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_BAYONET].skin, config.skincfg[WEAPON_KNIFE_BAYONET].wear, config.skincfg[WEAPON_KNIFE_BAYONET].seed, config.skincfg[WEAPON_KNIFE_BAYONET].stattrak, config.skincfg[WEAPON_KNIFE_BAYONET].name);
}
else if (cvar::misc_knifechanger_model == 1)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_FLIP;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_FLIP].skin, config.skincfg[WEAPON_KNIFE_FLIP].wear, config.skincfg[WEAPON_KNIFE_FLIP].seed, config.skincfg[WEAPON_KNIFE_FLIP].stattrak, config.skincfg[WEAPON_KNIFE_FLIP].name);
}
else if (cvar::misc_knifechanger_model == 2)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_GUT;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_GUT].skin, config.skincfg[WEAPON_KNIFE_GUT].wear, config.skincfg[WEAPON_KNIFE_GUT].seed, config.skincfg[WEAPON_KNIFE_GUT].stattrak, config.skincfg[WEAPON_KNIFE_GUT].name);
}
else if (cvar::misc_knifechanger_model == 3)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_KARAMBIT;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_KARAMBIT].skin, config.skincfg[WEAPON_KNIFE_KARAMBIT].wear, config.skincfg[WEAPON_KNIFE_KARAMBIT].seed, config.skincfg[WEAPON_KNIFE_KARAMBIT].stattrak, config.skincfg[WEAPON_KNIFE_KARAMBIT].name);
}
else if (cvar::misc_knifechanger_model == 4)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_M9BAYONET;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_M9BAYONET].skin, config.skincfg[WEAPON_KNIFE_M9BAYONET].wear, config.skincfg[WEAPON_KNIFE_M9BAYONET].seed, config.skincfg[WEAPON_KNIFE_M9BAYONET].stattrak, config.skincfg[WEAPON_KNIFE_M9BAYONET].name);
}
else if (cvar::misc_knifechanger_model == 5)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_HUNTSMAN;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_HUNTSMAN].skin, config.skincfg[WEAPON_KNIFE_HUNTSMAN].wear, config.skincfg[WEAPON_KNIFE_HUNTSMAN].seed, config.skincfg[WEAPON_KNIFE_HUNTSMAN].stattrak, config.skincfg[WEAPON_KNIFE_HUNTSMAN].name);
}
else if (cvar::misc_knifechanger_model == 6)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_FALCHION;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_FALCHION].skin, config.skincfg[WEAPON_KNIFE_FALCHION].wear, config.skincfg[WEAPON_KNIFE_FALCHION].seed, config.skincfg[WEAPON_KNIFE_FALCHION].stattrak, config.skincfg[WEAPON_KNIFE_FALCHION].name);
}
else if (cvar::misc_knifechanger_model == 7)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_BUTTERFLY;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_BUTTERFLY].skin, config.skincfg[WEAPON_KNIFE_BUTTERFLY].wear, config.skincfg[WEAPON_KNIFE_BUTTERFLY].seed, config.skincfg[WEAPON_KNIFE_BUTTERFLY].stattrak, config.skincfg[WEAPON_KNIFE_BUTTERFLY].name);
}
else if (cvar::misc_knifechanger_model == 8)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_DAGGER;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_DAGGER].skin, config.skincfg[WEAPON_KNIFE_DAGGER].wear, config.skincfg[WEAPON_KNIFE_DAGGER].seed, config.skincfg[WEAPON_KNIFE_DAGGER].stattrak, config.skincfg[WEAPON_KNIFE_DAGGER].name);
}
else if (cvar::misc_knifechanger_model == 9)
{
*(int*)((DWORD)weapon + offsets::weapon::m_iItemDefinitionIndex) = WEAPON_KNIFE_BOWIE;
weapon->SetPattern(info, config.skincfg[WEAPON_KNIFE_BOWIE].skin, config.skincfg[WEAPON_KNIFE_BOWIE].wear, config.skincfg[WEAPON_KNIFE_BOWIE].seed, config.skincfg[WEAPON_KNIFE_BOWIE].stattrak, config.skincfg[WEAPON_KNIFE_BOWIE].name);
}
}
}
}
}
//.........这里部分代码省略.........
示例2: OnSetOwner
void CLaser::OnSetOwner(CBaseEntity* pOwner)
{
BaseClass::OnSetOwner(pOwner);
CDigitank* pTank = dynamic_cast<CDigitank*>(pOwner);
if (!pTank)
return;
SetGlobalAngles(VectorAngles((pTank->GetLastAim() - GetGlobalOrigin()).Normalized()));
SetGlobalOrigin(pOwner->GetGlobalOrigin());
SetGlobalVelocity(Vector(0,0,0));
SetGlobalGravity(Vector(0,0,0));
m_flTimeExploded = GameServer()->GetGameTime();
Vector vecForward, vecRight;
AngleVectors(GetGlobalAngles(), &vecForward, &vecRight, NULL);
for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
{
CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
if (!pEntity)
continue;
if (!pEntity->TakesDamage())
continue;
if (pEntity->GetOwner() == pOwner->GetOwner())
continue;
float flDistance = DistanceToPlane(pEntity->GetGlobalOrigin(), GetGlobalOrigin(), vecRight);
if (flDistance > 4 + pEntity->GetBoundingRadius())
continue;
// Cull objects behind
if (vecForward.Dot(pEntity->GetGlobalOrigin() - GetGlobalOrigin()) < 0)
continue;
if (pEntity->Distance(GetGlobalOrigin()) > LaserLength())
continue;
pEntity->TakeDamage(pOwner, this, DAMAGE_LASER, m_flDamage, flDistance < pEntity->GetBoundingRadius()-2);
CDigitank* pTank = dynamic_cast<CDigitank*>(pEntity);
if (pTank)
{
float flRockIntensity = 0.5f;
Vector vecDirection = (pTank->GetGlobalOrigin() - pOwner->GetGlobalOrigin()).Normalized();
pTank->RockTheBoat(flRockIntensity, vecDirection);
}
}
CDigitanksPlayer* pCurrentTeam = DigitanksGame()->GetCurrentLocalDigitanksPlayer();
if (pCurrentTeam && pCurrentTeam->GetVisibilityAtPoint(GetGlobalOrigin()) < 0.1f)
{
if (pCurrentTeam->GetVisibilityAtPoint(GetGlobalOrigin() + AngleVector(GetGlobalAngles())*LaserLength()) < 0.1f)
{
// If the start and end points are both in the fog of war, delete it now that we've aready done the damage so it doesn't get rendered later.
if (GameNetwork()->IsHost())
Delete();
}
}
}