Permalink
Browse files

game: use weapon table

  • Loading branch information...
Aranud committed Oct 12, 2017
1 parent 5af6ee0 commit 165886cf7929573b63286813986233278807907e
Showing with 70 additions and 122 deletions.
  1. +46 −79 src/game/bg_misc.c
  2. +20 −34 src/game/g_client.c
  3. +4 −9 src/game/g_weapon.c
View
@@ -4262,111 +4262,78 @@ splinePath_t *BG_GetSplineData(int number, qboolean *backwards)
*/
int BG_MaxAmmoForWeapon(weapon_t weaponNum, int *skill)
{
// TODO: weapon table for type weapon ?
switch (weaponNum)
{
//case WP_KNIFE:
case WP_LUGER:
case WP_COLT:
case WP_STEN:
case WP_SILENCER:
case WP_CARBINE:
case WP_KAR98:
case WP_SILENCED_COLT:
int maxAmmo = GetWeaponTableData(weaponNum)->maxAmmo;
if (GetWeaponTableData(weaponNum)->isPistol || GetWeaponTableData(weaponNum)->isSilencedPistol || GetWeaponTableData(weaponNum)->isRifle || weaponNum == WP_STEN)
{
if (skill[SK_LIGHT_WEAPONS] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + GetWeaponTableData(weaponNum)->maxClip);
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
maxAmmo += GetWeaponTableData(weaponNum)->maxClip;
}
case WP_MP40:
case WP_THOMPSON:
}
else if (weaponNum == WP_MP40 || weaponNum == WP_THOMPSON)
{
if (skill[SK_FIRST_AID] >= 1 || skill[SK_LIGHT_WEAPONS] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + GetWeaponTableData(weaponNum)->maxClip);
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
maxAmmo += GetWeaponTableData(weaponNum)->maxClip;
}
case WP_M7:
case WP_GPG40:
}
else if (GetWeaponTableData(weaponNum)->isRiflenade)
{
if (skill[SK_EXPLOSIVES_AND_CONSTRUCTION] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + 4);
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
maxAmmo += 4;
}
case WP_GRENADE_PINEAPPLE:
case WP_GRENADE_LAUNCHER:
}
else if (GetWeaponTableData(weaponNum)->isGrenade)
{
// FIXME: this is class dependant, not ammo table
if (skill[SK_EXPLOSIVES_AND_CONSTRUCTION] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + 4);
maxAmmo += 4;
}
else if (skill[SK_FIRST_AID] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + 1);
maxAmmo += 1;
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
}
/*case WP_MOBILE_MG42:
case WP_MOBILE_BROWNING
case WP_PANZERFAUST:
case WP_BAZOOKA:
case WP_FLAMETHROWER:
if( skill[SK_HEAVY_WEAPONS] >= 1 )
return( GetWeaponTableData(weaponNum)->maxammo + GetWeaponTableData(weaponNum)->maxclip );
else
return( GetWeaponTableData(weaponNum)->maxammo );
case WP_MORTAR:
case WP_MORTAR_SET:
case WP_MORTAR2:
case WP_MORTAR2_SET:
if( skill[SK_HEAVY_WEAPONS] >= 1 )
return( GetWeaponTableData(weaponNum)->maxammo + 2 );
else
return( GetWeaponTableData(weaponNum)->maxammo );*/
case WP_MEDIC_SYRINGE:
}
// else if (GetWeaponTableData(weaponNum)->isPanzer || GetWeaponTableData(weaponNum)->isMG || GetWeaponTableData(weaponNum)->isMGSet || weaponNum == WP_FLAMETHROWER)
// {
// if( skill[SK_HEAVY_WEAPONS] >= 1 )
// {
// maxAmmo += GetWeaponTableData(weaponNum)->maxclip;
// }
// }
// else if (GetWeaponTableData(weaponNum)->isMortar || GetWeaponTableData(weaponNum)->isMortarSet)
// {
// if( skill[SK_HEAVY_WEAPONS] >= 1 )
// {
// maxAmmo += 2;
// }
// }
else if (weaponNum == WP_MEDIC_SYRINGE /*|| weaponNum == WP_MEDIC_ADRENALINE*/) // FIXME: why adrenaline is not take in count for max ammo?
{
if (skill[SK_FIRST_AID] >= 2)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + 2);
maxAmmo += 2;
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
}
case WP_GARAND:
case WP_K43:
case WP_FG42:
}
else if (GetWeaponTableData(GetWeaponTableData(weaponNum)->weapAlts)->isScoped)
{
if (skill[SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS] >= 1 || skill[SK_LIGHT_WEAPONS] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + GetWeaponTableData(weaponNum)->maxClip);
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
maxAmmo += GetWeaponTableData(weaponNum)->maxClip;
}
case WP_GARAND_SCOPE:
case WP_K43_SCOPE:
case WP_FG42SCOPE:
}
else if (GetWeaponTableData(weaponNum)->isScoped)
{
if (skill[SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS] >= 1)
{
return(GetWeaponTableData(weaponNum)->maxAmmo + GetWeaponTableData(weaponNum)->maxClip);
maxAmmo += GetWeaponTableData(weaponNum)->maxClip;
}
else
{
return(GetWeaponTableData(weaponNum)->maxAmmo);
}
default:
return(GetWeaponTableData(weaponNum)->maxAmmo);
}
return maxAmmo;
}
/**
View
@@ -999,38 +999,29 @@ team_t PickTeam(int ignoreClientNum)
*/
static void AddExtraSpawnAmmo(gclient_t *client, weapon_t weaponNum)
{
// TODO: weapon table ?
switch (weaponNum)
{
//case WP_KNIFE:
case WP_LUGER:
case WP_COLT:
case WP_STEN:
case WP_SILENCER:
case WP_CARBINE:
case WP_KAR98:
case WP_SILENCED_COLT:
if (GetWeaponTableData(weaponNum)->isPistol || GetWeaponTableData(weaponNum)->isSilencedPistol || GetWeaponTableData(weaponNum)->isRifle || weaponNum == WP_STEN)
{
if (client->sess.skill[SK_LIGHT_WEAPONS] >= 1)
{
client->ps.ammo[BG_FindAmmoForWeapon(weaponNum)] += GetWeaponTableData(weaponNum)->maxClip;
}
break;
case WP_MP40:
case WP_THOMPSON:
}
else if (weaponNum == WP_MP40 || weaponNum == WP_THOMPSON)
{
if ((client->sess.skill[SK_FIRST_AID] >= 1 && client->sess.playerType == PC_MEDIC) || client->sess.skill[SK_LIGHT_WEAPONS] >= 1)
{
client->ps.ammo[BG_FindAmmoForWeapon(weaponNum)] += GetWeaponTableData(weaponNum)->maxClip;
}
break;
case WP_M7:
case WP_GPG40:
}
else if (GetWeaponTableData(weaponNum)->isRiflenade)
{
if (client->sess.skill[SK_EXPLOSIVES_AND_CONSTRUCTION] >= 1)
{
client->ps.ammo[BG_FindAmmoForWeapon(weaponNum)] += 4;
}
break;
case WP_GRENADE_PINEAPPLE:
case WP_GRENADE_LAUNCHER:
}
else if (GetWeaponTableData(weaponNum)->isGrenade)
{
if (client->sess.playerType == PC_ENGINEER)
{
if (client->sess.skill[SK_EXPLOSIVES_AND_CONSTRUCTION] >= 1)
@@ -1045,32 +1036,27 @@ static void AddExtraSpawnAmmo(gclient_t *client, weapon_t weaponNum)
client->ps.ammoclip[BG_FindAmmoForWeapon(weaponNum)] += 1;
}
}
break;
case WP_MEDIC_SYRINGE:
case WP_MEDIC_ADRENALINE:
}
else if (weaponNum == WP_MEDIC_SYRINGE || weaponNum == WP_MEDIC_ADRENALINE)
{
if (client->sess.skill[SK_FIRST_AID] >= 2)
{
client->ps.ammoclip[BG_FindAmmoForWeapon(weaponNum)] += 2;
}
break;
case WP_GARAND:
case WP_K43:
case WP_FG42:
}
else if (GetWeaponTableData(GetWeaponTableData(weaponNum)->weapAlts)->isScoped)
{
if (client->sess.skill[SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS] >= 1 || client->sess.skill[SK_LIGHT_WEAPONS] >= 1)
{
client->ps.ammo[BG_FindAmmoForWeapon(weaponNum)] += GetWeaponTableData(weaponNum)->maxClip;
}
break;
case WP_GARAND_SCOPE:
case WP_K43_SCOPE:
case WP_FG42SCOPE:
}
else if (GetWeaponTableData(weaponNum)->isScoped)
{
if (client->sess.skill[SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS] >= 1)
{
client->ps.ammo[BG_FindAmmoForWeapon(weaponNum)] += GetWeaponTableData(weaponNum)->maxClip;
}
break;
default:
break;
}
}
View
@@ -3685,18 +3685,13 @@ gentity_t *weapon_grenadelauncher_fire(gentity_t *ent, int grenType)
upangle = .1f;
}
// TODO: weapon table ?
switch (grenType)
if (GetWeaponTableData(grenType)->isGrenade || grenType == WP_SMOKE_MARKER || grenType == WP_SMOKE_BOMB)
{
case WP_GRENADE_LAUNCHER:
case WP_GRENADE_PINEAPPLE:
case WP_SMOKE_MARKER:
case WP_SMOKE_BOMB:
upangle *= 900;
break;
default: // WP_DYNAMITE / WP_LANDMINE / WP_SATCHEL
}
else // WP_DYNAMITE / WP_LANDMINE / WP_SATCHEL
{
upangle *= 400;
break;
}
VectorCopy(muzzleEffect, tosspos);

0 comments on commit 165886c

Please sign in to comment.