Пример #1
0
/*
* G_SpawnQueue_Init
*/
void G_SpawnQueue_Init( void )
{
	int spawnsystem, team;
	cvar_t *g_spawnsystem;
	cvar_t *g_spawnsystem_wave_time;
	cvar_t *g_spawnsystem_wave_maxcount;

	g_spawnsystem = trap_Cvar_Get( "g_spawnsystem", va( "%i", SPAWNSYSTEM_INSTANT ), CVAR_DEVELOPER );
	g_spawnsystem_wave_time = trap_Cvar_Get( "g_spawnsystem_wave_time", va( "%i", REINFORCEMENT_WAVE_DELAY ), CVAR_ARCHIVE );
	g_spawnsystem_wave_maxcount = trap_Cvar_Get( "g_spawnsystem_wave_maxcount", va( "%i", REINFORCEMENT_WAVE_MAXCOUNT ), CVAR_ARCHIVE );

	memset( g_spawnQueues, 0, sizeof( g_spawnQueues ) );
	for( team = TEAM_SPECTATOR; team < GS_MAX_TEAMS; team++ )
		memset( &g_spawnQueues[team].list, -1, sizeof( g_spawnQueues[team].list ) );

	spawnsystem = g_spawnsystem->integer;
	clamp( spawnsystem, SPAWNSYSTEM_INSTANT, SPAWNSYSTEM_HOLD );
	if( spawnsystem != g_spawnsystem->integer )
		trap_Cvar_ForceSet( "g_spawnsystem", va( "%i", spawnsystem ) );

	for( team = TEAM_SPECTATOR; team < GS_MAX_TEAMS; team++ )
	{
		if( team == TEAM_SPECTATOR )
			G_SpawnQueue_SetTeamSpawnsystem( team, SPAWNSYSTEM_INSTANT, 0, 0, false );
		else
			G_SpawnQueue_SetTeamSpawnsystem( team, spawnsystem, g_spawnsystem_wave_time->integer, g_spawnsystem_wave_maxcount->integer, true );
	}
}
Пример #2
0
/*
* G_Teams_InitLevel
*/
void G_Teams_Init( void )
{
	edict_t	*ent;

	// set the team names with default ones
	trap_ConfigString( CS_TEAM_SPECTATOR_NAME, GS_DefaultTeamName( TEAM_SPECTATOR ) );
	trap_ConfigString( CS_TEAM_PLAYERS_NAME, GS_DefaultTeamName( TEAM_PLAYERS ) );
	trap_ConfigString( CS_TEAM_ALPHA_NAME, GS_DefaultTeamName( TEAM_ALPHA ) );
	trap_ConfigString( CS_TEAM_BETA_NAME, GS_DefaultTeamName( TEAM_BETA ) );

	g_teams_maxplayers = trap_Cvar_Get( "g_teams_maxplayers", "0", CVAR_ARCHIVE );
	g_teams_allow_uneven = trap_Cvar_Get( "g_teams_allow_uneven", "1", CVAR_ARCHIVE );

	//unlock all teams and clear up team lists
	memset( teamlist, 0, sizeof( teamlist ) );

	for( ent = game.edicts + 1; PLAYERNUM( ent ) < gs.maxclients; ent++ )
	{
		if( ent->r.inuse )
		{
			memset( &ent->r.client->teamstate, 0, sizeof( ent->r.client->teamstate ) );
			memset( &ent->r.client->resp, 0, sizeof( ent->r.client->resp ) );
			ent->s.team = ent->r.client->team = TEAM_SPECTATOR;
			G_GhostClient( ent );
			ent->movetype = MOVETYPE_NOCLIP; // allow freefly
			ent->r.client->teamstate.timeStamp = level.time;
			ent->r.client->resp.timeStamp = level.time;
		}
	}

}
Пример #3
0
/*
* TVM_Init
*
* This will be called when the dll is first loaded
*/
void TVM_Init( const char *game, unsigned int maxclients ) {
	TVM_Printf( "==== TVM_Init ====\n" );

	developer = trap_Cvar_Get( "developer", "0", 0 );

	// chase cam mode for spawning specs, 'carriers' by default
	tv_chasemode = trap_Cvar_Get( "tv_chasemode", "6", 0 );

	memset( &tvm, 0, sizeof( tvm ) );
	tvm.maxclients = maxclients;
}
Пример #4
0
/*
* CG_TestBlend
*/
void CG_AddTest( void )
{
	if( !cg_testEntities || !cg_testLights )
	{
		cg_testEntities =	trap_Cvar_Get( "cg_testEntities", "0", CVAR_CHEAT );
		cg_testLights =		trap_Cvar_Get( "cg_testLights", "0", CVAR_CHEAT );
	}

	if( cg_testEntities->integer )
		CG_TestEntities();
	if( cg_testLights->integer )
		CG_TestLights();
}
Пример #5
0
/*
* CG_ThirdPersonOffsetView
*/
static void CG_ThirdPersonOffsetView( cg_viewdef_t *view )
{
	float dist, f, r;
	vec3_t dest, stop;
	vec3_t chase_dest;
	trace_t	trace;
	vec3_t mins = { -4, -4, -4 };
	vec3_t maxs = { 4, 4, 4 };

	if( !cg_thirdPersonAngle || !cg_thirdPersonRange )
	{
		cg_thirdPersonAngle = trap_Cvar_Get( "cg_thirdPersonAngle", "0", CVAR_ARCHIVE );
		cg_thirdPersonRange = trap_Cvar_Get( "cg_thirdPersonRange", "70", CVAR_ARCHIVE );
	}

	// calc exact destination
	VectorCopy( view->origin, chase_dest );
	r = DEG2RAD( cg_thirdPersonAngle->value );
	f = -cos( r );
	r = -sin( r );
	VectorMA( chase_dest, cg_thirdPersonRange->value * f, &view->axis[AXIS_FORWARD], chase_dest );
	VectorMA( chase_dest, cg_thirdPersonRange->value * r, &view->axis[AXIS_RIGHT], chase_dest );
	chase_dest[2] += 8;

	// find the spot the player is looking at
	VectorMA( view->origin, 512, &view->axis[AXIS_FORWARD], dest );
	CG_Trace( &trace, view->origin, mins, maxs, dest, view->POVent, MASK_SOLID );

	// calculate pitch to look at the same spot from camera
	VectorSubtract( trace.endpos, view->origin, stop );
	dist = sqrt( stop[0] * stop[0] + stop[1] * stop[1] );
	if( dist < 1 )
		dist = 1;
	view->angles[PITCH] = RAD2DEG( -atan2( stop[2], dist ) );
	view->angles[YAW] -= cg_thirdPersonAngle->value;
	Matrix3_FromAngles( view->angles, view->axis );

	// move towards destination
	CG_Trace( &trace, view->origin, mins, maxs, chase_dest, view->POVent, MASK_SOLID );

	if( trace.fraction != 1.0 )
	{
		VectorCopy( trace.endpos, stop );
		stop[2] += ( 1.0 - trace.fraction ) * 32;
		CG_Trace( &trace, view->origin, mins, maxs, stop, view->POVent, MASK_SOLID );
		VectorCopy( trace.endpos, chase_dest );
	}

	VectorCopy( chase_dest, view->origin );
}
Пример #6
0
/*
* CG_RegisterFonts
*/
void CG_RegisterFonts( void )
{
	cvar_t *con_fontSystemFamily = trap_Cvar_Get( "con_fontSystemFamily", DEFAULT_SYSTEM_FONT_FAMILY, CVAR_ARCHIVE );
	cvar_t *con_fontSystemSmallSize = trap_Cvar_Get( "con_fontSystemSmallSize", STR_TOSTR( DEFAULT_SYSTEM_FONT_SMALL_SIZE ), CVAR_ARCHIVE );
	cvar_t *con_fontSystemMediumSize = trap_Cvar_Get( "con_fontSystemMediumSize", STR_TOSTR( DEFAULT_SYSTEM_FONT_MEDIUM_SIZE ), CVAR_ARCHIVE );
	cvar_t *con_fontSystemBigSize = trap_Cvar_Get( "con_fontSystemBigSize", STR_TOSTR( DEFAULT_SYSTEM_FONT_BIG_SIZE ), CVAR_ARCHIVE );

	// register system fonts
	Q_strncpyz( cgs.fontSystemFamily, con_fontSystemFamily->string, sizeof( cgs.fontSystemFamily ) );
	if( !con_fontSystemSmallSize->integer ) {
		trap_Cvar_Set( con_fontSystemSmallSize->name, con_fontSystemSmallSize->dvalue );
	}
	if( !con_fontSystemMediumSize->integer ) {
		trap_Cvar_Set( con_fontSystemMediumSize->name, con_fontSystemMediumSize->dvalue );
	}
	if( !con_fontSystemBigSize->integer ) {
		trap_Cvar_Set( con_fontSystemBigSize->name, con_fontSystemBigSize->dvalue );
	}

	float scale = cgs.vidHeight / 600.0f;
	if( scale < 0.4f )
		scale = 0.4f;

	cgs.fontSystemSmallSize = ceilf( con_fontSystemSmallSize->integer * scale );
	cgs.fontSystemSmall = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemSmallSize );
	if( !cgs.fontSystemSmall )
	{
		Q_strncpyz( cgs.fontSystemFamily, DEFAULT_SYSTEM_FONT_FAMILY, sizeof( cgs.fontSystemFamily ) );
		cgs.fontSystemSmallSize = ceilf( DEFAULT_SYSTEM_FONT_SMALL_SIZE * scale );

		cgs.fontSystemSmall = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemSmallSize );
		if( !cgs.fontSystemSmall )
			CG_Error( "Couldn't load default font \"%s\"", cgs.fontSystemFamily );
	}

	cgs.fontSystemMediumSize = ceilf( con_fontSystemMediumSize->integer * scale );
	cgs.fontSystemMedium = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemMediumSize );
	if( !cgs.fontSystemMedium ) {
		cgs.fontSystemMediumSize = ceilf( DEFAULT_SYSTEM_FONT_MEDIUM_SIZE * scale );
		cgs.fontSystemMedium = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemMediumSize );
	}

	cgs.fontSystemBigSize = ceilf( con_fontSystemBigSize->integer * scale );
	cgs.fontSystemBig = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemBigSize );
	if( !cgs.fontSystemBig ) {
		cgs.fontSystemBigSize = ceilf( DEFAULT_SYSTEM_FONT_BIG_SIZE * scale );
		cgs.fontSystemBig = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemBigSize );
	}
}
Пример #7
0
/*
* G_ProjectileDistancePrestep
*/
static void G_ProjectileDistancePrestep( edict_t *projectile, float distance )
{
	float speed;
	vec3_t dir, dest;
	int mask, i;
	trace_t	trace;
#ifdef PLASMAHACK
	vec3_t plasma_hack_start;
#endif

	if( projectile->movetype != MOVETYPE_TOSS 
		&& projectile->movetype != MOVETYPE_LINEARPROJECTILE
		&& projectile->movetype != MOVETYPE_BOUNCE 
		&& projectile->movetype != MOVETYPE_BOUNCEGRENADE )
		return;

	if( !distance )
		return;

	if( ( speed = VectorNormalize2( projectile->velocity, dir ) ) == 0.0f )
		return;

	mask = ( projectile->r.clipmask ) ? projectile->r.clipmask : MASK_SHOT; // race trick should come set up inside clipmask

	if( projectile->movetype == MOVETYPE_LINEARPROJECTILE )
		VectorCopy( projectile->s.origin2, projectile->s.origin );

#ifdef PLASMAHACK
	VectorCopy( projectile->s.origin, plasma_hack_start );
#endif

	VectorMA( projectile->s.origin, distance, dir, dest );
	G_Trace4D( &trace, projectile->s.origin, projectile->r.mins, projectile->r.maxs, dest, projectile->r.owner, mask, projectile->timeDelta );

	for( i = 0; i < 3; i++ )
		projectile->s.origin[i] = projectile->s.origin2[i] = projectile->olds.origin[i] = projectile->olds.origin2[i] = trace.endpos[i];

	GClip_LinkEntity( projectile );
	SV_Impact( projectile, &trace );

	// set initial water state
	if( !projectile->r.inuse )
		return;

	projectile->waterlevel = ( G_PointContents4D( projectile->s.origin, projectile->timeDelta ) & MASK_WATER ) ? qtrue : qfalse;

	// ffs : hack for the plasmagun
#ifdef PLASMAHACK
	if( projectile->s.type == ET_PLASMA )
		if (trap_Cvar_Get( "rs_plasma_hack", "1", CVAR_ARCHIVE )->integer==1)//racesow
			W_Plasma_Backtrace( projectile, plasma_hack_start );
#endif
}
Пример #8
0
/*
* W_Fire_Grenade
*/
edict_t *W_Fire_Grenade( edict_t *self, vec3_t start, vec3_t angles, int speed, float damage,
						int minKnockback, int maxKnockback, int stun, int minDamage, float radius,
						int timeout, int mod, int timeDelta, qboolean aim_up )
{
	edict_t	*grenade;
	static cvar_t *g_grenade_gravity = NULL;

	if( GS_Instagib() )
		damage = 9999;

	if( !g_grenade_gravity )
		g_grenade_gravity = trap_Cvar_Get( "g_grenade_gravity", "1.3", CVAR_DEVELOPER );

	if( aim_up )
	{
		angles[PITCH] -= 10; // aim some degrees upwards from view dir

		// clamp to front side of the player
		angles[PITCH] += -90; // rotate to make easier the check
		while( angles[PITCH] < -360 ) angles[PITCH] += 360;
		clamp( angles[PITCH], -180, 0 );
		angles[PITCH] += 90;
		while( angles[PITCH] > 360 ) angles[PITCH] -= 360;
	}

	grenade = W_Fire_TossProjectile( self, start, angles, speed, damage, minKnockback, maxKnockback, stun, minDamage, radius, timeout, timeDelta );
	VectorClear( grenade->s.angles );
	grenade->style = mod;
	grenade->s.type = ET_GRENADE;
	grenade->movetype = MOVETYPE_BOUNCEGRENADE;
	grenade->touch = W_Touch_Grenade;
	grenade->use = NULL;
	grenade->think = W_Grenade_Explode;
	grenade->classname = "grenade";
	grenade->gravity = g_grenade_gravity->value;
	grenade->enemy = NULL;

	if( mod == MOD_GRENADE_S )
	{
		grenade->s.modelindex = trap_ModelIndex( PATH_GRENADE_STRONG_MODEL );
		grenade->s.effects |= EF_STRONG_WEAPON;
	}
	else
	{
		grenade->s.modelindex = trap_ModelIndex( PATH_GRENADE_WEAK_MODEL );
		grenade->s.effects &= ~EF_STRONG_WEAPON;
	}

	GClip_LinkEntity( grenade );

	return grenade;
}
Пример #9
0
/*
* UI_RegisterFonts
*/
static void UI_RegisterFonts( void )
{
	cvar_t *con_fontSystemSmall = trap_Cvar_Get( "con_fontSystemSmall", DEFAULT_FONT_SMALL, CVAR_ARCHIVE );
	cvar_t *con_fontSystemMedium = trap_Cvar_Get( "con_fontSystemMedium", DEFAULT_FONT_MEDIUM, CVAR_ARCHIVE );
	cvar_t *con_fontSystemBig = trap_Cvar_Get( "con_fontSystemBig", DEFAULT_FONT_BIG, CVAR_ARCHIVE );

	uis.fontSystemSmall = trap_SCR_RegisterFont( con_fontSystemSmall->string );
	if( !uis.fontSystemSmall )
	{
		uis.fontSystemSmall = trap_SCR_RegisterFont( DEFAULT_FONT_SMALL );
		if( !uis.fontSystemSmall )
			UI_Error( "Couldn't load default font \"%s\"", DEFAULT_FONT_SMALL );
	}
	uis.fontSystemMedium = trap_SCR_RegisterFont( con_fontSystemMedium->string );
	if( !uis.fontSystemMedium )
		uis.fontSystemMedium = trap_SCR_RegisterFont( DEFAULT_FONT_MEDIUM );

	uis.fontSystemBig = trap_SCR_RegisterFont( con_fontSystemBig->string );
	if( !uis.fontSystemBig )
		uis.fontSystemBig = trap_SCR_RegisterFont( DEFAULT_FONT_BIG );

}
Пример #10
0
/*
* SF_Init
*/
bool SF_Init( void *hwnd, int maxEntities, bool verbose )
{
	soundpool = S_MemAllocPool( "OpenAL sound module" );
	
	s_num_ent_spats = 0;

#ifdef OPENAL_RUNTIME
	if( !QAL_Init( ALDRIVER, verbose ) )
	{
#ifdef ALDRIVER_ALT
		if( !QAL_Init( ALDRIVER_ALT, verbose ) )
#endif
		{
			Com_Printf( "Failed to load OpenAL library: %s\n", ALDRIVER );
			return false;
		}
	}
#endif

	s_volume = trap_Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
	s_musicvolume = trap_Cvar_Get( "s_musicvolume", "0.15", CVAR_ARCHIVE );
	s_doppler = trap_Cvar_Get( "s_doppler", "1.0", CVAR_ARCHIVE );
	s_sound_velocity = trap_Cvar_Get( "s_sound_velocity", "10976", CVAR_DEVELOPER );
	s_stereo2mono = trap_Cvar_Get ( "s_stereo2mono", "0", CVAR_ARCHIVE );
	s_globalfocus = trap_Cvar_Get( "s_globalfocus", "0", CVAR_ARCHIVE );

#ifdef ENABLE_PLAY
	trap_Cmd_AddCommand( "play", SF_Play_f );
#endif
	trap_Cmd_AddCommand( "music", SF_Music_f );
	trap_Cmd_AddCommand( "stopmusic", SF_StopBackgroundTrack );
	trap_Cmd_AddCommand( "prevmusic", SF_PrevBackgroundTrack );
	trap_Cmd_AddCommand( "nextmusic", SF_NextBackgroundTrack );
	trap_Cmd_AddCommand( "pausemusic", SF_PauseBackgroundTrack );
	trap_Cmd_AddCommand( "soundlist", SF_SoundList_f );
	trap_Cmd_AddCommand( "s_devices", SF_ListDevices_f );

	s_cmdPipe = S_CreateSoundCmdPipe();
	if( !s_cmdPipe ) {
		return false;
	}

	s_backThread = trap_Thread_Create( S_BackgroundUpdateProc, s_cmdPipe );

	S_IssueInitCmd( s_cmdPipe, hwnd, maxEntities, verbose );

	S_FinishSoundCmdPipe( s_cmdPipe );

	if( !alContext ) {
		return false;
	}

	S_InitBuffers();

	return true;
}
Пример #11
0
static void UpdateTeamCvars( void )
{
	switch( currentTEAM )
	{
	case TEAM_ALPHA:
		model = trap_Cvar_Get( "cg_teamALPHAmodel", "", CVAR_ARCHIVE );
		skin = trap_Cvar_Get( "cg_teamALPHAskin", "", CVAR_ARCHIVE );
		color = trap_Cvar_Get( "cg_teamALPHAcolor", DEFAULT_TEAMALPHA_COLOR, CVAR_ARCHIVE );
		break;
	case TEAM_BETA:
		model = trap_Cvar_Get( "cg_teamBETAmodel", "", CVAR_ARCHIVE );
		skin = trap_Cvar_Get( "cg_teamBETAskin", "", CVAR_ARCHIVE );
		color = trap_Cvar_Get( "cg_teamBETAcolor", DEFAULT_TEAMBETA_COLOR, CVAR_ARCHIVE );
		break;
	case TEAM_PLAYERS:
	default:
		model = trap_Cvar_Get( "cg_teamPLAYERSmodel", "", CVAR_ARCHIVE );
		skin = trap_Cvar_Get( "cg_teamPLAYERSskin", "", CVAR_ARCHIVE );
		color = trap_Cvar_Get( "cg_teamPLAYERScolor", "", CVAR_ARCHIVE );
		break;
	}
}
Пример #12
0
/*
* SF_Init
*/
bool SF_Init( void *hwnd, int maxEntities, bool verbose )
{
	soundpool = S_MemAllocPool( "QF Sound Module" );

	developer = trap_Cvar_Get( "developer", "0", 0 );

	s_volume = trap_Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
	s_musicvolume = trap_Cvar_Get( "s_musicvolume", "0.2", CVAR_ARCHIVE );
	s_khz = trap_Cvar_Get( "s_khz", "44", CVAR_ARCHIVE|CVAR_LATCH_SOUND );
	s_mixahead = trap_Cvar_Get( "s_mixahead", "0.14", CVAR_ARCHIVE );
	s_show = trap_Cvar_Get( "s_show", "0", CVAR_CHEAT );
	s_testsound = trap_Cvar_Get( "s_testsound", "0", 0 );
	s_swapstereo = trap_Cvar_Get( "s_swapstereo", "0", CVAR_ARCHIVE );
	s_vorbis = trap_Cvar_Get( "s_vorbis", "1", CVAR_ARCHIVE );
	s_pseudoAcoustics = trap_Cvar_Get( "s_pseudoAcoustics", "0", CVAR_ARCHIVE );
	s_separationDelay = trap_Cvar_Get( "s_separationDelay", "1.0", CVAR_ARCHIVE );
	s_globalfocus = trap_Cvar_Get( "s_globalfocus", "0", CVAR_ARCHIVE );

#ifdef ENABLE_PLAY
	trap_Cmd_AddCommand( "play", SF_Play_f );
#endif
	trap_Cmd_AddCommand( "music", SF_Music_f );
	trap_Cmd_AddCommand( "stopsound", SF_StopAllSounds_f );
	trap_Cmd_AddCommand( "stopmusic", SF_StopBackgroundTrack );
	trap_Cmd_AddCommand( "prevmusic", SF_PrevBackgroundTrack );
	trap_Cmd_AddCommand( "nextmusic", SF_NextBackgroundTrack );
	trap_Cmd_AddCommand( "pausemusic", SF_PauseBackgroundTrack );
	trap_Cmd_AddCommand( "soundlist", SF_SoundList_f );
	trap_Cmd_AddCommand( "soundinfo", SF_SoundInfo_f );

	num_sfx = 0;
	
	s_num_ent_spats = 0;

	s_registration_sequence = 1;
	s_registering = false;

	s_cmdPipe = S_CreateSoundCmdPipe();
	if( !s_cmdPipe ) {
		return false;
	}

	s_backThread = trap_Thread_Create( S_BackgroundUpdateProc, s_cmdPipe );

	S_IssueInitCmd( s_cmdPipe, hwnd, maxEntities, verbose );

	S_FinishSoundCmdPipe( s_cmdPipe );

	if( !dma.buffer )
		return false;

	SF_SetAttenuationModel( S_DEFAULT_ATTENUATION_MODEL, 
		S_DEFAULT_ATTENUATION_MAXDISTANCE, S_DEFAULT_ATTENUATION_REFDISTANCE );

	return true;
}
Пример #13
0
/*
* W_Touch_Grenade
*/
static void W_Touch_Grenade( edict_t *ent, edict_t *other, cplane_t *plane, int surfFlags )
{
	int hitType;
	vec3_t dir;

	if( surfFlags & SURF_NOIMPACT )
	{
		G_FreeEdict( ent );
		return;
	}

	hitType = G_Projectile_HitStyle( ent, other );
	if( hitType == PROJECTILE_TOUCH_NOT )
		return;

	// don't explode on doors and plats that take damage
	if( !other->takedamage || ISBRUSHMODEL( other->s.modelindex ) )
	{
		// kill some velocity on each bounce
		float fric;
		static cvar_t *g_grenade_friction = NULL;

		if( !g_grenade_friction )
			g_grenade_friction = trap_Cvar_Get( "g_grenade_friction", "0.85", CVAR_DEVELOPER );

		fric = bound( 0, g_grenade_friction->value, 1 );
		VectorScale( ent->velocity, fric, ent->velocity );

		G_AddEvent( ent, EV_GRENADE_BOUNCE, ( ent->s.effects & EF_STRONG_WEAPON ) ? FIRE_MODE_STRONG : FIRE_MODE_WEAK, qtrue );
		return;
	}

	if( other->takedamage )
	{
		int directHitDamage = ent->projectileInfo.maxDamage;

		VectorNormalize2( ent->velocity, dir );

		if( hitType == PROJECTILE_TOUCH_DIRECTSPLASH ) // use hybrid direction from splash and projectile
		{
			G_SplashFrac4D( ENTNUM( other ), ent->s.origin, ent->projectileInfo.radius, dir, NULL, NULL, ent->timeDelta );
		}
		else
		{
			VectorNormalize2( ent->velocity, dir );

			// no direct hit bonuses for grenades
			/*
			if( hitType == PROJECTILE_TOUCH_DIRECTAIRHIT )
				directHitDamage += DIRECAIRTHIT_DAMAGE_BONUS;
			else if( hitType == PROJECTILE_TOUCH_DIRECTHIT )
				directHitDamage += DIRECTHIT_DAMAGE_BONUS;
			*/
		}

		G_Damage( other, ent, ent->r.owner, dir, ent->velocity, ent->s.origin, directHitDamage, ent->projectileInfo.maxKnockback, ent->projectileInfo.stun, 0, ent->style );
	}

	ent->enemy = other;
	W_Grenade_ExplodeDir( ent, plane ? plane->normal : NULL );
}
Пример #14
0
//==========================================
// AI_InitLevel
// Inits Map local parameters
//==========================================
void AI_InitLevel( void )
{
	edict_t	*ent;

	//Init developer mode
	bot_showpath = trap_Cvar_Get( "bot_showpath", "0", 0 );
	bot_showcombat = trap_Cvar_Get( "bot_showcombat", "0", 0 );
	bot_showsrgoal = trap_Cvar_Get( "bot_showsrgoal", "0", 0 );
	bot_showlrgoal = trap_Cvar_Get( "bot_showlrgoal", "0", 0 );
	bot_dummy = trap_Cvar_Get( "bot_dummy", "0", 0 );
	sv_botpersonality =	    trap_Cvar_Get( "sv_botpersonality", "0", CVAR_ARCHIVE );

	nav.debugMode = false;

	AI_InitNavigationData( false );

	// count bots
	game.numBots = 0;
	for( ent = game.edicts + 1; PLAYERNUM( ent ) < gs.maxclients; ent++ )
	{
		if( !ent->r.inuse || !ent->ai ) continue;
		if( ent->r.svflags & SVF_FAKECLIENT && AI_GetType( ent->ai ) == AI_ISBOT )
			game.numBots++;
	}

	// set up weapon usage weights

	memset( &AIWeapons, 0, sizeof( ai_weapon_t )*WEAP_TOTAL );

	//WEAP_GUNBLADE
	AIWeapons[WEAP_GUNBLADE].aimType = AI_AIMSTYLE_INSTANTHIT;
	AIWeapons[WEAP_GUNBLADE].RangeWeight[AIWEAP_LONG_RANGE] = 0.1f;
	AIWeapons[WEAP_GUNBLADE].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.2f;
	AIWeapons[WEAP_GUNBLADE].RangeWeight[AIWEAP_SHORT_RANGE] = 0.3f;
	AIWeapons[WEAP_GUNBLADE].RangeWeight[AIWEAP_MELEE_RANGE] = 0.4f;

	//WEAP_MACHINEGUN
	AIWeapons[WEAP_MACHINEGUN].aimType = AI_AIMSTYLE_INSTANTHIT;
	AIWeapons[WEAP_MACHINEGUN].RangeWeight[AIWEAP_LONG_RANGE] = 0.8f;
	AIWeapons[WEAP_MACHINEGUN].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.7f;
	AIWeapons[WEAP_MACHINEGUN].RangeWeight[AIWEAP_SHORT_RANGE] = 0.4f;
	AIWeapons[WEAP_MACHINEGUN].RangeWeight[AIWEAP_MELEE_RANGE] = 0.1f;

	//WEAP_RIOTGUN
	AIWeapons[WEAP_RIOTGUN].aimType = AI_AIMSTYLE_INSTANTHIT;
	AIWeapons[WEAP_RIOTGUN].RangeWeight[AIWEAP_LONG_RANGE] = 0.1f;
	AIWeapons[WEAP_RIOTGUN].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.5f;
	AIWeapons[WEAP_RIOTGUN].RangeWeight[AIWEAP_SHORT_RANGE] = 0.8f;
	AIWeapons[WEAP_RIOTGUN].RangeWeight[AIWEAP_MELEE_RANGE] = 0.5f;

	//ROCKETLAUNCHER
	AIWeapons[WEAP_ROCKETLAUNCHER].aimType = AI_AIMSTYLE_PREDICTION_EXPLOSIVE;
	AIWeapons[WEAP_ROCKETLAUNCHER].RangeWeight[AIWEAP_LONG_RANGE] = 0.2f;
	AIWeapons[WEAP_ROCKETLAUNCHER].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.5f;
	AIWeapons[WEAP_ROCKETLAUNCHER].RangeWeight[AIWEAP_SHORT_RANGE] = 0.9f;
	AIWeapons[WEAP_ROCKETLAUNCHER].RangeWeight[AIWEAP_MELEE_RANGE] = 0.6f;

	//WEAP_GRENADELAUNCHER
	AIWeapons[WEAP_GRENADELAUNCHER].aimType = AI_AIMSTYLE_DROP;
	AIWeapons[WEAP_GRENADELAUNCHER].RangeWeight[AIWEAP_LONG_RANGE] = 0.0f;
	AIWeapons[WEAP_GRENADELAUNCHER].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.1f;
	AIWeapons[WEAP_GRENADELAUNCHER].RangeWeight[AIWEAP_SHORT_RANGE] = 0.4f;
	AIWeapons[WEAP_GRENADELAUNCHER].RangeWeight[AIWEAP_MELEE_RANGE] = 0.3f;

	//WEAP_PLASMAGUN
	AIWeapons[WEAP_PLASMAGUN].aimType = AI_AIMSTYLE_PREDICTION;
	AIWeapons[WEAP_PLASMAGUN].RangeWeight[AIWEAP_LONG_RANGE] = 0.1f;
	AIWeapons[WEAP_PLASMAGUN].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.5f;
	AIWeapons[WEAP_PLASMAGUN].RangeWeight[AIWEAP_SHORT_RANGE] = 0.7f;
	AIWeapons[WEAP_PLASMAGUN].RangeWeight[AIWEAP_MELEE_RANGE] = 0.4f;

	//WEAP_ELECTROBOLT
	AIWeapons[WEAP_ELECTROBOLT].aimType = AI_AIMSTYLE_INSTANTHIT;
	AIWeapons[WEAP_ELECTROBOLT].RangeWeight[AIWEAP_LONG_RANGE] = 0.9f;
	AIWeapons[WEAP_ELECTROBOLT].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.7f;
	AIWeapons[WEAP_ELECTROBOLT].RangeWeight[AIWEAP_SHORT_RANGE] = 0.4f;
	AIWeapons[WEAP_ELECTROBOLT].RangeWeight[AIWEAP_MELEE_RANGE] = 0.3f;

	//WEAP_LASERGUN
	AIWeapons[WEAP_LASERGUN].aimType = AI_AIMSTYLE_INSTANTHIT;
	AIWeapons[WEAP_LASERGUN].RangeWeight[AIWEAP_LONG_RANGE] = 0.0f;
	AIWeapons[WEAP_LASERGUN].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.0f;
	AIWeapons[WEAP_LASERGUN].RangeWeight[AIWEAP_SHORT_RANGE] = 0.7f;
	AIWeapons[WEAP_LASERGUN].RangeWeight[AIWEAP_MELEE_RANGE] = 0.6f;

	//WEAP_INSTAGUN
	AIWeapons[WEAP_INSTAGUN].aimType = AI_AIMSTYLE_INSTANTHIT;
	AIWeapons[WEAP_INSTAGUN].RangeWeight[AIWEAP_LONG_RANGE] = 0.9f;
	AIWeapons[WEAP_INSTAGUN].RangeWeight[AIWEAP_MEDIUM_RANGE] = 0.9f;
	AIWeapons[WEAP_INSTAGUN].RangeWeight[AIWEAP_SHORT_RANGE] = 0.9f;
	AIWeapons[WEAP_INSTAGUN].RangeWeight[AIWEAP_MELEE_RANGE] = 0.9f;
}
Пример #15
0
/*
* S_Init
*/
static qboolean S_Init( void *hwnd, int maxEntities, qboolean verbose )
{
	int numDevices;
	int userDeviceNum = -1;
	char *devices, *defaultDevice;
	cvar_t *s_openAL_device;

	alDevice = NULL;
	alContext = NULL;

	// get system default device identifier
	defaultDevice = ( char * )qalcGetString( NULL, ALC_DEFAULT_DEVICE_SPECIFIER );
	if( !defaultDevice )
	{
		Com_Printf( "Failed to get openAL default device\n" );
		return qfalse;
	}

	s_openAL_device = trap_Cvar_Get( "s_openAL_device", ALDEVICE_DEFAULT ? ALDEVICE_DEFAULT : defaultDevice, CVAR_ARCHIVE|CVAR_LATCH_SOUND );

	devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
	for( numDevices = 0; *devices; devices += strlen( devices ) + 1, numDevices++ )
	{
		if( !Q_stricmp( s_openAL_device->string, devices ) )
		{
			userDeviceNum = numDevices;

			// force case sensitive
			if( strcmp( s_openAL_device->string, devices ) )
				trap_Cvar_ForceSet( "s_openAL_device", devices );
		}
	}

	if( !numDevices )
	{
		Com_Printf( "Failed to get openAL devices\n" );
		return qfalse;
	}

	// the device assigned by the user is not available
	if( userDeviceNum == -1 )
	{
		Com_Printf( "'s_openAL_device': incorrect device name, reseting to default\n" );

		trap_Cvar_ForceSet( "s_openAL_device", ALDEVICE_DEFAULT ? ALDEVICE_DEFAULT : defaultDevice );

		devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
		for( numDevices = 0; *devices; devices += strlen( devices ) + 1, numDevices++ )
		{
			if( !Q_stricmp( s_openAL_device->string, devices ) )
				userDeviceNum = numDevices;
		}

		if( userDeviceNum == -1 )
			trap_Cvar_ForceSet( "s_openAL_device", defaultDevice );
	}

	alDevice = qalcOpenDevice( (const ALchar *)s_openAL_device->string );
	if( !alDevice )
	{
		Com_Printf( "Failed to open device\n" );
		return qfalse;
	}

	// Create context
	alContext = qalcCreateContext( alDevice, NULL );
	if( !alContext )
	{
		Com_Printf( "Failed to create context\n" );
		return qfalse;
	}
	qalcMakeContextCurrent( alContext );

	if( verbose )
	{
		Com_Printf( "OpenAL initialized\n" );

		if( numDevices )
		{
			int i;

			Com_Printf( "  Devices:    " );

			devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
			for( i = 0; *devices; devices += strlen( devices ) + 1, i++ )
				Com_Printf( "%s%s", devices, ( i < numDevices - 1 ) ? ", " : "" );
			Com_Printf( "\n" );

			if( defaultDevice && *defaultDevice )
				Com_Printf( "  Default system device: %s\n", defaultDevice );

			Com_Printf( "\n" );
		}

		Com_Printf( "  Device:     %s\n", qalcGetString( alDevice, ALC_DEVICE_SPECIFIER ) );
		Com_Printf( "  Vendor:     %s\n", qalGetString( AL_VENDOR ) );
		Com_Printf( "  Version:    %s\n", qalGetString( AL_VERSION ) );
		Com_Printf( "  Renderer:   %s\n", qalGetString( AL_RENDERER ) );
		Com_Printf( "  Extensions: %s\n", qalGetString( AL_EXTENSIONS ) );
	}

	// Check for Linux shutdown race condition
	if( !Q_stricmp( qalGetString( AL_VENDOR ), "J. Valenzuela" ) )
		snd_shutdown_bug = qtrue;

	qalDopplerFactor( s_doppler->value );
	qalDopplerVelocity( s_sound_velocity->value > 0.0f ? s_sound_velocity->value : 0.0f );
	if( qalSpeedOfSound ) // opelAL 1.1 only. alDopplerVelocity being deprecated
		qalSpeedOfSound( s_sound_velocity->value > 0.0f ? s_sound_velocity->value : 0.0f );

	s_doppler->modified = qfalse;

	S_SetAttenuationModel( S_DEFAULT_ATTENUATION_MODEL, S_DEFAULT_ATTENUATION_MAXDISTANCE, S_DEFAULT_ATTENUATION_REFDISTANCE );

	S_LockBackgroundTrack( qfalse );

	if( !S_InitDecoders( verbose ) )
	{
		Com_Printf( "Failed to init decoders\n" );
		return qfalse;
	}
	if( !S_InitSources( maxEntities, verbose ) )
	{
		Com_Printf( "Failed to init sources\n" );
		return qfalse;
	}

	return qtrue;
}
Пример #16
0
/*
* S_Init
*/
qboolean S_Init( void *hwnd, int maxEntities, qboolean verbose )
{
	int numDevices;
	int userDeviceNum = -1;
	char *devices, *defaultDevice;

	soundpool = S_MemAllocPool( "OpenAL sound module" );

	alDevice = NULL;
	alContext = NULL;

#ifdef OPENAL_RUNTIME
	if( !QAL_Init( ALDRIVER, verbose ) )
	{
#ifdef ALDRIVER_ALT
		if( !QAL_Init( ALDRIVER_ALT, verbose ) )
#endif
		{
			Com_Printf( "Failed to load OpenAL library: %s\n", ALDRIVER );
			goto fail_no_device;
		}
	}
#endif

	// get system default device identifier
	defaultDevice = ( char * )qalcGetString( NULL, ALC_DEFAULT_DEVICE_SPECIFIER );
	if( !defaultDevice )
	{
		Com_Printf( "Failed to get openAL default device\n" );
		goto fail_no_device;
	}

	s_openAL_device = trap_Cvar_Get( "s_openAL_device", ALDEVICE_DEFAULT ? ALDEVICE_DEFAULT : defaultDevice, CVAR_ARCHIVE|CVAR_LATCH_SOUND );

	devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
	for( numDevices = 0; *devices; devices += strlen( devices ) + 1, numDevices++ )
	{
		if( !Q_stricmp( s_openAL_device->string, devices ) )
		{
			userDeviceNum = numDevices;

			// force case sensitive
			if( strcmp( s_openAL_device->string, devices ) )
				trap_Cvar_ForceSet( "s_openAL_device", devices );
		}
	}

	if( !numDevices )
	{
		Com_Printf( "Failed to get openAL devices\n" );
		goto fail_no_device;
	}

	// the device assigned by the user is not available
	if( userDeviceNum == -1 )
	{
		Com_Printf( "'s_openAL_device': incorrect device name, reseting to default\n" );

		trap_Cvar_ForceSet( "s_openAL_device", ALDEVICE_DEFAULT ? ALDEVICE_DEFAULT : defaultDevice );

		devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
		for( numDevices = 0; *devices; devices += strlen( devices ) + 1, numDevices++ )
		{
			if( !Q_stricmp( s_openAL_device->string, devices ) )
				userDeviceNum = numDevices;
		}

		if( userDeviceNum == -1 )
			trap_Cvar_ForceSet( "s_openAL_device", defaultDevice );
	}

	alDevice = qalcOpenDevice( (const ALchar *)s_openAL_device->string );
	if( !alDevice )
	{
		Com_Printf( "Failed to open device\n" );
		goto fail_no_device;
	}

	// Create context
	alContext = qalcCreateContext( alDevice, NULL );
	if( !alContext )
	{
		Com_Printf( "Failed to create context\n" );
		goto fail;
	}
	qalcMakeContextCurrent( alContext );

	if( verbose )
	{
		Com_Printf( "OpenAL initialized\n" );

		if( numDevices )
		{
			int i;

			Com_Printf( "  Devices:    " );

			devices = ( char * )qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
			for( i = 0; *devices; devices += strlen( devices ) + 1, i++ )
				Com_Printf( "%s%s", devices, ( i < numDevices - 1 ) ? ", " : "" );
			Com_Printf( "\n" );

			if( defaultDevice && *defaultDevice )
				Com_Printf( "  Default system device: %s\n", defaultDevice );

			Com_Printf( "\n" );
		}

		Com_Printf( "  Device:     %s\n", qalcGetString( alDevice, ALC_DEVICE_SPECIFIER ) );
		Com_Printf( "  Vendor:     %s\n", qalGetString( AL_VENDOR ) );
		Com_Printf( "  Version:    %s\n", qalGetString( AL_VERSION ) );
		Com_Printf( "  Renderer:   %s\n", qalGetString( AL_RENDERER ) );
		Com_Printf( "  Extensions: %s\n", qalGetString( AL_EXTENSIONS ) );
	}

	// Check for Linux shutdown race condition
	if( !Q_stricmp( qalGetString( AL_VENDOR ), "J. Valenzuela" ) )
		snd_shutdown_bug = qtrue;

	s_volume = trap_Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
	s_musicvolume = trap_Cvar_Get( "s_musicvolume", "0.5", CVAR_ARCHIVE );
	s_doppler = trap_Cvar_Get( "s_doppler", "1.0", CVAR_ARCHIVE );
	s_sound_velocity = trap_Cvar_Get( "s_sound_velocity", "10976", CVAR_DEVELOPER );
	s_stereo2mono = trap_Cvar_Get ( "s_stereo2mono", "0", CVAR_ARCHIVE );

	qalDopplerFactor( s_doppler->value );
	qalDopplerVelocity( s_sound_velocity->value > 0.0f ? s_sound_velocity->value : 0.0f );
	if( qalSpeedOfSound ) // opelAL 1.1 only. alDopplerVelocity being deprecated
		qalSpeedOfSound( s_sound_velocity->value > 0.0f ? s_sound_velocity->value : 0.0f );

	s_doppler->modified = qfalse;

	S_SetAttenuationModel( S_DEFAULT_ATTENUATION_MODEL, S_DEFAULT_ATTENUATION_MAXDISTANCE, S_DEFAULT_ATTENUATION_REFDISTANCE );

	S_LockBackgroundTrack( qfalse );

	if( !S_InitDecoders( verbose ) )
	{
		Com_Printf( "Failed to init decoders\n" );
		goto fail;
	}
	if( !S_InitBuffers() )
	{
		Com_Printf( "Failed to init buffers\n" );
		goto fail;
	}
	if( !S_InitSources( maxEntities, verbose ) )
	{
		Com_Printf( "Failed to init sources\n" );
		goto fail;
	}

#ifdef ENABLE_PLAY
	trap_Cmd_AddCommand( "play", S_Play );
#endif
	trap_Cmd_AddCommand( "music", S_Music );
	trap_Cmd_AddCommand( "stopmusic", S_StopMusic );
	trap_Cmd_AddCommand( "prevmusic", S_PrevMusic );
	trap_Cmd_AddCommand( "nextmusic", S_NextMusic );
	trap_Cmd_AddCommand( "pausemusic", S_PauseMusic );
	trap_Cmd_AddCommand( "soundlist", S_SoundList );
	trap_Cmd_AddCommand( "s_devices", S_ListDevices );

	return qtrue;

fail:
	if( alContext )
	{
		if( !snd_shutdown_bug )
			qalcMakeContextCurrent( NULL );

		qalcDestroyContext( alContext );
		alContext = NULL;
	}

	if( alDevice )
	{
		qalcCloseDevice( alDevice );
		alDevice = NULL;
	}

fail_no_device:
	S_MemFreePool( &soundpool );
	return qfalse;
}
Пример #17
0
/*
* CG_RegisterVariables
*/
static void CG_RegisterVariables( void )
{
	cg_predict =	    trap_Cvar_Get( "cg_predict", "1", 0 );
	cg_predict_optimize = trap_Cvar_Get( "cg_predict_optimize", "1", 0 );
	cg_showMiss =	    trap_Cvar_Get( "cg_showMiss", "0", 0 );

	cg_debugPlayerModels =	trap_Cvar_Get( "cg_debugPlayerModels", "0", CVAR_CHEAT|CVAR_ARCHIVE );
	cg_debugWeaponModels =	trap_Cvar_Get( "cg_debugWeaponModels", "0", CVAR_CHEAT|CVAR_ARCHIVE );

	model =		    trap_Cvar_Get( "model", DEFAULT_PLAYERMODEL, CVAR_USERINFO | CVAR_ARCHIVE );
	skin =		    trap_Cvar_Get( "skin", DEFAULT_PLAYERSKIN, CVAR_USERINFO | CVAR_ARCHIVE );
	hand =		    trap_Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
	handicap =		trap_Cvar_Get( "handicap", "0", CVAR_USERINFO | CVAR_ARCHIVE );
	clan =		    trap_Cvar_Get( "clan", "", CVAR_USERINFO | CVAR_ARCHIVE );
	cg_oldMovement =	trap_Cvar_Get( "cg_oldMovement", "0", CVAR_USERINFO | CVAR_ARCHIVE );
	cg_noAutohop =	trap_Cvar_Get( "cg_noAutohop", "0", CVAR_USERINFO | CVAR_ARCHIVE );
	cg_fov =	    trap_Cvar_Get( "fov", "100", CVAR_USERINFO | CVAR_ARCHIVE );
	cg_zoomSens =	    trap_Cvar_Get( "zoomsens", "0", CVAR_ARCHIVE );

	cg_addDecals =	    trap_Cvar_Get( "cg_decals", "1", CVAR_ARCHIVE );
	//cg_footSteps =	    trap_Cvar_Get( "cg_footSteps", "1", 0 );

	cg_thirdPerson =	trap_Cvar_Get( "cg_thirdPerson", "0", CVAR_CHEAT );
	cg_thirdPersonAngle =	trap_Cvar_Get( "cg_thirdPersonAngle", "0", 0 );
	cg_thirdPersonRange =	trap_Cvar_Get( "cg_thirdPersonRange", "90", 0 );

	//skelmod
	cg_gun =		trap_Cvar_Get( "cg_gun", "1", CVAR_ARCHIVE );
	cg_gunx =		trap_Cvar_Get( "cg_gunx", "0", CVAR_ARCHIVE );
	cg_guny =		trap_Cvar_Get( "cg_guny", "0", CVAR_ARCHIVE );
	cg_gunz =		trap_Cvar_Get( "cg_gunz", "0", CVAR_ARCHIVE );
	cg_gunbob =		trap_Cvar_Get( "cg_gunbob", "1", CVAR_ARCHIVE );

	cg_gun_fov =		trap_Cvar_Get( "cg_gun_fov", "90", CVAR_ARCHIVE );
	cg_gun_alpha =		trap_Cvar_Get( "cg_gun_alpha", "1", CVAR_ARCHIVE );
	cg_weaponFlashes =	trap_Cvar_Get( "cg_weaponFlashes", "2", CVAR_ARCHIVE );

	// wsw
	cg_volume_players =	trap_Cvar_Get( "cg_volume_players", "1.0", CVAR_ARCHIVE );
	cg_volume_effects =	trap_Cvar_Get( "cg_volume_effects", "1.0", CVAR_ARCHIVE );
	cg_volume_announcer =	trap_Cvar_Get( "cg_volume_announcer", "1.0", CVAR_ARCHIVE );
	cg_volume_hitsound =	trap_Cvar_Get( "cg_volume_hitsound", "1.0", CVAR_ARCHIVE );
	cg_volume_voicechats =	trap_Cvar_Get( "cg_volume_voicechats", "1.0", CVAR_ARCHIVE );
	cg_handOffset =		trap_Cvar_Get( "cg_handOffset", "5", CVAR_ARCHIVE );
	cg_rocketTrail =	trap_Cvar_Get( "cg_rocketTrail", "40", CVAR_ARCHIVE );
	cg_rocketFireTrail =	trap_Cvar_Get( "cg_rocketFireTrail", "90", CVAR_ARCHIVE );
	cg_grenadeTrail =	trap_Cvar_Get( "cg_grenadeTrail", "20", CVAR_ARCHIVE );
	cg_bloodTrail =		trap_Cvar_Get( "cg_bloodTrail", "10", CVAR_ARCHIVE );
	cg_showBloodTrail =	trap_Cvar_Get( "cg_showBloodTrail", "1", CVAR_ARCHIVE );
	cg_rocketTrailAlpha =	trap_Cvar_Get( "cg_rocketTrailAlpha", "0.35", CVAR_ARCHIVE );
	cg_rocketFireTrailAlpha =	trap_Cvar_Get( "cg_rocketFireTrailAlpha", "0.45", CVAR_ARCHIVE );
	cg_grenadeTrailAlpha =	trap_Cvar_Get( "cg_grenadeTrailAlpha", "0.5", CVAR_ARCHIVE );
	cg_bloodTrailAlpha =	trap_Cvar_Get( "cg_bloodTrailAlpha", "1.0", CVAR_ARCHIVE );
	cg_explosionsRing =	trap_Cvar_Get( "cg_explosionsRing", "0", CVAR_ARCHIVE );
	cg_explosionsDust =    trap_Cvar_Get( "cg_explosionsDust", "0", CVAR_ARCHIVE );
	cg_gibs =		trap_Cvar_Get( "cg_gibs", "1", CVAR_ARCHIVE );
	cg_outlineModels =	trap_Cvar_Get( "cg_outlineModels", "1", CVAR_ARCHIVE );
	cg_outlineWorld =	trap_Cvar_Get( "cg_outlineWorld", "0", CVAR_ARCHIVE );
	cg_outlinePlayers =	trap_Cvar_Get( "cg_outlinePlayers", "1", CVAR_ARCHIVE );
	cg_drawEntityBoxes =	trap_Cvar_Get( "cg_drawEntityBoxes", "0", CVAR_DEVELOPER );
	cg_showObituaries =	trap_Cvar_Get( "cg_showObituaries", va( "%i", CG_OBITUARY_HUD|CG_OBITUARY_CENTER ), CVAR_ARCHIVE );
	cg_autoaction_demo =	trap_Cvar_Get( "cg_autoaction_demo", "0", CVAR_ARCHIVE );
	cg_autoaction_screenshot =  trap_Cvar_Get( "cg_autoaction_screenshot", "0", CVAR_ARCHIVE );
	cg_autoaction_stats =	trap_Cvar_Get( "cg_autoaction_stats", "0", CVAR_ARCHIVE );
	cg_autoaction_spectator = trap_Cvar_Get( "cg_autoaction_spectator", "0", CVAR_ARCHIVE );
	cg_simpleItems =	trap_Cvar_Get( "cg_simpleItems", "0", CVAR_ARCHIVE );
	cg_simpleItemsSize =	trap_Cvar_Get( "cg_simpleItemsSize", "12", CVAR_ARCHIVE );
	cg_particles =		trap_Cvar_Get( "cg_particles", "1", CVAR_ARCHIVE );
	cg_showhelp =		trap_Cvar_Get( "cg_showhelp", "1", CVAR_ARCHIVE );
	cg_predictLaserBeam =	trap_Cvar_Get( "cg_predictLaserBeam", "1", CVAR_ARCHIVE );
	cg_showSelfShadow =	trap_Cvar_Get( "cg_showSelfShadow", "0", CVAR_ARCHIVE );

	cg_cartoonEffects =		trap_Cvar_Get( "cg_cartoonEffects", "7", CVAR_ARCHIVE );
	cg_cartoonHitEffect =	trap_Cvar_Get( "cg_cartoonHitEffect", "0", CVAR_ARCHIVE );

	cg_damage_kick =	trap_Cvar_Get( "cg_damage_kick", "0", CVAR_ARCHIVE );
	cg_damage_indicator =	trap_Cvar_Get( "cg_damage_indicator", "1", CVAR_ARCHIVE );
	cg_damage_indicator_time =	trap_Cvar_Get( "cg_damage_indicator_time", "50", CVAR_ARCHIVE );
	cg_pickup_flash =	trap_Cvar_Get( "cg_pickup_flash", "0", CVAR_ARCHIVE );

	cg_weaponAutoSwitch =	trap_Cvar_Get( "cg_weaponAutoSwitch", "2", CVAR_ARCHIVE );

	cg_voiceChats =		trap_Cvar_Get( "cg_voiceChats", "1", CVAR_ARCHIVE );
	cg_shadows =		trap_Cvar_Get( "cg_shadows", "1", CVAR_ARCHIVE );

	cg_laserBeamSubdivisions = trap_Cvar_Get( "cg_laserBeamSubdivisions", "10", CVAR_ARCHIVE );
	cg_projectileAntilagOffset = trap_Cvar_Get( "cg_projectileAntilagOffset", "1.0", CVAR_ARCHIVE );

	cg_raceGhosts =		trap_Cvar_Get( "cg_raceGhosts", "0", CVAR_ARCHIVE );
	cg_raceGhostsAlpha =	trap_Cvar_Get( "cg_raceGhostsAlpha", "0.25", CVAR_ARCHIVE );

	cg_chatBeep =		trap_Cvar_Get( "cg_chatBeep", "1", CVAR_ARCHIVE );
	cg_chatFilter =		trap_Cvar_Get( "cg_chatFilter", "0", CVAR_ARCHIVE );
	cg_chatFilterTV =	trap_Cvar_Get( "cg_chatFilterTV", "2", CVAR_ARCHIVE );

	cg_scoreboardStats =	trap_Cvar_Get( "cg_scoreboardStats", "1", CVAR_ARCHIVE );

	// developer cvars
	developer =		trap_Cvar_Get( "developer", "0", CVAR_CHEAT );
	cg_showClamp =		trap_Cvar_Get( "cg_showClamp", "0", CVAR_DEVELOPER );

	//team models
	cg_teamPLAYERSmodel =	trap_Cvar_Get( "cg_teamPLAYERSmodel", "", CVAR_ARCHIVE );
	cg_teamPLAYERSskin =	trap_Cvar_Get( "cg_teamPLAYERSskin", "default", CVAR_ARCHIVE );
	cg_teamPLAYERScolor =	trap_Cvar_Get( "cg_teamPLAYERScolor", "", CVAR_ARCHIVE );
	cg_teamPLAYERSmodel->modified = qtrue;
	cg_teamPLAYERSskin->modified = qtrue;
	cg_teamPLAYERScolor->modified = qtrue;

	cg_teamALPHAmodel =	trap_Cvar_Get( "cg_teamALPHAmodel", "", CVAR_ARCHIVE );
	cg_teamALPHAskin =	trap_Cvar_Get( "cg_teamALPHAskin", "default", CVAR_ARCHIVE );
	cg_teamALPHAcolor =	trap_Cvar_Get( "cg_teamALPHAcolor", DEFAULT_TEAMALPHA_COLOR, CVAR_ARCHIVE );
	cg_teamALPHAmodel->modified = qtrue;
	cg_teamALPHAskin->modified = qtrue;
	cg_teamALPHAcolor->modified = qtrue;

	cg_teamBETAmodel =	trap_Cvar_Get( "cg_teamBETAmodel", "", CVAR_ARCHIVE );
	cg_teamBETAskin =	trap_Cvar_Get( "cg_teamBETAskin", "default", CVAR_ARCHIVE );
	cg_teamBETAcolor =	trap_Cvar_Get( "cg_teamBETAcolor", DEFAULT_TEAMBETA_COLOR, CVAR_ARCHIVE );
	cg_teamBETAmodel->modified = qtrue;
	cg_teamBETAskin->modified = qtrue;
	cg_teamBETAcolor->modified = qtrue;

	cg_forceMyTeamAlpha =		trap_Cvar_Get( "cg_forceMyTeamAlpha", "0", CVAR_ARCHIVE );
	cg_forceTeamPlayersTeamBeta =	trap_Cvar_Get( "cg_forceTeamPlayersTeamBeta", "0", CVAR_ARCHIVE );

	// dmh - learn0more's team colored beams
	cg_teamColoredBeams = trap_Cvar_Get( "cg_teamColoredBeams", "1", CVAR_ARCHIVE );

	cg_ebbeam_old = trap_Cvar_Get( "cg_ebbeam_old", "0", CVAR_ARCHIVE );
	cg_ebbeam_width = trap_Cvar_Get( "cg_ebbeam_width", "64", CVAR_ARCHIVE );
	cg_ebbeam_alpha = trap_Cvar_Get( "cg_ebbeam_alpha", "0.4", CVAR_ARCHIVE );
	cg_ebbeam_time = trap_Cvar_Get( "cg_ebbeam_time", "0.6", CVAR_ARCHIVE );
	cg_lgbeam_old = trap_Cvar_Get( "cg_lgbeam_old", "0", CVAR_ARCHIVE );

	cg_instabeam_width = trap_Cvar_Get( "cg_instabeam_width", "7", CVAR_ARCHIVE );
	cg_instabeam_alpha = trap_Cvar_Get( "cg_instabeam_alpha", "0.4", CVAR_ARCHIVE );
	cg_instabeam_time = trap_Cvar_Get( "cg_instabeam_time", "0.4", CVAR_ARCHIVE );

	cg_showminimap = trap_Cvar_Get( "cg_showMiniMap", "0", CVAR_ARCHIVE );
	cg_showitemtimers = trap_Cvar_Get( "cg_showItemTimers", "3", CVAR_ARCHIVE );
	cg_placebo =  trap_Cvar_Get( "cg_placebo", "0", CVAR_ARCHIVE );
	cg_strafeHUD = trap_Cvar_Get( "cg_strafeHUD", "0", CVAR_ARCHIVE );

	cg_playList = trap_Cvar_Get( "cg_playList", S_PLAYLIST_MATCH, CVAR_ARCHIVE );
	cg_playListShuffle = trap_Cvar_Get( "cg_playListShuffle", "1", CVAR_ARCHIVE );

	cg_flashWindowCount = trap_Cvar_Get( "cg_flashWindowCount", "4", CVAR_ARCHIVE );
}
Пример #18
0
/*
* G_Init
* 
* This will be called when the dll is first loaded, which
* only happens when a new game is started or a save game is loaded.
*/
void G_Init( unsigned int seed, unsigned int framemsec, int protocol, const char *demoExtension )
{
	cvar_t *g_maxentities;

	G_Printf( "==== G_Init ====\n" );

	srand( seed );

	G_InitGameShared();

	SV_ReadIPList ();

	game.snapFrameTime = framemsec;
	game.frametime = game.snapFrameTime;
	game.protocol = protocol;
	Q_strncpyz( game.demoExtension, demoExtension, sizeof( game.demoExtension ) );
	game.levelSpawnCount = 0;

	g_maxvelocity = trap_Cvar_Get( "g_maxvelocity", "16000", 0 );
	if( g_maxvelocity->value < 20 )
	{
		trap_Cvar_SetValue( "g_maxvelocity", 20 );
	}

	g_gravity = trap_Cvar_Get( "g_gravity", va( "%i", GRAVITY ), 0 );
	developer = trap_Cvar_Get( "developer", "0", 0 );

	// noset vars
	dedicated = trap_Cvar_Get( "dedicated", "0", CVAR_NOSET );

	// latched vars
	sv_cheats = trap_Cvar_Get( "sv_cheats", "0", CVAR_SERVERINFO | CVAR_LATCH );
	sv_mm_enable = trap_Cvar_Get( "sv_mm_enable", "0", CVAR_ARCHIVE | CVAR_NOSET | CVAR_SERVERINFO );

	// hack in CVAR_SERVERINFO flag
	trap_Cvar_Get( "gamename", trap_Cvar_String( "gamename" ), CVAR_SERVERINFO );
	trap_Cvar_Get( "gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH );

	password = trap_Cvar_Get( "password", "", CVAR_USERINFO );
	password->modified = true; // force an update of g_needpass in G_UpdateServerInfo
	g_operator_password = trap_Cvar_Get( "g_operator_password", "", CVAR_ARCHIVE );
	filterban = trap_Cvar_Get( "filterban", "1", 0 );

	cm_mapHeader = trap_Cvar_Get( "cm_mapHeader", "", 0 );
	cm_mapVersion = trap_Cvar_Get( "cm_mapVersion", "", 0 );

	g_ammo_respawn = trap_Cvar_Get( "g_ammo_respawn", "0", CVAR_ARCHIVE );
	g_weapon_respawn = trap_Cvar_Get( "g_weapon_respawn", "0", CVAR_ARCHIVE );
	g_health_respawn = trap_Cvar_Get( "g_health_respawn", "0", CVAR_ARCHIVE );
	g_armor_respawn = trap_Cvar_Get( "g_armor_respawn", "0", CVAR_ARCHIVE );
	g_select_empty = trap_Cvar_Get( "g_select_empty", "0", CVAR_DEVELOPER );
	g_projectile_touch_owner = trap_Cvar_Get( "g_projectile_touch_owner", "0", CVAR_DEVELOPER );
	g_projectile_prestep = trap_Cvar_Get( "g_projectile_prestep", va( "%i", PROJECTILE_PRESTEP ), CVAR_DEVELOPER );
	g_self_knockback = trap_Cvar_Get( "g_self_knockback", "1.18", CVAR_DEVELOPER );
	g_knockback_scale = trap_Cvar_Get( "g_knockback_scale", "1.0", CVAR_ARCHIVE );
	g_allow_stun = trap_Cvar_Get( "g_allow_stun", "1", CVAR_ARCHIVE );
	g_armor_degradation = trap_Cvar_Get( "g_armor_degradation", va( "%.2f", ARMOR_DEGRADATION ), CVAR_DEVELOPER );
	g_armor_protection = trap_Cvar_Get( "g_armor_protection", va( "%.2f", ARMOR_PROTECTION ), CVAR_DEVELOPER );
	g_respawn_delay_min = trap_Cvar_Get( "g_respawn_delay_min", "600", CVAR_DEVELOPER );
	g_respawn_delay_max = trap_Cvar_Get( "g_respawn_delay_max", "6000", CVAR_DEVELOPER );
	g_numbots = trap_Cvar_Get( "g_numbots", "0", CVAR_ARCHIVE );
	g_deadbody_followkiller = trap_Cvar_Get( "g_deadbody_followkiller", "1", CVAR_DEVELOPER );
	g_deadbody_autogib_delay = trap_Cvar_Get( "g_deadbody_autogib_delay", "2000", CVAR_DEVELOPER );
	g_maxtimeouts = trap_Cvar_Get( "g_maxtimeouts", "2", CVAR_ARCHIVE );
	g_antilag = trap_Cvar_Get( "g_antilag", "1", CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH );
	g_antilag_maxtimedelta = trap_Cvar_Get( "g_antilag_maxtimedelta", "200", CVAR_ARCHIVE );
	g_antilag_maxtimedelta->modified = true;
	g_antilag_timenudge = trap_Cvar_Get( "g_antilag_timenudge", "0", CVAR_ARCHIVE );
	g_antilag_timenudge->modified = true;

	g_allow_spectator_voting = trap_Cvar_Get( "g_allow_spectator_voting", "1", CVAR_ARCHIVE );

	if( dedicated->integer )
	{
		g_autorecord = trap_Cvar_Get( "g_autorecord", "1", CVAR_ARCHIVE );
		g_autorecord_maxdemos = trap_Cvar_Get( "g_autorecord_maxdemos", "200", CVAR_ARCHIVE );
	}
	else
	{
		g_autorecord = trap_Cvar_Get( "g_autorecord", "0", CVAR_ARCHIVE );
		g_autorecord_maxdemos = trap_Cvar_Get( "g_autorecord_maxdemos", "0", CVAR_ARCHIVE );
	}

	// flood control
	g_floodprotection_messages = trap_Cvar_Get( "g_floodprotection_messages", "4", 0 );
	g_floodprotection_messages->modified = true;
	g_floodprotection_team = trap_Cvar_Get( "g_floodprotection_team", "0", 0 );
	g_floodprotection_team->modified = true;
	g_floodprotection_seconds = trap_Cvar_Get( "g_floodprotection_seconds", "4", 0 );
	g_floodprotection_seconds->modified = true;
	g_floodprotection_penalty = trap_Cvar_Get( "g_floodprotection_delay", "10", 0 );
	g_floodprotection_penalty->modified = true;

	g_inactivity_maxtime = trap_Cvar_Get( "g_inactivity_maxtime", "90.0", 0 );
	g_inactivity_maxtime->modified = true;

	// map list
	g_maplist = trap_Cvar_Get( "g_maplist", "", CVAR_ARCHIVE );
	g_maprotation = trap_Cvar_Get( "g_maprotation", "1", CVAR_ARCHIVE );

	// map pool
	g_enforce_map_pool = trap_Cvar_Get( "g_enforce_map_pool", "0", CVAR_ARCHIVE );
	g_map_pool = trap_Cvar_Get( "g_map_pool", "", CVAR_ARCHIVE );

	//game switches
	g_instagib = trap_Cvar_Get( "g_instagib", "0", CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH );
	g_instajump = trap_Cvar_Get( "g_instajump", "1", CVAR_ARCHIVE );
	g_instashield = trap_Cvar_Get( "g_instashield", "1", CVAR_ARCHIVE );

	// helper cvars to show current status in serverinfo reply
	trap_Cvar_Get( "g_match_time", "", CVAR_SERVERINFO|CVAR_READONLY );
	trap_Cvar_Get( "g_match_score", "", CVAR_SERVERINFO|CVAR_READONLY );
	trap_Cvar_Get( "g_needpass", "", CVAR_SERVERINFO|CVAR_READONLY );
	trap_Cvar_Get( "g_gametypes_available", "", CVAR_SERVERINFO|CVAR_READONLY );
	trap_Cvar_Get( "g_race_gametype", "0", CVAR_SERVERINFO|CVAR_READONLY );

	// define this one here so we can see when it's modified
	g_disable_vote_gametype = trap_Cvar_Get( "g_disable_vote_gametype", "0", CVAR_ARCHIVE );

	g_asGC_stats = trap_Cvar_Get( "g_asGC_stats", "0", CVAR_ARCHIVE );
	g_asGC_interval = trap_Cvar_Get( "g_asGC_interval", "10", CVAR_ARCHIVE );

	g_skillRating = trap_Cvar_Get( "sv_skillRating", va("%.0f", MM_RATING_DEFAULT), CVAR_SERVERINFO|CVAR_READONLY );
	// trap_Cvar_ForceSet( "sv_skillRating", va("%d", MM_RATING_DEFAULT) );

	// nextmap
	trap_Cvar_ForceSet( "nextmap", "match \"advance\"" );

	// initialize all entities for this game
	g_maxentities = trap_Cvar_Get( "sv_maxentities", "1024", CVAR_LATCH );
	game.maxentities = g_maxentities->integer;
	game.edicts = ( edict_t * )G_Malloc( game.maxentities * sizeof( game.edicts[0] ) );

	// initialize all clients for this game
	game.clients = ( gclient_t * )G_Malloc( gs.maxclients * sizeof( game.clients[0] ) );

	game.quits = NULL;

	game.numentities = gs.maxclients + 1;

	trap_LocateEntities( game.edicts, sizeof( game.edicts[0] ), game.numentities, game.maxentities );

	// server console commands
	G_AddServerCommands();

	G_LoadFiredefsFromDisk();

	// weapon items
	GS_InitWeapons();

	// init AS engine
	G_asInitGameModuleEngine();
}
Пример #19
0
/*
* G_FireWeapon
*/
void G_FireWeapon( edict_t *ent, int parm )
{
	gs_weapon_definition_t *weapondef;
	firedef_t *firedef;
	edict_t *projectile;
	vec3_t origin, angles;
	vec3_t viewoffset = { 0, 0, 0 };
	int ucmdSeed;
	// racesow
	float prestep;
	// !racesow

	weapondef = GS_GetWeaponDef( ( parm & ~EV_INVERSE ) );
	firedef = ( parm & EV_INVERSE ) ? &weapondef->firedef : &weapondef->firedef_weak;

	// find this shot projection source
	if( ent->r.client )
	{
		viewoffset[2] += ent->r.client->ps.viewheight;
		VectorCopy( ent->r.client->ps.viewangles, angles );
		is_quad = ( ent->r.client->ps.inventory[POWERUP_QUAD] > 0 );
		ucmdSeed = ent->r.client->ucmd.serverTimeStamp & 255;
	}
	else
	{
		VectorCopy( ent->s.angles, angles );
		is_quad = qfalse;
		ucmdSeed = rand() & 255;
	}

	VectorAdd( ent->s.origin, viewoffset, origin );

	// racesow
	prestep=g_projectile_prestep->value;
	// !racesow

	// shoot 

	projectile = NULL;

	switch( weapondef->weapon_id )
	{
	default:
	case WEAP_NONE:
		break;

	case WEAP_GUNBLADE:
		if( firedef->fire_mode == FIRE_MODE_STRONG )
			projectile = G_Fire_Gunblade_Blast( origin, angles, firedef, ent, ucmdSeed );
		else
			projectile = G_Fire_Gunblade_Knife( origin, angles, firedef, ent );
		break;

	case WEAP_MACHINEGUN:
		projectile = G_Fire_Machinegun( origin, angles, firedef, ent, ucmdSeed );
		break;

	case WEAP_RIOTGUN:
		projectile = G_Fire_Riotgun( origin, angles, firedef, ent, ucmdSeed );
		break;

	case WEAP_GRENADELAUNCHER:
		projectile = G_Fire_Grenade( origin, angles, firedef, ent, ucmdSeed );
		// racesow
		if( GS_RaceGametype() )
			//prestep/=2; // racesow 0.42 had default prestep=48 and genade prestep=24
			prestep=trap_Cvar_Get( "rs_grenade_prestep", "90", CVAR_ARCHIVE )->integer;
		// !racesow
		break;

	case WEAP_ROCKETLAUNCHER:
		projectile = G_Fire_Rocket( origin, angles, firedef, ent, ucmdSeed );
		// racesow
		if( GS_RaceGametype() )
			//prestep=0; // racesow 0.42 had rocket prestep=0
			prestep=trap_Cvar_Get( "rs_rocket_prestep", "90", CVAR_ARCHIVE )->integer;
		// !racesow
		break;
	case WEAP_PLASMAGUN:
		projectile = G_Fire_Plasma( origin, angles, firedef, ent, ucmdSeed );
		// racesow
		if( GS_RaceGametype() )
			//prestep*=2/3; // racesow 0.42 had plasma prestep=32
			prestep=trap_Cvar_Get( "rs_plasma_prestep", "90", CVAR_ARCHIVE )->integer;
		// !racesow
		break;

	case WEAP_LASERGUN:
		projectile = G_Fire_Lasergun( origin, angles, firedef, ent, ucmdSeed );
		break;

	case WEAP_ELECTROBOLT:
		projectile = G_Fire_StrongBolt( origin, angles, firedef, ent, ucmdSeed );
		break;

	case WEAP_INSTAGUN:
		projectile = G_Fire_Instagun( origin, angles, firedef, ent, ucmdSeed );
		break;
	}

	// add stats
	if( ent->r.client && weapondef->weapon_id != WEAP_NONE ) 
		ent->r.client->level.stats.accuracy_shots[firedef->ammo_id - AMMO_GUNBLADE] += firedef->projectile_count;

	if( projectile )
	{
		//if( projectile->s.linearProjectile ) // convert distance to time for linear projectiles
		//	G_ProjectileTimePrestep( projectile, 1000.0f * ( g_projectile_prestep->value / VectorLengthFast( projectile->velocity ) ) );
		//else
			//G_ProjectileDistancePrestep( projectile, g_projectile_prestep->value ); //racesow Seems like this was added in warsow 0.7 -K1ll
		// racesow: modified prestep
		G_ProjectileDistancePrestep( projectile, prestep );
		// !racesow
	}

	// racesow: enable skipping no_antilag if rs_rocket_antilag is 1
	if ( GS_RaceGametype() && ((trap_Cvar_Get( "rs_rocket_antilag", "0", CVAR_ARCHIVE )->integer==1 && projectile->s.type == ET_ROCKET)))
		return;
	// !racesow

#ifdef NO_ROCKET_ANTILAG
	// hack for disabling antilag on rockets
	if( projectile && (projectile->s.type == ET_ROCKET || projectile->s.type == ET_PLASMA) )//racesow
	{
		int timeOffset;

		timeOffset = -projectile->timeDelta;
		projectile->timeDelta = 0;
		if( projectile->s.linearProjectile )
			projectile->s.modelindex2 = 0;

		// racesow: testing .42 time prestep function, because im really not sure it is equivalent to the .5 one; the difference is not that major anyway..
		//  G_ProjectileTimePrestep( projectile, timeOffset );
		rs_TimeDeltaPrestepProjectile(projectile,-timeOffset);
		// !racesow
	}
#endif
}
Пример #20
0
/*
* UI_Init
*/
void UI_Init( int vidWidth, int vidHeight, int protocol, int sharedSeed )
{
	m_active = NULL;
	m_cursoritem = NULL;
	m_drawfunc = NULL;
	m_keyfunc = NULL;
	m_entersound = qfalse;
	m_keypressed = 0;

	memset( &uis, 0, sizeof( uis ) );

	uis.vidWidth = vidWidth;
	uis.vidHeight = vidHeight;
	uis.gameProtocol = protocol;

#if 0
	uis.scaleX = UI_WIDTHSCALE;
	uis.scaleY = UI_HEIGHTSCALE;
#else
	uis.scaleX = 1;
	uis.scaleY = 1;
#endif

	uis.cursorX = uis.vidWidth / 2;
	uis.cursorY = uis.vidHeight / 2;

	uis.initialSharedSeed = sharedSeed;
	uis.sharedSeed = uis.initialSharedSeed;

	uis.backgroundNum = Q_rand( &uis.sharedSeed ) % UI_SHADER_MAX_BACKGROUNDS;

	developer =	trap_Cvar_Get( "developer", "0", CVAR_CHEAT );

	// wsw/Mokshu : test svn addin for VS 2005 and what about a "help/news" menu (latest news from website for example)
	trap_Cmd_AddCommand( "menu_main", M_Menu_Main_f );
	trap_Cmd_AddCommand( "menu_main_sbar", M_Menu_Main_Statusbar_f );
	trap_Cmd_AddCommand( "menu_setup", M_Menu_Setup_f );
	trap_Cmd_AddCommand( "menu_joinserver", M_Menu_JoinServer_f );
	trap_Cmd_AddCommand( "menu_matchmaker", M_Menu_MatchMaker_f );
#ifdef AUTH_CODE
	trap_Cmd_AddCommand( "menu_login", M_Menu_Login_f );
	trap_Cmd_AddCommand( "menu_register", M_Menu_Register_f );
#endif
	trap_Cmd_AddCommand( "menu_playerconfig", M_Menu_PlayerConfig_f );
	trap_Cmd_AddCommand( "menu_startserver", M_Menu_StartServer_f );
	trap_Cmd_AddCommand( "menu_sound", M_Menu_Sound_f );
	trap_Cmd_AddCommand( "menu_options", M_Menu_Options_f );
	trap_Cmd_AddCommand( "menu_performance", M_Menu_Performance_f );
	trap_Cmd_AddCommand( "menu_performanceadv", M_Menu_PerformanceAdv_f );
	trap_Cmd_AddCommand( "menu_keys", M_Menu_Keys_f );
	trap_Cmd_AddCommand( "menu_vsays", M_Menu_Vsays_f );
	trap_Cmd_AddCommand( "menu_quit", M_Menu_Quit_f );
	trap_Cmd_AddCommand( "menu_reset", M_Menu_Reset_f );
	trap_Cmd_AddCommand( "menu_demos", M_Menu_Demos_f );
	trap_Cmd_AddCommand( "menu_mods", M_Menu_Mods_f );
	trap_Cmd_AddCommand( "menu_game", M_Menu_Game_f );
	trap_Cmd_AddCommand( "menu_tv", M_Menu_TV_f );
	trap_Cmd_AddCommand( "menu_tv_channel_add", M_Menu_TV_ChannelAdd_f );
	trap_Cmd_AddCommand( "menu_tv_channel_remove", M_Menu_TV_ChannelRemove_f );
	trap_Cmd_AddCommand( "menu_failed", M_Menu_Failed_f );
	trap_Cmd_AddCommand( "menu_msgbox", M_Menu_MsgBox_f );
	trap_Cmd_AddCommand( "menu_custom", M_Menu_Custom_f );
	trap_Cmd_AddCommand( "menu_chasecam", M_Menu_Chasecam_f );
	trap_Cmd_AddCommand( "menu_teamconfig", M_Menu_TeamConfig_f );
	trap_Cmd_AddCommand( "menu_force", UI_Force_f );
	trap_Cmd_AddCommand( "menu_tutorials", M_Menu_Tutorials_f );
	trap_Cmd_AddCommand( "menu_demoplay", M_Menu_Demoplay_f );
	trap_Cmd_AddCommand( "menu_pop", Cmd_PopMenu_f );

	M_Cache();
	UI_Playermodel_Init(); // create a list with the available player models
	UI_InitTemporaryBoneposesCache();

	uis.backGroundTrackStarted = qfalse;

	// jal: this is a small trick to assign userinfo flag to cg_oldMovement before cgame is loaded
	trap_Cvar_Get( "cg_oldMovement", "0", CVAR_USERINFO | CVAR_ARCHIVE );
	trap_Cvar_Get( "cg_noAutohop", "0", CVAR_USERINFO | CVAR_ARCHIVE );
}
Пример #21
0
// CLASS: Cvar
void objectCVar_Constructor( asstring_t *name, asstring_t *value, unsigned int flags, ascvar_t *self )
{
	self->cvar = trap_Cvar_Get( name->buffer, value->buffer, flags );
}
Пример #22
0
bool SNDDMA_Init( void *hwnd, bool verbose )
{
	char drivername[128];
	SDL_AudioSpec desired;
	SDL_AudioSpec obtained;
	int tmp;

	if( snd_inited )
		return 1;

	if( verbose )
		Com_Printf( "SDL Audio driver initializing...\n" );

	if( !s_bits ) {
		s_bits = trap_Cvar_Get( "s_bits", "16", CVAR_ARCHIVE | CVAR_LATCH_SOUND );
		s_channels = trap_Cvar_Get( "s_channels", "2", CVAR_ARCHIVE | CVAR_LATCH_SOUND );
	}

	if( !SDL_WasInit( SDL_INIT_AUDIO ) ) {
		if( verbose )
			Com_Printf( "Calling SDL_Init(SDL_INIT_AUDIO)...\n" );
		if( SDL_Init( SDL_INIT_AUDIO ) == -1 ) {
			Com_Printf( "SDL_Init(SDL_INIT_AUDIO) failed: %s\n", SDL_GetError() );
			return false;
		}
		if( verbose )
			Com_Printf( "SDL_Init(SDL_INIT_AUDIO) passed.\n" );
	}

#if SDL_VERSION_ATLEAST( 2, 0, 0 )
	if( SDL_GetCurrentAudioDriver() ) {
		Q_strncpyz( drivername, SDL_GetCurrentAudioDriver(), sizeof( drivername ) );
	} else {
		Q_strncpyz( drivername, "(UNKNOWN)", sizeof( drivername ) );
	}
#else
	if( SDL_AudioDriverName( drivername, sizeof( drivername ) ) == NULL )
		Q_strncpyz( drivername, "(UNKNOWN)", sizeof( drivername ) );
#endif

	if( verbose )
		Com_Printf( "SDL audio driver is \"%s\"\n", drivername );

	memset( &desired, '\0', sizeof( desired ) );
	memset( &obtained, '\0', sizeof( obtained ) );

	if( s_khz->integer == 44 )
		desired.freq = 44100;
	else if( s_khz->integer == 22 )
		desired.freq = 22050;
	else
		desired.freq = 11025;

	desired.format = ( ( s_bits->integer != 16 ) ? AUDIO_U8 : AUDIO_S16SYS );

	// I dunno if this is the best idea, but I'll give it a try...
	//  should probably check a cvar for this...
	// just pick a sane default.
	if( desired.freq <= 11025 )
		desired.samples = 256;
	else if( desired.freq <= 22050 )
		desired.samples = 512;
	else if( desired.freq <= 44100 )
		desired.samples = 1024;
	else
		desired.samples = 2048; // (*shrug*)

	desired.channels = s_channels->integer;
	desired.callback = sdl_audio_callback;

	if( SDL_OpenAudio( &desired, &obtained ) == -1 ) {
		Com_Printf( "SDL_OpenAudio() failed: %s\n", SDL_GetError() );
		SDL_QuitSubSystem( SDL_INIT_AUDIO );
		return false;
	}

	if( verbose ) {
		print_audiospec( "Format we requested from SDL audio device", &desired );
		print_audiospec( "Format we actually got", &obtained );
	}

	// dma.samples needs to be big, or id's mixer will just refuse to
	//  work at all; we need to keep it significantly bigger than the
	//  amount of SDL callback samples, and just copy a little each time
	//  the callback runs.
	// 32768 is what the OSS driver filled in here on my system. I don't
	//  know if it's a good value overall, but at least we know it's
	//  reasonable...this is why I let the user override.
	tmp = ( obtained.samples * obtained.channels ) * 4;

	if( tmp & ( tmp - 1 ) ) // not a power of two? Seems to confuse something.
	{
		int val = 1;
		while( val < tmp )
			val <<= 1;

		val >>= 1;
		if( verbose )
			Com_Printf( "WARNING: sdlmixsamps wasn't a power of two (%d), so we made it one (%d).\n", tmp, val );
		tmp = val;
	}
Пример #23
0
static qboolean StartServer_MenuInit( void )
{
    menucommon_t *menuitem_settings_background;
    menucommon_t *menuitem, *col_title;
    static char *skill_names[] = { "easy", "normal", "hard", 0 };
    static char *sortmethod_names[] = { "file name", "title", 0 };
    cvar_t *cvar_lastmap;
    int maxclients;
    int scrollwindow_width, xoffset, yoffset = 0; //leave some room for preview pic

    trap_Cvar_Get( "ui_maplist_sortmethod", "1", CVAR_ARCHIVE );

    // create a list with the installed gametype names
    ui_gametype_names = trap_Cvar_Get( "ui_gametype_names", ";", CVAR_NOSET );
    if( !UI_CreateFileNamesListCvar( ui_gametype_names, "progs/gametypes", ".gt", ';' ) )
        trap_Cvar_ForceSet( "ui_gametype_names", "dm;" );

    if( uis.vidWidth < 800 )
        scrollwindow_width = uis.vidWidth * 0.85;
    else if( uis.vidWidth < 1024 )
        scrollwindow_width = uis.vidWidth * 0.75;
    else
        scrollwindow_width = uis.vidWidth * 0.45;
    xoffset = scrollwindow_width / 2;

    // convert to item names format
    M_StartServer_MakeGametypesNames( ui_gametype_names->string );

    s_startserver_menu.nitems = 0;

    menuitem = UI_InitMenuItem( "m_startserver_title1", "SERVER SETUP", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // separator
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_startserver_map", "initial map", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemMedium, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    // order type
    menuitem = col_title = UI_InitMenuItem( "m_startserver_order_title", "order by: ", -xoffset - LCOLUMN_OFFSET / 2, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );

    menuitem = UI_InitMenuItem( "m_startserver_order", NULL, col_title->x + trap_SCR_strWidth( col_title->title, uis.fontSystemSmall, 0 ),
                                yoffset, MTYPE_SPINCONTROL, ALIGN_LEFT_TOP, uis.fontSystemSmall, StartServer_UpdateOrderMethod );
    UI_SetupSpinControl( menuitem, sortmethod_names, trap_Cvar_Value( "ui_maplist_sortmethod" ) );
    Menu_AddItem( &s_startserver_menu, menuitem );

    menuitem = UI_InitMenuItem( "m_startserver_mappic", NULL, xoffset - MAPPIC_WIDTH - 8, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );

    cvar_lastmap = trap_Cvar_Get( "ui_startserver_lastselectedmap", "", CVAR_NOSET );
    MapsList_CreateItems( cvar_lastmap->string );
    MapsList_ChooseMap( NULL );

    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset = MapsList_CreateScrollbox( scrollwindow_width, yoffset );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    menuitem_settings_background = UI_InitMenuItem( "m_startserver_settings_back", "", -xoffset, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem_settings_background );
    // create an associated picture to the items to act as window background
    menuitem = menuitem_settings_background;
    menuitem->ownerdraw = M_StartServer_DrawSettingsBox;
    menuitem->pict.shader = uis.whiteShader;
    menuitem->pict.shaderHigh = NULL;
    Vector4Copy( colorMdGrey, menuitem->pict.color );
    menuitem->pict.color[3] = 0;
    menuitem->pict.yoffset = 0;
    menuitem->pict.xoffset = 0;
    menuitem->pict.width = scrollwindow_width;
    menuitem->pict.height = yoffset + menuitem->pict.yoffset; // will be set later

    yoffset += trap_SCR_strHeight( menuitem->font );

    // g_gametype
    m_gametype = mapList_suggested_gametype ? mapList_suggested_gametype : SuggestGameType( NULL );
    menuitem = m_gametypes_item = UI_InitMenuItem( "m_startserver_gametype", "gametype", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_GametypeFunc );
    menuitem->statusbar = "select the server gametype";
    UI_SetupSpinControl( menuitem, startserver_gametype_names, m_gametype );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_timelimit
    menuitem = UI_InitMenuItem( "m_startserver_timelimit", "time limit", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "0 = no limit";
    UI_SetupField( menuitem, trap_Cvar_String( "g_timelimit" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_skilllevel
    menuitem = UI_InitMenuItem( "m_startserver_skill", "skill level", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_SkillLevelFunc );
    m_skill = trap_Cvar_Value( "sv_skilllevel" );
    menuitem->statusbar = "select server skill level";
    UI_SetupSpinControl( menuitem, skill_names, m_skill );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_scorelimit
    menuitem = UI_InitMenuItem( "m_startserver_scorelimit", "score limit", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "0 = no limit";
    UI_SetupField( menuitem, trap_Cvar_String( "g_scorelimit" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_cheats
    menuitem = UI_InitMenuItem( "m_startserver_cheats", "cheats", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_CheatsFunc );
    m_cheats = trap_Cvar_Value( "sv_cheats" );
    menuitem->statusbar = "enable cheats on the server";
    UI_SetupSpinControl( menuitem, offon_names, m_cheats );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_numbots
    menuitem = UI_InitMenuItem( "m_startserver_numbots", "number of bots", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "Can't be more than maxclients";
    UI_SetupField( menuitem, trap_Cvar_String( "g_numbots" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // g_instagib
    menuitem = UI_InitMenuItem( "m_startserver_instagib", "instagib", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_InstagibFunc );
    m_instagib = trap_Cvar_Value( "g_instagib" );
    menuitem->statusbar = "enable instagib mode";
    UI_SetupSpinControl( menuitem, offon_names, m_instagib );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_maxclients
    /*
    ** maxclients determines the maximum number of players that can join
    ** the game.  If maxclients is only "1" then we should default the menu
    ** option to 8 players, otherwise use whatever its current value is.
    */
    maxclients = trap_Cvar_Value( "sv_maxclients" ) <= 1 ? 8 : trap_Cvar_Value( "sv_maxclients" );
    menuitem = UI_InitMenuItem( "m_startserver_maxplayers", "max players", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    UI_SetupField( menuitem, va( "%i", maxclients ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_public
    menuitem = UI_InitMenuItem( "m_startserver_public", "public", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_PublicFunc );
    m_public = trap_Cvar_Value( "sv_public" );
    menuitem->statusbar = "announce this server to metaservers";
    UI_SetupSpinControl( menuitem, offon_names, m_public );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_hostname
    menuitem = UI_InitMenuItem( "m_startserver_hostname", "server name", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    UI_SetupField( menuitem, trap_Cvar_String( "sv_hostname" ), 14, -1 );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    // here ends the settings background, set it's image height now
    menuitem_settings_background->pict.height = yoffset - menuitem_settings_background->pict.height + ( 0.5 * trap_SCR_strHeight( menuitem->font ) );

    yoffset += trap_SCR_strHeight( menuitem->font );

    // begin button
    menuitem = UI_InitMenuItem( "m_startserver_begin", "begin", 16, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, StartServerActionFunc );
    Menu_AddItem( &s_startserver_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );

    menuitem = UI_InitMenuItem( "m_startserver_back", "back", -16, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

    Menu_Center( &s_startserver_menu );
    s_startserver_menu.x = ( uis.vidWidth / 2 );
    Menu_Init( &s_startserver_menu, qfalse );
    return qtrue;
}
Пример #24
0
/*
* G_RadiusDamage
*/
void G_RadiusDamage( edict_t *inflictor, edict_t *attacker, cplane_t *plane, edict_t *ignore, int mod )
{
	edict_t *ent = NULL;
	float dmgFrac, kickFrac, damage, knockback, stun;
	vec3_t pushDir;
	int timeDelta;

	float maxdamage, mindamage, maxknockback, minknockback, maxstun, minstun, radius;

	int rs_minKnockback = 0, rs_maxKnockback = 0, rs_radius = 0; //racesow

	assert( inflictor );

	maxdamage = inflictor->projectileInfo.maxDamage;
	mindamage = inflictor->projectileInfo.minDamage;
	maxknockback = inflictor->projectileInfo.maxKnockback;
	minknockback = inflictor->projectileInfo.minKnockback;
	maxstun = inflictor->projectileInfo.stun;
	minstun = 1;
	radius = inflictor->projectileInfo.radius;

	if( radius <= 1.0f || ( maxdamage <= 0.0f && maxknockback <= 0.0f ) )
		return;

	clamp_high( mindamage, maxdamage );
	clamp_high( minknockback, maxknockback );
	clamp_high( minstun, maxstun );

	while( ( ent = GClip_FindBoxInRadius4D( ent, inflictor->s.origin, radius, inflictor->timeDelta ) ) != NULL )
	{
		if( ent == ignore || !ent->takedamage )
			continue;

		if( ent == attacker && ent->r.client )
			timeDelta = 0;
		else
			timeDelta = inflictor->timeDelta;

		G_SplashFrac4D( ENTNUM( ent ), inflictor->s.origin, radius, pushDir, &kickFrac, &dmgFrac, timeDelta );

		damage = max( 0, mindamage + ( ( maxdamage - mindamage ) * dmgFrac ) );
		stun = max( 0, minstun + ( ( maxstun - minstun ) * dmgFrac ) );
		knockback = max( 0, minknockback + ( ( maxknockback - minknockback ) * kickFrac ) );

		// weapon jumps hack : when knockback on self, use strong weapon definition
		if( ent == attacker && ent->r.client )
		{
			gs_weapon_definition_t *weapondef = NULL;
			if( inflictor->s.type == ET_ROCKET )
			{
				weapondef = GS_GetWeaponDef( WEAP_ROCKETLAUNCHER );
				// racesow
				rs_maxKnockback = trap_Cvar_Get( "rs_rocket_knockback", "100", CVAR_ARCHIVE )->integer;
				rs_radius = trap_Cvar_Get( "rs_rocket_splash", "140", CVAR_ARCHIVE )->integer;
				rs_minKnockback = trap_Cvar_Get( "rs_rocket_minknockback", "10", CVAR_ARCHIVE)->integer;
				// !racesow
			}
			else if( inflictor->s.type == ET_GRENADE )
			{
				weapondef = GS_GetWeaponDef( WEAP_GRENADELAUNCHER );
				// racesow
				rs_maxKnockback = trap_Cvar_Get( "rs_grenade_knockback", "90", CVAR_ARCHIVE )->integer;
				rs_radius = trap_Cvar_Get( "rs_grenade_splash", "160", CVAR_ARCHIVE )->value;
				rs_minKnockback = trap_Cvar_Get( "rs_grenade_minknockback", "5", CVAR_ARCHIVE )->integer;
				// !racesow
			}
			else if( inflictor->s.type == ET_PLASMA )
			{
				weapondef = GS_GetWeaponDef( WEAP_PLASMAGUN );
				// racesow
				rs_maxKnockback = trap_Cvar_Get( "rs_plasma_knockback", "20", CVAR_ARCHIVE )->integer;
				rs_radius = trap_Cvar_Get( "rs_plasma_splash", "45", CVAR_ARCHIVE )->integer;
				rs_minKnockback = trap_Cvar_Get( "rs_plasma_minknockback", "1", CVAR_ARCHIVE)->integer;
				// !racesow
			}
			else if( inflictor->s.type == ET_BLASTER )
				weapondef = GS_GetWeaponDef( WEAP_GUNBLADE );

			// racesow
			if( rs_maxKnockback && rs_radius && rs_minKnockback && weapondef )
			{
				G_SplashFrac4D( ENTNUM( ent ), inflictor->s.origin, rs_radius, pushDir, &kickFrac, NULL, 0 );
				knockback = (float)( rs_maxKnockback * kickFrac * g_self_knockback->value );
				damage *= weapondef->firedef.selfdamage;
			}
			// !racesow
		}

		if( knockback < 1.0f )
			knockback = 0.0f;

		if( stun < 1.0f )
			stun = 0.0f;

		if( damage <= 0.0f && knockback <= 0.0f && stun <= 0.0f )
			continue;

		if( G_CanSplashDamage( ent, inflictor, plane ) )
			G_Damage( ent, inflictor, attacker, pushDir, inflictor->velocity, inflictor->s.origin, damage, knockback, stun, DAMAGE_RADIUS, mod );
	}
}
Пример #25
0
/*
* G_Gametype_Init
*/
void G_Gametype_Init( void )
{
	bool changed = false;
	const char *mapGametype;

	g_gametypes_list = trap_Cvar_Get( "g_gametypes_list", "", CVAR_NOSET|CVAR_ARCHIVE );
	G_Gametype_GenerateGametypesList(); // fill the g_gametypes_list cvar

	// empty string to allow all
	g_votable_gametypes = trap_Cvar_Get( "g_votable_gametypes", "", CVAR_ARCHIVE );

	if( !g_gametype ) // first time initialized
		changed = true;

	g_gametype = trap_Cvar_Get( "g_gametype", "dm", CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH );

	//get the match cvars too
	g_warmup_timelimit = trap_Cvar_Get( "g_warmup_timelimit", "5", CVAR_ARCHIVE );
	g_postmatch_timelimit = trap_Cvar_Get( "g_postmatch_timelimit", "4", CVAR_ARCHIVE );
	g_countdown_time = trap_Cvar_Get( "g_countdown_time", "5", CVAR_ARCHIVE );
	g_match_extendedtime = trap_Cvar_Get( "g_match_extendedtime", "2", CVAR_ARCHIVE );

	// game settings
	g_timelimit = trap_Cvar_Get( "g_timelimit", "10", CVAR_ARCHIVE );
	g_scorelimit = trap_Cvar_Get( "g_scorelimit", "0", CVAR_ARCHIVE );
	g_allow_falldamage = trap_Cvar_Get( "g_allow_falldamage", "1", CVAR_ARCHIVE );
	g_allow_selfdamage = trap_Cvar_Get( "g_allow_selfdamage", "1", CVAR_ARCHIVE );
	g_allow_teamdamage = trap_Cvar_Get( "g_allow_teamdamage", "1", CVAR_ARCHIVE );
	g_allow_bunny = trap_Cvar_Get( "g_allow_bunny", "1", CVAR_ARCHIVE|CVAR_READONLY );

	// map-specific gametype
	mapGametype = G_asCallMapGametype();
	if( mapGametype[0] && G_Gametype_Exists( mapGametype ) )
		trap_Cvar_Set( g_gametype->name, mapGametype );

	// update latched gametype change
	if( g_gametype->latched_string )
	{
		if( G_Gametype_Exists( g_gametype->latched_string ) )
		{
			trap_Cvar_ForceSet( "g_gametype", va( "%s", g_gametype->latched_string ) );
			changed = true;
		}
		else
		{
			G_Printf( "G_Gametype: Invalid new gametype, change ignored\n" );
			trap_Cvar_ForceSet( "g_gametype", va( "%s", g_gametype->string ) );
		}
	}

	if( !G_Gametype_Exists( g_gametype->string ) )
	{
		G_Printf( "G_Gametype: Wrong value: '%s'. Setting up with default (dm)\n", g_gametype->string );
		trap_Cvar_ForceSet( "g_gametype", "dm" );
		changed = true;
	}

	G_Printf( "-------------------------------------\n" );
	G_Printf( "Initalizing '%s' gametype\n", g_gametype->string );

	if( changed )
	{
		const char *configs_path = "configs/server/gametypes/";

		G_InitChallengersQueue();

		// print a hint for admins so they know there's a chance to execute a
		// config here, but don't show it as an error, because it isn't
		G_Printf( "loading %s%s.cfg\n", configs_path, g_gametype->string );
		trap_Cmd_ExecuteText( EXEC_NOW, va( "exec %s%s.cfg silent\n", configs_path, g_gametype->string ) );
		trap_Cbuf_Execute();

		// on a listen server, override gametype-specific settings in config
		trap_Cmd_ExecuteText( EXEC_NOW, "vstr ui_startservercmd\n" );
		trap_Cbuf_Execute();
	}

	// fixme: we are doing this twice because the gametype may check for GS_Instagib
	G_CheckCvars(); // update GS_Instagib, GS_FallDamage, etc

	G_Gametype_SetDefaults();

	// Init the current gametype
	if( !GT_asLoadScript( g_gametype->string ) )
		G_Gametype_GENERIC_Init();

	GS_SetGametypeName( g_gametype->string );

	trap_ConfigString( CS_GAMETYPENAME, g_gametype->string );

	G_CheckCvars(); // update GS_Instagib, GS_FallDamage, etc

	// ch : if new gametype has been initialized, transfer the
	// client-specific ratings to gametype-specific list
	if( changed )
		G_TransferRatings();
}
Пример #26
0
/*
* SNDDMA_Init
* 
* Try to find a sound device to mix for.
* Returns false if nothing is found.
*/
bool SNDDMA_Init( void *hwnd, bool verbose )
{
	sndinitstat stat;

	cl_hwnd = ( HWND )hwnd;

	memset( (void *)&dma, 0, sizeof( dma ) );

	s_wavonly = trap_Cvar_Get( "s_wavonly", "0", CVAR_LATCH_SOUND|CVAR_ARCHIVE );

	s_globalfocus->modified = false;

	dsound_init = wav_init = false;

	stat = SIS_FAILURE; // assume DirectSound won't initialize

	/* Init DirectSound */
	if( !s_wavonly->integer )
	{
		if( /*snd_isdirect*/1 )
		{
			stat = SNDDMA_InitDirect( verbose );

			if( stat == SIS_SUCCESS )
			{
				snd_isdirect = true;

				if( verbose )
					Com_Printf( "dsound init succeeded\n" );
			}
			else
			{
				snd_isdirect = false;
				Com_Printf( "*** dsound init failed ***\n" );
			}
		}
	}

	// if DirectSound didn't succeed in initializing, try to initialize
	// waveOut sound, unless DirectSound failed because the hardware is
	// already allocated (in which case the user has already chosen not
	// to have sound)
	if( !dsound_init && ( stat != SIS_NOTAVAIL ) )
	{
		if( /*snd_iswave*/1 )
		{
			snd_iswave = SNDDMA_InitWav( verbose );

			if( snd_iswave )
			{
				if( verbose )
					Com_Printf( "Wave sound init succeeded\n" );
			}
			else
			{
				Com_Printf( "Wave sound init failed\n" );
			}
		}
	}

	if( !dsound_init && !wav_init )
	{
		Com_Printf( "*** No sound device initialized ***\n" );
		return false;
	}

	return true;
}