本文整理汇总了C++中TIMER_Done函数的典型用法代码示例。如果您正苦于以下问题:C++ TIMER_Done函数的具体用法?C++ TIMER_Done怎么用?C++ TIMER_Done使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIMER_Done函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Remote_Ranged
/*
-------------------------
Remote_Ranged
-------------------------
*/
void Remote_Ranged( qboolean visible, qboolean advance, qboolean retreat )
{
if ( TIMER_Done( NPCS.NPC, "attackDelay" ) ) // Attack?
{
TIMER_Set( NPCS.NPC, "attackDelay", Q_irand( 500, 3000 ) );
Remote_Fire();
}
if ( NPCS.NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Remote_Hunt( visible, advance, retreat );
}
}
示例2: Mark1_RocketAttack
/*
-------------------------
Mark1_RocketAttack
-------------------------
*/
void Mark1_RocketAttack( qboolean advance )
{
if ( TIMER_Done( NPC, "attackDelay" ) ) // Attack?
{
TIMER_Set( NPC, "attackDelay", Q_irand( 1000, 3000) );
NPC_SetAnim( NPC, SETANIM_TORSO, BOTH_ATTACK2, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
Mark1_FireRocket();
}
else if (advance)
{
Mark1_Hunt();
}
}
示例3: Droid_Spin
/*
-------------------------
void Droid_Spin( void )
-------------------------
*/
void Droid_Spin( void )
{
vec3_t dir = {0,0,1};
R2D2_TurnAnims();
// Head is gone, spin and spark
if ( NPC->client->NPC_class == CLASS_R5D2 )
{
// No head?
if (gi.G2API_GetSurfaceRenderStatus( &NPC->ghoul2[NPC->playerModel], "head" ))
{
if (TIMER_Done(NPC,"smoke") && !TIMER_Done(NPC,"droidsmoketotal"))
{
TIMER_Set( NPC, "smoke", 100);
G_PlayEffect( "droid_smoke" , NPC->currentOrigin,dir);
}
if (TIMER_Done(NPC,"droidspark"))
{
TIMER_Set( NPC, "droidspark", Q_irand(100,500));
G_PlayEffect( "spark", NPC->currentOrigin,dir);
}
ucmd.forwardmove = Q_irand( -64, 64);
if (TIMER_Done(NPC,"roam"))
{
TIMER_Set( NPC, "roam", Q_irand( 250, 1000 ) );
NPCInfo->desiredYaw = Q_irand( 0, 360 ); // Go in random directions
}
}
else
{
if (TIMER_Done(NPC,"roam"))
{
NPCInfo->localState = LSTATE_NONE;
}
else
{
NPCInfo->desiredYaw = AngleNormalize360(NPCInfo->desiredYaw + 40); // Spin around
}
}
}
else
{
if (TIMER_Done(NPC,"roam"))
{
NPCInfo->localState = LSTATE_NONE;
}
else
{
NPCInfo->desiredYaw = AngleNormalize360(NPCInfo->desiredYaw + 40); // Spin around
}
}
NPC_UpdateAngles( qtrue, qtrue );
}
示例4: Boba_Tactics
////////////////////////////////////////////////////////////////////////////////////////
// Tactics
//
// This function is called right after Update()
// If returns true, Jedi and Seeker AI not used for movement
//
////////////////////////////////////////////////////////////////////////////////////////
bool Boba_Tactics()
{
if (!NPC->enemy)
{
return false;
}
// Think About Changing Tactics
//------------------------------
if (TIMER_Done(NPC, "Boba_TacticsSelect"))
{
Boba_TacticsSelect();
}
// These Tactics Require Seeker & Jedi Movement
//----------------------------------------------
if (!NPCInfo->localState ||
NPCInfo->localState==BTS_RIFLE ||
NPCInfo->localState==BTS_MISSILE)
{
return false;
}
// Flame Thrower - Locked In Place
//---------------------------------
if (NPCInfo->localState==BTS_FLAMETHROW)
{
Boba_DoFlameThrower( NPC );
}
// Sniper - Move Around, And Take Shots
//--------------------------------------
else if (NPCInfo->localState==BTS_SNIPER)
{
Boba_DoSniper( NPC );
}
// Ambush Wait
//------------
else if (NPCInfo->localState==BTS_AMBUSHWAIT)
{
Boba_DoAmbushWait( NPC );
}
NPC_FacePosition( NPC->enemy->currentOrigin, qtrue);
NPC_UpdateAngles(qtrue, qtrue);
return true; // Do Not Use Normal Jedi Or Seeker Movement
}
示例5: ATST_Ranged
/*
-------------------------
ATST_Ranged
-------------------------
*/
void ATST_Ranged( qboolean visible, qboolean advance, qboolean altAttack )
{
if ( TIMER_Done( NPC, "atkDelay" ) && visible ) // Attack?
{
TIMER_Set( NPC, "atkDelay", Q_irand( 500, 3000 ) );
ucmd.buttons |= BUTTON_ATTACK;
}
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
ATST_Hunt( visible, advance );
}
}
示例6: Seeker_Ranged
//------------------------------------
void Seeker_Ranged( qboolean visible, qboolean advance )
{
if ( NPC->client->NPC_class != CLASS_BOBAFETT )
{ //racc - boba fett doesn't run out of ammo.
if ( NPC->count > 0 || NPC->count == -1)
{
//[SeekerItemNpc]
//better than using the timer, and if the dynamic music is ever used, then we can apply it to them using the shootTime
//meh, just using TIMER_ stuff for now, in case standard npc ai messes it up
//if (NPCInfo->shotTime < level.time) // Attack?
if ( TIMER_Done( NPC, "attackDelay" )) // Attack?
{
//NPCInfo->shotTime = level.time + NPC->delay + Q_irand(0, NPC->random);
TIMER_Set( NPC, "attackDelay", Q_irand(NPC->genericValue1, NPC->genericValue2));
Seeker_Fire();
if(NPC->count != -1)
NPC->count--;
}
/*
if ( TIMER_Done( NPC, "attackDelay" )) // Attack?
{
TIMER_Set( NPC, "attackDelay", Q_irand( 250, 2500 ));
Seeker_Fire();
NPC->count--;
}
*/
//[/SeekerItemNpc]
}
else
{
//[SeekerItemNpc] what is wrong with this? re-enabling...
//hmm, somewhere I saw code that handles the final death, but I cant find it anymore...
//meh, disabling again
// out of ammo, so let it die...give it a push up so it can fall more and blow up on impact
//NPC->client->ps.gravity = 900;
//NPC->svFlags &= ~SVF_CUSTOM_GRAVITY;
//NPC->client->ps.velocity[2] += 16;
G_Damage( NPC, NPC, NPC, NULL, NULL, NPC->health/*999*/, 0, MOD_UNKNOWN );
//[/SeekerItemNpc]
}
}
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Seeker_Hunt( visible, advance );
}
}
示例7: NPC_SandCreature_Pain
void NPC_SandCreature_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, const vec3_t point, int damage, int mod,int hitLoc )
{
if ( TIMER_Done( self, "pain" ) )
{
//FIXME: effect and sound
//FIXME: shootable during this anim?
NPC_SetAnim( self, SETANIM_LEGS, Q_irand(BOTH_ATTACK1,BOTH_ATTACK2), SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_RESTART );
G_AddEvent( self, EV_PAIN, Q_irand( 0, 100 ) );
TIMER_Set( self, "pain", self->client->ps.legsAnimTimer + Q_irand( 500, 2000 ) );
float playerDist = Distance( player->currentOrigin, self->currentOrigin );
if ( playerDist < 256 )
{
CGCam_Shake( 1.0f*playerDist/128.0f, self->client->ps.legsAnimTimer );
}
}
self->enemy = self->NPC->goalEntity = NULL;
}
示例8: Mark2_BlasterAttack
void Mark2_BlasterAttack( qboolean advance ) {
if ( TIMER_Done( NPC, "attackDelay" ) ) // Attack?
{
if ( NPCInfo->localState == LSTATE_NONE ) // He's up so shoot less often.
{
TIMER_Set( NPC, "attackDelay", Q_irand( 500, 2000 ) );
}
else {
TIMER_Set( NPC, "attackDelay", Q_irand( 100, 500 ) );
}
Mark2_FireBlaster( advance );
return;
}
else if ( advance ) {
Mark2_Hunt();
}
}
示例9: Remote_Attack
/*
-------------------------
Remote_Attack
-------------------------
*/
void Remote_Attack( void )
{
float distance;
qboolean visible;
float idealDist;
qboolean advance;
qboolean retreat;
if ( TIMER_Done(NPC,"spin") )
{
TIMER_Set( NPC, "spin", Q_irand( 250, 1500 ) );
NPCInfo->desiredYaw += Q_irand( -200, 200 );
}
// Always keep a good height off the ground
Remote_MaintainHeight();
// If we don't have an enemy, just idle
if ( NPC_CheckEnemyExt(qfalse) == qfalse )
{
Remote_Idle();
return;
}
// Rate our distance to the target, and our visibilty
distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPC->enemy );
//[CoOp]
idealDist = MIN_DISTANCE_SQR+(MIN_DISTANCE_SQR*Q_flrand( 0, 1 ));
//idealDist = MIN_DISTANCE_SQR+(MIN_DISTANCE_SQR*flrand( 0, 1 ));
//[/CoOp]
advance = (qboolean)(distance > idealDist*1.25);
retreat = (qboolean)(distance < idealDist*0.75);
// If we cannot see our target, move to see it
if ( visible == qfalse )
{
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Remote_Hunt( visible, advance, retreat );
return;
}
}
Remote_Ranged( visible, advance, retreat );
}
示例10: R2D2_PartsMove
/*
-------------------------
R2D2_PartsMove
-------------------------
*/
void R2D2_PartsMove(void)
{
// Front 'eye' lense
if ( TIMER_Done(NPC,"eyeDelay") )
{
NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]);
NPC->pos1[0]+=Q_irand( -20, 20 ); // Roll
NPC->pos1[1]=Q_irand( -20, 20 );
NPC->pos1[2]=Q_irand( -20, 20 );
if (NPC->genericBone1)
{
gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 );
}
TIMER_Set( NPC, "eyeDelay", Q_irand( 100, 1000 ) );
}
}
示例11: Boba_DoSniper
void Boba_DoSniper( gentity_t *self)
{
if (TIMER_Done(NPC, "PickNewSniperPoint"))
{
TIMER_Set(NPC, "PickNewSniperPoint", Q_irand(15000, 25000));
int SniperPoint = NPC_FindCombatPoint(NPC->currentOrigin, 0, NPC->currentOrigin, CP_SNIPE|CP_CLEAR|CP_HAS_ROUTE|CP_TRYFAR|CP_HORZ_DIST_COLL, 0, -1);
if (SniperPoint!=-1)
{
NPC_SetCombatPoint(SniperPoint);
NPC_SetMoveGoal( NPC, level.combatPoints[SniperPoint].origin, 20, qtrue, SniperPoint );
}
}
if (Distance(NPC->currentOrigin, level.combatPoints[NPCInfo->combatPoint].origin)<50.0f)
{
Boba_FireDecide();
}
bool IsOnAPath = !!NPC_MoveToGoal(qtrue);
// Resolve Blocked Problems
//--------------------------
if (NPCInfo->aiFlags&NPCAI_BLOCKED &&
NPC->client->moveType!=MT_FLYSWIM &&
((level.time - NPCInfo->blockedDebounceTime)>3000)
)
{
Boba_Printf("BLOCKED: Attempting Jump");
if (IsOnAPath)
{
if (!NPC_TryJump(NPCInfo->blockedTargetPosition))
{
Boba_Printf(" Failed");
}
}
}
NPC_FaceEnemy(qtrue);
NPC_UpdateAngles( qtrue, qtrue );
}
示例12: Seeker_FollowPlayer
//------------------------------------
void Seeker_FollowPlayer( void )
{
Seeker_MaintainHeight();
float dis = DistanceHorizontalSquared( NPC->currentOrigin, g_entities[0].currentOrigin );
vec3_t pt, dir;
if ( dis < MIN_DISTANCE_SQR )
{
// generally circle the player closely till we take an enemy..this is our target point
pt[0] = g_entities[0].currentOrigin[0] + cos( level.time * 0.001f + NPC->random ) * 56;
pt[1] = g_entities[0].currentOrigin[1] + sin( level.time * 0.001f + NPC->random ) * 56;
pt[2] = g_entities[0].currentOrigin[2] + 40;
VectorSubtract( pt, NPC->currentOrigin, dir );
VectorMA( NPC->client->ps.velocity, 0.8f, dir, NPC->client->ps.velocity );
}
else
{
if ( TIMER_Done( NPC, "seekerhiss" ))
{
TIMER_Set( NPC, "seekerhiss", 1000 + random() * 1000 );
G_Sound( NPC, G_SoundIndex( "sound/chars/seeker/misc/hiss" ));
}
// Hey come back!
NPCInfo->goalEntity = &g_entities[0];
NPCInfo->goalRadius = 32;
NPC_MoveToGoal( qtrue );
NPC->owner = &g_entities[0];
}
if ( NPCInfo->enemyCheckDebounceTime < level.time )
{
// check twice a second to find a new enemy
Seeker_FindEnemy();
NPCInfo->enemyCheckDebounceTime = level.time + 500;
}
NPC_UpdateAngles( qtrue, qtrue );
}
示例13: Rancor_Patrol
void Rancor_Patrol( void ) {
NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() ) {
ucmd.buttons &= ~BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
}
else {
if ( TIMER_Done( NPC, "patrolTime" ) ) {
TIMER_Set( NPC, "patrolTime", crandom() * 5000 + 5000 );
}
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse ) {
Rancor_Idle();
return;
}
Rancor_CheckRoar( NPC );
TIMER_Set( NPC, "lookForNewEnemy", Q_irand( 5000, 15000 ) );
}
示例14: R2D2_PartsMove
void R2D2_PartsMove( void ) {
// Front 'eye' lense
if ( TIMER_Done( NPC, "eyeDelay" ) ) {
NPC->pos1.yaw = AngleNormalize360( NPC->pos1.yaw );
NPC->pos1.pitch += Q_irand( -20, 20 ); // Roll
NPC->pos1.yaw = Q_irand( -20, 20 );
NPC->pos1.roll = Q_irand( -20, 20 );
/*
if (NPC->genericBone1)
{
gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL );
}
*/
NPC_SetBoneAngles( NPC, "f_eye", &NPC->pos1 );
TIMER_Set( NPC, "eyeDelay", Q_irand( 100, 1000 ) );
}
}
示例15: MineMonster_Combat
//----------------------------------
void MineMonster_Combat( void )
{
float distance;
qboolean advance;
// If we cannot see our target or we have somewhere to go, then do that
if ( !NPC_ClearLOS4( NPC->enemy ) || UpdateGoal( ))
{
NPCInfo->combatMove = qtrue;
NPCInfo->goalEntity = NPC->enemy;
NPCInfo->goalRadius = MAX_DISTANCE; // just get us within combat range
NPC_MoveToGoal( qtrue );
return;
}
// Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb
NPC_FaceEnemy( qtrue );
distance = DistanceHorizontalSquared( &NPC->r.currentOrigin, &NPC->enemy->r.currentOrigin );
advance = (qboolean)( distance > MIN_DISTANCE_SQR ? qtrue : qfalse );
if (( advance || NPCInfo->localState == LSTATE_WAITING ) && TIMER_Done( NPC, "attacking" )) // waiting monsters can't attack
{
if ( TIMER_Done2( NPC, "takingPain", qtrue ))
{
NPCInfo->localState = LSTATE_CLEAR;
}
else
{
MineMonster_Move( qtrue );
}
}
else
{
MineMonster_Attack();
}
}