本文整理汇总了C++中NPC_ClearLOS4函数的典型用法代码示例。如果您正苦于以下问题:C++ NPC_ClearLOS4函数的具体用法?C++ NPC_ClearLOS4怎么用?C++ NPC_ClearLOS4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NPC_ClearLOS4函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Seeker_Attack
//------------------------------------
void Seeker_Attack( void )
{
float distance;
qboolean visible, advance;
// Always keep a good height off the ground
Seeker_MaintainHeight();
// Rate our distance to the target, and our visibilty
distance = DistanceHorizontalSquared( NPCS.NPC->r.currentOrigin, NPCS.NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPCS.NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
if ( NPCS.NPC->client->NPC_class == CLASS_BOBAFETT )
{
advance = (qboolean)(distance>(200.0f*200.0f));
}
// If we cannot see our target, move to see it
if ( visible == qfalse )
{
if ( NPCS.NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Seeker_Hunt( visible, advance );
return;
}
}
Seeker_Ranged( visible, advance );
}
开发者ID:Avygeil,项目名称:NewJK,代码行数:31,代码来源:NPC_AI_Seeker.c
示例2: Sentry_AttackDecision
/*
-------------------------
Sentry_AttackDecision
-------------------------
*/
void Sentry_AttackDecision( void )
{
float distance;
qboolean visible;
qboolean advance;
// Always keep a good height off the ground
Sentry_MaintainHeight();
NPC->s.loopSound = G_SoundIndex( "sound/chars/sentry/misc/sentry_hover_2_lp" );
//randomly talk
if ( TIMER_Done(NPC,"patrolNoise") )
{
if (TIMER_Done(NPC,"angerNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/sentry/misc/talk%d", Q_irand(1, 3)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 4000, 10000 ) );
}
}
// He's dead.
if (NPC->enemy->health<1)
{
NPC->enemy = NULL;
Sentry_Idle();
return;
}
// If we don't have an enemy, just idle
if ( NPC_CheckEnemyExt(qfalse) == qfalse )
{
Sentry_Idle();
return;
}
// Rate our distance to the target and visibilty
distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
// If we cannot see our target, move to see it
if ( visible == qfalse )
{
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Sentry_Hunt( visible, advance );
return;
}
}
NPC_FaceEnemy( qtrue );
Sentry_RangedAttack( visible, advance );
}
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:61,代码来源:NPC_AI_Sentry.cpp
示例3: Seeker_FindEnemy
//------------------------------------
void Seeker_FindEnemy( void )
{
int numFound;
float dis, bestDis = SEEKER_SEEK_RADIUS * SEEKER_SEEK_RADIUS + 1;
vec3_t mins, maxs;
int entityList[MAX_GENTITIES];
gentity_t *ent, *best = NULL;
int i;
VectorSet( maxs, SEEKER_SEEK_RADIUS, SEEKER_SEEK_RADIUS, SEEKER_SEEK_RADIUS );
VectorScale( maxs, -1, mins );
numFound = trap->EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
for ( i = 0 ; i < numFound ; i++ )
{
ent = &g_entities[entityList[i]];
if ( ent->s.number == NPCS.NPC->s.number
|| !ent->client //&& || !ent->NPC
|| ent->health <= 0
|| !ent->inuse )
{
continue;
}
if ( ent->client->playerTeam == NPCS.NPC->client->playerTeam || ent->client->playerTeam == NPCTEAM_NEUTRAL ) // don't attack same team or bots
{
continue;
}
// try to find the closest visible one
if ( !NPC_ClearLOS4( ent ))
{
continue;
}
dis = DistanceHorizontalSquared( NPCS.NPC->r.currentOrigin, ent->r.currentOrigin );
if ( dis <= bestDis )
{
bestDis = dis;
best = ent;
}
}
if ( best )
{
// used to offset seekers around a circle so they don't occupy the same spot. This is not a fool-proof method.
NPCS.NPC->random = Q_flrand(0.0f, 1.0f) * 6.3f; // roughly 2pi
NPCS.NPC->enemy = best;
}
}
开发者ID:Avygeil,项目名称:NewJK,代码行数:55,代码来源:NPC_AI_Seeker.c
示例4: ATST_Attack
void ATST_Attack( void ) {
qboolean altAttack = qfalse, visible = qfalse, advance = qfalse;
int blasterTest, chargerTest;
float distance;
if ( !NPC_CheckEnemyExt( qfalse ) ) {
NPC->enemy = NULL;
return;
}
NPC_FaceEnemy( qtrue );
// Rate our distance to the target, and our visibilty
distance = (int)DistanceHorizontalSquared( &NPC->r.currentOrigin, &NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPC->enemy ) ? qtrue : qfalse;
advance = (distance > MIN_DISTANCE_SQR) ? qtrue : qfalse;
// If we cannot see our target, move to see it
if ( !visible ) {
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES ) {
ATST_Hunt( visible, advance );
return;
}
}
// Decide what type of attack to do
if ( distance > MIN_MELEE_RANGE_SQR ) {
// DIST_LONG
// NPC_ChangeWeapon( WP_ATST_SIDE );
//rwwFIXMEFIXME: make atst weaps work.
// See if the side weapons are there
blasterTest = trap->G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "head_light_blaster_cann" );
chargerTest = trap->G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "head_concussion_charger" );
// It has both side weapons
if ( blasterTest != -1 && !(blasterTest & TURN_OFF) && chargerTest != -1 && !(chargerTest & TURN_OFF) )
altAttack = Q_irand( 0, 1 ) ? qtrue : qfalse;
else if ( blasterTest != -1 && !(blasterTest & TURN_OFF) )
altAttack = qfalse;
else if ( chargerTest != -1 && !(chargerTest & TURN_OFF) )
altAttack = qtrue;
else
NPC_ChangeWeapon( WP_NONE );
}
else {
// DIST_MELEE
// NPC_ChangeWeapon( WP_ATST_MAIN );
}
NPC_FaceEnemy( qtrue );
ATST_Ranged( visible, advance, altAttack );
}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:53,代码来源:NPC_AI_Atst.cpp
示例5: ImperialProbe_AttackDecision
void ImperialProbe_AttackDecision( void )
{
float distance;
qboolean visible;
qboolean advance;
// Always keep a good height off the ground
ImperialProbe_MaintainHeight();
//randomly talk
if ( TIMER_Done(NPC,"patrolNoise") )
{
if (TIMER_Done(NPC,"angerNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/probe/misc/probetalk%d", Q_irand(1, 3)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 4000, 10000 ) );
}
}
// If we don't have an enemy, just idle
if ( NPC_CheckEnemyExt(qfalse) == qfalse )
{
ImperialProbe_Idle();
return;
}
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1, SETANIM_FLAG_NORMAL);
// Rate our distance to the target, and our visibilty
distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
// If we cannot see our target, move to see it
if ( visible == qfalse )
{
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
ImperialProbe_Hunt( visible, advance );
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 );
// Decide what type of attack to do
ImperialProbe_Ranged( visible, advance );
}
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:50,代码来源:NPC_AI_ImperialProbe.c
示例6: Seeker_Attack
void Seeker_Attack( void )
{
float distance;
qboolean visible;
qboolean advance;
// Always keep a good height off the ground
Seeker_MaintainHeight();
// Rate our distance to the target, and our visibilty
distance = DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
//[SeekerItemNpc]
//dont shoot at dead people
if(!NPC->enemy->inuse || NPC->enemy->health <= 0) {
NPC->enemy = NULL;
return;
}
//[/SeekerItemNpc]
if ( NPC->client->NPC_class == CLASS_BOBAFETT )
{
advance = (qboolean)(distance>(200.0f*200.0f));
}
// If we cannot see our target, move to see it
if ( visible == qfalse )
{
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Seeker_Hunt( visible, advance );
return;
}
//[SeekerItemNpc]
else {
//we cant chase them? then return to the follow target
NPC->enemy = NULL;
if(NPC->client->leader)
NPCInfo->goalEntity = NPC->client->leader;
return;
}
//[/SeekerItemNpc]
}
Seeker_Ranged( visible, advance );
}
开发者ID:jwginge,项目名称:ojpa,代码行数:49,代码来源:NPC_AI_Seeker.c
示例7: Interrogator_Attack
/*
-------------------------
Interrogator_Attack
-------------------------
*/
void Interrogator_Attack( void )
{
float distance;
qboolean visible;
qboolean advance;
// Always keep a good height off the ground
Interrogator_MaintainHeight();
//randomly talk
if ( TIMER_Done(NPC,"patrolNoise") )
{
if (TIMER_Done(NPC,"angerNoise"))
{
G_SoundOnEnt( NPC, CHAN_AUTO, va("sound/chars/probe/misc/talk.wav", Q_irand(1, 3)) );
TIMER_Set( NPC, "patrolNoise", Q_irand( 4000, 10000 ) );
}
}
// If we don't have an enemy, just idle
if ( NPC_CheckEnemyExt(qfalse) == qfalse )
{
Interrogator_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 );
advance = (qboolean)(distance > MIN_DISTANCE*MIN_DISTANCE );
if ( !visible )
{
advance = qtrue;
}
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
Interrogator_Hunt( visible, advance );
}
NPC_FaceEnemy( qtrue );
if (!advance)
{
Interrogator_Melee( visible, advance );
}
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:53,代码来源:NPC_AI_Interrogator.c
示例8: NPC_TargetVisible
qboolean NPC_TargetVisible( gentity_t *ent )
{
//Make sure we're in a valid range
if ( DistanceSquared( ent->r.currentOrigin, NPC->r.currentOrigin ) > ( NPCInfo->stats.visrange * NPCInfo->stats.visrange ) )
return qfalse;
//Check our FOV
if ( InFOV( ent, NPC, NPCInfo->stats.hfov, NPCInfo->stats.vfov ) == qfalse )
return qfalse;
//Check for sight
if ( NPC_ClearLOS4( ent ) == qfalse )
return qfalse;
return qtrue;
}
开发者ID:jwginge,项目名称:ojpa,代码行数:16,代码来源:NPC_utils.c
示例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 );
}
开发者ID:jwginge,项目名称:ojpa,代码行数:51,代码来源:NPC_AI_Remote.c
示例10: 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();
}
}
开发者ID:Geptun,项目名称:japp,代码行数:40,代码来源:NPC_AI_MineMonster.c
示例11: NPC_BSHowler_Default
//replaced with SP version.
void NPC_BSHowler_Default( void )
{
if ( NPC->client->ps.legsAnim != BOTH_GESTURE1 )
{
NPC->count = 0;
}
//FIXME: if in jump, do damage in front and maybe knock them down?
if ( !TIMER_Done( NPC, "attacking" ) )
{
if ( NPC->enemy )
{
//NPC_FaceEnemy( qfalse );
Howler_Attack( Distance( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin ), qfalse );
}
else
{
//NPC_UpdateAngles( qfalse, qtrue );
Howler_Attack( 0.0f, qfalse );
}
NPC_UpdateAngles( qfalse, qtrue );
return;
}
if ( NPC->enemy )
{
if ( NPCInfo->stats.aggression > 0 )
{
if ( TIMER_Done( NPC, "aggressionDecay" ) )
{
NPCInfo->stats.aggression--;
TIMER_Set( NPC, "aggressionDecay", 500 );
}
}
//RAFIXME - No fleeing, need to fix this at some point.
/*
if ( !TIMER_Done( NPC, "flee" )
&& NPC_BSFlee() ) //this can clear ENEMY
{//successfully trying to run away
return;
}
*/
if ( NPC->enemy == NULL)
{
NPC_UpdateAngles( qfalse, qtrue );
return;
}
if ( NPCInfo->localState == LSTATE_FLEE )
{//we were fleeing, now done (either timer ran out or we cannot flee anymore
if ( NPC_ClearLOS4( NPC->enemy ) )
{//if enemy is still around, go berzerk
NPCInfo->localState = LSTATE_BERZERK;
}
else
{//otherwise, lick our wounds?
NPCInfo->localState = LSTATE_CLEAR;
TIMER_Set( NPC, "standing", Q_irand( 3000, 10000 ) );
}
}
else if ( NPCInfo->localState == LSTATE_BERZERK )
{//go nuts!
}
else if ( NPCInfo->stats.aggression >= Q_irand( 75, 125 ) )
{//that's it, go nuts!
NPCInfo->localState = LSTATE_BERZERK;
}
else if ( !TIMER_Done( NPC, "retreating" ) )
{//trying to back off
NPC_FaceEnemy( qtrue );
if ( NPC->client->ps.speed > NPCInfo->stats.walkSpeed )
{
NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
}
ucmd.buttons |= BUTTON_WALKING;
if ( Distance( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin ) < HOWLER_RETREAT_DIST )
{//enemy is close
vec3_t moveDir;
AngleVectors( NPC->r.currentAngles, moveDir, NULL, NULL );
VectorScale( moveDir, -1, moveDir );
if ( !NAV_DirSafe( NPC, moveDir, 8 ) )
{//enemy is backing me up against a wall or ledge! Start to get really mad!
NPCInfo->stats.aggression += 2;
}
else
{//back off
ucmd.forwardmove = -127;
}
//enemy won't leave me alone, get mad...
NPCInfo->stats.aggression++;
}
return;
}
else if ( TIMER_Done( NPC, "standing" ) )
{//not standing around
if ( !(NPCInfo->last_ucmd.forwardmove)
&& !(NPCInfo->last_ucmd.rightmove) )
{//stood last frame
if ( TIMER_Done( NPC, "walking" )
&& TIMER_Done( NPC, "running" ) )
{//not walking or running
//.........这里部分代码省略.........
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:101,代码来源:NPC_AI_Howler.cpp
示例12: Mark2_AttackDecision
/*
-------------------------
Mark2_AttackDecision
-------------------------
*/
void Mark2_AttackDecision( void )
{
float distance;
qboolean visible;
qboolean advance;
NPC_FaceEnemy( qtrue );
distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
visible = NPC_ClearLOS4( NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
// He's been ordered to get up
if (NPCInfo->localState == LSTATE_RISINGUP)
{
NPC->flags &= ~FL_SHIELDED;
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1START, SETANIM_FLAG_HOLD|SETANIM_FLAG_OVERRIDE );
if ((NPC->client->ps.legsTimer<=0) &&
NPC->client->ps.torsoAnim == BOTH_RUN1START )
{
NPCInfo->localState = LSTATE_NONE; // He's up again.
}
return;
}
// If we cannot see our target, move to see it
if ((!visible) || (!NPC_FaceEnemy(qtrue)))
{
// If he's going down or is down, make him get up
if ((NPCInfo->localState == LSTATE_DOWN) || (NPCInfo->localState == LSTATE_DROPPINGDOWN))
{
if ( TIMER_Done( NPC, "downTime" ) ) // Down being down?? (The delay is so he doesn't pop up and down when the player goes in and out of range)
{
NPCInfo->localState = LSTATE_RISINGUP;
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1STOP, SETANIM_FLAG_HOLD|SETANIM_FLAG_OVERRIDE );
TIMER_Set( NPC, "runTime", Q_irand( 3000, 8000) ); // So he runs for a while before testing to see if he should drop down.
}
}
else
{
Mark2_Hunt();
}
return;
}
// He's down but he could advance if he wants to.
if ((advance) && (TIMER_Done( NPC, "downTime" )) && (NPCInfo->localState == LSTATE_DOWN))
{
NPCInfo->localState = LSTATE_RISINGUP;
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1STOP, SETANIM_FLAG_HOLD|SETANIM_FLAG_OVERRIDE );
TIMER_Set( NPC, "runTime", Q_irand( 3000, 8000) ); // So he runs for a while before testing to see if he should drop down.
}
NPC_FaceEnemy( qtrue );
// Dropping down to shoot
if (NPCInfo->localState == LSTATE_DROPPINGDOWN)
{
NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1STOP, SETANIM_FLAG_HOLD|SETANIM_FLAG_OVERRIDE );
TIMER_Set( NPC, "downTime", Q_irand( 3000, 9000) );
if ((NPC->client->ps.legsTimer<=0) && NPC->client->ps.torsoAnim == BOTH_RUN1STOP )
{
NPC->flags |= FL_SHIELDED;
NPCInfo->localState = LSTATE_DOWN;
}
}
// He's down and shooting
else if (NPCInfo->localState == LSTATE_DOWN)
{
NPC->flags |= FL_SHIELDED;//only damagable by lightsabers and missiles
Mark2_BlasterAttack(qfalse);
}
else if (TIMER_Done( NPC, "runTime" )) // Lowering down to attack. But only if he's done running at you.
{
NPCInfo->localState = LSTATE_DROPPINGDOWN;
}
else if (advance)
{
// We can see enemy so shoot him if timer lets you.
Mark2_BlasterAttack(advance);
}
}
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:89,代码来源:NPC_AI_Mark2.cpp
示例13: Rancor_Combat
//----------------------------------
void Rancor_Combat( void )
{
if ( NPCS.NPC->count )
{//holding my enemy
if ( TIMER_Done2( NPCS.NPC, "takingPain", qtrue ))
{
NPCS.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( NPCS.NPC->enemy ) )//|| UpdateGoal( ))
{
NPCS.NPCInfo->combatMove = qtrue;
NPCS.NPCInfo->goalEntity = NPCS.NPC->enemy;
NPCS.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( NPCS.NPC, "lookForNewEnemy", 0 );
NPCS.NPCInfo->consecutiveBlockedMoves++;
}
else
{
NPCS.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( NPCS.NPC->r.currentOrigin, NPCS.NPC->enemy->r.currentOrigin );
advance = (qboolean)( distance > (NPCS.NPC->r.maxs[0]+MIN_DISTANCE) ? qtrue : qfalse );
doCharge = qfalse;
if ( advance )
{//have to get closer
vec3_t yawOnlyAngles;
VectorSet( yawOnlyAngles, 0, NPCS.NPC->r.currentAngles[YAW], 0 );
if ( NPCS.NPC->enemy->health > 0
&& fabs(distance-250) <= 80
&& InFOV3( NPCS.NPC->enemy->r.currentOrigin, NPCS.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( NPCS.NPC, "attacking" )) // waiting monsters can't attack
{
if ( TIMER_Done2( NPCS.NPC, "takingPain", qtrue ))
{
NPCS.NPCInfo->localState = LSTATE_CLEAR;
}
else
{
Rancor_Move( qtrue );
}
}
else
{
Rancor_Attack( distance, doCharge );
}
}
}
开发者ID:Almightygir,项目名称:OpenJK,代码行数:80,代码来源:NPC_AI_Rancor.c
示例14: Mark1_AttackDecision
/*
-------------------------
Mark1_AttackDecision
-------------------------
*/
void Mark1_AttackDecision( void )
{
int blasterTest,rocketTest;
float distance;
distance_e distRate;
qboolean visible;
qboolean advance;
//randomly talk
if ( TIMER_Done(NPC,"patrolNoise") )
{
if (TIMER_Done(NPC,"angerNoise"))
{
TIMER_Set( NPC, "patrolNoise", Q_irand( 4000, 10000 ) );
}
}
// Enemy is dead or he has no enemy.
if ((NPC->enemy->health<1) || ( NPC_CheckEnemyExt(qfalse) == qfalse ))
{
NPC->enemy = NULL;
return;
}
// Rate our distance to the target and visibility
distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE;
visible = NPC_ClearLOS4( NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
// If we cannot see our target, move to see it
if ((!visible) || (!NPC_FaceEnemy(qtrue)))
{
Mark1_Hunt();
return;
}
// See if the side weapons are there
blasterTest = trap_G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "l_arm" );
rocketTest = trap_G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "r_arm" );
// It has both side weapons
if (!blasterTest && !rocketTest)
{
; // So do nothing.
}
else if (blasterTest!=-1
&&blasterTest)
{
distRate = DIST_LONG;
}
else if (rocketTest!=-1
&&rocketTest)
{
distRate = DIST_MELEE;
}
else // It should never get here, but just in case
{
NPC->health = 0;
NPC->client->ps.stats[STAT_HEALTH] = 0;
if (NPC->die)
{
NPC->die(NPC, NPC, NPC, 100, MOD_UNKNOWN);
}
}
// We can see enemy so shoot him if timers let you.
NPC_FaceEnemy( qtrue );
if (distRate == DIST_MELEE)
{
Mark1_BlasterAttack(advance);
}
else if (distRate == DIST_LONG)
{
Mark1_RocketAttack(advance);
}
}
开发者ID:NoahBennet,项目名称:base_enhanced,代码行数:83,代码来源:NPC_AI_Mark1.c
示例15: NPC_BSSaberDroid_Attack
void NPC_BSSaberDroid_Attack( void )
{//attack behavior
//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) == qfalse )//!NPC->enemy )//
{
NPC->enemy = NULL;
NPC_BSSaberDroid_Patrol();//FIXME: or patrol?
return;
}
if ( !NPC->enemy )
{//WTF? somehow we lost our enemy?
NPC_BSSaberDroid_Patrol();//FIXME: or patrol?
return;
}
enemyLOS = enemyCS = qfalse;
move = qtrue;
faceEnemy = qfalse;
shoot = qfalse;
enemyDist = DistanceSquared( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin );
//can we see our target?
if ( NPC_ClearLOS4( NPC->enemy ) )
{
NPCInfo->enemyLastSeenTime = level.time;
enemyLOS = qtrue;
if ( enemyDist <= 4096 && InFOV3( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin, NPC->client->ps.viewangles, 90, 45 ) )//within 64 & infront
{
VectorCopy( NPC->enemy->r.currentOrigin, NPCInfo->enemyLastSeenLocation );
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" ) )
{
move = qfalse;
}
else if ( enemyCS )
{
shoot = qtrue;
if ( enemyDist < (NPC->r.maxs[0]+NPC->enemy->r.maxs[0]+32)*(NPC->r.maxs[0]+NPC->enemy->r.maxs[0]+32) )
{//close enough
move = qfalse;
}
}//this should make him chase enemy when out of range...?
if ( NPC->client->ps.legsTimer
&& NPC->client->ps.legsAnim != BOTH_A3__L__R )//this one is a running attack
{//in the middle of a held, stationary anim, can't move
move = qfalse;
}
if ( move )
{//move toward goal
move = SaberDroid_Move();
if ( move )
{//if we had to chase him, be sure to attack as soon as possible
TIMER_Set( NPC, "attackDelay", NPC->client->ps.weaponTime );
}
}
if ( !faceEnemy )
{//we want to face in the dir we're running
if ( move )
{//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(qtrue);
}
if ( NPCInfo->scriptFlags&SCF_DONT_FIRE )
{
//.........这里部分代码省略.........
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:101,代码来源:NPC_AI_SaberDroid.c
示例16: ATST_Attack
/*
-------------------------
ATST_Attack
-------------------------
*/
void ATST_Attack( void )
{
qboolean altAttack=qfalse;
int blasterTest,chargerTest,weapon;
float distance;
distance_e distRate;
qboolean visible;
qboolean advance;
if ( NPC_CheckEnemyExt(qfalse) == qfalse )//!NPC->enemy )//
{
NPC->enemy = NULL;
return;
}
NPC_FaceEnemy( qtrue );
// Rate our distance to the target, and our visibilty
distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE;
visible = NPC_ClearLOS4( NPC->enemy );
advance = (qboolean)(distance > MIN_DISTANCE_SQR);
// If we cannot see our target, move to see it
if ( visible == qfalse )
{
if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES )
{
ATST_Hunt( visible, advance );
return;
}
}
// Decide what type of attack to do
switch ( distRate )
{
case DIST_MELEE:
// NPC_ChangeWeapon( WP_ATST_MAIN );
break;
case DIST_LONG:
// NPC_ChangeWeapon( WP_ATST_SIDE );
//rwwFIXMEFIXME: make atst weaps work.
// See if the side weapons are there
blasterTest = trap_G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "head_light_blaster_cann" );
chargerTest = trap_G2API_GetSurfaceRenderStatus( NPC->ghoul2, 0, "head_concussion_charger" );
// It has both side weapons
if ( blasterTest != -1
&& !(blasterTest&TURN_OFF)
&& chargerTest != -1
&& !(chargerTest&TURN_OFF))
{
weapon = Q_irand( 0, 1); // 0 is blaster, 1 is charger (ALT SIDE)
if (weapon) // Fire charger
{
altAttack = qtrue;
}
else
{
altAttack = qfalse;
}
}
else if (blasterTest != -1
&& !(blasterTest & TURN_OFF)) // Blaster is on
{
altAttack = qfalse;
}
else if (chargerTest != -1
&&!(chargerTest & TURN_OFF)) // Blaster is on
{
altAttack = qtrue;
}
else
{
NPC_ChangeWeapon( WP_NONE );
}
break;
}
NPC_FaceEnemy( qtrue );
ATST_Ranged( visible, advance,altAttack );
}
开发者ID:jwginge,项目名称:ojpa,代码行数:93,代码来源:NPC_AI_Atst.c
示例17: NPC_BSSniper_Attack
void NPC_BSSniper_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) == qfalse )//!NPC->enemy )//
{
NPC->enemy = NULL;
NPC_BSSniper_Patrol();//FIXME: or patrol?
return;
}
//[CoOp]
if ( TIMER_Done( NPC, "flee" ) && NPC_CheckForDanger( NPC_CheckAlertEvents( qtrue, qtrue, -1, qfalse, AEL_DANGER, qfalse ) ) )
//if ( TIMER_Done( NPC, "flee" ) && NPC_CheckForDanger( NPC_CheckAlertEvents( qtrue, qtrue, -1, qfalse, AEL_DANGER ) ) )
//[/CoOp]
{//going to run
NPC_UpdateAngles( qtrue, qtrue );
return;
}
if ( !NPC->enemy )
{//WTF? somehow we lost our enemy?
NPC_BSSniper_Patrol();//FIXME: or patrol?
return;
}
enemyLOS2 = enemyCS2 = qfalse;
move2 = qtrue;
faceEnemy2 = qfalse;
shoot2 = qfalse;
enemyDist2 = DistanceSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
if ( enemyDist2 < 16384 )//128 squared
{//too close, so switch to primary fire
if ( NPC->client->ps.weapon == WP_DISRUPTOR )
{//sniping... should be assumed
if ( NPCInfo->scriptFlags & SCF_ALT_FIRE )
{//use primary fire
trace_t trace;
trap_Trace ( &trace, NPC->enemy->r.currentOrigin, NPC->enemy->r.mins, NPC->enemy->r.maxs, NPC->r.currentOrigin, NPC->enemy->s.number, NPC->enemy->clipmask );
if ( !trace.allsolid && !trace.startsolid && (trace.fraction == 1.0 || trace.entityNum == NPC->s.number ) )
{//he can get right to me
NPCInfo->scriptFlags &= ~SCF_ALT_FIRE;
//reset fire-timing variables
NPC_ChangeWeapon( WP_DISRUPTOR );
NPC_UpdateAngles( qtrue, qtrue );
return;
}
}
//FIXME: switch back if he gets far away again?
}
}
else if ( enemyDist2 > 65536 )//256 squared
{
if ( NPC->client->ps.weapon == WP_DISRUPTOR )
{//sniping... should be assumed
if ( !(NPCInfo->scriptFlags&SCF_ALT_FIRE) )
{//use primary fire
NPCInfo->scriptFlags |= SCF_ALT_FIRE;
//reset fire-timing variables
NPC_ChangeWeapon( WP_DISRUPTOR );
NPC_UpdateAngles( qtrue, qtrue );
return;
}
}
}
Sniper_UpdateEnemyPos();
//can we see our target?
if ( NPC_ClearLOS4( NPC->enemy ) )//|| (NPCInfo->stats.aim >= 5 && gi.inPVS( NPC->client->renderInfo.eyePoint, NPC->enemy->currentOrigin )) )
{
float maxShootDist;
NPCInfo->enemyLastSeenTime = level.time;
VectorCopy( NPC->enemy->r.currentOrigin, NPCInfo->enemyLastSeenLocation );
enemyLOS2 = qtrue;
maxShootDist = NPC_MaxDistSquaredForWeapon();
if ( enemyDist2 < maxShootDist )
{
vec3_t fwd, right, up, muzzle, end;
trace_t tr;
int hit;
AngleVectors( NPC->client->ps.viewangles, fwd, right, up );
CalcMuzzlePoint( NPC, fwd, right, up, muzzle );
VectorMA( muzzle, 8192, fwd, end );
trap_Trace ( &tr, muzzle, NULL, NULL, end, NPC->s.number, MASK_SHOT );
hit = tr.entityNum;
//can we shoot our target?
if ( Sniper_EvaluateShot( hit ) )
{
enemyCS2 = qtrue;
}
//.........这里部分代码省略.........
开发者ID:jwginge,项目名称:ojpa,代码行数:101,代码来源:NPC_AI_Sniper.c
示例18: Seeker_FindEnemy
//------------------------------------
void Seeker_FindEnemy( void )
{
int numFound;
float dis, bestDis = SEEKER_SEEK_RADIUS * SEEKER_SEEK_RADIUS + 1;
vec3_t mins, maxs;
int entityList[MAX_GENTITIES];
gentity_t *ent, *best = NULL;
int i;
//[SeekerItemNpc]
float closestDist = SEEKER_SEEK_RADIUS * SEEKER_SEEK_RADIUS + 1;
//[/SeekerItemNpc]
if(NPC->activator && NPC->activator->client->ps.weapon == WP_SABER && !NPC->activator->client->ps.saberHolstered)
{
NPC->enemy=NULL;
return;
}
VectorSet( maxs, SEEKER_SEEK_RADIUS, SEEKER_SEEK_RADIUS, SEEKER_SEEK_RADIUS );
VectorScale( maxs, -1, mins );
//[CoOp]
//without this, the seekers are just scanning in terms of the world coordinates instead of around themselves, which is bad.
VectorAdd(maxs, NPC->r.currentOrigin, maxs);
VectorAdd(mins, NPC->r.currentOrigin, mins);
//[/CoOp]
numFound = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
for ( i = 0 ; i < numFound ; i++ )
{
ent = &g_entities[entityList[i]];
if ( ent->s.number == NPC->s.number
|| !ent->client //&& || !ent->NPC
//[CoOp]
//SP says this. Don't attack non-NPCs?!
//|| !ent->NPC
//[/CoOp]
|| ent->health <= 0
|| !ent->inuse )
{
continue;
}
//[SeekerItemNpc]
if(OnSameTeam(NPC->activator, ent))
{ //our owner is on the same team as this entity, don't target them.
continue;
}
//dont attack our owner
if(NPC->activator == ent)
continue;
if(ent->s.NPC_class == CLASS_VEHICLE)
continue;
//[/SeekerItemNpc]
dis = DistanceHorizontalSquared( NPC->r.currentOrigin, ent->r.currentOrigin );
if ( dis <= closestDist )
closestDist = dis;
// try to find the closest visible one
if ( !NPC_ClearLOS4( ent ))
{
continue;
}
if ( dis <= bestDis )
{
bestDis = dis;
best = ent;
}
//[/SeekerItemNpc]
}
if ( best )
{
//[SeekerItemNpc] because we can run even if we already have an enemy
if(!NPC->enemy) {
// used to offset seekers around a circle so they don't occupy the same spot. This is not a fool-proof method.
NPC->random = random() * 6.3f; // roughly 2pi
NPC->enemy = best;
}
//[/SeekerItemNpc]
}
//[SeekerItemNpc]
//positive radius, check with los in mind
if(NPC->radius > 0) {
if(best && bestDis <= NPC->radius)
NPC->fly_sound_debounce_time = level.time + (int)floor(2500.0f * (bestDis / (float)NPC->radius)) + 500;
else
NPC->fly_sound_debounce_time = -1;
}
//.........这里部分代码省略.........
开发者ID:jwginge,项目名称:ojpa,代码行数:101,代码来源:NPC_AI_Seeker.c
示例19: Howler_Combat
//----------------------------------
//replaced with SP version.
static void Howler_Combat( void )
{
qboolean faced = qfalse;
float distance;
qboolean advance = qfalse;
if ( NPC->client->ps.groundEntityNum == ENTITYNUM_NONE )
{//not on the ground
if ( NPC->client->ps.legsAnim == BOTH_JUMP1
|| NPC->client->ps.legsAnim == BOTH_INAIR1 )
{//flying through the air with the greatest of ease, etc
Howler_TryDamage( 10, qfalse, qfalse );
}
}
else
{//not in air, see if we should attack or advance
// If we cannot see our target or we have somewhere to go, then do that
if ( !NPC_ClearLOS4( NPC->enemy ) )//|| UpdateGoal( ))
{
NPCInfo->goalEntity = NPC->enemy;
NPCInfo->goalRadius = MAX_DISTANCE; // just get us within combat range
if ( NPCInfo->localState == LSTATE_BERZERK )
{
NPC_Howler_Move( 3 );
}
else
{
NPC_Howler_Move( 10 );
}
NPC_UpdateAngles( qfalse, qtrue );
return;
}
distance = DistanceHorizontal( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin );
if ( NPC->enemy && NPC->enemy->client && PM_InKnockDown( &NPC->enemy->client->ps ) )
{//get really close to knocked down enemies
advance = (qboolean)( distance > MIN_DISTANCE ? qtrue : qfalse );
}
else
{
advance = (qboolean)( distance > MAX_DISTANCE ? qtrue : qfalse );//MIN_DISTANCE
}
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 if ( TIMER_Done( NPC, "standing" ) )
{
faced = Howler_Move( qtrue );
}
}
else
{
Howler_Attack( distance, qfalse );
}
}
if ( !faced )
{
if ( //TIMER_Done( NPC, "standing" ) //not just standing there
//!advance //not moving
TIMER_Done( NPC, "attacking" ) )// not attacking
{//not standing around
// Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb
NPC_FaceEnemy( qtrue );
}
else
{
NPC_UpdateAngles( qfalse, qtrue );
}
}
}
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:78,代码来源:NPC_AI_Howler.cpp
示例20: 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) == 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;
}
enemyLOS3 = enemyCS3 = qfalse;
move3 = qtrue;
faceEnemy3 = qfalse;
shoot3 = qfalse;
enemyDist3 = DistanceSquared( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin );
//See if we should switch to melee attack
if ( enemyDist3 < 16384 //128
&& (!NPC->enemy->client
|| NPC->enemy->client->ps.weapon != WP_SABER
|| BG_SabersOff( &NPC->enemy->client->ps )
)
)
{//enemy is close a
|
请发表评论