本文整理汇总了C++中CBaseEntity::GetServerVehicle方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::GetServerVehicle方法的具体用法?C++ CBaseEntity::GetServerVehicle怎么用?C++ CBaseEntity::GetServerVehicle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::GetServerVehicle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldHitEntity
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pHandleEntity -
// contentsMask -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CASW_Trace_Filter_Door_Crush::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
{
if ( !StandardFilterRules( pHandleEntity, contentsMask ) )
return false;
if ( !PassServerEntityFilter( pHandleEntity, m_pPassEnt ) )
return false;
// Don't test if the game code tells us we should ignore this collision...
CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity );
if ( pEntity )
{
//Msg("%f CASW_Trace_Filter_Door_Crush::ShouldHitEntity %s\n", gpGlobals->curtime, pEntity->GetClassname());
if ( !pEntity->ShouldCollide( m_collisionGroup, contentsMask ) )
return false;
if ( !g_pGameRules->ShouldCollide( m_collisionGroup, pEntity->GetCollisionGroup() ) )
return false;
if ( pEntity->Classify() == CLASS_ASW_DOOR )
return false;
if ( pEntity->m_takedamage == DAMAGE_NO )
return false;
// Translate the vehicle into its driver for damage
if ( pEntity->GetServerVehicle() != NULL )
{
CBaseEntity *pDriver = pEntity->GetServerVehicle()->GetPassenger();
if ( pDriver != NULL )
{
pEntity = pDriver;
}
}
Vector attackDir = pEntity->WorldSpaceCenter() - m_dmgInfo->GetAttacker()->WorldSpaceCenter();
VectorNormalize( attackDir );
pEntity->TakeDamage( *m_dmgInfo );
//CalculateMeleeDamageForce( &info, attackDir, info.GetAttacker()->WorldSpaceCenter(), m_flForceScale );
return true;
}
return false;
}
示例2: GetBaseEntity
IPhysicsVehicleController *GetLuaVehicle(ILuaInterface *gLua)
{
gLua->CheckType(1, GLua::TYPE_ENTITY);
CBaseHandle *handle = (CBaseHandle*)gLua->GetUserData(1);
CBaseEntity *entity = GetBaseEntity(handle->GetEntryIndex());
if(!entity)
{
gLua->Error("[gm_pimpmyride] NO ENTITY!");
return NULL;
}
IServerVehicle *vehicle = entity->GetServerVehicle();
if(!vehicle)
{
gLua->Error("[gm_pimpmyride] NO VEHICLE!");
return NULL;
}
IPhysicsVehicleController *controller = vehicle->GetVehicleController();
if(!controller)
{
gLua->Error("[gm_pimpmyride] NO PHYSICS CONTROLLER!");
return NULL;
}
return controller;
}
示例3: WeaponLOSCondition
//-----------------------------------------------------------------------------
// Purpose: Check the weapon LOS for an owner at an arbitrary position
// If bSetConditions is true, LOS related conditions will also be set
//-----------------------------------------------------------------------------
bool CBaseCombatWeapon::WeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions )
{
// --------------------
// Check for occlusion
// --------------------
CAI_BaseNPC* npcOwner = m_hOwner.Get()->MyNPCPointer();
// Find its relative shoot position
Vector vecRelativeShootPosition;
VectorSubtract( npcOwner->Weapon_ShootPosition(), npcOwner->GetAbsOrigin(), vecRelativeShootPosition );
Vector barrelPos = ownerPos + vecRelativeShootPosition;
// Use the custom LOS trace filter
CWeaponLOSFilter traceFilter( m_hOwner.Get(), npcOwner->GetEnemy(), COLLISION_GROUP_BREAKABLE_GLASS );
trace_t tr;
UTIL_TraceLine( barrelPos, targetPos, MASK_SHOT, &traceFilter, &tr );
// See if we completed the trace without interruption
if ( tr.fraction == 1.0 )
{
if ( ai_debug_shoot_positions.GetBool() )
{
NDebugOverlay::Line( barrelPos, targetPos, 0, 255, 0, false, 1.0 );
}
return true;
}
CBaseEntity *pHitEnt = tr.m_pEnt;
CBasePlayer *pEnemyPlayer = ToBasePlayer( npcOwner->GetEnemy() );
// is player in a vehicle? if so, verify vehicle is target and return if so (so npc shoots at vehicle)
if ( pEnemyPlayer && pEnemyPlayer->IsInAVehicle() )
{
// Ok, player in vehicle, check if vehicle is target we're looking at, fire if it is
// Also, check to see if the owner of the entity is the vehicle, in which case it's valid too.
// This catches vehicles that use bone followers.
CBaseEntity *pVehicle = pEnemyPlayer->GetVehicle()->GetVehicleEnt();
if ( pHitEnt == pVehicle || pHitEnt->GetOwnerEntity() == pVehicle )
return true;
}
// Hitting our enemy is a success case
if ( pHitEnt == npcOwner->GetEnemy() )
{
if ( ai_debug_shoot_positions.GetBool() )
{
NDebugOverlay::Line( barrelPos, targetPos, 0, 255, 0, false, 1.0 );
}
return true;
}
// If a vehicle is blocking the view, grab its driver and use that as the combat character
CBaseCombatCharacter *pBCC;
IServerVehicle *pVehicle = pHitEnt->GetServerVehicle();
if ( pVehicle )
{
pBCC = pVehicle->GetPassenger( );
}
else
{
pBCC = ToBaseCombatCharacter( pHitEnt );
}
if ( pBCC )
{
if ( npcOwner->IRelationType( pBCC ) == D_HT )
return true;
if ( bSetConditions )
{
npcOwner->SetCondition( COND_WEAPON_BLOCKED_BY_FRIEND );
}
}
else if ( bSetConditions )
{
npcOwner->SetCondition( COND_WEAPON_SIGHT_OCCLUDED );
npcOwner->SetEnemyOccluder( pHitEnt );
if( ai_debug_shoot_positions.GetBool() )
{
NDebugOverlay::Line( tr.startpos, tr.endpos, 255, 0, 0, false, 1.0 );
}
}
return false;
}
示例4: DoRotorPhysicsPush
//.........这里部分代码省略.........
float flLightestMass = 9999;
while ((pEntity = gEntList.FindEntityInSphere(pEntity, vecPhysicsOrigin, BASECHOPPER_WASH_RADIUS )) != NULL)
{
IRotorWashShooter *pShooter = GetRotorWashShooter( pEntity );
if ( pEntity->IsEFlagSet( EFL_NO_ROTORWASH_PUSH ))
continue;
if ( pShooter || pEntity->GetMoveType() == MOVETYPE_VPHYSICS || (pEntity->VPhysicsGetObject() && !pEntity->IsPlayer()) )
{
// Make sure it's not already in our wash
bool bAlreadyPushing = false;
for ( int i = 0; i < iCount; i++ )
{
if ( m_hEntitiesPushedByWash[i].hEntity == pEntity )
{
bAlreadyPushing = true;
break;
}
}
if ( bAlreadyPushing )
continue;
float flMass = FLT_MAX;
if ( pShooter )
{
flMass = 1.0f;
}
else
{
// Don't try to push anything too big
IPhysicsObject *pPhysObject = pEntity->VPhysicsGetObject();
if ( pPhysObject )
{
flMass = pPhysObject->GetMass();
if ( flMass > BASECHOPPER_WASH_MAX_MASS )
continue;
}
}
// Ignore anything bigger than the one we've already found
if ( flMass > flLightestMass )
continue;
Vector vecSpot = pEntity->BodyTarget( vecPhysicsOrigin );
// Don't push things too far below our starting point (helps reduce through-roof cases w/o doing a trace)
if ( fabs( vecSpot.z - vecPhysicsOrigin.z ) > 96 )
continue;
Vector vecToSpot = ( vecSpot - vecPhysicsOrigin );
vecToSpot.z = 0;
float flDist = VectorNormalize( vecToSpot );
if ( flDist > BASECHOPPER_WASH_RADIUS )
continue;
// Try to cast to the helicopter; if we can't, then we can't be hit.
if ( pEntity->GetServerVehicle() )
{
UTIL_TraceLine( vecSpot, vecPhysicsOrigin, MASK_SOLID_BRUSHONLY, pEntity, COLLISION_GROUP_NONE, &tr );
if ( tr.fraction != 1.0f )
continue;
}
flLightestMass = flMass;
pLightestEntity = pEntity;
washentity_t Wash;
Wash.hEntity = pLightestEntity;
Wash.flWashStartTime = gpGlobals->curtime;
m_hEntitiesPushedByWash.AddToTail( Wash );
// Can we fit more after adding this one? No? Then we are done.
iCount = m_hEntitiesPushedByWash.Count();
if ( iCount >= BASECHOPPER_WASH_MAX_OBJECTS )
break;
}
}
// Handle sound.
// If we just started pushing objects, ramp the blast sound up.
if ( !bWasPushingObjects && m_hEntitiesPushedByWash.Count() )
{
if ( m_pRotorBlast )
{
CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
controller.SoundChangeVolume( m_pRotorBlast, 1.0, 1.0 );
}
}
else if ( bWasPushingObjects && m_hEntitiesPushedByWash.Count() == 0 )
{
if ( m_pRotorBlast )
{
// We just stopped pushing objects, so fade the blast sound out.
CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
controller.SoundChangeVolume( m_pRotorBlast, 0, 1.0 );
}
}
}