Enemy Territory

Project: Bug Fix

The objective

The goal of this project is to provide modders in the ET community with a SDK code base that contains fixes for various bugs which are present in the stock etmain game (version 2.60).

26th september 2006: Sadly bugfix 088 had a bug :-( There were 3 lines that should have been deleted for the fix to work correctly.

Show index
Previous bug: When using Panzer and SMG, it switches to grenades and not the SMG after you fire the panzer
Next bug: XP and Medals are indented incorrectly on the playerstat dropdown

Bugfix 022 - Damage distance falloff is inverted between 1500-2500 units

Problem:

The damage falloff algorithm caused damage given in the the range of 1500-2500 units to be inverted. Update: And the usage of squared numbers is wrong.

Solution:

Use the correct algorithm. Update: And throw away the squared numbers.

References:

Spawning thread and original fix

Notes:

The bug was semi-fixed in version 2.60. The damage falloff algorithm in the headshot code (g_weapon.c), is still using the squared numbers. However the way it does it is flawed. Now that we'll be editing the 2.60 files we might as well cleanup the old distance code.

2.60 Code

g_combat.c @ 1413 VectorSubtract( point, muzzleTrace, shotvec ); dist = VectorLength( shotvec );
#if DO_BROKEN_DISTANCEFALLOFF // ~~~___---___ 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; } } #else // ~~~---______
// zinx - start at 100% at 1500 units (and before), // and go to 20% at 2500 units (and after) // 1500 to 2500 -> 0.0 to 1.0 scale = (dist - 1500.f) / (2500.f - 1500.f); // 0.0 to 1.0 -> 0.0 to 0.8 scale *= 0.8f; // 0.0 to 0.8 -> 1.0 to 0.2 scale = 1.0f - scale; // And, finally, cap it. if (scale > 1.0f) scale = 1.0f; else if (scale < 0.2f) scale = 0.2f; take *= scale;
#endif
}
g_weapon.c @ 3218 //VectorSubtract( tr.endpos, start, shotvec ); VectorSubtract( tr.endpos, muzzleTrace, shotvec ); dist = VectorLengthSquared( shotvec );
#if DO_BROKEN_DISTANCEFALLOFF // ~~~___---___ 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; } } #else // ~~~---______
// zinx - start at 100% at 1500 units (and before), // and go to 50% at 2500 units (and after)
// Square(1500) to Square(2500) -> 0.0 to 1.0 scale = (dist - Square(1500.f)) / (Square(2500.f) - Square(1500.f));
// 1500 to 2500 -> 0.0 to 1.0 scale = (dist - 1500.f) / (2500.f - 1500.f);
// 0.0 to 1.0 -> 0.0 to 0.5 scale *= 0.5f; // 0.0 to 0.5 -> 1.0 to 0.5 scale = 1.0f - scale; // And, finally, cap it. reducedDamage = qtrue; if (scale >= 1.0f) { scale = 1.0f; reducedDamage = qfalse; } else if (scale < 0.5f) scale = 0.5f; damage *= scale;
#endif
}

2.56 Code

g_combat.c @ 1410 take *= 0.2f; } else {
float scale = 1.f - 0.2f * (1000.f / (dist - 1000.f));
// CHRUKER: b022 - Correct distance falloff algorithm float scale = 1.f - 0.8f * (dist-1500.f)/1000.f;
take *= scale;
g_weapon.c @ 3120 //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)));
// CHRUKER: b022 - Correct distance falloff algorithm float scale = 1.f - 0.5f * (dist-1500.f)/1000.f;
damage *= scale; } }

Show index
Previous bug: When using Panzer and SMG, it switches to grenades and not the SMG after you fire the panzer
Next bug: XP and Medals are indented incorrectly on the playerstat dropdown

Color coding

Sample = New code
Sample = Changed code (the new version is what is displayed)
Sample = Deleted code

©2017 Chruker