本文整理汇总了C++中OnSameTeam函数的典型用法代码示例。如果您正苦于以下问题:C++ OnSameTeam函数的具体用法?C++ OnSameTeam怎么用?C++ OnSameTeam使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnSameTeam函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
edict_t *NextNearestTotem(edict_t *ent, int totemType, edict_t *lastTotem, qboolean allied)
{
edict_t *ed, *owner, *closestEnt = NULL;
float closestDistance = -1.0;
float lastTotemDistance = 0.0;
if (lastTotem) lastTotemDistance = V_EntDistance(ent, lastTotem);
for (ed = g_edicts ; ed < &g_edicts[globals.num_edicts]; ed++)
{
float thisDistance;
//skip all ents that are not totems, and skip the last "closest" totem.
if(ed->mtype != totemType || ed == lastTotem)
continue;
// air totems can be configured to protect only their owner
if (PM_PlayerHasMonster(ed->activator))
owner = ed->activator->owner;
else
owner = ed->activator;
if (ed->mtype == TOTEM_AIR && ed->style && ent != owner)
continue;
//skip any totems that are "not on my team" or are "not my enemy"
if(allied && !OnSameTeam(ent, ed))
continue;
else if(!allied && OnSameTeam(ent, ed))
continue;
thisDistance = V_EntDistance(ent, ed);
//Totem must be in range and must be in "line of sight".
//Using visible1() so forcewall, etc.. can block it.
if(thisDistance > TOTEM_MAX_RANGE || !visible1(ed, ent))
continue;
//The closest totem found must be farther away than the last one found.
if(lastTotem != NULL && thisDistance < lastTotemDistance)
continue;
//This is a valid totem, but is it the closest one?
if(thisDistance < closestDistance || closestDistance == -1.0)
{
closestDistance = thisDistance;
closestEnt = ed;
}
}
//This should be the next closest totem to the target, and should be null if there isn't one.
return closestEnt;
}
示例2:
gentity_t *EnemyCapturingFlag ( gentity_t *self, int flag_entitynum )
{// Should return an enemy that is trying to capture the same flag as us...
gentity_t *flag = &g_entities[flag_entitynum];
int client = 0;
for (client = 0; client < MAX_GENTITIES; client++)
{
gentity_t *ent = &g_entities[client];
if (!ent)
continue;
if (!ent->client)
continue;
if (ent->health <= 0)
continue;
if (ent->s.eType != ET_NPC && ent->s.eType != ET_PLAYER)
continue;
if (ent->client->ps.stats[STAT_CAPTURE_ENTITYNUM] != flag_entitynum)
continue;
if (OnSameTeam(ent, self))
continue;
// OK, we found an enemy trying to capture this flag! Return it!
return ent;
}
return NULL;
}
示例3: G_SayTo
static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *message ) {
if ( !other || !other->inuse || !other->client )
return;
if ( other->client->pers.connected != CON_CONNECTED )
return;
if ( mode == SAY_TEAM && !OnSameTeam( ent, other ) )
return;
//QTZTODO: specmute
/*
// no chatting to players in tournaments
if ( (level.gametype == GT_DUEL || level.gametype == GT_POWERDUEL)
&& other->client->sess.sessionTeam == TEAM_FREE
&& ent->client->sess.sessionTeam != TEAM_FREE ) {
//Hmm, maybe some option to do so if allowed? Or at least in developer mode...
return;
}
*/
trap->SV_GameSendServerCommand( ARRAY_INDEX( g_entities, other ), va( "%s %i \"%c%c%s\"",
mode == SAY_TEAM ? "tchat" : "chat",
ent->s.number, Q_COLOR_ESCAPE, color, message));
}
示例4: forcewall_touch
void forcewall_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
V_Touch(self, other, plane, surf);
// let teammates pass thru
if (/*(other != self->activator) &&*/ G_EntIsAlive(other))
{
if (OnSameTeam(self->activator, other) && (other->movetype == MOVETYPE_STEP || other->movetype == MOVETYPE_WALK))
{
//gi.dprintf("%s touching %d \n",other->classname, other->movetype);
self->solid = SOLID_NOT;
self->wait = level.time + 0.2; // small buffer so monsters can get thru
}
else if (level.time > self->random)
{
// dont allow solid force wall to trap people
if (level.framenum == self->count-900)
{
G_FreeEdict(self);
return;
}
forcewall_knockback(self, other); // knock them back
gi.sound(other, CHAN_ITEM, gi.soundindex("world/force2.wav"), 1, ATTN_NORM, 0);
self->random = level.time + 0.5; // dont spam the sound
}
}
}
示例5: mymedic_attack
void mymedic_attack(edict_t *self)
{
float dist, r;
if (!self->enemy)
return;
if (!self->enemy->inuse)
return;
dist = entdist(self, self->enemy);
r = random();
if ((self->monsterinfo.aiflags & AI_MEDIC)
&& ((self->enemy->health < 1 || OnSameTeam(self, self->enemy))))
{
if (dist <= 256)
self->monsterinfo.currentmove = &mymedic_move_attackCable;
return;
}
if (dist <= 256)
{
if (r <= 0.2)
self->monsterinfo.currentmove = &mymedic_move_attackHyperBlaster;
else
self->monsterinfo.currentmove = &mymedic_move_attackBlaster;
}
else
{
if (r <= 0.3)
self->monsterinfo.currentmove = &mymedic_move_attackBlaster;
else
self->monsterinfo.currentmove = &mymedic_move_attackHyperBlaster;
}
}
示例6: G_VoiceTo
static void
G_VoiceTo(Gentity *ent, Gentity *other, int mode, const char *id,
qbool voiceonly)
{
int color;
char *cmd;
if(!other)
return;
if(!other->inuse)
return;
if(!other->client)
return;
if(mode == SAY_TEAM && !OnSameTeam(ent, other))
return;
/* no chatting to players in tournements */
if(g_gametype.integer == GT_TOURNAMENT)
return;
if(mode == SAY_TEAM){
color = COLOR_CYAN;
cmd = "vtchat";
}else if(mode == SAY_TELL){
color = COLOR_MAGENTA;
cmd = "vtell";
}else{
color = COLOR_GREEN;
cmd = "vchat";
}
trap_SendServerCommand(other-g_entities,
va("%s %d %d %d %s", cmd, voiceonly, ent->s.number, color, id));
}
示例7: G_CurseValidTarget
qboolean G_CurseValidTarget (edict_t *self, edict_t *target, qboolean vis, qboolean isCurse)
{
if (!G_EntIsAlive(target))
return false;
// don't target players with invulnerability
if (target->client && (target->client->invincible_framenum > level.framenum))
return false;
// don't target spawning players
if (target->client && (target->client->respawn_time > level.time))
return false;
// don't target players in chat-protect
if (!ptr->value && target->client && (target->flags & FL_CHATPROTECT))
return false;
// don't target spawning world monsters
if (target->activator && !target->activator->client && (target->svflags & SVF_MONSTER)
&& (target->deadflag != DEAD_DEAD) && (target->nextthink-level.time > 2*FRAMETIME))
return false;
// don't target cloaked players
if (target->client && target->svflags & SVF_NOCLIENT)
return false;
if (vis && !visible(self, target))
return false;
if(que_typeexists(target->curses, CURSE_FROZEN))
return false;
if (isCurse && (target->flags & FL_GODMODE || OnSameTeam(self, target)))
return false;
if (target == self)
return false;
return true;
}
示例8: Cmd_Say_f
/*
==================
Cmd_Say_f
==================
*/
void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0)
{
int j;
edict_t *other;
char *p;
char text[2048];
if (gi.argc () < 2 && !arg0)
return;
if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
team = false;
if (team)
Com_sprintf (text, sizeof(text), "(%s): ", ent->client->pers.netname);
else
Com_sprintf (text, sizeof(text), "%s: ", ent->client->pers.netname);
if (arg0)
{
strcat (text, gi.argv(0));
strcat (text, " ");
strcat (text, gi.args());
}
else
{
p = gi.args();
if (*p == '"')
{
p++;
p[strlen(p)-1] = 0;
}
strcat(text, p);
}
// don't let text be too long for malicious reasons
if (strlen(text) > 150)
text[150] = 0;
strcat(text, "\n");
if (dedicated->value)
gi.cprintf(NULL, PRINT_CHAT, "%s", text);
for (j = 1; j <= game.maxclients; j++)
{
other = &g_edicts[j];
if (!other->inuse)
continue;
if (!other->client)
continue;
if (team)
{
if (!OnSameTeam(ent, other))
continue;
}
gi.cprintf(other, PRINT_CHAT, "%s", text);
}
}
示例9: G_SayTo
static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message ) {
if (!other) {
return;
}
if (!other->inuse) {
return;
}
if (!other->client) {
return;
}
if ( other->client->pers.connected != CON_CONNECTED ) {
return;
}
if ( mode == SAY_TEAM && !OnSameTeam(ent, other) ) {
return;
}
// no chatting to players in tournements
if ( (g_gametype.integer == GT_TOURNAMENT )
&& other->client->sess.sessionTeam == TEAM_FREE
&& ent->client->sess.sessionTeam != TEAM_FREE ) {
return;
}
trap_SendServerCommand( other-g_entities, va("%s \"%s%c%c%s\"",
mode == SAY_TEAM ? "tchat" : "chat",
name, Q_COLOR_ESCAPE, color, message));
}
示例10: LogAccuracyHit
/*
===============
LogAccuracyHit
===============
*/
qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ) {
if( !target->takedamage ) {
return qfalse;
}
if ( target == attacker ) {
return qfalse;
}
if( !target->client ) {
return qfalse;
}
if( !attacker->client ) {
return qfalse;
}
if( target->client->ps.stats[STAT_HEALTH] <= 0 ) {
return qfalse;
}
if ( OnSameTeam( target, attacker ) ) {
return qfalse;
}
return qtrue;
}
示例11: FindEnemy
static edict_t *
FindEnemy(edict_t * self, int radius)
{
// loop through all nearby entities, looking for targets
edict_t * ent = 0;
int nPriority = 0; // 1 grenades, 2 clients, 3 pets
int nPotentialPriority = 0;
edict_t * enemy = 0;
while ((ent = findradius(ent, self->s.origin, 500)) != NULL)
{
if ((ent->flags & FL_NOTARGET)||(ent->svflags & SVF_NOCLIENT))
continue;
if (!ent->inuse || !ent->takedamage || (ent->health <= 0))
continue;
if (EntIsMonster(ent))
{
if (OnSameTeam(ent, self))
continue;
nPotentialPriority = 3;
}
else if (EntIsClient(ent))
{
if (OnSameTeam(ent, self))
continue;
nPotentialPriority = 2;
}
else
{
// first priority is grenades
// modify this if you don't want pets shooting grenades
nPotentialPriority = 1;
}
if (nPriority>nPotentialPriority)
continue;
if (!visible(self, ent))
continue;
// remember this candidate enemy
enemy = ent;
nPriority = nPotentialPriority;
}
// return best we found (might be zero)
return enemy;
}
示例12: parasite_cantarget
static qboolean parasite_cantarget (edict_t *self, edict_t *target)
{
int para_range = PARASITE_ATTACK_RANGE;
return (G_EntExists(target) && !que_typeexists(target->curses, CURSE_FROZEN)
&& !OnSameTeam(self, target) && visible(self, target) && nearfov(self, target, 45, 45)
&& (entdist(self, target) <= para_range));
}
示例13: GetNearbyTeammates
void GetNearbyTeammates(edict_t *self, char *buf)
{
unsigned char nearby_teammates[10][16];
int nearby_teammates_num, l;
edict_t *ent = NULL;
nearby_teammates_num = 0;
while ((ent = findradius(ent, self->s.origin, 1500)) != NULL)
{
if (ent == self || !ent->client || !CanDamage(ent, self) ||
OnSameTeam(ent, self))
continue;
strncpy(nearby_teammates[nearby_teammates_num], ent->client->pers.netname, 15);
nearby_teammates[nearby_teammates_num][15] = 0; // in case their name is 15 chars...
nearby_teammates_num++;
if (nearby_teammates_num >= 10)
break;
}
if (nearby_teammates_num == 0)
{
strcpy(buf, "nobody");
return;
}
for (l = 0; l < nearby_teammates_num; l++)
{
if (l == 0)
{
strcpy(buf, nearby_teammates[l]);
}
else
{
if (nearby_teammates_num == 2)
{
strcat(buf, " and ");
strcat(buf, nearby_teammates[l]);
}
else
{
if (l == (nearby_teammates_num - 1))
{
strcat(buf, ", and ");
strcat(buf, nearby_teammates[l]);
}
else
{
strcat(buf, ", ");
strcat(buf, nearby_teammates[l]);
}
}
}
}
}
示例14: supplystation_pain
void supplystation_pain (edict_t *self, edict_t *other, float kick, int damage)
{
if (G_EntExists(other) && !OnSameTeam(self, other) && (level.time > self->random))
{
if (other->client)
gi.centerprintf(self->creator, "%s is attacking\nyour station!\n", other->client->pers.netname);
else
gi.centerprintf(self->creator, "Your station is under\nattack!");
self->random = level.time + 5;
}
}
示例15: PassLovedOneCheck
//We cannot hurt the ones we love. Unless of course this
//function says we can.
int PassLovedOneCheck(bot_state_t *bs, gentity_t *ent)
{
int i;
bot_state_t *loved;
if (!bs->lovednum)
{
return 1;
}
if (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL)
{ //There is no love in 1-on-1
return 1;
}
i = 0;
if (!botstates[ent->s.number])
{ //not a bot
return 1;
}
if (!bot_attachments.integer)
{
return 1;
}
loved = botstates[ent->s.number];
while (i < bs->lovednum)
{
if (strcmp(level.clients[loved->client].pers.netname, bs->loved[i].name) == 0)
{
if (!IsTeamplay() && bs->loved[i].level < 2)
{ //if FFA and level of love is not greater than 1, just don't care
return 1;
}
else if (IsTeamplay() && !OnSameTeam(&g_entities[bs->client], &g_entities[loved->client]) && bs->loved[i].level < 2)
{ //is teamplay, but not on same team and level < 2
return 1;
}
else
{
return 0;
}
}
i++;
}
return 1;
}