BUGFIX: self-headshot when prone


(bani) #1

g_weapon.c:


qboolean Bullet_Fire_Extended(gentity_t *source, gentity_t *attacker, vec3_t start, vec3_t end, float spread, int damage, qboolean distance_falloff) {
        trace_t         tr;
        gentity_t       *tent;
        gentity_t       *traceEnt;
        qboolean hitClient = qfalse;

        qboolean reducedDamage = qfalse;

        G_HistoricalTrace(source, &tr, start, NULL, NULL, end, source->s.number, MASK_SHOT);

        // bullet debugging using Q3A's railtrail

change it to:


qboolean Bullet_Fire_Extended(gentity_t *source, gentity_t *attacker, vec3_t start, vec3_t end, float spread, int damage, qboolean distance_falloff) {
        trace_t         tr;
        gentity_t       *tent;
        gentity_t       *traceEnt;
        qboolean hitClient = qfalse;

        qboolean reducedDamage = qfalse;

        qboolean waslinked = qfalse;

        //bani - prevent shooting ourselves in the head when prone, firing through a breakable
        if( g_entities[ attacker->s.number ].client && g_entities[ attacker->s.number ].r.linked ==
qtrue ) {
                g_entities[ attacker->s.number ].r.linked = qfalse;
                waslinked = qtrue;
        }

        G_HistoricalTrace(source, &tr, start, NULL, NULL, end, source->s.number, MASK_SHOT);

        //bani - prevent shooting ourselves in the head when prone, firing through a breakable
        if( waslinked == qtrue ) {
                g_entities[ attacker->s.number ].r.linked = qtrue;
        }

        // bullet debugging using Q3A's railtrail


(Demolama) #2

interesting… had no clue you could shoot yourself


(Seph64) #3

It was probably a random bug that doesn’t pop up so often.

Anyway, you can count on this fix to appear in the next version of my mod.


(SCDS_reyalP) #4

It pops up any time you prone directly in front of a breakable, and attempt to shoot through it :banana:


(Seph64) #5

oooh, never noticed it since I never did that. But I am glad it is fixed. I think I shall put this to the test in a listen server on etmain.

edit: I see what you mean.

Edit #2: Now that’s interesting, I applied the bugfix a few days ago, I just now tested it out, and now when I prone and shoot through a breakable that would hit me it’ll show water getting hit by bullets effect. screenshot of this in action.


(SCDS_reyalP) #6

hmmm, another semi-related tidbit. The whole ‘shoot through a func_explosive’ thing isn’t even done for mounted guns, since these go through g_msic.c Fire_Lead_Ext rather than Bullet_Fire_Extended. Not that it matters much, since another bullet should be on the way shortly after the func_explosive dies…

Note that Fire_Lead is just a #define for Fire_Lead_Ext

In Bullet_Fire_Extended, distance falloff may also get bypassed or reduced, and antilag won’t be done for the recursive shot.