Allow to reload main weapon from akimbo clip

This commit is contained in:
Petr Bartos 2024-04-14 12:45:31 +02:00
parent cfccc0f37c
commit 7d9be84f1c
3 changed files with 44 additions and 5 deletions

View file

@ -627,6 +627,10 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, int font, float scale, vec4
if ( type == 0 ) { // ammo
value = cg.snap->ps.ammo[BG_FindAmmoForWeapon( weap )];
if ( (weap == WP_COLT || weap == WP_MP40 || weap == WP_THOMPSON) && weapAlts[weap] ) {
// When holding single weapon, add akimbo clip to reserve
value += ps->ammoclip[weapAlts[weap]];
}
} else { // clip
value = ps->ammoclip[BG_FindClipForWeapon( weap )];
if ( special ) {
@ -634,7 +638,6 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, int font, float scale, vec4
if ( weapAlts[weap] ) {
value = ps->ammoclip[weapAlts[weap]];
}
// value2 = ps->ammoclip[weapAlts[weap]];
}
}

View file

@ -4146,12 +4146,19 @@ CG_WeaponHasAmmo
==============
*/
static qboolean CG_WeaponHasAmmo( int i ) {
if ( !( cg.predictedPlayerState.ammo[BG_FindAmmoForWeapon( i )] ) &&
!( cg.predictedPlayerState.ammoclip[BG_FindClipForWeapon( i )] ) ) {
return qfalse;
if ( cg.predictedPlayerState.ammo[BG_FindAmmoForWeapon( i )] ) {
return qtrue;
}
return qtrue;
if ( cg.predictedPlayerState.ammoclip[BG_FindClipForWeapon( i )] ) {
return qtrue;
}
if (i == WP_COLT || i == WP_MP40 || i == WP_THOMPSON) {
return cg.predictedPlayerState.ammoclip[BG_FindClipForWeapon(getAltWeapon(i))];
}
return qfalse;
}
/*

View file

@ -2351,6 +2351,21 @@ static void PM_ReloadClip( int weapon ) {
pm->ps->ammoclip[BG_FindClipForWeapon( weapon )] += ammomove;
}
// If clip is not full, check if we have ammo in akimbo clip
// If so, fill main weapon clip from akimbo clip
ammoclip = pm->ps->ammoclip[BG_FindClipForWeapon( weapon )];
ammomove = ammoTable[weapon].maxclip - ammoclip;
if (ammomove && (weapon == WP_COLT || weapon == WP_MP40 || weapon == WP_THOMPSON)) {
int altWeapon = weapAlts[weapon];
if (altWeapon != pm->ps->weapon) {
ammoreserve = pm->ps->ammoclip[ BG_FindClipForWeapon( altWeapon )];
if ( ammoreserve < ammomove ) {
ammomove = ammoreserve;
}
pm->ps->ammoclip[BG_FindClipForWeapon( altWeapon )] -= ammomove;
pm->ps->ammoclip[BG_FindClipForWeapon( weapon )] += ammomove;
}
}
}
/*
@ -2441,6 +2456,13 @@ void PM_CheckForReload( int weapon ) {
doReload = qtrue;
}
}
} else if (weapon == WP_COLT || weapon == WP_MP40 || weapon == WP_THOMPSON) {
// Allow to reload main weapon from akimbo clip
if ( pm->ps->ammoclip[BG_FindClipForWeapon( weapAlts[weapon] )] ) {
if ( pm->ps->ammoclip[clipWeap] < ammoTable[weapon].maxclip) {
doReload = qtrue;
}
}
}
}
// clip is empty, but you have reserves. (auto reload)
@ -2462,6 +2484,13 @@ void PM_CheckForReload( int weapon ) {
} else {
doReload = qtrue;
}
} else if (weapon == WP_COLT || weapon == WP_MP40 || weapon == WP_THOMPSON) {
// Allow to reload main weapon from akimbo clip
if ( pm->ps->ammoclip[BG_FindClipForWeapon( weapAlts[weapon] )] ) {
if ( pm->ps->ammoclip[clipWeap] < ammoTable[weapon].maxclip) {
doReload = qtrue;
}
}
}
}