Limiting weapons per team.


(NewName) #1

Hi, I have been working on the code and trying to limit the weapons per team, however it’s a long route. I’m quite sure there’s another way of doing so, but ETMAIN has no LUA support, which is the only other method of which I know.

Question, what’s the easiest method of removing weapons from a team.

I’ve been using g_client.c for weapon modifications.

switch( client->sess.sessionTeam ) {
			case TEAM_AXIS:
				switch( pc ) {
					case PC_SOLDIER:
						if( client->sess.skill[SK_HEAVY_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_MP40 ) {
					//		AddWeaponToPlayer( client, WP_MP40, 2*(GetAmmoTableData(WP_MP40)->defaultStartingAmmo), GetAmmoTableData(WP_MP40)->defaultStartingClip, qtrue );
						} else if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_AKIMBO_LUGER ) {
						//	client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_LUGER))] = GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip;
						//	AddWeaponToPlayer( client, WP_AKIMBO_LUGER, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip, qfalse );
						} else {
					//		AddWeaponToPlayer( client, WP_LUGER, GetAmmoTableData(WP_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_LUGER)->defaultStartingClip, qfalse );
						}
						break;

					case PC_COVERTOPS:
						if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && ( client->sess.playerWeapon2 == WP_AKIMBO_SILENCEDLUGER || client->sess.playerWeapon2 == WP_AKIMBO_LUGER ) ) {
					//		client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_SILENCEDLUGER))] = GetAmmoTableData(WP_AKIMBO_SILENCEDLUGER)->defaultStartingClip;
					//		AddWeaponToPlayer( client, WP_AKIMBO_SILENCEDLUGER, GetAmmoTableData(WP_AKIMBO_SILENCEDLUGER)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_SILENCEDLUGER)->defaultStartingClip, qfalse );
						} else {
						//	AddWeaponToPlayer( client, WP_LUGER, GetAmmoTableData(WP_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_LUGER)->defaultStartingClip, qfalse );
						//	AddWeaponToPlayer( client, WP_SILENCER, GetAmmoTableData(WP_SILENCER)->defaultStartingAmmo, GetAmmoTableData(WP_SILENCER)->defaultStartingClip, qfalse );
						//	client->pmext.silencedSideArm = 1;
						}
						break;

					default:
						if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_AKIMBO_LUGER ) {
						//	client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_LUGER))] = GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip;
						//	AddWeaponToPlayer( client, WP_AKIMBO_LUGER, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip, qfalse );
						} else {
						//	AddWeaponToPlayer( client, WP_LUGER, GetAmmoTableData(WP_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_LUGER)->defaultStartingClip, qfalse );
						}
						break;
				}
				break;
			default:

Commented out weapons, but this is a tedious way and it seems that weapons are muddled up between Axis and Allied.

What’s the easiest way to remove ALL Axis weapons from ALL classes but still keep the knife.

AddWeaponToPlayer( client, WP_KNIFE, 1, 0, qtrue );

I’m quite sure my method is the long route and a simple edit would do the job.

I’ve also removed the weaponcard (where it shows the weapons to choose in limbo).

Anyone got a better idea, as this way is confusing and sometimes has adverse effects, like removing the sten removes it from both teams. I’m most likely missing something, but I can’t see where.

For testing: g_client.c - look for

/*
===========
SetWolfSpawnWeapons
===========
*/

Thanks a lot!


(Indloon) #2

Oh you!
Remove all that crap there,so the function could look like this:


void SetWolfSpawnWeapons( gclient_t *client ) 
{
	if ( client->sess.sessionTeam == TEAM_SPECTATOR )
		return;

	// Reset special weapon time
	client->ps.classWeaponTime = -999999;

	// JPW NERVE -- zero out all ammo counts
	memset(client->ps.ammo, 0, MAX_WEAPONS * sizeof(int));

	// All players start with a knife (not OR-ing so that it clears previous weapons)
	client->ps.weapons[0] = 0;
	client->ps.weapons[1] = 0;

	AddWeaponToPlayer( client, WP_KNIFE, 1, 0, qtrue );

	client->ps.weaponstate = WEAPON_READY;
}


(NewName) #3

Hi Indloon, surely this would remove the weapons from ALL teams right? I’m only needing to remove from Axis.

Thanks a lot :slight_smile:


(Indloon) #4

void SetWolfSpawnWeapons( gclient_t *client ) {
    int		pc = client->sess.playerType;
	if ( client->sess.sessionTeam == TEAM_SPECTATOR )
		return;

	client->ps.classWeaponTime = -999999;
	client->ps.stats[STAT_PLAYER_CLASS] = pc;
	client->ps.teamNum = pc;

	memset(client->ps.ammo, 0, MAX_WEAPONS * sizeof(int));
	client->ps.weapons[0] = 0;
	client->ps.weapons[1] = 0;

	AddWeaponToPlayer( client, WP_KNIFE, 1, 0, qtrue );

	client->ps.weaponstate = WEAPON_READY;
	
	switch(client->sess.sessionTeam) {
	    case TEAM_AXIS:
		    AddWeaponToPlayer( client, WP_MEDIC_ADRENALINE, GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingAmmo, GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingClip, qfalse );
		    break;
		case TEAM_ALLIES:
		    switch( client->sess.playerWeapon ) {
			        default:
					case WP_THOMPSON:
						AddWeaponToPlayer( client, WP_THOMPSON, 2*(GetAmmoTableData(WP_THOMPSON)->defaultStartingAmmo), GetAmmoTableData(WP_THOMPSON)->defaultStartingClip, qtrue );
						break;
					case WP_PANZERFAUST:
						AddWeaponToPlayer( client, WP_PANZERFAUST, GetAmmoTableData(WP_PANZERFAUST)->defaultStartingAmmo, GetAmmoTableData(WP_PANZERFAUST)->defaultStartingClip, qtrue );
						break;
					case WP_FLAMETHROWER:
						AddWeaponToPlayer( client, WP_FLAMETHROWER, GetAmmoTableData(WP_FLAMETHROWER)->defaultStartingAmmo, GetAmmoTableData(WP_FLAMETHROWER)->defaultStartingClip, qtrue );
						break;
					case WP_MOBILE_MG42:
						if( AddWeaponToPlayer( client, WP_MOBILE_MG42, GetAmmoTableData(WP_MOBILE_MG42)->defaultStartingAmmo, GetAmmoTableData(WP_MOBILE_MG42)->defaultStartingClip, qtrue ) ) {
							AddWeaponToPlayer( client, WP_MOBILE_MG42_SET, GetAmmoTableData(WP_MOBILE_MG42_SET)->defaultStartingAmmo, GetAmmoTableData(WP_MOBILE_MG42_SET)->defaultStartingClip, qfalse );
						}
						break;
					case WP_MORTAR:
						if( AddWeaponToPlayer( client, WP_MORTAR, GetAmmoTableData(WP_MORTAR)->defaultStartingAmmo, GetAmmoTableData(WP_MORTAR)->defaultStartingClip, qtrue ) ) {
							AddWeaponToPlayer( client, WP_MORTAR_SET, GetAmmoTableData(WP_MORTAR_SET)->defaultStartingAmmo, GetAmmoTableData(WP_MORTAR_SET)->defaultStartingClip, qfalse );
						}
						break;
					case WP_CARBINE:
					    if( AddWeaponToPlayer( client, WP_CARBINE, GetAmmoTableData(WP_CARBINE)->defaultStartingAmmo, GetAmmoTableData(WP_CARBINE)->defaultStartingClip, qtrue ) ) {
						    AddWeaponToPlayer( client, WP_M7, GetAmmoTableData(WP_M7)->defaultStartingAmmo, GetAmmoTableData(WP_M7)->defaultStartingClip, qfalse );
					    }
					    break;
					case WP_K43:
			        case WP_GARAND:
					    if( AddWeaponToPlayer( client, WP_GARAND, GetAmmoTableData(WP_GARAND)->defaultStartingAmmo, GetAmmoTableData(WP_GARAND)->defaultStartingClip, qtrue ) ) {
						    AddWeaponToPlayer( client, WP_GARAND_SCOPE, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingClip, qfalse );
					    }
					    break;
			        case WP_FG42:
				        if( AddWeaponToPlayer( client, WP_FG42, GetAmmoTableData(WP_FG42)->defaultStartingAmmo, GetAmmoTableData(WP_FG42)->defaultStartingClip, qtrue ) ) {
					        AddWeaponToPlayer( client, WP_FG42SCOPE, GetAmmoTableData(WP_FG42SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_FG42SCOPE)->defaultStartingClip, qfalse );
				        }
				        break;
	        }
	}
}

(Indloon) #5

You asked for that the Axis has only knife and Allied team all,so


void SetWolfSpawnWeapons( gclient_t *client ) {
    int		pc = client->sess.playerType;
	if ( client->sess.sessionTeam == TEAM_SPECTATOR )
		return;

	client->ps.classWeaponTime = -999999;
	client->ps.stats[STAT_PLAYER_CLASS] = pc;
	client->ps.teamNum = pc;

	memset(client->ps.ammo, 0, MAX_WEAPONS * sizeof(int));
	client->ps.weapons[0] = 0;
	client->ps.weapons[1] = 0;

	AddWeaponToPlayer( client, WP_KNIFE, 1, 0, qtrue );

	client->ps.weaponstate = WEAPON_READY;
	
	switch(client->sess.sessionTeam) {
	    case TEAM_AXIS:
		    AddWeaponToPlayer( client, WP_MEDIC_ADRENALINE, GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingAmmo, GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingClip, qfalse );
		    break;
		case TEAM_ALLIES:
		    for(i=0;i<WP_NUM_WEAPONS;i++) {
			    if ( BG_WeaponInWolfMP(i) )
				    COM_BitSet( ent->client->ps.weapons, i );
		    }
	}
}

COM_BitSet should work here,since we are still at the game side :smiley:


(NewName) #6

I think I tried the COM_BitSet before this Indloon :(.

Doesn’t compile, can’t even see the error. Something wrong with your code? Mine is also not compiling :(.


(Indloon) #7

[QUOTE=iDan;393980]I think I tried the COM_BitSet before this Indloon :(.

Doesn’t compile, can’t even see the error. Something wrong with your code? Mine is also not compiling :(.[/QUOTE]

Hm,thats weird.the COM_BitSet is from Cmd_Give_f code.
Well,as I can understand,the weapon names are dynamiclly defined as numbers,so


for(i=0;i<WP_NUM_WEAPONS;i++) {
			AddWeaponToPlayer( client, i+1, GetAmmoTableData(i+1)->defaultStartingAmmo, GetAmmoTableData(i+1)->defaultStartingClip, qtrue );
		}

If that doesn’t work,then yeah,lets add weapons by name :frowning:

EDIT:


	for( i = WP_KNIFE; i < WP_NUM_WEAPONS; i++ ) {
		if( BG_WeaponInWolfMP( i ) )
			AddWeaponToPlayer( client, i, GetAmmoTableData(i)->defaultStartingAmmo, GetAmmoTableData(i)->defaultStartingClip, qtrue );
	}