コード例 #1
0
ファイル: ui_players.c プロジェクト: LuckyBro/sgfork
/*
===============
UI_PlayerInfo_SetWeapon
===============
*/
static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {
    gitem_t *	item;
    char		path[MAX_QPATH];

    pi->currentWeapon = weaponNum;
    pi->realWeapon = weaponNum;
    pi->weaponModel = 0;
    pi->barrelModel = 0;
    pi->flashModel = 0;

    if(weaponNum == WP_NONE)
        return;

    for(item=&bg_itemlist[1]; ITEM_INDEX(item) < IT_NUM_ITEMS; item++) {
        if(item->giType != IT_WEAPON)
            continue;
        if(item->giTag == weaponNum)
            break;
    }

    if (ITEM_INDEX(item) < IT_NUM_ITEMS)
        pi->weaponModel = trap_R_RegisterModel(item->world_model[0]);

    if(pi->weaponModel == 0 || ITEM_INDEX(item) >= IT_NUM_ITEMS) {
        weaponNum = WP_NONE;
        pi->currentWeapon = weaponNum;
        pi->realWeapon = weaponNum;
        return;
    }

    if ( weaponNum == WP_PEACEMAKER || weaponNum == WP_KNIFE ) {
        strcpy( path, item->world_model[0] );
        COM_StripExtension(path, path, sizeof(path));
        strcat( path, "_barrel.md3" );
        pi->barrelModel = trap_R_RegisterModel( path );
    }

    strcpy( path, item->world_model[0] );
    COM_StripExtension(path, path, sizeof(path));
    strcat( path, "_flash.md3" );
    pi->flashModel = trap_R_RegisterModel( path );

    switch( weaponNum ) {
    case WP_KNIFE:
        MAKERGB( pi->flashDlightColor, 0.0f, 0.0f, 0.0f );
        break;

    default:
        MAKERGB( pi->flashDlightColor, 1.0f, 1.0f, 0.0f );
        break;
    }
}
コード例 #2
0
/*
=================
CG_TestModel_f

Creates an entity in front of the current position, which
can then be moved around
=================
*/
void CG_TestModel_f( void )
{
	vec3_t angles;

	memset( &cg.testModelEntity, 0, sizeof( cg.testModelEntity ) );
	memset( &cg.testModelBarrelEntity, 0, sizeof( cg.testModelBarrelEntity ) );

	if ( trap_Argc() < 2 )
	{
		return;
	}

	Q_strncpyz( cg.testModelName, CG_Argv( 1 ), MAX_QPATH );
	cg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName );

	Q_strncpyz( cg.testModelBarrelName, CG_Argv( 1 ), MAX_QPATH );
	cg.testModelBarrelName[ strlen( cg.testModelBarrelName ) - 4 ] = '\0';
	Q_strcat( cg.testModelBarrelName, MAX_QPATH, "_barrel.md3" );
	cg.testModelBarrelEntity.hModel = trap_R_RegisterModel( cg.testModelBarrelName );

	if ( trap_Argc() == 3 )
	{
		cg.testModelEntity.backlerp = atof( CG_Argv( 2 ) );
		cg.testModelEntity.frame = 1;
		cg.testModelEntity.oldframe = 0;
	}

	if ( !cg.testModelEntity.hModel )
	{
		CG_Printf( "Can't register model\n" );
		return;
	}

	VectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[ 0 ], cg.testModelEntity.origin );

	angles[ PITCH ] = 0;
	angles[ YAW ] = 180 + cg.refdefViewAngles[ 1 ];
	angles[ ROLL ] = 0;

	AnglesToAxis( angles, cg.testModelEntity.axis );
	cg.testGun = qfalse;

	if ( cg.testModelBarrelEntity.hModel )
	{
		angles[ YAW ] = 0;
		angles[ PITCH ] = 0;
		angles[ ROLL ] = 0;
		AnglesToAxis( angles, cg.testModelBarrelEntity.axis );
	}
}
コード例 #3
0
static void CG_AddTestModel (void) {
	int		i;

	// re-register the model, because the level may have changed
	cg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName );
	if (! cg.testModelEntity.hModel ) {
		CG_Printf ("Can't register model\n");
		return;
	}

	// if testing a gun, set the origin reletive to the view origin
	if ( cg.testGun ) {
		VectorCopy( cg.refdef.vieworg, cg.testModelEntity.origin );
		VectorCopy( cg.refdef.viewaxis[0], cg.testModelEntity.axis[0] );
		VectorCopy( cg.refdef.viewaxis[1], cg.testModelEntity.axis[1] );
		VectorCopy( cg.refdef.viewaxis[2], cg.testModelEntity.axis[2] );

		// allow the position to be adjusted
		for (i=0 ; i<3 ; i++) {
			cg.testModelEntity.origin[i] += cg.refdef.viewaxis[0][i] * cg_gun_x.value;
			cg.testModelEntity.origin[i] += cg.refdef.viewaxis[1][i] * cg_gun_y.value;
			cg.testModelEntity.origin[i] += cg.refdef.viewaxis[2][i] * cg_gun_z.value;
		}
	}

	trap_R_AddRefEntityToScene( &cg.testModelEntity );
}
コード例 #4
0
ファイル: g_character.c プロジェクト: dstaesse/etlegacy
/*
===================
G_RegisterCharacter
===================
*/
qboolean G_RegisterCharacter(const char *characterFile, bg_character_t *character)
{
	bg_characterDef_t characterDef;

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

	if (!BG_ParseCharacterFile(characterFile, &characterDef))
	{
		return qfalse;  // the parser will provide the error message
	}

#ifdef FEATURE_SERVERMDX
	// Register mesh
	if (!(character->mesh = trap_R_RegisterModel(characterDef.mesh)))
	{
		G_Printf(S_COLOR_YELLOW "WARNING: failed to register mesh '%s' referenced from '%s'\n", characterDef.mesh, characterFile);
	}
#endif

	// Parse Animation Files
	if (!G_CheckForExistingAnimModelInfo(characterDef.animationGroup, characterDef.animationScript, &character->animModelInfo))
	{
		if (!G_ParseAnimationFiles(character, characterDef.animationGroup, characterDef.animationScript))
		{
			G_Printf(S_COLOR_YELLOW "WARNING: failed to load animation files referenced from '%s'\n", characterFile);
			return qfalse;
		}

		mdx_LoadHitsFile(characterDef.animationGroup, character->animModelInfo);
	}

	return qtrue;
}
コード例 #5
0
/*
=================
Controls_InitWeapons
=================
*/
static void Controls_InitWeapons( void ) {
	gitem_t *	item;

	for ( item = bg_itemlist + 1 ; item->classname ; item++ ) {
		if ( item->giType != IT_WEAPON ) {
			continue;
		}
		trap_R_RegisterModel( item->world_model[0] );
	}
}
コード例 #6
0
ファイル: cg_media.cpp プロジェクト: cfr/qfusion
/*
* CG_RegisterModel
*/
struct model_s *CG_RegisterModel( const char *name )
{
	struct model_s *model;

	model = trap_R_RegisterModel( name );

	// precache bones
	if( trap_R_SkeletalGetNumBones( model, NULL ) )
		CG_SkeletonForModel( model );

	return model;
}
コード例 #7
0
ファイル: bg_animgroup.c プロジェクト: BulldogDrummond/etmod
static qboolean BG_RAG_ParseAnimFile(int handle, animModelInfo_t *animModelInfo)
{
    pc_token_t token;
    qhandle_t  mdxFile;

    animation_t *animation;

    if (!trap_PC_ReadToken(handle, &token))
    {
        return BG_RAG_ParseError(handle, "expected mdx filename");
    }

    if (!(mdxFile = trap_R_RegisterModel(token.string)))
    {
        return BG_RAG_ParseError(handle, "failed to load %s", token.string);
    }

    if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
    {
        return BG_RAG_ParseError(handle, "expected '{'");
    }

    while (1)
    {
        if (!trap_PC_ReadToken(handle, &token))
        {
            return BG_RAG_ParseError(handle, "unexpected EOF");
        }

        if (token.string[0] == '}')
        {
            break;
        }

        if (!(animation = BG_RAG_FindFreeAnimation(mdxFile, token.string)))
        {
            return BG_RAG_ParseError(handle, "out of animation storage space");
        }

        Q_strncpyz(animation->name, token.string, sizeof(animation->name));
        Q_strlwr(animation->name);

        if (!BG_RAG_ParseAnimation(handle, animation))
        {
            return qfalse;
        }

        animModelInfo->animations[animModelInfo->numAnimations] = animation;
        animModelInfo->numAnimations++;
    }

    return qtrue;
}
コード例 #8
0
ファイル: cg_effects.c プロジェクト: Delfin1/japp
/*
==================
CG_GlassShatter_Old
Throws glass shards from within a given bounding box in the world
==================
*/
void CG_GlassShatter_Old(int entnum, vector3 *org, vector3 *mins, vector3 *maxs)
{
	vector3 velocity, a, shardorg, dif, difx;
	float windowmass;
	float shardsthrow = 0;
	char chunkname[256];

	trap_S_StartSound(org, entnum, CHAN_BODY, trap_S_RegisterSound("sound/effects/glassbreak1.wav"));

	VectorSubtract(maxs, mins, &a);

	windowmass = VectorLength(&a); //should give us some idea of how big the chunk of glass is

	while (shardsthrow < windowmass)
	{
		velocity.x = crandom()*150;
		velocity.y = crandom()*150;
		velocity.z = 150 + crandom()*75;

		Com_sprintf(chunkname, sizeof(chunkname), "models/chunks/glass/glchunks_%i.md3", Q_irand(1, 6));
		VectorCopy(org, &shardorg);
	
		dif.x = (maxs->x-mins->x)/2;
		dif.y = (maxs->y-mins->y)/2;
		dif.z = (maxs->z-mins->z)/2;

		if (dif.x < 2)
			dif.x = 2;
		if (dif.y < 2)
			dif.y = 2;
		if (dif.z < 2)
			dif.z = 2;

		difx.x = Q_irand(1, (dif.x*0.9)*2);
		difx.y = Q_irand(1, (dif.y*0.9)*2);
		difx.z = Q_irand(1, (dif.z*0.9)*2);

		if (difx.x > dif.x)		shardorg.x += difx.x-(dif.x);
		else					shardorg.x -= difx.x;
		if (difx.y > dif.y)		shardorg.y += difx.y-(dif.y);
		else					shardorg.y -= difx.y;
		if (difx.z > dif.z)		shardorg.z += difx.z-(dif.z);
		else					shardorg.z -= difx.z;

		//CG_TestLine(org, shardorg, 5000, 0x0000ff, 3);

		CG_ThrowChunk( &shardorg, &velocity, trap_R_RegisterModel( chunkname ), 0, 254 );

		shardsthrow += 10;
	}
}
コード例 #9
0
void SP_misc_weather_zone( void ) {
	char *model;
	vec3_t mins, maxs;

	CG_SpawnString( "model", "", &model );

	if( !model || !model[0] ) {
		CG_Error( "misc_weather_zone with invalid brush model data." );
		return;
	}

	trap_R_ModelBounds( trap_R_RegisterModel( model ), mins, maxs );

	trap_WE_AddWeatherZone( mins, maxs );
}
コード例 #10
0
ファイル: cg_weapons.c プロジェクト: entdark/q3mme
/*
=================
CG_RegisterItemVisuals

The server says this item is used on this level
=================
*/
void CG_RegisterItemVisuals( int itemNum ) {
	itemInfo_t		*itemInfo;
	gitem_t			*item;

	if ( itemNum < 0 || itemNum >= bg_numItems ) {
		CG_Error( "CG_RegisterItemVisuals: itemNum %d out of range [0-%d]", itemNum, bg_numItems-1 );
	}

	itemInfo = &cg_items[ itemNum ];
	if ( itemInfo->registered ) {
		return;
	}

	item = &bg_itemlist[ itemNum ];

	memset( itemInfo, 0, sizeof( &itemInfo ) );
	itemInfo->registered = qtrue;

	itemInfo->models[0] = trap_R_RegisterModel( item->world_model[0] );

	itemInfo->icon = trap_R_RegisterShader( item->icon );

	if ( item->giType == IT_WEAPON ) {
		CG_RegisterWeapon( item->giTag );
	}

	//
	// powerups have an accompanying ring or sphere
	//
	if ( item->giType == IT_POWERUP || item->giType == IT_HEALTH || 
		item->giType == IT_ARMOR || item->giType == IT_HOLDABLE ) {
		if ( item->world_model[1] ) {
			itemInfo->models[1] = trap_R_RegisterModel( item->world_model[1] );
		}
	}
}
コード例 #11
0
static JSBool sys_registermodel(JSContext *cx, unsigned argc, jsval *vp)
{
    JSString *s;
    char *message;
    jsval rval;
    qhandle_t handle;
    if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &s))
        return JS_FALSE;
    message = JS_EncodeString(cx, s);
    handle = trap_R_RegisterModel(message);
    JS_free(cx, message);
    JS_NewNumberValue(cx, handle, &rval);
    JS_SET_RVAL(cx, vp, rval);
    return JS_TRUE;
}
コード例 #12
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_PrecachePlayersForSiegeTeam(int team)
{
	siegeTeam_t *stm;
	int i = 0;

	stm = BG_SiegeFindThemeForTeam(team);

	if (!stm)
	{ //invalid team/no theme for team?
		return;
	}

	while (i < stm->numClasses)
	{
		siegeClass_t *scl = stm->classes[i];

		if (scl->forcedModel[0])
		{
			clientInfo_t fake;

			memset(&fake, 0, sizeof(fake));
			strcpy(fake.modelName, scl->forcedModel);

			trap_R_RegisterModel(va("models/players/%s/model.glm", scl->forcedModel));
			if (scl->forcedSkin[0])
			{
				trap_R_RegisterSkin(va("models/players/%s/model_%s.skin", scl->forcedModel, scl->forcedSkin));
				strcpy(fake.skinName, scl->forcedSkin);
			}
			else
			{
				strcpy(fake.skinName, "default");
			}

			//precache the sounds for the model...
			CG_LoadCISounds(&fake, qtrue);
		}

		i++;
	}
}
コード例 #13
0
ファイル: g_character.c プロジェクト: lcfx/etet
/*
===================
G_RegisterCharacter
===================
*/
qboolean G_RegisterCharacter( const char *characterFile, bg_character_t *character )
{
	bg_characterDef_t	characterDef;

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

	if( !BG_ParseCharacterFile( characterFile, &characterDef ) ) {
		return qfalse;	// the parser will provide the error message
	}

	// Register mesh
	if( !(character->mesh = trap_R_RegisterModel( characterDef.mesh )) )
		G_Printf( S_COLOR_YELLOW "WARNING: failed to register mesh '%s' referenced from '%s'\n", characterDef.mesh, characterFile );

	// Parse Animation Files
	if( !G_CheckForExistingAnimModelInfo( characterDef.animationGroup, characterDef.animationScript, &character->animModelInfo ) ) {
		if( !G_ParseAnimationFiles( character, characterDef.animationGroup, characterDef.animationScript ) ) {
			G_Printf( S_COLOR_YELLOW "WARNING: failed to load animation files referenced from '%s'\n", characterFile );
			return qfalse;
		}

#ifdef BONE_HITTESTS
		{
			char hitsfile[MAX_QPATH], *sep;
			// zinx - mdx hits
			Q_strncpyz(hitsfile, characterDef.animationGroup, sizeof(hitsfile) - 4);
			if ((sep = strrchr(hitsfile, '.'))) { // FIXME: should abort on /'s
				strcpy(sep, ".hit");
			} else {
				strcat(sep, ".hit");
			}
			mdx_RegisterHits( character->animModelInfo, hitsfile );
		}
#endif
	}

	return qtrue;
}
コード例 #14
0
/*
===============
CG_InitBuildables

Initialises the animation db
===============
*/
void CG_InitBuildables( void )
{
  char          filename[ MAX_QPATH ];
  char          soundfile[ MAX_QPATH ];
  char          *buildableName;
  char          *modelFile;
  int           i;
  int           j;
  fileHandle_t  f;

  memset( cg_buildables, 0, sizeof( cg_buildables ) );

  //default sounds
  for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ )
  {
    strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] );

    Com_sprintf( filename, sizeof( filename ), "sound/buildables/alien/%s", soundfile );
    defaultAlienSounds[ j ] = trap_S_RegisterSound( filename, qfalse );

    Com_sprintf( filename, sizeof( filename ), "sound/buildables/human/%s", soundfile );
    defaultHumanSounds[ j ] = trap_S_RegisterSound( filename, qfalse );
  }

  cg.buildablesFraction = 0.0f;

  for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ )
  {
    buildableName = BG_FindNameForBuildable( i );

    //animation.cfg
    Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName );
    if ( !CG_ParseBuildableAnimationFile( filename, i ) )
      Com_Printf( S_COLOR_YELLOW "WARNING: failed to load animation file %s\n", filename );

    //sound.cfg
    Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/sound.cfg", buildableName );
    if ( !CG_ParseBuildableSoundFile( filename, i ) )
      Com_Printf( S_COLOR_YELLOW "WARNING: failed to load sound file %s\n", filename );

    //models
    for( j = 0; j <= 3; j++ )
    {
      if( ( modelFile = BG_FindModelsForBuildable( i, j ) ) )
        cg_buildables[ i ].models[ j ] = trap_R_RegisterModel( modelFile );
    }

    //sounds
    for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ )
    {
      strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] );
      Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/%s", buildableName, soundfile );

      if( cg_buildables[ i ].sounds[ j ].enabled )
      {
        if( trap_FS_FOpenFile( filename, &f, FS_READ ) > 0 )
        {
          //file exists so close it
          trap_FS_FCloseFile( f );

          cg_buildables[ i ].sounds[ j ].sound = trap_S_RegisterSound( filename, qfalse );
        }
        else
        {
          //file doesn't exist - use default
          if( BG_FindTeamForBuildable( i ) == BIT_ALIENS )
            cg_buildables[ i ].sounds[ j ].sound = defaultAlienSounds[ j ];
          else
            cg_buildables[ i ].sounds[ j ].sound = defaultHumanSounds[ j ];
        }
      }
    }

    cg.buildablesFraction = (float)i / (float)( BA_NUM_BUILDABLES - 1 );
    trap_UpdateScreen( );
  }

  cgs.media.teslaZapTS = CG_RegisterTrailSystem( "models/buildables/tesla/zap" );
}
コード例 #15
0
ファイル: ui_players.c プロジェクト: LuckyBro/sgfork
/*
==========================
UI_RegisterClientModelname
==========================
*/
qbool UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName ) {
    char		modelName[MAX_QPATH];
    char		skinName[MAX_QPATH];
    char		filename[MAX_QPATH];
    char		*slash;

    pi->torsoModel = 0;
    pi->headModel = 0;

    if ( !modelSkinName[0] ) {
        return qfalse;
    }

    Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) );

    slash = strchr( modelName, '/' );
    if ( !slash ) {
        // modelName did not include a skin name
        Q_strncpyz( skinName, "default", sizeof( skinName ) );
    } else {
        Q_strncpyz( skinName, slash + 1, sizeof( skinName ) );
        *slash = '\0';
    }

    Com_sprintf( filename, sizeof( filename ), "models/wq3_players/%s/lower.md3", modelName );
    pi->legsModel = trap_R_RegisterModel( filename );
    if ( !pi->legsModel ) {
        Com_Printf( "Failed to load model file %s\n", filename );
        return qfalse;
    }

    Com_sprintf( filename, sizeof( filename ), "models/wq3_players/%s/upper.md3", modelName );
    pi->torsoModel = trap_R_RegisterModel( filename );
    if ( !pi->torsoModel ) {
        Com_Printf( "Failed to load model file %s\n", filename );
        return qfalse;
    }

    Com_sprintf( filename, sizeof( filename ), "models/wq3_players/%s/head.md3", modelName );
    pi->headModel = trap_R_RegisterModel( filename );

    if (!pi->headModel) {
        Com_Printf( "Failed to load model file %s\n", filename );
        return qfalse;
    }

    // if any skins failed to load, fall back to default
    if ( !UI_RegisterClientSkin( pi, modelName, skinName ) ) {
        if ( !UI_RegisterClientSkin( pi, modelName, "default" ) ) {
            Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
            return qfalse;
        }
    }

    // load the animations
    Com_sprintf( filename, sizeof( filename ), "models/wq3_players/%s/animation.cfg", modelName );
    if ( !UI_ParseAnimationFile( filename, pi->animations ) ) {
        Com_Printf( "Failed to load animation file %s\n", filename );
        return qfalse;
    }

    return qtrue;
}
コード例 #16
0
ファイル: cg_weapons.c プロジェクト: entdark/q3mme
/*
=================
CG_RegisterWeapon

The server says this item is used on this level
=================
*/
void CG_RegisterWeapon( int weaponNum ) {
	weaponInfo_t	*weaponInfo;
	gitem_t			*item, *ammo;
	char			path[MAX_QPATH];
	vec3_t			mins, maxs;
	int				i;

	weaponInfo = &cg_weapons[weaponNum];

	if ( weaponNum == 0 ) {
		return;
	}

	if ( weaponInfo->registered ) {
		return;
	}

	memset( weaponInfo, 0, sizeof( *weaponInfo ) );
	weaponInfo->registered = qtrue;

	for ( item = bg_itemlist + 1 ; item->classname ; item++ ) {
		if ( item->giType == IT_WEAPON && item->giTag == weaponNum ) {
			weaponInfo->item = item;
			break;
		}
	}
	if ( !item->classname ) {
		CG_Error( "Couldn't find weapon %i", weaponNum );
	}
	CG_RegisterItemVisuals( item - bg_itemlist );

	// load cmodel before model so filecache works
	weaponInfo->weaponModel = trap_R_RegisterModel( item->world_model[0] );

	// calc midpoint for rotation
	trap_R_ModelBounds( weaponInfo->weaponModel, mins, maxs );
	for ( i = 0 ; i < 3 ; i++ ) {
		weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * ( maxs[i] - mins[i] );
	}

	weaponInfo->weaponIcon = trap_R_RegisterShader( item->icon );
	weaponInfo->ammoIcon = trap_R_RegisterShader( item->icon );

	for ( ammo = bg_itemlist + 1 ; ammo->classname ; ammo++ ) {
		if ( ammo->giType == IT_AMMO && ammo->giTag == weaponNum ) {
			break;
		}
	}
	if ( ammo->classname && ammo->world_model[0] ) {
		weaponInfo->ammoModel = trap_R_RegisterModel( ammo->world_model[0] );
	}

	strcpy( path, item->world_model[0] );
	COM_StripExtension( path, path );
	strcat( path, "_flash.md3" );
	weaponInfo->flashModel = trap_R_RegisterModel( path );

	strcpy( path, item->world_model[0] );
	COM_StripExtension( path, path );
	strcat( path, "_barrel.md3" );
	weaponInfo->barrelModel = trap_R_RegisterModel( path );

	strcpy( path, item->world_model[0] );
	COM_StripExtension( path, path );
	strcat( path, "_hand.md3" );
	weaponInfo->handsModel = trap_R_RegisterModel( path );

	if ( !weaponInfo->handsModel ) {
		weaponInfo->handsModel = trap_R_RegisterModel( "models/weapons2/shotgun/shotgun_hand.md3" );
	}

	weaponInfo->loopFireSound = qfalse;

	switch ( weaponNum ) {
	case WP_GAUNTLET:
		MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
		weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
		break;

	case WP_LIGHTNING:
		MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
		weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
		weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse );

		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
		cgs.media.lightningShader = trap_R_RegisterShader( "lightningBoltNew");
		cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
		cgs.media.sfx_lghit1 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit.wav", qfalse );
		cgs.media.sfx_lghit2 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit2.wav", qfalse );
		cgs.media.sfx_lghit3 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit3.wav", qfalse );

		break;

	case WP_GRAPPLING_HOOK:
		MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
		weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/rocket/rocket.md3" );
		weaponInfo->missileTrailFunc = CG_GrappleTrail;
		weaponInfo->missileDlight = 200;
		weaponInfo->wiTrailTime = 2000;
		weaponInfo->trailRadius = 64;
		MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );
		weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
		weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse );
		break;

	case WP_MACHINEGUN:
		MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
		weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
		weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
		weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
		weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
		cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
		break;

	case WP_SHOTGUN:
		MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/shotgun/sshotf1b.wav", qfalse );
		weaponInfo->ejectBrassFunc = CG_ShotgunEjectBrass;
		break;

	case WP_ROCKET_LAUNCHER:
		weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/rocket/rocket.md3" );
		weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse );
		weaponInfo->missileTrailFunc = CG_RocketTrail;
		weaponInfo->missileDlight = 200;
		weaponInfo->wiTrailTime = 2000;
		weaponInfo->trailRadius = 64;
		MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );
		MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
		cgs.media.rocketExplosionShader = trap_R_RegisterShader( "rocketExplosion" );
		break;

	case WP_GRENADE_LAUNCHER:
		weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/grenade1.md3" );
		MAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/grenade/grenlf1a.wav", qfalse );
		cgs.media.grenadeExplosionShader = trap_R_RegisterShader( "grenadeExplosion" );
		break;

	case WP_PLASMAGUN:
		weaponInfo->missileTrailFunc = CG_PlasmaTrail;
		weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/plasma/lasfly.wav", qfalse );
		MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
		cgs.media.plasmaExplosionShader = trap_R_RegisterShader( "plasmaExplosion" );
		cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" );
		break;

	case WP_RAILGUN:
		weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/railgun/rg_hum.wav", qfalse );
		MAKERGB( weaponInfo->flashDlightColor, 1, 0.5f, 0 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/railgun/railgf1a.wav", qfalse );
		cgs.media.railExplosionShader = trap_R_RegisterShader( "railExplosion" );
		cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" );
		cgs.media.railCoreShader = trap_R_RegisterShader( "railCore" );
		break;

	case WP_BFG:
		weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/bfg/bfg_hum.wav", qfalse );
		MAKERGB( weaponInfo->flashDlightColor, 1, 0.7f, 1 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/bfg/bfg_fire.wav", qfalse );
		cgs.media.bfgExplosionShader = trap_R_RegisterShader( "bfgExplosion" );
		weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/bfg.md3" );
		weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse );
		break;

	 default:
		MAKERGB( weaponInfo->flashDlightColor, 1, 1, 1 );
		weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
		break;
	}
}
コード例 #17
0
/*
===============
UI_PlayerInfo_SetWeapon
===============
*/
static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {
	gitem_t *   item;
	char path[MAX_QPATH];

	pi->currentWeapon = weaponNum;
tryagain:
	pi->realWeapon = weaponNum;
	pi->weaponModel = 0;
	pi->barrelModel = 0;
	pi->flashModel = 0;

	if ( weaponNum == WP_NONE ) {
		return;
	}

	for ( item = bg_itemlist + 1; item->classname ; item++ ) {
		if ( item->giType != IT_WEAPON ) {
			continue;
		}
		if ( item->giTag == weaponNum ) {
			break;
		}
	}

	if ( item->classname ) {
		pi->weaponModel = trap_R_RegisterModel( item->world_model[0] );
	}

	if ( pi->weaponModel == 0 ) {
//		if( weaponNum == WP_MACHINEGUN ) {	//----(SA)	removing old weapon references
		if ( weaponNum == WP_MP40 ) {
			weaponNum = WP_NONE;
			goto tryagain;
		}
//		weaponNum = WP_MACHINEGUN;	//----(SA)	removing old weapon references
		weaponNum = WP_MP40;
		goto tryagain;
	}

	strcpy( path, item->world_model[0] );
	COM_StripExtension(path, path, sizeof(path));
	strcat( path, "_flash.md3" );
	pi->flashModel = trap_R_RegisterModel( path );

	switch ( weaponNum ) {
	case WP_GAUNTLET:
		MAKERGB( pi->flashDlightColor, 0.6, 0.6, 1 );
		break;

//	case WP_MACHINEGUN:
//		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
//		break;

//	case WP_SHOTGUN:
//		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
//		break;

	case WP_GRENADE_LAUNCHER:
		MAKERGB( pi->flashDlightColor, 1, 0.7, 0.5 );
		break;

	case WP_FLAMETHROWER:
		MAKERGB( pi->flashDlightColor, 0.6, 0.6, 1 );
		break;

//	case WP_RAILGUN:
//		MAKERGB( pi->flashDlightColor, 1, 0.5, 0 );
//		break;

//	case WP_BFG:
//		MAKERGB( pi->flashDlightColor, 1, 0.7, 1 );
//		break;

//	case WP_GRAPPLING_HOOK:
//		MAKERGB( pi->flashDlightColor, 0.6, 0.6, 1 );
//		break;

	default:
		MAKERGB( pi->flashDlightColor, 1, 1, 1 );
		break;
	}
}
コード例 #18
0
qboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName ) {
	char modelName[MAX_QPATH];
	char skinName[MAX_QPATH];
	char filename[MAX_QPATH];
	char        *slash;
	const char* backpack = NULL;
	const char* helmet = NULL;

	pi->torsoModel = 0;
	pi->headModel = 0;

	if ( !modelSkinName[0] ) {
		return qfalse;
	}

	Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) );

	slash = strchr( modelName, '/' );
	if ( !slash ) {
		// modelName did not include a skin name
		Q_strncpyz( skinName, "default", sizeof( skinName ) );
	} else {
		Q_strncpyz( skinName, slash + 1, sizeof( skinName ) );
		// truncate modelName
		*slash = 0;
	}

	// NERVE - SMF - set weapon
	pi->weapon = WM_getWeaponIndex();
	UI_PlayerInfo_SetWeapon( pi, pi->weapon );

	// NERVE - SMF - determine skin
	{
		const char *team;
		const char *playerClass;
		int var, teamval;

		teamval = trap_Cvar_VariableValue( "mp_team" );

		if ( teamval == 1 ) {
			team = "blue";
		} else {
			team = "red";
		}

		var = trap_Cvar_VariableValue( "mp_playerType" );

		if ( var == 0 ) {
			playerClass = "soldier";

			if ( teamval == 1 ) {
				backpack = "acc/backpack/backpack_sol.md3";
				helmet = "acc/helmet_american/sol.md3";
			} else {
				backpack = "acc/backpack/backpack_german_sol.md3";
				helmet = "acc/helmet_german/helmet_german_sol.md3";
			}
		} else if ( var == 1 )   {
			playerClass = "medic";

			if ( teamval == 1 ) {
				backpack = "acc/backpack/backpack_med.md3";
				helmet = "acc/helmet_american/med.md3";
			} else {
				backpack = "acc/backpack/backpack_german_med.md3";
				helmet = "acc/helmet_german/helmet_german_med.md3";
			}
		} else if ( var == 2 )   {
			playerClass = "engineer";

			if ( teamval == 1 ) {
				backpack = "acc/backpack/backpack_eng.md3";
				helmet = "acc/helmet_american/eng.md3";
			} else {
				backpack = "acc/backpack/backpack_german_eng.md3";
				helmet = "acc/helmet_german/helmet_german_eng.md3";
			}
		} else {
			playerClass = "lieutenant";

			if ( teamval == 1 ) {
				backpack = "acc/backpack/backpack_lieu.md3";
				helmet = "acc/helmet_american/lieu.md3";
			} else {
				backpack = "acc/backpack/backpack_german_lieu.md3";
				helmet = "acc/helmet_american/lieu.md3";
			}
		}

		strcpy( skinName, va( "%s%s1", team, playerClass ) );
	}
	// -NERVE - SMF

//		Q_strncpyz( skinName, "bluesoldier1", sizeof( skinName ) );		// NERVE - SMF - make this work with wolf - TESTING!!!
//	}
//	else {
//		Q_strncpyz( skinName, "redsoldier1", sizeof( skinName ) );		// NERVE - SMF - make this work with wolf - TESTING!!!
//	}

	// load cmodels before models so filecache works

//	Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
	Com_sprintf( filename, sizeof( filename ), "models/players/%s/body.mds", modelName ); // NERVE - SMF - make this work with wolf
	pi->legsModel = trap_R_RegisterModel( filename );
	if ( !pi->legsModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

//	Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
	Com_sprintf( filename, sizeof( filename ), "models/players/%s/body.mds", modelName ); // NERVE - SMF - make this work with wolf
	pi->torsoModel = trap_R_RegisterModel( filename );
	if ( !pi->torsoModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

	Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", modelName );
	pi->headModel = trap_R_RegisterModel( filename );
	if ( !pi->headModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

	// NERVE - SMF - load backpack and helmet
	if ( backpack ) {
		pi->backpackModel = trap_R_RegisterModel( va( "models/players/%s/%s", modelName, backpack ) );
	}

	if ( helmet ) {
		pi->helmetModel = trap_R_RegisterModel( va( "models/players/%s/%s", modelName, helmet ) );
	}

	// if any skins failed to load, fall back to default
	if ( !UI_RegisterClientSkin( pi, modelName, skinName ) ) {
		if ( !UI_RegisterClientSkin( pi, modelName, "default" ) ) {
			Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
			return qfalse;
		}
	}

	// load the animations
//----(SA) changing name of config file to avoid backwards or alternate compatibility confustion
//	Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
	Com_sprintf( filename, sizeof( filename ), "models/players/%s/wolfanim.cfg", modelName );
//----(SA) end
	if ( !UI_ParseAnimationFile( filename, pi ) ) {         // NERVE - SMF - make this work with wolf
		Com_Printf( "Failed to load animation file %s\n", filename );
		return qfalse;
	}

	return qtrue;
}
コード例 #19
0
ファイル: cg_spawn.cpp プロジェクト: TheDushan/OpenWolf
void SP_misc_gamemodel( void ) {
	char* model;
	vec_t angle;
	vec3_t angles;

	vec_t scale;
	vec3_t vScale;

	vec3_t org;

	cg_gamemodel_t* gamemodel;

	int i;

	if ( CG_SpawnString( "targetname", "", &model ) || CG_SpawnString( "scriptname", "", &model ) || CG_SpawnString( "spawnflags", "", &model ) ) {
		// Gordon: this model may not be static, so let the server handle it
		return;
	}

	if ( cg.numMiscGameModels >= MAX_STATIC_GAMEMODELS ) {
		CG_Error( "^1MAX_STATIC_GAMEMODELS(%i) hit", MAX_STATIC_GAMEMODELS );
	}

	CG_SpawnString( "model", "", &model );

	CG_SpawnVector( "origin", "0 0 0", org );

	if ( !CG_SpawnVector( "angles", "0 0 0", angles ) ) {
		if ( CG_SpawnFloat( "angle", "0", &angle ) ) {
			angles[YAW] = angle;
		}
	}

	if ( !CG_SpawnVector( "modelscale_vec", "1 1 1", vScale ) ) {
		if ( CG_SpawnFloat( "modelscale", "1", &scale ) ) {
			VectorSet( vScale, scale, scale, scale );
		}
	}

	gamemodel = &cgs.miscGameModels[cg.numMiscGameModels++];
	gamemodel->model = trap_R_RegisterModel( model );
	AnglesToAxis( angles, gamemodel->axes );
	for ( i = 0; i < 3; i++ ) {
		VectorScale( gamemodel->axes[i], vScale[i], gamemodel->axes[i] );
	}
	VectorCopy( org, gamemodel->org );

	if ( gamemodel->model ) {
		vec3_t mins, maxs;

		trap_R_ModelBounds( gamemodel->model, mins, maxs );

		for ( i = 0; i < 3; i++ ) {
			mins[i] *= vScale[i];
			maxs[i] *= vScale[i];
		}

		gamemodel->radius = RadiusFromBounds( mins, maxs );
	} else {
		gamemodel->radius = 0;
	}
}
コード例 #20
0
ファイル: ui_players.c プロジェクト: SHOVELL/Unvanquished
/*
===============
UI_PlayerInfo_SetWeapon
===============
*/
static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum )
{
	gitem_t *item;
	char    path[ MAX_QPATH ];

	pi->currentWeapon = weaponNum;
tryagain:
	pi->realWeapon = weaponNum;
	pi->weaponModel = 0;
	pi->barrelModel = 0;
	pi->flashModel = 0;

	if ( weaponNum == WP_NONE )
	{
		return;
	}

	// NERVE - SMF - multiplayer only hack to show correct panzerfaust and venom barrel
	if ( weaponNum == WP_PANZERFAUST )
	{
		pi->weaponModel = trap_R_RegisterModel( "models/multiplayer/panzerfaust/multi_pf.md3" );
		return;
	}

	// -NERVE - SMF

	for ( item = bg_itemlist + 1; item->classname; item++ )
	{
		if ( item->giType != IT_WEAPON )
		{
			continue;
		}

		if ( item->giTag == weaponNum )
		{
			break;
		}
	}

	if ( item->classname )
	{
		pi->weaponModel = trap_R_RegisterModel( item->world_model[ 0 ] );
	}

	if ( pi->weaponModel == 0 )
	{
		if ( weaponNum == WP_MP40 )
		{
			weaponNum = WP_NONE;
			goto tryagain;
		}

		weaponNum = WP_MP40;
		goto tryagain;
	}

	strcpy( path, item->world_model[ 0 ] );
	COM_StripExtension( path, path );
	strcat( path, "_flash.md3" );
	pi->flashModel = trap_R_RegisterModel( path );

	switch ( weaponNum )
	{
//  case WP_MACHINEGUN:
//      MAKERGB( pi->flashDlightColor, 1, 1, 0 );
//      break;

//  case WP_SHOTGUN:
//      MAKERGB( pi->flashDlightColor, 1, 1, 0 );
//      break;

		case WP_GRENADE_LAUNCHER:
			MAKERGB( pi->flashDlightColor, 1, 0.7, 0.5 );
			break;

		case WP_FLAMETHROWER:
			MAKERGB( pi->flashDlightColor, 0.6, 0.6, 1 );
			break;

//  case WP_RAILGUN:
//      MAKERGB( pi->flashDlightColor, 1, 0.5, 0 );
//      break;

//  case WP_BFG:
//      MAKERGB( pi->flashDlightColor, 1, 0.7, 1 );
//      break;

//  case WP_GRAPPLING_HOOK:
//      MAKERGB( pi->flashDlightColor, 0.6, 0.6, 1 );
//      break;

		default:
			MAKERGB( pi->flashDlightColor, 1, 1, 1 );
			break;
	}
}
コード例 #21
0
ファイル: ui_players.c プロジェクト: ElderPlayerX/Afterwards
/*
===============
UI_PlayerInfo_SetWeapon
===============
*/
static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {
	gitem_t *	item;
	char		path[MAX_QPATH];

	pi->currentWeapon = weaponNum;
tryagain:
	pi->realWeapon = weaponNum;
	pi->weaponModel = 0;
	pi->barrelModel = 0;
	pi->flashModel = 0;

	if ( weaponNum == WP_NONE ) {
		return;
	}

	for ( item = bg_itemlist + 1; item->classname ; item++ ) {
		if ( item->giType != IT_WEAPON ) {
			continue;
		}
		if ( item->giTag == weaponNum ) {
			break;
		}
	}

	if ( item->classname ) {
		pi->weaponModel = trap_R_RegisterModel( item->world_model[0] );
	}

	if( pi->weaponModel == 0 ) {
		if( weaponNum == WP_MACHINEGUN ) {
			weaponNum = WP_NONE;
			goto tryagain;
		}
		weaponNum = WP_MACHINEGUN;
		goto tryagain;
	}

	if ( weaponNum == WP_MACHINEGUN || weaponNum == WP_GAUNTLET || weaponNum == WP_BFG ) {
		strcpy( path, item->world_model[0] );
		COM_StripExtension( path, path );
		strcat( path, "_barrel.md3" );
		pi->barrelModel = trap_R_RegisterModel( path );
	}

	strcpy( path, item->world_model[0] );
	COM_StripExtension( path, path );
	strcat( path, "_flash.md3" );
	pi->flashModel = trap_R_RegisterModel( path );

	switch( weaponNum ) {
	case WP_GAUNTLET:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	case WP_MACHINEGUN:
		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
		break;

	case WP_SHOTGUN:
		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
		break;

	case WP_GRENADE_LAUNCHER:
		MAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f );
		break;

	case WP_ROCKET_LAUNCHER:
		MAKERGB( pi->flashDlightColor, 1, 0.75f, 0 );
		break;

	case WP_LIGHTNING:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	case WP_RAILGUN:
		MAKERGB( pi->flashDlightColor, 1, 0.5f, 0 );
		break;

	case WP_PLASMAGUN:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	case WP_BFG:
		MAKERGB( pi->flashDlightColor, 1, 0.7f, 1 );
		break;

	case WP_GRAPPLING_HOOK:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	default:
		MAKERGB( pi->flashDlightColor, 1, 1, 1 );
		break;
	}
}
コード例 #22
0
ファイル: ui_players.c プロジェクト: ElderPlayerX/Afterwards
/*
==========================
UI_RegisterClientModelname
==========================
*/
qboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName, const char *headName, const char *teamName ) {
	char		modelName[MAX_QPATH];
	char		headModelName[MAX_QPATH];
	char		skinName[MAX_QPATH];
	char		filename[MAX_QPATH];
	char		*slash, *headslash;

	pi->torsoModel = 0;
	pi->headModel = 0;

	if ( !modelSkinName[0] ) {
		return qfalse;
	}

	Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) );
	Q_strncpyz( headModelName, headName, sizeof( headModelName ) );

	slash = strchr( modelName, '/' );
	if ( !slash ) {
		// modelName did not include a skin name
		Q_strncpyz( skinName, "default", sizeof( skinName ) );
	} else {
		Q_strncpyz( skinName, slash + 1, sizeof( skinName ) );
		// truncate modelName
		*slash = 0;
	}

	headslash = strchr( headModelName, '/' );
	if ( headslash ) {
		*headslash = 0;
	}

	// load cmodels before models so filecache works

	Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
	pi->legsModel = trap_R_RegisterModel( filename );
	if ( !pi->legsModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

	Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
	pi->torsoModel = trap_R_RegisterModel( filename );
	if ( !pi->torsoModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

  if (headName && headName[0] == '*' ) {
	  Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", &headName[1], &headName[1] );
  }
  else {
	  Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", headModelName );
  }
  pi->headModel = trap_R_RegisterModel( filename );
  if ( !pi->headModel && headName[0] != '*') {
	  Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", headName, headName );
	  pi->headModel = trap_R_RegisterModel( filename );
	}

	if (!pi->headModel) {
	  Com_Printf( "Failed to load model file %s\n", filename );
	  return qfalse;
  }

	// if any skins failed to load, fall back to default
	if ( !UI_RegisterClientSkin( pi, modelName, skinName, headModelName, skinName, teamName) ) {
    if ( !UI_RegisterClientSkin( pi, modelName, "default", headName, "default", teamName ) ) {
			Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
			return qfalse;
		}
	}

	// load the animations
	Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
	if ( !UI_ParseAnimationFile( filename, pi->animations ) ) {
		Com_Printf( "Failed to load animation file %s\n", filename );
		return qfalse;
	}

	return qtrue;
}
コード例 #23
0
/*
===============
UI_PlayerInfo_SetWeapon
===============
*/
static void UI_PlayerInfo_SetWeapon( uiPlayerInfo_t *pi, weapon_t weaponNum ) {
#ifdef TA_WEAPSYS
	int			i;
#else
	gitem_t *	item;
#endif
	char		path[MAX_QPATH];

	pi->currentWeapon = weaponNum;
#ifndef TA_WEAPSYS
tryagain:
#endif
	pi->realWeapon = weaponNum;
#ifdef TA_WEAPSYS
	for (i = 0; i < MAX_HANDS; i++)
	{
		pi->weaponModel[i] = 0;
		pi->barrelModel[i] = 0;
		pi->flashModel[i] = 0;
	}
#else
	pi->weaponModel = 0;
	pi->barrelModel = 0;
	pi->flashModel = 0;
#endif

	if ( weaponNum == WP_NONE ) {
		return;
	}

#ifdef TA_WEAPSYS
	for (i = 0; i < MAX_HANDS; i++)
	{
		if (bg_weapongroupinfo[weaponNum].weapon[i]->model[0] == '\0')
			continue;

		pi->weaponModel[i] = trap_R_RegisterModel(bg_weapongroupinfo[weaponNum].weapon[i]->model);

		strcpy( path, bg_weapongroupinfo[weaponNum].weapon[i]->model );
		COM_StripExtension(path, path, sizeof(path));
		strcat( path, "_barrel.md3" );
		pi->barrelModel[i] = trap_R_RegisterModel( path );

		strcpy( path, bg_weapongroupinfo[weaponNum].weapon[i]->model );
		COM_StripExtension(path, path, sizeof(path));
		strcat( path, "_flash.md3" );
		pi->flashModel[i] = trap_R_RegisterModel( path );

		VectorCopy(bg_weapongroupinfo[weaponNum].weapon[i]->flashColor, pi->flashDlightColor[i]);
	}
#else
	item = BG_FindItemForWeapon( weaponNum );
	if ( item ) {
		pi->weaponModel = trap_R_RegisterModel( item->world_model[0] );
	}

	if( pi->weaponModel == 0 ) {
		if( weaponNum == WP_MACHINEGUN ) {
			weaponNum = WP_NONE;
			goto tryagain;
		}
		weaponNum = WP_MACHINEGUN;
		goto tryagain;
	}

	COM_StripExtension( item->world_model[0], path, sizeof(path) );
	Q_strcat( path, sizeof(path), "_barrel.md3" );
	pi->barrelModel = trap_R_RegisterModel( path );

	COM_StripExtension( item->world_model[0], path, sizeof(path) );
	Q_strcat( path, sizeof(path), "_flash.md3" );
	pi->flashModel = trap_R_RegisterModel( path );

	switch( weaponNum ) {
	case WP_GAUNTLET:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	case WP_MACHINEGUN:
		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
		break;

	case WP_SHOTGUN:
		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
		break;

	case WP_GRENADE_LAUNCHER:
		MAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f );
		break;

	case WP_ROCKET_LAUNCHER:
		MAKERGB( pi->flashDlightColor, 1, 0.75f, 0 );
		break;

	case WP_LIGHTNING:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	case WP_RAILGUN:
		MAKERGB( pi->flashDlightColor, 1, 0.5f, 0 );
		break;

	case WP_PLASMAGUN:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

	case WP_BFG:
		MAKERGB( pi->flashDlightColor, 1, 0.7f, 1 );
		break;

	case WP_GRAPPLING_HOOK:
		MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
		break;

#ifdef MISSIONPACK
	case WP_NAILGUN:
		MAKERGB( pi->flashDlightColor, 1, 0.75f, 0 );
		break;

	case WP_PROX_LAUNCHER:
		MAKERGB( pi->flashDlightColor, 1, 0.70f, 0 );
		break;

	case WP_CHAINGUN:
		MAKERGB( pi->flashDlightColor, 1, 1, 0 );
		break;
#endif

	default:
		MAKERGB( pi->flashDlightColor, 1, 1, 1 );
		break;
	}
#endif
}
コード例 #24
0
void SP_misc_model_static( void ) {
	char* model;
	vec_t angle;
	vec3_t angles;
	vec_t scale;
	vec3_t vScale;
	vec3_t org;
	vec_t zoffset;
	int i;
	int modelIndex;
	cg_staticmodel_t *staticmodel;

	if( cgs.numMiscStaticModels >= MAX_STATIC_MODELS ) {
		CG_Error( "MAX_STATIC_MODELS(%i) hit", MAX_STATIC_MODELS );
	}

	CG_SpawnString( "model", "", &model );

	if( !model || !model[0] ) {
		CG_Error( "misc_model_static with no model." );
	}

	CG_SpawnVector( "origin", "0 0 0", org );
	CG_SpawnFloat( "zoffset", "0", &zoffset );

	if( !CG_SpawnVector( "angles", "0 0 0", angles ) ) {
		if( CG_SpawnFloat( "angle", "0", &angle ) ) {
			angles[YAW] = angle;
		}
	}

	if( !CG_SpawnVector( "modelscale_vec", "1 1 1", vScale ) ) {
		if( CG_SpawnFloat( "modelscale", "1", &scale ) ) {
			VectorSet( vScale, scale, scale, scale );
		}
	}

	modelIndex = trap_R_RegisterModel( model );
	if( modelIndex == 0 ) {
		CG_Error( "misc_model_static failed to load model '%s'", model );
		return;
	}

	staticmodel		= &cgs.miscStaticModels[cgs.numMiscStaticModels++];
	staticmodel->model	= modelIndex;
	AnglesToAxis( angles, staticmodel->axes );
	for( i = 0; i < 3; i++ ) {
		VectorScale( staticmodel->axes[i], vScale[i], staticmodel->axes[i] );
	}

	VectorCopy( org, staticmodel->org );
	staticmodel->zoffset = zoffset;

	if( staticmodel->model ) {
		vec3_t mins, maxs;

		trap_R_ModelBounds( staticmodel->model, mins, maxs );

		VectorScaleVector( mins, vScale, mins );
		VectorScaleVector( maxs, vScale, maxs );

		staticmodel->radius = RadiusFromBounds( mins, maxs );
	}
	else {
		staticmodel->radius = 0;
	}
}
コード例 #25
0
ファイル: cg_saga.c プロジェクト: ForcePush/OJPRPFZ
void CG_InitSiegeMode(void)
{
	char			levelname[MAX_QPATH];
	char			btime[1024];
	char			teams[2048];
	char			teamInfo[MAX_SIEGE_INFO_SIZE];
	int				len = 0;
	int				i = 0;
	int				j = 0;
	siegeClass_t		*cl;
	siegeTeam_t		*sTeam;
	fileHandle_t	f;
	char			teamIcon[128];

	if (cgs.gametype != GT_SIEGE)
	{
		goto failure;
	}

	Com_sprintf(levelname, sizeof(levelname), "%s\0", cgs.mapname);

	i = strlen(levelname)-1;

	while (i > 0 && levelname[i] && levelname[i] != '.')
	{
		i--;
	}

	if (!i)
	{
		goto failure;
	}

	levelname[i] = '\0'; //kill the ".bsp"

	Com_sprintf(levelname, sizeof(levelname), "%s.siege\0", levelname); 

	if (!levelname || !levelname[0])
	{
		goto failure;
	}

	len = trap_FS_FOpenFile(levelname, &f, FS_READ);

	if (!f || len >= MAX_SIEGE_INFO_SIZE)
	{
		goto failure;
	}

	trap_FS_Read(siege_info, len, f);

	trap_FS_FCloseFile(f);

	siege_valid = 1;

	if (BG_SiegeGetValueGroup(siege_info, "Teams", teams))
	{
		char buf[1024];

		//[SIEGECVARFIX]
		siege_Cvar_VariableStringBuffer("cg_siegeTeam1", buf, 1024);
		//trap_Cvar_VariableStringBuffer("cg_siegeTeam1", buf, 1024);
		//[SIEGECVARFIX]
		if (buf[0] && Q_stricmp(buf, "none"))
		{
			strcpy(team1, buf);
		}
		else
		{
			BG_SiegeGetPairedValue(teams, "team1", team1);
		}

		if (team1[0] == '@')
		{ //it's a damn stringed reference.
			char b[256];
			trap_SP_GetStringTextString(team1+1, b, 256);
			trap_Cvar_Set("cg_siegeTeam1Name", b);
		}
		else
		{
			trap_Cvar_Set("cg_siegeTeam1Name", team1);
		}

		//[SIEGECVARFIX]
		siege_Cvar_VariableStringBuffer("cg_siegeTeam2", buf, 1024);
		//trap_Cvar_VariableStringBuffer("cg_siegeTeam2", buf, 1024);
		//[/SIEGECVARFIX]
		if (buf[0] && Q_stricmp(buf, "none"))
		{
			strcpy(team2, buf);
		}
		else
		{
			BG_SiegeGetPairedValue(teams, "team2", team2);
		}

		if (team2[0] == '@')
		{ //it's a damn stringed reference.
			char b[256];
			trap_SP_GetStringTextString(team2+1, b, 256);
			trap_Cvar_Set("cg_siegeTeam2Name", b);
		}
		else
		{
			trap_Cvar_Set("cg_siegeTeam2Name", team2);
		}
	}
	else
	{
		CG_Error("Siege teams not defined");
	}

	if (BG_SiegeGetValueGroup(siege_info, team1, teamInfo))
	{
		if (BG_SiegeGetPairedValue(teamInfo, "TeamIcon", teamIcon))
		{
			trap_Cvar_Set( "team1_icon", teamIcon);
		}

		if (BG_SiegeGetPairedValue(teamInfo, "Timed", btime))
		{
			team1Timed = atoi(btime)*1000;
			CG_SetSiegeTimerCvar ( team1Timed );
		}
		else
		{
			team1Timed = 0;
		}
	}
	else
	{
		CG_Error("No team entry for '%s'\n", team1);
	}

	if (BG_SiegeGetPairedValue(siege_info, "mapgraphic", teamInfo))
	{
		trap_Cvar_Set("siege_mapgraphic", teamInfo);
	}
	else
	{
		trap_Cvar_Set("siege_mapgraphic", "gfx/mplevels/siege1_hoth");
	}

	if (BG_SiegeGetPairedValue(siege_info, "missionname", teamInfo))
	{
		trap_Cvar_Set("siege_missionname", teamInfo);
	}
	else
	{
		trap_Cvar_Set("siege_missionname", " ");
	}

	if (BG_SiegeGetValueGroup(siege_info, team2, teamInfo))
	{
		if (BG_SiegeGetPairedValue(teamInfo, "TeamIcon", teamIcon))
		{
			trap_Cvar_Set( "team2_icon", teamIcon);
		}

		if (BG_SiegeGetPairedValue(teamInfo, "Timed", btime))
		{
			team2Timed = atoi(btime)*1000;
			CG_SetSiegeTimerCvar ( team2Timed );
		}
		else
		{
			team2Timed = 0;
		}
	}
	else
	{
		CG_Error("No team entry for '%s'\n", team2);
	}

	//Load the player class types
	BG_SiegeLoadClasses(NULL);

	if (!bgNumSiegeClasses)
	{ //We didn't find any?!
		CG_Error("Couldn't find any player classes for Siege");
	}

	//Now load the teams since we have class data.
	BG_SiegeLoadTeams();

	if (!bgNumSiegeTeams)
	{ //React same as with classes.
		CG_Error("Couldn't find any player teams for Siege");
	}

	//Get and set the team themes for each team. This will control which classes can be
	//used on each team.
	if (BG_SiegeGetValueGroup(siege_info, team1, teamInfo))
	{
		if (BG_SiegeGetPairedValue(teamInfo, "UseTeam", btime))
		{
			BG_SiegeSetTeamTheme(SIEGETEAM_TEAM1, btime);
		}
		if (BG_SiegeGetPairedValue(teamInfo, "FriendlyShader", btime))
		{
			cgSiegeTeam1PlShader = trap_R_RegisterShaderNoMip(btime);
		}
		else
		{
			cgSiegeTeam1PlShader = 0;
		}
	}
	if (BG_SiegeGetValueGroup(siege_info, team2, teamInfo))
	{
		if (BG_SiegeGetPairedValue(teamInfo, "UseTeam", btime))
		{
			BG_SiegeSetTeamTheme(SIEGETEAM_TEAM2, btime);
		}
		if (BG_SiegeGetPairedValue(teamInfo, "FriendlyShader", btime))
		{
			cgSiegeTeam2PlShader = trap_R_RegisterShaderNoMip(btime);
		}
		else
		{
			cgSiegeTeam2PlShader = 0;
		}
	}

	//Now go through the classes used by the loaded teams and try to precache
	//any forced models or forced skins.
	i = SIEGETEAM_TEAM1;

	while (i <= SIEGETEAM_TEAM2)
	{
		j = 0;
		sTeam = BG_SiegeFindThemeForTeam(i);

		if (!sTeam)
		{
			i++;
			continue;
		}

		//Get custom team shaders while we're at it.
		if (i == SIEGETEAM_TEAM1)
		{
			cgSiegeTeam1PlShader = sTeam->friendlyShader;
		}
		else if (i == SIEGETEAM_TEAM2)
		{
			cgSiegeTeam2PlShader = sTeam->friendlyShader;
		}

		while (j < sTeam->numClasses)
		{
			cl = sTeam->classes[j];

			if (cl->forcedModel[0])
			{ //This class has a forced model, so precache it.
				trap_R_RegisterModel(va("models/players/%s/model.glm", cl->forcedModel));

				if (cl->forcedSkin[0])
				{ //also has a forced skin, precache it.
					char *useSkinName;

					if (strchr(cl->forcedSkin, '|'))
					{//three part skin
						useSkinName = va("models/players/%s/|%s", cl->forcedModel, cl->forcedSkin);
					}
					else
					{
						useSkinName = va("models/players/%s/model_%s.skin", cl->forcedModel, cl->forcedSkin);
					}

					trap_R_RegisterSkin(useSkinName);
				}
			}
			
			j++;
		}
		i++;
	}

	//precache saber data for classes that use sabers on both teams
	BG_PrecacheSabersForSiegeTeam(SIEGETEAM_TEAM1);
	BG_PrecacheSabersForSiegeTeam(SIEGETEAM_TEAM2);

	CG_PrecachePlayersForSiegeTeam(SIEGETEAM_TEAM1);
	CG_PrecachePlayersForSiegeTeam(SIEGETEAM_TEAM2);

	CG_PrecachePlayersForSiegeTeam(SIEGETEAM_TEAM1);
	CG_PrecachePlayersForSiegeTeam(SIEGETEAM_TEAM2);

	CG_PrecacheSiegeObjectiveAssetsForTeam(SIEGETEAM_TEAM1);
	CG_PrecacheSiegeObjectiveAssetsForTeam(SIEGETEAM_TEAM2);

	return;
failure:
	siege_valid = 0;
}
コード例 #26
0
/*
===============
MainMenu_Cache
===============
*/
void MainMenu_Cache( void ) {
	s_main.bannerModel = trap_R_RegisterModel( MAIN_BANNER_MODEL );
}
コード例 #27
0
ファイル: cg_main.c プロジェクト: asl97/ZEQ2-Lite-1
/*
=================
CG_RegisterGraphics

This function may execute for a couple of minutes with a slow disk.
=================
*/
static void CG_RegisterGraphics( void ) {
	int			i;
	static char		*sb_nums[11] = {
		"interface/fonts/numbers/0",
		"interface/fonts/numbers/1",
		"interface/fonts/numbers/2",
		"interface/fonts/numbers/3",
		"interface/fonts/numbers/4",
		"interface/fonts/numbers/5",
		"interface/fonts/numbers/6",
		"interface/fonts/numbers/7",
		"interface/fonts/numbers/8",
		"interface/fonts/numbers/9",
		"interface/fonts/numbers/-",
	};

	// clear any references to old media
	memset( &cg.refdef, 0, sizeof( cg.refdef ) );
	trap_R_ClearScene();

	CG_LoadingString( cgs.mapname );

	trap_R_LoadWorldMap( cgs.mapname );
	CG_LoadingString( "game media" );

	for ( i=0 ; i<11 ; i++) {
		cgs.media.numberShaders[i] = trap_R_RegisterShader( sb_nums[i] );
	}

	cgs.media.waterBubbleLargeShader = trap_R_RegisterShader( "waterBubbleLarge" );
	cgs.media.waterBubbleMediumShader = trap_R_RegisterShader( "waterBubbleMedium" );
	cgs.media.waterBubbleSmallShader = trap_R_RegisterShader( "waterBubbleSmall" );
	cgs.media.waterBubbleTinyShader = trap_R_RegisterShader( "waterBubbleTiny" );
	cgs.media.selectShader = trap_R_RegisterShader( "interface/hud/select.png" );
	cgs.media.chatBubble = trap_R_RegisterShader( "chatBubble");

	for ( i = 0 ; i < NUM_CROSSHAIRS ; i++ ) {
		cgs.media.crosshairShader[i] = trap_R_RegisterShader( va("crosshair%c", 'a'+i) );
	}
	cgs.media.speedLineShader = trap_R_RegisterShaderNoMip("speedLines");
	cgs.media.speedLineSpinShader = trap_R_RegisterShaderNoMip("speedLinesSpin");
	cgs.media.globalCelLighting = trap_R_RegisterShader("GlobalCelLighting");
	cgs.media.waterSplashSkin = trap_R_RegisterSkin( "effects/water/waterSplash.skin" );
	cgs.media.waterSplashModel = trap_R_RegisterModel( "effects/water/waterSplash.md3" );
	cgs.media.waterRippleSkin = trap_R_RegisterSkin( "effects/water/waterRipple.skin" );
	cgs.media.waterRippleModel = trap_R_RegisterModel( "effects/water/waterRipple.md3" );
	cgs.media.waterRippleSingleSkin = trap_R_RegisterSkin( "effects/water/waterRippleSingle.skin" );
	cgs.media.waterRippleSingleModel = trap_R_RegisterModel( "effects/water/waterRippleSingle.md3" );
	cgs.media.meleeSpeedEffectShader = trap_R_RegisterShader( "skills/energyBlast" );
	cgs.media.meleePowerEffectShader = trap_R_RegisterShader( "shockwave" );
	cgs.media.teleportEffectShader = trap_R_RegisterShader( "teleportEffect" );
	cgs.media.boltEffectShader = trap_R_RegisterShader( "boltEffect" );
	cgs.media.auraLightningSparks1 = trap_R_RegisterShader( "AuraLightningSparks1" );
	cgs.media.auraLightningSparks2 = trap_R_RegisterShader( "AuraLightningSparks2" );
	cgs.media.powerStruggleRaysEffectShader = trap_R_RegisterShader( "PowerStruggleRays" );
	cgs.media.powerStruggleShockwaveEffectShader = trap_R_RegisterShader( "PowerStruggleShockwave" );
	cgs.media.bfgLFGlare = trap_R_RegisterShader("bfgLFGlare");
	cgs.media.bfgLFDisc = trap_R_RegisterShader("bfgLFDisc");
	cgs.media.bfgLFRing = trap_R_RegisterShader("bfgLFRing");
	cgs.media.bfgLFStar = trap_R_RegisterShader("bfgLFStar");
	cgs.media.bfgLFLine = trap_R_RegisterShader("bfgLFLine");

	memset( cg_weapons, 0, sizeof( cg_weapons ) );

	cgs.media.wakeMarkShader = trap_R_RegisterShader( "wake" );
	cgs.media.dirtPushShader = trap_R_RegisterShader( "DirtPush" );
	cgs.media.dirtPushSkin = trap_R_RegisterSkin( "effects/shockwave/dirtPush.skin" );
	cgs.media.dirtPushModel = trap_R_RegisterModel( "effects/shockwave/dirtPush.md3" );

	cgs.media.hudShader = trap_R_RegisterShaderNoMip( "interface/hud/main.png" );
	cgs.media.chatBackgroundShader = trap_R_RegisterShaderNoMip("chatBox");
	cgs.media.markerAscendShader = trap_R_RegisterShaderNoMip( "interface/hud/markerAscend.png" );
	cgs.media.markerDescendShader = trap_R_RegisterShaderNoMip( "interface/hud/markerDescend.png" );
	cgs.media.breakLimitShader = trap_R_RegisterShaderNoMip( "breakLimit" );
	cgs.media.RadarBlipShader = trap_R_RegisterShaderNoMip( "interface/sense/blip.png" );
	cgs.media.RadarBlipTeamShader = trap_R_RegisterShaderNoMip( "interface/sense/blipteam.png" );
	cgs.media.RadarBurstShader = trap_R_RegisterShaderNoMip( "interface/sense/burst.png" );
	cgs.media.RadarWarningShader = trap_R_RegisterShaderNoMip( "interface/sense/warning.png" );
	cgs.media.RadarMidpointShader = trap_R_RegisterShaderNoMip( "interface/sense/midpoint.png" );
	// END ADDING

	// register the inline models
	cgs.numInlineModels = trap_CM_NumInlineModels();
	for ( i = 1 ; i < cgs.numInlineModels ; i++ ) {
		char	name[10];
		vec3_t			mins, maxs;
		int				j;

		Com_sprintf( name, sizeof(name), "*%i", i );
		cgs.inlineDrawModel[i] = trap_R_RegisterModel( name );
		trap_R_ModelBounds( cgs.inlineDrawModel[i], mins, maxs, 0 );
		for ( j = 0 ; j < 3 ; j++ ) {
			cgs.inlineModelMidpoints[i][j] = mins[j] + 0.5 * ( maxs[j] - mins[j] );
		}
	}

	// register all the server specified models
	for (i=1 ; i<MAX_MODELS ; i++) {
		const char		*modelName;

		modelName = CG_ConfigString( CS_MODELS+i );
		if ( !modelName[0] ) {
			break;
		}
		cgs.gameModels[i] = trap_R_RegisterModel( modelName );
	}
	CG_ClearParticles ();
}
コード例 #28
0
/*
==========================
UI_RegisterPlayerModelname
==========================
*/
qboolean UI_RegisterPlayerModelname( uiPlayerInfo_t *pi, const char *modelSkinName, const char *headModelSkinName, const char *teamName ) {
	char		modelName[MAX_QPATH];
	char		skinName[MAX_QPATH];
	char		headModelName[MAX_QPATH];
	char		headSkinName[MAX_QPATH];
	char		filename[MAX_QPATH];
	char		*slash;

	pi->torsoModel = 0;
	pi->headModel = 0;

	if ( !modelSkinName[0] ) {
		return qfalse;
	}

	Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) );

	slash = strchr( modelName, '/' );
	if ( !slash ) {
		// modelName did not include a skin name
		Q_strncpyz( skinName, "default", sizeof( skinName ) );
	} else {
		Q_strncpyz( skinName, slash + 1, sizeof( skinName ) );
		*slash = '\0';
	}

	Q_strncpyz( headModelName, headModelSkinName, sizeof( headModelName ) );
	slash = strchr( headModelName, '/' );
	if ( !slash ) {
		// modelName did not include a skin name
		Q_strncpyz( headSkinName, "default", sizeof( skinName ) );
	} else {
		Q_strncpyz( headSkinName, slash + 1, sizeof( skinName ) );
		*slash = '\0';
	}

#ifdef IOQ3ZTM // BLANK_HEADMODEL
	if (!headModelName[0]) {
		Q_strncpyz( headModelName, modelName, sizeof( headModelName ) );
	}
#endif

	// load cmodels before models so filecache works

	Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
	pi->legsModel = trap_R_RegisterModel( filename );
	if ( !pi->legsModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

	Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
	pi->torsoModel = trap_R_RegisterModel( filename );
	if ( !pi->torsoModel ) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

	if (headModelName[0] == '*' ) {
		Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", &headModelName[1], &headModelName[1] );
	}
	else {
		Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", headModelName );
	}
	pi->headModel = trap_R_RegisterModel( filename );
	if ( !pi->headModel && headModelName[0] != '*') {
		Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", headModelName, headModelName );
		pi->headModel = trap_R_RegisterModel( filename );
	}

	if (!pi->headModel) {
		Com_Printf( "Failed to load model file %s\n", filename );
		return qfalse;
	}

	// if any skins failed to load, fall back to default
	if ( !UI_RegisterPlayerSkin( pi, modelName, skinName, headModelName, headSkinName, teamName) ) {
		if ( !UI_RegisterPlayerSkin( pi, modelName, "default", headModelName, "default", teamName ) ) {
			Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
			return qfalse;
		}
	}

	// load the animations
#ifdef TA_PLAYERSYS
	return BG_LoadPlayerCFGFile(&pi->playercfg, modelName, headModelName);
#else
	Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
	if ( !UI_ParseAnimationFile( filename, pi->animations ) ) {
		Com_Printf( "Failed to load animation file %s\n", filename );
		return qfalse;
	}

	return qtrue;
#endif
}
コード例 #29
0
ファイル: cg_servercmds.c プロジェクト: SinSiXX/Rogue-Reborn
/*
================
CG_ConfigStringModified

================
*/
static void CG_ConfigStringModified(void)
{
	const char     *str;
	int             num;

	num = atoi(CG_Argv(1));

	// get the gamestate from the client system, which will have the
	// new configstring already integrated
	trap_GetGameState(&cgs.gameState);

	// look up the individual string that was modified
	str = CG_ConfigString(num);

	// do something with it if necessary
	if(num == CS_MUSIC)
	{
		CG_StartMusic();
	}
	else if(num == CS_SERVERINFO)
	{
		CG_ParseServerinfo();
	}
	else if(num == CS_WARMUP)
	{
		CG_ParseWarmup();
	}
	else if(num == CS_SCORES1)
	{
		cgs.scores1 = atoi(str);
	}
	else if(num == CS_SCORES2)
	{
		cgs.scores2 = atoi(str);
	}
	else if(num == CS_LEVEL_START_TIME)
	{
		cgs.levelStartTime = atoi(str);
	}
	else if(num == CS_VOTE_TIME)
	{
		cgs.voteTime = atoi(str);
		cgs.voteModified = qtrue;
	}
	else if(num == CS_VOTE_YES)
	{
		cgs.voteYes = atoi(str);
		cgs.voteModified = qtrue;
	}
	else if(num == CS_VOTE_NO)
	{
		cgs.voteNo = atoi(str);
		cgs.voteModified = qtrue;
	}
	else if(num == CS_VOTE_STRING)
	{
		Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString));

		trap_S_StartLocalSound(cgs.media.voteNow, CHAN_ANNOUNCER);
	}
	else if(num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1)
	{
		cgs.teamVoteTime[num - CS_TEAMVOTE_TIME] = atoi(str);
		cgs.teamVoteModified[num - CS_TEAMVOTE_TIME] = qtrue;
	}
	else if(num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1)
	{
		cgs.teamVoteYes[num - CS_TEAMVOTE_YES] = atoi(str);
		cgs.teamVoteModified[num - CS_TEAMVOTE_YES] = qtrue;
	}
	else if(num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1)
	{
		cgs.teamVoteNo[num - CS_TEAMVOTE_NO] = atoi(str);
		cgs.teamVoteModified[num - CS_TEAMVOTE_NO] = qtrue;
	}
	else if(num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1)
	{
		Q_strncpyz(cgs.teamVoteString[num - CS_TEAMVOTE_STRING], str, sizeof(cgs.teamVoteString));

		trap_S_StartLocalSound(cgs.media.voteNow, CHAN_ANNOUNCER);
	}
	else if(num == CS_INTERMISSION)
	{
		cg.intermissionStarted = atoi(str);
	}
	else if(num >= CS_MODELS && num < CS_MODELS + MAX_MODELS)
	{
		cgs.gameModels[num - CS_MODELS] = trap_R_RegisterModel(str, qtrue);
	}
	else if(num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS)
	{
		if(str[0] != '*')
		{
			// player specific sounds don't register here
			cgs.gameSounds[num - CS_SOUNDS] = trap_S_RegisterSound(str);
		}
	}
	else if(num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS)
	{
		CG_NewClientInfo(num - CS_PLAYERS);
		CG_BuildSpectatorString();
	}
	else if(num == CS_FLAGSTATUS)
	{
		if(cgs.gametype == GT_CTF)
		{
			// format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped
			cgs.redflag = str[0] - '0';
			cgs.blueflag = str[1] - '0';
		}
		else if(cgs.gametype == GT_1FCTF)
		{
			cgs.flagStatus = str[0] - '0';
		}
	}
	else if(num == CS_SHADERSTATE)
	{
		CG_ShaderStateChanged();
	}

}
コード例 #30
0
ファイル: cg_servercmds.c プロジェクト: baseas/aftershock
static void CG_ConfigStringModified(void)
{
	const char	*str;
	int		num;

	num = atoi(BG_Argv(1));

	// get the gamestate from the client system, which will have the
	// new configstring already integrated
	trap_GetGameState(&cgs.gameState);

	// look up the individual string that was modified
	str = CG_ConfigString(num);

	// do something with it if necessary
	if (num == CS_SERVERINFO) {
		CG_ParseServerinfo();
	} else if (num == CS_WARMUP) {
		CG_SetWarmup(atoi(str));
	} else if (num == CS_SCORES1) {
		cgs.scores1 = atoi(str);
	} else if (num == CS_SCORES2) {
		cgs.scores2 = atoi(str);
	} else if (num == CS_LEVEL_START_TIME) {
		cgs.levelStartTime = atoi(str);
	} else if (num == CS_VOTE_TIME) {
		if (!strcmp(str, "failed")) {
			cgs.voteTime = 0;
			CG_Printf("Vote failed.\n");
			CG_AddBufferedSound(cgs.media.voteFailed);
		} else if (!strcmp(str, "passed")) {
			cgs.voteTime = 0;
			CG_Printf("Vote passed.\n");
			CG_AddBufferedSound(cgs.media.votePassed);
		} else if (*str) {
			cgs.voteTime = atoi(str);
			CG_Printf("Vote cast.\n");
			CG_AddBufferedSound(cgs.media.voteNow);
		}
	} else if (num == CS_VOTE_YES) {
		cgs.voteYes = atoi(str);
		trap_S_StartLocalSound(cgs.media.talkSound, CHAN_LOCAL_SOUND);
	} else if (num == CS_VOTE_NO) {
		cgs.voteNo = atoi(str);
		trap_S_StartLocalSound(cgs.media.talkSound, CHAN_LOCAL_SOUND);
	} else if (num == CS_VOTE_STRING) {
		Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString));
	} else if (num == CS_INTERMISSION) {
		cg.intermissionStarted = atoi(str);
	} else if (num >= CS_MODELS && num < CS_MODELS+MAX_MODELS) {
		cgs.gameModels[num-CS_MODELS] = trap_R_RegisterModel(str);
	} else if (num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS) {
		if (str[0] != '*') {	// player specific sounds don't register here
			cgs.gameSounds[num-CS_SOUNDS] = trap_S_RegisterSound(str, qfalse);
		}
	} else if (num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS) {
		CG_NewClientInfo(num - CS_PLAYERS);
	} else if (num == CS_FLAGSTATUS) {
		// format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped
		if (cgs.gametype == GT_CTF) {
			team_t	team;
			team = cgs.clientinfo[cg.clientNum].team;
			if ((cgs.redflag == 1 && str[0] - '0' == 2 && team == TEAM_RED)
				|| (cgs.blueflag == 1 && str[1] - '0' == 2 && team == TEAM_BLUE))
			{
				CG_CenterPrint("^2The enemy dropped your flag");
			} else if ((cgs.redflag == 1 && str[0] - '0' == 2 && team == TEAM_BLUE)
				|| (cgs.blueflag == 1 && str[1] - '0' == 2 && team == TEAM_RED))
			{
				CG_CenterPrint("^1You team dropped the flag");
			}

			cgs.redflag = str[0] - '0';
			cgs.blueflag = str[1] - '0';
		}
	} else if (num == CS_SHADERSTATE) {
		CG_ShaderStateChanged();
	} else if (num == CS_ROUND_START) {
		cg.countdownCount = -1;
		cgs.roundStartTime = atoi(str);
	} else if (num == CS_LIVING_COUNT) {
		int		newRed, newBlue;

		newRed = atoi(COM_Parse((char **) &str));
		newBlue = atoi(COM_Parse((char **) &str));

		if (!cgs.warmup && cg.time >= cgs.roundStartTime) {
			team_t	team;
			team = cg.snap->ps.persistant[PERS_TEAM];
			if ((newRed == 1 && cgs.redLivingCount != 1 && team == TEAM_RED)
				|| (newBlue == 1 && cgs.blueLivingCount != 1 && team == TEAM_BLUE))
			{
				CG_CenterPrint("You are the last in your team");
			}
		}

		cgs.redLivingCount = newRed;
		cgs.blueLivingCount = newBlue;
	} else if (num == CS_OVERTIME) {
		cgs.overtimeStart = atoi(str);
		trap_S_StartLocalSound(cgs.media.protectSound, CHAN_ANNOUNCER);
		CG_CenterPrint(va("^3OVERTIME^7 - %d seconds added", cgs.overtimeLimit));
	} else if (num >= CS_RESPAWN_TIMERS && num < CS_RESPAWN_TIMERS + MAX_RESPAWN_TIMERS) {
		CG_ParseRespawnTimer(num - CS_RESPAWN_TIMERS, str);
	} else if (num == CS_PAUSE_START) {
		cgs.pauseStart = atoi(str);
		if (cgs.pauseStart > 0) {
			trap_S_StartLocalSound(cgs.media.pauseSound, CHAN_LOCAL_SOUND);
		}
	} else if (num == CS_PAUSE_END) {
		cg.countdownCount = -1;
		cgs.pauseEnd = atoi(str);
	} else if (num == CS_PAUSE_TIME) {
		cgs.pauseTime = atoi(str);
	}
}