本文整理汇总了C++中G_SetEnemy函数的典型用法代码示例。如果您正苦于以下问题:C++ G_SetEnemy函数的具体用法?C++ G_SetEnemy怎么用?C++ G_SetEnemy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_SetEnemy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Howler_Patrol
/*
-------------------------
Howler_Patrol
-------------------------
*/
static void Howler_Patrol( void )
{
NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
NPC_Howler_Move( 100 );
}
vec3_t dif;
VectorSubtract( g_entities[0].currentOrigin, NPC->currentOrigin, dif );
if ( VectorLengthSquared( dif ) < 256 * 256 )
{
G_SetEnemy( NPC, &g_entities[0] );
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse )
{
Howler_Idle();
return;
}
Howler_Attack( 0.0f, qtrue );
}
开发者ID:Arbixal,项目名称:OpenJK,代码行数:31,代码来源:AI_Howler.cpp
示例2: Howler_Patrol
//[CoOp]
//Replaced with SP version
static void Howler_Patrol( void )
{
gentity_t *ClosestPlayer = FindClosestPlayer(NPC->r.currentOrigin, NPC->client->enemyTeam);
NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
NPC_Howler_Move( 100 );
}
if(ClosestPlayer)
{//attack enemy players that are close.
if(Distance(ClosestPlayer->r.currentOrigin, NPC->r.currentOrigin) < 256 * 256)
{
G_SetEnemy( NPC, ClosestPlayer );
}
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse )
{
Howler_Idle();
return;
}
Howler_Attack( 0.0f, qtrue );
}
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:30,代码来源:NPC_AI_Howler.cpp
示例3: target_laser_start
void target_laser_start (gentity_t *self)
{
gentity_t *ent;
self->s.eType = ET_BEAM;
if (self->target) {
ent = G_Find (NULL, FOFS(targetname), self->target);
if (!ent) {
gi.Printf ("%s at %s: %s is a bad target\n", self->classname, vtos(self->s.origin), self->target);
}
G_SetEnemy( self, ent );
} else {
G_SetMovedir (self->s.angles, self->movedir);
}
self->e_UseFunc = useF_target_laser_use;
self->e_ThinkFunc = thinkF_target_laser_think;
if ( !self->damage ) {
self->damage = 1;
}
if (self->spawnflags & 1)
target_laser_on (self);
else
target_laser_off (self);
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:28,代码来源:g_target.cpp
示例4: funcGlassDie
//-----------------------------------------------------
void funcGlassDie( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod,int dFlags,int hitLoc )
{
vec3_t verts[4], normal;
// if a missile is stuck to us, blow it up so we don't look dumb....we could, alternately, just let the missile drop off??
for ( int i = 0; i < MAX_GENTITIES; i++ )
{
if ( g_entities[i].s.groundEntityNum == self->s.number && ( g_entities[i].s.eFlags & EF_MISSILE_STICK ))
{
G_Damage( &g_entities[i], self, self, NULL, NULL, 99999, 0, MOD_CRUSH ); //?? MOD?
}
}
// Really naughty cheating. Put in an EVENT at some point...
cgi_R_GetBModelVerts( cgs.inlineDrawModel[self->s.modelindex], verts, normal );
CG_DoGlass( verts, normal, self->pos1, self->pos2, self->splashRadius );
self->takedamage = qfalse;//stop chain reaction runaway loops
G_SetEnemy( self, self->enemy );
//So chunks don't get stuck inside me
self->s.solid = 0;
self->contents = 0;
self->clipmask = 0;
gi.linkentity(self);
if ( self->target && attacker != NULL )
{
G_UseTargets( self, attacker );
}
gi.AdjustAreaPortalState( self, qtrue );
G_FreeEntity( self );
}
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:36,代码来源:g_breakable.cpp
示例5: AI_CheckEnemyCollision
qboolean AI_CheckEnemyCollision( gentity_t *ent, qboolean takeEnemy )
{
if ( ent == NULL )
return qfalse;
if ( ent->svFlags & SVF_LOCKEDENEMY )
return qfalse;
navInfo_t info;
NAV_GetLastMove( info );
//See if we've hit something
if ( ( info.blocker ) && ( info.blocker != ent->enemy ) )
{
if ( ( info.blocker->client ) && ( info.blocker->client->playerTeam == ent->client->enemyTeam ) )
{
if ( takeEnemy )
G_SetEnemy( ent, info.blocker );
return qtrue;
}
}
return qfalse;
}
开发者ID:Christian-Barrett,项目名称:OpenJK,代码行数:26,代码来源:AI_Utils.cpp
示例6: Howler_Patrol
/*
-------------------------
Howler_Patrol
-------------------------
*/
void Howler_Patrol( void )
{
vector3 dif;
NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
ucmd.buttons &= ~BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
}
else
{
if ( TIMER_Done( NPC, "patrolTime" ))
{
TIMER_Set( NPC, "patrolTime", crandom() * 5000 + 5000 );
}
}
//rwwFIXMEFIXME: Care about all clients, not just client 0
VectorSubtract( &g_entities[0].r.currentOrigin, &NPC->r.currentOrigin, &dif );
if ( VectorLengthSquared( &dif ) < 256 * 256 )
{
G_SetEnemy( NPC, &g_entities[0] );
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse )
{
Howler_Idle();
return;
}
}
开发者ID:Geptun,项目名称:japp,代码行数:39,代码来源:NPC_AI_Howler.c
示例7: Howler_Patrol
/*
-------------------------
Howler_Patrol
-------------------------
*/
void Howler_Patrol( void )
{
NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
ucmd.buttons &= ~BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
}
else
{
if ( TIMER_Done( NPC, "patrolTime" ))
{
TIMER_Set( NPC, "patrolTime", crandom() * 5000 + 5000 );
}
}
vec3_t dif;
VectorSubtract( g_entities[0].currentOrigin, NPC->currentOrigin, dif );
if ( VectorLengthSquared( dif ) < 256 * 256 )
{
G_SetEnemy( NPC, &g_entities[0] );
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse )
{
Howler_Idle();
return;
}
}
开发者ID:slaytan1c,项目名称:jedioutcast,代码行数:38,代码来源:AI_Howler.cpp
示例8: MineMonster_Patrol
/*
-------------------------
MineMonster_Patrol
-------------------------
*/
void MineMonster_Patrol( void )
{
vec3_t dif;
NPCS.NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
NPCS.ucmd.buttons &= ~BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
}
else
{
if ( TIMER_Done( NPCS.NPC, "patrolTime" ))
{
TIMER_Set( NPCS.NPC, "patrolTime", Q_flrand(-1.0f, 1.0f) * 5000 + 5000 );
}
}
//rwwFIXMEFIXME: Care about all clients, not just client 0
//OJKFIXME: clietnum 0
VectorSubtract( g_entities[0].r.currentOrigin, NPCS.NPC->r.currentOrigin, dif );
if ( VectorLengthSquared( dif ) < 256 * 256 )
{
G_SetEnemy( NPCS.NPC, &g_entities[0] );
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse )
{
MineMonster_Idle();
return;
}
}
开发者ID:Avygeil,项目名称:NewJK,代码行数:40,代码来源:NPC_AI_MineMonster.c
示例9: NPC_CheckPlayerDistance
static qboolean NPC_CheckPlayerDistance( void )
{
//Make sure we have an enemy
if ( NPC->enemy == NULL )
return qfalse;
//Only do this for non-players
if ( NPC->enemy->s.number == 0 )
return qfalse;
//must be set up to get mad at player
if ( !NPC->client || NPC->client->enemyTeam != TEAM_PLAYER )
return qfalse;
//Must be within our FOV
if ( InFOV( &g_entities[0], NPC, NPCInfo->stats.hfov, NPCInfo->stats.vfov ) == qfalse )
return qfalse;
float distance = DistanceSquared( NPC->currentOrigin, NPC->enemy->currentOrigin );
if ( distance > DistanceSquared( NPC->currentOrigin, g_entities[0].currentOrigin ) )
{
G_SetEnemy( NPC, &g_entities[0] );
return qtrue;
}
return qfalse;
}
开发者ID:Agustinlv,项目名称:BlueHarvest,代码行数:28,代码来源:NPC_utils.cpp
示例10: NPC_BSStandGuard
void NPC_BSStandGuard (void)
{
//FIXME: Use Snapshot info
if ( NPC->enemy == NULL )
{//Possible to pick one up by being shot
if( random() < 0.5 )
{
if(NPC->client->enemyTeam)
{
//gentity_t *newenemy = NPC_PickEnemy(NPC, NPC->client->enemyTeam, (NPC->cantHitEnemyCounter < 10), (NPC->client->enemyTeam == NPCTEAM_PLAYER), qtrue);
gentity_t *newenemy = NPC_PickEnemy();
//only checks for vis if couldn't hit last enemy
if(newenemy)
{
G_SetEnemy( NPC, newenemy );
}
}
}
}
if ( NPC->enemy != NULL )
{
if( NPCInfo->tempBehavior == BS_STAND_GUARD )
{
NPCInfo->tempBehavior = BS_DEFAULT;
}
if( NPCInfo->behaviorState == BS_STAND_GUARD )
{
NPCInfo->behaviorState = BS_STAND_AND_SHOOT;
}
}
NPC_UpdateAngles( qtrue, qtrue );
}
开发者ID:erfg12,项目名称:clanmod-jka,代码行数:35,代码来源:NPC_AI_Default.c
示例11: MineMonster_Patrol
/*
-------------------------
MineMonster_Patrol
-------------------------
*/
void MineMonster_Patrol( void )
{
NPCInfo->localState = LSTATE_CLEAR;
//If we have somewhere to go, then do that
if ( UpdateGoal() )
{
ucmd.buttons &= ~BUTTON_WALKING;
NPC_MoveToGoal( qtrue );
}
vec3_t dif;
VectorSubtract( g_entities[0].currentOrigin, NPC->currentOrigin, dif );
if ( VectorLengthSquared( dif ) < 256 * 256 )
{
G_SetEnemy( NPC, &g_entities[0] );
}
if ( NPC_CheckEnemyExt( qtrue ) == qfalse )
{
MineMonster_Idle();
return;
}
}
开发者ID:Arbixal,项目名称:OpenJK,代码行数:30,代码来源:AI_MineMonster.cpp
示例12: NPC_Touch
void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace)
{
if(!self->NPC)
return;
SaveNPCGlobals();
SetNPCGlobals( self );
if ( other->client )
{//FIXME: if pushing against another bot, both ucmd.rightmove = 127???
//Except if not facing one another...
if ( other->health > 0 )
{
NPCInfo->touchedByPlayer = other;
}
if ( other == NPCInfo->goalEntity )
{
NPCInfo->aiFlags |= NPCAI_TOUCHED_GOAL;
}
if( !(self->svFlags&SVF_LOCKEDENEMY) && !(self->svFlags&SVF_IGNORE_ENEMIES) && !(other->flags & FL_NOTARGET) )
{
if ( self->client->enemyTeam )
{//See if we bumped into an enemy
if ( other->client->playerTeam == self->client->enemyTeam )
{//bumped into an enemy
//FIXME: should we care about disguise here?
if( NPCInfo->behaviorState != BS_HUNT_AND_KILL && !NPCInfo->tempBehavior )
{//MCG - Begin: checking specific BS mode here, this is bad, a HACK
//FIXME: not medics?
G_SetEnemy( NPC, other );
// NPCInfo->tempBehavior = BS_HUNT_AND_KILL;
}
}
}
}
//FIXME: do this if player is moving toward me and with a certain dist?
/*
if ( other->s.number == 0 && self->client->playerTeam == other->client->playerTeam )
{
VectorAdd( self->s.pushVec, other->client->ps.velocity, self->s.pushVec );
}
*/
}
else
{//FIXME: check for SVF_NONNPC_ENEMY flag here?
if ( other == NPCInfo->goalEntity )
{
NPCInfo->aiFlags |= NPCAI_TOUCHED_GOAL;
}
}
RestoreNPCGlobals();
}
开发者ID:UberGames,项目名称:SP-Mod-Source-Code,代码行数:56,代码来源:NPC_reactions.cpp
示例13: NPC_FindEnemy
qboolean NPC_FindEnemy( qboolean checkAlerts )
{
gentity_t *newenemy;
//We're ignoring all enemies for now
//if( NPC->svFlags & SVF_IGNORE_ENEMIES )
if (0) //rwwFIXMEFIXME: support for flag
{
G_ClearEnemy( NPC );
return qfalse;
}
//we can't pick up any enemies for now
if( NPCInfo->confusionTime > level.time )
{
return qfalse;
}
//Don't want a new enemy
//rwwFIXMEFIXME: support for locked enemy
//if ( ( ValidEnemy( NPC->enemy ) ) && ( NPC->svFlags & SVF_LOCKEDENEMY ) )
// return qtrue;
//See if the player is closer than our current enemy
if ( NPC_CheckPlayerDistance() )
{
return qtrue;
}
//Otherwise, turn off the flag
// NPC->svFlags &= ~SVF_LOCKEDENEMY;
//See if the player is closer than our current enemy
if ( NPC->client->NPC_class != CLASS_RANCOR
&& NPC->client->NPC_class != CLASS_WAMPA
//&& NPC->client->NPC_class != CLASS_SAND_CREATURE
&& NPC_CheckPlayerDistance() )
{//rancors, wampas & sand creatures don't care if player is closer, they always go with closest
return qtrue;
}
//If we've gotten here alright, then our target it still valid
if ( NPC_ValidEnemy( NPC->enemy ) )
return qtrue;
newenemy = NPC_PickEnemyExt( checkAlerts );
//if we found one, take it as the enemy
if( NPC_ValidEnemy( newenemy ) )
{
G_SetEnemy( NPC, newenemy );
return qtrue;
}
return qfalse;
}
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:55,代码来源:NPC_utils.cpp
示例14: ammo_use
void ammo_use( gentity_t *self, gentity_t *other, gentity_t *activator)
{
int dif;
G_ActivateBehavior(self,BSET_USE);
if (self->think != NULL)
{
if (self->use != NULL)
{
self->think = NULL;
}
}
else
{
if (other->client)
{
dif = ammoData[AMMO_BLASTER].max - other->client->ps.ammo[AMMO_BLASTER];
}
else
{ // Being triggered to be used up
dif = 1;
self->count = 0;
}
// Does player already have full ammo?
if (dif > 0)
{
// G_Sound(self, G_SoundIndex("sound/player/suitenergy.wav") );
if ((dif >= self->count) || (self->count<1)) // use it all up?
{
ammo_shutdown(self);
}
}
else
{
// G_Sound(self, G_SoundIndex("sound/weapons/noammo.wav") );
}
// Use target when used
if (self->spawnflags & 8)
{
G_UseTargets( self, activator );
}
self->use = NULL;
G_SetEnemy( self, other );
self->think = ammo_think;
self->nextthink = level.time + 50;
}
}
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:51,代码来源:g_breakable.c
示例15: funcBBrushDie
void funcBBrushDie (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod,int dFlags,int hitLoc)
{
self->takedamage = qfalse;//stop chain reaction runaway loops
G_SetEnemy(self, attacker);
if(self->delay)
{
self->e_ThinkFunc = thinkF_funcBBrushDieGo;
self->nextthink = level.time + floor(self->delay * 1000.0f);
return;
}
funcBBrushDieGo(self);
}
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:15,代码来源:g_breakable.cpp
示例16: fx_target_beam_link
//------------------------------------------
void fx_target_beam_link( gentity_t *ent )
{
gentity_t *target = NULL;
vec3_t dir;
float len;
target = G_Find( target, FOFS(targetname), ent->target );
if ( !target )
{
Com_Printf( "bolt_link: unable to find target %s\n", ent->target );
G_FreeEntity( ent );
return;
}
ent->attackDebounceTime = level.time;
if ( !target->classname || Q_stricmp( "info_null", target->classname ) )
{//don't want to set enemy to something that's going to free itself... actually, this could be bad in other ways, too... ent pointer could be freed up and re-used by the time we check it next
G_SetEnemy( ent, target );
}
VectorSubtract( target->s.origin, ent->s.origin, dir );//er, does it ever use dir?
len = VectorNormalize( dir );//er, does it use len or dir?
vectoangles( dir, ent->s.angles );//er, does it use s.angles?
VectorCopy( target->s.origin, ent->s.origin2 );
if ( ent->spawnflags & 1 )
{
// Do nothing
ent->e_ThinkFunc = thinkF_NULL;
}
else
{
if ( !(ent->spawnflags & 8 )) // one_shot, only calls when used
{
// switch think functions to avoid doing the bolt_link every time
ent->e_ThinkFunc = thinkF_fx_target_beam_think;
ent->nextthink = level.time + FRAMETIME;
}
}
ent->e_UseFunc = useF_fx_target_beam_use;
gi.linkentity( ent );
}
开发者ID:LTolosa,项目名称:Jedi-Outcast,代码行数:46,代码来源:g_fx.cpp
示例17: TurretG2Pain
void TurretG2Pain( gentity_t *self, gentity_t *attacker, int damage ) {
if ( self->paintarget && self->paintarget[0] ) {
if ( self->genericValue8 < level.time ) {
G_UseTargets2( self, self, self->paintarget );
self->genericValue8 = level.time + self->genericValue4;
}
}
if ( attacker->client && attacker->client->ps.weapon == WP_DEMP2 ) {
self->attackDebounceTime = level.time + 2000 + random() * 500;
self->painDebounceTime = self->attackDebounceTime;
}
if ( !self->enemy ) {//react to being hit
G_SetEnemy( self, attacker );
}
//self->s.health = self->health;
//mmm..yes..bad.
}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:18,代码来源:g_turret_G2.cpp
示例18: NPC_FindEnemy
qboolean NPC_FindEnemy( qboolean checkAlerts = qfalse )
{
//We're ignoring all enemies for now
if( NPC->svFlags & SVF_IGNORE_ENEMIES )
{
G_ClearEnemy( NPC );
return qfalse;
}
//we can't pick up any enemies for now
if( NPCInfo->confusionTime > level.time )
{
return qfalse;
}
//Don't want a new enemy
if ( ( ValidEnemy( NPC->enemy ) ) && ( NPC->svFlags & SVF_LOCKEDENEMY ) )
return qtrue;
//See if the player is closer than our current enemy
if ( NPC_CheckPlayerDistance() )
{
return qtrue;
}
//Otherwise, turn off the flag
NPC->svFlags &= ~SVF_LOCKEDENEMY;
//If we've gotten here alright, then our target it still valid
if ( NPC_ValidEnemy( NPC->enemy ) )
return qtrue;
gentity_t *newenemy = NPC_PickEnemyExt( checkAlerts );
//if we found one, take it as the enemy
if( NPC_ValidEnemy( newenemy ) )
{
G_SetEnemy( NPC, newenemy );
return qtrue;
}
return qfalse;
}
开发者ID:Agustinlv,项目名称:BlueHarvest,代码行数:43,代码来源:NPC_utils.cpp
示例19: target_scriptrunner_use
void target_scriptrunner_use(gentity_t *self, gentity_t *other, gentity_t *activator)
{
if ( self->nextthink > level.time )
{
return;
}
self->activator = activator;
G_SetEnemy( self, other );
if ( self->delay )
{//delay before firing scriptrunner
self->e_ThinkFunc = thinkF_scriptrunner_run;
self->nextthink = level.time + self->delay;
}
else
{
scriptrunner_run (self);
}
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:19,代码来源:g_target.cpp
示例20: target_relay_use
void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator)
{
if ( ( self->spawnflags & 1 ) && activator->client )
{//&& activator->client->ps.persistant[PERS_TEAM] != TEAM_RED ) {
return;
}
if ( ( self->spawnflags & 2 ) && activator->client )
{//&& activator->client->ps.persistant[PERS_TEAM] != TEAM_BLUE ) {
return;
}
if ( self->svFlags & SVF_INACTIVE )
{//set by target_deactivate
return;
}
if ( self->painDebounceTime > level.time )
{
return;
}
G_SetEnemy( self, other );
self->activator = activator;
if ( self->delay )
{
self->e_ThinkFunc = thinkF_target_relay_use_go;
self->nextthink = level.time + self->delay;
return;
}
target_relay_use_go( self );
if ( self->wait < 0 )
{
self->e_UseFunc = useF_NULL;
}
else
{
self->painDebounceTime = level.time + self->wait;
}
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:43,代码来源:g_target.cpp
注:本文中的G_SetEnemy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论