本文整理汇总了C++中NPC_UpdateAngles函数的典型用法代码示例。如果您正苦于以下问题:C++ NPC_UpdateAngles函数的具体用法?C++ NPC_UpdateAngles怎么用?C++ NPC_UpdateAngles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NPC_UpdateAngles函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Seeker_FollowPlayer
//------------------------------------
void Seeker_FollowPlayer( void )
{
Seeker_MaintainHeight();
float dis = DistanceHorizontalSquared( NPC->currentOrigin, g_entities[0].currentOrigin );
vec3_t pt, dir;
float minDistSqr = MIN_DISTANCE_SQR;
if ( NPC->client->NPC_class == CLASS_BOBAFETT )
{
if ( TIMER_Done( NPC, "flameTime" ) )
{
minDistSqr = 200*200;
}
}
if ( dis < minDistSqr )
{
// generally circle the player closely till we take an enemy..this is our target point
if ( NPC->client->NPC_class == CLASS_BOBAFETT )
{
pt[0] = g_entities[0].currentOrigin[0] + cos( level.time * 0.001f + NPC->random ) * 250;
pt[1] = g_entities[0].currentOrigin[1] + sin( level.time * 0.001f + NPC->random ) * 250;
if ( NPC->client->jetPackTime < level.time )
{
pt[2] = NPC->currentOrigin[2] - 64;
}
else
{
pt[2] = g_entities[0].currentOrigin[2] + 200;
}
}
else
{
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 ( NPC->client->NPC_class != CLASS_BOBAFETT )
{
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 );
}
开发者ID:Arbixal,项目名称:OpenJK,代码行数:71,代码来源:AI_Seeker.cpp
示例2: NPC_Think
void NPC_Think ( gentity_t *self)//, int msec )
{
vector3 oldMoveDir;
int i = 0;
gentity_t *player;
self->nextthink = level.time + FRAMETIME;
SetNPCGlobals( self );
memset( &ucmd, 0, sizeof( ucmd ) );
VectorCopy( &self->client->ps.moveDir, &oldMoveDir );
if (self->s.NPC_class != CLASS_VEHICLE)
{ //YOU ARE BREAKING MY PREDICTION. Bad clear.
VectorClear( &self->client->ps.moveDir );
}
if(!self || !self->NPC || !self->client)
{
return;
}
// dead NPCs have a special think, don't run scripts (for now)
//FIXME: this breaks deathscripts
if ( self->health <= 0 )
{
DeadThink();
if ( NPCInfo->nextBStateThink <= level.time )
{
trap->ICARUS_MaintainTaskManager(self->s.number);
}
VectorCopy(&self->r.currentOrigin, &self->client->ps.origin);
return;
}
// see if NPC ai is frozen
if ( d_npcfreeze.value || (NPC->r.svFlags&SVF_ICARUS_FREEZE) )
{
NPC_UpdateAngles( qtrue, qtrue );
ClientThink(self->s.number, &ucmd);
//VectorCopy(self->s.origin, self->s.origin2 );
VectorCopy(&self->r.currentOrigin, &self->client->ps.origin);
return;
}
self->nextthink = level.time + FRAMETIME/2;
while (i < MAX_CLIENTS)
{
player = &g_entities[i];
if (player->inuse && player->client && player->client->sess.sessionTeam != TEAM_SPECTATOR &&
!(player->client->ps.pm_flags & PMF_FOLLOW))
{
//if ( player->client->ps.viewEntity == self->s.number )
if (0) //rwwFIXMEFIXME: Allow controlling ents
{//being controlled by player
G_DroidSounds( self );
//FIXME: might want to at least make sounds or something?
//NPC_UpdateAngles(qtrue, qtrue);
//Which ucmd should we send? Does it matter, since it gets overridden anyway?
NPCInfo->last_ucmd.serverTime = level.time - 50;
ClientThink( NPC->s.number, &ucmd );
//VectorCopy(self->s.origin, self->s.origin2 );
VectorCopy(&self->r.currentOrigin, &self->client->ps.origin);
return;
}
}
i++;
}
if ( self->client->NPC_class == CLASS_VEHICLE)
{
if (self->client->ps.m_iVehicleNum)
{//we don't think on our own
//well, run scripts, though...
trap->ICARUS_MaintainTaskManager(self->s.number);
return;
}
else
{
VectorClear(&self->client->ps.moveDir);
self->client->pers.cmd.forwardmove = 0;
self->client->pers.cmd.rightmove = 0;
self->client->pers.cmd.upmove = 0;
self->client->pers.cmd.buttons = 0;
memcpy(&self->m_pVehicle->m_ucmd, &self->client->pers.cmd, sizeof(usercmd_t));
}
}
else if ( NPC->s.m_iVehicleNum )
{//droid in a vehicle?
G_DroidSounds( self );
}
if ( NPCInfo->nextBStateThink <= level.time
&& !NPC->s.m_iVehicleNum )//NPCs sitting in Vehicles do NOTHING
{
#if AI_TIMERS
//.........这里部分代码省略.........
开发者ID:Geptun,项目名称:japp,代码行数:101,代码来源:NPC.c
示例3: NPC_BSWander
void NPC_BSWander (void)
{//FIXME: don't actually go all the way to the next waypoint, just move in fits and jerks...?
if ( !NPCInfo->investigateDebounceTime )
{//Starting out
float minGoalReachedDistSquared = 64;//32*32;
vec3_t vec;
//Keep moving toward our tempGoal
NPCInfo->goalEntity = NPCInfo->tempGoal;
VectorSubtract ( NPCInfo->tempGoal->currentOrigin, NPC->currentOrigin, vec);
if ( NPCInfo->tempGoal->waypoint != WAYPOINT_NONE )
{
minGoalReachedDistSquared = 64;
}
if ( VectorLengthSquared( vec ) < minGoalReachedDistSquared )
{
//Close enough, just got there
NPC->waypoint = NAV_FindClosestWaypointForEnt( NPC, WAYPOINT_NONE );
if( !Q_irand(0, 1) )
{
NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_GUARD_LOOKAROUND1, SETANIM_FLAG_NORMAL);
}
else
{
NPC_SetAnim(NPC, SETANIM_BOTH, BOTH_GUARD_IDLE1, SETANIM_FLAG_NORMAL);
}
//Just got here, so Look around for a while
NPCInfo->investigateDebounceTime = level.time + Q_irand(3000, 10000);
}
else
{
//Keep moving toward goal
NPC_MoveToGoal( qtrue );
}
}
else
{
//We're there
if ( NPCInfo->investigateDebounceTime > level.time )
{
//Still waiting around for a bit
//Turn angles every now and then to look around
if ( NPCInfo->tempGoal->waypoint != WAYPOINT_NONE )
{
if ( !Q_irand( 0, 30 ) )
{
int numEdges = navigator.GetNodeNumEdges( NPCInfo->tempGoal->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
int branchNum = Q_irand( 0, numEdges - 1 );
vec3_t branchPos, lookDir;
int nextWp = navigator.GetNodeEdge( NPCInfo->tempGoal->waypoint, branchNum );
navigator.GetNodePosition( nextWp, branchPos );
VectorSubtract( branchPos, NPCInfo->tempGoal->currentOrigin, lookDir );
NPCInfo->desiredYaw = AngleNormalize360( vectoyaw( lookDir ) + Q_flrand( -45, 45 ) );
}
}
}
}
else
{//Just finished waiting
NPC->waypoint = NAV_FindClosestWaypointForEnt( NPC, WAYPOINT_NONE );
if ( NPC->waypoint != WAYPOINT_NONE )
{
int numEdges = navigator.GetNodeNumEdges( NPC->waypoint );
if ( numEdges != WAYPOINT_NONE )
{
int branchNum = Q_irand( 0, numEdges - 1 );
int nextWp = navigator.GetNodeEdge( NPC->waypoint, branchNum );
navigator.GetNodePosition( nextWp, NPCInfo->tempGoal->currentOrigin );
NPCInfo->tempGoal->waypoint = nextWp;
}
NPCInfo->investigateDebounceTime = 0;
//Start moving toward our tempGoal
NPCInfo->goalEntity = NPCInfo->tempGoal;
NPC_MoveToGoal( qtrue );
}
}
}
NPC_UpdateAngles( qtrue, qtrue );
}
开发者ID:slaytan1c,项目名称:jedioutcast,代码行数:94,代码来源:NPC_behavior.cpp
示例4: NPC_Howler_Move
//added from SP
static qboolean NPC_Howler_Move( int randomJumpChance )
{
if ( !TIMER_Done( NPC, "standing" ) )
{//standing around
return qfalse;
}
if ( NPC->client->ps.groundEntityNum == ENTITYNUM_NONE )
{//in air, don't do anything
return qfalse;
}
if ( (!NPC->enemy&&TIMER_Done( NPC, "running" )) || !TIMER_Done( NPC, "walking" ) )
{
ucmd.buttons |= BUTTON_WALKING;
}
if ( (!randomJumpChance||Q_irand( 0, randomJumpChance ))
&& NPC_MoveToGoal( qtrue ) )
{
if ( VectorCompare( NPC->client->ps.moveDir, vec3_origin )
|| !NPC->client->ps.speed )
{//uh.... wtf? Got there?
if ( NPCInfo->goalEntity )
{
NPC_FaceEntity( NPCInfo->goalEntity, qfalse );
}
else
{
NPC_UpdateAngles( qfalse, qtrue );
}
return qtrue;
}
//TEMP: don't want to strafe
VectorClear( NPC->client->ps.moveDir );
ucmd.rightmove = 0.0f;
// Com_Printf( "Howler moving %d\n",ucmd.forwardmove );
//if backing up, go slow...
if ( ucmd.forwardmove < 0.0f )
{
ucmd.buttons |= BUTTON_WALKING;
//if ( NPC->client->ps.speed > NPCInfo->stats.walkSpeed )
{//don't walk faster than I'm allowed to
NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
}
}
else
{
if ( (ucmd.buttons&BUTTON_WALKING) )
{
NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
}
else
{
NPC->client->ps.speed = NPCInfo->stats.runSpeed;
}
}
NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw = NPCInfo->lastPathAngles[YAW];
NPC_UpdateAngles( qfalse, qtrue );
}
else if ( NPCInfo->goalEntity )
{//couldn't get where we wanted to go, try to jump there
NPC_FaceEntity( NPCInfo->goalEntity, qfalse );
NPC_TryJump_Gent( NPCInfo->goalEntity, 400.0f, -256.0f );
}
return qtrue;
}
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:65,代码来源:NPC_AI_Howler.cpp
示例5: Interrogator_MaintainHeight
/*
-------------------------
Interrogator_MaintainHeight
-------------------------
*/
void Interrogator_MaintainHeight( void )
{
float dif;
// vec3_t endPos;
// trace_t trace;
NPC->s.loopSound = G_SoundIndex( "sound/chars/interrogator/misc/torture_droid_lp" );
// Update our angles regardless
NPC_UpdateAngles( qtrue, qtrue );
// If we have an enemy, we should try to hover at about enemy eye level
if ( NPC->enemy )
{
// Find the height difference
dif = (NPC->enemy->currentOrigin[2] + NPC->enemy->maxs[2]) - NPC->currentOrigin[2];
// cap to prevent dramatic height shifts
if ( fabs( dif ) > 2 )
{
if ( fabs( dif ) > 16 )
{
dif = ( dif < 0 ? -16 : 16 );
}
NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
}
}
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 )
{
ucmd.upmove = ( ucmd.upmove < 0 ? -4 : 4 );
}
else
{
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;
}
}
}
}
// Apply friction
else if ( NPC->client->ps.velocity[2] )
{
NPC->client->ps.velocity[2] *= VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[2] ) < 1 )
{
NPC->client->ps.velocity[2] = 0;
}
}
}
// 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;
}
}
}
开发者ID:Almightygir,项目名称:OpenJK,代码行数:98,代码来源:AI_Interrogator.cpp
示例6: NPC_BSGrenadier_Attack
void NPC_BSGrenadier_Attack( void )
{
//Don't do anything if we're hurt
if ( NPC->painDebounceTime > level.time )
{
NPC_UpdateAngles( qtrue, qtrue );
return;
}
//NPC_CheckEnemy( qtrue, qfalse );
//If we don't have an enemy, just idle
if ( NPC_CheckEnemyExt() == qfalse )//!NPC->enemy )//
{
NPC->enemy = NULL;
NPC_BSGrenadier_Patrol();//FIXME: or patrol?
return;
}
if ( TIMER_Done( NPC, "flee" ) && NPC_CheckForDanger( NPC_CheckAlertEvents( qtrue, qtrue, -1, qfalse, AEL_DANGER ) ) )
{//going to run
NPC_UpdateAngles( qtrue, qtrue );
return;
}
if ( !NPC->enemy )
{//WTF? somehow we lost our enemy?
NPC_BSGrenadier_Patrol();//FIXME: or patrol?
return;
}
enemyLOS = enemyCS = qfalse;
move = qtrue;
faceEnemy = qfalse;
shoot = qfalse;
enemyDist = DistanceSquared( NPC->enemy->currentOrigin, NPC->currentOrigin );
//See if we should switch to melee attack
if ( enemyDist < 16384 && (!NPC->enemy->client||NPC->enemy->client->ps.weapon != WP_SABER||!NPC->enemy->client->ps.saberActive) )//128
{//enemy is close and not using saber
if ( NPC->client->ps.weapon == WP_THERMAL )
{//grenadier
trace_t trace;
gi.trace ( &trace, NPC->currentOrigin, NPC->enemy->mins, NPC->enemy->maxs, NPC->enemy->currentOrigin, NPC->s.number, NPC->enemy->clipmask );
if ( !trace.allsolid && !trace.startsolid && (trace.fraction == 1.0 || trace.entityNum == NPC->enemy->s.number ) )
{//I can get right to him
//reset fire-timing variables
NPC_ChangeWeapon( WP_MELEE );
if ( !(NPCInfo->scriptFlags&SCF_CHASE_ENEMIES) )//NPCInfo->behaviorState == BS_STAND_AND_SHOOT )
{//FIXME: should we be overriding scriptFlags?
NPCInfo->scriptFlags |= SCF_CHASE_ENEMIES;//NPCInfo->behaviorState = BS_HUNT_AND_KILL;
}
}
}
}
else if ( enemyDist > 65536 || (NPC->enemy->client && NPC->enemy->client->ps.weapon == WP_SABER && NPC->enemy->client->ps.saberActive) )//256
{//enemy is far or using saber
if ( NPC->client->ps.weapon == WP_MELEE && (NPC->client->ps.stats[STAT_WEAPONS]&(1<<WP_THERMAL)) )
{//fisticuffs, make switch to thermal if have it
//reset fire-timing variables
NPC_ChangeWeapon( WP_THERMAL );
}
}
//can we see our target?
if ( NPC_ClearLOS( NPC->enemy ) )
{
NPCInfo->enemyLastSeenTime = level.time;
enemyLOS = qtrue;
if ( NPC->client->ps.weapon == WP_MELEE )
{
if ( enemyDist <= 4096 && InFOV( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 90, 45 ) )//within 64 & infront
{
VectorCopy( NPC->enemy->currentOrigin, NPCInfo->enemyLastSeenLocation );
enemyCS = qtrue;
}
}
else if ( InFOV( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 45, 90 ) )
{//in front of me
//can we shoot our target?
//FIXME: how accurate/necessary is this check?
int hit = NPC_ShotEntity( NPC->enemy );
gentity_t *hitEnt = &g_entities[hit];
if ( hit == NPC->enemy->s.number
|| ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) )
{
VectorCopy( NPC->enemy->currentOrigin, NPCInfo->enemyLastSeenLocation );
float enemyHorzDist = DistanceHorizontalSquared( NPC->enemy->currentOrigin, NPC->currentOrigin );
if ( enemyHorzDist < 1048576 )
{//within 1024
enemyCS = qtrue;
NPC_AimAdjust( 2 );//adjust aim better longer we have clear shot at enemy
}
else
{
NPC_AimAdjust( 1 );//adjust aim better longer we can see enemy
}
}
}
}
//.........这里部分代码省略.........
开发者ID:blaenk,项目名称:jedioutcast,代码行数:101,代码来源:AI_Grenadier.cpp
示例7: NPC_BSSandCreature_Default
void NPC_BSSandCreature_Default( void )
{
qboolean visible = qfalse;
//clear it every frame, will be set if we actually move this frame...
NPC->s.loopSound = 0;
if ( NPC->health > 0 && TIMER_Done( NPC, "breaching" ) )
{//go back to non-solid mode
if ( NPC->contents )
{
NPC->contents = 0;
}
if ( NPC->clipmask == MASK_NPCSOLID )
{
NPC->clipmask = CONTENTS_SOLID|CONTENTS_MONSTERCLIP;
}
if ( TIMER_Done( NPC, "speaking" ) )
{
G_SoundOnEnt( NPC, CHAN_VOICE, va( "sound/chars/sand_creature/voice%d.mp3", Q_irand( 1, 3 ) ) );
TIMER_Set( NPC, "speaking", Q_irand( 3000, 10000 ) );
}
}
else
{//still in breaching anim
visible = qtrue;
//FIXME: maybe push things up/away and maybe knock people down when doing this?
//FIXME: don't turn while breaching?
//FIXME: move faster while breaching?
//NOTE: shaking now done whenever he moves
}
//FIXME: when in start and end of attack/pain anims, need ground disturbance effect around him
// NOTENOTE: someone stubbed this code in, so I figured I'd use it. The timers are all weird, ie, magic numbers that sort of work,
// but maybe I'll try and figure out real values later if I have time.
if ( NPC->client->ps.legsAnim == BOTH_ATTACK1
|| NPC->client->ps.legsAnim == BOTH_ATTACK2 )
{//FIXME: get start and end frame numbers for this effect for each of these anims
vec3_t up={0,0,1};
vec3_t org;
VectorCopy( NPC->currentOrigin, org );
org[2] -= 40;
if ( NPC->client->ps.legsAnimTimer > 3700 )
{
// G_PlayEffect( G_EffectIndex( "env/sand_dive" ), NPC->currentOrigin, up );
G_PlayEffect( G_EffectIndex( "env/sand_spray" ), org, up );
}
else if ( NPC->client->ps.legsAnimTimer > 1600 && NPC->client->ps.legsAnimTimer < 1900 )
{
G_PlayEffect( G_EffectIndex( "env/sand_spray" ), org, up );
}
//G_PlayEffect( G_EffectIndex( "env/sand_attack_breach" ), org, up );
}
if ( !TIMER_Done( NPC, "pain" ) )
{
visible = qtrue;
}
else if ( !TIMER_Done( NPC, "attacking" ) )
{
visible = qtrue;
}
else
{
if ( NPC->activator )
{//kill and remove the guy we ate
//FIXME: want to play ...? What was I going to say?
NPC->activator->health = 0;
GEntity_DieFunc( NPC->activator, NPC, NPC, 1000, MOD_MELEE, 0, HL_NONE );
if ( NPC->activator->s.number )
{
G_FreeEntity( NPC->activator );
}
else
{//can't remove the player, just make him invisible
NPC->client->ps.eFlags |= EF_NODRAW;
}
NPC->activator = NPC->enemy = NPCInfo->goalEntity = NULL;
}
if ( NPC->enemy )
{
SandCreature_Chase();
}
else if ( (level.time - NPCInfo->enemyLastSeenTime) < 5000 )//FIXME: should make this able to be variable
{//we were alerted recently, move towards there and look for footsteps, etc.
SandCreature_Hunt();
}
else
{//no alerts, sleep and wake up only by alerts
//FIXME: keeps chasing goalEntity even when it's already reached it!
SandCreature_Sleep();
}
}
NPC_UpdateAngles( qtrue, qtrue );
if ( !visible )
{
NPC->client->ps.eFlags |= EF_NODRAW;
NPC->s.eFlags |= EF_NODRAW;
//.........这里部分代码省略.........
开发者ID:AlexXT,项目名称:OpenJK,代码行数:101,代码来源:AI_SandCreature.cpp
示例8: Seeker_MaintainHeight
//------------------------------------
void Seeker_MaintainHeight( void )
{
float dif;
// Update our angles regardless
NPC_UpdateAngles( qtrue, qtrue );
// 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_flrand( NPC->enemy->maxs[2]/2, 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 );
}
NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
}
}
}
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 )
{
ucmd.upmove = ( ucmd.upmove < 0 ? -4 : 4 );
}
else
{
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;
}
}
}
}
}
// 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;
}
}
}
开发者ID:AlexXT,项目名称:OpenJK,代码行数:86,代码来源:AI_Seeker.cpp
示例9: NPC_BSHuntAndKill
void NPC_BSHuntAndKill( void )
{
qboolean turned = qfalse;
vec3_t vec;
float enemyDist;
visibility_t oEVis;
int curAnim;
NPC_CheckEnemy( NPCInfo->tempBehavior != BS_HUNT_AND_KILL, qfalse, qtrue );//don't find new enemy if this is tempbehav
if ( NPC->enemy )
{
oEVis = enemyVisibility = NPC_CheckVisibility ( NPC->enemy, CHECK_FOV|CHECK_SHOOT );//CHECK_360|//CHECK_PVS|
if(enemyVisibility > VIS_PVS)
{
if ( !NPC_EnemyTooFar( NPC->enemy, 0, qtrue ) )
{//Enemy is close enough to shoot - FIXME: this next func does this also, but need to know here for info on whether ot not to turn later
NPC_CheckCanAttack( 1.0, qfalse );
turned = qtrue;
}
}
curAnim = NPC->client->ps.legsAnim;
if(curAnim != BOTH_ATTACK1 && curAnim != BOTH_ATTACK2 && curAnim != BOTH_ATTACK3 && curAnim != BOTH_MELEE1 && curAnim != BOTH_MELEE2 )
{//Don't move toward enemy if we're in a full-body attack anim
//FIXME, use IdealDistance to determin if we need to close distance
VectorSubtract(NPC->enemy->r.currentOrigin, NPC->r.currentOrigin, vec);
enemyDist = VectorLength(vec);
if( enemyDist > 48 && ((enemyDist*1.5)*(enemyDist*1.5) >= NPC_MaxDistSquaredForWeapon() ||
oEVis != VIS_SHOOT ||
//!(ucmd.buttons & BUTTON_ATTACK) ||
enemyDist > IdealDistance(NPC)*3 ) )
{//We should close in?
NPCInfo->goalEntity = NPC->enemy;
NPC_MoveToGoal( qtrue );
}
else if(enemyDist < IdealDistance(NPC))
{//We should back off?
//if(ucmd.buttons & BUTTON_ATTACK)
{
NPCInfo->goalEntity = NPC->enemy;
NPCInfo->goalRadius = 12;
NPC_MoveToGoal( qtrue );
ucmd.forwardmove *= -1;
ucmd.rightmove *= -1;
VectorScale( NPC->client->ps.moveDir, -1, NPC->client->ps.moveDir );
ucmd.buttons |= BUTTON_WALKING;
}
}//otherwise, stay where we are
}
}
else
{//ok, stand guard until we find an enemy
if( NPCInfo->tempBehavior == BS_HUNT_AND_KILL )
{
NPCInfo->tempBehavior = BS_DEFAULT;
}
else
{
NPCInfo->tempBehavior = BS_STAND_GUARD;
NPC_BSStandGuard();
}
return;
}
if(!turned)
{
NPC_UpdateAngles(qtrue, qtrue);
}
}
开发者ID:Camron,项目名称:OpenJK,代码行数:73,代码来源:NPC_AI_Default.c
示例10: 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[0]+MIN_DISTANCE) ? qtrue : qfalse );
doCharge = qfalse;
if ( advance )
{//have to get closer
vec3_t yawOnlyAngles;
VectorSet( yawOnlyAngles, 0, NPC->r.currentAngles[YAW], 0 );
if ( NPC->enemy->health > 0
&& fabs(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( 1 );
}
}
else
{
Rancor_Attack( distance, doCharge );
}
}
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:80,代码来源:NPC_AI_Rancor.c
示例11: NPC_BSRancor_Default
/*
-------------------------
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;
//.........这里部分代码省略.........
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:101,代码来源:NPC_AI_Rancor.c
示例12: Sentry_MaintainHeight
/*
-------------------------
Sentry_MaintainHeight
-------------------------
*/
void Sentry_MaintainHeight( void )
{
float dif;
NPC->s.loopSound = G_SoundIndex( "sound/chars/sentry/misc/sentry_hover_1_lp" );
// Update our angles regardless
NPC_UpdateAngles( qtrue, qtrue );
// If we have an enemy, we should try to hover at about enemy eye level
if ( NPC->enemy )
{
// Find the height difference
dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2];
// cap to prevent dramatic height shifts
if ( fabs( dif ) > 8 )
{
if ( fabs( dif ) > SENTRY_HOVER_HEIGHT )
{
dif = ( dif < 0 ? -24 : 24 );
}
NPC->client->ps.velocity[2] = (NPC->client->ps.velocity[2]+dif)/2;
}
}
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 ) > SENTRY_HOVER_HEIGHT )
{
ucmd.upmove = ( ucmd.upmove < 0 ? -4 : 4 );
}
else
{
if ( NPC->client->ps.velocity[2] )
{
NPC->client->ps.velocity[2] *= SENTRY_VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[2] ) < 2 )
{
NPC->client->ps.velocity[2] = 0;
}
}
}
}
// Apply friction to Z
else if ( NPC->client->ps.velocity[2] )
{
NPC->client->ps.velocity[2] *= SENTRY_VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[2] ) < 1 )
{
NPC->client->ps.velocity[2] = 0;
}
}
}
// Apply friction
if ( NPC->client->ps.velocity[0] )
{
NPC->client->ps.velocity[0] *= SENTRY_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] *= SENTRY_VELOCITY_DECAY;
if ( fabs( NPC->client->ps.velocity[1] ) < 1 )
{
NPC->client->ps.velocity[1] = 0;
}
}
NPC_FaceEnemy( qtrue );
}
开发者ID:Avygeil,项目名称:NewJK,代码行数:100,代码来源:AI_Sentry.cpp
示例13: NPC_BSWampa_Default
/*
-------------------------
NPC_BSWampa_Default
-------------------------
*/
void NPC_BSWampa_Default( void )
{
NPC->client->ps.eFlags2 &= ~EF2_USE_ALT_ANIM;
//NORMAL ANIMS
// stand1 = normal stand
// walk1 = normal, non-angry walk
// walk2 = injured
// run1 = far away run
// run2 = close run
//VICTIM ANIMS
// grabswipe = melee1 - sweep out and grab
// stand2 attack = attack4 - while holding victim, swipe at him
// walk3_drag = walk5 - walk with drag
// stand2 = hold victim
// stand2to1 = drop victim
if ( !TIMER_Done( NPC, "rageTime" ) )
{//do nothing but roar first time we see an enemy
NPC_FaceEnemy( qtrue );
return;
}
if ( NPC->enemy )
{
if ( !TIMER_Done(NPC,"attacking") )
{//in middle of attack
//face enemy
NPC_FaceEnemy( qtrue );
//continue attack logic
enemyDist = Distance( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
Wampa_Attack( enemyDist, qfalse );
return;
}
else
{
if ( TIMER_Done(NPC,"angrynoise") )
{
G_Sound( NPC, CHAN_VOICE, G_SoundIndex( va("sound/chars/wampa/misc/anger%d.wav", Q_irand(1, 2)) ) );
TIMER_Set( NPC, "angrynoise", Q_irand( 5000, 10000 ) );
}
//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_WAMPA )
{//got mad at another Wampa, look for a valid enemy
if ( TIMER_Done( NPC, "wampaInfight" ) )
{
NPC_CheckEnemyExt( qtrue );
}
}
else
{
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;
Wampa_Patrol();
NPC_UpdateAngles( qtrue, qtrue );
//just lost my enemy
if ( (NPC->spawnflags&2) )
{//search around me if I don't have an enemy
NPC_BSSearchStart( NPC->waypoint, BS_SEARCH );
NPCInfo->tempBehavior = BS_DEFAULT;
}
else if ( (NPC->spawnflags&1) )
{//wander if I don't have an enemy
NPC_BSSearchStart( NPC->waypoint, BS_WANDER );
NPCInfo->tempBehavior = BS_DEFAULT;
}
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 ) );
}
}
}
Wampa_Combat();
return;
}
}
else
//.........这里部分代码省略.........
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:101,代码来源:NPC_AI_Wampa.cpp
示例14: NPC_BSGM_Attack
void NPC_BSGM_Attack( void )
{
//Don't do anything if we're hurt
if ( NPC->painDebounceTime > level.time )
{
NPC_UpdateAngles( qtrue, qtrue );
return;
}
//FIXME: if killed enemy, use victory anim
if ( NPC->enemy && NPC->enemy->health <= 0
&& !NPC->enemy->s.number )
{//my enemy is dead
if ( NPC->client->ps.torsoAnim == BOTH_STAND2TO1 )
{
if ( NPC->client->ps.torsoAnimTimer <= 500 )
{
G_AddVoiceEvent( NPC, Q_irand( EV_VICTORY1, EV_VICTORY3 ), 3000 );
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_TRIUMPHANT1START, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
NPC->client->ps.legsAnimTimer += 500;
NPC->client->ps.torsoAnimTimer += 500;
}
}
else if ( NPC->client->ps.torsoAnim == BOTH_TRIUMPHANT1START )
{
if ( NPC->client->ps.torsoAnimTimer <= 500 )
{
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_TRIUMPHANT1STARTGESTURE, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
NPC->client->ps.legsAnimTimer += 500;
NPC->client->ps.torsoAnimTimer += 500;
}
}
else if ( NPC->client->ps.torsoAnim == BOTH_TRIUMPHANT1STARTGESTURE )
{
if ( NPC->client->ps.torsoAnimTimer <= 500 )
{
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_TRIUMPHANT1STOP, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
NPC->client->ps.legsAnimTimer += 500;
NPC->client->ps.torsoAnimTimer += 500;
}
}
else if ( NPC->client->ps.torsoAnim == BOTH_TRIUMPHANT1STOP )
{
if ( NPC->client->ps.torsoAnimTimer <= 500 )
{
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_STAND1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
NPC->client->ps.legsAnimTimer = -1;
NPC->client->ps.torsoAnimTimer = -1;
}
}
else if ( NPC->wait )
{
if ( TIMER_Done( NPC, "gloatTime" ) )
{
GM_StartGloat();
}
else if ( DistanceHorizontalSquared( NPC->client->renderInfo.eyePoint, NPC->enemy->currentOrigin ) > 4096 && (NPCInfo->scriptFlags&SCF_CHASE_ENEMIES) )//64 squared
{
NPCInfo->goalEntity = NPC->enemy;
GM_Move();
}
else
{//got there
GM_StartGloat();
}
}
NPC_FaceEnemy( qtrue );
NPC_UpdateAngles( qtrue, qtrue );
return;
}
//If we don't have an enemy, just idle
if ( NPC_CheckEnemyExt() == qfalse || !NPC->enemy )
{
NPC->enemy = NULL;
NPC_BSGM_Patrol();
return;
}
enemyLOS = enemyCS = qfalse;
bMove = qtrue;
faceEnemy = qfalse;
shoot = qfalse;
hitAlly = qfalse;
VectorClear( impactPos );
enemyDist = DistanceSquared( NPC->currentOrigin, NPC->enemy->currentOrigin );
if ( NPC->client->ps.torsoAnim == BOTH_ATTACK4 ||
NPC->client->ps.torsoAnim == BOTH_ATTACK5 )
{
shoot = qfalse;
if ( TIMER_Done( NPC, "smackTime" ) && !NPCInfo->blockedDebounceTime )
{//time to smack
//recheck enemyDist and InFront
if ( enemyDist < MELEE_DIST_SQUARED && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) )
{
vec3_t smackDir;
VectorSubtract( NPC->enemy->currentOrigin, NPC->currentOrigin, smackDir );
smackDir[2] += 30;
VectorNormalize( smackDir );
//hurt them
//.........这里部分代码省略.........
开发者ID:PJayB,项目名称:jk2src,代码行数:101,代码来源:AI_GalakMech.cpp
示例15: Droid_Patrol
/*
-------------------------
Droid_Patrol
-------------------------
*/
void Droid_Patrol( void )
{
NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]);
if ( NPC->client && NPC->client->NPC_class != CLASS_GONK )
{
if (NPC->client->NPC_class != CLASS_R5D2)
{ //he doesn't have an eye.
R2D2_PartsMove(); // Get his eye moving.
}
R2D2_TurnAnims();
}
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
ucmd.buttons |= BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
if( NPC->client && NPC->client->NPC_class == CLASS_MOUSE )
{
NPCInfo->desiredYaw += sin(level.time*.5) * 25; // Weaves side to side a little
if (TIMER_Done(NPC,"patrolNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/mouse/misc/mousego%d.wav", Q_irand(1, 3)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
}
}
else if( NPC->client && NPC->client->NPC_class == CLASS_R2D2 )
{
if (TIMER_Done(NPC,"patrolNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/r2d2/misc/r2d2talk0%d.wav", Q_irand(1, 3)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
}
}
else if( NPC->client && NPC->client->NPC_class == CLASS_R5D2 )
{
if (TIMER_Done(NPC,"patrolNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/r5d2/misc/r5talk%d.wav", Q_irand(1, 4)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
}
}
if( NPC->client && NPC->client->NPC_class == CLASS_GONK )
{
if (TIMER_Done(NPC,"patrolNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/gonk/misc/gonktalk%d.wav", Q_irand(1, 2)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 2000, 4000 ) );
}
}
// else
// {
// R5D2_LookAround();
// }
}
NPC_UpdateAngles( qtrue, qtrue );
}
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:72,代码来源:NPC_AI_Droid.cpp
示例16: NPC_BSStandAndShoot
void NPC_BSStandAndShoot (void)
{
//FIXME:
//When our numbers outnumber enemies 3 to 1, or only one of them,
//go into hunt and kill mode
//FIXME:
//When they're all dead, go to some script or wander off to sickbay?
if(NPC->client->playerTeam && NPC->client->enemyTeam)
{
//FIXME: don't realize this right away- or else enemies show up and we're standing around
/*
if( teamNumbers[NPC->enemyTeam] == 0 )
{//ok, stand guard until we find another enemy
//reset our rush counter
teamCounter[NPC->playerTeam] = 0;
NPCInfo->tempBehavior = BS_STAND_GUARD;
NPC_BSStandGuard();
return;
}*/
/*
//FIXME: whether to do this or not should be settable
else if( NPC->playerTeam != TEAM_BORG )//Borg don't rush
{
//FIXME: In case reinforcements show up, we should wait a few seconds
//and keep checking before rushing!
//Also: what if not everyone on our team is going after playerTeam?
//Also: our team count includes medics!
if(NPC->health > 25)
{//Can we rush the enemy?
if(teamNumbers[NPC->enemyTeam] == 1 ||
teamNumbers[NPC->playerTeam] >= teamNumbers[NPC->enemyTeam]*3)
{//Only one of them or we outnumber 3 to 1
if(teamStrength[NPC->playerTeam] >= 75 ||
(teamStrength[NPC->playerTeam] >= 50 && teamStrength[NPC->playerTeam] > teamStrength[NPC->enemyTeam]))
{//Our team is strong enough to rush
teamCounter[NPC->playerTeam]++;
if(teamNumbers[NPC->playerTeam] * 17 <= teamCounter[NPC->playerTeam])
{//ok, we waited 1.7 think cycles on average and everyone is go, let's do it!
//FIXME: Should we do this to everyone on our team?
NPCInfo->behaviorState = BS_HUNT_AND_KILL;
//FIXME: if the tide changes, we should retreat!
//FIXME: when do we reset the counter?
NPC_BSHuntAndKill ();
return;
}
}
else//Oops! Something's wrong, reset the counter to rush
teamCounter[NPC->playerTeam] = 0;
}
else//Oops! Something's wrong, reset the counter to rush
teamCounter[NPC->playerTeam] = 0;
}
}
*/
}
NPC_CheckEnemy(qtrue, qfalse, qtrue);
if(NPCInfo->duckDebounceTime > level.time && NPC->client->ps.weapon != WP_SABER )
{
ucmd.upmove = -127;
if(NPC->enemy)
{
NPC_CheckCanAttack(1.0, qtrue);
}
return;
}
i
|
请发表评论