
//===========================================================================
//
// Name:			bb_g_macros.h
//===========================================================================


// make num fit between min & max, inclusive
#define		BB_MACRO_FIT_TO_RANGE(num, min, max) \
				(((num) <= (min)) ? (min) : (((num) > (max)) ? (max) : (num)))

// num squared
#define		BB_MACRO_MAKE_EXPONENTIAL(num) \
				((num) * (num))

// an exponential curve rotated about the line from 0,0 to 1,1
// num must be <= 1.0
#define		BB_MACRO_MAKE_REVERSE_EXPONENTIAL(num) \
				(1 - ((1 - (num)) * (1 - (num))))

// maps to a sine curve from 0 to 1
// num must be <= 1.0
#define		BB_MACRO_MAKE_SINE_WAVE(num) \
				(((sin((180 * (num)) - 90)) + 1) * 0.5)

// BB begin BOTAI TEMP
// these should only be used in the bot AI code...
#define		BB_MACRO_VALIDATE_WEAPONNUM(weap, loc)							   \
		if (weap < WP_GAUNTLET || weap > WP_HANDGRENADE)							   \
		  {																	   \
		    char n[MAX_NETNAME];											   \
			ClientName (bs->entitynum, n, sizeof(n));					       \
			BotAI_Print (PRT_ERROR, "%s - invalid weapon number=%d at %s\n",   \
			             n, weap, loc);										   \
		  }																	   \
		else if ((bs->cur_ps.stats[STAT_WEAPONS] & (1 << weap)) == 0)		   \
		  {																	   \
		    char n[MAX_NETNAME];											   \
			ClientName (bs->entitynum, n, sizeof(n));						   \
			BotAI_Print(PRT_ERROR, "%s - dont have weapon number=%d at %s\n",  \
			            n, weap, loc);										   \
		  }

#define		BB_MACRO_VALID_WEAPONNUM(weap)									   \
		((weap >= WP_GAUNTLET && weap <= WP_HANDGRENADE) &&							   \
		 (bs->cur_ps.stats[STAT_WEAPONS] & (1 << weap)))

#define		BB_MACRO_VALIDATE_ENTNUM(ent, loc)								   \
		if (ent < 0 || ent > ENTITYNUM_WORLD)								   \
		  {																	   \
			BotAI_Print (PRT_ERROR, "invalid entity number=%d at %s\n",		   \
			             ent, loc);											   \
		  }																	   \

#define		BB_MACRO_VALID_ENTNUM(ent)										   \
		((ent) >= 0 && (ent) <= ENTITYNUM_WORLD)

