[code] Instagib


(bacon) #1

This is the code I used in my mod for instagib.

g_main.c
Find:

vmCvar_t		g_disableComplaints;

Below Add:

vmCvar_t		b_instagib;

Find:

{ &g_disableComplaints, "g_disableComplaints", "0", CVAR_ARCHIVE },

Below Add:

{ &b_instagib, "b_instagib", "0", CVAR_SERVERINFO | 0, 0, qtrue, qtrue },

g_local.h
Find:

extern vmCvar_t		g_disableComplaints;

Below Add:

extern vmCvar_t		b_instagib;

g_client.c
Tell the server what weapons we want players to spawn with when in instagib mode.
Find:

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

	client->ps.weaponstate = WEAPON_READY;

Replace with:


	// players don't get a knife in instagib
	if (b_instagib.integer == 0)
		AddWeaponToPlayer( client, WP_KNIFE, 1, 0, qtrue );

	client->ps.weaponstate = WEAPON_READY;

	if (b_instagib.integer == 0) {

Find:

if ( g_knifeonly.integer != 1 ) {

Replace With:

if ( g_knifeonly.integer != 1 && b_instagib.integer == 0) {

Find:

if( pc == PC_COVERTOPS ) {
			if( client->sess.sessionTeam == TEAM_AXIS ) {
				AddWeaponToPlayer( client, WP_GRENADE_LAUNCHER,  0, 2, qfalse );
			} else {
				AddWeaponToPlayer( client, WP_GRENADE_PINEAPPLE, 0, 2, qfalse );
			}
		}

Below Add:

} else if (g_knifeonly.integer != 1 && b_instagib.integer != 0) {
		// UPDATE: if instagib is set to 1 give everybody the K43 & scope, otherwise give them
		// the proper team weapon
		if (b_instagib.integer == 1|| (b_instagib.integer == 2 && client->sess.sessionTeam == TEAM_AXIS)) {
			AddWeaponToPlayer( client, WP_K43, 999, GetAmmoTableData(WP_K43)->defaultStartingClip, qtrue);
			AddWeaponToPlayer( client, WP_K43_SCOPE, 999, GetAmmoTableData(WP_K43_SCOPE)->defaultStartingClip, qfalse);
		} else if (b_instagib.integer == 2 && client->sess.sessionTeam == TEAM_ALLIES) {
			AddWeaponToPlayer( client, WP_GARAND, 999, GetAmmoTableData(WP_GARAND)->defaultStartingClip, qtrue);
			AddWeaponToPlayer( client, WP_GARAND_SCOPE, 999, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingClip, qfalse);
		}

		// Engineer gets dynamite
		if ( pc == PC_ENGINEER ) {
			AddWeaponToPlayer( client, WP_DYNAMITE, 0, 1, qfalse);
			AddWeaponToPlayer( client, WP_PLIERS, 0, 1, qfalse);
		//Covert Ops gets satchel charge
		} else if ( pc == PC_COVERTOPS ) {
			// see if we already have a satchel charge place - NOTE: maybe we want to change so the thing voids on death
			if ( G_FindSatchel( &g_entities[client->ps.clientNum] ) ) {
				AddWeaponToPlayer( client, WP_SATCHEL, 0, 0, qfalse );		// Big Bang \o/
				AddWeaponToPlayer( client, WP_SATCHEL_DET, 0, 1, qfalse);	// Big Red Button for tha Big Bang
			} else {
				AddWeaponToPlayer( client, WP_SATCHEL, 0, 1, qfalse );		// Big Bang \o/
				AddWeaponToPlayer( client, WP_SATCHEL_DET, 0, 0, qfalse);	// Big Red Button for tha Big Bang
			}
		}

You have to throw on another } at the end of the trailing else statement.

g_cmds.c
This will prevent players from entering tanks, since tank weapon do 0 damage it’s pointless to let them use it.
Find:

if( G_TankIsOccupied( ent ) ) {
		return qfalse;
	}

Below Add:

// bacon - do not allow anybody in the tank when in instagib!
	if ( b_instagib.integer != 0 ) {
		return qfalse;
	}

g_misc.c
Don’t spawn MG42’s when we’re in instagib mode.
Find:

if ( g_knifeonly.integer != 1 ) {

Replace With:

if ( g_knifeonly.integer != 1 || b_instagib.integer == 0) {

g_weapon.c
We set the damage here. We want dynamite & satchel charges to keep their damage. We also want the environment to hurt the player without gibbing.
Find:

switch (weapon) {
		default:
			return 1;
		case WP_KNIFE: 
			return 10;
		case WP_STEN: 
			return 14;
		case WP_CARBINE:
		case WP_GARAND:
		case WP_KAR98:
		case WP_K43:
			return 34;
		case WP_FG42: 
			return 15;
		case WP_LUGER:
		case WP_SILENCER:
		case WP_AKIMBO_LUGER:
		case WP_AKIMBO_SILENCEDLUGER:
		case WP_COLT:
		case WP_SILENCED_COLT:
		case WP_AKIMBO_COLT:
		case WP_AKIMBO_SILENCEDCOLT: 
		case WP_THOMPSON: 
		case WP_MP40: 
		case WP_MOBILE_MG42: 
		case WP_MOBILE_MG42_SET:
			return 18;
		case WP_FG42SCOPE: 
			return 30;
		case WP_GARAND_SCOPE: 
		case WP_K43_SCOPE: 
			return 50;
		case WP_SMOKE_MARKER: 
			return 140; // just enough to kill somebody standing on it
		case WP_MAPMORTAR: 
		case WP_GRENADE_LAUNCHER: 
		case WP_GRENADE_PINEAPPLE: 
		case WP_GPG40:
		case WP_M7: 
		case WP_LANDMINE: 
		case WP_SATCHEL:
			return 250;
		case WP_TRIPMINE: 
			return 300;
		case WP_PANZERFAUST: 
		case WP_MORTAR_SET: 
		case WP_DYNAMITE: 
			return 400;
	}

Replace With:

if (b_instagib.integer != 0) {
		switch (weapon) {
			case WP_K43:
			case WP_KAR98:
			case WP_K43_SCOPE:
			case WP_CARBINE:
			case WP_GARAND:
			case WP_GARAND_SCOPE:
				return 300;
			case WP_DYNAMITE:
				return 400;
			case WP_SATCHEL:
				return 250;
			case WP_KNIFE:
			case WP_STEN:
			case WP_LUGER:
			case WP_SILENCER:
			case WP_AKIMBO_LUGER:
			case WP_AKIMBO_SILENCEDLUGER:
			case WP_COLT:
			case WP_SILENCED_COLT:
			case WP_AKIMBO_COLT:
			case WP_AKIMBO_SILENCEDCOLT:
			case WP_THOMPSON:
			case WP_MP40:
			case WP_MOBILE_MG42:
			case WP_MOBILE_MG42_SET:
			case WP_FG42SCOPE:
			case WP_FG42:
			case WP_SMOKE_MARKER:
			case WP_MAPMORTAR: 
			case WP_GRENADE_LAUNCHER: 
			case WP_GRENADE_PINEAPPLE: 
			case WP_GPG40:
			case WP_M7: 
			case WP_LANDMINE: 
			case WP_PANZERFAUST: 
			case WP_MORTAR_SET:
			case WP_TRIPMINE:
			case WP_KILL_SYRINGE:
				return 0;
			default:
				return 0;
		}
	} else {
		switch (weapon) {
			default:
				return 1;
			case WP_KNIFE: 
				return 10;
			case WP_STEN: 
				return 14;
			case WP_CARBINE:
			case WP_GARAND:
			case WP_KAR98:
			case WP_K43:
				return 34;
			case WP_FG42: 
				return 15;
			case WP_LUGER:
			case WP_SILENCER:
			case WP_AKIMBO_LUGER:
			case WP_AKIMBO_SILENCEDLUGER:
			case WP_COLT:
			case WP_SILENCED_COLT:
			case WP_AKIMBO_COLT:
			case WP_AKIMBO_SILENCEDCOLT: 
			case WP_THOMPSON: 
			case WP_MP40: 
			case WP_MOBILE_MG42: 
			case WP_MOBILE_MG42_SET:
				return 18;
			case WP_FG42SCOPE: 
				return 30;
			case WP_GARAND_SCOPE: 
			case WP_K43_SCOPE: 
				return 50;
			case WP_SMOKE_MARKER: 
				return 140; // just enough to kill somebody standing on it
			case WP_MAPMORTAR: 
			case WP_GRENADE_LAUNCHER: 
			case WP_GRENADE_PINEAPPLE: 
			case WP_GPG40:
			case WP_M7: 
			case WP_LANDMINE: 
			case WP_SATCHEL:
				return 250;
			case WP_TRIPMINE: 
				return 300;
			case WP_PANZERFAUST: 
			case WP_MORTAR_SET: 
			case WP_DYNAMITE: 
				return 400;
			case WP_KILL_SYRINGE:
				return 200;
		}
	}

And that’s it! Wasn’t it easy?


(jamez) #2

wow nice work

do u know of any servers with instagib on yet?


(SCDS_reyalP) #3

Nice.
One comment… context diffs are good :moo:


(Ramoonus) #4

wicked
ths for sharing the code


(MessiaH) #5

Your code in weapon.c has some serious parsing problems, can’t compile.


(MessiaH) #6

Big problem, I was able to compile, but all players spawn with no weapons… =/