本文整理汇总了C++中IWeapon::GetHostId方法的典型用法代码示例。如果您正苦于以下问题:C++ IWeapon::GetHostId方法的具体用法?C++ IWeapon::GetHostId怎么用?C++ IWeapon::GetHostId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWeapon
的用法示例。
在下文中一共展示了IWeapon::GetHostId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsMountedWeaponUsableWithTarget
//.........这里部分代码省略.........
}
IEntity* pItemEntity = pItem->GetEntity();
if(!pItemEntity)
return pH->EndFunction();
if(!pItem->GetOwnerId())
{
// weapon is not used, check if it is on a vehicle
IEntity* pParentEntity = pItemEntity->GetParent();
if(pParentEntity)
{
IAIObject* pParentAI = pParentEntity->GetAI();
if(pParentAI && pParentAI->GetAIType()==AIOBJECT_VEHICLE)
{
// (MATT) Feature was cut and code was tricky, hence ignore weapons in vehicles {2008/02/15:11:08:51}
return pH->EndFunction();
}
}
}
else if( pItem->GetOwnerId()!= pEntity->GetId()) // item is used by someone else?
return pH->EndFunction(false);
// check target
if(bSkipTargetCheck)
return pH->EndFunction(true);
IAIObject* pTarget = pAIActor->GetAttentionTarget();
if(targetPos.IsZero())
{
if(!pTarget)
return pH->EndFunction();
targetPos = pTarget->GetPos();
}
Vec3 targetDir(targetPos - pItemEntity->GetWorldPos());
Vec3 targetDirXY(targetDir.x, targetDir.y, 0);
float length2D = targetDirXY.GetLength();
if(length2D < minDist || length2D<=0)
return pH->EndFunction();
targetDirXY /= length2D;//normalize
IWeapon* pWeapon = pItem->GetIWeapon();
bool vehicleGun = pWeapon && pWeapon->GetHostId();
if (!vehicleGun)
{
Vec3 mountedAngleLimits(pItem->GetMountedAngleLimits());
float yawRange = DEG2RAD(mountedAngleLimits.z);
if(yawRange > 0 && yawRange < gf_PI)
{
float deltaYaw = pItem->GetMountedDir().Dot(targetDirXY);
if(deltaYaw < cosf(yawRange))
return pH->EndFunction(false);
}
float minPitch = DEG2RAD(mountedAngleLimits.x);
float maxPitch = DEG2RAD(mountedAngleLimits.y);
//maxPitch = (maxPitch - minPitch)/2;
//minPitch = -maxPitch;
float pitch = atanf(targetDir.z / length2D);
if ( pitch < minPitch || pitch > maxPitch )
return pH->EndFunction(false);
}
if(pTarget)
{
IEntity* pTargetEntity = pTarget->GetEntity();
if(pTargetEntity)
{
// check target distance and where he's going
IPhysicalEntity *phys = pTargetEntity->GetPhysics();
if(phys)
{
pe_status_dynamics dyn;
phys->GetStatus(&dyn);
Vec3 velocity ( dyn.v);
velocity.z = 0;
float speed = velocity.GetLength2D();
if(speed>0)
{
//velocity /= speed;
if(length2D< minDist * 0.75f && velocity.Dot(targetDirXY)<=0)
return pH->EndFunction(false);
}
}
}
}
return pH->EndFunction(true);
}