本文整理汇总了C++中TIMER_Set函数的典型用法代码示例。如果您正苦于以下问题:C++ TIMER_Set函数的具体用法?C++ TIMER_Set怎么用?C++ TIMER_Set使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIMER_Set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Touch_Item
void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace) {
int respawn = 0;
if (!other->client)
return;
if (other->health < 1)
return; // dead people can't pickup
if ( other->client->ps.pm_time > 0 )
{ //cant pick up when out of control
return;
}
// NPCs can pick it up
if ((ent->spawnflags & ITMSF_ALLOWNPC) && (!other->s.number))
{
return;
}
// Players cannot pick it up
if ( (ent->spawnflags & ITMSF_NOPLAYER) && (other->s.number) )
{
return;
}
if ( ent->noDamageTeam != TEAM_FREE && other->client->playerTeam != ent->noDamageTeam )
{ //only one team can pick it up
return;
}
if ( !G_CanPickUpWeapons( other ) )
{ //FIXME: some flag would be better
//droids can't pick up items/weapons!
return;
}
//FIXME: need to make them run toward a dropped weapon when fleeing without one?
//FIXME: need to make them come out of flee mode when pick up their old weapon?
if ( CheckItemCanBePickedUpByNPC( ent, other ) )
{
if ( other->NPC && other->NPC->goalEntity && other->NPC->goalEntity == ent )
{ //they were running to pick me up, they did, so clear goal
other->NPC->goalEntity = NULL;
other->NPC->squadState = SQUAD_STAND_AND_SHOOT;
NPCInfo->tempBehavior = BS_DEFAULT;
TIMER_Set(other, "flee", -1);
}
else
{
return;
}
}
else if ( !(ent->spawnflags & ITMSF_ALLOWNPC) )
{ // NPCs cannot pick it up
if ( other->s.number != 0 )
{ // Not the player?
return;
}
}
// the same pickup rules are used for client side and server side
if ( !BG_CanItemBeGrabbed( &ent->s, &other->client->ps ) ) {
return;
}
if ( other->client )
{
if ( (other->client->ps.eFlags&EF_FORCE_GRIPPED) || (other->client->ps.eFlags&EF_FORCE_DRAINED) )
{ //can't pick up anything while being gripped
return;
}
if ( PM_InKnockDown( &other->client->ps ) && !PM_InGetUp( &other->client->ps ) )
{ //can't pick up while in a knockdown
return;
}
}
if (!ent->item) { //not an item!
gi.Printf( "Touch_Item: %s is not an item!\n", ent->classname);
return;
}
if ( ent->item->giType == IT_WEAPON
&& ent->item->giTag == WP_SABER )
{ //a saber
if ( ent->delay > level.time )
{ //just picked it up, don't pick up again right away
return;
}
}
if ( other->s.number < MAX_CLIENTS
&& (ent->spawnflags&ITMSF_USEPICKUP) )
{ //only if player is holing use button
if ( !(other->client->usercmd.buttons&BUTTON_USE) )
{ //not holding use?
return;
}
}
qboolean bHadWeapon = qfalse;
//.........这里部分代码省略.........
示例2: NPC_ChoosePainAnimation
void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, const vec3_t point, int damage, int mod, int hitLoc, int voiceEvent = -1 )
{
//If we've already taken pain, then don't take it again
if ( level.time < self->painDebounceTime && mod != MOD_ELECTROCUTE && mod != MOD_MELEE )
{//FIXME: if hit while recoving from losing a saber lock, we should still play a pain anim?
return;
}
int pain_anim = -1;
float pain_chance;
if ( self->s.weapon == WP_THERMAL && self->client->fireDelay > 0 )
{//don't interrupt thermal throwing anim
return;
}
else if (self->client->ps.powerups[PW_GALAK_SHIELD])
{
return;
}
else if ( self->client->NPC_class == CLASS_GALAKMECH )
{
if ( hitLoc == HL_GENERIC1 )
{//hit the antenna!
pain_chance = 1.0f;
self->s.powerups |= ( 1 << PW_SHOCKED );
self->client->ps.powerups[PW_SHOCKED] = level.time + Q_irand( 500, 2500 );
}
else if ( self->client->ps.powerups[PW_GALAK_SHIELD] )
{//shield up
return;
}
else if ( self->health > 200 && damage < 100 )
{//have a *lot* of health
pain_chance = 0.05f;
}
else
{//the lower my health and greater the damage, the more likely I am to play a pain anim
pain_chance = (200.0f-self->health)/100.0f + damage/50.0f;
}
}
else if ( self->client && self->client->playerTeam == TEAM_PLAYER && other && !other->s.number )
{//ally shot by player always complains
pain_chance = 1.1f;
}
else
{
if ( other && (other->s.weapon == WP_SABER || mod == MOD_ELECTROCUTE || mod == MOD_CRUSH/*FIXME:MOD_FORCE_GRIP*/) )
{
if ( self->client->ps.weapon == WP_SABER
&& other->s.number < MAX_CLIENTS )
{//hmm, shouldn't *always* react to damage from player if I have a saber
pain_chance = 1.05f - ((self->NPC->rank)/(float)RANK_CAPTAIN);
}
else
{
pain_chance = 1.0f;//always take pain from saber
}
}
else if ( mod == MOD_GAS )
{
pain_chance = 1.0f;
}
else if ( mod == MOD_MELEE )
{//higher in rank (skill) we are, less likely we are to be fazed by a punch
pain_chance = 1.0f - ((RANK_CAPTAIN-self->NPC->rank)/(float)RANK_CAPTAIN);
}
else if ( self->client->NPC_class == CLASS_PROTOCOL )
{
pain_chance = 1.0f;
}
else
{
pain_chance = NPC_GetPainChance( self, damage );
}
if ( self->client->NPC_class == CLASS_DESANN )
{
pain_chance *= 0.5f;
}
}
//See if we're going to flinch
if ( random() < pain_chance )
{
//Pick and play our animation
if ( (self->client->ps.eFlags&EF_FORCE_GRIPPED) )
{
G_AddVoiceEvent( self, Q_irand(EV_CHOKE1, EV_CHOKE3), 0 );
}
else if ( mod == MOD_GAS )
{
//SIGH... because our choke sounds are inappropriately long, I have to debounce them in code!
if ( TIMER_Done( self, "gasChokeSound" ) )
{
TIMER_Set( self, "gasChokeSound", Q_irand( 1000, 2000 ) );
G_AddVoiceEvent( self, Q_irand(EV_CHOKE1, EV_CHOKE3), 0 );
}
}
else if ( (self->client->ps.eFlags&EF_FORCE_DRAINED) )
{
NPC_SetPainEvent( self );
//.........这里部分代码省略.........
示例3: NPC_Wampa_Pain
//void NPC_Wampa_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, const vec3_t point, int damage, int mod,int hitLoc )
void NPC_Wampa_Pain( gentity_t *self, gentity_t *attacker, int damage )
{
qboolean hitByWampa = qfalse;
if ( attacker&&attacker->client&&attacker->client->NPC_class==CLASS_WAMPA )
{
hitByWampa = qtrue;
}
if ( attacker
&& attacker->inuse
&& attacker != self->enemy
&& !(attacker->flags&FL_NOTARGET) )
{
if ( (!attacker->s.number&&!Q_irand(0,3))
|| !self->enemy
|| self->enemy->health == 0
|| (self->enemy->client&&self->enemy->client->NPC_class == CLASS_WAMPA)
|| (!Q_irand(0, 4 ) && DistanceSquared( attacker->r.currentOrigin, self->r.currentOrigin ) < DistanceSquared( self->enemy->r.currentOrigin, self->r.currentOrigin )) )
{//if my enemy is dead (or attacked by player) and I'm not still holding/eating someone, turn on the attacker
//FIXME: if can't nav to my enemy, take this guy if I can nav to him
G_SetEnemy( self, attacker );
TIMER_Set( self, "lookForNewEnemy", Q_irand( 5000, 15000 ) );
if ( hitByWampa )
{//stay mad at this Wampa for 2-5 secs before looking for attacker enemies
TIMER_Set( self, "wampaInfight", Q_irand( 2000, 5000 ) );
}
}
}
if ( (hitByWampa|| Q_irand( 0, 100 ) < damage )//hit by wampa, hit while holding live victim, or took a lot of damage
&& self->client->ps.legsAnim != BOTH_GESTURE1
&& self->client->ps.legsAnim != BOTH_GESTURE2
&& TIMER_Done( self, "takingPain" ) )
{
if ( !Wampa_CheckRoar( self ) )
{
if ( self->client->ps.legsAnim != BOTH_ATTACK1
&& self->client->ps.legsAnim != BOTH_ATTACK2
&& self->client->ps.legsAnim != BOTH_ATTACK3 )
{//cant interrupt one of the big attack anims
if ( self->health > 100 || hitByWampa )
{
TIMER_Remove( self, "attacking" );
VectorCopy( self->NPC->lastPathAngles, self->s.angles );
if ( !Q_irand( 0, 1 ) )
{
NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN2, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
else
{
NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
TIMER_Set( self, "takingPain", self->client->ps.legsTimer+Q_irand(0, 500) );
//allow us to re-evaluate our running speed/anim
TIMER_Set( self, "runfar", -1 );
TIMER_Set( self, "runclose", -1 );
TIMER_Set( self, "walk", -1 );
if ( self->NPC )
{
self->NPC->localState = LSTATE_WAITING;
}
}
}
}
}
}
示例4: NPC_BSGrenadier_Attack
//.........这里部分代码省略.........
NPC_AimAdjust( 1 );//adjust aim better longer we can see enemy
}
}
}
}
else
{
NPC_AimAdjust( -1 );//adjust aim worse longer we cannot see enemy
}
/*
else if ( gi.inPVS( NPC->enemy->currentOrigin, NPC->currentOrigin ) )
{
NPCInfo->enemyLastSeenTime = level.time;
faceEnemy = qtrue;
}
*/
if ( enemyLOS )
{//FIXME: no need to face enemy if we're moving to some other goal and he's too far away to shoot?
faceEnemy = qtrue;
}
if ( enemyCS )
{
shoot = qtrue;
if ( NPC->client->ps.weapon == WP_THERMAL )
{//don't chase and throw
AImove = qfalse;
}
else if ( NPC->client->ps.weapon == WP_MELEE && enemyDist < (NPC->maxs[0]+NPC->enemy->maxs[0]+16)*(NPC->maxs[0]+NPC->enemy->maxs[0]+16) )
{//close enough
AImove = qfalse;
}
}//this should make him chase enemy when out of range...?
//Check for movement to take care of
Grenadier_CheckMoveState();
//See if we should override shooting decision with any special considerations
Grenadier_CheckFireState();
if ( AImove )
{//move toward goal
if ( NPCInfo->goalEntity )//&& ( NPCInfo->goalEntity != NPC->enemy || enemyDist > 10000 ) )//100 squared
{
AImove = Grenadier_Move();
}
else
{
AImove = qfalse;
}
}
if ( !AImove )
{
if ( !TIMER_Done( NPC, "duck" ) )
{
ucmd.upmove = -127;
}
//FIXME: what about leaning?
}
else
{//stop ducking!
TIMER_Set( NPC, "duck", -1 );
}
if ( !faceEnemy )
{//we want to face in the dir we're running
if ( AImove )
{//don't run away and shoot
NPCInfo->desiredYaw = NPCInfo->lastPathAngles[YAW];
NPCInfo->desiredPitch = 0;
shoot = qfalse;
}
NPC_UpdateAngles( qtrue, qtrue );
}
else// if ( faceEnemy )
{//face the enemy
NPC_FaceEnemy();
}
if ( NPCInfo->scriptFlags&SCF_DONT_FIRE )
{
shoot = qfalse;
}
//FIXME: don't shoot right away!
if ( shoot )
{//try to shoot if it's time
if ( TIMER_Done( NPC, "attackDelay" ) )
{
if( !(NPCInfo->scriptFlags & SCF_FIRE_WEAPON) ) // we've already fired, no need to do it again here
{
WeaponThink( qtrue );
TIMER_Set( NPC, "attackDelay", NPCInfo->shotTime-level.time );
}
}
}
}
示例5: Remote_MaintainHeight
/*
-------------------------
Remote_MaintainHeight
-------------------------
*/
void Remote_MaintainHeight( void )
{
float dif;
// Update our angles regardless
NPC_UpdateAngles( qtrue, qtrue );
if ( NPC->client->ps.velocity[2] )
{
NPC->client->ps.velocity[2] *= VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[2] ) < 2 )
{
NPC->client->ps.velocity[2] = 0;
}
}
// If we have an enemy, we should try to hover at or a little below enemy eye level
if ( NPC->enemy )
{
if (TIMER_Done( NPC, "heightChange"))
{
TIMER_Set( NPC,"heightChange",Q_irand( 1000, 3000 ));
// Find the height difference
dif = (NPC->enemy->currentOrigin[2] + Q_irand( 0, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2];
// cap to prevent dramatic height shifts
if ( fabs( dif ) > 2 )
{
if ( fabs( dif ) > 24 )
{
dif = ( dif < 0 ? -24 : 24 );
}
dif *= 10;
NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
NPC->fx_time = level.time;
G_Sound( NPC, G_SoundIndex("sound/chars/remote/misc/hiss.wav"));
}
}
}
else
{
gentity_t *goal = NULL;
if ( NPCInfo->goalEntity ) // Is there a goal?
{
goal = NPCInfo->goalEntity;
}
else
{
goal = NPCInfo->lastGoalEntity;
}
if ( goal )
{
dif = goal->currentOrigin[2] - NPC->currentOrigin[2];
if ( fabs( dif ) > 24 )
{
dif = ( dif < 0 ? -24 : 24 );
NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
}
}
}
// Apply friction
if ( NPC->client->ps.velocity[0] )
{
NPC->client->ps.velocity[0] *= VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[0] ) < 1 )
{
NPC->client->ps.velocity[0] = 0;
}
}
if ( NPC->client->ps.velocity[1] )
{
NPC->client->ps.velocity[1] *= VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[1] ) < 1 )
{
NPC->client->ps.velocity[1] = 0;
}
}
}
示例6: Mark1_dying
/*
-------------------------
Mark1_dying
-------------------------
*/
void Mark1_dying( gentity_t *self )
{
int num,newBolt;
if (self->client->ps.torsoTimer>0)
{
if (TIMER_Done(self,"dyingExplosion"))
{
num = Q_irand( 1, 3);
// Find place to generate explosion
if (num == 1)
{
num = Q_irand( 8, 10);
newBolt = trap_G2API_AddBolt( self->ghoul2, 0, va("*flash%d",num) );
NPC_Mark1_Part_Explode(self,newBolt);
}
else
{
num = Q_irand( 1, 6);
newBolt = trap_G2API_AddBolt( self->ghoul2, 0, va("*torso_tube%d",num) );
NPC_Mark1_Part_Explode(self,newBolt);
NPC_SetSurfaceOnOff( self, va("torso_tube%d",num), TURN_OFF );
}
TIMER_Set( self, "dyingExplosion", Q_irand( 300, 1000 ) );
}
// int dir;
// vec3_t right;
// Shove to the side
// AngleVectors( self->client->renderInfo.eyeAngles, NULL, right, NULL );
// VectorMA( self->client->ps.velocity, -80, right, self->client->ps.velocity );
// See which weapons are there
// Randomly fire blaster
if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "l_arm" )) // Is the blaster still on the model?
{
if (Q_irand( 1, 5) == 1)
{
SaveNPCGlobals();
SetNPCGlobals( self );
Mark1Dead_FireBlaster();
RestoreNPCGlobals();
}
}
// Randomly fire rocket
if (!trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "r_arm" )) // Is the rocket still on the model?
{
if (Q_irand( 1, 10) == 1)
{
SaveNPCGlobals();
SetNPCGlobals( self );
Mark1Dead_FireRocket();
RestoreNPCGlobals();
}
}
}
}
示例7: NPC_BSGrenadier_Patrol
void NPC_BSGrenadier_Patrol( void )
{//FIXME: pick up on bodies of dead buddies?
if ( NPCInfo->confusionTime < level.time )
{
//Look for any enemies
if ( NPCInfo->scriptFlags&SCF_LOOK_FOR_ENEMIES )
{
if ( NPC_CheckPlayerTeamStealth() )
{
//NPCInfo->behaviorState = BS_HUNT_AND_KILL;//should be automatic now
//NPC_AngerSound();
NPC_UpdateAngles( qtrue, qtrue );
return;
}
}
if ( !(NPCInfo->scriptFlags&SCF_IGNORE_ALERTS) )
{
//Is there danger nearby
int alertEvent = NPC_CheckAlertEvents( qtrue, qtrue, -1, qfalse, AEL_SUSPICIOUS );
if ( NPC_CheckForDanger( alertEvent ) )
{
NPC_UpdateAngles( qtrue, qtrue );
return;
}
else
{//check for other alert events
//There is an event to look at
if ( alertEvent >= 0 && level.alertEvents[alertEvent].ID != NPCInfo->lastAlertID )
{
NPCInfo->lastAlertID = level.alertEvents[alertEvent].ID;
if ( level.alertEvents[alertEvent].level == AEL_DISCOVERED )
{
if ( level.alertEvents[alertEvent].owner &&
level.alertEvents[alertEvent].owner->client &&
level.alertEvents[alertEvent].owner->health >= 0 &&
level.alertEvents[alertEvent].owner->client->playerTeam == NPC->client->enemyTeam )
{//an enemy
G_SetEnemy( NPC, level.alertEvents[alertEvent].owner );
//NPCInfo->enemyLastSeenTime = level.time;
TIMER_Set( NPC, "attackDelay", Q_irand( 500, 2500 ) );
}
}
else
{//FIXME: get more suspicious over time?
//Save the position for movement (if necessary)
VectorCopy( level.alertEvents[alertEvent].position, NPCInfo->investigateGoal );
NPCInfo->investigateDebounceTime = level.time + Q_irand( 500, 1000 );
if ( level.alertEvents[alertEvent].level == AEL_SUSPICIOUS )
{//suspicious looks longer
NPCInfo->investigateDebounceTime += Q_irand( 500, 2500 );
}
}
}
}
if ( NPCInfo->investigateDebounceTime > level.time )
{//FIXME: walk over to it, maybe? Not if not chase enemies
//NOTE: stops walking or doing anything else below
vec3_t dir, angles;
float o_yaw, o_pitch;
VectorSubtract( NPCInfo->investigateGoal, NPC->client->renderInfo.eyePoint, dir );
vectoangles( dir, angles );
o_yaw = NPCInfo->desiredYaw;
o_pitch = NPCInfo->desiredPitch;
NPCInfo->desiredYaw = angles[YAW];
NPCInfo->desiredPitch = angles[PITCH];
NPC_UpdateAngles( qtrue, qtrue );
NPCInfo->desiredYaw = o_yaw;
NPCInfo->desiredPitch = o_pitch;
return;
}
}
}
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
ucmd.buttons |= BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
}
NPC_UpdateAngles( qtrue, qtrue );
}
示例8: Sniper_CheckMoveState
static void Sniper_CheckMoveState( void )
{
//See if we're a scout
if ( !(NPCInfo->scriptFlags & SCF_CHASE_ENEMIES) )//NPCInfo->behaviorState == BS_STAND_AND_SHOOT )
{
if ( NPCInfo->goalEntity == NPC->enemy )
{
doMove = qfalse;
return;
}
}
//See if we're running away
else if ( NPCInfo->squadState == SQUAD_RETREAT )
{
if ( TIMER_Done( NPC, "flee" ) )
{
NPCInfo->squadState = SQUAD_IDLE;
}
else
{
faceEnemy = qfalse;
}
}
else if ( NPCInfo->squadState == SQUAD_IDLE )
{
if ( !NPCInfo->goalEntity )
{
doMove = qfalse;
return;
}
}
if ( !TIMER_Done( NPC, "taunting" ) )
{//no doMove while taunting
doMove = qfalse;
return;
}
//See if we're moving towards a goal, not the enemy
if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) )
{
//Did we make it?
if ( STEER::Reached(NPC, NPCInfo->goalEntity, 16, !!FlyingCreature(NPC)) ||
( NPCInfo->squadState == SQUAD_SCOUT && enemyLOS && enemyDist <= 10000 ) )
{
int newSquadState = SQUAD_STAND_AND_SHOOT;
//we got where we wanted to go, set timers based on why we were running
switch ( NPCInfo->squadState )
{
case SQUAD_RETREAT://was running away
if ( NPC->client->NPC_class == CLASS_SABOTEUR )
{
Saboteur_Cloak( NPC );
}
TIMER_Set( NPC, "duck", (NPC->max_health - NPC->health) * 100 );
TIMER_Set( NPC, "hideTime", Q_irand( 3000, 7000 ) );
newSquadState = SQUAD_COVER;
break;
case SQUAD_TRANSITION://was heading for a combat point
TIMER_Set( NPC, "hideTime", Q_irand( 2000, 4000 ) );
break;
case SQUAD_SCOUT://was running after player
break;
default:
break;
}
NPC_ReachedGoal();
//don't attack right away
TIMER_Set( NPC, "attackDelay", Q_irand( (6-NPCInfo->stats.aim)*50, (6-NPCInfo->stats.aim)*100 ) ); //FIXME: Slant for difficulty levels, too?
//don't do something else just yet
TIMER_Set( NPC, "roamTime", Q_irand( 1000, 4000 ) );
//stop fleeing
if ( NPCInfo->squadState == SQUAD_RETREAT )
{
TIMER_Set( NPC, "flee", -level.time );
NPCInfo->squadState = SQUAD_IDLE;
}
return;
}
//keep going, hold of roamTimer until we get there
TIMER_Set( NPC, "roamTime", Q_irand( 4000, 8000 ) );
}
}
示例9: NPC_BSSniper_Attack
//.........这里部分代码省略.........
enemyCS = qtrue;
}
}
}
/*
else if ( gi.inPVS( NPC->enemy->currentOrigin, NPC->currentOrigin ) )
{
NPCInfo->enemyLastSeenTime = level.time;
faceEnemy = qtrue;
}
*/
if ( enemyLOS )
{//FIXME: no need to face enemy if we're moving to some other goal and he's too far away to shoot?
faceEnemy = qtrue;
}
if ( !TIMER_Done( NPC, "taunting" ) )
{
doMove = qfalse;
shoot = qfalse;
}
else if ( enemyCS )
{
shoot = qtrue;
}
else if ( level.time - NPCInfo->enemyLastSeenTime > 3000 )
{//Hmm, have to get around this bastard... FIXME: this NPCInfo->enemyLastSeenTime builds up when ducked seems to make them want to run when they uncrouch
Sniper_ResolveBlockedShot();
}
else if ( NPC->client->ps.weapon == WP_TUSKEN_RIFLE && !Q_irand( 0, 100 ) )
{//start a taunt
NPC_Tusken_Taunt();
TIMER_Set( NPC, "duck", -1 );
doMove = qfalse;
}
//Check for movement to take care of
Sniper_CheckMoveState();
//See if we should override shooting decision with any special considerations
Sniper_CheckFireState();
if ( doMove )
{//doMove toward goal
if ( NPCInfo->goalEntity )//&& ( NPCInfo->goalEntity != NPC->enemy || enemyDist > 10000 ) )//100 squared
{
doMove = Sniper_Move();
}
else
{
doMove = qfalse;
}
}
if ( !doMove )
{
if ( !TIMER_Done( NPC, "duck" ) )
{
if ( TIMER_Done( NPC, "watch" ) )
{//not while watching
ucmd.upmove = -127;
if ( NPC->client->NPC_class == CLASS_SABOTEUR )
{
Saboteur_Cloak( NPC );
}
示例10: NPC_Rancor_Pain
void NPC_Rancor_Pain( gentity_t *self, gentity_t *attacker, int damage ) {
qboolean hitByRancor = qfalse;
if ( attacker&&attacker->client&&attacker->client->NPC_class == CLASS_RANCOR ) {
hitByRancor = qtrue;
}
if ( attacker
&& attacker->inuse
&& attacker != self->enemy
&& !(attacker->flags&FL_NOTARGET) ) {
if ( !self->count ) {
if ( (!attacker->s.number&&!Q_irand( 0, 3 ))
|| !self->enemy
|| self->enemy->health == 0
|| (self->enemy->client&&self->enemy->client->NPC_class == CLASS_RANCOR)
|| (self->NPC && self->NPC->consecutiveBlockedMoves >= 10 && DistanceSquared( &attacker->r.currentOrigin, &self->r.currentOrigin ) < DistanceSquared( &self->enemy->r.currentOrigin, &self->r.currentOrigin )) ) {//if my enemy is dead (or attacked by player) and I'm not still holding/eating someone, turn on the attacker
//FIXME: if can't nav to my enemy, take this guy if I can nav to him
G_SetEnemy( self, attacker );
TIMER_Set( self, "lookForNewEnemy", Q_irand( 5000, 15000 ) );
if ( hitByRancor ) {//stay mad at this Rancor for 2-5 secs before looking for attacker enemies
TIMER_Set( self, "rancorInfight", Q_irand( 2000, 5000 ) );
}
}
}
}
if ( (hitByRancor || (self->count == 1 && self->activator&&!Q_irand( 0, 4 )) || Q_irand( 0, 200 ) < damage)//hit by rancor, hit while holding live victim, or took a lot of damage
&& self->client->ps.legsAnim != BOTH_STAND1TO2
&& TIMER_Done( self, "takingPain" ) ) {
if ( !Rancor_CheckRoar( self ) ) {
if ( self->client->ps.legsAnim != BOTH_MELEE1
&& self->client->ps.legsAnim != BOTH_MELEE2
&& self->client->ps.legsAnim != BOTH_ATTACK2 ) {//cant interrupt one of the big attack anims
/*
if ( self->count != 1
|| attacker == self->activator
|| (self->client->ps.legsAnim != BOTH_ATTACK1&&self->client->ps.legsAnim != BOTH_ATTACK3) )
*/
{//if going to bite our victim, only victim can interrupt that anim
if ( self->health > 100 || hitByRancor ) {
TIMER_Remove( self, "attacking" );
VectorCopy( &self->NPC->lastPathAngles, &self->s.angles );
if ( self->count == 1 ) {
NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN2, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
else {
NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
TIMER_Set( self, "takingPain", self->client->ps.legsTimer + Q_irand( 0, 500 ) );
if ( self->NPC ) {
self->NPC->localState = LSTATE_WAITING;
}
}
}
}
}
//let go
/*
if ( !Q_irand( 0, 3 ) && self->count == 1 )
{
Rancor_DropVictim( self );
}
*/
}
}
示例11: NPC_BSRancor_Default
void NPC_BSRancor_Default( void ) {
AddSightEvent( NPC, &NPC->r.currentOrigin, 1024, AEL_DANGER_GREAT, 50 );
Rancor_Crush();
NPC->client->ps.eFlags2 &= ~(EF2_USE_ALT_ANIM | EF2_GENERIC_NPC_FLAG);
if ( NPC->count ) {//holding someone
NPC->client->ps.eFlags2 |= EF2_USE_ALT_ANIM;
if ( NPC->count == 2 ) {//in my mouth
NPC->client->ps.eFlags2 |= EF2_GENERIC_NPC_FLAG;
}
}
else {
NPC->client->ps.eFlags2 &= ~(EF2_USE_ALT_ANIM | EF2_GENERIC_NPC_FLAG);
}
if ( TIMER_Done2( NPC, "clearGrabbed", qtrue ) ) {
Rancor_DropVictim( NPC );
}
else if ( NPC->client->ps.legsAnim == BOTH_PAIN2
&& NPC->count == 1
&& NPC->activator ) {
if ( !Q_irand( 0, 3 ) ) {
Rancor_CheckDropVictim();
}
}
if ( !TIMER_Done( NPC, "rageTime" ) ) {//do nothing but roar first time we see an enemy
AddSoundEvent( NPC, &NPC->r.currentOrigin, 1024, AEL_DANGER_GREAT, qfalse );//, qfalse );
NPC_FaceEnemy( qtrue );
return;
}
if ( NPC->enemy ) {
/*
if ( NPC->enemy->client //enemy is a client
&& (NPC->enemy->client->NPC_class == CLASS_UGNAUGHT || NPC->enemy->client->NPC_class == CLASS_JAWA )//enemy is a lowly jawa or ugnaught
&& NPC->enemy->enemy != NPC//enemy's enemy is not me
&& (!NPC->enemy->enemy || !NPC->enemy->enemy->client || NPC->enemy->enemy->client->NPC_class!=CLASS_RANCOR) )//enemy's enemy is not a client or is not a rancor (which is as scary as me anyway)
{//they should be scared of ME and no-one else
G_SetEnemy( NPC->enemy, NPC );
}
*/
if ( TIMER_Done( NPC, "angrynoise" ) ) {
G_Sound( NPC, CHAN_AUTO, G_SoundIndex( va( "sound/chars/rancor/misc/anger%d.wav", Q_irand( 1, 3 ) ) ) );
TIMER_Set( NPC, "angrynoise", Q_irand( 5000, 10000 ) );
}
else {
AddSoundEvent( NPC, &NPC->r.currentOrigin, 512, AEL_DANGER_GREAT, qfalse );//, qfalse );
}
if ( NPC->count == 2 && NPC->client->ps.legsAnim == BOTH_ATTACK3 ) {//we're still chewing our enemy up
NPC_UpdateAngles( qtrue, qtrue );
return;
}
//else, if he's in our hand, we eat, else if he's on the ground, we keep attacking his dead body for a while
if ( NPC->enemy->client && NPC->enemy->client->NPC_class == CLASS_RANCOR ) {//got mad at another Rancor, look for a valid enemy
if ( TIMER_Done( NPC, "rancorInfight" ) ) {
NPC_CheckEnemyExt( qtrue );
}
}
else if ( !NPC->count ) {
if ( ValidEnemy( NPC->enemy ) == qfalse ) {
TIMER_Remove( NPC, "lookForNewEnemy" );//make them look again right now
if ( !NPC->enemy->inuse || level.time - NPC->enemy->s.time > Q_irand( 10000, 15000 ) ) {//it's been a while since the enemy died, or enemy is completely gone, get bored with him
NPC->enemy = NULL;
Rancor_Patrol();
NPC_UpdateAngles( qtrue, qtrue );
return;
}
}
if ( TIMER_Done( NPC, "lookForNewEnemy" ) ) {
gentity_t *newEnemy, *sav_enemy = NPC->enemy;//FIXME: what about NPC->lastEnemy?
NPC->enemy = NULL;
newEnemy = NPC_CheckEnemy( NPCInfo->confusionTime < level.time, qfalse, qfalse );
NPC->enemy = sav_enemy;
if ( newEnemy && newEnemy != sav_enemy ) {//picked up a new enemy!
NPC->lastEnemy = NPC->enemy;
G_SetEnemy( NPC, newEnemy );
//hold this one for at least 5-15 seconds
TIMER_Set( NPC, "lookForNewEnemy", Q_irand( 5000, 15000 ) );
}
else {//look again in 2-5 secs
TIMER_Set( NPC, "lookForNewEnemy", Q_irand( 2000, 5000 ) );
}
}
}
Rancor_Combat();
}
else {
if ( TIMER_Done( NPC, "idlenoise" ) ) {
G_Sound( NPC, CHAN_AUTO, G_SoundIndex( va( "sound/chars/rancor/snort_%d.wav", Q_irand( 1, 2 ) ) ) );
TIMER_Set( NPC, "idlenoise", Q_irand( 2000, 4000 ) );
AddSoundEvent( NPC, &NPC->r.currentOrigin, 384, AEL_DANGER, qfalse );//, qfalse );
}
if ( NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES ) {
Rancor_Patrol();
}
else {
Rancor_Idle();
}
//.........这里部分代码省略.........
示例12: Rancor_Combat
void Rancor_Combat( void ) {
if ( NPC->count ) {//holding my enemy
if ( TIMER_Done2( NPC, "takingPain", qtrue ) ) {
NPCInfo->localState = LSTATE_CLEAR;
}
else {
Rancor_Attack( 0, qfalse );
}
NPC_UpdateAngles( qtrue, qtrue );
return;
}
// 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 = MIN_DISTANCE;//MAX_DISTANCE; // just get us within combat range
if ( !NPC_MoveToGoal( qtrue ) ) {//couldn't go after him? Look for a new one
TIMER_Set( NPC, "lookForNewEnemy", 0 );
NPCInfo->consecutiveBlockedMoves++;
}
else {
NPCInfo->consecutiveBlockedMoves = 0;
}
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 );
{
float distance;
qboolean advance;
qboolean doCharge;
distance = Distance( &NPC->r.currentOrigin, &NPC->enemy->r.currentOrigin );
advance = (qboolean)(distance > (NPC->r.maxs.x + MIN_DISTANCE) ? qtrue : qfalse);
doCharge = qfalse;
if ( advance ) {//have to get closer
vector3 yawOnlyAngles;
VectorSet( &yawOnlyAngles, 0, NPC->r.currentAngles.yaw, 0 );
if ( NPC->enemy->health > 0
&& fabsf( distance - 250 ) <= 80
&& InFOV3( &NPC->enemy->r.currentOrigin, &NPC->r.currentOrigin, &yawOnlyAngles, 30, 30 ) ) {
if ( !Q_irand( 0, 9 ) ) {//go for the charge
doCharge = qtrue;
advance = 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 {
Rancor_Move( qtrue );
}
}
else {
Rancor_Attack( distance, doCharge );
}
}
}
示例13: Rancor_Attack
void Rancor_Attack( float distance, qboolean doCharge ) {
if ( !TIMER_Exists( NPC, "attacking" ) ) {
if ( NPC->count == 2 && NPC->activator ) {
}
else if ( NPC->count == 1 && NPC->activator ) {//holding enemy
if ( NPC->activator->health > 0 && Q_irand( 0, 1 ) ) {//quick bite
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_ATTACK1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
TIMER_Set( NPC, "attack_dmg", 450 );
}
else {//full eat
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_ATTACK3, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
TIMER_Set( NPC, "attack_dmg", 900 );
//Make victim scream in fright
if ( NPC->activator->health > 0 && NPC->activator->client ) {
G_AddEvent( NPC->activator, Q_irand( EV_DEATH1, EV_DEATH3 ), 0 );
NPC_SetAnim( NPC->activator, SETANIM_TORSO, BOTH_FALLDEATH1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
if ( NPC->activator->NPC ) {//no more thinking for you
TossClientItems( NPC );
NPC->activator->NPC->nextBStateThink = Q3_INFINITE;
}
}
}
}
else if ( NPC->enemy->health > 0 && doCharge ) {//charge
vector3 fwd, yawAng;
VectorSet( &yawAng, 0, NPC->client->ps.viewangles.yaw, 0 );
AngleVectors( &yawAng, &fwd, NULL, NULL );
VectorScale( &fwd, distance*1.5f, &NPC->client->ps.velocity );
NPC->client->ps.velocity.z = 150;
NPC->client->ps.groundEntityNum = ENTITYNUM_NONE;
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_MELEE2, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
TIMER_Set( NPC, "attack_dmg", 1250 );
}
else if ( !Q_irand( 0, 1 ) ) {//smash
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_MELEE1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
TIMER_Set( NPC, "attack_dmg", 1000 );
}
else {//try to grab
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_ATTACK2, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
TIMER_Set( NPC, "attack_dmg", 1000 );
}
TIMER_Set( NPC, "attacking", NPC->client->ps.legsTimer + random() * 200 );
}
// Need to do delayed damage since the attack animations encapsulate multiple mini-attacks
if ( TIMER_Done2( NPC, "attack_dmg", qtrue ) ) {
vector3 shakePos;
switch ( NPC->client->ps.legsAnim ) {
case BOTH_MELEE1:
Rancor_Smash();
G_GetBoltPosition( NPC, NPC->client->renderInfo.handLBolt, &shakePos, 0 );
G_ScreenShake( &shakePos, NULL, 4.0f, 1000, qfalse );
//CGCam_Shake( 1.0f*playerDist/128.0f, 1000 );
break;
case BOTH_MELEE2:
Rancor_Bite();
TIMER_Set( NPC, "attack_dmg2", 450 );
break;
case BOTH_ATTACK1:
if ( NPC->count == 1 && NPC->activator ) {
G_Damage( NPC->activator, NPC, NPC, &vec3_origin, &NPC->activator->r.currentOrigin, Q_irand( 25, 40 ), DAMAGE_NO_ARMOR | DAMAGE_NO_KNOCKBACK, MOD_MELEE );
if ( NPC->activator->health <= 0 ) {//killed him
//make it look like we bit his head off
//NPC->activator->client->dismembered = qfalse;
G_Dismember( NPC->activator, NPC, &NPC->activator->r.currentOrigin, G2_MODELPART_HEAD, 90, 0, NPC->activator->client->ps.torsoAnim, qtrue );
//G_DoDismemberment( NPC->activator, NPC->activator->r.currentOrigin, MOD_SABER, 1000, HL_HEAD, qtrue );
NPC->activator->client->ps.forceHandExtend = HANDEXTEND_NONE;
NPC->activator->client->ps.forceHandExtendTime = 0;
NPC_SetAnim( NPC->activator, SETANIM_BOTH, BOTH_SWIM_IDLE1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
G_Sound( NPC->activator, CHAN_AUTO, G_SoundIndex( "sound/chars/rancor/chomp.wav" ) );
}
break;
case BOTH_ATTACK2:
//try to grab
Rancor_Swing( qtrue );
break;
case BOTH_ATTACK3:
if ( NPC->count == 1 && NPC->activator ) {
//cut in half
if ( NPC->activator->client ) {
//NPC->activator->client->dismembered = qfalse;
G_Dismember( NPC->activator, NPC, &NPC->activator->r.currentOrigin, G2_MODELPART_WAIST, 90, 0, NPC->activator->client->ps.torsoAnim, qtrue );
//G_DoDismemberment( NPC->activator, NPC->enemy->r.currentOrigin, MOD_SABER, 1000, HL_WAIST, qtrue );
}
//KILL
G_Damage( NPC->activator, NPC, NPC, &vec3_origin, &NPC->activator->r.currentOrigin, NPC->enemy->health + 10, DAMAGE_NO_PROTECTION | DAMAGE_NO_ARMOR | DAMAGE_NO_KNOCKBACK | DAMAGE_NO_HIT_LOC, MOD_MELEE );//, HL_NONE );//
if ( NPC->activator->client ) {
NPC->activator->client->ps.forceHandExtend = HANDEXTEND_NONE;
NPC->activator->client->ps.forceHandExtendTime = 0;
NPC_SetAnim( NPC->activator, SETANIM_BOTH, BOTH_SWIM_IDLE1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
TIMER_Set( NPC, "attack_dmg2", 1350 );
G_Sound( NPC->activator, CHAN_AUTO, G_SoundIndex( "sound/chars/rancor/swipehit.wav" ) );
G_AddEvent( NPC->activator, EV_JUMP, NPC->activator->health );
}
break;
//.........这里部分代码省略.........
示例14: Rancor_Swing
void Rancor_Swing( qboolean tryGrab ) {
int radiusEntNums[128];
int numEnts;
const float radius = 88;
const float radiusSquared = (radius*radius);
int i;
vector3 boltOrg;
numEnts = NPC_GetEntsNearBolt( radiusEntNums, radius, NPC->client->renderInfo.handRBolt, &boltOrg );
for ( i = 0; i < numEnts; i++ ) {
gentity_t *radiusEnt = &g_entities[radiusEntNums[i]];
if ( !radiusEnt->inuse ) {
continue;
}
if ( radiusEnt == NPC ) {//Skip the rancor ent
continue;
}
if ( radiusEnt->client == NULL ) {//must be a client
continue;
}
if ( (radiusEnt->client->ps.eFlags2&EF2_HELD_BY_MONSTER) ) {//can't be one already being held
continue;
}
if ( DistanceSquared( &radiusEnt->r.currentOrigin, &boltOrg ) <= radiusSquared ) {
if (tryGrab
&& NPC->count != 1 //don't have one in hand or in mouth already - FIXME: allow one in hand and any number in mouth!
&& radiusEnt->client->NPC_class != CLASS_RANCOR
&& radiusEnt->client->NPC_class != CLASS_GALAKMECH
&& radiusEnt->client->NPC_class != CLASS_ATST
&& radiusEnt->client->NPC_class != CLASS_GONK
&& radiusEnt->client->NPC_class != CLASS_R2D2
&& radiusEnt->client->NPC_class != CLASS_R5D2
&& radiusEnt->client->NPC_class != CLASS_MARK1
&& radiusEnt->client->NPC_class != CLASS_MARK2
&& radiusEnt->client->NPC_class != CLASS_MOUSE
&& radiusEnt->client->NPC_class != CLASS_PROBE
&& radiusEnt->client->NPC_class != CLASS_SEEKER
&& radiusEnt->client->NPC_class != CLASS_REMOTE
&& radiusEnt->client->NPC_class != CLASS_SENTRY
&& radiusEnt->client->NPC_class != CLASS_INTERROGATOR
&& radiusEnt->client->NPC_class != CLASS_VEHICLE) {//grab
if (NPC->count == 2) {//have one in my mouth, remove him
TIMER_Remove(NPC, "clearGrabbed");
Rancor_DropVictim(NPC);
}
NPC->enemy = radiusEnt;//make him my new best friend
radiusEnt->client->ps.eFlags2 |= EF2_HELD_BY_MONSTER;
//FIXME: this makes it so that the victim can't hit us with shots! Just use activator or something
radiusEnt->client->ps.hasLookTarget = qtrue;
radiusEnt->client->ps.lookTarget = NPC->s.number;
NPC->activator = radiusEnt;//remember him
NPC->count = 1;//in my hand
//wait to attack
TIMER_Set(NPC, "attacking", NPC->client->ps.legsTimer + Q_irand(500, 2500));
if (radiusEnt->health > 0){//do pain on enemy
if(radiusEnt->pain)
radiusEnt->pain( radiusEnt, NPC, 100 );
JPLua::Entity_CallFunction( radiusEnt, JPLua::JPLUA_ENTITY_PAIN, (intptr_t)NPC, (intptr_t)100 );
//GEntity_PainFunc( radiusEnt, NPC, NPC, radiusEnt->r.currentOrigin, 0, MOD_CRUSH );
}
else if ( radiusEnt->client ) {
radiusEnt->client->ps.forceHandExtend = HANDEXTEND_NONE;
radiusEnt->client->ps.forceHandExtendTime = 0;
NPC_SetAnim( radiusEnt, SETANIM_BOTH, BOTH_SWIM_IDLE1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );
}
}
else {//smack
vector3 pushDir;
vector3 angs;
G_Sound( radiusEnt, CHAN_AUTO, G_SoundIndex( "sound/chars/rancor/swipehit.wav" ) );
//actually push the enemy
/*
//VectorSubtract( radiusEnt->r.currentOrigin, boltOrg, pushDir );
VectorSubtract( radiusEnt->r.currentOrigin, NPC->r.currentOrigin, pushDir );
pushDir[2] = flrand( 100, 200 );
VectorNormalize( pushDir );
*/
VectorCopy( &NPC->client->ps.viewangles, &angs );
angs.yaw += flrand( 25, 50 );
angs.pitch = flrand( -25, -15 );
AngleVectors( &angs, &pushDir, NULL, NULL );
if ( radiusEnt->client->NPC_class != CLASS_RANCOR
&& radiusEnt->client->NPC_class != CLASS_ATST ) {
G_Damage( radiusEnt, NPC, NPC, &vec3_origin, &radiusEnt->r.currentOrigin, Q_irand( 25, 40 ), DAMAGE_NO_ARMOR | DAMAGE_NO_KNOCKBACK, MOD_MELEE );
G_Throw( radiusEnt, &pushDir, 250 );
if ( radiusEnt->health > 0 ) {//do pain on enemy
G_Knockdown( radiusEnt );//, NPC, pushDir, 100, qtrue );
}
}
}
}
}
}
示例15: NPC_GM_Pain
void NPC_GM_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, vec3_t point, int damage, int mod,int hitLoc )
{
if ( self->client->ps.powerups[PW_GALAK_SHIELD] == 0 )
{//shield is currently down
//FIXME: allow for radius damage?
if ( (hitLoc==HL_GENERIC1) && (self->locationDamage[HL_GENERIC1] > GENERATOR_HEALTH) )
{
int newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*antenna_base" );
if ( newBolt != -1 )
{
GM_CreateExplosion( self, newBolt );
}
gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "torso_shield_off", TURN_OFF );
gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "torso_antenna", TURN_OFF );
gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "torso_antenna_base_cap_off", TURN_ON );
self->client->ps.powerups[PW_GALAK_SHIELD] = 0;//temp, for effect
self->client->ps.stats[STAT_ARMOR] = 0;//no more armor
self->NPC->investigateDebounceTime = 0;//stop recharging
NPC_SetAnim( self, SETANIM_BOTH, BOTH_ALERT1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
TIMER_Set( self, "attackDelay", self->client->ps.torsoAnimTimer );
G_AddEvent( self, Q_irand( EV_DEATH1, EV_DEATH3 ), self->health );
}
}
else
{//store the point for shield impact
if ( point )
{
VectorCopy( point, self->pos4 );
self->client->poisonTime = level.time;
}
}
if ( !self->lockCount && !self->client->ps.torsoAnimTimer )
{//don't interrupt laser sweep attack or other special attacks/moves
if ( self->count < 4 && self->health > 100 && hitLoc != HL_GENERIC1 )
{
if ( self->delay < level.time )
{
int speech;
switch( self->count )
{
default:
case 0:
speech = EV_PUSHED1;
break;
case 1:
speech = EV_PUSHED2;
break;
case 2:
speech = EV_PUSHED3;
break;
case 3:
speech = EV_DETECTED1;
break;
}
self->count++;
self->NPC->blockedSpeechDebounceTime = 0;
G_AddVoiceEvent( self, speech, Q_irand( 3000, 5000 ) );
self->delay = level.time + Q_irand( 5000, 7000 );
}
}
else
{
NPC_Pain( self, inflictor, attacker, point, damage, mod, hitLoc );
}
}
else if ( hitLoc == HL_GENERIC1 )
{
NPC_SetPainEvent( self );
self->s.powerups |= ( 1 << PW_SHOCKED );
self->client->ps.powerups[PW_SHOCKED] = level.time + Q_irand( 500, 2500 );
}
if ( inflictor && inflictor->lastEnemy == self )
{//He force-pushed my own lobfires back at me
if ( mod == MOD_REPEATER_ALT && !Q_irand( 0, 2 ) )
{
if ( TIMER_Done( self, "noRapid" ) )
{
self->NPC->scriptFlags &= ~SCF_ALT_FIRE;
self->alt_fire = qfalse;
TIMER_Set( self, "noLob", Q_irand( 2000, 6000 ) );
}
else
{//hopefully this will make us fire the laser
TIMER_Set( self, "noLob", Q_irand( 1000, 2000 ) );
}
}
else if ( mod == MOD_REPEATER && !Q_irand( 0, 5 ) )
{
if ( TIMER_Done( self, "noLob" ) )
{
self->NPC->scriptFlags |= SCF_ALT_FIRE;
self->alt_fire = qtrue;
TIMER_Set( self, "noRapid", Q_irand( 2000, 6000 ) );
}
else
{//hopefully this will make us fire the laser
//.........这里部分代码省略.........