本文整理汇总了C++中CAI_BaseNPC::WorldSpaceCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC::WorldSpaceCenter方法的具体用法?C++ CAI_BaseNPC::WorldSpaceCenter怎么用?C++ CAI_BaseNPC::WorldSpaceCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_BaseNPC
的用法示例。
在下文中一共展示了CAI_BaseNPC::WorldSpaceCenter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateObstacleNpcs
void CAI_PlaneSolver::GenerateObstacleNpcs( const AILocalMoveGoal_t &goal, float probeDist )
{
if ( !ProbeForNpcs() )
{
CAI_BaseNPC **ppAIs = g_AI_Manager.AccessAIs();
Vector minsSelf, maxsSelf;
m_pNpc->CollisionProp()->WorldSpaceSurroundingBounds( &minsSelf, &maxsSelf );
float radiusSelf = (minsSelf.AsVector2D() - maxsSelf.AsVector2D()).Length() * 0.5;
for ( int i = 0; i < g_AI_Manager.NumAIs(); i++ )
{
CAI_BaseNPC *pAI = ppAIs[i];
if ( pAI != m_pNpc && pAI->IsAlive() && ( !goal.pPath || pAI != goal.pPath->GetTarget() ) )
{
Vector mins, maxs;
pAI->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
if ( mins.z < maxsSelf.z + 12.0 && maxs.z > minsSelf.z - 12.0 )
{
float radius = (mins.AsVector2D() - maxs.AsVector2D()).Length() * 0.5;
float distance = ( pAI->GetAbsOrigin().AsVector2D() - m_pNpc->GetAbsOrigin().AsVector2D() ).Length();
if ( distance - radius < radiusSelf + probeDist )
{
AddObstacle( pAI->WorldSpaceCenter(), radius, pAI, AIMST_AVOID_NPC );
}
}
}
}
#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
CBaseEntity *pPlayer = UTIL_GetNearestPlayer(m_pNpc->GetAbsOrigin());
#else
CBaseEntity *pPlayer = UTIL_PlayerByIndex( 1 );
#endif //SecobMod__Enable_Fixed_Multiplayer_AI
if ( pPlayer )
{
Vector mins, maxs;
pPlayer->CollisionProp()->WorldSpaceSurroundingBounds( &mins, &maxs );
if ( mins.z < maxsSelf.z + 12.0 && maxs.z > minsSelf.z - 12.0 )
{
float radius = (mins.AsVector2D() - maxs.AsVector2D()).Length();
float distance = ( pPlayer->GetAbsOrigin().AsVector2D() - m_pNpc->GetAbsOrigin().AsVector2D() ).Length();
if ( distance - radius < radiusSelf + probeDist )
{
AddObstacle( pPlayer->WorldSpaceCenter(), radius, pPlayer, AIMST_AVOID_NPC );
}
}
}
}
}
示例2: GetOwner
int CWeaponCrowbar::WeaponMeleeAttack1Condition( float flDot, float flDist )
{
// Attempt to lead the target (needed because citizens can't hit manhacks with the crowbar!)
CAI_BaseNPC *pNPC = GetOwner()->MyNPCPointer();
CBaseEntity *pEnemy = pNPC->GetEnemy();
if (!pEnemy)
return COND_NONE;
Vector vecVelocity;
vecVelocity = pEnemy->GetSmoothedVelocity( );
// Project where the enemy will be in a little while
float dt = sk_crowbar_lead_time.GetFloat();
dt += random->RandomFloat( -0.3f, 0.2f );
if ( dt < 0.0f )
dt = 0.0f;
Vector vecExtrapolatedPos;
VectorMA( pEnemy->WorldSpaceCenter(), dt, vecVelocity, vecExtrapolatedPos );
Vector vecDelta;
VectorSubtract( vecExtrapolatedPos, pNPC->WorldSpaceCenter(), vecDelta );
if ( fabs( vecDelta.z ) > 70 )
{
return COND_TOO_FAR_TO_ATTACK;
}
Vector vecForward = pNPC->BodyDirection2D( );
vecDelta.z = 0.0f;
float flExtrapolatedDist = Vector2DNormalize( vecDelta.AsVector2D() );
if ((flDist > 64) && (flExtrapolatedDist > 64))
{
return COND_TOO_FAR_TO_ATTACK;
}
float flExtrapolatedDot = DotProduct2D( vecDelta.AsVector2D(), vecForward.AsVector2D() );
if ((flDot < 0.7) && (flExtrapolatedDot < 0.7))
{
return COND_NOT_FACING_ATTACK;
}
return COND_CAN_MELEE_ATTACK1;
}
示例3: GetOwner
int CWeaponStunStick::WeaponMeleeAttack1Condition( float flDot, float flDist )
{
// Attempt to lead the target (needed because citizens can't hit manhacks with the crowbar!)
CAI_BaseNPC *pNPC = GetOwner()->MyNPCPointer();
CBaseEntity *pEnemy = pNPC->GetEnemy();
if (!pEnemy)
return COND_NONE;
Vector vecVelocity;
AngularImpulse angVelocity;
pEnemy->GetVelocity( &vecVelocity, &angVelocity );
// Project where the enemy will be in a little while, add some randomness so he doesn't always hit
float dt = sk_crowbar_lead_time.GetFloat();
dt += random->RandomFloat( -0.3f, 0.2f );
if ( dt < 0.0f )
dt = 0.0f;
Vector vecExtrapolatedPos;
VectorMA( pEnemy->WorldSpaceCenter(), dt, vecVelocity, vecExtrapolatedPos );
Vector vecDelta;
VectorSubtract( vecExtrapolatedPos, pNPC->WorldSpaceCenter(), vecDelta );
if ( fabs( vecDelta.z ) > 70 )
{
return COND_TOO_FAR_TO_ATTACK;
}
Vector vecForward = pNPC->BodyDirection2D( );
vecDelta.z = 0.0f;
float flExtrapolatedDot = DotProduct2D( vecDelta.AsVector2D(), vecForward.AsVector2D() );
if ((flDot < 0.7) && (flExtrapolatedDot < 0.7))
{
return COND_NOT_FACING_ATTACK;
}
float flExtrapolatedDist = Vector2DNormalize( vecDelta.AsVector2D() );
if( pEnemy->IsPlayer() )
{
//Vector vecDir = pEnemy->GetSmoothedVelocity();
//float flSpeed = VectorNormalize( vecDir );
// If player will be in front of me in one-half second, clock his arse.
Vector vecProjectEnemy = pEnemy->GetAbsOrigin() + (pEnemy->GetAbsVelocity() * 0.35);
Vector vecProjectMe = GetAbsOrigin();
if( (vecProjectMe - vecProjectEnemy).Length2D() <= 48.0f )
{
return COND_CAN_MELEE_ATTACK1;
}
}
/*
if( metropolice_move_and_melee.GetBool() )
{
if( pNPC->IsMoving() )
{
flTargetDist *= 1.5f;
}
}
*/
float flTargetDist = 48.0f;
if ((flDist > flTargetDist) && (flExtrapolatedDist > flTargetDist))
{
return COND_TOO_FAR_TO_ATTACK;
}
return COND_CAN_MELEE_ATTACK1;
}