Few coding question


(P4nth3r) #1

Hi, still working on my mod.
Got not much help yet. =(
So I’m going to try and do the small coding part on my own (know nothing about c++)
Ok, we start with the fun stuff.
I wanne replace the garand + rifle nade with a shotgun.
Now the shotgun code is in the quake3 source (don’t know what i need exactly)

What code should I replace with what code to make it work ingame? (what files too)
I looked in g_weapon.c I found some code there and I looked in bg_public.h

Can somebody tell me what code most take and what part I most replace.

Greetz Panther aka Way2Evil


(P4nth3r) #2

=(


(IneQuation) #3

That’s actually not that hard. Look in g_weapon.c for the FireWeapon. You’ll need to do several BulletFire calls instead of just one and modify the weapons stats to give it more spread and less damage. And get rid of the nades as well.


(P4nth3r) #4

Thnx Rookie One,

That is atleast, something.
Can I copy part of the shotgun code from the quake 3 source to do this ?? (as I said I don’t know shit about coding)
The damage part I figured out now.
But the spread and several BulletFire I don’t know where to change that.

Thnx & Greetz Panther aka Way2Evil


(IneQuation) #5

As I sead, look for the FireWeapon function in g_weapon.c. There’s a big switch statement for each of the weapons. Look for WP_GARAND:

case WP_GARAND_SCOPE:
		Bullet_Fire( ent, GARANDSCOPE_SPREAD*aimSpreadScale, GARANDSCOPE_DAMAGE, qfalse );
		break;
	case WP_GARAND:
		aimSpreadScale = 1.0f;
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		break;
	case WP_SATCHEL_DET:
		if( G_ExplodeSatchels( ent ) ) {
			ent->client->ps.ammo[WP_SATCHEL_DET] = 0;
			ent->client->ps.ammoclip[WP_SATCHEL_DET] = 0;
			ent->client->ps.ammoclip[WP_SATCHEL] = 1;
			G_AddEvent( ent, EV_NOAMMO, 0 );
		}
		break;

Copy Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse ); as many times as the number of pieces of buckshot you want (let’s say 11 - that’s what Q3 has):

case WP_GARAND_SCOPE:
		Bullet_Fire( ent, GARANDSCOPE_SPREAD*aimSpreadScale, GARANDSCOPE_DAMAGE, qfalse );
		break;
	case WP_GARAND:
		aimSpreadScale = 1.0f;
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		Bullet_Fire( ent, GARAND_SPREAD*aimSpreadScale, GARAND_DAMAGE, qfalse );
		break;
	case WP_SATCHEL_DET:
		if( G_ExplodeSatchels( ent ) ) {
			ent->client->ps.ammo[WP_SATCHEL_DET] = 0;
			ent->client->ps.ammoclip[WP_SATCHEL_DET] = 0;
			ent->client->ps.ammoclip[WP_SATCHEL] = 1;
			G_AddEvent( ent, EV_NOAMMO, 0 );
		}
		break;

Now, find the GARAND_SPREAD define and change it to suit your needs (Q3’s DEFAULT_SHOTGUN_SPREAD is 700).


(P4nth3r) #6

Thnx Rookie One.
I kinda understand what’s going on there but I coulnd’t figure it out for myself.
I’ll try to figure out the shotgun spread myself.
You’ve been great help.

Greetz Panther aka Way2Evil


(IneQuation) #7

No problem. :wink: You’ll have to figure out how to get rid of the nades yourself, though (look for instances of WP_M7).


(P4nth3r) #8

Neh, I think I wanna keep the nades in there (I’ll change them a bit tho.
Also you made a little mistake with the WP_GARAND, that is the sniper garand, the engineer grand is the WP_CARBINE.
Np there tho, found that myself =)
It’s working correct now. thnx.
Only problem I got now is that the Carbine can’t reload in the middle of a clip.
I know etpro removes this, but I con’t find the code that makes this happen.

Greetz Panther


(P4nth3r) #9

Another problem I just encounterd is the headshot damage.
my shotgun fires around 8 bullets with a good spread, but the head shot damage of 1 of those 8 bullets is around 50hp.
So, a head shot when only 3 bullets hit the head means death in 1 shot.
I looked before how I could change the headshot damage, but couldn’t found anything usefull.
Maybe it is possible to change the headshot damage.

Thnx & Greetz Panther


(IneQuation) #10

Replied in the other topic + sent you a PM. :slight_smile: