/* ================== BotValidChatPosition ================== */ int BotValidChatPosition(bot_state_t *bs) { vec3_t point, start, end, mins, maxs; bsp_trace_t trace; //if the bot is dead all positions are valid if (BotIsDead(bs)) return qtrue; //never start chatting with a powerup if (bs->inventory[INVENTORY_QUAD] || bs->inventory[INVENTORY_ENVIRONMENTSUIT] || bs->inventory[INVENTORY_HASTE] || bs->inventory[INVENTORY_INVISIBILITY] || bs->inventory[INVENTORY_REGEN] || bs->inventory[INVENTORY_FLIGHT]) return qfalse; //must be on the ground //if (bs->cur_ps.groundEntityNum != ENTITYNUM_NONE) return qfalse; //do not chat if in lava or slime VectorCopy(bs->origin, point); point[2] -= 24; if (trap_PointContents(point,bs->entitynum) & (CONTENTS_LAVA|CONTENTS_SLIME)) return qfalse; //do not chat if under water VectorCopy(bs->origin, point); point[2] += 32; if (trap_PointContents(point,bs->entitynum) & MASK_WATER) return qfalse; //must be standing on the world entity VectorCopy(bs->origin, start); VectorCopy(bs->origin, end); start[2] += 1; end[2] -= 10; trap_AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, mins, maxs); BotAI_Trace(&trace, start, mins, maxs, end, bs->playernum, MASK_SOLID); if (trace.entityNum != ENTITYNUM_WORLD) return qfalse; //the bot is in a position where it can chat return qtrue; }
/* ================== BotValidChatPosition ================== */ int BotValidChatPosition( bot_state_t *bs ) { vec3_t point, start, end, mins, maxs; bsp_trace_t trace; //if the bot is dead all positions are valid if ( BotIsDead( bs ) ) { return qtrue; } //must be on the ground //if (bs->cur_ps.groundEntityNum != ENTITYNUM_NONE) return qfalse; //do not chat if in lava or slime VectorCopy( bs->origin, point ); point[2] -= 24; if ( trap_PointContents( point,bs->entitynum ) & ( CONTENTS_LAVA | CONTENTS_SLIME ) ) { return qfalse; } //do not chat if under water VectorCopy( bs->origin, point ); point[2] += 32; if ( trap_PointContents( point,bs->entitynum ) & MASK_WATER ) { return qfalse; } //must be standing on the world entity VectorCopy( bs->origin, start ); VectorCopy( bs->origin, end ); start[2] += 1; end[2] -= 10; trap_AAS_PresenceTypeBoundingBox( PRESENCE_CROUCH, mins, maxs ); BotAI_Trace( &trace, start, mins, maxs, end, bs->client, MASK_SOLID ); if ( trace.ent != ENTITYNUM_WORLD ) { return qfalse; } //the bot is in a position where it can chat return qtrue; }
/* ================ Bot_ScriptThink ================ */ void Bot_ScriptThink(void) { int i; bot_state_t *bs; for(i = 0; i < level.maxclients; i++) { // get the bot for this entity num bs = &botstates[i]; // if there's no bot here, skip it if(!bs->inuse) { continue; } // if the bot is dead, skip it if(BotIsDead(bs)) { continue; } Bot_ScriptRun(bs, qfalse); } }