本文整理汇总了C++中CAI_BaseNPC::GetLocalOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC::GetLocalOrigin方法的具体用法?C++ CAI_BaseNPC::GetLocalOrigin怎么用?C++ CAI_BaseNPC::GetLocalOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_BaseNPC
的用法示例。
在下文中一共展示了CAI_BaseNPC::GetLocalOrigin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Operator_HandleAnimEvent
//-----------------------------------------------------------------------------
// Purpose: Gets event from anim stream and throws the object
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeaponBrickbat::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator )
{
switch( pEvent->event )
{
case EVENT_WEAPON_THROW:
{
CAI_BaseNPC *pNPC = GetOwner()->MyNPCPointer();
if (!pNPC)
{
return;
}
Vector vec_target = pNPC->GetEnemyLKP();
// -----------------------------------------------------
// Get position of throw
// -----------------------------------------------------
// If owner has a hand, set position to the hand bone position
Vector launchPos;
int iBIndex = pNPC->LookupBone("Bip01 R Hand");
if (iBIndex != -1) {
Vector origin;
QAngle angles;
pNPC->GetBonePosition( iBIndex, launchPos, angles);
}
// Otherwise just set to in front of the owner
else {
Vector vFacingDir = pNPC->BodyDirection2D( );
vFacingDir = vFacingDir * 60.0;
launchPos = pNPC->GetLocalOrigin()+vFacingDir;
}
ThrowBrickbat( launchPos, m_vecTossVelocity, sk_npc_dmg_brickbat.GetFloat());
// Drop the weapon and remove as no more ammo
pNPC->Weapon_Drop( this );
UTIL_Remove( this );
}
break;
default:
BaseClass::Operator_HandleAnimEvent( pEvent, pOperator );
break;
}
}
示例2: GetOwner
//-----------------------------------------------------------------------------
// Purpose:
// Input : flDot -
// flDist -
// Output : int
//-----------------------------------------------------------------------------
int CWeaponSMG1::WeaponRangeAttack2Condition( float flDot, float flDist )
{
CAI_BaseNPC *npcOwner = GetOwner()->MyNPCPointer();
return COND_NONE;
/*
// --------------------------------------------------------
// Assume things haven't changed too much since last time
// --------------------------------------------------------
if (gpGlobals->curtime < m_flNextGrenadeCheck )
return m_lastGrenadeCondition;
*/
// -----------------------
// If moving, don't check.
// -----------------------
if ( npcOwner->IsMoving())
return COND_NONE;
CBaseEntity *pEnemy = npcOwner->GetEnemy();
if (!pEnemy)
return COND_NONE;
Vector vecEnemyLKP = npcOwner->GetEnemyLKP();
if ( !( pEnemy->GetFlags() & FL_ONGROUND ) && pEnemy->GetWaterLevel() == 0 && vecEnemyLKP.z > (GetAbsOrigin().z + WorldAlignMaxs().z) )
{
//!!!BUGBUG - we should make this check movetype and make sure it isn't FLY? Players who jump a lot are unlikely to
// be grenaded.
// don't throw grenades at anything that isn't on the ground!
return COND_NONE;
}
// --------------------------------------
// Get target vector
// --------------------------------------
Vector vecTarget;
if (random->RandomInt(0,1))
{
// magically know where they are
vecTarget = pEnemy->WorldSpaceCenter();
}
else
{
// toss it to where you last saw them
vecTarget = vecEnemyLKP;
}
// vecTarget = m_vecEnemyLKP + (pEnemy->BodyTarget( GetLocalOrigin() ) - pEnemy->GetLocalOrigin());
// estimate position
// vecTarget = vecTarget + pEnemy->m_vecVelocity * 2;
if ( ( vecTarget - npcOwner->GetLocalOrigin() ).Length2D() <= COMBINE_MIN_GRENADE_CLEAR_DIST )
{
// crap, I don't want to blow myself up
m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second.
return (COND_NONE);
}
// ---------------------------------------------------------------------
// Are any friendlies near the intended grenade impact area?
// ---------------------------------------------------------------------
CBaseEntity *pTarget = NULL;
while ( ( pTarget = gEntList.FindEntityInSphere( pTarget, vecTarget, COMBINE_MIN_GRENADE_CLEAR_DIST ) ) != NULL )
{
//Check to see if the default relationship is hatred, and if so intensify that
if ( npcOwner->IRelationType( pTarget ) == D_LI )
{
// crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while.
m_flNextGrenadeCheck = gpGlobals->curtime + 1; // one full second.
return (COND_WEAPON_BLOCKED_BY_FRIEND);
}
}
// ---------------------------------------------------------------------
// Check that throw is legal and clear
// ---------------------------------------------------------------------
// FIXME: speed is based on difficulty...
Vector vecToss = VecCheckThrow( this, npcOwner->GetLocalOrigin() + Vector(0,0,60), vecTarget, 600.0, 0.5 );
if ( vecToss != vec3_origin )
{
m_vecTossVelocity = vecToss;
// don't check again for a while.
// JAY: HL1 keeps checking - test?
//m_flNextGrenadeCheck = gpGlobals->curtime;
m_flNextGrenadeCheck = gpGlobals->curtime + 0.3; // 1/3 second.
return COND_CAN_RANGE_ATTACK2;
}
else
{
//.........这里部分代码省略.........
示例3: FrameUpdatePostEntityThink
//-----------------------------------------------------------------------------
// Purpose: Called once per frame after all entities have had a chance to think
//-----------------------------------------------------------------------------
void CLagCompensationManager::FrameUpdatePostEntityThink()
{
if ( m_bNeedsAIUpdate )
UpdateAIIndexes(); // only bother if we haven't had one yet
else // setting this true here ensures that the update happens at the start of the next frame
m_bNeedsAIUpdate = true;
if ( (gpGlobals->maxClients <= 1) || !sv_unlag.GetBool() )
{
ClearHistory();
return;
}
m_flTeleportDistanceSqr = sv_lagcompensation_teleport_dist.GetFloat() * sv_lagcompensation_teleport_dist.GetFloat();
VPROF_BUDGET( "FrameUpdatePostEntityThink", "CLagCompensationManager" );
// remove all records before that time:
int flDeadtime = gpGlobals->curtime - sv_maxunlag.GetFloat();
// Iterate all active players
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );
CUtlFixedLinkedList< LagRecord > *track = &m_PlayerTrack[i-1];
if ( !pPlayer )
{
if ( track->Count() > 0 )
{
track->RemoveAll();
}
continue;
}
Assert( track->Count() < 1000 ); // insanity check
// remove tail records that are too old
int tailIndex = track->Tail();
while ( track->IsValidIndex( tailIndex ) )
{
LagRecord &tail = track->Element( tailIndex );
// if tail is within limits, stop
if ( tail.m_flSimulationTime >= flDeadtime )
break;
// remove tail, get new tail
track->Remove( tailIndex );
tailIndex = track->Tail();
}
// check if head has same simulation time
if ( track->Count() > 0 )
{
LagRecord &head = track->Element( track->Head() );
// check if player changed simulation time since last time updated
if ( head.m_flSimulationTime >= pPlayer->GetSimulationTime() )
continue; // don't add new entry for same or older time
}
// add new record to player track
LagRecord &record = track->Element( track->AddToHead() );
record.m_fFlags = 0;
if ( pPlayer->IsAlive() )
{
record.m_fFlags |= LC_ALIVE;
}
record.m_flSimulationTime = pPlayer->GetSimulationTime();
record.m_vecAngles = pPlayer->GetLocalAngles();
record.m_vecOrigin = pPlayer->GetLocalOrigin();
record.m_vecMinsPreScaled = pPlayer->CollisionProp()->OBBMinsPreScaled();
record.m_vecMaxsPreScaled = pPlayer->CollisionProp()->OBBMaxsPreScaled();
int layerCount = pPlayer->GetNumAnimOverlays();
for( int layerIndex = 0; layerIndex < layerCount; ++layerIndex )
{
CAnimationLayer *currentLayer = pPlayer->GetAnimOverlay(layerIndex);
if( currentLayer )
{
record.m_layerRecords[layerIndex].m_cycle = currentLayer->m_flCycle;
record.m_layerRecords[layerIndex].m_order = currentLayer->m_nOrder;
record.m_layerRecords[layerIndex].m_sequence = currentLayer->m_nSequence;
record.m_layerRecords[layerIndex].m_weight = currentLayer->m_flWeight;
}
}
record.m_masterSequence = pPlayer->GetSequence();
record.m_masterCycle = pPlayer->GetCycle();
}
// Iterate all active NPCs
CAI_BaseNPC **ppAIs = g_AI_Manager.AccessAIs();
//.........这里部分代码省略.........
示例4: FinishLagCompensation
void CLagCompensationManager::FinishLagCompensation( CBasePlayer *player )
{
VPROF_BUDGET_FLAGS( "FinishLagCompensation", VPROF_BUDGETGROUP_OTHER_NETWORKING, BUDGETFLAG_CLIENT|BUDGETFLAG_SERVER );
m_pCurrentPlayer = NULL;
if ( !m_bNeedToRestore )
return; // no player was changed at all
// Iterate all active players
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
int pl_index = i - 1;
if ( !m_RestorePlayer.Get( pl_index ) )
{
// player wasn't changed by lag compensation
continue;
}
CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );
if ( !pPlayer )
{
continue;
}
LagRecord *restore = &m_RestoreData[ pl_index ];
LagRecord *change = &m_ChangeData[ pl_index ];
bool restoreSimulationTime = false;
if ( restore->m_fFlags & LC_SIZE_CHANGED )
{
restoreSimulationTime = true;
// see if simulation made any changes, if no, then do the restore, otherwise,
// leave new values in
if ( pPlayer->CollisionProp()->OBBMinsPreScaled() == change->m_vecMinsPreScaled &&
pPlayer->CollisionProp()->OBBMaxsPreScaled() == change->m_vecMaxsPreScaled )
{
// Restore it
pPlayer->SetSize( restore->m_vecMinsPreScaled, restore->m_vecMaxsPreScaled );
}
else
{
Warning( "Should we really not restore the size?\n" );
}
}
if ( restore->m_fFlags & LC_ANGLES_CHANGED )
{
restoreSimulationTime = true;
if ( pPlayer->GetLocalAngles() == change->m_vecAngles )
{
pPlayer->SetLocalAngles( restore->m_vecAngles );
}
}
if ( restore->m_fFlags & LC_ORIGIN_CHANGED )
{
restoreSimulationTime = true;
// Okay, let's see if we can do something reasonable with the change
Vector delta = pPlayer->GetLocalOrigin() - change->m_vecOrigin;
// If it moved really far, just leave the player in the new spot!!!
if ( delta.Length2DSqr() < m_flTeleportDistanceSqr )
{
RestorePlayerTo( pPlayer, restore->m_vecOrigin + delta );
}
}
if( restore->m_fFlags & LC_ANIMATION_CHANGED )
{
restoreSimulationTime = true;
pPlayer->SetSequence(restore->m_masterSequence);
pPlayer->SetCycle(restore->m_masterCycle);
int layerCount = pPlayer->GetNumAnimOverlays();
for( int layerIndex = 0; layerIndex < layerCount; ++layerIndex )
{
CAnimationLayer *currentLayer = pPlayer->GetAnimOverlay(layerIndex);
if( currentLayer )
{
currentLayer->m_flCycle = restore->m_layerRecords[layerIndex].m_cycle;
currentLayer->m_nOrder = restore->m_layerRecords[layerIndex].m_order;
currentLayer->m_nSequence = restore->m_layerRecords[layerIndex].m_sequence;
currentLayer->m_flWeight = restore->m_layerRecords[layerIndex].m_weight;
}
}
}
if ( restoreSimulationTime )
{
pPlayer->SetSimulationTime( restore->m_flSimulationTime );
}
}
//.........这里部分代码省略.........