Quake Style - Quake 3 Tutorials
Code Helpers - Visible for Quake 3
Can two objects can see each other? Find out! (Function was in Quake 2!)

Just like the FindRadius tutorial, this function makes up for some lack of code helpers in the Quake 3 source code. If you are an experienced programmer and you want more functionality, check this. But beware newbies, this doesn't actually add any functionality to the code :)

Open up g_utils.c, and go down the bottom. Add this code:

// (NOBODY): Code helper function
//
qboolean visible( gentity_t *ent1, gentity_t *ent2 ) {
	trace_t         trace;

	trap_Trace (&trace, ent1->s.pos.trBase, NULL, NULL, ent2->s.pos.trBase, ent1->s.number, MASK_SHOT );

	if ( trace.contents & CONTENTS_SOLID ) {
		return qfalse;
	}

	return qtrue;
}


Then, add the function definition to the bottom of g_local.h as so:

qboolean visible( gentity_t *ent1, gentity_t *ent2 );


There. You're done. Have fun. (hehe)

-- Credits:
   Tutorial by (nobody)
   Return to QS Tutorials

-- Important:
   If you do use something from QuakeStyle in your mod, please give us credit.
   Our code is copyrighted, but we give permission to everyone to use it in any way they see fit, as long as we are recognized.