hmmm, is this what was intended ?


(SCDS_reyalP) #1

g_combat.c:G_Damage, around line 1409


		if( dflags & DAMAGE_DISTANCEFALLOFF ) { vec_t dist;
			vec3_t shotvec;

			VectorSubtract( point, muzzleTrace, shotvec );
			dist = VectorLength( shotvec );

			if( dist > 1500.f ) {
				if( dist > 2500.f ) {
					take *= 0.2f;
				} else {
					float scale = 1.f - 0.2f * (1000.f / (dist - 1000.f));

					take *= scale;
				}
			}
		}


so, in the 1500-2500 range, damage is least close to 1500, and most near 2500 ? The code for body shots (g_weapon.c, Bullet_Fire_Extended) does the same thing… Or am I smoking crack ?

:moo: :poke:


(bani) #2

hah.

dist = 1500 = 0.6
dist = 2500 = 0.8

thats great.

:moo:


(Lanz) #3

lol!

Something like this would probably be better:


float scale = 1.f - 0.2f * (dist/1000.f);

if (scale < 0.2f)
	scale = 0.2f;

take *= scale;


(pgh) #4

All Greek to me :>


(Sauron|EFG) #5

dist < 1500 => scale = 1
dist > 2500 => scale = 0.2

so…

scale = 1.f - 0.8f * (dist-1500.f)/1000.f;


(ildon) #6

Very nice fix, if a little direct.


(jamez) #7

crack is sniffed not smoked


(raffles) #8

Crack is most certainly smoked. Perhaps you are thinking of cocaine, of which crack is the crystallised form.


(Demolama) #9

some of the solutions to this problem seemed borked so I came up with something tonight while in bed… double check the math because Im tired :stuck_out_tongue:


// Demolama

			if( dist > 1500.f ) {

				if( dist > 2500.f ) {
           				take *= 0.2f;
				} else {
					float scale = 1.f - 0.2f *  (dist- 1500.f) / 1000.f;
									
				    scale = 1.f - scale;
				
                        take *= scale; 
				}
				
			}

if distance is over 1500 then check the algorithm for distance falloff

if the distance is over 2500 only multiply .2 to the 1 hit damage you recieve … so in the end you are only recieving 20% of your normal hit damage

between 1500 and 2500 this algorithm is called

float scale = . 8 *(dist- 1500.f) / 1000.f;

if we are at 2499 returns .7992
if we are at 1501 returns .0008

next we subract the x from 1
2499: 1 - .7992 returns .201
1501: 1 - .0008 returns .9992

so as you can see if you around 1500 you are recieving around the normal 100 % hit damage

if you are beyond that to 2000 you will only recieve 60% your hit damage

and at around 2500 and beyond you will get 20%


(SCDS_reyalP) #10

I assume x = scale in the above post ? In which case, it is the same as Sauron|EFG solution, which is what
I used in rmod.

note that there is another instance similar too, but not the same as this in g_weapon.c: bullet_fire_extended:


	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;
			}
		}
	}

In the above, I changed used a regular vectorlength, eliminated all the squared terms, and then used the same algorithm as for headshot, except with .5 instead of .8


(Demolama) #11

just so I understand better in bullet_fire_extended… this just determines the hit damage for any body shot?

and the headshot damage for distance fomula is in g_damage?

doesnt that make the headshot kinda worthless… at over 2500 you are only recieving 10 hitpoints instead of 50 but if you hit the body with an smg you recieve 7

shouldnt it be atleast 25 for a head shot?
so basically what is happening is unless you are a sniper headshots from a distances doesnt do squat especially if the person whom you are shooting at is a medic… 10 hit points gets soaked up in their self healing in less than a second… doesnt this then make them not even worth wasting ammo on unless they are close

so to me it seems like this idea of lessing damage at a distance is a punishment for those who can actually hit things at a distance… this then forces everyone to be face to face at close range to shoot
:frowning:

kinda defeats the purpose of shooting that far


(SCDS_reyalP) #12

yes to everything you wrote. :confused:

And the unscoped rifles (which don’t have damage falloff) don’t help, because the only way you can get a headshot with them at that range is luck. Neither does the MG42, since it doesn’t do headshots at all.

2500 is quite long range, FWIW.


(pgh) #13

All greek still but I know both Crack and Coke can all be Sorted, Injected and Smoked… :slight_smile:


(Chruker) #14

While the inversion has been fixed in 2.60, the headshot part is still using squared numbers:

		// Square(1500) to Square(2500) -> 0.0 to 1.0
		scale = (dist - Square(1500.f)) / (Square(2500.f) - Square(1500.f));

Now why is this bad. Try inserting ex. Square(2000) instead of dist. And you get scale to be = 0,4375

Now replace dist with 2000 in this code:

		// 1500 to 2500 -> 0.0 to 1.0
		scale = (dist - 1500.f) / (2500.f - 1500.f);

And you get: 0,5


(Chruker) #15

Yeah, I manage to revive the thread one year and one day after its last reply :slight_smile:


(jet Pilot) #16

And I’ll further revive it, because something’s got me a bit confused.

In Bullet_Fire_Extended() there is a check for falloff damage, if it passes, damage is reduced by the above algorithm.
Then G_Damage() is called, with the modified damage value.
In G_Damage() there is a further check for falloff damage if the hit is a headshot, in which the damage is further reduced. Why the need for two checks, and two reductions? Wouldn’t it have been more efficient to do all of the falloff damage calculations in one spot, ie G_Damage()?


(Jaquboss) #17

:nag: i bet you can delete that in g_damage


(IneQuation) #18

One can see that Jaquboss has really strong feelings towards this nag smiley. :wink:


(jet Pilot) #19

it does get used in G_Damage(), but I’ve already removed it, since the damage is already reduced in Bullet_Fire_Extended(). I was just wondering if it’s reasoning could be explained.

Lol, yeah Jaquboos does like his smiley, but it’s all good.
Jaquboss, this is for you : :nag: :nag:


(Jaquboss) #20

Thanks , for them :nag:, i think that it was a topic about this one sometime before…
Maybe removing this can do better job for snipers, but because ET guns accuracy, I can understant if someone wanted to remove damage again