Skip to content

Commit

Permalink
Classic DOOM - MBF21 - Finalize Ammo per shot
Browse files Browse the repository at this point in the history
  • Loading branch information
MadDeCoDeR committed Jan 16, 2025
1 parent c6a25fb commit fcdb87a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions doomclassic/doom/d_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void initWeapons() {
S_PLASMA,
S_PLASMA1,
S_PLASMAFLASH1,
0,
1
},
{
Expand Down Expand Up @@ -150,6 +151,7 @@ void initWeapons() {
S_DSGUN,
S_DSGUN1,
S_DSGUNFLASH1,
0,
2
},
};
Expand Down
32 changes: 17 additions & 15 deletions doomclassic/doom/p_pspr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ qboolean P_CheckAmmo (player_t* player)
ammo = weaponinfo[player->readyweapon].ammo;

// Minimal amount for one shot varies.
if (player->readyweapon == wp_bfg && ::g->BFGCELL != 40)
if (player->readyweapon == wp_bfg && ::g->BFGCELL != 40){
weaponinfo[wp_bfg].clipAmmo = ::g->BFGCELL;
count = ::g->BFGCELL;
}
else
count = weaponinfo[player->readyweapon].clipAmmo; // Regular.

Expand All @@ -226,28 +228,28 @@ qboolean P_CheckAmmo (player_t* player)
do
{
if (player->weaponowned[wp_plasma]
&& player->ammo[am_cell]
&& player->ammo[am_cell]>weaponinfo[wp_plasma].clipAmmo
&& (::g->gamemode != shareware) )
{
player->pendingweapon = wp_plasma;
}
else if (player->weaponowned[wp_supershotgun]
&& player->ammo[am_shell]>2
&& player->ammo[am_shell]>weaponinfo[wp_supershotgun].clipAmmo
&& (::g->gamemode == commercial) )
{
player->pendingweapon = wp_supershotgun;
}
else if (player->weaponowned[wp_chaingun]
&& player->ammo[am_clip])
&& player->ammo[am_clip]>weaponinfo[wp_chaingun].clipAmmo)
{
player->pendingweapon = wp_chaingun;
}
else if (player->weaponowned[wp_shotgun]
&& player->ammo[am_shell])
&& player->ammo[am_shell]>weaponinfo[wp_shotgun].clipAmmo)
{
player->pendingweapon = wp_shotgun;
}
else if (player->ammo[am_clip])
else if (player->ammo[am_clip]>weaponinfo[wp_pistol].clipAmmo)
{
player->pendingweapon = wp_pistol;
}
Expand All @@ -256,12 +258,12 @@ qboolean P_CheckAmmo (player_t* player)
player->pendingweapon = wp_chainsaw;
}
else if (player->weaponowned[wp_missile]
&& player->ammo[am_misl])
&& player->ammo[am_misl]>weaponinfo[wp_missile].clipAmmo)
{
player->pendingweapon = wp_missile;
}
else if (player->weaponowned[wp_bfg]
&& player->ammo[am_cell]>40
&& player->ammo[am_cell]>weaponinfo[wp_bfg].clipAmmo
&& (::g->gamemode != shareware) )
{
player->pendingweapon = wp_bfg;
Expand Down Expand Up @@ -631,7 +633,7 @@ A_FireMissile
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}
P_SpawnPlayerMissile (player->mo, MT_ROCKET);

Expand All @@ -650,7 +652,7 @@ A_FireBFG
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo] -= ::g->BFGCELL;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}

P_SpawnPlayerMissile (player->mo, MT_BFG);
Expand All @@ -670,7 +672,7 @@ A_FirePlasma
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}

P_SetPsprite (player,
Expand Down Expand Up @@ -755,7 +757,7 @@ A_FirePistol

P_SetMobjState (player->mo, S_PLAY_ATK2);
if( (player->cheats & CF_INFAMMO ) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}

P_SetPsprite (player,
Expand Down Expand Up @@ -785,7 +787,7 @@ A_FireShotgun
P_SetMobjState (player->mo, S_PLAY_ATK2);

if( ( player->cheats & CF_INFAMMO ) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}

P_SetPsprite (player,
Expand Down Expand Up @@ -821,7 +823,7 @@ A_FireShotgun2
P_SetMobjState (player->mo, S_PLAY_ATK2);

if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]-=2;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}

P_SetPsprite (player,
Expand Down Expand Up @@ -862,7 +864,7 @@ A_FireCGun

P_SetMobjState (player->mo, S_PLAY_ATK2);
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
player->ammo[weaponinfo[player->readyweapon].ammo] -= weaponinfo[player->readyweapon].clipAmmo;
}
P_SetPsprite (player,
ps_flash,
Expand Down

0 comments on commit fcdb87a

Please sign in to comment.