Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Tactical/Interface Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6060,7 +6060,8 @@ void ItemDescAmmoCallback(GUI_BUTTON *btn,INT32 reason)
gfItemAmmoDown = FALSE;

//CHRISL: We dont' want to be able to reload guns using the ammo crate from this function
if((gpItemPointer != NULL && Magazine[Item[gpItemPointer->usItem].ubClassIndex].ubMagType >= AMMO_BOX) || !EnoughPoints(gpItemDescSoldier, APBPConstants[AP_RELOAD_GUN], 0, TRUE))//dnl ch65 040913
//Greysa: add check for ammo item
if( gpItemPointer != NULL && ( (Item[gpItemPointer->usItem].usItemClass != IC_AMMO || Magazine[Item[gpItemPointer->usItem].ubClassIndex].ubMagType >= AMMO_BOX) ) || !EnoughPoints(gpItemDescSoldier, APBPConstants[AP_RELOAD_GUN], 0, TRUE) )//dnl ch65 040913
{
fInterfacePanelDirty = DIRTYLEVEL2;
btn->uiFlags &= (~BUTTON_CLICKED_ON );
Expand All @@ -6083,7 +6084,8 @@ void ItemDescAmmoCallback(GUI_BUTTON *btn,INT32 reason)
else
{
//holding an item
if(Magazine[Item[gpItemPointer->usItem].ubClassIndex].ubCalibre == Weapon[Item[gpItemDescObject->usItem].ubClassIndex].ubCalibre)
//Greysa: add check for ammo item
if( Item[gpItemPointer->usItem].usItemClass == IC_AMMO && Magazine[Item[gpItemPointer->usItem].ubClassIndex].ubCalibre == Weapon[Item[gpItemDescObject->usItem].ubClassIndex].ubCalibre )
{
ReloadGun(gpItemDescSoldier, gpItemDescObject, gpItemPointer, ubStatusIndex);
}
Expand Down
118 changes: 109 additions & 9 deletions Tactical/Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3872,13 +3872,113 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier, bool aReloadEvenIfNotEmpty )
{
OBJECTTYPE *pObj, *pObj2;
INT8 bSlot;
INT16 bAPCost;
INT16 bAPCost;
BOOLEAN fRet = FALSE;

CHECKF( pSoldier );

// 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 :)

{
pObj2 = pSoldier->GetUsedWeapon( &(pSoldier->inv[SECONDHANDPOS]) );
}
else
{
pObj2 = NULL;
}
// Greysa: Check if weapon is jammed and unjam it first
if ((*pObj)[0]->data.gun.bGunAmmoStatus < 0 || ((pObj2 != NULL) && (*pObj2)[0]->data.gun.bGunAmmoStatus < 0))
{
if ((*pObj)[0]->data.gun.bGunAmmoStatus < 0)
{
//borrowed from Weapons.cpp
if (EnoughPoints(pSoldier, APBPConstants[AP_UNJAM], APBPConstants[BP_UNJAM], FALSE))
{
DeductPoints(pSoldier, APBPConstants[AP_UNJAM], APBPConstants[BP_UNJAM]);

INT8 bChanceMod;

if (Weapon[pObj->usItem].EasyUnjam)
bChanceMod = 100;
else
bChanceMod = (INT8)(GetReliability(pObj) * 4);

int iResult = SkillCheck(pSoldier, UNJAM_GUN_CHECK, bChanceMod);

if (iResult > 0)
{
// yay! unjammed the gun
(*pObj)[0]->data.gun.bGunAmmoStatus *= -1;

// MECHANICAL/DEXTERITY GAIN: Unjammed a gun

if (bChanceMod < 100) // don't give exp for unjamming an easily unjammable gun
{
StatChange(pSoldier, MECHANAMT, 5, FALSE);
StatChange(pSoldier, DEXTAMT, 5, FALSE);
}

DirtyMercPanelInterface(pSoldier, DIRTYLEVEL2);
PlayJA2Sample(Weapon[Item[pObj->usItem].ubClassIndex].ManualReloadSound, RATE_11025, SoundVolume(HIGHVOLUME, pSoldier->sGridNo), 1, SoundDir(pSoldier->sGridNo));
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_UNJAMMED], pSoldier->GetName(), ItemNames[pObj->usItem]);
// merc voice feedback?
}
else
{
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_FAILED_UNJAM], pSoldier->GetName(), ItemNames[pObj->usItem]);
}
}
else
{
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_NO_AP_NO_UNJAM], pSoldier->GetName(), ItemNames[pObj->usItem]);
}
}
if ((pObj2 != NULL) && (*pObj2)[0]->data.gun.bGunAmmoStatus < 0)
{
if (EnoughPoints(pSoldier, APBPConstants[AP_UNJAM], APBPConstants[BP_UNJAM], FALSE))
{
DeductPoints(pSoldier, APBPConstants[AP_UNJAM], APBPConstants[BP_UNJAM]);

INT8 bChanceMod;

if (Weapon[pObj2->usItem].EasyUnjam)
bChanceMod = 100;
else
bChanceMod = (INT8)(GetReliability(pObj2) * 4);

int iResult = SkillCheck(pSoldier, UNJAM_GUN_CHECK, bChanceMod);

if (iResult > 0)
{
// yay! unjammed the gun
(*pObj2)[0]->data.gun.bGunAmmoStatus *= -1;

// MECHANICAL/DEXTERITY GAIN: Unjammed a gun

if (bChanceMod < 100) // don't give exp for unjamming an easily unjammable gun
{
StatChange(pSoldier, MECHANAMT, 5, FALSE);
StatChange(pSoldier, DEXTAMT, 5, FALSE);
}

DirtyMercPanelInterface(pSoldier, DIRTYLEVEL2);
PlayJA2Sample(Weapon[Item[pObj2->usItem].ubClassIndex].ManualReloadSound, RATE_11025, SoundVolume(HIGHVOLUME, pSoldier->sGridNo), 1, SoundDir(pSoldier->sGridNo));
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_UNJAMMED], pSoldier->GetName(), ItemNames[pObj2->usItem]);
// merc voice feedback?
}
else
{
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_FAILED_UNJAM], pSoldier->GetName(), ItemNames[pObj2->usItem]);
}
}
else
{
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, Message[STR_NO_AP_NO_UNJAM], pSoldier->GetName(), ItemNames[pObj2->usItem]);
}
}
return FALSE; // Greysa: We want to skip reloading if we attempted to unjam, regardless of outcome. Return value doesn't seem to matter as there doesn't seem to be any actual checks on the returned value. I picked FALSE as actual reload hasn't occurred
}

//<SB> manual recharge
if ((*pObj)[0]->data.gun.ubGunShotsLeft && !((*pObj)[0]->data.gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) )
Expand Down Expand Up @@ -3915,9 +4015,9 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier, bool aReloadEvenIfNotEmpty )

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.

{
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


if ((*pObj2)[0]->data.gun.ubGunShotsLeft && !((*pObj2)[0]->data.gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) )
{
Expand All @@ -3930,9 +4030,9 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier, bool aReloadEvenIfNotEmpty )
}
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

{
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


if ((*pObj2)[0]->data.gun.ubGunShotsLeft && !((*pObj2)[0]->data.gun.ubGunState & GS_CARTRIDGE_IN_CHAMBER) )
{
Expand Down Expand Up @@ -3989,21 +4089,21 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier, bool aReloadEvenIfNotEmpty )
// if we are valid for two-pistol shooting (reloading) and we have enough APs still
// 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

&& ( aReloadEvenIfNotEmpty || !EnoughAmmo( pSoldier, FALSE, SECONDHANDPOS ) ) )
{
// 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


bSlot = FindAmmoToReload( pSoldier, SECONDHANDPOS, NO_SLOT );
if ( bSlot != NO_SLOT )
{
// ce would reload using this ammo!
bAPCost = GetAPsToReloadGunWithAmmo( pSoldier, pObj, &( pSoldier->inv[bSlot] ) );
bAPCost = GetAPsToReloadGunWithAmmo( pSoldier, pObj2, &( pSoldier->inv[bSlot] ) );
if ( EnoughPoints( pSoldier, (INT16)bAPCost, 0, FALSE ) )
{
// reload the 2nd gun too
fRet = ReloadGun( pSoldier, pObj, &( pSoldier->inv[bSlot] ) );
fRet = ReloadGun( pSoldier, pObj2, &( pSoldier->inv[bSlot] ) );
}
else
{
Expand Down
24 changes: 14 additions & 10 deletions Tactical/Turn Based Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4303,21 +4303,25 @@ void GetKeyboardInput( UINT32 *puiNewEvent )

// Make auto reload with magazines from sector inventory
case 'R':
HandleTBReloadAll();

if (fAlt && gusSelectedSoldier != NOBODY ) // Greysa: Moved here from 'r' to retain all functionality during testing.
{
if (CHEATER_CHEAT_LEVEL())
{
ReloadWeapon(gusSelectedSoldier, gusSelectedSoldier->ubAttackingHand);
}
}
else
{
HandleTBReloadAll();
}
break;
case 'r':
if( gusSelectedSoldier != NOBODY )
{
if( fAlt ) //reload selected merc's weapon
if( fAlt )
{
if ( CHEATER_CHEAT_LEVEL( ) )
{
ReloadWeapon( gusSelectedSoldier, gusSelectedSoldier->ubAttackingHand );
}
else
HandleTBReload();
}
HandleTBReload();
}
else if( fCtrl )
{
if ( INFORMATION_CHEAT_LEVEL( ) )
Expand Down
5 changes: 5 additions & 0 deletions i18n/_ChineseText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"没有能够训练的民兵。", //L"No militia that can be drilled present.",

L"%s 已经完全的探索了 %s。", //L"%s has fully explored %s."

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
5 changes: 5 additions & 0 deletions i18n/_DutchText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s has fully explored %s.", // TODO.Translate

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
5 changes: 5 additions & 0 deletions i18n/_EnglishText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s has fully explored %s.",

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
5 changes: 5 additions & 0 deletions i18n/_FrenchText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s has fully explored %s.", // TODO.Translate

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game // TODO.Translate
Expand Down
5 changes: 5 additions & 0 deletions i18n/_GermanText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s hat %s vollständig erkundet.",

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
5 changes: 5 additions & 0 deletions i18n/_ItalianText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s has fully explored %s.", // TODO.Translate

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
5 changes: 5 additions & 0 deletions i18n/_PolishText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s has fully explored %s.", // TODO.Translate

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
5 changes: 5 additions & 0 deletions i18n/_RussianText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,11 @@ CHAR16 Message[][STRING_LENGTH] =
L"No militia that can be drilled present.",

L"%s has fully explored %s.", // TODO.Translate

// The first %s is a merc name and the second %s is an item name
L"%s unjammed %s.",
L"%s failed to unjam %s.",
L"%s does not have enough APs to unjam %s."
};

// the country and its noun in the game
Expand Down
4 changes: 4 additions & 0 deletions i18n/include/Text.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ enum

STR_ASSIGNMENT_EXPLORATION_DONE,

STR_UNJAMMED,
STR_FAILED_UNJAM,
STR_NO_AP_NO_UNJAM,

TEXT_NUM_STR_MESSAGE,
};

Expand Down