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
3 changes: 2 additions & 1 deletion src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,8 @@ target_sources_grouped(
TARGET client
NAME "Source Files\\Shared\\Weapons"
FILES
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.h
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.h
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.cpp
Expand Down Expand Up @@ -1816,4 +1818,3 @@ target_sources_grouped(
${CMAKE_SOURCE_DIR}/game/client/NextBot/C_NextBot.cpp
${CMAKE_SOURCE_DIR}/game/client/NextBot/C_NextBot.h
)

2 changes: 1 addition & 1 deletion src/game/client/hl2mp/clientmode_hl2mpnormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ float ClientModeHL2MPNormal::GetViewModelFOV()
m_bViewAim = true;
}

const CHL2MPSWeaponInfo* pWepInfo = &pWeapon->GetHL2MPWpnData();
const CNEOWeaponInfo* pWepInfo = &pWeapon->GetNEOWpnData();
Assert(pWepInfo);

const float endAimingChange = m_flStartAimingChange + NEO_ZOOM_SPEED;
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/neo/ui/neo_hud_ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void CNEOHud_Ammo::DrawAmmo() const
{
char fireModeText[2]{ '\0' };

ammoChar = activeWep->GetWpnData().szBulletCharacter;
ammoChar = activeWep->GetNEOWpnData().szBulletCharacter;
magSizeMax = activeWep->GetMaxClip1();
magSizeCurrent = activeWep->Clip1();

Expand Down
2 changes: 2 additions & 0 deletions src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,8 @@ target_sources_grouped(
TARGET server
NAME "NEO\\Weapons"
FILES
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.h
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.h
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,7 @@ void CNEO_Player::Weapon_DropAllOnDeath( const CTakeDamageInfo &info )

void CNEO_Player::Weapon_DropOnDeath(CNEOBaseCombatWeapon* pNeoWeapon, Vector damageForce)
{
if (!pNeoWeapon->GetWpnData().m_bDropOnDeath)
if (!pNeoWeapon->GetNEOWpnData().m_bDropOnDeath)
{ // Can't drop this weapon on death, remove it
UTIL_Remove(pNeoWeapon);
return;
Expand Down
12 changes: 0 additions & 12 deletions src/game/shared/basecombatweapon_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,7 @@ const FileWeaponInfo_t &CBaseCombatWeapon::GetWpnData( void ) const
//-----------------------------------------------------------------------------
const char *CBaseCombatWeapon::GetViewModel( int /*viewmodelindex = 0 -- this is ignored in the base class here*/ ) const
{
#ifdef NEO
auto owner = GetOwner();

if (!owner)
{
return GetWpnData().szViewModel;
}

return owner->GetTeamNumber() == TEAM_JINRAI ?
GetWpnData().szViewModel : GetWpnData().szViewModel2;
#else
return GetWpnData().szViewModel;
#endif
}

//-----------------------------------------------------------------------------
Expand Down
67 changes: 2 additions & 65 deletions src/game/shared/hl2mp/hl2mp_weapon_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,22 @@
#include "hl2mp_weapon_parse.h"
#include "ammodef.h"

#ifndef NEO
FileWeaponInfo_t* CreateWeaponInfo()
{
return new CHL2MPSWeaponInfo;
}


#endif

CHL2MPSWeaponInfo::CHL2MPSWeaponInfo()
{
m_iPlayerDamage = 0;

#ifdef NEO
m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin;
m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle;
#endif
}


void CHL2MPSWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )
{
BaseClass::Parse( pKeyValuesData, szWeaponName );

#ifndef NEO
m_iPlayerDamage = pKeyValuesData->GetInt( "damage", 0 );
#endif
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.

Dunno if you were getting a warning that was blocking the build, but wonder if we could actually keep the #ifndef NEO here so that we don't set m_iPLayerDamage twice, since this value may get clobbered and never used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea was to restore this file to it's original state. In general I think we should avoid ifdefs unless absolutely necessary.

  • If the script only contains "Damage" this will set it to 0, and then our subclass overwrites it with the correct value.
  • If the script only contains "damage" this will read that value, and then our subclass will default to 42.
  • If the script contains no damage entry, this will set it to 0 and then our subclass will default to 42.

So ifdefing out this line would have no effect as far as I can tell.


#ifdef NEO
m_iPlayerDamage = pKeyValuesData->GetInt("Damage", 0);
if (m_iPlayerDamage == 0)
{
m_iPlayerDamage = pKeyValuesData->GetInt("damage", 0);
}

KeyValues *pViewModel = pKeyValuesData->FindKey("ViewModelOffset");
if (pViewModel)
{
m_flVMFov = pKeyValuesData->GetFloat("VMFov", 60);

m_vecVMPosOffset.x = pViewModel->GetFloat("forward", 0);
m_vecVMPosOffset.y = pViewModel->GetFloat("right", 0);
m_vecVMPosOffset.z = pViewModel->GetFloat("up", 0);

m_angVMAngOffset[PITCH] = pViewModel->GetFloat("pitch", 0);
m_angVMAngOffset[YAW] = pViewModel->GetFloat("yaw", 0);
m_angVMAngOffset[ROLL] = pViewModel->GetFloat("roll", 0);
}

// NEO TODO (Rain): add optional ironsight offsets
// in addition to "traditional" NT aim

// AimOffset = Ironsight ADS offset (Disabled)
// ZoomOffset = Traditional ADS offset
#if 0
KeyValues *pAimOffset = pKeyValuesData->FindKey("AimOffset");
#else
KeyValues* pAimOffset = pKeyValuesData->FindKey("ZoomOffset");
#endif
if (pAimOffset)
{
m_flVMAimFov = pAimOffset->GetFloat("fov", 55);

m_vecVMAimPosOffset.x = pAimOffset->GetFloat("forward", 0);
m_vecVMAimPosOffset.y = pAimOffset->GetFloat("right", 0);
m_vecVMAimPosOffset.z = pAimOffset->GetFloat("up", 0);

m_angVMAimAngOffset[PITCH] = pAimOffset->GetFloat("pitch", 0);
m_angVMAimAngOffset[YAW] = pAimOffset->GetFloat("yaw", 0);
m_angVMAimAngOffset[ROLL] = pAimOffset->GetFloat("roll", 0);
}

// Get CycleTime AKA Fire-rate
m_flCycleTime = pKeyValuesData->GetFloat("CycleTime", 0.0f);
#ifdef _DEBUG
const char *printName = pKeyValuesData->GetString("printname");
if (!V_strstr(printName, "#HL2") && !V_strstr(printName, "Grenade"))
{
Assert(m_flCycleTime != 0.0f);
}
#endif
#endif
}

12 changes: 0 additions & 12 deletions src/game/shared/hl2mp/hl2mp_weapon_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ class CHL2MPSWeaponInfo : public FileWeaponInfo_t
public:

int m_iPlayerDamage;

#ifdef NEO
float m_flVMFov = 0.0f;
Vector m_vecVMPosOffset;
QAngle m_angVMAngOffset;

float m_flVMAimFov = 0.0f;
Vector m_vecVMAimPosOffset;
QAngle m_angVMAimAngOffset;

float m_flCycleTime = 0.0f;
#endif
};


Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/neo/neo_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4324,7 +4324,7 @@ void CNEORules::DeathNotice(CBasePlayer* pVictim, const CTakeDamageInfo& info)
}
else if (neoWep)
{
event->SetString("deathIcon", neoWep->GetWpnData().szDeathIcon);
event->SetString("deathIcon", neoWep->GetNEOWpnData().szDeathIcon);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/neo/neo_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void KillerLineStr(char* killByLine, const int killByLineMax,
{
static constexpr float FOV_AIM_OFFSET_FALLBACK = 30.0f;
auto *neoWep = dynamic_cast<CNEOBaseCombatWeapon *>(wep);
return (neoWep) ? neoWep->GetWpnData().iAimFOV : fovDef - FOV_AIM_OFFSET_FALLBACK;
return (neoWep) ? neoWep->GetNEOWpnData().iAimFOV : fovDef - FOV_AIM_OFFSET_FALLBACK;
}

#ifdef CLIENT_DLL
Expand Down
6 changes: 3 additions & 3 deletions src/game/shared/neo/neo_predicted_viewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "in_buttons.h"
#include "neo_gamerules.h"
#include "weapon_hl2mpbase.h"
#include "weapon_neobasecombatweapon.h"

#ifdef CLIENT_DLL
#include "c_neo_player.h"
Expand Down Expand Up @@ -480,14 +480,14 @@ void CNEOPredictedViewModel::CalcViewModelView(CBasePlayer *pOwner,
}

// Is there a nicer way to do this?
auto weapon = static_cast<CWeaponHL2MPBase*>(GetOwningWeapon());
auto weapon = static_cast<CNEOBaseCombatWeapon*>(GetOwningWeapon());

if (!weapon)
{
return;
}

CHL2MPSWeaponInfo data = weapon->GetHL2MPWpnData();
CNEOWeaponInfo data = weapon->GetNEOWpnData();

Vector vForward, vRight, vUp, newPos, vOffset;
QAngle newAng, angOffset;
Expand Down
95 changes: 95 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//

#include <KeyValues.h>
#include "neo_weapon_parse.h"


FileWeaponInfo_t* CreateWeaponInfo()
{
return new CNEOWeaponInfo;
}


CNEOWeaponInfo::CNEOWeaponInfo()
{
m_iBullets = 0;
m_flCycleTime = 0.f;
szViewModel2[0] = 0;
szBulletCharacter[0] = 0;
szDeathIcon[0] = 0;
m_flPenetration = 0.f;
m_bDropOnDeath = true;
iAimFOV = 0;

m_flVMFov = m_flVMAimFov = 0.f;
m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin;
m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle;
}


void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )
{
BaseClass::Parse( pKeyValuesData, szWeaponName );

m_iPlayerDamage = pKeyValuesData->GetInt( "Damage", 42 ); // Douglas Adams 1952 - 2001
m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 );
m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 );

const char *notFoundStr = "notfound";
Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING);
// If there was no NSF viewmodel specified, fall back to Source's default "viewmodel" to ensure we have something sensible available.
// This might happen when attempting to equip a non-NT weapon.
if (Q_strcmp(szViewModel2, notFoundStr) == 0)
{
Q_strncpy(szViewModel2, pKeyValuesData->GetString("viewmodel"), MAX_WEAPON_STRING);
}

Q_strncpy( szBulletCharacter, pKeyValuesData->GetString("BulletCharacter", "a"), MAX_BULLET_CHARACTER);
Q_strncpy( szDeathIcon, pKeyValuesData->GetString("iDeathIcon", ""), MAX_BULLET_CHARACTER);
m_flPenetration = pKeyValuesData->GetFloat("Penetration", 0);
m_bDropOnDeath = pKeyValuesData->GetBool("DropOnDeath", true);
iAimFOV = pKeyValuesData->GetInt("AimFov", 45);

KeyValues *pViewModel = pKeyValuesData->FindKey("ViewModelOffset");
if (pViewModel)
{
m_flVMFov = pKeyValuesData->GetFloat("VMFov", 60);

m_vecVMPosOffset.x = pViewModel->GetFloat("forward", 0);
m_vecVMPosOffset.y = pViewModel->GetFloat("right", 0);
m_vecVMPosOffset.z = pViewModel->GetFloat("up", 0);

m_angVMAngOffset[PITCH] = pViewModel->GetFloat("pitch", 0);
m_angVMAngOffset[YAW] = pViewModel->GetFloat("yaw", 0);
m_angVMAngOffset[ROLL] = pViewModel->GetFloat("roll", 0);
}

// NEO TODO (Rain): add optional ironsight offsets
// in addition to "traditional" NT aim

// AimOffset = Ironsight ADS offset (Disabled)
// ZoomOffset = Traditional ADS offset
#if 0
KeyValues *pAimOffset = pKeyValuesData->FindKey("AimOffset");
#else
KeyValues* pAimOffset = pKeyValuesData->FindKey("ZoomOffset");
#endif
if (pAimOffset)
{
m_flVMAimFov = pAimOffset->GetFloat("fov", 55);

m_vecVMAimPosOffset.x = pAimOffset->GetFloat("forward", 0);
m_vecVMAimPosOffset.y = pAimOffset->GetFloat("right", 0);
m_vecVMAimPosOffset.z = pAimOffset->GetFloat("up", 0);

m_angVMAimAngOffset[PITCH] = pAimOffset->GetFloat("pitch", 0);
m_angVMAimAngOffset[YAW] = pAimOffset->GetFloat("yaw", 0);
m_angVMAimAngOffset[ROLL] = pAimOffset->GetFloat("roll", 0);
}
}


44 changes: 44 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//

#ifndef NEO_WEAPON_PARSE_H
#define NEO_WEAPON_PARSE_H
#ifdef _WIN32
#pragma once
#endif

#include "hl2mp_weapon_parse.h"

//--------------------------------------------------------------------------------------------------------
class CNEOWeaponInfo : public CHL2MPSWeaponInfo
{
public:
DECLARE_CLASS_GAMEROOT( CNEOWeaponInfo, CHL2MPSWeaponInfo );

CNEOWeaponInfo();

virtual void Parse( ::KeyValues *pKeyValuesData, const char *szWeaponName );

int m_iBullets;
float m_flCycleTime;
char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm
char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip
char szDeathIcon[MAX_BULLET_CHARACTER];
float m_flPenetration;
bool m_bDropOnDeath;
int iAimFOV;

float m_flVMFov;
Vector m_vecVMPosOffset;
QAngle m_angVMAngOffset;

float m_flVMAimFov;
Vector m_vecVMAimPosOffset;
QAngle m_angVMAimAngOffset;
};


#endif // NEO_WEAPON_PARSE_H
3 changes: 2 additions & 1 deletion src/game/shared/neo/weapons/weapon_aa13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ void CWeaponAA13::PrimaryAttack(void)
Vector vecAiming = pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);

Vector vecSpread = GetBulletSpread();
FireBulletsInfo_t info(5, vecSrc, vecAiming, vecSpread, MAX_TRACE_LENGTH, m_iPrimaryAmmoType);
int numBullets = GetNEOWpnData().m_iBullets;
FireBulletsInfo_t info(numBullets, vecSrc, vecAiming, vecSpread, MAX_TRACE_LENGTH, m_iPrimaryAmmoType);
info.m_pAttacker = pPlayer;
info.m_iTracerFreq = 0;

Expand Down
Loading
Loading