My initial fix was via script and yes I was checking leaning. In fact I remember we had a discussion on leaning in Discord, and I posted several threads that were what you were looking for.
Basically when you lean it's a float value that is 0 -> 1 (if I remember correctly) or -1 -> 0 if you lean in the other way. I can't remember if the value were 1 or up to 16.. -16 <-- 0 --> 16
The way RR fixed it in the antiSTWH, was instead of checking leaning, we checked the gunmuzzleposition and check if it "collides" with a wall. If it does, we set bulletAttack to 0 so the bullet is fired, but doesn't do any damage.
vec3_t start;
vec3_t mins = { -4, -4, 0};
vec3_t maxs = { 4, 4, 6 };
//we add + 2.0f to x and y axis to prevent back of player model to collide with doorway or walls
//also for z value we use centroid to prevent from false positives when players foot falls a bit under ground
start[0] = ent->absmin[0] + 2.0f;
start[1]= ent->absmin[1] + 2.0f;
start[2] = ent->centroid[2];
//Now we do a trace
gi.trace(&res, start, mins, maxs, pos, ent->s.number, MASK_SOLID, 0, 0);
if(res.fraction != 1.0f && res.surfaceFlags != 0x108B0) // we make sure that surface isn't a GLASS? Windows have this value
{
gi.Printf("Reborn Patch: STWH Detected! Skipping BulletAttack!\n");
return 0;
}
else
{
//return CanShoot_orig(emptyWeaponStructPointer, somevalue, varInsideCurrentWeaponPointer, currentWeaponStructPointer);
return 1;
}