Bullet damage decreasing over distance?


(gonzoboi) #1

I once read somewhere that in ET small caliber bullets (ie pistols and SMGs) dont do less damage at long range. Could some guru point me to the code section where this is handled so i can have a look?


(pgh) #2

Nm… Wrong post. :slight_smile:


(Spark) #3

In g_weapon.c there is a function FireWeapon(). For the SMG and pistols it calls Bullet_Fire with a defined damage value and “distance_falloff” set to qtrue. This one calls Bullet_Fire_Extended, passing the same damage and distance_falloff values. There you’ll find the following:


if( distance_falloff ) {
		vec_t dist;
		vec3_t shotvec;

		//VectorSubtract( tr.endpos, start, shotvec );
		VectorSubtract( tr.endpos, muzzleTrace, shotvec );		
		dist = VectorLengthSquared( shotvec );

		if( dist > Square(1500.f) ) {
			reducedDamage = qtrue;

			if( dist > Square(2500.f) ) {
				damage *= 0.5f;
			} else {
				float scale = 1.f - 0.5f * (Square(1000.f) / (dist - Square(1000.f)));

				damage *= scale;
			}
		}
	}

If that’s not broken, they should indeed do less damage on very long distances.


(gonzoboi) #4

Nice :drink:

And what about changing the weapon’s firing speed? I’m trying to get a pump-action shotgun and after changing all the stuff, i have this big table in bg_misc.c, circa line 142,

ammotable_t ammoTableMP[WP_NUM_WEAPONS]

In that table i’m trying to change fireDelayTime and nextShotTime to make it fire slower, i even tried setting it to 10000 or so, but the weapon keeps firing like a normal engineer k43. Any ideas or places to look?


(Spark) #5

I just tested nextShotTime with the knife and it worked, so that should be the right value.


(gonzoboi) #6

you mean if you change nextShot value for the knife to, say, 3000, you can only attack every 3 seconds? damn, i must’ve fucked up elsewhere then :confused:

After 2 hours of useless tests i just noticed something:

I looked at the console output and i spotted this:

Sys_LoadDll(/home/axel/.etwolf/amok2/ui.mp.i386.so)… ok
Sys_LoadDll(ui) found vmMain at 0x50a3ec6c
Sys_LoadDll(ui) succeeded!
— Common Initialization Complete —

[…]

9122 files in pk3 files
copy /usr/local/games/enemy-territory/etmain/qagame.mp.i386.so to /home/axel/.etwolf/amok2/qagame.mp.i386.so
Sys_LoadDll(/home/axel/.etwolf/amok2/qagame.mp.i386.so)… ok
Sys_LoadDll(qagame) found vmMain at 0x520f87ec
Sys_LoadDll(qagame) succeeded!

See? For some reason ET is copying the ‘stock’ qagame dll to my mod dll directory (~/.etwolf/amok2). After running ET, the dll in my mod dir is a copy of the stock one and timestamps show it’s just been written. :eek:

Can someone help with this? Why is ET overwriting my dll?


(gonzoboi) #7

:bump:


(Spark) #8

Sorry, no idea. :frowning: I have the same problem and the only good solution I found was to copy the files to the main dir instead (/usr/local/games/enemy-territory/yourmod/). With a script of course. It would be cool to know a solution for this so I could save entering the root password each time.


(gonzoboi) #9

ah well
i sort of fixed it :clap:

i copied the whole ET dir to $HOME/.et so i don’t need to enter root password every time. wastes about 500mb, but who cares…

cheers mate and thanks for the help :beer:

PHEAR!!!


(sniser) #10

The “next shot delay” isn’t used for all weapons, sometimes there’s a hardcoded value in the code (for example ammo and medpacks).


(bani) #11

sv_pure 0


(gonzoboi) #12

bani,

even with sv_pure 0, the game keeps copying qagame.so over my mod. sucks.