Skip to content

Unjam function added to reload hotkey#583

Open
Greysa wants to merge 6 commits into1dot13:masterfrom
Greysa:master
Open

Unjam function added to reload hotkey#583
Greysa wants to merge 6 commits into1dot13:masterfrom
Greysa:master

Conversation

@Greysa
Copy link
Copy Markdown
Contributor

@Greysa Greysa commented Mar 22, 2026

Adds unjam function to the Alt + r reload hotkey.

Currently, when a weapon is jammed, the only way to unjam it in tactical is to shoot the weapon again. This may or may not unjam the weapon based on the skill of the character wielding the weapon. Repeated attempts may be required to unjam the weapon, potentially leaving the character exposed to atttack. Alternatively, the character can find cover, but shooting is still required to unjam the weapon, potentially wasting AP (and ammo) on an unnecesary action.

This change allows the character to unjam the weapon without needing to shoot. The character can now find cover and deal with the jam without spending AP shooting at nothing. A reload is not performed if the weapon is jammed, allowing a character to clear the jam and continue shooting without spending AP on an unnecesary reload.

The reload now has two functions based on the jam state of the weapon.

If the weapon is jammed, attempt to clear jam. Do not reload.

If the weapon is not jammed, reload weapon.

This also functions with dual wielded weapons. No reload will occur if either weapon is jammed and either or both weapons will be unjammed as required.

@Greysa
Copy link
Copy Markdown
Contributor Author

Greysa commented Mar 23, 2026

sorry for fix #580 being a part of this pull request. I am a dummy and forgot to create a branch before working on either of these items.

Comment thread Tactical/Items.cpp
PlayJA2Sample( Weapon[ Item[pObj->usItem].ubClassIndex ].ManualReloadSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) );

if ( pSoldier->IsValidSecondHandShot( ) )
if (pObj2 != NULL)//( pSoldier->IsValidSecondHandShot( ) )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the commented out code. No need to clutter the codebase with commented out code, unless there's a good reason to do so.

Comment thread Tactical/Items.cpp
if (pObj2 != NULL)//( pSoldier->IsValidSecondHandShot( ) )
{
pObj2 = &(pSoldier->inv[SECONDHANDPOS]);
//pObj2 = &(pSoldier->inv[SECONDHANDPOS]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment thread Tactical/Items.cpp
{
// Flugente: check for underbarrel weapons and use that object if necessary
pObj = pSoldier->GetUsedWeapon( &( pSoldier->inv[SECONDHANDPOS] ) );
//pObj2 = pSoldier->GetUsedWeapon( &( pSoldier->inv[SECONDHANDPOS] ) );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove instead of commenting out

Comment thread Tactical/Items.cpp

// Flugente: check for underbarrel weapons and use that object if necessary
pObj = pSoldier->GetUsedWeapon( &(pSoldier->inv[HANDPOS]) );
if (pSoldier->IsValidSecondHandShotForReloadingPurposes()) //check for valid second hand weapon for reloading purposes (something that doesn't use ammo)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize pObj2 to null and then you only need to have the if {} block without else {}. Not strictly necessary, but I do find that more readable and c++ being what it is, initializing values is a good habit to have :)

Comment thread Tactical/Items.cpp
else
{
if ( pSoldier->IsValidSecondHandShot( ) )
if (pObj2 != NULL)//( pSoldier->IsValidSecondHandShot( ) )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread Tactical/Items.cpp
if (pObj2 != NULL)//( pSoldier->IsValidSecondHandShot( ) )
{
pObj2 = &(pSoldier->inv[SECONDHANDPOS]);
//pObj2 = &(pSoldier->inv[SECONDHANDPOS]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

Comment thread Tactical/Items.cpp
// then do a reload of both guns!
// Flugente: only reload if it's empty, or we really want to
if ( pSoldier->IsValidSecondHandShotForReloadingPurposes()
if ( pObj2 != NULL //pSoldier->IsValidSecondHandShotForReloadingPurposes()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants