Preparting to add weapon_m82a1

This commit is contained in:
Kamay Xutax 2024-09-06 14:43:27 +02:00
parent 4f1c5397b6
commit 0affff43d5
26 changed files with 365 additions and 12 deletions

View file

@ -73,6 +73,7 @@ static const char * s_WeaponAliasInfo[] =
"galil", // WEAPON_GALIL
"famas", // WEAPON_FAMAS // CT cheap m4a1
"usp", // WEAPON_USP
"m82a1", // WEAPON_M82A1
"awp", // WEAPON_AWP
"mp5navy", // WEAPON_MP5N
"m249", // WEAPON_M249 // big machinegun

View file

@ -148,6 +148,7 @@ $Project "Client (CStrike)"
{
$File "$SRCDIR\game\shared\cstrike\weapon_ak47.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_aug.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_m82a1.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_awp.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_basecsgrenade.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_basecsgrenade.h"

View file

@ -421,7 +421,7 @@ static CSWeaponID s_secondaryWeapons[NUM_SECONDARY_WEAPONS] =
WEAPON_FIVESEVEN,
};
const int NUM_PRIMARY_WEAPONS = 23;
const int NUM_PRIMARY_WEAPONS = 24;
static CSWeaponID s_primaryWeapons[NUM_PRIMARY_WEAPONS] =
{
WEAPON_NONE,
@ -437,6 +437,7 @@ static CSWeaponID s_primaryWeapons[NUM_PRIMARY_WEAPONS] =
// Snipers
CSWeaponID(-WEAPONTYPE_SNIPER_RIFLE),
WEAPON_M82A1,
WEAPON_AWP,
WEAPON_SG550,
WEAPON_G3SG1,

View file

@ -399,8 +399,7 @@ void CCSBaseBuyMenu::UpdateBuyPresets( bool showDefaultPanel )
HandleBlackMarket();
}
const char *g_pWeaponNames[] =
{
const char* g_pWeaponNames[] = {
" ",
"#Cstrike_TitlesTXT_P228",
"#Cstrike_TitlesTXT_Glock18",
@ -418,6 +417,7 @@ const char *g_pWeaponNames[] =
"#Cstrike_TitlesTXT_Galil",
"#Cstrike_TitlesTXT_Famas",
"#Cstrike_TitlesTXT_USP45",
"#Cstrike_TitlesTXT_M82A1",
"#Cstrike_TitlesTXT_Magnum",
"#Cstrike_TitlesTXT_mp5navy",
"#Cstrike_TitlesTXT_ESM249",

View file

@ -203,6 +203,7 @@ void CStatsSummary::ApplySchemeSettings(vgui::IScheme *pScheme)
m_StatImageMap.Insert(CSSTAT_KILLS_P228, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/p228", true)));
m_StatImageMap.Insert(CSSTAT_KILLS_ELITE, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/elites", true)));
m_StatImageMap.Insert(CSSTAT_KILLS_FIVESEVEN, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/fiveseven", true)));
m_StatImageMap.Insert(CSSTAT_KILLS_M82A1, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/m82a1", true)));
m_StatImageMap.Insert(CSSTAT_KILLS_AWP, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/awp", true)));
m_StatImageMap.Insert(CSSTAT_KILLS_AK47, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/ak47", true)));
m_StatImageMap.Insert(CSSTAT_KILLS_M4A1, m_pImageList->AddImage(scheme()->GetImage("gfx/vgui/fav_weap/m4a1", true)));

View file

@ -8,6 +8,7 @@
#include "buy_preset_debug.h"
#include "buy_presets.h"
#include "cs_weapon_parse.h"
#include "weapon_csbase.h"
#include "cs_ammodef.h"
#include "cs_gamerules.h"
@ -776,6 +777,8 @@ const char *ImageFnameFromWeaponID( CSWeaponID weaponID, bool isPrimary )
return "gfx/vgui/galil";
case WEAPON_FAMAS:
return "gfx/vgui/famas";
case WEAPON_M82A1:
return "gfx/vgui/m82a1";
case WEAPON_AWP:
return "gfx/vgui/awp";
case WEAPON_MP5NAVY:

View file

@ -44,6 +44,7 @@ static WeaponDisplayNameInfo weaponDisplayNameInfo[] =
{ WEAPON_GALIL, "#Cstrike_TitlesTXT_Galil" },
{ WEAPON_FAMAS, "#Cstrike_TitlesTXT_Famas" },
{ WEAPON_USP, "#Cstrike_TitlesTXT_USP45" },
{ WEAPON_M82A1, "#Cstrike_TitlesTXT_M82A1" },
{ WEAPON_AWP, "#Cstrike_TitlesTXT_ArcticWarfareMagnum" },
{ WEAPON_MP5NAVY, "#Cstrike_TitlesTXT_mp5navy" },
{ WEAPON_M249, "#Cstrike_TitlesTXT_ESM249" },

View file

@ -819,8 +819,8 @@ CSPlayerState C_CSPlayer::State_Get() const
float C_CSPlayer::GetMinFOV() const
{
// Min FOV for AWP.
return 10;
// Min FOV for M82A1.
return 3;
}

View file

@ -4,7 +4,7 @@
// Desc: Manages client side stat storage, accumulation, and access
// Author: Peter Freese <peter@hiddenpath.com>
// Date: 2009/09/11
// Copyright: © 2009 Hidden Path Entertainment
// Copyright: <EFBFBD> 2009 Hidden Path Entertainment
//
// Keywords:
//-------------------------------------------------------------
@ -264,6 +264,7 @@ CON_COMMAND_F( stats_preload, "Load stats with data ripe for getting achievmenet
{ CSSTAT_KILLS_P228, 199},
{ CSSTAT_KILLS_ELITE, 99},
{ CSSTAT_KILLS_FIVESEVEN, 99},
{ CSSTAT_KILLS_M82A1, 999},
{ CSSTAT_KILLS_AWP, 999},
{ CSSTAT_KILLS_AK47, 999},
{ CSSTAT_KILLS_M4A1, 999},
@ -363,6 +364,7 @@ CON_COMMAND_F( stats_corrupt, "Load stats with corrupt values", FCVAR_DEVELOPMEN
{ CSSTAT_KILLS_P228, 0x00000000 },
{ CSSTAT_KILLS_ELITE, 0x00000000 },
{ CSSTAT_KILLS_FIVESEVEN, 0x00000000 },
{ CSSTAT_KILLS_M82A1, 0x00000000 },
{ CSSTAT_KILLS_AWP, 0x00000000 },
{ CSSTAT_KILLS_AK47, 0x00000001 },
{ CSSTAT_KILLS_M4A1, 0x00000000 },
@ -389,6 +391,7 @@ CON_COMMAND_F( stats_corrupt, "Load stats with corrupt values", FCVAR_DEVELOPMEN
{ CSSTAT_SHOTS_P228, 0x00000000 },
{ CSSTAT_SHOTS_ELITE, 0x00000000 },
{ CSSTAT_SHOTS_FIVESEVEN, 0x00000000 },
{ CSSTAT_SHOTS_M82A1, 0x00000000 },
{ CSSTAT_SHOTS_AWP, 0x00000000 },
{ CSSTAT_SHOTS_AK47, 0x0000000E },
{ CSSTAT_SHOTS_M4A1, 0x00000000 },
@ -413,6 +416,7 @@ CON_COMMAND_F( stats_corrupt, "Load stats with corrupt values", FCVAR_DEVELOPMEN
{ CSSTAT_HITS_P228, 0x00000000 },
{ CSSTAT_HITS_ELITE, 0x00000000 },
{ CSSTAT_HITS_FIVESEVEN, 0x00000000 },
{ CSSTAT_HITS_M82A1, 0x00000000 },
{ CSSTAT_HITS_AWP, 0x00000000 },
{ CSSTAT_HITS_AK47, 0x00000003 },
{ CSSTAT_HITS_M4A1, 0x00000000 },

View file

@ -14,6 +14,7 @@
#include "cs_bot.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "cs_weapon_parse.h"
#include "tier0/memdbgon.h"
//--------------------------------------------------------------------------------------------------------------
@ -95,6 +96,11 @@ void CCSBot::OnWeaponFire( IGameEvent *event )
range = 99999.0f;
break;
// very loud
case WEAPON_M82A1:
range = 10000000.0f;
break;
// normal
default:
range = NormalRange;

View file

@ -10,6 +10,7 @@
#include "cbase.h"
#include "cs_gamerules.h"
#include "cs_bot.h"
#include "cs_weapon_parse.h"
#include "fmtstr.h"
// memdbgon must be the last include file in a .cpp file!!!
@ -87,7 +88,7 @@ void CCSBot::Upkeep( void )
// spray the big machinegun at the enemy's gut
aimAtPart = GUT;
}
else if (IsUsing( WEAPON_AWP ) || IsUsingShotgun())
else if (IsUsing( WEAPON_AWP ) || IsUsingShotgun() || IsUsing( WEAPON_M82A1 ))
{
// these weapons are best aimed at the chest
aimAtPart = GUT;

View file

@ -12,6 +12,7 @@
#include "basecsgrenade_projectile.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "cs_weapon_parse.h"
#include "tier0/memdbgon.h"
//--------------------------------------------------------------------------------------------------------------
@ -61,7 +62,7 @@ void CCSBot::FireWeaponAtEnemy( void )
{
// check our accuracy versus our target distance
float fProjectedSpread = rangeToEnemy * GetActiveCSWeapon()->GetInaccuracy();
float fRequiredSpread = IsUsing( WEAPON_AWP ) ? 50.0f : 25.0f; // AWP will kill with any hit
float fRequiredSpread = (IsUsing( WEAPON_AWP ) || IsUsing( WEAPON_M82A1 )) ? 50.0f : 25.0f; // AWP will kill with any hit
if ( fProjectedSpread > fRequiredSpread )
return;
}
@ -1177,7 +1178,7 @@ void CCSBot::ReloadCheck( void )
}
// don't reload the AWP until it is totally out of ammo
if (IsUsing( WEAPON_AWP ) && !IsActiveWeaponClipEmpty())
if ((IsUsing( WEAPON_AWP ) || IsUsing( WEAPON_M82A1 )) && !IsActiveWeaponClipEmpty())
return;
Reload();

View file

@ -212,7 +212,7 @@ struct BuyInfo
const char *buyAlias; ///< the buy alias for this equipment
};
#define PRIMARY_WEAPON_BUY_COUNT 13
#define PRIMARY_WEAPON_BUY_COUNT 14
#define SECONDARY_WEAPON_BUY_COUNT 3
/**
@ -232,6 +232,7 @@ static BuyInfo primaryWeaponBuyInfoCT[ PRIMARY_WEAPON_BUY_COUNT ] =
{ RIFLE, true, "m4a1" }, // WEAPON_M4A1
{ RIFLE, false, "aug" }, // WEAPON_AUG
{ SNIPER_RIFLE, true, "sg550" }, // WEAPON_SG550
{ SNIPER_RIFLE, true, "m82a1" }, // WEAPON_M82A1
{ SNIPER_RIFLE, true, "awp" }, // WEAPON_AWP
{ MACHINE_GUN, false, "m249" } // WEAPON_M249
};
@ -258,6 +259,7 @@ static BuyInfo primaryWeaponBuyInfoT[ PRIMARY_WEAPON_BUY_COUNT ] =
{ RIFLE, true, "ak47" }, // WEAPON_AK47
{ SNIPER_RIFLE, false, "scout" }, // WEAPON_SCOUT
{ RIFLE, true, "sg552" }, // WEAPON_SG552
{ SNIPER_RIFLE, true, "m82a1" }, // WEAPON_M82A1
{ SNIPER_RIFLE, true, "awp" }, // WEAPON_AWP
{ SNIPER_RIFLE, true, "g3sg1" }, // WEAPON_G3SG1
{ MACHINE_GUN, false, "m249" } // WEAPON_M249

View file

@ -14,6 +14,7 @@ AutoBuyInfoStruct g_autoBuyInfo[] =
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), "ak47", "weapon_ak47" }, // ak47
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), "scout", "weapon_scout" }, // scout
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), "sg552", "weapon_sg552" }, // sg552
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), "m82a1", "weapon_m82a1" }, // m82a1
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), "awp", "weapon_awp" }, // awp
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), "g3sg1", "weapon_g3sg1" }, // g3sg1
{ (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), "famas", "weapon_famas" }, // famas

View file

@ -14,6 +14,7 @@
#include <tier0/platform.h>
#include "cs_gamerules.h"
#include "cs_gamestats.h"
#include "cs_weapon_parse.h"
#include "weapon_csbase.h"
#include "props.h"
#include "cs_achievement_constants.h"
@ -1042,7 +1043,8 @@ void CCSGameStats::Event_PlayerKilledOther( CBasePlayer *pAttacker, CBaseEntity
bool bUsingSniper = ( weaponId == WEAPON_AWP ||
weaponId == WEAPON_SCOUT ||
weaponId == WEAPON_SG550 ||
weaponId == WEAPON_G3SG1 );
weaponId == WEAPON_G3SG1 ||
weaponId == WEAPON_M82A1 );
// If we're zoomed in
if ( bUsingSniper && pPlayerAttacker->GetFOV() != pPlayerAttacker->GetDefaultFOV() )

View file

@ -4460,6 +4460,7 @@ bool CCSPlayer::ClientCommand( const CCommand &args )
ClientPrint( this, msg_dest, " ak47\n" );
ClientPrint( this, msg_dest, " scout\n" );
ClientPrint( this, msg_dest, " sg552\n" );
ClientPrint( this, msg_dest, " m82a1\n" );
ClientPrint( this, msg_dest, " awp\n" );
ClientPrint( this, msg_dest, " g3sg1\n" );
ClientPrint( this, msg_dest, " famas\n" );

View file

@ -131,6 +131,7 @@ $Project "Server (CStrike)"
{
$File "$SRCDIR\game\shared\cstrike\weapon_ak47.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_aug.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_m82a1.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_awp.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_basecsgrenade.cpp"
$File "$SRCDIR\game\shared\cstrike\weapon_basecsgrenade.h"

View file

@ -288,6 +288,7 @@ DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsP228, "KILL_ENEMY_P228", 5, CSST
DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsElite, "KILL_ENEMY_ELITE", 5, CSSTAT_KILLS_ELITE, 100); //100
DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsFiveSeven, "KILL_ENEMY_FIVESEVEN", 5, CSSTAT_KILLS_FIVESEVEN, 100); //100
DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsM82A1, "KILL_ENEMY_M82A1", 5, CSSTAT_KILLS_M82A1, 1000); //1000
DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsAWP, "KILL_ENEMY_AWP", 5, CSSTAT_KILLS_AWP, 1000); //1000
DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsAK47, "KILL_ENEMY_AK47", 5, CSSTAT_KILLS_AK47, 1000); //1000
DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsM4A1, "KILL_ENEMY_M4A1", 5, CSSTAT_KILLS_M4A1, 1000); //1000
@ -485,6 +486,7 @@ class CAchievementCS_RifleMaster : public CAchievement_Meta
virtual void Init()
{
BaseClass::Init();
AddRequirement(CSEnemyKillsM82A1);
AddRequirement(CSEnemyKillsAWP);
AddRequirement(CSEnemyKillsAK47);
AddRequirement(CSEnemyKillsM4A1);

View file

@ -108,6 +108,7 @@ typedef enum
CSEnemyKillsP228,
CSEnemyKillsElite,
CSEnemyKillsFiveSeven,
CSEnemyKillsM82A1,
CSEnemyKillsAWP,
CSEnemyKillsAK47,
CSEnemyKillsM4A1,

View file

@ -5,6 +5,7 @@
//=============================================================================//
#include "cbase.h"
#include "cs_weapon_parse.h"
#include "fmtstr.h"
#ifdef GAME_DLL
#include "gamestats.h"
@ -44,6 +45,7 @@ const WeaponName_StatId WeaponName_StatId_Table[] =
{ WEAPON_P228, CSSTAT_KILLS_P228, CSSTAT_SHOTS_P228, CSSTAT_HITS_P228, CSSTAT_DAMAGE_P228 },
{ WEAPON_ELITE, CSSTAT_KILLS_ELITE, CSSTAT_SHOTS_ELITE, CSSTAT_HITS_ELITE, CSSTAT_DAMAGE_ELITE },
{ WEAPON_FIVESEVEN, CSSTAT_KILLS_FIVESEVEN, CSSTAT_SHOTS_FIVESEVEN, CSSTAT_HITS_FIVESEVEN, CSSTAT_DAMAGE_FIVESEVEN },
{ WEAPON_M82A1, CSSTAT_KILLS_M82A1, CSSTAT_SHOTS_M82A1, CSSTAT_HITS_M82A1, CSSTAT_DAMAGE_M82A1 },
{ WEAPON_AWP, CSSTAT_KILLS_AWP, CSSTAT_SHOTS_AWP, CSSTAT_HITS_AWP, CSSTAT_DAMAGE_AWP },
{ WEAPON_AK47, CSSTAT_KILLS_AK47, CSSTAT_SHOTS_AK47, CSSTAT_HITS_AK47, CSSTAT_DAMAGE_AK47 },
{ WEAPON_M4A1, CSSTAT_KILLS_M4A1, CSSTAT_SHOTS_M4A1, CSSTAT_HITS_M4A1, CSSTAT_DAMAGE_M4A1 },
@ -94,6 +96,7 @@ CSStatProperty CSStatProperty_Table[] =
{ CSSTAT_KILLS_P228, "total_kills_p228", "#GAMEUI_Stat_P228Kills", CSSTAT_PRIORITY_HIGH, },
{ CSSTAT_KILLS_ELITE, "total_kills_elite", "#GAMEUI_Stat_EliteKills", CSSTAT_PRIORITY_HIGH, },
{ CSSTAT_KILLS_FIVESEVEN, "total_kills_fiveseven", "#GAMEUI_Stat_FiveSevenKills", CSSTAT_PRIORITY_HIGH, },
{ CSSTAT_KILLS_M82A1, "total_kills_m82a1", "#GAMEUI_Stat_M82A1Kills", CSSTAT_PRIORITY_HIGH, },
{ CSSTAT_KILLS_AWP, "total_kills_awp", "#GAMEUI_Stat_AWPKills", CSSTAT_PRIORITY_HIGH, },
{ CSSTAT_KILLS_AK47, "total_kills_ak47", "#GAMEUI_Stat_AK47Kills", CSSTAT_PRIORITY_HIGH, },
{ CSSTAT_KILLS_M4A1, "total_kills_m4a1", "#GAMEUI_Stat_M4A1Kills", CSSTAT_PRIORITY_HIGH, },
@ -121,6 +124,7 @@ CSStatProperty CSStatProperty_Table[] =
{ CSSTAT_SHOTS_P228, "total_shots_p228", "#GAMEUI_Stat_P228Shots", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_SHOTS_ELITE, "total_shots_elite", "#GAMEUI_Stat_EliteShots", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_SHOTS_FIVESEVEN, "total_shots_fiveseven", "#GAMEUI_Stat_FiveSevenShots", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_SHOTS_M82A1, "total_shots_m82a1", "#GAMEUI_Stat_M82A1Shots", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_SHOTS_AWP, "total_shots_awp", "#GAMEUI_Stat_AWPShots", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_SHOTS_AK47, "total_shots_ak47", "#GAMEUI_Stat_AK47Shots", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_SHOTS_M4A1, "total_shots_m4a1", "#GAMEUI_Stat_M4A1Shots", CSSTAT_PRIORITY_LOW, },
@ -148,6 +152,7 @@ CSStatProperty CSStatProperty_Table[] =
{ CSSTAT_HITS_P228, "total_hits_p228", "#GAMEUI_Stat_P228Hits", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_HITS_ELITE, "total_hits_elite", "#GAMEUI_Stat_EliteHits", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_HITS_FIVESEVEN, "total_hits_fiveseven", "#GAMEUI_Stat_FiveSevenHits", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_HITS_M82A1, "total_hits_m82a1", "#GAMEUI_Stat_M82A1Hits", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_HITS_AWP, "total_hits_awp", "#GAMEUI_Stat_AWPHits", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_HITS_AK47, "total_hits_ak47", "#GAMEUI_Stat_AK47Hits", CSSTAT_PRIORITY_LOW, },
{ CSSTAT_HITS_M4A1, "total_hits_m4a1", "#GAMEUI_Stat_M4A1Hits", CSSTAT_PRIORITY_LOW, },
@ -175,6 +180,7 @@ CSStatProperty CSStatProperty_Table[] =
{ CSSTAT_DAMAGE_P228, NULL, NULL, CSSTAT_PRIORITY_NEVER, },
{ CSSTAT_DAMAGE_ELITE, NULL, NULL, CSSTAT_PRIORITY_NEVER, },
{ CSSTAT_DAMAGE_FIVESEVEN, NULL, NULL, CSSTAT_PRIORITY_NEVER, },
{ CSSTAT_DAMAGE_M82A1, NULL, NULL, CSSTAT_PRIORITY_NEVER, },
{ CSSTAT_DAMAGE_AWP, NULL, NULL, CSSTAT_PRIORITY_NEVER, },
{ CSSTAT_DAMAGE_AK47, NULL, NULL, CSSTAT_PRIORITY_NEVER, },
{ CSSTAT_DAMAGE_M4A1, NULL, NULL, CSSTAT_PRIORITY_NEVER, },

View file

@ -87,6 +87,7 @@ enum CSStatType_t
CSSTAT_KILLS_P228,
CSSTAT_KILLS_ELITE,
CSSTAT_KILLS_FIVESEVEN,
CSSTAT_KILLS_M82A1,
CSSTAT_KILLS_AWP,
CSSTAT_KILLS_AK47,
CSSTAT_KILLS_M4A1,
@ -114,6 +115,7 @@ enum CSStatType_t
CSSTAT_SHOTS_P228,
CSSTAT_SHOTS_ELITE,
CSSTAT_SHOTS_FIVESEVEN,
CSSTAT_SHOTS_M82A1,
CSSTAT_SHOTS_AWP,
CSSTAT_SHOTS_AK47,
CSSTAT_SHOTS_M4A1,
@ -141,6 +143,7 @@ enum CSStatType_t
CSSTAT_HITS_P228,
CSSTAT_HITS_ELITE,
CSSTAT_HITS_FIVESEVEN,
CSSTAT_HITS_M82A1,
CSSTAT_HITS_AWP,
CSSTAT_HITS_AK47,
CSSTAT_HITS_M4A1,
@ -168,6 +171,7 @@ enum CSStatType_t
CSSTAT_DAMAGE_P228,
CSSTAT_DAMAGE_ELITE,
CSSTAT_DAMAGE_FIVESEVEN,
CSSTAT_DAMAGE_M82A1,
CSSTAT_DAMAGE_AWP,
CSSTAT_DAMAGE_AK47,
CSSTAT_DAMAGE_M4A1,

View file

@ -68,6 +68,7 @@ WeaponNameInfo s_weaponNameInfo[] =
{ WEAPON_FAMAS, "weapon_famas" },
{ WEAPON_USP, "weapon_usp" },
{ WEAPON_AWP, "weapon_awp" },
{ WEAPON_M82A1, "weapon_m82a1" },
{ WEAPON_MP5NAVY, "weapon_mp5navy" },
{ WEAPON_M249, "weapon_m249" },
{ WEAPON_M3, "weapon_m3" },

View file

@ -54,6 +54,7 @@ enum CSWeaponID
WEAPON_GALIL,
WEAPON_FAMAS,
WEAPON_USP,
WEAPON_M82A1,
WEAPON_AWP,
WEAPON_MP5NAVY,
WEAPON_M249,

View file

@ -6,6 +6,7 @@
//=============================================================================//
#include "cbase.h"
#include "cs_weapon_parse.h"
#include "in_buttons.h"
#include "takedamageinfo.h"
#include "weapon_csbase.h"
@ -37,7 +38,7 @@
#endif
ConVar weapon_accuracy_model( "weapon_accuracy_model", "2", FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY | FCVAR_ARCHIVE );
ConVar weapon_accuracy_model( "weapon_accuracy_model", "1", FCVAR_REPLICATED );
// ----------------------------------------------------------------------------- //
@ -57,6 +58,7 @@ static const WeaponAliasTranslationInfoStruct s_WeaponAliasTranslationInfo[] =
{ "cv47", "ak47" },
{ "defender", "galil" },
{ "krieg552", "sg552" },
{ "m82a1", "m82a1" },
{ "magnum", "awp" },
{ "d3au1", "g3sg1" },
{ "clarion", "famas" },
@ -105,6 +107,7 @@ WeaponAliasInfo s_weaponAliasInfo[] =
{ WEAPON_GALIL, "galil" },
{ WEAPON_FAMAS, "famas" },
{ WEAPON_USP, "usp" },
{ WEAPON_M82A1, "m82a1" },
{ WEAPON_AWP, "awp" },
{ WEAPON_MP5NAVY, "mp5navy" },
{ WEAPON_M249, "m249" },

View file

@ -0,0 +1,305 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "weapon_csbasegun.h"
#if defined( CLIENT_DLL )
#define CWeaponM82A1 C_WeaponM82A1
#include "c_cs_player.h"
#else
#include "cs_player.h"
#include "KeyValues.h"
#endif
#define SNIPER_ZOOM_CONTEXT "SniperRifleThink"
enum FOVContext_t
{
FOV_SCOPE_1,
FOV_SCOPE_2,
FOV_SCOPE_3,
FOV_MAX
};
static constexpr int FOVValues[FOV_MAX] = { 40, 10, 3 };
#ifdef M82A1_UNZOOM
ConVar sv_m82a1unzoomdelay(
"sv_m82a1unzoomdelay",
"1.0",
0,
"how many seconds to zoom the zoom up after firing",
true, 0, // min value
false, 0 // max value
);
#endif
class CWeaponM82A1 : public CWeaponCSBaseGun
{
public:
DECLARE_CLASS( CWeaponM82A1, CWeaponCSBaseGun );
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
#ifndef CLIENT_DLL
DECLARE_DATADESC();
#endif
CWeaponM82A1();
virtual void Spawn();
virtual void PrimaryAttack();
virtual void SecondaryAttack();
virtual float GetInaccuracy() const;
virtual float GetMaxSpeed() const;
virtual bool IsM82a1() const;
virtual bool Reload();
virtual bool Deploy();
virtual CSWeaponID GetWeaponID( void ) const { return WEAPON_M82A1; }
private:
int m_iLastZoom;
#ifdef M82A1_UNZOOM
void UnzoomThink( void );
#endif
CWeaponM82A1( const CWeaponM82A1 & );
};
IMPLEMENT_NETWORKCLASS_ALIASED( WeaponM82A1, DT_WeaponM82A1 )
BEGIN_NETWORK_TABLE( CWeaponM82A1, DT_WeaponM82A1 )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CWeaponM82A1 )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( weapon_m82a1, CWeaponM82A1 );
PRECACHE_WEAPON_REGISTER( weapon_m82a1 );
#ifndef CLIENT_DLL
BEGIN_DATADESC( CWeaponM82A1 )
#ifdef M82A1_UNZOOM
DEFINE_THINKFUNC( UnzoomThink ),
#endif
END_DATADESC()
#endif
CWeaponM82A1::CWeaponM82A1()
{
}
void CWeaponM82A1::Spawn()
{
Precache();
BaseClass::Spawn();
}
void CWeaponM82A1::SecondaryAttack()
{
const float kZoomTime = 0.15f;
CCSPlayer *pPlayer = GetPlayerOwner();
if ( pPlayer == NULL )
{
Assert( pPlayer != NULL );
return;
}
if ( pPlayer->GetFOV() == pPlayer->GetDefaultFOV() )
{
pPlayer->SetFOV( pPlayer, FOVValues[FOV_SCOPE_1], kZoomTime );
m_weaponMode = Secondary_Mode;
m_fAccuracyPenalty += GetCSWpnData().m_fInaccuracyAltSwitch;
}
else if ( pPlayer->GetFOV() == FOVValues[FOV_SCOPE_1] )
{
pPlayer->SetFOV( pPlayer, FOVValues[FOV_SCOPE_2], kZoomTime );
m_weaponMode = Secondary_Mode;
}
else if ( pPlayer->GetFOV() == FOVValues[FOV_SCOPE_2] )
{
pPlayer->SetFOV( pPlayer, FOVValues[FOV_SCOPE_3], kZoomTime );
m_weaponMode = Secondary_Mode;
}
else
{
pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), kZoomTime );
m_weaponMode = Primary_Mode;
}
m_iLastZoom = pPlayer->GetFOV();
#ifndef CLIENT_DLL
// If this isn't guarded, the sound will be emitted twice, once by the server and once by the client.
// Let the server play it since if only the client plays it, it's liable to get played twice cause of
// a prediction error. joy.
//=============================================================================
// HPE_BEGIN:
// [tj] Playing this from the player so that we don't try to play the sound outside the level.
//=============================================================================
if ( GetPlayerOwner() )
{
GetPlayerOwner()->EmitSound( "Default.Zoom" );
}
//=============================================================================
// HPE_END
//=============================================================================
// let the bots hear the rifle zoom
IGameEvent * event = gameeventmanager->CreateEvent( "weapon_zoom" );
if ( event )
{
event->SetInt( "userid", pPlayer->GetUserID() );
gameeventmanager->FireEvent( event );
}
#endif
m_flNextSecondaryAttack = gpGlobals->curtime + 0.4f;
m_zoomFullyActiveTime = gpGlobals->curtime + 0.2f;
}
float CWeaponM82A1::GetInaccuracy() const
{
if ( weapon_accuracy_model.GetInt() == 1 )
{
CCSPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return 0.0f;
float fSpread = 0.0f;
if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
fSpread = 0.85f;
else if ( pPlayer->GetAbsVelocity().Length2D() > 140 )
fSpread = 0.25f;
else if ( pPlayer->GetAbsVelocity().Length2D() > 10 )
fSpread = 0.10f;
else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
fSpread = 0.0f;
else
fSpread = 0.0f;
return fSpread;
}
else
{
return BaseClass::GetInaccuracy();
}
}
void CWeaponM82A1::PrimaryAttack()
{
CCSPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
if ( !CSBaseGunFire( GetCSWpnData().m_flCycleTime, m_weaponMode ) )
return;
if ( m_weaponMode == Secondary_Mode )
{
pPlayer->m_iLastZoom = m_iLastZoom;
#ifdef M82A1_UNZOOM
SetContextThink( &CWeaponM82A1::UnzoomThink, gpGlobals->curtime + sv_m82a1unzoomdelay.GetFloat(), SNIPER_ZOOM_CONTEXT );
#else
pPlayer->m_bResumeZoom = true;
pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.1f );
m_weaponMode = Primary_Mode;
#endif
}
QAngle angle = pPlayer->GetPunchAngle();
angle.x -= 5;
pPlayer->SetPunchAngle( angle );
}
#ifdef M82A1_UNZOOM
void CWeaponM82A1::UnzoomThink( void )
{
CCSPlayer *pPlayer = GetPlayerOwner();
if (pPlayer == NULL)
{
Assert(pPlayer != NULL);
return;
}
pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.1f );
}
#endif
float CWeaponM82A1::GetMaxSpeed() const
{
CCSPlayer *pPlayer = GetPlayerOwner();
if (pPlayer == NULL)
{
Assert(pPlayer != NULL);
return BaseClass::GetMaxSpeed();
}
if ( pPlayer->GetFOV() == pPlayer->GetDefaultFOV() )
{
return BaseClass::GetMaxSpeed();
}
else
{
// Slower speed when zoomed in.
return 100;
}
}
bool CWeaponM82A1::IsM82a1() const
{
return true;
}
bool CWeaponM82A1::Reload()
{
m_weaponMode = Primary_Mode;
return BaseClass::Reload();
}
bool CWeaponM82A1::Deploy()
{
// don't allow weapon switching to shortcut cycle time (quickswitch exploit)
float fOldNextPrimaryAttack = m_flNextPrimaryAttack;
float fOldNextSecondaryAttack = m_flNextSecondaryAttack;
if ( !BaseClass::Deploy() )
return false;
m_weaponMode = Primary_Mode;
m_flNextPrimaryAttack = MAX( m_flNextPrimaryAttack, fOldNextPrimaryAttack );
m_flNextSecondaryAttack = MAX( m_flNextSecondaryAttack, fOldNextSecondaryAttack );
return true;
}

View file

@ -50,6 +50,7 @@ enum CSWeaponID
WEAPON_GALIL,
WEAPON_FAMAS,
WEAPON_USP,
WEAPON_M82A1,
WEAPON_AWP,
WEAPON_MP5NAVY,
WEAPON_M249,
@ -124,6 +125,7 @@ static weapons_t g_Weapons[] =
{ WEAPON_EVERYTHING, 2000, WEAPON_GALIL, 0, 0, },
{ WEAPON_EVERYTHING, 2250, WEAPON_FAMAS, 0, 0, },
{ WEAPON_PISTOL, 500, WEAPON_USP, 0, 0, },
{ WEAPON_EVERYTHING, 10000, WEAPON_M82A1, 0, 0, },
{ WEAPON_EVERYTHING, 4750, WEAPON_AWP, 0, 0, },
{ WEAPON_EVERYTHING, 1500, WEAPON_MP5NAVY, 0, 0, },
{ WEAPON_EVERYTHING, 5750, WEAPON_M249, 0, 0, },
@ -162,6 +164,7 @@ const char * s_WeaponAliasInfo[] =
"galil", // WEAPON_GALIL
"famas", // WEAPON_FAMAS // CT cheap m4a1
"usp", // WEAPON_USP
"m82a1", // WEAPON_M82A1
"awp", // WEAPON_AWP
"mp5navy", // WEAPON_MP5N
"m249", // WEAPON_M249 // big machinegun