Jump to content

Adding weapons with Skill


sCenna.

Recommended Posts

Tutorial: Become a new Weapons when u reach Medic Skill Level 4 and/or Engi Skill Level 4:
(Etpub 0.91 / Chaos 0.1.5)

File: cgame/cg_limbopanel.c

In:
void CG_LimboPanel_WeaponPanel( panel_button_t* button ) {
Search:
	// render in expanded mode ^
	for( i = 0, x = 1; i < cnt; i++ ) {
		weapon_t cycleWeap = CG_LimboPanel_GetWeaponForNumber( i, cgs.ccSelectedWeaponNumber, qtrue );
		if( cycleWeap != weap ) {
			CG_LimboPanel_WeaponPanel_DrawWeapon( &rect, cycleWeap, qtrue, va( "%iof%i", i+1, cnt ), CG_LimboPanel_RealWeaponIsDisabled( cycleWeap ) );

			if( BG_CursorInRect( &rect ) ) {
				if( button->data[7] != x ) {
					SOUND_FOCUS;

					button->data[7] = x;
				}
			}

			rect.y -= rect.h;
			x++;
		}
	}

Change it with:
	// render in expanded mode ^
	for( i = 0, x = 1; i < cnt; i++ ) {
		weapon_t cycleWeap = CG_LimboPanel_GetWeaponForNumber( i, cgs.ccSelectedWeaponNumber, qtrue );
		if( cycleWeap != weap && (
			cycleWeap != WP_SHOTGUN || cycleWeap != WP_PPS43 || 
			cgs.clientinfo[cg.clientNum].skill[sK_EXPLOSIVES_AND_CONSTRUCTION] >= 5 ||
			cgs.clientinfo[cg.clientNum].skill[sK_FIRST_AID] >= 5)) {

			CG_LimboPanel_WeaponPanel_DrawWeapon( &rect, cycleWeap, qtrue, va( "%iof%i", i+1, cnt ), CG_LimboPanel_RealWeaponIsDisabled( cycleWeap ) );

			if( BG_CursorInRect( &rect ) ) {
				if( button->data[7] != x ) {
					SOUND_FOCUS;

					button->data[7] = x;
				}
			}

			rect.y -= rect.h;
			x++;
		}
	}
...

Search:
int CG_LimboPanel_WeaponCount_ForSlot( int number ) {
if( number == 1 ) {
	bg_playerclass_t* classInfo = CG_LimboPanel_GetPlayerClass();
	int cnt = 0, i;

	for(i = 0; i < MAX_WEAPS_PER_CLASS; i++) {
		if( !classInfo->classWeapons[i] ) {
			break;
		}

		cnt++;
	}
	return cnt;
} else {
	if( cgs.clientinfo[cg.clientNum].skill[sK_HEAVY_WEAPONS] >= 4 && CG_LimboPanel_GetClass() == PC_SOLDIER ) {
		if( cgs.clientinfo[cg.clientNum].skill[sK_LIGHT_WEAPONS] >= 4 ) {
			return 3;
		} else {
			return 2;
		}
	} else {
		if( cgs.clientinfo[cg.clientNum].skill[sK_LIGHT_WEAPONS] >= 4 ) {
			return 2;
		} else {
			return 1;
		}
	}
}
}

Change it with:
int CG_LimboPanel_WeaponCount_ForSlot( int number ) {
if( number == 1 ) {
	bg_playerclass_t* classInfo = CG_LimboPanel_GetPlayerClass();
	int cnt = 0, i;

	for(i = 0; i < MAX_WEAPS_PER_CLASS; i++) {
		if( !classInfo->classWeapons[i] ) {
			break;
		}
		
		// dont count Shotgun if disabled
		if (classInfo->classWeapons[i] == WP_SHOTGUN && !( cgs.clientinfo[cg.clientNum].skill[sK_EXPLOSIVES_AND_CONSTRUCTION] >= 5 ))
			continue;
		if ( classInfo->classWeapons[i] == WP_PPS43 && !( cgs.clientinfo[cg.clientNum].skill[sK_FIRST_AID] >= 5 ))
			continue;
			
		cnt++;
	}
	return cnt;
} else {
	if( cgs.clientinfo[cg.clientNum].skill[sK_HEAVY_WEAPONS] >= 4 && CG_LimboPanel_GetClass() == PC_SOLDIER ) {
		if( cgs.clientinfo[cg.clientNum].skill[sK_LIGHT_WEAPONS] >= 4 ) {
			return 3;
		} else {
			return 2;
		}
	} else {
		if( cgs.clientinfo[cg.clientNum].skill[sK_LIGHT_WEAPONS] >= 4 ) {
			return 2;
		} else {
			return 1;
		}
	}
}
}

File: game/bg_classes.c
Search PC_Medic and PC_Engineer
Add then the weapon, but they must to be the last weapons!
Dont forgott to make these on Axis and Allied!!!!
{
	PC_MEDIC,
	"characters/temperate/allied/medic.char",
	"ui/assets/mp_health_blue.tga",
	"ui/assets/mp_arrow_blue.tga",
	{ 
		WP_THOMPSON,
		WP_M3A1,
		WP_PPS43 //must to be the last weapon
	},	
},

{
	PC_ENGINEER,
	"characters/temperate/allied/engineer.char",
	"ui/assets/mp_wrench_blue.tga",
	"ui/assets/mp_arrow_blue.tga",
	{ 
		WP_THOMPSON,
		WP_CARBINE,
		WP_M3A1,
		WP_BREN,
		WP_SHOTGUN //must to be the last weapon
	},	
},


File: game/g_client.c
These will fix the /class e 5 2 command
qboolean _SetMedicSpawnWeapons(gclient_t *client) 
{
weapon_t w;
weapon_t w2;
w = client->sess.latchPlayerWeapon;
if(client->sess.sessionTeam == TEAM_AXIS) {
	switch(w) {
		case WP_PPS43:
			if( client->sess.skill[sK_FIRST_AID] <= 4 ) //If Skill Level 5 reached: Allow ppsh43
				w = WP_MP40;
			break;
		case WP_MP44:
		case WP_MP40:
		case WP_M3A1:
			break;
		default:
			w = WP_MP40;
	}
	AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 1, qfalse);
	w2 = G_BestSecWeaponForClient( client );
	if( w2 == WP_AKIMBO_LUGER && 
			(g_medics.integer & MEDIC_NOAKIMBO) ) {
		w2 = WP_LUGER;
	}
}
else if(client->sess.sessionTeam == TEAM_ALLIES) {
	switch(w) {
		case WP_PPS43:
			if( client->sess.skill[sK_FIRST_AID] <= 4 ) //If Skill Level 5 reached: Allow ppsh43
				w = WP_THOMPSON;
			break;
		case WP_BAR:
		case WP_THOMPSON:
		case WP_M3A1:
			break;
		default:
			w = WP_THOMPSON;
	}
	AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 1, qfalse);	

	w2 = G_BestSecWeaponForClient( client );
	if( w2 == WP_AKIMBO_COLT && 
			(g_medics.integer & MEDIC_NOAKIMBO) ) {

....


qboolean _SetEngineerSpawnWeapons(gclient_t *client) 
{
weapon_t w = client->sess.latchPlayerWeapon;
weapon_t w2 = G_BestSecWeaponForClient( client );
if(client->sess.sessionTeam == TEAM_AXIS) {
	switch(w) {
		case WP_SHOTGUN:
			if( client->sess.skill[sK_EXPLOSIVES_AND_CONSTRUCTION] <= 4 ) //If Skill Level 5 reached: Allow Shotgun
				w = WP_MP40;
			break;
		case WP_KAR98:
		case WP_MP40:
		case WP_M3A1:
		case WP_BREN:
			break;
	default:
		w = WP_MP40;
	}
	AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 4, qfalse);	
} else if(client->sess.sessionTeam == TEAM_ALLIES) {
	switch(w) {
		case WP_SHOTGUN:
			if( client->sess.skill[sK_EXPLOSIVES_AND_CONSTRUCTION] <= 4 ) //If Skill Level 5 reached: Allow Shotgun
				w = WP_THOMPSON;
			break;
		case WP_CARBINE:
		case WP_THOMPSON:
		case WP_M3A1:
		case WP_BREN:
			break;
	default:
		w = WP_THOMPSON;
	}
	AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 4, qfalse);
} else {
	return qfalse;
}



Credits: Nq-Mod and Chaos-Mod

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...