From 6f9a35f3f435a7d769b3c35ac92c3d9010ce6923 Mon Sep 17 00:00:00 2001 From: Ochii Date: Fri, 10 Jun 2016 15:42:53 +0100 Subject: [PATCH 01/12] C_WeaponNEOBase update And a couple other stuff --- .../client/NeotokyoSource/c_neoplayer.cpp | 2 +- .../game/client/NeotokyoSource/c_neoplayer.h | 7 + .../NeotokyoSource/neo_weapon_parse.cpp | 70 ++ .../shared/NeotokyoSource/neo_weapon_parse.h | 106 +++ .../shared/NeotokyoSource/weapon_neobase.cpp | 643 ++++++++++++++++++ .../shared/NeotokyoSource/weapon_neobase.h | 79 ++- mp/src/game/shared/basecombatweapon_shared.h | 4 + 7 files changed, 884 insertions(+), 27 deletions(-) create mode 100644 mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp create mode 100644 mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h create mode 100644 mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index 672dcde8daa..e3da5b3b4b3 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -422,7 +422,7 @@ float C_NEOPlayer::GetFOV() CWeaponNEOBase* activeWeapon = GetActiveNEOWeapon(); if ( activeWeapon ) - activeWeapon->GetFOV(); + activeWeapon->m_fFov; else return 75.f; } diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.h b/mp/src/game/client/NeotokyoSource/c_neoplayer.h index 6959a5f603e..14553e15c99 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.h +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.h @@ -62,6 +62,10 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers CWeaponNEOBase* GetActiveNEOWeapon() const; + inline int GetThermoptic() { return m_iThermoptic; } + inline int GetVision() { return m_iVision; } + inline int GetSprint() { return m_iSprint; } + void UpdateThermoptic(); void UpdateGeiger(); void UpdateVision(); @@ -71,7 +75,10 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers private: CNetworkVar( bool, m_bIsVIP ); +public: float m_flUnknown; + +private: int m_iUnknown; float m_flUnknown3; diff --git a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp new file mode 100644 index 00000000000..54e2851e106 --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp @@ -0,0 +1,70 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include +#include "neo_weapon_parse.h" + +FileWeaponInfo_t* CreateWeaponInfo() +{ + return new CNEOWeaponInfo; +} + + +CNEOWeaponInfo::CNEOWeaponInfo() +{ +} + + +void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName ) +{ + BaseClass::Parse( pKeyValuesData, szWeaponName ); + + // These instructions below were in FileWeaponInfo_t::Parse. I moved these here because that's where they belong (and because I couldn't access the new members). -Ochii + wcsncpy( &m_wBulletCharacter, pKeyValuesData->GetWString( "BulletCharacter" ), 1 ); + + m_bDrawCrosshair = ( pKeyValuesData->GetInt( "DrawCrosshair", 0 ) != 0 ) ? true : false; + + m_iAimType = pKeyValuesData->GetInt( "AimType", 1 ); + m_iScopeStyle = pKeyValuesData->GetInt( "ScopeStyle", 0 ); + + m_fVMFov = pKeyValuesData->GetInt( "VMFov", 54.f ); + m_fVMAimFov = pKeyValuesData->GetInt( "VMAimFov", 54.f ); + m_fAimFov = pKeyValuesData->GetInt( "AimFov", 54.f ); + + m_fVMOffsetUp = pKeyValuesData->GetInt( "VMOffsetUp", 0.f ); + m_fVMOffsetForward = pKeyValuesData->GetInt( "VMOffsetForward", 0.f ); + m_fVMOffsetRight = pKeyValuesData->GetInt( "VMOffsetRight", 0.f ); + + m_fVMAimOffsetUp = pKeyValuesData->GetInt( "VMAimOffsetUp", 0.f ); + m_fVMAimOffsetForward = pKeyValuesData->GetInt( "VMAimOffsetForward", 0.f ); + m_fVMAimOffsetRight = pKeyValuesData->GetInt( "VMAimOffsetRight", 0.f ); + + m_fVMAngleYaw = pKeyValuesData->GetInt( "VMAngleYaw", 0.f ); + m_fVMAnglePitch = pKeyValuesData->GetInt( "VMAnglePitch", 0.f ); + m_fVMAngleRoll = pKeyValuesData->GetInt( "VMAngleRoll", 0.f ); + + m_fVMAimAngleYaw = pKeyValuesData->GetInt( "VMAimAngleYaw", 0.f ); + m_fVMAimAnglePitch = pKeyValuesData->GetInt( "VMAimAnglePitch", 0.f ); + m_fVMAimAngleRoll = pKeyValuesData->GetInt( "VMAimAngleRoll", 0.f ); + + m_fPenetration = pKeyValuesData->GetInt( "Penetration", 1.f ); + + // These were always in here + Q_strncpy( m_szAnim_prefix, pKeyValuesData->GetString( "anim_prefix" ), MAX_WEAPON_PREFIX ); + + m_iDamage = pKeyValuesData->GetInt( "Damage", 42 ); + m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); + + m_fCycleTime = pKeyValuesData->GetInt( "CycleTime", 0.15f ); + m_fTPMuzzleFlashScale = pKeyValuesData->GetInt( "TPMuzzleFlashScale", 1.0f ); +} + +// Check the header for more info -Ochii +/*virtual const char* CNEOWeaponInfo::GetClassName() +{ + return "CNEOWeaponInfo"; +}*/ \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h new file mode 100644 index 00000000000..297969c21e2 --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h @@ -0,0 +1,106 @@ +#ifndef NEO_WEAPON_PARSE_H +#define NEO_WEAPON_PARSE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "weapon_parse.h" + +enum NEOWeaponID +{ + WEAPON_NONE = 0, + + WEAPON_MP5, + WEAPON_SUPA7, + WEAPON_GRENADE, + WEAPON_HL2PISTOL, + WEAPON_TACHI, + WEAPON_ZR68S, + WEAPON_ZR68C, + WEAPON_ZR68L, + WEAPON_MX, + WEAPON_MILSO, + WEAPON_SRM, + WEAPON_SRM_S, + WEAPON_MILSO_S, + WEAPON_MPN, // VPN45 + WEAPON_PZ, + WEAPON_JITTE, + WEAPON_JITTESCOPED, + WEAPON_GHOST, + WEAPON_SMAC, + WEAPON_M41, + WEAPON_M41L, + WEAPON_SMOKEGRENADE, + WEAPON_REMOTEDET, + WEAPON_KYLA, + WEAPON_AA13, + WEAPON_KNIFE, + WEAPON_MX_SILENCED, + WEAPON_SRS, + WEAPON_M41S, + + WEAPON_MAX, // number of weapons weapon index +}; + +class CNEOWeaponInfo : public FileWeaponInfo_t +{ +public: + DECLARE_CLASS_GAMEROOT( CNEOWeaponInfo, FileWeaponInfo_t ); + + CNEOWeaponInfo(); + + virtual void Parse( KeyValues *pKeyValuesData, const char *szWeaponName ); + + virtual const char* GetClassName(); // This is on the original game but I'm not sure we need this, let's keep this commented for now. -Ochii + +public: + wchar_t m_wBulletCharacter; + + char m_szTeam2viewmodel[ 80 ]; + + bool m_bDrawCrosshair; + + int m_iAimType; + + int m_iScopeStyle; + + float m_fAimFov; + + float m_fPenetration; + + float m_fVMFov; + float m_fVMAimFov; + + float m_fVMOffsetUp; + float m_fVMOffsetForward; + float m_fVMOffsetRight; + + float m_fVMAimOffsetUp; + float m_fVMAimOffsetForward; + float m_fVMAimOffsetRight; + + float m_fVMAngleYaw; + float m_fVMAnglePitch; + float m_fVMAngleRoll; + + float m_fVMAimAngleYaw; + float m_fVMAimAnglePitch; + float m_fVMAimAngleRoll; + + char m_szAnim_prefix[ MAX_WEAPON_PREFIX ]; + + int m_iDamage; + int m_iBullets; + + float m_fCycleTime; + + float m_fTPMuzzleFlashScale; +}; + +CNEOWeaponInfo* GetNEOWeaponInfoFromHandle( WEAPON_FILE_INFO_HANDLE handle ) +{ + return static_cast< CNEOWeaponInfo* >(GetFileWeaponInfoFromHandle( handle )); +} + +#endif // NEO_WEAPON_PARSE_H diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp new file mode 100644 index 00000000000..6ea39967aa9 --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp @@ -0,0 +1,643 @@ +#include "weapon_neobase.h" +#include "c_neoplayer.h" +#include "materialsystem\imaterialvar.h" +#include "keyvalues.h" +#include "c_recipientfilter.h" +#include "iefx.h" +#include "dlight.h" + +// We use these on the c&p CalcViewmodelBob +#define HL2_BOB_CYCLE_MAX 0.45f +#define HL2_BOB_UP 0.5f + +float g_lateralBob = 0.f; +float g_verticalBob = 0.f; + +ConVar v_vmtweak( "v_vmtweak", "0", FCVAR_CLIENTDLL ); + +ConVar v_vm_aimfov( "v_vm_aimfov", "54.0", FCVAR_CLIENTDLL ); +ConVar v_vmaimoffsetup( "v_vmaimoffsetup", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmaimoffsetforward( "v_vmaimoffsetforward", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmaimoffsetright( "v_vmaimoffsetright", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmaimangleyaw( "v_vmaimangleyaw", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmaimanglepitch( "v_vmaimanglepitch", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmaimangleroll( "v_vmaimangleroll", "0.0", FCVAR_CLIENTDLL ); + +ConVar v_vm_fov( "v_vm_fov", "54.0", FCVAR_CLIENTDLL ); +ConVar v_vmoffsetup( "v_vmoffsetup", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmoffsetforward( "v_vmoffsetforward", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmoffsetright( "v_vmoffsetright", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmangleyaw( "v_vmangleyaw", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmanglepitch( "v_vmanglepitch", "0.0", FCVAR_CLIENTDLL ); +ConVar v_vmangleroll( "v_vmangleroll", "0.0", FCVAR_CLIENTDLL ); + +static const char* s_WeaponAliasInfo[] = +{ + "none", + "mp5", + "supa7", + "grenade", + "hl2pistol", + "tachi", + "zr68s", + "zr68c", + "zr68l", + "mx", + "milso", + "srm", + "srm_s", + "milso_s", + "mpn", + "pz", + "jitte", + "jittescoped", + "ghost", + "smac", + "m41", + "m41l", + "smokegrenade", + "remotedet", + "kyla", + "aa13", + "knife", + "mx_silenced", + "srs", + "m41s", + NULL, +}; + +const char* WeaponIDToAlias( int id ) +{ + if ( ( id >= WEAPON_MAX) || ( id < 0 ) ) + return NULL; + + return s_WeaponAliasInfo[ id ]; +} + +bool CreateThermopticMaterial( IMaterial* material ) +{ + if ( !g_pMaterialSystem ) + return false; + + KeyValues* keyValues = new KeyValues( "Refract" ); + + material = g_pMaterialSystem->CreateMaterial( "thermoptic", keyValues ); + + if ( !material ) + return false; + + bool found = false; + + material->SetShader( "Refract" ); + material->SetMaterialVarFlag( MATERIAL_VAR_MODEL, true ); + material->SetMaterialVarFlag( MATERIAL_VAR_SUPPRESS_DECALS, true ); + + IMaterialVar* refractamount = material->FindVar( "$refractamount", &found ); + + if ( found ) + refractamount->SetFloatValue( 0.8f ); + + IMaterialVar* normalmap = material->FindVar( "$normalmap", &found ); + + if ( found ) + { + ITexture* waterTexture = g_pMaterialSystem->FindTexture( "dev/water_normal", "ClientEffect textures" ); + + if ( waterTexture ) + normalmap->SetTextureValue( waterTexture ); + } + + IMaterialVar* bumpframe = material->FindVar( "$bumpframe", &found ); + + if ( found ) + bumpframe->SetIntValue( 0 ); + + return true; +} + +IMaterial* GetThermopticMaterial() +{ + static IMaterial* pThermopticMaterial; + + if ( pThermopticMaterial || CreateThermopticMaterial( pThermopticMaterial ) ) + return pThermopticMaterial; + + return nullptr; +} + +// This function has really some nasty stuff going on :/ +void UpdateThermopticMaterial( IMaterial* material, float a2 ) +{ + *(int*) ((uintp) material + 4) = a2 * 0.2f; // material + 4 is CMaterial::m_iEnumerationID, which we can't set through IMaterial. I'll have to look for a lookaround later. -Ochii + + if ( !material ) + return; + + bool found = false; + + IMaterialVar* refractamount = material->FindVar( "$refractamount", &found ); + + if ( found ) + refractamount->SetFloatValue( material->GetEnumerationID() * 0.035f ); + + IMaterialVar* bluramount = material->FindVar( "$bluramount", &found ); + + if ( found ) + bluramount->SetFloatValue( material->GetEnumerationID() * 20.f + 10.524f ); + + IMaterialVar* refracttint = material->FindVar( "$refracttint", &found ); + + if ( found ) + refracttint->SetVecValue( 0.85f - material->GetEnumerationID() * 0.8f, 0.85f - material->GetEnumerationID() * 0.6f, 0.85f - material->GetEnumerationID() * 0.6f ); + + IMaterialVar* fresnelreflection = material->FindVar( "$fresnelreflection", &found ); + + if ( found ) + fresnelreflection->SetFloatValue( material->GetEnumerationID() * 2 + 0.25f ); + + IMaterialVar* bumptransform = material->FindVar( "$bumptransform", &found ); + + if ( found ) + { + float v25 = cos( 0.7853981633974483 ) * gpGlobals->curtime * 0.25; + float v26 = sin( 0.7853981633974483 ) * gpGlobals->curtime * 0.25; + + if ( v25 < 0.f ) + v25 = v25 - 1.f - v25; + + VMatrix matrix( 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f ); + + if ( bumptransform->GetType() == MATERIAL_VAR_TYPE_MATRIX ) + bumptransform->SetMatrixValue( matrix ); + else + bumptransform->SetVecValue( 0.f, 0.f, 0.f ); + } +} + +IMPLEMENT_NETWORKCLASS_ALIASED( WeaponNEOBase, DT_WeaponNEOBase ) + +BEGIN_NETWORK_TABLE( CWeaponNEOBase, DT_WeaponNEOBase ) +END_NETWORK_TABLE() + +LINK_ENTITY_TO_CLASS( weapon_neo_base, CWeaponNEOBase ); + +CWeaponNEOBase::CWeaponNEOBase() +{ + SetPredictionEligible( true ); + AddSolidFlags(FSOLID_TRIGGER); + + bAimed = false; + m_fAccuracy = 0.f; +} + +void CWeaponNEOBase::Spawn() +{ + m_fMinRange1 = 0.f; + m_fMinRange2 = 0.f; + m_fMaxRange1 = 0.f; + m_fMaxRange2 = 0.f; + + BaseClass::Spawn(); +} + +void CWeaponNEOBase::Precache() +{ + BaseClass::Precache(); + + CNEOWeaponInfo* weaponInfo = GetNEOWeaponInfoFromHandle( GetWeaponFileInfoHandle() ); + + m_bDrawCrosshair = weaponInfo->m_bDrawCrosshair; + + m_iAimType = weaponInfo->m_iAimType; + m_iScopeStyle = weaponInfo->m_iScopeStyle; + + m_fVMFov = weaponInfo->m_fVMFov; + m_fVMAimFov = weaponInfo->m_fVMAimFov; + m_fAimFov = weaponInfo->m_fAimFov; + + m_fVMOffsetUp = weaponInfo->m_fVMOffsetUp; + m_fVMOffsetForward = weaponInfo->m_fVMOffsetForward; + m_fVMOffsetRight = weaponInfo->m_fVMOffsetRight; + + m_fVMAimOffsetUp = weaponInfo->m_fVMAimOffsetUp; + m_fVMAimOffsetForward = weaponInfo->m_fVMAimOffsetForward; + m_fVMAimOffsetRight = weaponInfo->m_fVMAimOffsetRight; + + m_fVMAngleYaw = weaponInfo->m_fVMAngleYaw; + m_fVMAnglePitch = weaponInfo->m_fVMAnglePitch; + m_fVMAngleRoll = weaponInfo->m_fVMAngleRoll; + + m_fVMAimAngleYaw = weaponInfo->m_fVMAimAngleYaw; + m_fVMAimAnglePitch = weaponInfo->m_fVMAimAnglePitch; + m_fVMAimAngleRoll = weaponInfo->m_fVMAimAngleRoll; + + m_fTPMuzzleFlashScale = weaponInfo->m_fTPMuzzleFlashScale; + + int viewmodelIndex = modelinfo->GetModelIndex( GetTeam2ViewModelName() ); + + if ( m_iTeam2ViewModelIndex != viewmodelIndex ) + m_iTeam2ViewModelIndex = viewmodelIndex; +} + +bool CWeaponNEOBase::ShouldPredict() +{ + if ( ToNEOPlayer( GetOwner() ) == C_NEOPlayer::GetLocalNEOPlayer() ) + return true; + + return false; +} + +int CWeaponNEOBase::InternalDrawModel( int flags ) +{ + C_NEOPlayer* owner = dynamic_cast< C_NEOPlayer* >( GetOwner() ); + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( !owner || !localPlayer ) + return BaseClass::InternalDrawModel( flags ); + + if ( owner->GetThermoptic() == 1 ) + { + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return 0; + + IMaterial* thermopticMaterial = GetThermopticMaterial(); + + UpdateThermopticMaterial( thermopticMaterial, owner->m_flUnknown ); + + modelrender->ForcedMaterialOverride( thermopticMaterial ); + int result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + + return result; + } + + else if ( owner->GetVision() == 3 ) // Thermal vision + { + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return BaseClass::InternalDrawModel( flags ); + + IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/vm_thermal", "Other textures" ); + + if ( IsErrorMaterial( matThermal ) ) + { + DevMsg( SPEW_MESSAGE, "Fuck me...\n" ); // Their message, not mine kek + BaseClass::DrawModel( flags ); + } + + bool found = false; + IMaterialVar* matVar = matThermal->FindVar( "$eyevec", &found ); + + if ( found ) + { + Vector forward; + GetVectors( &forward, nullptr, nullptr ); + matVar->SetVecValue( forward.x, forward.y, forward.z, 3.f ); + } + + modelrender->ForcedMaterialOverride( matThermal ); + int result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + + return result; + } + + if ( owner->GetVision() == 4 ) // Motion vision + { + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return BaseClass::InternalDrawModel( flags ); + + IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/motion", "Other textures" ); + + if ( IsErrorMaterial( matThermal ) ) + { + DevMsg( SPEW_MESSAGE, "Fuck me...\n" ); + BaseClass::DrawModel( flags ); + } + + float velocity = localPlayer->GetLocalVelocity().Length() / 75.f; + + if ( velocity > 4.f ) + velocity = 4.f; + + bool found = false; + IMaterialVar* matVar = matThermal->FindVar( "$eyevec", &found ); + + if ( found ) + { + Vector forward; + GetVectors( &forward, nullptr, nullptr ); + matVar->SetVecValue( forward.x, forward.y, forward.z, velocity ); + } + + modelrender->ForcedMaterialOverride( matThermal ); + int result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + + return result; + } + + return BaseClass::InternalDrawModel( flags ); +} + +void CWeaponNEOBase::SetViewModel() +{ + C_NEOPlayer* owner = ToNEOPlayer( GetOwner() ); + + if ( !owner ) + return; + + C_BaseViewModel* viewModel = owner->GetViewModel( m_nViewModelIndex ); + + if ( !viewModel ) + return; + + viewModel->SetWeaponModel( GetWorldModel(), this ); +} + +void CWeaponNEOBase::ItemPostFrame() +{ + C_NEOPlayer* owner = ToNEOPlayer( GetOwner() ); + + if ( owner->GetObserverMode() != OBS_MODE_NONE ) + return; + + /* if ( g_pGameRules->0x64 ) + { + input->ClearInputButton( 1 ); + return; + }*/ // I need to check CNEOGameRules + + if ( !owner || owner->GetSprint() == 1 || owner->GetMoveType() == MOVETYPE_LADDER ) + return; + + if ( m_bUnknown + && owner->m_nButtons & 0x40000000 // Custom IN_ flag? ( 1 << 30 ) + && gpGlobals->curtime > m_flNextPrimaryAttack && gpGlobals->curtime > m_flNextSecondaryAttack ) + { + m_bUnknown2 = true; + m_fUnknown = gpGlobals->curtime + 0.25f; + + if ( bAimed ) + bAimed = false; + + SendWeaponAnim( ACT_SLAM_STICKWALL_ND_IDLE ); + + float seqDuration = SequenceDuration() + gpGlobals->curtime; + + if ( m_flNextSecondaryAttack != seqDuration ) + m_flNextSecondaryAttack = seqDuration; + + if ( m_flNextPrimaryAttack != m_flNextSecondaryAttack ) + m_flNextPrimaryAttack = m_flNextSecondaryAttack; + + SetWeaponIdleTime( seqDuration ); + } + + else if ( m_bUnknown2 && gpGlobals->curtime >= m_fUnknown ) + { + m_bUnknown2 = false; + // call to vfunc at 322, which is only implemented by shotguns (?). I have to add it here later. + } +} + +void CWeaponNEOBase::OverrideViewmodelBob( CBaseViewModel *viewmodel, Vector &origin, QAngle &angles ) +{ + Vector forward, right; + + AngleVectors( angles, &forward, &right, nullptr ); + + float fOffsetUp, fOffsetForward, fOffsetRight, fAngleYaw, fAnglePitch, fAngleRoll; + + if ( !v_vmtweak.GetBool() ) + { + switch ( m_iUnknown ) + { + case 1: + m_fFov = m_fVMFov - m_fVMAimFov * m_fUnknown2 + m_fVMAimFov; + fOffsetUp = m_fVMOffsetUp - m_fVMAimOffsetUp * m_fUnknown2 + m_fVMAimOffsetUp; + fOffsetForward = m_fVMOffsetForward - m_fVMAimOffsetForward * m_fUnknown2 + m_fVMAimOffsetForward; + fOffsetRight = m_fVMOffsetRight - m_fVMAimOffsetRight * m_fUnknown2 + m_fVMAimOffsetRight; + fAngleYaw = m_fVMAngleYaw - m_fVMAimAngleYaw * m_fUnknown2 + m_fVMAimAngleYaw; + fAnglePitch = m_fVMAnglePitch - m_fVMAimAnglePitch * m_fUnknown2 + m_fVMAimAnglePitch; + fAngleRoll = m_fVMAngleRoll - m_fVMAimAngleRoll * m_fUnknown2 + m_fVMAimAngleRoll; + break; + + case 2: + m_fFov = m_fVMAimFov; + fOffsetUp = m_fVMAimOffsetUp; + fOffsetForward = m_fVMAimOffsetForward; + fOffsetRight = m_fVMAimOffsetRight; + fAngleYaw = m_fVMAimAngleYaw; + fAnglePitch = m_fVMAimAnglePitch; + fAngleRoll = m_fVMAimAngleRoll; + break; + + case 3: + m_fFov = m_fVMAimFov - m_fVMFov * m_fUnknown2 + m_fVMFov; + fOffsetUp = m_fVMAimOffsetUp - m_fVMOffsetUp * m_fUnknown2 + m_fVMOffsetUp; + fOffsetForward = m_fVMAimOffsetForward - m_fVMOffsetForward * m_fUnknown2 + m_fVMOffsetForward; + fOffsetRight = m_fVMAimOffsetRight - m_fVMOffsetRight * m_fUnknown2 + m_fVMOffsetRight; + fAngleYaw = m_fVMAimAngleYaw - m_fVMAngleYaw * m_fUnknown2 + m_fVMAngleYaw; + fAnglePitch = m_fVMAimAnglePitch - m_fVMAnglePitch * m_fUnknown2 + m_fVMAnglePitch; + fAngleRoll = m_fVMAimAngleRoll - m_fVMAngleRoll * m_fUnknown2 + m_fVMAngleRoll; + break; + + default: + m_fFov = m_fVMFov; + fOffsetUp = m_fVMOffsetUp; + fOffsetForward = m_fVMOffsetForward; + fOffsetRight = m_fVMOffsetRight; + fAngleYaw = m_fVMAngleYaw; + fAnglePitch = m_fVMAnglePitch; + fAngleRoll = m_fVMAngleRoll; + } + } + + else + { + if ( bAimed ) + { + m_fFov = v_vm_aimfov.GetFloat(); + fOffsetUp = v_vmaimoffsetup.GetFloat(); + fOffsetForward = v_vmaimoffsetforward.GetFloat(); + fOffsetRight = v_vmaimoffsetright.GetFloat(); + fAngleYaw = v_vmaimangleyaw.GetFloat(); + fAnglePitch = v_vmaimanglepitch.GetFloat(); + fAngleRoll = v_vmaimangleroll.GetFloat(); + } + + else + { + m_fFov = v_vm_fov.GetFloat(); + fOffsetUp = v_vmoffsetup.GetFloat(); + fOffsetForward = v_vmoffsetforward.GetFloat(); + fOffsetRight = v_vmoffsetright.GetFloat(); + fAngleYaw = v_vmangleyaw.GetFloat(); + fAnglePitch = v_vmanglepitch.GetFloat(); + fAngleRoll = v_vmangleroll.GetFloat(); + } + } + + VectorMA( origin, fOffsetForward, forward, origin ); + VectorMA( origin, fOffsetRight, right, origin ); + + origin.z += fOffsetUp; + + angles.x += fAnglePitch; + angles.y += fAngleYaw; + angles.z += fAngleRoll; +} + +void CWeaponNEOBase::AddViewmodelBob( CBaseViewModel *viewmodel, Vector &origin, QAngle &angles ) +{ + float bobMult = 1.f; // Eh I'm pretty sure we can name this better + + switch ( m_iUnknown ) + { + case 1: + bobMult = m_fUnknown2 * 0.5f + 0.5f; + break; + + case 2: + bobMult = 0.5f; + break; + + case 3: + bobMult = 1.f - 0.5f * m_fUnknown2; + } + + Vector forward, right; + + AngleVectors( angles, &forward, &right, nullptr ); + + CalcViewmodelBob(); + + VectorMA( origin, g_verticalBob * 0.1 * bobMult, forward, origin ); + + origin.z += g_verticalBob * 0.2f * bobMult; + + angles.z += g_verticalBob * 0.5f * bobMult; + angles.x -= g_verticalBob * 0.4f * bobMult; + + angles.y -= g_lateralBob * 0.3f * bobMult; + + VectorMA( origin, bobMult * (g_lateralBob * 0.8f), right, origin ); +} + +// I c&p this from CBaseHLCombatWeapon since it seems to be exactly the same +float CWeaponNEOBase::CalcViewmodelBob() +{ + static float bobtime; + static float lastbobtime; + float cycle; + + CBasePlayer *player = ToBasePlayer( GetOwner() ); + //Assert( player ); + + //NOTENOTE: For now, let this cycle continue when in the air, because it snaps badly without it + + if ( (!gpGlobals->frametime) || (player == NULL) ) + { + //NOTENOTE: We don't use this return value in our case (need to restructure the calculation function setup!) + return 0.0f;// just use old value + } + + //Find the speed of the player + float speed = player->GetLocalVelocity().Length2D(); + + //FIXME: This maximum speed value must come from the server. + // MaxSpeed() is not sufficient for dealing with sprinting - jdw + + speed = clamp( speed, -320, 320 ); + + float bob_offset = RemapVal( speed, 0, 320, 0.0f, 1.0f ); + + bobtime += (gpGlobals->curtime - lastbobtime) * bob_offset; + lastbobtime = gpGlobals->curtime; + + //Calculate the vertical bob + cycle = bobtime - (int) (bobtime / HL2_BOB_CYCLE_MAX)*HL2_BOB_CYCLE_MAX; + cycle /= HL2_BOB_CYCLE_MAX; + + if ( cycle < HL2_BOB_UP ) + { + cycle = M_PI * cycle / HL2_BOB_UP; + } + else + { + cycle = M_PI + M_PI*(cycle - HL2_BOB_UP) / (1.0 - HL2_BOB_UP); + } + + g_verticalBob = speed*0.005f; + g_verticalBob = g_verticalBob*0.3 + g_verticalBob*0.7*sin( cycle ); + + g_verticalBob = clamp( g_verticalBob, -7.0f, 4.0f ); + + //Calculate the lateral bob + cycle = bobtime - (int) (bobtime / HL2_BOB_CYCLE_MAX * 2)*HL2_BOB_CYCLE_MAX * 2; + cycle /= HL2_BOB_CYCLE_MAX * 2; + + if ( cycle < HL2_BOB_UP ) + { + cycle = M_PI * cycle / HL2_BOB_UP; + } + else + { + cycle = M_PI + M_PI*(cycle - HL2_BOB_UP) / (1.0 - HL2_BOB_UP); + } + + g_lateralBob = speed*0.005f; + g_lateralBob = g_lateralBob*0.3 + g_lateralBob*0.7*sin( cycle ); + g_lateralBob = clamp( g_lateralBob, -7.0f, 4.0f ); + + //NOTENOTE: We don't use this return value in our case (need to restructure the calculation function setup!) + return 0.0f; +} + +bool CWeaponNEOBase::PlayEmptySound() +{ + CPASAttenuationFilter filter( this ); + EmitSound( filter, entindex(), "Default.ClipEmpty_Rifle" ); +} + +void CWeaponNEOBase::DoNEOMuzzleFlash() +{ + CNEOPlayer* owner = ToNEOPlayer( GetOwner() ); + + if ( !owner ) + return; + + CBaseViewModel* viewModel = owner->GetViewModel( m_nViewModelIndex ); + + if ( !viewModel ) + return; + + Vector origin; + QAngle angles; + + bool result = viewModel->GetAttachment( 1, origin, angles ); + + if ( !result ) + return; + + dlight_t* light = effects->CL_AllocDlight( LIGHT_INDEX_TE_DYNAMIC + index ); + + if ( !light ) + return; + + light->origin = origin; + light->radius = RandomFloat( 64.f, 96.f ); + light->decay = RandomFloat( 64.f, 96.f ) / 0.05f; + light->color.r = 255; + light->color.g = 192; + light->color.b = 64; + light->color.exponent = 5; + light->die = gpGlobals->curtime + 0.05f; + + FX_MuzzleEffect( origin, angles, 1.f, 1 ); // 1 is the world index +} + +const char* CWeaponNEOBase::GetTeam2ViewModelName() +{ + return ((CNEOWeaponInfo*) &GetWpnData())->m_szTeam2viewmodel; // Yeah this is kinda ugly +} \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.h b/mp/src/game/shared/NeotokyoSource/weapon_neobase.h index 5eef887615d..c3ef315ca1e 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.h +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.h @@ -5,17 +5,14 @@ #endif #include "basecombatweapon_shared.h" +#include "neo_playeranimstate.h" +#include "neo_weapon_parse.h" #if defined( CLIENT_DLL ) #define CWeaponNEOBase C_WeaponNEOBase #endif -extern int ClassnameToWeaponID( const char *classname ); -extern int AliasToWeaponID( const char *alias ); -extern const char *WeaponIDToAlias( int id ); -extern const char *GetTranslatedWeaponAlias( const char *alias); -extern bool IsPrimaryWeapon( int id ); -extern bool IsSecondaryWeapon( int id ); +extern const char* WeaponIDToAlias( int id ); class CNEOPlayer; @@ -30,55 +27,85 @@ class CWeaponNEOBase : public CBaseCombatWeapon // C_BaseEntity implementations virtual void Spawn(); - virtual void Precache( void ); + virtual void Precache(); virtual bool ShouldPredict(); // C_BaseAnimating implementations virtual int InternalDrawModel( int flags ); // C_BaseCombatWeapon implementations - virtual bool IsPredicted() const; + virtual bool IsPredicted() const { return true; } virtual void SetViewModel(); virtual void ItemPostFrame(); - virtual float GetFireRate( void ); + virtual float GetFireRate() { return 1.f; } + virtual void OverrideViewmodelBob( CBaseViewModel *viewmodel, Vector &origin, QAngle &angles ); virtual void AddViewmodelBob( CBaseViewModel *viewmodel, Vector &origin, QAngle &angles ); - virtual float CalcViewmodelBob( void ); + virtual float CalcViewmodelBob(); // Now for WeaponNEOBase itself - virtual const char* GetWeaponTypeName(); + virtual const char* GetWeaponTypeName() { return "primary"; } - virtual CNEOPlayer* GetPlayerOwner() const; + virtual NEOWeaponID GetWeaponID() const { return WEAPON_NONE; } + + virtual bool IsGhost() { return false; } // The robot blowdoll you know - - virtual /*NEOWeaponID*/ int GetWeaponID( void ) const; //{ return WEAPON_NONE; } - - - virtual bool IsGhost(); // The robot blowdoll you know - - virtual int GetWeaponType(); // If it's an assault rifle, etc. + virtual int GetWeaponType() { return 0x68; } // If it's an assault rifle, etc. We'll get an enum for this later virtual bool PlayEmptySound(); // *click* - virtual void DoMuzzleFlash(); // This creates a Dlight then calls FX_MuzzleEffect + virtual void DoNEOMuzzleFlash(); // This creates a Dlight then calls FX_MuzzleEffect + + virtual const char* GetTeam2ViewModelName(); - virtual float GetRunningFov(); // When you're not aiming, I didn't want to think on a better name. Static reversal says it returns 75.f - virtual float GetAimingFov( int dunno ); // I think you can just push 0 since I believe they all just return the same variable. Static reversal says it returns 50.f + virtual float GetRunningFov() { return 75.f; } + virtual float GetAimingFov() { return 50.f; } -public: - inline float GetFOV() { return m_fFOV; } -private: +public: // Let's just keep these public for a while int m_iTeam2ViewModelIndex; + float m_fTPMuzzleFlashScale; + + bool m_bUnknown2; + float m_fUnknown; + int m_iUnknown; + float m_fUnknown2; + + bool m_bDrawCrosshair; bool bAimed; - float m_fFOV; + int m_iAimType; + int m_iScopeStyle; + + float m_fVMFov; + float m_fVMAimFov; + float m_fAimFov; + + float m_fVMOffsetUp; + float m_fVMOffsetForward; + float m_fVMOffsetRight; + + float m_fVMAimOffsetUp; + float m_fVMAimOffsetForward; + float m_fVMAimOffsetRight; + float m_fVMAngleYaw; + float m_fVMAnglePitch; + float m_fVMAngleRoll; + + float m_fVMAimAngleYaw; + float m_fVMAimAnglePitch; + float m_fVMAimAngleRoll; + + bool m_bUnknown; + float m_fAccuracy; + int m_iUnknown2; + private: CWeaponNEOBase( const CWeaponNEOBase & ); }; diff --git a/mp/src/game/shared/basecombatweapon_shared.h b/mp/src/game/shared/basecombatweapon_shared.h index 2c712923b18..1a8f7148863 100644 --- a/mp/src/game/shared/basecombatweapon_shared.h +++ b/mp/src/game/shared/basecombatweapon_shared.h @@ -318,6 +318,8 @@ class CBaseCombatWeapon : public BASECOMBATWEAPON_DERIVED_FROM void SetOwner( CBaseCombatCharacter *owner ); virtual void OnPickedUp( CBaseCombatCharacter *pNewOwner ); + virtual void OverrideViewmodelBob( CBaseViewModel *viewmodel, Vector &origin, QAngle &angles ); // This should be moved to C_WeaponNEOBase! -Ochii + virtual void AddViewmodelBob( CBaseViewModel *viewmodel, Vector &origin, QAngle &angles ) {}; virtual float CalcViewmodelBob( void ) { return 0.0f; }; @@ -603,6 +605,8 @@ class CBaseCombatWeapon : public BASECOMBATWEAPON_DERIVED_FROM IPhysicsConstraint *GetConstraint() { return m_pConstraint; } + float m_fFov; // It's here to replicate the game, better move this to its own class later + private: WEAPON_FILE_INFO_HANDLE m_hWeaponFileInfo; IPhysicsConstraint *m_pConstraint; From 4f6e9198ae14c47054e2742a99caf1b0ef210235 Mon Sep 17 00:00:00 2001 From: Ochii Date: Fri, 10 Jun 2016 15:47:03 +0100 Subject: [PATCH 02/12] Fix CNEOWeaponInfo::Parse Whoopsie --- .../NeotokyoSource/neo_weapon_parse.cpp | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp index 54e2851e106..c0101db3375 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp +++ b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp @@ -13,12 +13,10 @@ FileWeaponInfo_t* CreateWeaponInfo() return new CNEOWeaponInfo; } - CNEOWeaponInfo::CNEOWeaponInfo() { } - void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName ) { BaseClass::Parse( pKeyValuesData, szWeaponName ); @@ -31,27 +29,27 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_iAimType = pKeyValuesData->GetInt( "AimType", 1 ); m_iScopeStyle = pKeyValuesData->GetInt( "ScopeStyle", 0 ); - m_fVMFov = pKeyValuesData->GetInt( "VMFov", 54.f ); - m_fVMAimFov = pKeyValuesData->GetInt( "VMAimFov", 54.f ); - m_fAimFov = pKeyValuesData->GetInt( "AimFov", 54.f ); + m_fVMFov = pKeyValuesData->GetFloat( "VMFov", 54.f ); + m_fVMAimFov = pKeyValuesData->GetFloat( "VMAimFov", 54.f ); + m_fAimFov = pKeyValuesData->GetFloat( "AimFov", 54.f ); - m_fVMOffsetUp = pKeyValuesData->GetInt( "VMOffsetUp", 0.f ); - m_fVMOffsetForward = pKeyValuesData->GetInt( "VMOffsetForward", 0.f ); - m_fVMOffsetRight = pKeyValuesData->GetInt( "VMOffsetRight", 0.f ); + m_fVMOffsetUp = pKeyValuesData->GetFloat( "VMOffsetUp", 0.f ); + m_fVMOffsetForward = pKeyValuesData->GetFloat( "VMOffsetForward", 0.f ); + m_fVMOffsetRight = pKeyValuesData->GetFloat( "VMOffsetRight", 0.f ); - m_fVMAimOffsetUp = pKeyValuesData->GetInt( "VMAimOffsetUp", 0.f ); - m_fVMAimOffsetForward = pKeyValuesData->GetInt( "VMAimOffsetForward", 0.f ); - m_fVMAimOffsetRight = pKeyValuesData->GetInt( "VMAimOffsetRight", 0.f ); + m_fVMAimOffsetUp = pKeyValuesData->GetFloat( "VMAimOffsetUp", 0.f ); + m_fVMAimOffsetForward = pKeyValuesData->GetFloat( "VMAimOffsetForward", 0.f ); + m_fVMAimOffsetRight = pKeyValuesData->GetFloat( "VMAimOffsetRight", 0.f ); - m_fVMAngleYaw = pKeyValuesData->GetInt( "VMAngleYaw", 0.f ); - m_fVMAnglePitch = pKeyValuesData->GetInt( "VMAnglePitch", 0.f ); - m_fVMAngleRoll = pKeyValuesData->GetInt( "VMAngleRoll", 0.f ); + m_fVMAngleYaw = pKeyValuesData->GetFloat( "VMAngleYaw", 0.f ); + m_fVMAnglePitch = pKeyValuesData->GetFloat( "VMAnglePitch", 0.f ); + m_fVMAngleRoll = pKeyValuesData->GetFloat( "VMAngleRoll", 0.f ); - m_fVMAimAngleYaw = pKeyValuesData->GetInt( "VMAimAngleYaw", 0.f ); - m_fVMAimAnglePitch = pKeyValuesData->GetInt( "VMAimAnglePitch", 0.f ); - m_fVMAimAngleRoll = pKeyValuesData->GetInt( "VMAimAngleRoll", 0.f ); + m_fVMAimAngleYaw = pKeyValuesData->GetFloat( "VMAimAngleYaw", 0.f ); + m_fVMAimAnglePitch = pKeyValuesData->GetFloat( "VMAimAnglePitch", 0.f ); + m_fVMAimAngleRoll = pKeyValuesData->GetFloat( "VMAimAngleRoll", 0.f ); - m_fPenetration = pKeyValuesData->GetInt( "Penetration", 1.f ); + m_fPenetration = pKeyValuesData->GetFloat( "Penetration", 1.f ); // These were always in here Q_strncpy( m_szAnim_prefix, pKeyValuesData->GetString( "anim_prefix" ), MAX_WEAPON_PREFIX ); @@ -59,8 +57,8 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_iDamage = pKeyValuesData->GetInt( "Damage", 42 ); m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); - m_fCycleTime = pKeyValuesData->GetInt( "CycleTime", 0.15f ); - m_fTPMuzzleFlashScale = pKeyValuesData->GetInt( "TPMuzzleFlashScale", 1.0f ); + m_fCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15f ); + m_fTPMuzzleFlashScale = pKeyValuesData->GetFloat( "TPMuzzleFlashScale", 1.0f ); } // Check the header for more info -Ochii From d228bb282c3339a0a92510a7524b7cede07c8ea6 Mon Sep 17 00:00:00 2001 From: Ochii Date: Sun, 12 Jun 2016 21:32:16 +0100 Subject: [PATCH 03/12] Add C_NEORagdoll That's it --- .../client/NeotokyoSource/c_neoplayer.cpp | 291 +++++++++++++++++- .../game/client/NeotokyoSource/c_neoplayer.h | 6 +- .../shared/NeotokyoSource/weapon_neobase.cpp | 8 +- 3 files changed, 291 insertions(+), 14 deletions(-) diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index e3da5b3b4b3..5bd3a9878b3 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -6,11 +6,290 @@ #include "prediction.h" #include "iviewrender.h" #include "ivieweffects.h" +#include "materialsystem\imaterialvar.h" +#include "convar.h" + +ConVar cl_nt_ragdoll_lifetime( "cl_nt_ragdoll_lifetime", "60", FCVAR_REPLICATED ); #if defined( CNEOPlayer ) #undef CNEOPlayer #endif +class C_NEORagdoll : public C_BaseAnimatingOverlay +{ +public: + DECLARE_CLASS( C_NEORagdoll, C_BaseAnimatingOverlay ); + DECLARE_CLIENTCLASS(); + + C_NEORagdoll(); + ~C_NEORagdoll(); + + virtual void OnDataChanged( DataUpdateType_t type ); + + IRagdoll* GetIRagdoll() const; + + virtual bool AddRagdollToFadeQueue() { return true; } + + virtual void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName ); + virtual int DrawModel( int flags ); + virtual void ClientThink(); + +private: + C_NEORagdoll( const C_NEORagdoll & ); + + void Interp_Copy( C_BaseAnimatingOverlay *pSourceEntity ); + void CreateNEORagdoll(); + +private: + EHANDLE m_hPlayer; + CNetworkVector( m_vecRagdollVelocity ); + CNetworkVector( m_vecRagdollOrigin ); + float m_flRagdollSinkStart; // The time when it spawned, took the name from CSS source +}; + +IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_NEORagdoll, DT_NEORagdoll, CNEORagdoll ) + RecvPropVector( RECVINFO( m_vecRagdollOrigin ) ), + RecvPropEHandle( RECVINFO( m_hPlayer ) ), + RecvPropInt( RECVINFO( m_nModelIndex ) ), + RecvPropInt( RECVINFO( m_nForceBone ) ), + RecvPropVector( RECVINFO( m_vecForce ) ), + RecvPropVector( RECVINFO( m_vecRagdollVelocity ) ), +END_RECV_TABLE() + +C_NEORagdoll::C_NEORagdoll() +{ +} + +C_NEORagdoll::~C_NEORagdoll() +{ +} + +int C_NEORagdoll::DrawModel( int flags ) +{ + C_NEOPlayer *pPlayer = dynamic_cast< C_NEOPlayer* >(m_hPlayer.Get()); + + if ( pPlayer && ( pPlayer->IsLocalNEOPlayer() || pPlayer->m_bIsOnDeathScreen ) ) + return 0; + + if ( pPlayer->m_iVision == 3 ) // Thermal vision + { + IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/thermal", "Other textures" ); + + if ( g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + { + bool found = false; + + IMaterialVar* matVar = matThermal->FindVar( "$eyevec", &found ); + + if ( found ) + { + Vector forward; + pPlayer->GetVectors( &forward, nullptr, nullptr ); + + matVar->SetVecValue( forward.x, forward.y, forward.z ); + } + } + + modelrender->ForcedMaterialOverride( matThermal ); + + int result = InternalDrawModel( flags ); + + modelrender->ForcedMaterialOverride( nullptr ); + + return result; + } + + return BaseClass::DrawModel( flags ); +} + +void C_NEORagdoll::ClientThink() +{ + if ( (m_flRagdollSinkStart + cl_nt_ragdoll_lifetime.GetFloat()) < gpGlobals->curtime ) + { + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( !localPlayer ) + return; + + if ( (GetAbsOrigin() - localPlayer->GetAbsOrigin()).Length() > 600.f ) + { + Vector origin, min, max; + + origin = m_pRagdoll->GetRagdollOrigin(); + m_pRagdoll->GetRagdollBounds( min, max ); + + if ( engine->IsBoxInViewCluster( origin + min, origin + max ) ) + engine->CullBox( origin + min, origin + max ); + } + } +} + +// Turns out these are the same as in C_HL2MPRagdoll except CreateNEORagdoll, so let's paste them +void C_NEORagdoll::Interp_Copy( C_BaseAnimatingOverlay *pSourceEntity ) +{ + if ( !pSourceEntity ) + return; + + VarMapping_t *pSrc = pSourceEntity->GetVarMapping(); + VarMapping_t *pDest = GetVarMapping(); + + // Find all the VarMapEntry_t's that represent the same variable. + for ( int i = 0; i < pDest->m_Entries.Count(); i++ ) + { + VarMapEntry_t *pDestEntry = &pDest->m_Entries[ i ]; + const char *pszName = pDestEntry->watcher->GetDebugName(); + for ( int j = 0; j < pSrc->m_Entries.Count(); j++ ) + { + VarMapEntry_t *pSrcEntry = &pSrc->m_Entries[ j ]; + if ( !Q_strcmp( pSrcEntry->watcher->GetDebugName(), pszName ) ) + { + pDestEntry->watcher->Copy( pSrcEntry->watcher ); + break; + } + } + } +} + +void C_NEORagdoll::ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName ) +{ + IPhysicsObject *pPhysicsObject = VPhysicsGetObject(); + + if ( !pPhysicsObject ) + return; + + Vector dir = pTrace->endpos - pTrace->startpos; + + if ( iDamageType == DMG_BLAST ) + { + dir *= 4000; // adjust impact strenght + + // apply force at object mass center + pPhysicsObject->ApplyForceCenter( dir ); + } + else + { + Vector hitpos; + + VectorMA( pTrace->startpos, pTrace->fraction, dir, hitpos ); + VectorNormalize( dir ); + + dir *= 4000; // adjust impact strenght + + // apply force where we hit it + pPhysicsObject->ApplyForceOffset( dir, hitpos ); + + // Blood spray! + // FX_CS_BloodSpray( hitpos, dir, 10 ); + } + + m_pRagdoll->ResetRagdollSleepAfterTime(); +} + +void C_NEORagdoll::CreateNEORagdoll() +{ + // First, initialize all our data. If we have the player's entity on our client, + // then we can make ourselves start out exactly where the player is. + C_NEOPlayer *pPlayer = dynamic_cast< C_NEOPlayer* >(m_hPlayer.Get()); + + if ( pPlayer && !pPlayer->IsDormant() ) + { + pPlayer->SnatchModelInstance( this ); + + VarMapping_t *varMap = GetVarMapping(); + + // Copy all the interpolated vars from the player entity. + // The entity uses the interpolated history to get bone velocity. + bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); + if ( bRemotePlayer ) + { + Interp_Copy( pPlayer ); + + SetAbsAngles( pPlayer->GetRenderAngles() ); + GetRotationInterpolator().Reset(); + + m_flAnimTime = pPlayer->m_flAnimTime; + SetSequence( pPlayer->GetSequence() ); + m_flPlaybackRate = pPlayer->GetPlaybackRate(); + } + else + { + // This is the local player, so set them in a default + // pose and slam their velocity, angles and origin + SetAbsOrigin( m_vecRagdollOrigin ); + + SetAbsAngles( pPlayer->GetRenderAngles() ); + + SetAbsVelocity( m_vecRagdollVelocity ); + + int iSeq = LookupSequence( "walk_lower" ); + if ( iSeq == -1 ) + { + Assert( false ); // missing walk_lower? + iSeq = 0; + } + + SetSequence( iSeq ); // walk_lower, basic pose + SetCycle( 0.0 ); + + Interp_Reset( varMap ); + + pPlayer->m_bIsOnDeathScreen = true; // Only these were added + pPlayer->m_fRagdollCreationTime = gpGlobals->curtime; + } + } + else + { + // overwrite network origin so later interpolation will + // use this position + SetNetworkOrigin( m_vecRagdollOrigin ); + + SetAbsOrigin( m_vecRagdollOrigin ); + SetAbsVelocity( m_vecRagdollVelocity ); + + Interp_Reset( GetVarMapping() ); + } + + SetModelByIndex( GetModelIndex() ); + + // Make us a ragdoll.. + m_nRenderFX = kRenderFxRagdoll; + + matrix3x4_t boneDelta0[ MAXSTUDIOBONES ]; + matrix3x4_t boneDelta1[ MAXSTUDIOBONES ]; + matrix3x4_t currentBones[ MAXSTUDIOBONES ]; + const float boneDt = 0.05f; + + if ( pPlayer && !pPlayer->IsDormant() ) + { + pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); + } + else + { + GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); + } + + InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); +} + +void C_NEORagdoll::OnDataChanged( DataUpdateType_t type ) +{ + BaseClass::OnDataChanged( type ); + + if ( type == DATA_UPDATE_CREATED ) + { + CreateNEORagdoll(); + + AngularImpulse angularVel( 0, 0, 0 ); + + m_pPhysicsObject->AddVelocity( &m_vecRagdollVelocity.Get(), &angularVel ); + } +} + +IRagdoll* C_NEORagdoll::GetIRagdoll() const +{ + return m_pRagdoll; +} + BEGIN_RECV_TABLE_NOBASE( C_NEOPlayer, DT_NEOLocalPlayerExclusive ) RecvPropInt( RECVINFO( m_iShotsFired ) ), RecvPropFloat( RECVINFO( m_fSprintNRG ) ), @@ -45,7 +324,7 @@ C_NEOPlayer::C_NEOPlayer() : m_iv_angEyeAngles( "C_NEOPlayer::m_iv_angEyeAngles" AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR ); - m_fLastDeathTime = 0.f; + m_fRagdollCreationTime = 0.f; m_iLives = -1; m_fTurnSpeed = 1.f; m_flUnknown2 = 1.f; @@ -378,7 +657,7 @@ void C_NEOPlayer::CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, // I'm not sure what they do in here yet } - if ( gpGlobals->curtime >= (m_fLastDeathTime + 10.f) ) + if ( gpGlobals->curtime >= (m_fRagdollCreationTime + 10.f) ) m_bIsOnDeathScreen = false; } @@ -396,12 +675,12 @@ bool C_NEOPlayer::CreateMove( float flInputSampleTime, CUserCmd *pCmd ) IRagdoll* C_NEOPlayer::GetRepresentativeRagdoll() const { - C_BaseEntity /*C_NEORagdoll*/ *pRagdoll = /*(C_NEORagdoll*)*/ m_hRagdoll.Get(); + C_NEORagdoll *pRagdoll = (C_NEORagdoll*) m_hRagdoll.Get(); - if ( m_hRagdoll.Get() ) + if ( pRagdoll ) return pRagdoll->GetIRagdoll(); - else - return nullptr; + + return nullptr; } void C_NEOPlayer::PreThink() diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.h b/mp/src/game/client/NeotokyoSource/c_neoplayer.h index 14553e15c99..7becb4a4724 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.h +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.h @@ -72,13 +72,11 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers void UpdateInCross(); void UpdateSomething( float a1 ); -private: +public: // Eh let's make it all public for now CNetworkVar( bool, m_bIsVIP ); -public: float m_flUnknown; -private: int m_iUnknown; float m_flUnknown3; @@ -135,7 +133,7 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers bool m_bIsOnDeathScreen; - float m_fLastDeathTime; + float m_fRagdollCreationTime; float m_fLastThinkTime; private: diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp index 6ea39967aa9..57be8414871 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp @@ -306,9 +306,9 @@ int CWeaponNEOBase::InternalDrawModel( int flags ) if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) return BaseClass::InternalDrawModel( flags ); - IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/motion", "Other textures" ); + IMaterial* matMotion = g_pMaterialSystem->FindMaterial( "dev/motion", "Other textures" ); - if ( IsErrorMaterial( matThermal ) ) + if ( IsErrorMaterial( matMotion ) ) { DevMsg( SPEW_MESSAGE, "Fuck me...\n" ); BaseClass::DrawModel( flags ); @@ -320,7 +320,7 @@ int CWeaponNEOBase::InternalDrawModel( int flags ) velocity = 4.f; bool found = false; - IMaterialVar* matVar = matThermal->FindVar( "$eyevec", &found ); + IMaterialVar* matVar = matMotion->FindVar( "$eyevec", &found ); if ( found ) { @@ -329,7 +329,7 @@ int CWeaponNEOBase::InternalDrawModel( int flags ) matVar->SetVecValue( forward.x, forward.y, forward.z, velocity ); } - modelrender->ForcedMaterialOverride( matThermal ); + modelrender->ForcedMaterialOverride( matMotion ); int result = BaseClass::InternalDrawModel( flags ); modelrender->ForcedMaterialOverride( nullptr ); From ca9df7e193234c3e95784dc799b3dfb01b224b0d Mon Sep 17 00:00:00 2001 From: Ochii Date: Tue, 14 Jun 2016 19:16:17 +0100 Subject: [PATCH 04/12] Add missing virtuals to C_NEOPlayer Pretty much that --- .../client/NeotokyoSource/c_neoplayer.cpp | 198 +++++++++++++++++- .../game/client/NeotokyoSource/c_neoplayer.h | 13 +- mp/src/game/client/client_NeotokyoSource.vpc | 3 + .../shared/NeotokyoSource/neo_weapon_parse.h | 2 +- .../shared/NeotokyoSource/weapon_neobase.cpp | 10 +- mp/src/game/shared/basecombatweapon_shared.h | 2 + 6 files changed, 209 insertions(+), 19 deletions(-) diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index 5bd3a9878b3..f3945781290 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -8,9 +8,13 @@ #include "ivieweffects.h" #include "materialsystem\imaterialvar.h" #include "convar.h" +#include "view_scene.h" ConVar cl_nt_ragdoll_lifetime( "cl_nt_ragdoll_lifetime", "60", FCVAR_REPLICATED ); +void UpdateThermopticMaterial( IMaterial* material, float a2 ); +IMaterial* GetThermopticMaterial(); + #if defined( CNEOPlayer ) #undef CNEOPlayer #endif @@ -30,7 +34,7 @@ class C_NEORagdoll : public C_BaseAnimatingOverlay virtual bool AddRagdollToFadeQueue() { return true; } - virtual void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName ); + virtual void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName ); virtual int DrawModel( int flags ); virtual void ClientThink(); @@ -66,9 +70,9 @@ C_NEORagdoll::~C_NEORagdoll() int C_NEORagdoll::DrawModel( int flags ) { - C_NEOPlayer *pPlayer = dynamic_cast< C_NEOPlayer* >(m_hPlayer.Get()); + C_NEOPlayer *pPlayer = dynamic_cast(m_hPlayer.Get()); - if ( pPlayer && ( pPlayer->IsLocalNEOPlayer() || pPlayer->m_bIsOnDeathScreen ) ) + if ( pPlayer && (pPlayer->IsLocalNEOPlayer() || pPlayer->m_bIsOnDeathScreen) ) return 0; if ( pPlayer->m_iVision == 3 ) // Thermal vision @@ -189,7 +193,7 @@ void C_NEORagdoll::CreateNEORagdoll() { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. - C_NEOPlayer *pPlayer = dynamic_cast< C_NEOPlayer* >(m_hPlayer.Get()); + C_NEOPlayer *pPlayer = dynamic_cast(m_hPlayer.Get()); if ( pPlayer && !pPlayer->IsDormant() ) { @@ -430,7 +434,7 @@ void C_NEOPlayer::UpdateVision() if ( !IsLocalNEOPlayer() ) return; - //dword_243ED4F8 = m_iVision; + //dword_243ED4F8 = m_iVision; // This is used somewhere in CViewRender to draw the nightvision effect if ( m_iVision != m_iOldVision ) { @@ -577,6 +581,184 @@ Vector C_NEOPlayer::EyePosition() return BaseClass::EyePosition(); } +void C_NEOPlayer::OnDataChanged( DataUpdateType_t updateType ) +{ + BaseClass::OnDataChanged( updateType ); + + if ( updateType == DATA_UPDATE_CREATED ) + SetNextClientThink( -1293.f ); + + UpdateVisibility(); +} + +void C_NEOPlayer::PostDataUpdate( DataUpdateType_t updateType ) +{ + SetNetworkAngles( GetLocalAngles() ); + + BaseClass::PostDataUpdate( updateType ); +} + +const QAngle& C_NEOPlayer::GetRenderAngles() +{ + if ( IsRagdoll() ) + return vec3_angle; + + else + return m_PlayerAnimState->GetRenderAngles(); +} + +int C_NEOPlayer::DrawModel( int flags ) +{ + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + int result = -1; + + if ( localPlayer ) + { + if ( GetTeamNumber() == localPlayer->GetTeamNumber() ) + m_bUnknown = true; + + if ( m_iOldVision != 3 ) + { + if ( m_bUnknown2 ) + { + m_bUnknown2 = false; + + dlight_t* light = effects->CL_AllocDlight( LIGHT_INDEX_TE_DYNAMIC + index ); + + light->origin = GetAbsOrigin(); + light->radius = 96.f; + light->decay = 192.f; + light->color.r = 64; + light->color.g = 64; + light->color.b = 255; + light->color.exponent = 10; + light->die = gpGlobals->curtime + 0.1f; + + return 0; + } + + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return 0; + + UpdateRefractTexture(); + + IMaterial* thermopticMaterial = GetThermopticMaterial(); + + UpdateThermopticMaterial( thermopticMaterial, m_flUnknown ); + + modelrender->ForcedMaterialOverride( thermopticMaterial ); + int result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + } + + else + { + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return BaseClass::DrawModel( flags ); + + IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/thermal", TEXTURE_GROUP_OTHER ); + + if ( IsErrorMaterial( matThermal ) ) + { + DevMsg( SPEW_MESSAGE, "Fuck me...\n" ); // Their message, not mine kek + BaseClass::DrawModel( flags ); + } + + bool found = false; + IMaterialVar* matVar = matThermal->FindVar( "$eyevec", &found ); + + if ( found ) + { + Vector forward; + GetVectors( &forward, nullptr, nullptr ); + matVar->SetVecValue( forward.x, forward.y, forward.z, 3.f ); + } + + modelrender->ForcedMaterialOverride( matThermal ); + result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + } + + if ( m_iThermoptic == 1 ) + { + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return BaseClass::DrawModel( flags ); + + IMaterial* matMotion = g_pMaterialSystem->FindMaterial( "dev/motion", TEXTURE_GROUP_OTHER ); + + if ( IsErrorMaterial( matMotion ) ) + { + DevMsg( SPEW_MESSAGE, "Fuck me...\n" ); + BaseClass::DrawModel( flags ); + } + + float velocity = localPlayer->GetLocalVelocity().Length() / 75.f; + + if ( velocity > 4.f ) + velocity = 4.f; + + bool found = false; + IMaterialVar* matVar = matMotion->FindVar( "$eyevec", &found ); + + if ( found ) + { + Vector forward; + GetVectors( &forward, nullptr, nullptr ); + matVar->SetVecValue( forward.x, forward.y, forward.z, velocity ); + } + + modelrender->ForcedMaterialOverride( matMotion ); + int result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + } + + if ( m_iVision == 3 ) // Thermal vision + { + if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + return BaseClass::DrawModel( flags ); + + IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/vm_thermal", "Other textures" ); + + if ( IsErrorMaterial( matThermal ) ) + { + DevMsg( SPEW_MESSAGE, "Fuck me...\n" ); + BaseClass::DrawModel( flags ); + } + + bool found = false; + IMaterialVar* matVar = matThermal->FindVar( "$eyevec", &found ); + + if ( found ) + { + Vector forward; + GetVectors( &forward, nullptr, nullptr ); + matVar->SetVecValue( forward.x, forward.y, forward.z, 3.f ); + } + + modelrender->ForcedMaterialOverride( matThermal ); + result = BaseClass::InternalDrawModel( flags ); + modelrender->ForcedMaterialOverride( nullptr ); + } + + if ( m_bUnknown2 ) + m_bUnknown2 = false; + + if ( result >= 0 ) + return result; + } + + return BaseClass::DrawModel( flags ); +} + +ShadowType_t C_NEOPlayer::ShadowCastType() +{ + if ( !IsVisible() ) + return SHADOWS_NONE; + + return m_iThermoptic != 1 ? SHADOWS_RENDER_TO_TEXTURE_DYNAMIC : SHADOWS_NONE; +} + C_BaseAnimating* C_NEOPlayer::BecomeRagdollOnClient( bool bCopyEntity /*= true*/ ) { return nullptr; @@ -595,7 +777,7 @@ void C_NEOPlayer::UpdateClientSideAnimation() void C_NEOPlayer::DoMuzzleFlash() { C_BaseAnimating::DoMuzzleFlash(); - //*(bool*) (this + 0x1044) = true; + m_bUnknown2 = true; } void C_NEOPlayer::ProcessMuzzleFlashEvent() @@ -653,9 +835,7 @@ void C_NEOPlayer::CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, UTIL_TraceHull( start, forward, -Vector( 12, 12, 12 ), Vector( 12, 12, 12 ), CONTENTS_MOVEABLE | CONTENTS_GRATE | CONTENTS_AUX | CONTENTS_WINDOW | CONTENTS_SOLID, this, 0, &trace ); if ( trace.fraction < 1.f ) - { - // I'm not sure what they do in here yet - } + forward = trace.endpos; if ( gpGlobals->curtime >= (m_fRagdollCreationTime + 10.f) ) m_bIsOnDeathScreen = false; diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.h b/mp/src/game/client/NeotokyoSource/c_neoplayer.h index 7becb4a4724..49b8d6a4f7e 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.h +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.h @@ -24,7 +24,14 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers // C_BaseEnity implementantions virtual void AddEntity(); - virtual Vector EyePosition(); + virtual Vector EyePosition(); + + virtual void OnDataChanged( DataUpdateType_t updateType ); + virtual void PostDataUpdate( DataUpdateType_t updateType ); + + virtual const QAngle& GetRenderAngles(); + virtual int DrawModel( int flags ); + virtual ShadowType_t ShadowCastType(); // C_BaseAnimating implementations virtual C_BaseAnimating* BecomeRagdollOnClient( bool bCopyEntity = true ); @@ -123,6 +130,8 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers CNetworkVar( int, m_iLives ); CNetworkVar( int, m_iStar ); + bool m_bUnknown; + CNetworkVar( float, m_fTurnSpeed ); float m_flUnknown4; @@ -136,6 +145,8 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers float m_fRagdollCreationTime; float m_fLastThinkTime; + bool m_bUnknown2; + private: C_NEOPlayer( const C_NEOPlayer& ); }; diff --git a/mp/src/game/client/client_NeotokyoSource.vpc b/mp/src/game/client/client_NeotokyoSource.vpc index 86486cde4a1..abe531aef25 100644 --- a/mp/src/game/client/client_NeotokyoSource.vpc +++ b/mp/src/game/client/client_NeotokyoSource.vpc @@ -39,6 +39,9 @@ $Project "Client (NeotokyoSource)" $File "NeotokyoSource\c_neoplayer.cpp" $File "NeotokyoSource\c_neoplayer.h" $File "$SRCDIR\game\shared\NeotokyoSource\neo_playeranimstate.h" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_weapon_prase.cpp" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_weapon_prase.h" + $File "$SRCDIR\game\shared\NeotokyoSource\weapon_neobase.cpp" $File "$SRCDIR\game\shared\NeotokyoSource\weapon_neobase.h" $File "$SRCDIR\game\shared\NeotokyoSource\weapon_neobasefirearm.h" } diff --git a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h index 297969c21e2..99d8897ce14 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h +++ b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h @@ -23,7 +23,7 @@ enum NEOWeaponID WEAPON_SRM, WEAPON_SRM_S, WEAPON_MILSO_S, - WEAPON_MPN, // VPN45 + WEAPON_MPN, WEAPON_PZ, WEAPON_JITTE, WEAPON_JITTESCOPED, diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp index 57be8414871..46f5241f13d 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp @@ -159,12 +159,6 @@ void UpdateThermopticMaterial( IMaterial* material, float a2 ) if ( found ) { - float v25 = cos( 0.7853981633974483 ) * gpGlobals->curtime * 0.25; - float v26 = sin( 0.7853981633974483 ) * gpGlobals->curtime * 0.25; - - if ( v25 < 0.f ) - v25 = v25 - 1.f - v25; - VMatrix matrix( 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f ); if ( bumptransform->GetType() == MATERIAL_VAR_TYPE_MATRIX ) @@ -276,7 +270,7 @@ int CWeaponNEOBase::InternalDrawModel( int flags ) if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) return BaseClass::InternalDrawModel( flags ); - IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/vm_thermal", "Other textures" ); + IMaterial* matThermal = g_pMaterialSystem->FindMaterial( "dev/vm_thermal", TEXTURE_GROUP_OTHER ); if ( IsErrorMaterial( matThermal ) ) { @@ -306,7 +300,7 @@ int CWeaponNEOBase::InternalDrawModel( int flags ) if ( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) return BaseClass::InternalDrawModel( flags ); - IMaterial* matMotion = g_pMaterialSystem->FindMaterial( "dev/motion", "Other textures" ); + IMaterial* matMotion = g_pMaterialSystem->FindMaterial( "dev/motion", TEXTURE_GROUP_OTHER ); if ( IsErrorMaterial( matMotion ) ) { diff --git a/mp/src/game/shared/basecombatweapon_shared.h b/mp/src/game/shared/basecombatweapon_shared.h index 1a8f7148863..1ec21ed3a96 100644 --- a/mp/src/game/shared/basecombatweapon_shared.h +++ b/mp/src/game/shared/basecombatweapon_shared.h @@ -605,7 +605,9 @@ class CBaseCombatWeapon : public BASECOMBATWEAPON_DERIVED_FROM IPhysicsConstraint *GetConstraint() { return m_pConstraint; } +#ifdef NEO_DLL float m_fFov; // It's here to replicate the game, better move this to its own class later +#endif private: WEAPON_FILE_INFO_HANDLE m_hWeaponFileInfo; From 7816466fdeafe89b5a06d04c9a73f274289691de Mon Sep 17 00:00:00 2001 From: Ochii Date: Thu, 16 Jun 2016 21:09:28 +0100 Subject: [PATCH 05/12] Add CNEOGameRules And its proxy --- .../client/NeotokyoSource/c_neoplayer.cpp | 6 +- .../shared/NeotokyoSource/neo_gamerules.cpp | 53 ++++++++++++++++++ .../shared/NeotokyoSource/neo_gamerules.h | 56 +++++++++++++++++++ .../shared/NeotokyoSource/weapon_neobase.cpp | 3 + 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp create mode 100644 mp/src/game/shared/NeotokyoSource/neo_gamerules.h diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index f3945781290..eb4011e67df 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -57,7 +57,7 @@ IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_NEORagdoll, DT_NEORagdoll, CNEORagdoll ) RecvPropInt( RECVINFO( m_nModelIndex ) ), RecvPropInt( RECVINFO( m_nForceBone ) ), RecvPropVector( RECVINFO( m_vecForce ) ), - RecvPropVector( RECVINFO( m_vecRagdollVelocity ) ), + RecvPropVector( RECVINFO( m_vecRagdollVelocity ) ) END_RECV_TABLE() C_NEORagdoll::C_NEORagdoll() @@ -300,7 +300,7 @@ BEGIN_RECV_TABLE_NOBASE( C_NEOPlayer, DT_NEOLocalPlayerExclusive ) RecvPropFloat( RECVINFO( m_fThermopticNRG ) ), RecvPropInt( RECVINFO( m_iReinforceTimer ) ), RecvPropInt( RECVINFO( m_iSprint ) ), - RecvPropFloat( RECVINFO( m_fTurnSpeed ) ), + RecvPropFloat( RECVINFO( m_fTurnSpeed ) ) END_RECV_TABLE() IMPLEMENT_CLIENTCLASS_DT( C_NEOPlayer, DT_NEOPlayer, CNEOPlayer ) @@ -317,7 +317,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_NEOPlayer, DT_NEOPlayer, CNEOPlayer ) RecvPropInt( RECVINFO( m_iThermoptic ) ), RecvPropInt( RECVINFO( m_iNMFlash ) ), RecvPropInt( RECVINFO( m_iVision ) ), - RecvPropInt( RECVINFO( m_bIsVIP ) ), + RecvPropInt( RECVINFO( m_bIsVIP ) ) END_RECV_TABLE() C_NEOPlayer::C_NEOPlayer() : m_iv_angEyeAngles( "C_NEOPlayer::m_iv_angEyeAngles" ) diff --git a/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp b/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp new file mode 100644 index 00000000000..a88f2d518e9 --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp @@ -0,0 +1,53 @@ +#include "neo_gamerules.h" + +static CViewVectors g_NEOViewVectors( + Vector( 0, 0, 60 ), + + Vector( -16, -16, 0 ), + Vector( 16, 16, 70 ), + + Vector( -16, -16, 0 ), + Vector( 16, 16, 59 ), + Vector( 0, 0, 50 ), + + Vector( -10, -10, -10 ), + Vector( 10, 10, 10 ), + + Vector( 0, 0, 14 ) + ); + +BEGIN_NETWORK_TABLE_NOBASE( CNEOGameRules, DT_NEOGameRules ) + RecvPropInt( RECVINFO( m_iGameType ) ), + RecvPropFloat( RECVINFO( m_fRoundTimeLeft ) ), + RecvPropInt( RECVINFO( m_iRoundNumber ) ), + RecvPropInt( RECVINFO( m_iGameState ) ), + RecvPropInt( RECVINFO( m_iGameHud ) ), + RecvPropInt( RECVINFO( m_iMVP ) ), + RecvPropInt( RECVINFO( m_iAttackingTeam ) ), + RecvPropBool( RECVINFO( m_bFreezePeriod ) ) +END_NETWORK_TABLE() + +bool CNEOGameRules::ShouldCollide( int collisionGroup0, int collisionGroup1 ) +{ + if ( collisionGroup0 > collisionGroup1 ) + { + // swap so that lowest is always first + ::V_swap( collisionGroup0, collisionGroup1 ); + } + + if ( collisionGroup1 == COLLISION_GROUP_PROJECTILE && (collisionGroup0 == COLLISION_GROUP_PLAYER || collisionGroup0 == COLLISION_GROUP_PLAYER_MOVEMENT) ) + return false; + + if ( collisionGroup0 == COLLISION_GROUP_PLAYER && collisionGroup1 == COLLISION_GROUP_PLAYER_MOVEMENT ) + return false; + + if ( collisionGroup1 == COLLISION_GROUP_WEAPON ) + return false; + + return BaseClass::ShouldCollide( collisionGroup0, collisionGroup1 ); +} + +const CViewVectors* CNEOGameRules::GetViewVectors() const +{ + return &g_NEOViewVectors; +} \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/neo_gamerules.h b/mp/src/game/shared/NeotokyoSource/neo_gamerules.h new file mode 100644 index 00000000000..d6c5aea7d18 --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/neo_gamerules.h @@ -0,0 +1,56 @@ +#ifndef NEO_GAMERULES_H +#define NEO_GAMERULES_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "teamplay_gamerules.h" + +#ifdef CLIENT_DLL + #define CNEOGameRules C_NEOGameRules + #define CNEOGameRulesProxy C_NEOGameRulesProxy +#endif + +class CNEOGameRulesProxy : public CGameRulesProxy +{ +public: + DECLARE_CLASS( CNEOGameRules, CGameRulesProxy ); + DECLARE_NETWORKCLASS(); +}; + +class CNEOGameRules : public CTeamplayRules +{ +public: + DECLARE_CLASS( CNEOGameRules, CTeamplayRules ); + DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars. + + CNEOGameRules(); + +public: + virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 ); + + virtual const CViewVectors* GetViewVectors() const; + +private: + CNetworkVar( int, m_iGameType ); + + CNetworkVar( float, m_fRoundTimeLeft ); + CNetworkVar( int, m_iRoundNumber ); + + CNetworkVar( int, m_iGameState ); + CNetworkVar( int, m_iGameHud ); + + CNetworkVar( int, m_iMVP ); + + CNetworkVar( int, m_iAttackingTeam ); + + CNetworkVar( bool, m_bFreezePeriod ); +}; + +inline CNEOGameRules* NEOGameRules() +{ + return static_cast< CNEOGameRules* >( g_pGameRules ); +} + +#endif // NEO_GAMERULES_H \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp index 46f5241f13d..c637eac0004 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp @@ -171,6 +171,9 @@ void UpdateThermopticMaterial( IMaterial* material, float a2 ) IMPLEMENT_NETWORKCLASS_ALIASED( WeaponNEOBase, DT_WeaponNEOBase ) BEGIN_NETWORK_TABLE( CWeaponNEOBase, DT_WeaponNEOBase ) + RecvPropBool( RECVINFO( bAimed ) ), + RecvPropFloat( RECVINFO( m_fAccuracy ) ), + RecvPropInt( RECVINFO( m_iTeam2ViewModelIndex ) ) END_NETWORK_TABLE() LINK_ENTITY_TO_CLASS( weapon_neo_base, CWeaponNEOBase ); From 353f5965f71b05da1c883c08867b02c7d289ba78 Mon Sep 17 00:00:00 2001 From: Ochii Date: Fri, 17 Jun 2016 23:45:18 +0100 Subject: [PATCH 06/12] Add CNEOInput, CNEOPrediction and ClientModeNEONormal Along with more fixes --- .../NeotokyoSource/VGUI/neoviewport.cpp | 77 +++++++++++++++++++ .../client/NeotokyoSource/VGUI/neoviewport.h | 34 ++++++++ .../client/NeotokyoSource/c_neoplayer.cpp | 18 ++++- .../NeotokyoSource/clientmode_neonormal.cpp | 62 +++++++++++++++ .../NeotokyoSource/clientmode_neonormal.h | 36 +++++++++ .../client/NeotokyoSource/neo_in_main.cpp | 19 +++++ .../client/NeotokyoSource/neo_prediction.cpp | 37 +++++++++ mp/src/game/client/client_NeotokyoSource.vpc | 19 ++++- .../shared/NeotokyoSource/neo_gamerules.cpp | 1 + .../shared/NeotokyoSource/neo_gamerules.h | 2 +- .../shared/NeotokyoSource/neo_shareddefs.h | 11 +++ .../NeotokyoSource/neo_weapon_parse.cpp | 19 ++--- .../shared/NeotokyoSource/neo_weapon_parse.h | 9 +-- .../shared/NeotokyoSource/weapon_neobase.cpp | 3 + 14 files changed, 320 insertions(+), 27 deletions(-) create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoviewport.h create mode 100644 mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp create mode 100644 mp/src/game/client/NeotokyoSource/clientmode_neonormal.h create mode 100644 mp/src/game/client/NeotokyoSource/neo_in_main.cpp create mode 100644 mp/src/game/client/NeotokyoSource/neo_prediction.cpp create mode 100644 mp/src/game/shared/NeotokyoSource/neo_shareddefs.h diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp new file mode 100644 index 00000000000..86f1a4fd2b4 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp @@ -0,0 +1,77 @@ +#include "cbase.h" +#include "NEOViewport.h" +#include "neo_shareddefs.h" + +void NEOViewport::ApplySchemeSettings( vgui::IScheme *pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); + + gHUD.InitColors( pScheme ); + + SetPaintBackgroundEnabled( false ); +} + +IViewPortPanel* NEOViewport::CreatePanelByName( const char *szPanelName ) +{ + IViewPortPanel* newpanel = nullptr; + + if ( Q_strcmp( PANEL_TEAM, szPanelName ) == 0 ) + { + //newpanel = new CNeoTeamMenu( this ); + } + + else if ( Q_strcmp( PANEL_SCOREBOARD, szPanelName ) == 0 ) + { + //newpanel = new CNEOClientScoreBoardDialog( this ); + } + + else if ( Q_strcmp( PANEL_CLASS, szPanelName ) == 0 ) + { + //newpanel = new CNeoClassMenu( this ); + } + + else if ( Q_strcmp( PANEL_LOADOUT_DEV, szPanelName ) == 0 ) + { + //newpanel = new CNeoLoadoutMenu_Dev( this ); + } + + else if ( Q_strcmp( PANEL_LOADOUT, szPanelName ) == 0 ) + { + //newpanel = new CNeoLoadoutMenu( this ); + } + + else + { + // create a generic base panel, don't add twice + newpanel = BaseClass::CreatePanelByName( szPanelName ); + } + + return newpanel; +} + +void NEOViewport::CreateDefaultPanels() +{ + BaseClass::CreateDefaultPanels(); + + AddNewPanel( CreatePanelByName( PANEL_TEAM ), "PANEL_TEAM" ); + AddNewPanel( CreatePanelByName( PANEL_CLASS ), "PANEL_CLASS" ); + AddNewPanel( CreatePanelByName( PANEL_LOADOUT_DEV ), "PANEL_LOADOUT_DEV" ); + AddNewPanel( CreatePanelByName( PANEL_LOADOUT ), "PANEL_LOADOUT" ); +} + +void NEOViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 *pGameEventManager ) +{ + BaseClass::Start( pGameUIFuncs, pGameEventManager ); +} + +int NEOViewport::GetDeathMessageStartHeight() +{ + int y = YRES( 2 ); + + auto specGui = gViewPortInterface->FindPanelByName( PANEL_SPECGUI ); + + if ( specGui && specGui->IsVisible() ) + y += YRES( 52 ); + + return y; +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.h b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.h new file mode 100644 index 00000000000..90bd3682891 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.h @@ -0,0 +1,34 @@ +#ifndef NEOVIEWPORT_H +#define NEOVIEWPORT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "baseviewport.h" + +using namespace vgui; + +namespace vgui +{ + class Panel; + class Label; + class CBitmapImagePanel; +} + + +class NEOViewport : public CBaseViewport +{ +private: + DECLARE_CLASS_SIMPLE( NEOViewport, CBaseViewport ); + +public: + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + virtual IViewPortPanel* CreatePanelByName( const char *szPanelName ); + virtual void CreateDefaultPanels(); + virtual void Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 *pGameEventManager ); + virtual int GetDeathMessageStartHeight(); +}; + + +#endif // NEOVIEWPORT_H diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index eb4011e67df..6ee4f5839b9 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -362,7 +362,7 @@ bool C_NEOPlayer::IsLocalNEOPlayer( void ) const CWeaponNEOBase* C_NEOPlayer::GetActiveNEOWeapon() const { - return dynamic_cast(GetActiveWeapon()); + return dynamic_cast< CWeaponNEOBase* >( GetActiveWeapon() ); } void C_NEOPlayer::UpdateThermoptic() @@ -648,7 +648,7 @@ int C_NEOPlayer::DrawModel( int flags ) UpdateThermopticMaterial( thermopticMaterial, m_flUnknown ); modelrender->ForcedMaterialOverride( thermopticMaterial ); - int result = BaseClass::InternalDrawModel( flags ); + result = BaseClass::InternalDrawModel( flags ); modelrender->ForcedMaterialOverride( nullptr ); } @@ -709,7 +709,7 @@ int C_NEOPlayer::DrawModel( int flags ) } modelrender->ForcedMaterialOverride( matMotion ); - int result = BaseClass::InternalDrawModel( flags ); + result = BaseClass::InternalDrawModel( flags ); modelrender->ForcedMaterialOverride( nullptr ); } @@ -881,7 +881,7 @@ float C_NEOPlayer::GetFOV() CWeaponNEOBase* activeWeapon = GetActiveNEOWeapon(); if ( activeWeapon ) - activeWeapon->m_fFov; + return activeWeapon->m_fFov; else return 75.f; } @@ -965,6 +965,16 @@ void C_NEOPlayer::CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& f fov = GetFOV(); } +CWeaponNEOBase* C_NEOPlayer::NEOAnim_GetActiveWeapon() +{ + return GetActiveNEOWeapon(); +} + +bool C_NEOPlayer::NEOAnim_CanMove() +{ + return true; +} + void C_NEOPlayer::NEO_MuzzleFlash() { if ( m_iOldNMFlash != m_iNMFlash ) diff --git a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp new file mode 100644 index 00000000000..5a99f198868 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp @@ -0,0 +1,62 @@ +#include "cbase.h" +#include "clientmode_neonormal.h" +#include "VGUI\neoviewport.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +// Instance the singleton and expose the interface to it. +IClientMode* GetClientModeNormal() +{ + static ClientModeNEONormal g_ClientModeNormal; + return &g_ClientModeNormal; +} + + +ClientModeNEONormal::ClientModeNEONormal() +{ + m_bUnknown = false; + m_bUnknown2 = false; +} + +ClientModeNEONormal::~ClientModeNEONormal() +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void ClientModeNEONormal::InitViewport() +{ + BaseClass::InitViewport(); + + m_pViewport = new NEOViewport(); + m_pViewport->Start( gameuifuncs, gameeventmanager ); +} + +void ClientModeNEONormal::Init() +{ + BaseClass::Init(); +} + +void ClientModeNEONormal::Shutdown() +{ + BaseClass::Shutdown(); +} + +void ClientModeNEONormal::LevelInit( const char *newmap ) +{ + BaseClass::LevelInit( newmap ); +} + +void ClientModeNEONormal::LevelShutdown() +{ + BaseClass::LevelShutdown(); +} + +float ClientModeNEONormal::GetViewModelFOV() +{ + return 75.f; +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h new file mode 100644 index 00000000000..72a47deb334 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h @@ -0,0 +1,36 @@ +#if !defined( CLIENTMODE_NEONORMAL_H ) +#define CLIENTMODE_NEONORMAL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "clientmode_shared.h" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class ClientModeNEONormal : public ClientModeShared +{ +public: + DECLARE_CLASS( ClientModeNEONormal, ClientModeShared ); + + ClientModeNEONormal(); + ~ClientModeNEONormal(); + +public: + virtual void InitViewport(); + virtual void Init(); + virtual void Shutdown(); + virtual void LevelInit( const char *newmap ); + virtual void LevelShutdown(); + virtual float GetViewModelFOV(); + +private: + bool m_bUnknown; + bool m_bUnknown2; +}; + +extern IClientMode* GetClientModeNormal(); + +#endif // CLIENTMODE_NEONORMAL_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/neo_in_main.cpp b/mp/src/game/client/NeotokyoSource/neo_in_main.cpp new file mode 100644 index 00000000000..5678dc77465 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/neo_in_main.cpp @@ -0,0 +1,19 @@ +#include "cbase.h" +#include "kbutton.h" +#include "input.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//----------------------------------------------------------------------------- +// Purpose: HL Input interface +//----------------------------------------------------------------------------- +class CNEOInput : public CInput +{ +public: +}; + +static CNEOInput g_Input; + +// Expose this interface +IInput *input = ( IInput * )&g_Input; diff --git a/mp/src/game/client/NeotokyoSource/neo_prediction.cpp b/mp/src/game/client/NeotokyoSource/neo_prediction.cpp new file mode 100644 index 00000000000..e3a9da6864f --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/neo_prediction.cpp @@ -0,0 +1,37 @@ +#include "cbase.h" +#include "prediction.h" +#include "c_neoplayer.h" +#include "igamemovement.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +static CMoveData g_MoveData; +CMoveData *g_pMoveData = &g_MoveData; + +class CNEOPrediction : public CPrediction +{ + DECLARE_CLASS( CNEOPrediction, CPrediction ); + +public: + virtual void SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move ); + virtual void FinishMove( C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move ); +}; + +void CNEOPrediction::SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move ) +{ + BaseClass::SetupMove( player, ucmd, pHelper, move ); +} + +void CNEOPrediction::FinishMove( C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move ) +{ + BaseClass::FinishMove( player, ucmd, move ); +} + +// Expose interface to engine +static CPrediction g_Prediction; + +EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CPrediction, IPrediction, VCLIENT_PREDICTION_INTERFACE_VERSION, g_Prediction ); + +CPrediction *prediction = &g_Prediction; + diff --git a/mp/src/game/client/client_NeotokyoSource.vpc b/mp/src/game/client/client_NeotokyoSource.vpc index abe531aef25..4c0cf6000fc 100644 --- a/mp/src/game/client/client_NeotokyoSource.vpc +++ b/mp/src/game/client/client_NeotokyoSource.vpc @@ -36,11 +36,26 @@ $Project "Client (NeotokyoSource)" $Folder "Neotokyo DLL" { + $Folder "VGUI" + { + $File "NeotokyoSource\VGUI\neoframe.cpp" + $File "NeotokyoSource\VGUI\neoframe.h" + $File "NeotokyoSource\VGUI\neoviewport.cpp" + $File "NeotokyoSource\VGUI\neoviewport.h" + } + $File "NeotokyoSource\c_neoplayer.cpp" $File "NeotokyoSource\c_neoplayer.h" + $File "NeotokyoSource\clientmode_neonormal.cpp" + $File "NeotokyoSource\clientmode_neonormal.h" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_gamerules.cpp" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_gamerules.h" + $File "NeotokyoSource\neo_in_main.cpp" $File "$SRCDIR\game\shared\NeotokyoSource\neo_playeranimstate.h" - $File "$SRCDIR\game\shared\NeotokyoSource\neo_weapon_prase.cpp" - $File "$SRCDIR\game\shared\NeotokyoSource\neo_weapon_prase.h" + $File "NeotokyoSource\neo_prediction.cpp" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_shareddefs.h" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_weapon_parse.cpp" + $File "$SRCDIR\game\shared\NeotokyoSource\neo_weapon_parse.h" $File "$SRCDIR\game\shared\NeotokyoSource\weapon_neobase.cpp" $File "$SRCDIR\game\shared\NeotokyoSource\weapon_neobase.h" $File "$SRCDIR\game\shared\NeotokyoSource\weapon_neobasefirearm.h" diff --git a/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp b/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp index a88f2d518e9..aa5821d65c0 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp +++ b/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp @@ -1,3 +1,4 @@ +#include "cbase.h" #include "neo_gamerules.h" static CViewVectors g_NEOViewVectors( diff --git a/mp/src/game/shared/NeotokyoSource/neo_gamerules.h b/mp/src/game/shared/NeotokyoSource/neo_gamerules.h index d6c5aea7d18..9cd7e12a05e 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_gamerules.h +++ b/mp/src/game/shared/NeotokyoSource/neo_gamerules.h @@ -15,7 +15,7 @@ class CNEOGameRulesProxy : public CGameRulesProxy { public: - DECLARE_CLASS( CNEOGameRules, CGameRulesProxy ); + DECLARE_CLASS( CNEOGameRulesProxy, CGameRulesProxy ); DECLARE_NETWORKCLASS(); }; diff --git a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h new file mode 100644 index 00000000000..d3cefaa5389 --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h @@ -0,0 +1,11 @@ +#ifndef NEO_SHAREDDEFS_H +#define NEO_SHAREDDEFS_H + +#ifdef _WIN32 +#pragma once +#endif + +#define PANEL_LOADOUT "loadout" +#define PANEL_LOADOUT_DEV "loadout_dev" + +#endif // NEO_SHAREDDEFS_H diff --git a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp index c0101db3375..420e8e2bced 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp +++ b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.cpp @@ -1,13 +1,12 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - #include "cbase.h" #include #include "neo_weapon_parse.h" +CNEOWeaponInfo* GetNEOWeaponInfoFromHandle( WEAPON_FILE_INFO_HANDLE handle ) +{ + return static_cast< CNEOWeaponInfo* >(GetFileWeaponInfoFromHandle( handle )); +} + FileWeaponInfo_t* CreateWeaponInfo() { return new CNEOWeaponInfo; @@ -59,10 +58,4 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_fCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15f ); m_fTPMuzzleFlashScale = pKeyValuesData->GetFloat( "TPMuzzleFlashScale", 1.0f ); -} - -// Check the header for more info -Ochii -/*virtual const char* CNEOWeaponInfo::GetClassName() -{ - return "CNEOWeaponInfo"; -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h index 99d8897ce14..99d1c154de8 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h +++ b/mp/src/game/shared/NeotokyoSource/neo_weapon_parse.h @@ -52,12 +52,10 @@ class CNEOWeaponInfo : public FileWeaponInfo_t virtual void Parse( KeyValues *pKeyValuesData, const char *szWeaponName ); - virtual const char* GetClassName(); // This is on the original game but I'm not sure we need this, let's keep this commented for now. -Ochii - public: wchar_t m_wBulletCharacter; - char m_szTeam2viewmodel[ 80 ]; + char m_szTeam2viewmodel[ MAX_WEAPON_STRING ]; bool m_bDrawCrosshair; @@ -98,9 +96,6 @@ class CNEOWeaponInfo : public FileWeaponInfo_t float m_fTPMuzzleFlashScale; }; -CNEOWeaponInfo* GetNEOWeaponInfoFromHandle( WEAPON_FILE_INFO_HANDLE handle ) -{ - return static_cast< CNEOWeaponInfo* >(GetFileWeaponInfoFromHandle( handle )); -} +extern CNEOWeaponInfo* GetNEOWeaponInfoFromHandle( WEAPON_FILE_INFO_HANDLE handle ); #endif // NEO_WEAPON_PARSE_H diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp index c637eac0004..c3b8701c5be 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp @@ -1,3 +1,4 @@ +#include "cbase.h" #include "weapon_neobase.h" #include "c_neoplayer.h" #include "materialsystem\imaterialvar.h" @@ -595,6 +596,8 @@ bool CWeaponNEOBase::PlayEmptySound() { CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "Default.ClipEmpty_Rifle" ); + + return false; } void CWeaponNEOBase::DoNEOMuzzleFlash() From afaefc5abb0e20d38cb53e6309791464ab5307c6 Mon Sep 17 00:00:00 2001 From: Ochii Date: Sun, 19 Jun 2016 18:15:58 +0100 Subject: [PATCH 07/12] Add CNeoClassMenu And some other vgui related classes --- .../NeotokyoSource/VGUI/neoclassmenu.cpp | 212 ++++++++++++++++++ .../client/NeotokyoSource/VGUI/neoclassmenu.h | 36 +++ .../client/NeotokyoSource/VGUI/neoframe.cpp | 79 +++++++ .../client/NeotokyoSource/VGUI/neoframe.h | 35 +++ .../NeotokyoSource/VGUI/neoimagebutton.cpp | 56 +++++ .../NeotokyoSource/VGUI/neoimagebutton.h | 37 +++ .../NeotokyoSource/VGUI/neoviewport.cpp | 10 +- .../NeotokyoSource/clientmode_neonormal.cpp | 7 +- .../NeotokyoSource/clientmode_neonormal.h | 10 +- mp/src/game/client/client_NeotokyoSource.vpc | 4 + 10 files changed, 479 insertions(+), 7 deletions(-) create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoframe.h create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.h diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp new file mode 100644 index 00000000000..371f9e30d82 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp @@ -0,0 +1,212 @@ +#include "cbase.h" +#include "neoclassmenu.h" +#include "clientmode_neonormal.h" +#include "c_neoplayer.h" +#include "neoimagebutton.h" + +static const char* s_ClassMenuClassesJinrai[ 18 ] +{ + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/jinrai_scout01", + "vgui/cm/jinrai_scout02", + "vgui/cm/jinrai_scout03", + "vgui/cm/jinrai_assault01", + "vgui/cm/jinrai_assault02", + "vgui/cm/jinrai_assault03", + "vgui/cm/jinrai_heavy01", + "vgui/cm/jinrai_heavy02", + "vgui/cm/jinrai_heavy03", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none" +}; + +static const char* s_ClassMenuClassesNsf[ 18 ] +{ + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/nsf_scout01", + "vgui/cm/nsf_scout02", + "vgui/cm/nsf_scout03", + "vgui/cm/nsf_assault01", + "vgui/cm/nsf_assault02", + "vgui/cm/nsf_assault03", + "vgui/cm/nsf_heavy01", + "vgui/cm/nsf_heavy02", + "vgui/cm/nsf_heavy03", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none", + "vgui/cm/none" +}; + +// This can get really a lot simpler, let's keep it this way for now. Also we need to think on a better name +const char* GetNameOfClass( int teamId, int classId, int variant ) +{ + if ( teamId == 2 && classId < 6 && variant < 3 ) + { + return s_ClassMenuClassesJinrai[ classId + variant + 2 * classId ]; + } + + else if ( teamId == 3 && classId < 6 && variant < 3 ) + { + return s_ClassMenuClassesNsf[ classId + variant + 2 * classId ]; + } + + return "vgui/cm/none"; +} + + +CNeoClassMenu::CNeoClassMenu() : CNeoFrame( PANEL_CLASS ) +{ + m_iUnknown = 0; + m_iUnknown2 = 0; + + m_fCreationTime = gpGlobals->curtime; + + m_bUnknown2 = false; + + LoadControlSettings( "Resource/UI/ClassMenu.res" ); + InvalidateLayout(); +} + +CNeoClassMenu::~CNeoClassMenu() +{ +} + +bool CNeoClassMenu::IsVisible() +{ + return BaseClass::IsVisible(); +} + +void CNeoClassMenu::SetParent( vgui::VPANEL newParent ) +{ + BaseClass::SetParent( newParent ); +} + +void CNeoClassMenu::ApplySchemeSettings( vgui::IScheme* pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); +} + +void CNeoClassMenu::OnCommand( const char* command ) +{ + if ( GetClientModeNEONormal()->IsNEODev() ) + engine->ClientCmd( "iamantdev" ); + + if ( !V_stricmp( "vguicancel", command ) || !V_stricmp( "Close", command ) ) + { + Close(); + gViewPortInterface->ShowBackGround( false ); + } + + else if ( !V_stricmp( "playerready", command ) ) + { + engine->ClientCmd( command ); + Close(); + gViewPortInterface->ShowBackGround( false ); + } + + else if ( !V_stricmp( "SetVariant 0", command ) ) + { + C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 0; + + if ( m_bUnknown ) + { + engine->ClientCmd( command ); + Close(); + gViewPortInterface->ShowBackGround( false ); + } + } + + else if ( !V_stricmp( "SetVariant 1", command ) ) + { + C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 1; + + if ( m_bUnknown ) + { + engine->ClientCmd( command ); + Close(); + gViewPortInterface->ShowBackGround( false ); + } + } + + else if ( !V_stricmp( "SetVariant 2", command ) ) + { + C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 2; + + if ( m_bUnknown ) + { + engine->ClientCmd( command ); + Close(); + gViewPortInterface->ShowBackGround( false ); + } + } + + else if ( !V_stricmp( "setclass 1", command ) ) + { + m_bUnknown = true; + CreateImagePanels( 1 ); + engine->ClientCmd( command ); + } + + else if ( !V_stricmp( "setclass 2", command ) ) + { + m_bUnknown = true; + CreateImagePanels( 2 ); + engine->ClientCmd( command ); + } + + else if ( !V_stricmp( "setclass 3", command ) ) + { + m_bUnknown = true; + CreateImagePanels( 3 ); + engine->ClientCmd( command ); + } + + engine->ClientCmd( command ); + BaseClass::OnCommand( command ); +} + +void CNeoClassMenu::OnKeyCodePressed( vgui::KeyCode code ) +{ + if ( !m_iUnknown2 || m_iUnknown2 != code ) + BaseClass::OnKeyCodePressed( code ); +} + +void CNeoClassMenu::CreateImagePanels( int classId ) +{ + if ( classId < 1 ) + classId = 1; + + if ( classId > 3 ) + classId = 3; + + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( !localPlayer ) + return; + + if ( localPlayer->GetTeamNumber() != 2 && localPlayer->GetTeamNumber() != 3 ) + { + m_bUnknown2 = true; + classId = 0; + } + + vgui::CNImageButton* imagePanel = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel" ); + imagePanel->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) ); + + vgui::CNImageButton* imagePanel2 = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel2" ); + imagePanel2->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) ); + + vgui::CNImageButton* imagePanel3 = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel3" ); + imagePanel3->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) ); +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h new file mode 100644 index 00000000000..de4ce27c544 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h @@ -0,0 +1,36 @@ +#ifndef NEO_CLASSMENU_H +#define NEO_CLASSMENU_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "neoframe.h" +#include + +class CNeoClassMenu : public vgui::CNeoFrame, public IViewPortPanel +{ + DECLARE_CLASS_SIMPLE( CNeoClassMenu, vgui::CNeoFrame ); + +public: + CNeoClassMenu(); + virtual ~CNeoClassMenu(); + +public: + virtual bool IsVisible(); + virtual void SetParent( vgui::VPANEL newParent ); + virtual void ApplySchemeSettings( vgui::IScheme* pScheme ); + virtual void OnCommand( const char* command ); + virtual void OnKeyCodePressed( vgui::KeyCode code ); + + void CreateImagePanels( int classId ); + +private: + int m_iUnknown; + int m_iUnknown2; + float m_fCreationTime; + bool m_bUnknown; + bool m_bUnknown2; +}; + +#endif // NEO_CLASSMENU_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp new file mode 100644 index 00000000000..a722bd096af --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp @@ -0,0 +1,79 @@ +#include "cbase.h" +#include "neoframe.h" +#include + +namespace vgui +{ + +CNeoFrame::CNeoFrame( const char *panelName ) : Frame( nullptr, panelName ) +{ + ISurface* pSurface = surface(); + ISchemeManager* pScheme = scheme(); + + SetScheme( pScheme->LoadSchemeFromFile( "resource/ClientScheme.res", "ClientScheme" ) ); + + m_iTextureID1 = pSurface->CreateNewTextureID(); + pSurface->DrawSetTextureFile( m_iTextureID1, "vgui/ngui_corner", true, false ); + + m_iTextureID2 = pSurface->CreateNewTextureID(); + pSurface->DrawSetTextureFile( m_iTextureID1, "vgui/ngui_titlebar", true, false ); + + m_iTextureID3 = pSurface->CreateNewTextureID(); + pSurface->DrawSetTextureFile( m_iTextureID1, "vgui/ngui_body", true, false ); + + SetMoveable( false ); + SetSizeable( false ); + SetPaintBackgroundEnabled( false ); + InvalidateLayout(); +} + +CNeoFrame::~CNeoFrame() +{ +} + +bool CNeoFrame::IsVisible() +{ + return BaseClass::IsVisible(); +} + +void CNeoFrame::SetParent( VPANEL newParent ) +{ + BaseClass::SetParent( newParent ); +} + +void CNeoFrame::ApplySchemeSettings( IScheme *pScheme ) +{ +} + +void CNeoFrame::PaintBackground() +{ + BaseClass::PaintBackground(); +} + +void CNeoFrame::Paint() +{ + int wide, tall; + auto pSurface = surface(); + + GetSize( wide, tall ); + + pSurface->DrawSetColor( 255, 255, 255, 255 ); + + pSurface->DrawSetTexture( m_iTextureID1 ); + pSurface->DrawTexturedRect( 0, 0, 16, 16 ); + + pSurface->DrawSetTexture( m_iTextureID2 ); + pSurface->DrawTexturedRect( 16, 0, wide, 16 ); + + pSurface->DrawSetTexture( m_iTextureID3 ); + pSurface->DrawTexturedRect( 0, 16, wide, tall ); + + pSurface->DrawSetColor( 0, 0, 0, 255 ); + + pSurface->DrawFilledRect( 0, tall - 1, wide, tall ); + pSurface->DrawFilledRect( wide - 1, 0, wide, tall ); + + CNeoFrame::Paint(); +} + +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoframe.h b/mp/src/game/client/NeotokyoSource/VGUI/neoframe.h new file mode 100644 index 00000000000..acff4634f4a --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoframe.h @@ -0,0 +1,35 @@ +#ifndef NEO_FRAME_H +#define NEO_FRAME_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls\Frame.h" + +namespace vgui +{ + +class CNeoFrame : public Frame +{ + DECLARE_CLASS_SIMPLE( CNeoFrame, Frame ); + +public: + CNeoFrame( const char *panelName ); + virtual ~CNeoFrame(); + + virtual bool IsVisible(); + virtual void SetParent( VPANEL newParent ); + virtual void ApplySchemeSettings( IScheme *pScheme ); + virtual void PaintBackground(); + virtual void Paint(); + +private: + int m_iTextureID1; + int m_iTextureID2; + int m_iTextureID3; +}; + +} + +#endif // NEO_FRAME_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.cpp new file mode 100644 index 00000000000..0802f9e675f --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.cpp @@ -0,0 +1,56 @@ +#include "cbase.h" +#include "neoimagebutton.h" +#include + +namespace vgui +{ + +CNImageButton::CNImageButton( Panel *parent, const char *panelName, const char *text ) : Button( parent, panelName, text ) +{ + SetPaintBackgroundEnabled( false ); + + m_iTextureID = 0; + m_bUnknown = false; +} + +CNImageButton::~CNImageButton() +{ +} + +void CNImageButton::ApplySettings( KeyValues *inResourceData ) +{ + const char* image = inResourceData->GetString( "command", "" ); + + if ( image ) + { + m_iTextureID = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iTextureID, image, true, false ); + } + + BaseClass::ApplySettings( inResourceData ); +} + +void CNImageButton::OnMousePressed( MouseCode code ) +{ + BaseClass::OnMousePressed( code ); +} + +void CNImageButton::PaintBackground() +{ +} + +void CNImageButton::PaintBorder() +{ +} + +void CNImageButton::DrawFocusBorder( int tx0, int ty0, int tx1, int ty1 ) +{ +} + +void CNImageButton::SetTexture( const char* textureName ) +{ + m_iTextureID = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iTextureID, textureName, true, false ); +} + +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.h b/mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.h new file mode 100644 index 00000000000..54bb40c9272 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoimagebutton.h @@ -0,0 +1,37 @@ +#ifndef NEO_IMAGEBUTTON_H +#define NEO_IMAGEBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include + +namespace vgui +{ + +class CNImageButton : public Button +{ + DECLARE_CLASS_SIMPLE( CNImageButton, Button ); + +public: + CNImageButton( Panel *parent, const char *panelName, const char *text ); + virtual ~CNImageButton(); + +public: + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void OnMousePressed( MouseCode code ); + virtual void PaintBackground(); + virtual void PaintBorder(); + virtual void DrawFocusBorder( int tx0, int ty0, int tx1, int ty1 ); + + void SetTexture( const char* textureName ); + +private: + int m_iTextureID; + bool m_bUnknown; +}; + +} + +#endif // NEO_IMAGEBUTTON_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp index 86f1a4fd2b4..f16cb74808d 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp @@ -15,27 +15,27 @@ IViewPortPanel* NEOViewport::CreatePanelByName( const char *szPanelName ) { IViewPortPanel* newpanel = nullptr; - if ( Q_strcmp( PANEL_TEAM, szPanelName ) == 0 ) + if ( V_strcmp( PANEL_TEAM, szPanelName ) == 0 ) { //newpanel = new CNeoTeamMenu( this ); } - else if ( Q_strcmp( PANEL_SCOREBOARD, szPanelName ) == 0 ) + else if ( V_strcmp( PANEL_SCOREBOARD, szPanelName ) == 0 ) { //newpanel = new CNEOClientScoreBoardDialog( this ); } - else if ( Q_strcmp( PANEL_CLASS, szPanelName ) == 0 ) + else if ( V_strcmp( PANEL_CLASS, szPanelName ) == 0 ) { //newpanel = new CNeoClassMenu( this ); } - else if ( Q_strcmp( PANEL_LOADOUT_DEV, szPanelName ) == 0 ) + else if ( V_strcmp( PANEL_LOADOUT_DEV, szPanelName ) == 0 ) { //newpanel = new CNeoLoadoutMenu_Dev( this ); } - else if ( Q_strcmp( PANEL_LOADOUT, szPanelName ) == 0 ) + else if ( V_strcmp( PANEL_LOADOUT, szPanelName ) == 0 ) { //newpanel = new CNeoLoadoutMenu( this ); } diff --git a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp index 5a99f198868..4b24b450bd8 100644 --- a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp +++ b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp @@ -13,11 +13,16 @@ IClientMode* GetClientModeNormal() return &g_ClientModeNormal; } +ClientModeNEONormal* GetClientModeNEONormal() +{ + return (ClientModeNEONormal*) GetClientModeNormal(); +} + ClientModeNEONormal::ClientModeNEONormal() { m_bUnknown = false; - m_bUnknown2 = false; + m_bIsNEODev = false; } ClientModeNEONormal::~ClientModeNEONormal() diff --git a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h index 72a47deb334..038f4c2fe6f 100644 --- a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h +++ b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.h @@ -26,11 +26,19 @@ class ClientModeNEONormal : public ClientModeShared virtual void LevelShutdown(); virtual float GetViewModelFOV(); + bool IsNEODev(); + private: bool m_bUnknown; - bool m_bUnknown2; + bool m_bIsNEODev; }; +inline bool ClientModeNEONormal::IsNEODev() +{ + return m_bIsNEODev; +} + extern IClientMode* GetClientModeNormal(); +extern ClientModeNEONormal* GetClientModeNEONormal(); #endif // CLIENTMODE_NEONORMAL_H \ No newline at end of file diff --git a/mp/src/game/client/client_NeotokyoSource.vpc b/mp/src/game/client/client_NeotokyoSource.vpc index 4c0cf6000fc..6a7b5e71ce6 100644 --- a/mp/src/game/client/client_NeotokyoSource.vpc +++ b/mp/src/game/client/client_NeotokyoSource.vpc @@ -38,8 +38,12 @@ $Project "Client (NeotokyoSource)" { $Folder "VGUI" { + $File "NeotokyoSource\VGUI\neoclassmenu.cpp" + $File "NeotokyoSource\VGUI\neoclassmenu.h" $File "NeotokyoSource\VGUI\neoframe.cpp" $File "NeotokyoSource\VGUI\neoframe.h" + $File "NeotokyoSource\VGUI\neoimagebutton.cpp" + $File "NeotokyoSource\VGUI\neoimagebutton.h" $File "NeotokyoSource\VGUI\neoviewport.cpp" $File "NeotokyoSource\VGUI\neoviewport.h" } From 05fac4a0000ec0f7e4386f994273bab1ee9aae93 Mon Sep 17 00:00:00 2001 From: Ochii Date: Tue, 21 Jun 2016 16:12:08 +0100 Subject: [PATCH 08/12] Add CNeoTeamMenu --- .../client/NeotokyoSource/VGUI/neobutton.cpp | 52 ++++++ .../client/NeotokyoSource/VGUI/neobutton.h | 39 +++++ .../NeotokyoSource/VGUI/neoclassmenu.cpp | 81 +++++++-- .../client/NeotokyoSource/VGUI/neoclassmenu.h | 24 ++- .../client/NeotokyoSource/VGUI/neoframe.cpp | 3 +- .../NeotokyoSource/VGUI/neoteammenu.cpp | 163 ++++++++++++++++++ .../client/NeotokyoSource/VGUI/neoteammenu.h | 42 +++++ .../NeotokyoSource/VGUI/neoviewport.cpp | 6 +- .../shared/NeotokyoSource/neo_shareddefs.h | 4 + 9 files changed, 386 insertions(+), 28 deletions(-) create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neobutton.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neobutton.h create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neobutton.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neobutton.cpp new file mode 100644 index 00000000000..43332759b8e --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neobutton.cpp @@ -0,0 +1,52 @@ +#include "cbase.h" +#include "neobutton.h" +#include + +namespace vgui +{ + +CNButton::CNButton( Panel *parent, const char *panelName, const char *text ) : Button( parent, panelName, text ) +{ + SetPaintBackgroundEnabled( false ); + + m_iButtonNormalId = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iButtonNormalId, "vgui/buttons/button_normal", true, false ); + + m_iButtonPressedId = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iButtonPressedId, "vgui/buttons/button_pressed", true, false ); + + m_iButtonMouseoverId = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iButtonMouseoverId, "vgui/buttons/button_mouseover", true, false ); + + m_iButtonDisabledId = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iButtonDisabledId, "vgui/buttons/button_disabled", true, false ); + + m_iButtonArmedId = surface()->CreateNewTextureID(); + surface()->DrawSetTextureFile( m_iButtonArmedId, "vgui/buttons/button_armed", true, false ); + + m_fUnknown = 0.f; +} + +CNButton::~CNButton() +{ +} + +void CNButton::OnMousePressed( MouseCode code ) +{ + BaseClass::OnMousePressed( code ); +} + +void CNButton::PaintBackground() +{ +} + +void CNButton::PaintBorder() +{ +} + +void CNButton::DrawFocusBorder( int tx0, int ty0, int tx1, int ty1 ) +{ + BaseClass::DrawFocusBorder( tx0, ty0, tx1, ty1 - 2 ); +} + +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neobutton.h b/mp/src/game/client/NeotokyoSource/VGUI/neobutton.h new file mode 100644 index 00000000000..8e0a5c5ffa3 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neobutton.h @@ -0,0 +1,39 @@ +#ifndef NEO_BUTTON_H +#define NEO_BUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include + +namespace vgui +{ + +class CNButton : public Button +{ + DECLARE_CLASS_SIMPLE( CNButton, Button ); + +public: + CNButton( Panel *parent, const char *panelName, const char *text ); + virtual ~CNButton(); + +public: + virtual void OnMousePressed( MouseCode code ); + virtual void PaintBackground(); + virtual void PaintBorder(); + virtual void DrawFocusBorder( int tx0, int ty0, int tx1, int ty1 ); + +private: + int m_iButtonNormalId; + int m_iButtonPressedId; + int m_iButtonMouseoverId; + int m_iButtonDisabledId; + int m_iButtonArmedId; + + float m_fUnknown; +}; + +} + +#endif // NEO_BUTTON_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp index 371f9e30d82..2dacf33adf2 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp @@ -3,6 +3,7 @@ #include "clientmode_neonormal.h" #include "c_neoplayer.h" #include "neoimagebutton.h" +#include "IGameUIFuncs.h" static const char* s_ClassMenuClassesJinrai[ 18 ] { @@ -65,31 +66,23 @@ const char* GetNameOfClass( int teamId, int classId, int variant ) } -CNeoClassMenu::CNeoClassMenu() : CNeoFrame( PANEL_CLASS ) +CNeoClassMenu::CNeoClassMenu( IViewPort *pViewPort ) : CNeoFrame( PANEL_CLASS ) { - m_iUnknown = 0; - m_iUnknown2 = 0; + m_pViewPort = pViewPort; - m_fCreationTime = gpGlobals->curtime; + m_iJumpKey = 0; + m_iScoreboardKey = 0; - m_bUnknown2 = false; + m_bNeedsUpdate = false; LoadControlSettings( "Resource/UI/ClassMenu.res" ); InvalidateLayout(); -} - -CNeoClassMenu::~CNeoClassMenu() -{ -} -bool CNeoClassMenu::IsVisible() -{ - return BaseClass::IsVisible(); + m_fCreationTime = gpGlobals->curtime; } -void CNeoClassMenu::SetParent( vgui::VPANEL newParent ) +CNeoClassMenu::~CNeoClassMenu() { - BaseClass::SetParent( newParent ); } void CNeoClassMenu::ApplySchemeSettings( vgui::IScheme* pScheme ) @@ -178,10 +171,64 @@ void CNeoClassMenu::OnCommand( const char* command ) void CNeoClassMenu::OnKeyCodePressed( vgui::KeyCode code ) { - if ( !m_iUnknown2 || m_iUnknown2 != code ) + if ( !m_iScoreboardKey || m_iScoreboardKey != code ) BaseClass::OnKeyCodePressed( code ); } +void CNeoClassMenu::Update() +{ + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( localPlayer && (localPlayer->GetTeamNumber() == 2 || localPlayer->GetTeamNumber() == 3) ) + { + m_bNeedsUpdate = false; + CreateImagePanels( localPlayer->m_iClassType ); + } +} + +void CNeoClassMenu::ShowPanel( bool bShow ) +{ + gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false ); + + if ( IsVisible() == bShow ) + return; + + if ( bShow ) + { + Activate(); + SetMouseInputEnabled( true ); + + if ( !m_iJumpKey ) + m_iJumpKey = gameuifuncs->GetButtonCodeForBind( "jump" ); + + if ( !m_iScoreboardKey ) + m_iScoreboardKey = gameuifuncs->GetButtonCodeForBind( "showscores" ); + + MoveToCenterOfScreen(); + + int classId = C_NEOPlayer::GetLocalNEOPlayer()->m_iClassType; + + if ( classId == 0 ) + { + classId = 1; + engine->ClientCmd( "setclass 1" ); + } + + m_bUnknown = true; + + CreateImagePanels( classId ); + CreateImagePanels( classId ); + } + + else + { + SetVisible( false ); + SetMouseInputEnabled( false ); + } + + m_pViewPort->ShowBackGround( bShow ); +} + void CNeoClassMenu::CreateImagePanels( int classId ) { if ( classId < 1 ) @@ -197,7 +244,7 @@ void CNeoClassMenu::CreateImagePanels( int classId ) if ( localPlayer->GetTeamNumber() != 2 && localPlayer->GetTeamNumber() != 3 ) { - m_bUnknown2 = true; + m_bNeedsUpdate = true; classId = 0; } diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h index de4ce27c544..fcb66c77b2a 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.h @@ -13,12 +13,21 @@ class CNeoClassMenu : public vgui::CNeoFrame, public IViewPortPanel DECLARE_CLASS_SIMPLE( CNeoClassMenu, vgui::CNeoFrame ); public: - CNeoClassMenu(); + CNeoClassMenu( IViewPort *pViewPort ); virtual ~CNeoClassMenu(); -public: - virtual bool IsVisible(); - virtual void SetParent( vgui::VPANEL newParent ); + virtual const char *GetName( void ) { return PANEL_CLASS; } + virtual void SetData( KeyValues *data ) {}; + virtual void Reset() {}; + virtual void Update(); + virtual bool NeedsUpdate( void ) { return m_bNeedsUpdate; } + virtual bool HasInputElements( void ) { return true; } + virtual void ShowPanel( bool bShow ); + + vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); } + virtual bool IsVisible() { return BaseClass::IsVisible(); } + virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); } + virtual void ApplySchemeSettings( vgui::IScheme* pScheme ); virtual void OnCommand( const char* command ); virtual void OnKeyCodePressed( vgui::KeyCode code ); @@ -26,11 +35,12 @@ class CNeoClassMenu : public vgui::CNeoFrame, public IViewPortPanel void CreateImagePanels( int classId ); private: - int m_iUnknown; - int m_iUnknown2; + IViewPort* m_pViewPort; + int m_iJumpKey; + int m_iScoreboardKey; float m_fCreationTime; bool m_bUnknown; - bool m_bUnknown2; + bool m_bNeedsUpdate; }; #endif // NEO_CLASSMENU_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp index a722bd096af..916b6eeca0f 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoframe.cpp @@ -8,9 +8,8 @@ namespace vgui CNeoFrame::CNeoFrame( const char *panelName ) : Frame( nullptr, panelName ) { ISurface* pSurface = surface(); - ISchemeManager* pScheme = scheme(); - SetScheme( pScheme->LoadSchemeFromFile( "resource/ClientScheme.res", "ClientScheme" ) ); + SetScheme( scheme()->LoadSchemeFromFile( "resource/ClientScheme.res", "ClientScheme" ) ); m_iTextureID1 = pSurface->CreateNewTextureID(); pSurface->DrawSetTextureFile( m_iTextureID1, "vgui/ngui_corner", true, false ); diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp new file mode 100644 index 00000000000..daaa48c3d80 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp @@ -0,0 +1,163 @@ +#include "cbase.h" +#include "neoteammenu.h" +#include "neo_shareddefs.h" +#include "c_team.h" // c_neoteam.h +#include "c_neoplayer.h" +#include "IGameUIFuncs.h" +#include +#include +#include + + +CNeoTeamMenu::CNeoTeamMenu( IViewPort *pViewPort ) : CNeoFrame( PANEL_TEAM ) +{ + m_pViewPort = pViewPort; + + m_iJumpKey = 0; + m_iScoreboardKey = 0; + + LoadControlSettings( "Resource/UI/TeamMenu.res" ); + InvalidateLayout(); + + m_fCreationTime = gpGlobals->curtime; +} + +CNeoTeamMenu::~CNeoTeamMenu() +{ +} + +void CNeoTeamMenu::ApplySchemeSettings( vgui::IScheme* pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); +} + +void CNeoTeamMenu::OnCommand( const char* command ) +{ + if ( V_stricmp( "vguicancel", command ) && V_stricmp( "Close", command ) ) + engine->ClientCmd( command ); + + Close(); + gViewPortInterface->ShowBackGround( false ); + + BaseClass::OnCommand( command ); +} + +void CNeoTeamMenu::OnKeyCodePressed( vgui::KeyCode code ) +{ + if ( m_iJumpKey && m_iJumpKey == code ) + engine->ClientCmd( "jointeam 0" ); + + if ( !m_iScoreboardKey || m_iScoreboardKey != code ) + BaseClass::OnKeyCodePressed( code ); +} + +void CNeoTeamMenu::Update() +{ + wchar_t buffer[ 1024 ]; + wchar_t buffer2[ 6 ]; + + vgui::Label* jplayerCountLabel = dynamic_cast< vgui::Label* >( FindChildByName( "jplayercountlabel" ) ); + vgui::Label* jScoreLabel = dynamic_cast< vgui::Label* >(FindChildByName( "jscorelabel" )); + vgui::Label* nplayerCountLabel = dynamic_cast< vgui::Label* >(FindChildByName( "nplayercountlabel" )); + vgui::Label* nScoreLabel = dynamic_cast< vgui::Label* >(FindChildByName( "nscorelabel" )); + + /*C_NEOTeam*/ C_Team* jinraiTeam = GetGlobalTeam( TEAM_JINRAI ); + + if ( jinraiTeam ) + { + if ( jinraiTeam->GetNumPlayers() > 0 ) + { + g_pVGuiLocalize->ConvertANSIToUnicode( "PLAYERS: ", buffer, sizeof( buffer ) ); + + V_snwprintf( buffer2, V_wcslen( buffer2 ), L"%i", jinraiTeam->GetNumPlayers() ); + + V_wcscat( buffer, buffer2, V_wcslen( buffer ) ); + } + + else + g_pVGuiLocalize->ConvertANSIToUnicode( "PLAYERS: 0", buffer, sizeof( buffer ) ); + + jplayerCountLabel->SetText( buffer ); + + //if ( jinraiTeam->GetTeamScore() > 0 ) // This seems to be a virtual from C_NEOTeam, gotta reverse it + //{ + g_pVGuiLocalize->ConvertANSIToUnicode( "SCORE: ", buffer, sizeof( buffer ) ); + + V_snwprintf( buffer2, V_wcslen( buffer2 ), L"%i"/*, jinraiTeam->GetTeamScore()*/ ); + + V_wcscat( buffer, buffer2, V_wcslen( buffer ) ); + //} + + //else + g_pVGuiLocalize->ConvertANSIToUnicode( "SCORE: 0", buffer, sizeof( buffer ) ); + + jScoreLabel->SetText( buffer ); + } + + /*C_NEOTeam*/ C_Team* nsfTeam = GetGlobalTeam( TEAM_NSF ); + + if ( nsfTeam ) + { + if ( nsfTeam->GetNumPlayers() > 0 ) + { + g_pVGuiLocalize->ConvertANSIToUnicode( "PLAYERS: ", buffer, sizeof( buffer ) ); + + V_snwprintf( buffer2, V_wcslen( buffer2 ), L"%i", nsfTeam->GetNumPlayers() ); + + V_wcscat( buffer, buffer2, V_wcslen( buffer ) ); + } + + else + g_pVGuiLocalize->ConvertANSIToUnicode( "PLAYERS: 0", buffer, sizeof( buffer ) ); + + nplayerCountLabel->SetText( buffer ); + + //if ( nsfTeam->GetTeamScore() > 0 ) + //{ + g_pVGuiLocalize->ConvertANSIToUnicode( "SCORE: ", buffer, sizeof( buffer ) ); + + V_snwprintf( buffer2, V_wcslen( buffer2 ), L"%i"/*, nsfTeam->GetTeamScore()*/ ); + + V_wcscat( buffer, buffer2, V_wcslen( buffer ) ); + //} + + //else + g_pVGuiLocalize->ConvertANSIToUnicode( "SCORE: 0", buffer, sizeof( buffer ) ); + + nScoreLabel->SetText( buffer ); + } +} + +void CNeoTeamMenu::ShowPanel( bool bShow ) +{ + gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false ); + + if ( IsVisible() == bShow ) + return; + + if ( bShow ) + { + Activate(); + SetMouseInputEnabled( true ); + + if ( !m_iJumpKey ) + m_iJumpKey = gameuifuncs->GetButtonCodeForBind( "jump" ); + + if ( !m_iScoreboardKey ) + m_iScoreboardKey = gameuifuncs->GetButtonCodeForBind( "showscores" ); + + MoveToCenterOfScreen(); + + vgui::Button* cancelButton = dynamic_cast< vgui::Button* >( FindChildByName( "CancelButton" ) ); + + cancelButton->SetEnabled( C_NEOPlayer::GetLocalNEOPlayer()->GetTeamNumber() != TEAM_UNASSIGNED ); + } + + else + { + SetVisible( false ); + SetMouseInputEnabled( false ); + } + + m_pViewPort->ShowBackGround( bShow ); +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h new file mode 100644 index 00000000000..b75d21dfa49 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h @@ -0,0 +1,42 @@ +#ifndef NEO_TEAMMENU_H +#define NEO_TEAMMENU_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "neoframe.h" +#include + +class CNeoTeamMenu : public vgui::CNeoFrame, public IViewPortPanel +{ + DECLARE_CLASS_SIMPLE( CNeoTeamMenu, vgui::CNeoFrame ); + +public: + CNeoTeamMenu( IViewPort *pViewPort ); + virtual ~CNeoTeamMenu(); + + virtual const char *GetName( void ) { return PANEL_CLASS; } + virtual void SetData( KeyValues *data ) {}; + virtual void Reset() {}; + virtual void Update(); + virtual bool NeedsUpdate( void ) { return true; } + virtual bool HasInputElements( void ) { return true; } + virtual void ShowPanel( bool bShow ); + + vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); } + virtual bool IsVisible() { return BaseClass::IsVisible(); } + virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); } + + virtual void ApplySchemeSettings( vgui::IScheme* pScheme ); + virtual void OnCommand( const char* command ); + virtual void OnKeyCodePressed( vgui::KeyCode code ); + +private: + IViewPort* m_pViewPort; + int m_iJumpKey; + int m_iScoreboardKey; + float m_fCreationTime; +}; + +#endif // NEO_TEAMMENU_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp index f16cb74808d..5b507adcf41 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp @@ -1,6 +1,8 @@ #include "cbase.h" #include "NEOViewport.h" #include "neo_shareddefs.h" +#include "neoteammenu.h" +#include "neoclassmenu.h" void NEOViewport::ApplySchemeSettings( vgui::IScheme *pScheme ) { @@ -17,7 +19,7 @@ IViewPortPanel* NEOViewport::CreatePanelByName( const char *szPanelName ) if ( V_strcmp( PANEL_TEAM, szPanelName ) == 0 ) { - //newpanel = new CNeoTeamMenu( this ); + newpanel = new CNeoTeamMenu( this ); } else if ( V_strcmp( PANEL_SCOREBOARD, szPanelName ) == 0 ) @@ -27,7 +29,7 @@ IViewPortPanel* NEOViewport::CreatePanelByName( const char *szPanelName ) else if ( V_strcmp( PANEL_CLASS, szPanelName ) == 0 ) { - //newpanel = new CNeoClassMenu( this ); + newpanel = new CNeoClassMenu( this ); } else if ( V_strcmp( PANEL_LOADOUT_DEV, szPanelName ) == 0 ) diff --git a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h index d3cefaa5389..2e353a32e23 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h +++ b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h @@ -8,4 +8,8 @@ #define PANEL_LOADOUT "loadout" #define PANEL_LOADOUT_DEV "loadout_dev" +#define TEAM_JINRAI 2 +#define TEAM_NSF 3 +#define TEAM_MAXCOUNT 4 + #endif // NEO_SHAREDDEFS_H From 4a66c82dc91e641cb321061190c7d3934109787f Mon Sep 17 00:00:00 2001 From: Ochii Date: Thu, 23 Jun 2016 19:22:00 +0100 Subject: [PATCH 09/12] Add loadout menues What a mess --- .../NeotokyoSource/VGUI/neoclassmenu.cpp | 20 +- .../NeotokyoSource/VGUI/neoloadoutmenu.cpp | 301 ++++++++++++++++++ .../NeotokyoSource/VGUI/neoloadoutmenu.h | 81 +++++ .../VGUI/neoloadoutmenu_dev.cpp | 138 ++++++++ .../NeotokyoSource/VGUI/neoloadoutmenu_dev.h | 48 +++ .../NeotokyoSource/VGUI/neoteammenu.cpp | 2 +- .../client/NeotokyoSource/VGUI/neoteammenu.h | 2 +- .../NeotokyoSource/VGUI/neoviewport.cpp | 6 +- .../NeotokyoSource/clientmode_neonormal.cpp | 6 +- .../shared/NeotokyoSource/neo_shareddefs.h | 25 +- 10 files changed, 609 insertions(+), 20 deletions(-) create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.h diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp index 2dacf33adf2..c716f85ab28 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp @@ -95,20 +95,20 @@ void CNeoClassMenu::OnCommand( const char* command ) if ( GetClientModeNEONormal()->IsNEODev() ) engine->ClientCmd( "iamantdev" ); - if ( !V_stricmp( "vguicancel", command ) || !V_stricmp( "Close", command ) ) + if ( !V_stricmp( command, "vguicancel" ) || !V_stricmp( command, "Close" ) ) { Close(); gViewPortInterface->ShowBackGround( false ); } - else if ( !V_stricmp( "playerready", command ) ) + else if ( !V_stricmp( command, "playerready" ) ) { engine->ClientCmd( command ); Close(); gViewPortInterface->ShowBackGround( false ); } - else if ( !V_stricmp( "SetVariant 0", command ) ) + else if ( !V_stricmp( command, "SetVariant 0" ) ) { C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 0; @@ -120,7 +120,7 @@ void CNeoClassMenu::OnCommand( const char* command ) } } - else if ( !V_stricmp( "SetVariant 1", command ) ) + else if ( !V_stricmp( command, "SetVariant 1" ) ) { C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 1; @@ -132,7 +132,7 @@ void CNeoClassMenu::OnCommand( const char* command ) } } - else if ( !V_stricmp( "SetVariant 2", command ) ) + else if ( !V_stricmp( command, "SetVariant 2" ) ) { C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 2; @@ -144,21 +144,21 @@ void CNeoClassMenu::OnCommand( const char* command ) } } - else if ( !V_stricmp( "setclass 1", command ) ) + else if ( !V_stricmp( command, "setclass 1" ) ) { m_bUnknown = true; CreateImagePanels( 1 ); engine->ClientCmd( command ); } - else if ( !V_stricmp( "setclass 2", command ) ) + else if ( !V_stricmp( command, "setclass 2" ) ) { m_bUnknown = true; CreateImagePanels( 2 ); engine->ClientCmd( command ); } - else if ( !V_stricmp( "setclass 3", command ) ) + else if ( !V_stricmp( command, "setclass 3" ) ) { m_bUnknown = true; CreateImagePanels( 3 ); @@ -252,8 +252,8 @@ void CNeoClassMenu::CreateImagePanels( int classId ) imagePanel->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) ); vgui::CNImageButton* imagePanel2 = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel2" ); - imagePanel2->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) ); + imagePanel2->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 1 ) ); vgui::CNImageButton* imagePanel3 = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel3" ); - imagePanel3->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) ); + imagePanel3->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 2) ); } \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp new file mode 100644 index 00000000000..844a958c867 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp @@ -0,0 +1,301 @@ +#include "cbase.h" +#include "neoloadoutmenu.h" +#include "clientmode_neonormal.h" +#include "c_neoplayer.h" +#include "IGameUIFuncs.h" +#include "neoimagebutton.h" + +static CLoadoutWeaponClass s_DevLoadoutWeapons[ 14 ] +{ + { "MPN45", "vgui/loadout/loadout_mpn", "weapon_mpn", "AMMO_PRI" }, + { "SRM", "vgui/loadout/loadout_srm", "weapon_srm", "AMMO_PRI" }, + { "SRM (silenced)", "vgui/loadout/loadout_srms", "weapon_srm_s", "AMMO_PRI" }, + { "Jitte", "vgui/loadout/loadout_jitte", "weapon_jitte", "AMMO_PRI" }, + { "Jitte (with scope)", "vgui/loadout/loadout_jittes", "weapon_jittescoped", "AMMO_PRI" }, + { "ZR68-C (compact)", "vgui/loadout/loadout_zr68c", "weapon_zr68c", "AMMO_PRI" }, + { "ZR68-S (silenced)", "vgui/loadout/loadout_zr68s", "weapon_zr68s", "AMMO_PRI" }, + { "ZR68-L (accurized)", "vgui/loadout/loadout_zr68l", "weapon_zr68l", "AMMO_PRI" }, + { "MX", "vgui/loadout/loadout_mx", "weapon_mx", "AMMO_PRI" }, + { "PZ252", "vgui/loadout/loadout_pz", "weapon_pz", "AMMO_PRI" }, + { "Murata Supa-7", "vgui/loadout/loadout_supa7", "weapon_supa7", "AMMO_PRI" }, + { "Mosok", "vgui/loadout/loadout_mosok", "weapon_m41", "AMMO_PRI" }, + { "Mosok (with scope)", "vgui/loadout/loadout_mosokl", "weapon_m41l", "AMMO_PRI" }, + { "", "", "", "AMMO_PRI" } +}; + +static CLoadoutWeaponClass s_ReconLoadoutWeapons[ 10 ] +{ + { "MPN45", "vgui/loadout/loadout_mpn", "weapon_mpn", "AMMO_PRI" }, + { "SRM", "vgui/loadout/loadout_srm", "weapon_srm", "AMMO_PRI" }, + { "Jitte", "vgui/loadout/loadout_jitte", "weapon_jitte", "AMMO_PRI" }, + { "SRM (silenced)", "vgui/loadout/loadout_srms", "weapon_srm_s", "AMMO_PRI" }, + { "Jitte (with scope)", "vgui/loadout/loadout_jittes", "weapon_jittescoped", "AMMO_PRI" }, + { "ZR68-L (accurized)", "vgui/loadout/loadout_zr68l", "weapon_zr68l", "AMMO_PRI" }, + { "ZR68C", "vgui/loadout/loadout_zr68c", "weapon_zr68c", "AMMO_PRI" }, + { "Murata Supa-7", "vgui/loadout/loadout_supa7", "weapon_supa7", "AMMO_10G_SHELL" }, + { "Mosok Silenced", "vgui/loadout/loadout_mosokl", "weapon_m41s", "AMMO_PRI" }, + { "", "", "", "AMMO_PRI" } +}; + +static CLoadoutWeaponClass s_AssaultLoadoutWeapons[ 13 ] +{ + { "MPN45", "vgui/loadout/loadout_mpn", "weapon_mpn", "AMMO_PRI" }, + { "SRM", "vgui/loadout/loadout_srm", "weapon_srm", "AMMO_PRI" }, + { "Jitte", "vgui/loadout/loadout_jitte", "weapon_jitte", "AMMO_PRI" }, + { "ZR68-C (compact)", "vgui/loadout/loadout_zr68c", "weapon_zr68c", "AMMO_PRI" }, + { "ZR68-S (silenced)", "vgui/loadout/loadout_zr68s", "weapon_zr68s", "AMMO_PRI" }, + { "Murata Supa-7", "vgui/loadout/loadout_supa7", "weapon_supa7", "AMMO_10G_SHELL" }, + { "Mosok", "vgui/loadout/loadout_mosok", "weapon_m41", "AMMO_PRI" }, + { "Mosok Silenced", "vgui/loadout/loadout_mosokl", "weapon_m41s", "AMMO_PRI" }, + { "MX", "vgui/loadout/loadout_mx", "weapon_mx", "AMMO_PRI" }, + { "MX Silenced", "vgui/loadout/loadout_mxs", "weapon_mx_silenced", "AMMO_PRI" }, + { "AA13", "vgui/loadout/loadout_aa13", "weapon_aa13", "AMMO_10G_SHELL" }, + { "SRS", "vgui/loadout/loadout_srs", "weapon_srs", "AMMO_PRI" }, + { "", "", "", "AMMO_PRI" } +}; + +static CLoadoutWeaponClass s_SupportLoadoutWeapons[ 10 ] +{ + { "MPN45", "vgui/loadout/loadout_mpn", "weapon_mpn", "AMMO_PRI" }, + { "SRM", "vgui/loadout/loadout_srm", "weapon_srm", "AMMO_PRI" }, + { "ZR68-C (compact)", "vgui/loadout/loadout_zr68c", "weapon_zr68c", "AMMO_PRI" }, + { "Mosok", "vgui/loadout/loadout_mosok", "weapon_m41", "AMMO_PRI" }, + { "Murata Supa-7", "vgui/loadout/loadout_supa7", "weapon_supa7", "AMMO_10G_SHELL" }, + { "MX", "vgui/loadout/loadout_mx", "weapon_mx", "AMMO_PRI" }, + { "Mosok Silenced", "vgui/loadout/loadout_mosokl", "weapon_m41s", "AMMO_PRI" }, + { "MX Silenced", "vgui/loadout/loadout_mxs", "weapon_mx_silenced", "AMMO_PRI" }, + { "PZ252", "vgui/loadout/loadout_pz", "weapon_pz", "AMMO_5_7MM" }, + { "", "", "", "AMMO_PRI" } +}; + +static std::vector< std::string > s_LoadoutMenuButtons +{ + "Button1", + "Button2", + "Button3", + "Button4", + "Button5", + "Button6", + "Button7", + "Button8", + "Button9", + "Button10", + "Button11", + "Button12", +}; + +CLoadoutWeaponClass::CLoadoutWeaponClass( const char* weaponName, const char* vguiImage, const char* weaponEntityName, const char* ammoType ) +{ + m_szWeaponName = weaponName; + m_szVguiImage = vguiImage; + m_szWeaponEntityName = weaponEntityName; + m_szAmmoType = ammoType; +} + +CLoadoutWeaponClass::~CLoadoutWeaponClass() +{ +} + +// Gotta rework on these functions, I have a feeling they wont work +int GetNumberOfLoadoutWeapons( int teamNum, int classType, int rank, bool isDev ) +{ + CLoadoutWeaponClass** pLoadout = nullptr; + + if ( isDev ) + pLoadout = (CLoadoutWeaponClass**) &s_DevLoadoutWeapons; + else if ( classType == CLASS_RECON ) + pLoadout = (CLoadoutWeaponClass**) &s_ReconLoadoutWeapons; + else if ( classType == CLASS_ASSAULT ) + pLoadout = (CLoadoutWeaponClass**) &s_AssaultLoadoutWeapons; + else if ( classType == CLASS_SUPPORT ) + pLoadout = (CLoadoutWeaponClass**) &s_SupportLoadoutWeapons; + else + return 0; + + int ammount = 0; + int i = 0; + + for ( CLoadoutWeaponClass* l = *pLoadout; l; l = pLoadout[ i ] ) + { + if ( rank >= i ) + ammount++; + i++; + } + + return ammount; +} + +std::string GetLoadoutVguiWeaponName( int teamNum, int classType, int rank, int num, bool isDev ) +{ + CLoadoutWeaponClass** pLoadout = nullptr; + + if ( isDev ) + pLoadout = (CLoadoutWeaponClass**) &s_DevLoadoutWeapons; + else if ( classType == CLASS_RECON ) + pLoadout = (CLoadoutWeaponClass**) &s_ReconLoadoutWeapons; + else if ( classType == CLASS_ASSAULT ) + pLoadout = (CLoadoutWeaponClass**) &s_AssaultLoadoutWeapons; + else if ( classType == CLASS_SUPPORT ) + pLoadout = (CLoadoutWeaponClass**) &s_SupportLoadoutWeapons; + else + return ""; + + if ( !*pLoadout ) + return ""; + + if ( num >= GetNumberOfLoadoutWeapons( teamNum, classType, rank, isDev ) ) + return ""; + + return pLoadout[ num ]->m_szVguiImage; +} + +CNeoLoadoutMenu::CNeoLoadoutMenu( IViewPort *pViewPort ) : CNeoFrame( PANEL_TEAM ) +{ + m_pViewPort = pViewPort; + + m_iJumpKey = 0; + m_iScoreboardKey = 0; + + m_bNeedsUpdate = false; + + LoadControlSettings( "Resource/UI/LoadoutMenu.res" ); + InvalidateLayout(); + + m_fCreationTime = gpGlobals->curtime; +} + +CNeoLoadoutMenu::~CNeoLoadoutMenu() +{ +} + +void CNeoLoadoutMenu::ApplySchemeSettings( vgui::IScheme* pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); +} + +void CNeoLoadoutMenu::OnCommand( const char* command ) +{ + if ( GetClientModeNEONormal()->IsNEODev() ) + engine->ClientCmd( "iamantdev" ); + + if ( !V_stricmp( command, "vguicancel" ) || !V_stricmp( command, "Close" ) ) + { + Close(); + gViewPortInterface->ShowBackGround( false ); + } + + else if ( !V_stricmp( command, "playerstate_reverse" ) ) + { + engine->ClientCmd( command ); + Close(); + gViewPortInterface->ShowBackGround( false ); + } + + else if ( V_stristr( command, "loadout" ) ) + { + engine->ClientCmd( command ); + BaseClass::OnCommand( command ); + + Close(); + gViewPortInterface->ShowBackGround( false ); + + engine->ClientCmd( "playerready" ); + BaseClass::OnCommand( "playerready" ); + + return; + } + + BaseClass::OnCommand( command ); +} + +void CNeoLoadoutMenu::OnKeyCodePressed( vgui::KeyCode code ) +{ + if ( !m_iScoreboardKey || m_iScoreboardKey != code ) + BaseClass::OnKeyCodePressed( code ); +} + +void CNeoLoadoutMenu::SetWeaponImages() +{ + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + int iLoadoutWeapons = GetNumberOfLoadoutWeapons( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, localPlayer->m_iRank, GetClientModeNEONormal()->IsNEODev() ); + + int iLoadoutWeapons2 = GetNumberOfLoadoutWeapons( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, 4, GetClientModeNEONormal()->IsNEODev() ); + + for ( int i = 0; i < 12; i++ ) + { + vgui::CNImageButton* imageButton = (vgui::CNImageButton*) vgui::Panel::FindChildByName( s_LoadoutMenuButtons[ i ].c_str() ); + + std::string buttonName; + + if ( iLoadoutWeapons < i ) + { + // This will set everything as loadout_none first. I don't think I wrote it properly, gotta test + if ( iLoadoutWeapons2 < i ) + { + imageButton->SetTexture( "vgui/loadout/loadout_none" ); + imageButton->SetEnabled( false ); + imageButton->SetVisible( true ); + continue; + } + + // Then it will set the image the "_no" version of every class specific weapon + buttonName = GetLoadoutVguiWeaponName( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, 4, i, GetClientModeNEONormal()->IsNEODev() ); + buttonName.append( "_no" ); + + imageButton->SetEnabled( false ); + imageButton->SetVisible( true ); + } + + // Now we can set the regular textures to the weapons that are available to us + else + { + imageButton->SetEnabled( true ); + imageButton->SetVisible( true ); + + buttonName = GetLoadoutVguiWeaponName( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, localPlayer->m_iRank, i, GetClientModeNEONormal()->IsNEODev() ); + } + + imageButton->SetTexture( buttonName.c_str() ); + } +} + +void CNeoLoadoutMenu::Update() +{ + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( localPlayer && (localPlayer->GetTeamNumber() == TEAM_JINRAI || localPlayer->GetTeamNumber() == TEAM_NSF) ) + m_bNeedsUpdate = false; +} + +void CNeoLoadoutMenu::ShowPanel( bool bShow ) +{ + gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false ); + + if ( IsVisible() == bShow ) + return; + + if ( bShow ) + { + SetWeaponImages(); + + Activate(); + SetMouseInputEnabled( true ); + + if ( !m_iJumpKey ) + m_iJumpKey = gameuifuncs->GetButtonCodeForBind( "jump" ); + + if ( !m_iScoreboardKey ) + m_iScoreboardKey = gameuifuncs->GetButtonCodeForBind( "showscores" ); + + MoveToCenterOfScreen(); + } + + else + { + SetVisible( false ); + SetMouseInputEnabled( false ); + } + + m_pViewPort->ShowBackGround( bShow ); +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h new file mode 100644 index 00000000000..8afd6aa581a --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h @@ -0,0 +1,81 @@ +#ifndef NEO_LOADOUTMENU_H +#define NEO_LOADOUTMENU_H + +#ifdef _WIN32 +#pragma once +#endif + +#include +#include +#include "neoframe.h" +#include +#include "neo_shareddefs.h" + +class CNeoLoadoutMenu : public vgui::CNeoFrame, public IViewPortPanel +{ + DECLARE_CLASS_SIMPLE( CNeoLoadoutMenu, vgui::CNeoFrame ); + +public: + CNeoLoadoutMenu( IViewPort *pViewPort ); + virtual ~CNeoLoadoutMenu(); + + virtual const char *GetName( void ) { return PANEL_LOADOUT; } + virtual void SetData( KeyValues *data ) {}; + virtual void Reset() {}; + virtual void Update(); + virtual bool NeedsUpdate( void ) { return m_bNeedsUpdate; } + virtual bool HasInputElements( void ) { return true; } + virtual void ShowPanel( bool bShow ); + + vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); } + virtual bool IsVisible() { return BaseClass::IsVisible(); } + virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); } + + virtual void ApplySchemeSettings( vgui::IScheme* pScheme ); + virtual void OnCommand( const char* command ); + virtual void OnKeyCodePressed( vgui::KeyCode code ); + + virtual void SetWeaponImages(); + +private: + IViewPort* m_pViewPort; + int m_iJumpKey; + int m_iScoreboardKey; + float m_fCreationTime; + bool m_bUnknown; + bool m_bNeedsUpdate; +}; + +class CLoadoutWeaponClass +{ +public: + CLoadoutWeaponClass( const char* weaponName, const char* vguiImage, const char* weaponEntityName, const char* ammoType ); + ~CLoadoutWeaponClass(); + +public: + std::string m_szWeaponName; + int m_iUnknown; // There may be way too many unknown variables. Some may even be part of std::string + + std::string m_szVguiImage; + int m_iUnknown2; + + std::string m_szWeaponEntityName; + int m_iUnknown3; + + std::string m_szAmmoType; + int m_iUnknown4; + int m_iUnknown5; + bool m_bUnknown; +}; + +extern CLoadoutWeaponClass s_DevLoadoutWeapons[ 14 ]; +extern CLoadoutWeaponClass s_ReconLoadoutWeapons[ 10 ]; +extern CLoadoutWeaponClass s_AssaultLoadoutWeapons[ 13 ]; +extern CLoadoutWeaponClass s_SupportLoadoutWeapons[ 10 ]; + +extern std::vector< std::string > s_LoadoutMenuButtons; + +extern int GetNumberOfLoadoutWeapons( int teamNum, int classType, int rank, bool isDev ); +extern std::string GetLoadoutVguiWeaponName( int teamNum, int classType, int rank, int num, bool isDev ); + +#endif // NEO_LOADOUTMENU_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp new file mode 100644 index 00000000000..2757ab3afb7 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp @@ -0,0 +1,138 @@ +#include "cbase.h" +#include "neoloadoutmenu_dev.h" +#include "neoloadoutmenu.h" +#include "clientmode_neonormal.h" +#include "c_neoplayer.h" +#include "IGameUIFuncs.h" +#include "neoimagebutton.h" + +CNeoLoadoutMenu_Dev::CNeoLoadoutMenu_Dev( IViewPort *pViewPort ) : CNeoFrame( PANEL_TEAM ) +{ + m_pViewPort = pViewPort; + + m_iJumpKey = 0; + m_iScoreboardKey = 0; + + m_bNeedsUpdate = false; + + LoadControlSettings( "Resource/UI/LoadoutMenu.res" ); + InvalidateLayout(); + + m_fCreationTime = gpGlobals->curtime; +} + +CNeoLoadoutMenu_Dev::~CNeoLoadoutMenu_Dev() +{ +} + +void CNeoLoadoutMenu_Dev::ApplySchemeSettings( vgui::IScheme* pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); +} + +void CNeoLoadoutMenu_Dev::OnCommand( const char* command ) +{ + if ( GetClientModeNEONormal()->IsNEODev() ) + engine->ClientCmd( "iamantdev" ); + + if ( !V_stricmp( command, "vguicancel" ) || !V_stricmp( command, "Close" ) ) + { + Close(); + gViewPortInterface->ShowBackGround( false ); + } + + else if ( !V_stricmp( command, "playerready" ) ) + { + engine->ClientCmd( command ); + Close(); + gViewPortInterface->ShowBackGround( false ); + } + + else if ( V_stristr( command, "loadout" ) ) + { + } + + FindChildByName( "Done_Button" )->SetVisible( true ); + + vgui::CNImageButton* imagePanel = (vgui::CNImageButton*) FindChildByName( "Weapon_ImagePanel" ); + + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + imagePanel->SetTexture( GetLoadoutVguiWeaponName( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, localPlayer->m_iRank, 0, GetClientModeNEONormal()->IsNEODev() ).c_str() ); + + BaseClass::OnCommand( command ); +} + +void CNeoLoadoutMenu_Dev::OnKeyCodePressed( vgui::KeyCode code ) +{ + if ( !m_iScoreboardKey || m_iScoreboardKey != code ) + BaseClass::OnKeyCodePressed( code ); +} + +void CNeoLoadoutMenu_Dev::SetWeaponImages() +{ + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + int iLoadoutWeapons = GetNumberOfLoadoutWeapons( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, localPlayer->m_iRank, GetClientModeNEONormal()->IsNEODev() ); + + for ( int i = 0; i < 14; i++ ) + { + vgui::CNImageButton* imageButton = (vgui::CNImageButton*) vgui::Panel::FindChildByName( s_LoadoutMenuButtons[ i ].c_str() ); + + if ( iLoadoutWeapons < i ) + { + imageButton->SetEnabled( false ); + imageButton->SetVisible( false ); + + imageButton->SetTexture( "" ); + } + + else + { + imageButton->SetEnabled( true ); + imageButton->SetVisible( true ); + + imageButton->SetTexture( GetLoadoutVguiWeaponName( localPlayer->GetTeamNumber(), localPlayer->m_iClassType, localPlayer->m_iRank, i, GetClientModeNEONormal()->IsNEODev() ).c_str() ); + } + } +} + +void CNeoLoadoutMenu_Dev::Update() +{ + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( localPlayer && (localPlayer->GetTeamNumber() == TEAM_JINRAI || localPlayer->GetTeamNumber() == TEAM_NSF) ) + m_bNeedsUpdate = false; +} + +void CNeoLoadoutMenu_Dev::ShowPanel( bool bShow ) +{ + gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false ); + + if ( IsVisible() == bShow ) + return; + + if ( bShow ) + { + SetWeaponImages(); + + Activate(); + SetMouseInputEnabled( true ); + + if ( !m_iJumpKey ) + m_iJumpKey = gameuifuncs->GetButtonCodeForBind( "jump" ); + + if ( !m_iScoreboardKey ) + m_iScoreboardKey = gameuifuncs->GetButtonCodeForBind( "showscores" ); + + MoveToCenterOfScreen(); + } + + else + { + SetVisible( false ); + SetMouseInputEnabled( false ); + } + + m_pViewPort->ShowBackGround( bShow ); +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.h b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.h new file mode 100644 index 00000000000..7dd15397379 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.h @@ -0,0 +1,48 @@ +#ifndef NEO_LOADOUTMENUDEV_H +#define NEO_LOADOUTMENUDEV_H + +#ifdef _WIN32 +#pragma once +#endif + +#include +#include "neoframe.h" +#include +#include "neo_shareddefs.h" + +class CNeoLoadoutMenu_Dev : public vgui::CNeoFrame, public IViewPortPanel +{ + DECLARE_CLASS_SIMPLE( CNeoLoadoutMenu_Dev, vgui::CNeoFrame ); + +public: + CNeoLoadoutMenu_Dev( IViewPort *pViewPort ); + virtual ~CNeoLoadoutMenu_Dev(); + + virtual const char *GetName( void ) { return PANEL_LOADOUT_DEV; } + virtual void SetData( KeyValues *data ) {}; + virtual void Reset() {}; + virtual void Update(); + virtual bool NeedsUpdate( void ) { return m_bNeedsUpdate; } + virtual bool HasInputElements( void ) { return true; } + virtual void ShowPanel( bool bShow ); + + vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); } + virtual bool IsVisible() { return BaseClass::IsVisible(); } + virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); } + + virtual void ApplySchemeSettings( vgui::IScheme* pScheme ); + virtual void OnCommand( const char* command ); + virtual void OnKeyCodePressed( vgui::KeyCode code ); + + virtual void SetWeaponImages(); + +private: + IViewPort* m_pViewPort; + int m_iJumpKey; + int m_iScoreboardKey; + float m_fCreationTime; + bool m_bUnknown; + bool m_bNeedsUpdate; +}; + +#endif // NEO_LOADOUTMENUDEV_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp index daaa48c3d80..ab452ccc3c5 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.cpp @@ -33,7 +33,7 @@ void CNeoTeamMenu::ApplySchemeSettings( vgui::IScheme* pScheme ) void CNeoTeamMenu::OnCommand( const char* command ) { - if ( V_stricmp( "vguicancel", command ) && V_stricmp( "Close", command ) ) + if ( V_stricmp( command, "vguicancel" ) && V_stricmp( command, "Close" ) ) engine->ClientCmd( command ); Close(); diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h index b75d21dfa49..039d1774893 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoteammenu.h @@ -16,7 +16,7 @@ class CNeoTeamMenu : public vgui::CNeoFrame, public IViewPortPanel CNeoTeamMenu( IViewPort *pViewPort ); virtual ~CNeoTeamMenu(); - virtual const char *GetName( void ) { return PANEL_CLASS; } + virtual const char *GetName( void ) { return PANEL_TEAM; } virtual void SetData( KeyValues *data ) {}; virtual void Reset() {}; virtual void Update(); diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp index 5b507adcf41..c1355d58954 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp @@ -3,6 +3,8 @@ #include "neo_shareddefs.h" #include "neoteammenu.h" #include "neoclassmenu.h" +#include "neoloadoutmenu_dev.h" +#include "neoloadoutmenu.h" void NEOViewport::ApplySchemeSettings( vgui::IScheme *pScheme ) { @@ -34,12 +36,12 @@ IViewPortPanel* NEOViewport::CreatePanelByName( const char *szPanelName ) else if ( V_strcmp( PANEL_LOADOUT_DEV, szPanelName ) == 0 ) { - //newpanel = new CNeoLoadoutMenu_Dev( this ); + newpanel = new CNeoLoadoutMenu_Dev( this ); } else if ( V_strcmp( PANEL_LOADOUT, szPanelName ) == 0 ) { - //newpanel = new CNeoLoadoutMenu( this ); + newpanel = new CNeoLoadoutMenu( this ); } else diff --git a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp index 4b24b450bd8..fa9a457d1cb 100644 --- a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp +++ b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp @@ -9,13 +9,13 @@ // Instance the singleton and expose the interface to it. IClientMode* GetClientModeNormal() { - static ClientModeNEONormal g_ClientModeNormal; - return &g_ClientModeNormal; + return GetClientModeNEONormal(); } ClientModeNEONormal* GetClientModeNEONormal() { - return (ClientModeNEONormal*) GetClientModeNormal(); + static ClientModeNEONormal g_ClientModeNormal; + return &g_ClientModeNormal; } diff --git a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h index 2e353a32e23..340323cc058 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h +++ b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h @@ -8,8 +8,27 @@ #define PANEL_LOADOUT "loadout" #define PANEL_LOADOUT_DEV "loadout_dev" -#define TEAM_JINRAI 2 -#define TEAM_NSF 3 -#define TEAM_MAXCOUNT 4 +// From https://github.com/softashell/sourcemod-nt-include + +#define TEAM_JINRAI 2 +#define TEAM_NSF 3 +#define TEAM_MAXCOUNT 4 + +#define VISION_NONE 0 +#define VISION_NIGHT 2 +#define VISION_THERMAL 3 +#define VISION_MOTION 4 + +#define CLASS_RECON 1 +#define CLASS_ASSAULT 2 +#define CLASS_SUPPORT 3 + +#define IN_AIM (1 << 23) +#define IN_LEANL (1 << 24) +#define IN_LEANR (1 << 25) +#define IN_SPRINT (1 << 26) +#define IN_THERMOPTIC (1 << 27) +#define IN_VISION (1 << 28) +#define IN_TOSS (1 << 29) #endif // NEO_SHAREDDEFS_H From 4aa6ec4a89c5a051210b758163185f4b6232d448 Mon Sep 17 00:00:00 2001 From: Ochii Date: Sun, 26 Jun 2016 12:55:02 +0100 Subject: [PATCH 10/12] Add Scoreboard --- .../VGUI/neoclientscoreboard.cpp | 305 ++++++++++++++++++ .../NeotokyoSource/VGUI/neoclientscoreboard.h | 43 +++ .../NeotokyoSource/VGUI/neoloadoutmenu.cpp | 3 + .../NeotokyoSource/VGUI/neoloadoutmenu.h | 9 - .../VGUI/neoloadoutmenu_dev.cpp | 3 + .../NeotokyoSource/VGUI/neoviewport.cpp | 3 +- 6 files changed, 356 insertions(+), 10 deletions(-) create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.cpp create mode 100644 mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.h diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.cpp new file mode 100644 index 00000000000..b1b32aa2784 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.cpp @@ -0,0 +1,305 @@ +#include "cbase.h" +#include "neoclientscoreboard.h" +#include +#include "neo_shareddefs.h" +#include "c_team.h" +#include +#include "c_neoplayer.h" +#include +#include +#include + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +using namespace vgui; + +enum EScoreboardSections +{ + SCORESECTION_JINRAI = 1, + SCORESECTION_NSF, + SCORESECTION_SPECTATOR +}; + +enum EScoreboardTeams +{ + SCORETEAM_JINRAI = 1, + SCORETEAM_NSF, + SCORETEAM_SPECTATOR +}; + +static const char* s_PlayerRanks[ 6 ] +{ + "Rankless Dog", + "Private", + "Corporal", + "Sergeant", + "Lieutenant", + "Major" +}; + +static const char* s_PlayerClasses[ 6 ] +{ + "Unassigned", + "Recon", + "Assault", + "Support", + "Operator", + "VIP" +}; + +static const char* s_Stars[ 6 ] +{ + "None", + "Alpha", + "Bravo", + "Charlie", + "Delta", + "Echo" +}; + +CNEOClientScoreBoardDialog::CNEOClientScoreBoardDialog( IViewPort *pViewPort ) : CClientScoreBoardDialog( pViewPort ) +{ + m_iNumTeams = 2; +} + +CNEOClientScoreBoardDialog::~CNEOClientScoreBoardDialog() +{ +} + +bool CNEOClientScoreBoardDialog::GetPlayerScoreInfo( int playerIndex, KeyValues *outPlayerInfo ) +{ + IGameResources* gr = GameResources(); + + if ( !gr ) + return false; + + outPlayerInfo->SetInt( "deaths", gr->GetDeaths( playerIndex ) ); + outPlayerInfo->SetInt( "frags", gr->GetFrags( playerIndex ) ); + outPlayerInfo->SetInt( "ping", gr->GetPing( playerIndex ) ); + outPlayerInfo->SetString( "name", gr->GetPlayerName( playerIndex ) ); + outPlayerInfo->SetString( "rank", s_PlayerRanks[ gr->GetRank() ] ); + outPlayerInfo->SetString( "alive", gr->IsAlive( playerIndex ) ? "Alive" : "Dead" ); + outPlayerInfo->SetString( "class", s_PlayerClasses[ gr->GetClass() ] ); + outPlayerInfo->SetString( "star", s_Stars[ gr->GetStar() ] ); + outPlayerInfo->SetInt( "playerIndex", playerIndex ); + + return true; +} + +void CNEOClientScoreBoardDialog::InitScoreboardSections() +{ + AddHeader(); + AddSection( TYPE_TEAM, SCORETEAM_JINRAI ); // The ids are different from TEAM_* constants so I have my doubts about this + AddSection( TYPE_TEAM, SCORETEAM_NSF ); + AddSection( TYPE_PLAYERS, SCORETEAM_SPECTATOR ); +} + +void CNEOClientScoreBoardDialog::UpdateTeamInfo() +{ + wchar_t buffer[ 1024 ]; + + for ( int teamIndex = TEAM_JINRAI; teamIndex <= TEAM_NSF; teamIndex++ ) + { + C_Team* team = GetGlobalTeam( teamIndex ); + + if ( team ) + { + switch ( teamIndex ) + { + case TEAM_JINRAI: + V_snwprintf( buffer, sizeof( buffer ), L"JINRAI Score: %d Players: %d", team->Get_Score(), team->Get_Number_Players() ); + m_pPlayerList->ModifyColumn( SCORESECTION_JINRAI, "name", buffer ); + break; + + case TEAM_NSF: + V_snwprintf( buffer, sizeof( buffer ), L"JNSF Score: %d Players: %d", team->Get_Score(), team->Get_Number_Players() ); + m_pPlayerList->ModifyColumn( SCORESECTION_NSF, "name", buffer ); + break; + + default: + Assert( false ); + } + } + } +} + +void CNEOClientScoreBoardDialog::UpdatePlayerInfo() +{ + m_iSectionId = 0; // 0'th row is a header + int selectedRow = -1; + + // walk all the players and make sure they're in the scoreboard + for ( int i = 1; i <= gpGlobals->maxClients; ++i ) + { + IGameResources *gr = GameResources(); + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + if ( gr && gr->IsConnected( i ) && localPlayer ) + { + // add the player to the list + KeyValues *playerData = new KeyValues( "data" ); + GetPlayerScoreInfo( i, playerData ); + UpdatePlayerAvatar( i, playerData ); + + const char *oldName = playerData->GetString( "name", "" ); + char newName[ MAX_PLAYER_NAME_LENGTH ]; + + UTIL_MakeSafeName( oldName, newName, MAX_PLAYER_NAME_LENGTH ); + + playerData->SetString( "name", newName ); + + int itemID = FindItemIDForPlayerIndex( i ); + int sectionID = gr->GetTeam( i ); + + int team = 0; + + if ( sectionID == TEAM_JINRAI ) + team = 1; + else if ( sectionID == TEAM_NSF ) + team = 2; + else if ( sectionID == TEAM_SPECTATOR || !team ) + team = 3; + + int teamNum = localPlayer->GetTeamNumber(); + + if ( gr->IsLocalPlayer( i ) ) + { + selectedRow = itemID; + } + if ( itemID == -1 ) + { + if ( teamNum != TEAM_INVALID && teamNum != sectionID ) + { + playerData->SetString( "alive", "" ); + playerData->SetString( "class", "" ); + playerData->SetString( "star", "" ); + } + + // add a new row + itemID = m_pPlayerList->AddItem( sectionID, playerData ); + } + else + { + if ( teamNum != TEAM_INVALID && teamNum != sectionID ) + { + playerData->SetString( "alive", "" ); + playerData->SetString( "class", "" ); + playerData->SetString( "star", "" ); + } + + // modify the current row + m_pPlayerList->ModifyItem( itemID, sectionID, playerData ); + } + + // set the row color based on the players team + m_pPlayerList->SetItemFgColor( itemID, gr->GetTeamColor( sectionID ) ); + + playerData->deleteThis(); + } + else + { + // remove the player + int itemID = FindItemIDForPlayerIndex( i ); + if ( itemID != -1 ) + { + m_pPlayerList->RemoveItem( itemID ); + } + } + } + + if ( selectedRow != -1 ) + { + m_pPlayerList->SetSelectedItem( selectedRow ); + } +} + +void CNEOClientScoreBoardDialog::AddHeader() +{ + // add the top header + m_pPlayerList->AddSection( 0, "" ); + m_pPlayerList->SetSectionAlwaysVisible( 0 ); + m_pPlayerList->AddColumnToSection( 0, "name", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_NAME_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "rank", "Rank", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_RANK_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "class", "Class", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_CLASS_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "star", "Star", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_STAR_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "frags", "XP", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_FRAGS_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "deaths", "Deaths", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_DEATH_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "ping", "Ping", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_PING_WIDTH ) ); + m_pPlayerList->AddColumnToSection( 0, "alive", "Status", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_ALIVE_WIDTH ) ); +} + +void CNEOClientScoreBoardDialog::AddSection( int teamType, int teamNumber ) +{ + if ( teamType == TYPE_TEAM ) + { + int sectionId = 0; + + if ( teamNumber == SCORETEAM_JINRAI ) + sectionId = SCORESECTION_JINRAI; + else if ( teamNumber == SCORETEAM_NSF ) + sectionId = SCORESECTION_NSF; + + m_pPlayerList->AddSection( sectionId, "", StaticPlayerSortFunc ); + + // Avatars are always displayed at 32x32 regardless of resolution + if ( ShowAvatars() ) + { + m_pPlayerList->AddColumnToSection( sectionId, "avatar", "", SectionedListPanel::COLUMN_IMAGE | SectionedListPanel::COLUMN_RIGHT, m_iAvatarWidth ); + } + + m_pPlayerList->AddColumnToSection( sectionId, "name", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_NAME_WIDTH ) - m_iAvatarWidth ); + m_pPlayerList->AddColumnToSection( sectionId, "rank", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_RANK_WIDTH ) ); + m_pPlayerList->AddColumnToSection( sectionId, "class", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_CLASS_WIDTH ) ); + m_pPlayerList->AddColumnToSection( sectionId, "star", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_STAR_WIDTH ) ); + m_pPlayerList->AddColumnToSection( sectionId, "frags", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_FRAGS_WIDTH ) ); + m_pPlayerList->AddColumnToSection( sectionId, "deaths", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_DEATH_WIDTH ) ); + m_pPlayerList->AddColumnToSection( sectionId, "ping", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_PING_WIDTH ) ); + m_pPlayerList->AddColumnToSection( sectionId, "alive", "", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NEO_ALIVE_WIDTH ) ); + } + else if ( teamType == TYPE_SPECTATORS ) + { + m_pPlayerList->AddSection( SCORESECTION_SPECTATOR, "" ); + + // Avatars are always displayed at 32x32 regardless of resolution + if ( ShowAvatars() ) + { + m_pPlayerList->AddColumnToSection( SCORESECTION_SPECTATOR, "avatar", "", SectionedListPanel::COLUMN_IMAGE | SectionedListPanel::COLUMN_RIGHT, m_iAvatarWidth ); + } + m_pPlayerList->AddColumnToSection( SCORESECTION_SPECTATOR, "name", "#Spectators", 0, scheme()->GetProportionalScaledValueEx( GetScheme(), NAME_WIDTH ) - m_iAvatarWidth ); + } +} + +void CNEOClientScoreBoardDialog::UpdateServerInfo( KeyValues* kv ) +{ + if ( !V_strcmp( kv->GetName(), "hltv_status" ) ) + { + m_HLTVSpectators = kv->GetInt( "clients" ); + m_HLTVSpectators -= kv->GetInt( "proxies" ); + } + + else if ( !V_strcmp( kv->GetName(), "server_spawn" ) ) + { + if ( !V_stricmp( kv->GetString( "hostname" ), "Half-Life" ) ) + SetControlString( "ServerName", "Neotokyo" ); + else + SetControlString( "ServerName", kv->GetString( "hostname" ) ); + + SetLabelColorWhite( "ServerName" ); + } + + if ( IsVisible() ) + Update(); +} + +void CNEOClientScoreBoardDialog::SetLabelColorWhite( const char* labelName ) +{ + vgui::Label* label = dynamic_cast(FindChildByName( labelName )); + + if ( !label ) + return; + + label->SetFgColor( Color( 255, 255, 255, 255 ) ); + label->SetBgColor( Color( 0, 0, 0, 0 ) ); + label->MoveToFront(); +} \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.h b/mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.h new file mode 100644 index 00000000000..dc6ac1a6897 --- /dev/null +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoclientscoreboard.h @@ -0,0 +1,43 @@ +#ifndef NEOCLIENTSCOREBOARDDIALOG_H +#define NEOCLIENTSCOREBOARDDIALOG_H + +#ifdef _WIN32 +#pragma once +#endif + +#include + +class CNEOClientScoreBoardDialog : public CClientScoreBoardDialog +{ + DECLARE_CLASS_SIMPLE( CNEOClientScoreBoardDialog, CClientScoreBoardDialog ); + +public: + CNEOClientScoreBoardDialog( IViewPort *pViewPort ); + ~CNEOClientScoreBoardDialog(); + + virtual bool GetPlayerScoreInfo( int playerIndex, KeyValues *outPlayerInfo ); + virtual void InitScoreboardSections(); + virtual void UpdateTeamInfo(); + virtual void UpdatePlayerInfo(); + virtual void AddHeader(); + virtual void AddSection( int teamType, int teamNumber ); + + virtual void UpdateServerInfo( KeyValues* kv ); + + void SetLabelColorWhite( const char* labelName ); + +private: + enum + { + NEO_NAME_WIDTH = 180, + NEO_RANK_WIDTH = 75, + NEO_CLASS_WIDTH = 50, + NEO_STAR_WIDTH = 50, + NEO_FRAGS_WIDTH = 40, + NEO_DEATH_WIDTH = 40, + NEO_PING_WIDTH = 40, + NEO_ALIVE_WIDTH = 40 + }; +}; + +#endif // NEOCLIENTSCOREBOARDDIALOG_H \ No newline at end of file diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp index 844a958c867..4b888f580e9 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.cpp @@ -5,6 +5,9 @@ #include "IGameUIFuncs.h" #include "neoimagebutton.h" +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + static CLoadoutWeaponClass s_DevLoadoutWeapons[ 14 ] { { "MPN45", "vgui/loadout/loadout_mpn", "weapon_mpn", "AMMO_PRI" }, diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h index 8afd6aa581a..bf6eb5a42c5 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu.h @@ -54,18 +54,9 @@ class CLoadoutWeaponClass public: std::string m_szWeaponName; - int m_iUnknown; // There may be way too many unknown variables. Some may even be part of std::string - std::string m_szVguiImage; - int m_iUnknown2; - std::string m_szWeaponEntityName; - int m_iUnknown3; - std::string m_szAmmoType; - int m_iUnknown4; - int m_iUnknown5; - bool m_bUnknown; }; extern CLoadoutWeaponClass s_DevLoadoutWeapons[ 14 ]; diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp index 2757ab3afb7..d00d9a41a79 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoloadoutmenu_dev.cpp @@ -6,6 +6,9 @@ #include "IGameUIFuncs.h" #include "neoimagebutton.h" +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + CNeoLoadoutMenu_Dev::CNeoLoadoutMenu_Dev( IViewPort *pViewPort ) : CNeoFrame( PANEL_TEAM ) { m_pViewPort = pViewPort; diff --git a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp index c1355d58954..9f6e11d7cf5 100644 --- a/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp +++ b/mp/src/game/client/NeotokyoSource/VGUI/neoviewport.cpp @@ -2,6 +2,7 @@ #include "NEOViewport.h" #include "neo_shareddefs.h" #include "neoteammenu.h" +#include "neoclientscoreboard.h" #include "neoclassmenu.h" #include "neoloadoutmenu_dev.h" #include "neoloadoutmenu.h" @@ -26,7 +27,7 @@ IViewPortPanel* NEOViewport::CreatePanelByName( const char *szPanelName ) else if ( V_strcmp( PANEL_SCOREBOARD, szPanelName ) == 0 ) { - //newpanel = new CNEOClientScoreBoardDialog( this ); + newpanel = new CNEOClientScoreBoardDialog( this ); } else if ( V_strcmp( PANEL_CLASS, szPanelName ) == 0 ) From 6068031462984f4e759666f6b42ada999a0cb2b1 Mon Sep 17 00:00:00 2001 From: Ochii Date: Sun, 26 Jun 2016 20:00:30 +0100 Subject: [PATCH 11/12] Roll NEOGameMovement out Can I get banned for swearing in here --- .../client/NeotokyoSource/c_neoplayer.cpp | 11 + .../game/client/NeotokyoSource/c_neoplayer.h | 2 + .../NeotokyoSource/clientmode_neonormal.cpp | 37 ++ mp/src/game/client/c_baseplayer.h | 1 + mp/src/game/client/c_playerresource.cpp | 50 +++ mp/src/game/client/c_playerresource.h | 13 + .../NeotokyoSource/neo_gamemovement.cpp | 383 ++++++++++++++++++ .../shared/NeotokyoSource/neo_gamerules.cpp | 17 + .../shared/NeotokyoSource/neo_gamerules.h | 18 + .../shared/NeotokyoSource/neo_shareddefs.h | 17 + mp/src/public/igameresources.h | 6 + 11 files changed, 555 insertions(+) create mode 100644 mp/src/game/shared/NeotokyoSource/neo_gamemovement.cpp diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index 6ee4f5839b9..cd24b48d286 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -9,6 +9,7 @@ #include "materialsystem\imaterialvar.h" #include "convar.h" #include "view_scene.h" +#include "neo_gamerules.h" ConVar cl_nt_ragdoll_lifetime( "cl_nt_ragdoll_lifetime", "60", FCVAR_REPLICATED ); @@ -360,6 +361,16 @@ bool C_NEOPlayer::IsLocalNEOPlayer( void ) const return (GetLocalNEOPlayer() == this); } +bool C_NEOPlayer::CanMove() +{ + return (GetObserverMode() == OBS_MODE_NONE && !NEOGameRules()->IsInFreezePeriod()); +} + +bool C_NEOPlayer::CanSpeedBoost() +{ + return m_fSprintNRG > 33.f; +} + CWeaponNEOBase* C_NEOPlayer::GetActiveNEOWeapon() const { return dynamic_cast< CWeaponNEOBase* >( GetActiveWeapon() ); diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.h b/mp/src/game/client/NeotokyoSource/c_neoplayer.h index 49b8d6a4f7e..58073635dd5 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.h +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.h @@ -66,6 +66,8 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers static C_NEOPlayer* GetLocalNEOPlayer(); bool IsLocalNEOPlayer( void ) const; + bool CanMove(); + bool CanSpeedBoost(); CWeaponNEOBase* GetActiveNEOWeapon() const; diff --git a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp index fa9a457d1cb..b65f625c87f 100644 --- a/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp +++ b/mp/src/game/client/NeotokyoSource/clientmode_neonormal.cpp @@ -1,10 +1,47 @@ #include "cbase.h" #include "clientmode_neonormal.h" +#include "ivmodemanager.h" +#include "panelmetaclassmgr.h" +#include "neo_gamerules.h" #include "VGUI\neoviewport.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#define SCREEN_FILE "scripts/vgui_screens.txt" + + +class CNEOModeManager : public IVModeManager +{ +public: + virtual void Init(); + virtual void SwitchMode( bool commander, bool force ) {} + virtual void LevelInit( const char *newmap ); + virtual void LevelShutdown( void ); + virtual void ActivateMouse( bool isactive ) {} +}; + +static CNEOModeManager g_ModeManager; +IVModeManager *modemanager = (IVModeManager *) &g_ModeManager; + +void CNEOModeManager::Init() +{ + g_pClientMode = GetClientModeNormal(); + + PanelMetaClassMgr()->LoadMetaClassDefinitionFile( SCREEN_FILE ); +} + +void CNEOModeManager::LevelInit( const char *newmap ) +{ + g_pClientMode->LevelInit( newmap ); +} + +void CNEOModeManager::LevelShutdown( void ) +{ + NEOGameRules()->LevelShutdown(); + g_pClientMode->LevelShutdown(); +} + // Instance the singleton and expose the interface to it. IClientMode* GetClientModeNormal() diff --git a/mp/src/game/client/c_baseplayer.h b/mp/src/game/client/c_baseplayer.h index 9d3657bf6f9..6d364289e37 100644 --- a/mp/src/game/client/c_baseplayer.h +++ b/mp/src/game/client/c_baseplayer.h @@ -571,6 +571,7 @@ class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener friend class CHL2GameMovement; friend class CDODGameMovement; friend class CPortalGameMovement; + friend class CNEOGameMovement; // Accessors for gamemovement float GetStepSize( void ) const { return m_Local.m_flStepSize; } diff --git a/mp/src/game/client/c_playerresource.cpp b/mp/src/game/client/c_playerresource.cpp index 3732a54715e..8aacfed5092 100644 --- a/mp/src/game/client/c_playerresource.cpp +++ b/mp/src/game/client/c_playerresource.cpp @@ -13,6 +13,10 @@ #include "hl2mp_gamerules.h" #endif +#ifdef NEO_DLL +#include "neo_shareddefs.h" +#endif + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -26,6 +30,11 @@ IMPLEMENT_CLIENTCLASS_DT_NOBASE(C_PlayerResource, DT_PlayerResource, CPlayerReso RecvPropArray3( RECVINFO_ARRAY(m_iTeam), RecvPropInt( RECVINFO(m_iTeam[0]))), RecvPropArray3( RECVINFO_ARRAY(m_bAlive), RecvPropInt( RECVINFO(m_bAlive[0]))), RecvPropArray3( RECVINFO_ARRAY(m_iHealth), RecvPropInt( RECVINFO(m_iHealth[0]))), +#ifdef NEO_DLL + RecvPropArray3( RECVINFO_ARRAY(m_iClassType), RecvPropInt( RECVINFO(m_iClassType[0]))), + RecvPropArray3( RECVINFO_ARRAY(m_iStar), RecvPropInt( RECVINFO(m_iStar[0]))), + RecvPropArray3( RECVINFO_ARRAY(m_iRank), RecvPropInt( RECVINFO(m_iRank[0]))), +#endif END_RECV_TABLE() BEGIN_PREDICTION_DATA( C_PlayerResource ) @@ -38,6 +47,11 @@ BEGIN_PREDICTION_DATA( C_PlayerResource ) DEFINE_PRED_ARRAY( m_iTeam, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_bAlive, FIELD_BOOLEAN, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), DEFINE_PRED_ARRAY( m_iHealth, FIELD_INTEGER, MAX_PLAYERS+1, FTYPEDESC_PRIVATE ), +#ifdef NEO_DLL + DEFINE_PRED_ARRAY( m_iClassType, FIELD_INTEGER, MAX_PLAYERS + 1, FTYPEDESC_PRIVATE ), + DEFINE_PRED_ARRAY( m_iStar, FIELD_INTEGER, MAX_PLAYERS + 1, FTYPEDESC_PRIVATE ), + DEFINE_PRED_ARRAY( m_iRank, FIELD_INTEGER, MAX_PLAYERS + 1, FTYPEDESC_PRIVATE ), +#endif END_PREDICTION_DATA() @@ -58,6 +72,9 @@ C_PlayerResource::C_PlayerResource() memset( m_iTeam, 0, sizeof( m_iTeam ) ); memset( m_bAlive, 0, sizeof( m_bAlive ) ); memset( m_iHealth, 0, sizeof( m_iHealth ) ); + memset( m_iClassType, 0, sizeof( m_iClassType ) ); + memset( m_iStar, 0, sizeof( m_iStar ) ); + memset( m_iRank, 0, sizeof( m_iRank ) ); m_szUnconnectedName = 0; for ( int i=0; i(pPlayer), pMove ); +} + +Vector CNEOGameMovement::GetPlayerMins( bool ducked ) const +{ + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( neoPlayer && neoPlayer->m_iClassType >= CLASS_NONE && neoPlayer->m_iClassType < CLASS_MAX ) + return ducked ? NEO_VEC_DUCK_HULL_MIN_SCALED( neoPlayer->m_iClassType, player ) : NEO_VEC_HULL_MIN_SCALED( neoPlayer->m_iClassType, player ); // source sdk 2006 doesn't scales, watch out + else + return ducked ? VEC_DUCK_HULL_MIN_SCALED( player ) : VEC_HULL_MIN_SCALED( player ); // same about scaling in here +} + +Vector CNEOGameMovement::GetPlayerMaxs( bool ducked ) const +{ + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( neoPlayer && neoPlayer->m_iClassType >= CLASS_NONE && neoPlayer->m_iClassType < CLASS_MAX ) + return ducked ? NEO_VEC_DUCK_HULL_MAX_SCALED( neoPlayer->m_iClassType, player ) : NEO_VEC_HULL_MAX_SCALED( neoPlayer->m_iClassType, player ); + else + return ducked ? VEC_DUCK_HULL_MAX_SCALED( player ) : VEC_HULL_MAX_SCALED( player ); +} + +Vector CNEOGameMovement::GetPlayerViewOffset( bool ducked ) const +{ + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( neoPlayer && neoPlayer->m_iClassType >= CLASS_NONE && neoPlayer->m_iClassType < CLASS_MAX ) + return ducked ? NEO_VEC_DUCK_VIEW_SCALED( neoPlayer->m_iClassType, player ) : NEO_VEC_VIEW_SCALED( neoPlayer->m_iClassType, player ); + else + return ducked ? VEC_DUCK_VIEW_SCALED( player ) : VEC_VIEW_SCALED( player ); +} + +Vector CNEOGameMovement::GetPlayerMins( void ) const +{ + if ( player->IsObserver() ) + { + return VEC_OBS_HULL_MIN_SCALED( player ); + } + else + { + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( neoPlayer && neoPlayer->m_iClassType >= CLASS_NONE && neoPlayer->m_iClassType < CLASS_MAX ) + return player->m_Local.m_bDucked ? NEO_VEC_DUCK_HULL_MIN_SCALED( neoPlayer->m_iClassType, player ) : NEO_VEC_HULL_MIN_SCALED( neoPlayer->m_iClassType, player ); + else + return player->m_Local.m_bDucked ? VEC_DUCK_HULL_MIN_SCALED( player ) : VEC_HULL_MIN_SCALED( player ); + } +} + +Vector CNEOGameMovement::GetPlayerMaxs( void ) const +{ + if ( player->IsObserver() ) + { + return VEC_OBS_HULL_MAX_SCALED( player ); + } + else + { + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( neoPlayer && neoPlayer->m_iClassType >= CLASS_NONE && neoPlayer->m_iClassType < CLASS_MAX ) + return player->m_Local.m_bDucked ? NEO_VEC_DUCK_HULL_MAX_SCALED( neoPlayer->m_iClassType, player ) : NEO_VEC_HULL_MAX_SCALED( neoPlayer->m_iClassType, player ); + else + return player->m_Local.m_bDucked ? VEC_DUCK_HULL_MAX_SCALED( player ) : VEC_HULL_MAX_SCALED( player ); + } +} + +bool CNEOGameMovement::CanAccelerate() +{ + if ( player->GetObserverMode() == OBS_MODE_CHASE ) + return true; + + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( neoPlayer->CanMove() ) + return false; + + return BaseClass::CanAccelerate(); +} + +void CNEOGameMovement::WalkMove() +{ + if ( mv->m_flForwardMove < 0.f ) + mv->m_flForwardMove *= 0.75f; + + BaseClass::WalkMove(); +} + +bool CNEOGameMovement::CheckJumpButton() +{ + C_NEOPlayer* neoPlayer = dynamic_cast(player); + + if ( !neoPlayer->CanMove() ) + return false; + + bool bIsRecon = false, bIsSprintingAsRecon = false; + float fClassVelModifier = 0.f; + + if ( neoPlayer ) + { + if ( neoPlayer->m_iClassType == CLASS_RECON ) + { + bIsRecon = true; + fClassVelModifier = 1.5f; + + if ( neoPlayer->m_iSprint == 1 ) + bIsSprintingAsRecon = true; + } + + else if ( neoPlayer->m_iClassType == 5 ) // LEAKED CODE ABOUT A NEW CLASS!!!!!!1111 #dramaalert + fClassVelModifier = 1.5f; + } + + if ( player->pl.deadflag ) + { + mv->m_nOldButtons |= IN_JUMP; // don't jump again until released + return false; + } + + // See if we are waterjumping. If so, decrement count and return. + if ( player->m_flWaterJumpTime ) + { + player->m_flWaterJumpTime -= gpGlobals->frametime; + if ( player->m_flWaterJumpTime < 0 ) + player->m_flWaterJumpTime = 0; + + return false; + } + + // If we are in the water most of the way... + if ( player->GetWaterLevel() >= 2 ) + { + // swimming, not jumping + SetGroundEntity( NULL ); + + if ( player->GetWaterType() == CONTENTS_WATER ) // We move up a certain amount + mv->m_vecVelocity[ 2 ] = 100; + else if ( player->GetWaterType() == CONTENTS_SLIME ) + mv->m_vecVelocity[ 2 ] = 80; + + // play swiming sound + if ( player->m_flSwimSoundTime <= 0 ) + { + // Don't play sound again for 1 second + player->m_flSwimSoundTime = 1000; + PlaySwimSound(); + } + + return false; + } + + // No more effect + if ( player->GetGroundEntity() == NULL ) + { + mv->m_nOldButtons |= IN_JUMP; + return false; // in air, so no effect + } + + // Don't allow jumping when the player is in a stasis field. + if ( player->m_Local.m_bSlowMovement ) + return false; + + if ( mv->m_nOldButtons & IN_JUMP ) + return false; // don't pogo stick + + // Cannot jump will in the unduck transition. + if ( player->m_Local.m_bDucking && (player->GetFlags() & FL_DUCKING) ) + return false; + + // Still updating the eye position. + if ( player->m_Local.m_flDuckJumpTime > 0.0f ) + return false; + + + // In the air now. + SetGroundEntity( NULL ); + + player->PlayStepSound( (Vector &) mv->GetAbsOrigin(), player->m_pSurfaceData, 1.0, true ); + + MoveHelper()->PlayerSetAnimation( PLAYER_JUMP ); + + float flGroundFactor = 1.0f; + if ( player->m_pSurfaceData ) + { + flGroundFactor = player->m_pSurfaceData->game.jumpFactor; + } + + float flMul = sqrt( 2 * GetCurrentGravity() * NEOGAMEMOVEMENT_JUMP_HEIGHT * fClassVelModifier ); + + // Acclerate upward + // If we are ducking... + float startz = mv->m_vecVelocity[ 2 ]; + if ( (player->m_Local.m_bDucking) || (player->GetFlags() & FL_DUCKING) ) + { + // d = 0.5 * g * t^2 - distance traveled with linear accel + // t = sqrt(2.0 * 45 / g) - how long to fall 45 units + // v = g * t - velocity at the end (just invert it to jump up that high) + // v = g * sqrt(2.0 * 45 / g ) + // v^2 = g * g * 2.0 * 45 / g + // v = sqrt( g * 2.0 * 45 ) + mv->m_vecVelocity[ 2 ] = flGroundFactor * flMul; // 2 * gravity * height + } + else + { + mv->m_vecVelocity[ 2 ] += flGroundFactor * flMul; // 2 * gravity * height + } + + if ( neoPlayer && bIsRecon && bIsSprintingAsRecon && neoPlayer->CanSpeedBoost() ) + { + Vector vecForward; + + AngleVectors( mv->m_vecViewAngles, &vecForward ); + vecForward.z = 0; + VectorNormalize( vecForward ); + + vecForward *= mv->m_flForwardMove; + + VectorAdd( vecForward, mv->m_vecVelocity, mv->m_vecVelocity ); + } + + FinishGravity(); + + mv->m_outJumpVel.z += mv->m_vecVelocity[ 2 ] - startz; + mv->m_outStepHeight += 0.15f; + + OnJump( mv->m_outJumpVel.z ); + + // Set jump time. + if ( gpGlobals->maxClients == 1 ) + { + player->m_Local.m_flJumpTime = GAMEMOVEMENT_JUMP_TIME; + player->m_Local.m_bInDuckJump = true; + } + + // Flag that we jumped. + mv->m_nOldButtons |= IN_JUMP; // don't jump again until released + return true; +} + +void CNEOGameMovement::CategorizePosition() +{ + // There should be a mobile armor check in here + BaseClass::CategorizePosition(); +} + +void CNEOGameMovement::HandleDuckingSpeedCrop( void ) +{ +} \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp b/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp index aa5821d65c0..08563d0f97c 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp +++ b/mp/src/game/shared/NeotokyoSource/neo_gamerules.cpp @@ -51,4 +51,21 @@ bool CNEOGameRules::ShouldCollide( int collisionGroup0, int collisionGroup1 ) const CViewVectors* CNEOGameRules::GetViewVectors() const { return &g_NEOViewVectors; +} + +// I'm not sure what this is all about since the values seem to be 0 all the time +void CNEOGameRules::LevelShutdown() +{ + DevMsg( "Client CNEOGameRules::LevelShutdown\n" ); + + if ( m_iUnknown2 < 0 ) + m_iUnknown4 = m_iUnknown; + + else + { + delete m_iUnknown; + + m_iUnknown1 = 0; + m_iUnknown4 = nullptr; + } } \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/neo_gamerules.h b/mp/src/game/shared/NeotokyoSource/neo_gamerules.h index 9cd7e12a05e..8d8b6ff0be7 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_gamerules.h +++ b/mp/src/game/shared/NeotokyoSource/neo_gamerules.h @@ -32,7 +32,25 @@ class CNEOGameRules : public CTeamplayRules virtual const CViewVectors* GetViewVectors() const; + // These might be used somewhere, although these are pretty fucking useless (can I swear in c++) + virtual bool Unknown00( int unk, int unk2 ) { return true; } + virtual int Unknown01( int unk, int unk2 ) { return 0; } + virtual bool Unknown02() { return true; } + virtual float Unknown03( int unk ) { return 0.f; } + + virtual void LevelShutdown(); + + virtual void Unknown04(int unk, int unk2) {} + + inline bool IsInFreezePeriod() { return m_bFreezePeriod; } + private: + void* m_iUnknown; + int m_iUnknown1; + int m_iUnknown2; + int m_iUnknown3; + void* m_iUnknown4; + CNetworkVar( int, m_iGameType ); CNetworkVar( float, m_fRoundTimeLeft ); diff --git a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h index 340323cc058..efb406b450c 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h +++ b/mp/src/game/shared/NeotokyoSource/neo_shareddefs.h @@ -8,6 +8,21 @@ #define PANEL_LOADOUT "loadout" #define PANEL_LOADOUT_DEV "loadout_dev" + +#define NEO_VEC_VIEW_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vView * player->GetModelScale() ) +#define NEO_VEC_HULL_MIN_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vHullMin * player->GetModelScale() ) +#define NEO_VEC_HULL_MAX_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vHullMax * player->GetModelScale() ) + +#define NEO_VEC_DUCK_HULL_MIN_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vDuckHullMin * player->GetModelScale() ) +#define NEO_VEC_DUCK_HULL_MAX_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vDuckHullMax * player->GetModelScale() ) +#define NEO_VEC_DUCK_VIEW_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vDuckView * player->GetModelScale() ) + +#define NEO_VEC_OBS_HULL_MIN_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vObsHullMin * player->GetModelScale() ) +#define NEO_VEC_OBS_HULL_MAX_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vObsHullMax * player->GetModelScale() ) + +#define NEO_VEC_DEAD_VIEWHEIGHT_SCALED( classType, player ) ( m_ViewVectors[ classType ].m_vDeadViewHeight * player->GetModelScale() ) + + // From https://github.com/softashell/sourcemod-nt-include #define TEAM_JINRAI 2 @@ -19,9 +34,11 @@ #define VISION_THERMAL 3 #define VISION_MOTION 4 +#define CLASS_NONE 0 #define CLASS_RECON 1 #define CLASS_ASSAULT 2 #define CLASS_SUPPORT 3 +#define CLASS_MAX 6 // Maybe the max, because of CNEOGameMovement::GetPlayerMins #define IN_AIM (1 << 23) #define IN_LEANL (1 << 24) diff --git a/mp/src/public/igameresources.h b/mp/src/public/igameresources.h index 8aeaae25a45..2026b86b481 100644 --- a/mp/src/public/igameresources.h +++ b/mp/src/public/igameresources.h @@ -36,6 +36,12 @@ abstract_class IGameResources virtual int GetFrags( int index ) = 0; virtual int GetTeam( int index ) = 0; virtual int GetHealth( int index ) = 0; + +#ifdef NEO_DLL + virtual int GetClassType( int index ) = 0; + virtual int GetStar( int index ) = 0; + virtual int GetRank( int index ) = 0; +#endif }; extern IGameResources *GameResources( void ); // singelton accessor From c63d1c836bf2cef69136f7a8aeb641c22d5dd572 Mon Sep 17 00:00:00 2001 From: Ochii Date: Wed, 29 Jun 2016 15:59:02 +0100 Subject: [PATCH 12/12] Add CNEOPlayerAnimState most of the code was pasted like everything i do am i right --- .../client/NeotokyoSource/c_neoplayer.cpp | 6 + .../game/client/NeotokyoSource/c_neoplayer.h | 1 + .../NeotokyoSource/neo_playeranimstate.cpp | 558 ++++++++++++++++++ .../NeotokyoSource/neo_playeranimstate.h | 3 + .../shared/NeotokyoSource/weapon_neobase.cpp | 5 + .../shared/NeotokyoSource/weapon_neobase.h | 3 + 6 files changed, 576 insertions(+) create mode 100644 mp/src/game/shared/NeotokyoSource/neo_playeranimstate.cpp diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp index cd24b48d286..207e8059870 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.cpp @@ -376,6 +376,11 @@ CWeaponNEOBase* C_NEOPlayer::GetActiveNEOWeapon() const return dynamic_cast< CWeaponNEOBase* >( GetActiveWeapon() ); } +void C_NEOPlayer::UpdateSomething2() +{ + // To mess with later +} + void C_NEOPlayer::UpdateThermoptic() { if ( m_iThermoptic != m_iOldThermoptic ) @@ -878,6 +883,7 @@ void C_NEOPlayer::PreThink() { BaseClass::PreThink(); + UpdateSomething2(); UpdateThermoptic(); UpdateGeiger(); UpdateVision(); diff --git a/mp/src/game/client/NeotokyoSource/c_neoplayer.h b/mp/src/game/client/NeotokyoSource/c_neoplayer.h index 58073635dd5..81359dca5e9 100644 --- a/mp/src/game/client/NeotokyoSource/c_neoplayer.h +++ b/mp/src/game/client/NeotokyoSource/c_neoplayer.h @@ -75,6 +75,7 @@ class C_NEOPlayer : public C_BasePlayer, public INEOPlayerAnimStateHelpers inline int GetVision() { return m_iVision; } inline int GetSprint() { return m_iSprint; } + void UpdateSomething2(); void UpdateThermoptic(); void UpdateGeiger(); void UpdateVision(); diff --git a/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.cpp b/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.cpp new file mode 100644 index 00000000000..572de219ddc --- /dev/null +++ b/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.cpp @@ -0,0 +1,558 @@ +#include "cbase.h" +#include "neo_playeranimstate.h" +#include "base_playeranimstate.h" +#include "c_neoplayer.h" +#include "weapon_neobase.h" +#include "animation.h" + +// Mostly from CSS' source + +#define ANIM_TOPSPEED_WALK 100 +#define ANIM_TOPSPEED_RUN 250 +#define ANIM_TOPSPEED_RUN_CROUCH 85 + +#define DEFAULT_IDLE_NAME "idle_upper_" +#define DEFAULT_CROUCH_IDLE_NAME "crouch_idle_upper_" +#define DEFAULT_CROUCH_WALK_NAME "crouch_walk_upper_" +#define DEFAULT_WALK_NAME "walk_upper_" +#define DEFAULT_RUN_NAME "run_upper_" + +#define DEFAULT_FIRE_IDLE_NAME "idle_shoot_" +#define DEFAULT_FIRE_CROUCH_NAME "crouch_idle_shoot_" +#define DEFAULT_FIRE_CROUCH_WALK_NAME "crouch_walk_shoot_" +#define DEFAULT_FIRE_WALK_NAME "walk_shoot_" +#define DEFAULT_FIRE_RUN_NAME "run_shoot_" + +// I'm not sure about these values +#define FIRESEQUENCE_LAYER (AIMSEQUENCE_LAYER+NUM_AIMSEQUENCE_LAYERS) +#define RELOADSEQUENCE_LAYER (FIRESEQUENCE_LAYER+1) +#define GRENADESEQUENCE_LAYER (RELOADSEQUENCE_LAYER+1) +#define NUM_LAYERS_WANTED (GRENADESEQUENCE_LAYER+1) + +float g_flThrowGrenadeFraction = 0.25; + + +class CNEOPlayerAnimState : public CBasePlayerAnimState, public INEOPlayerAnimState +{ +public: + DECLARE_CLASS( CNEOPlayerAnimState, CBasePlayerAnimState ); + friend INEOPlayerAnimState* CreatePlayerAnimState( CBaseAnimatingOverlay *pEntity, INEOPlayerAnimStateHelpers *pHelpers, LegAnimType_t legAnimType, bool bUseAimSequences ); + + CNEOPlayerAnimState(); + + virtual void DoAnimationEvent( PlayerAnimEvent_t event, int nData ); + virtual bool IsThrowingGrenade(); + + virtual void ClearAnimationLayers(); + virtual void ComputeSequences( CStudioHdr *pStudioHdr ); + virtual Activity CalcMainActivity(); + virtual int CalcAimLayerSequence( float *flCycle, float *flAimSequenceWeight, bool bForceIdle ); + virtual bool CanThePlayerMove(); + virtual float GetCurrentMaxGroundSpeed(); + virtual void DebugShowAnimState( int iStartLine ); + virtual void ComputePoseParam_BodyPitch( CStudioHdr *pStudioHdr ); + + void InitNEO( CBaseAnimatingOverlay *pPlayer, INEOPlayerAnimStateHelpers *pHelpers, LegAnimType_t legAnimType, bool bUseAimSequences ); + +protected: + int CalcReloadLayerSequence(); + void ComputeFireSequence( CStudioHdr *pStudioHdr ); + + void ComputeReloadSequence( CStudioHdr *pStudioHdr ); + int CalcFireLayerSequence( PlayerAnimEvent_t event ); + + int GetOuterGrenadeThrowCounter(); + bool IsOuterGrenadePrimed(); + int CalcGrenadePrimeSequence(); + int CalcGrenadeThrowSequence(); + void ComputeGrenadeSequence( CStudioHdr *pStudioHdr ); + + const char* GetWeaponSuffix(); + bool HandleJumping(); + + void UpdateLayerSequenceGeneric( CStudioHdr *pStudioHdr, int iLayer, bool &bEnabled, float &flCurCycle, int &iSequence, bool bWaitAtEnd ); + +private: + bool m_bJumping; // Set on a jump event. + bool m_bUnknown; // It's very likely that it's related to jumping to be placed in here + float m_flJumpStartTime; + bool m_bFirstJumpFrame; + + // Aim sequence plays reload while this is on. + bool m_bReloading; + float m_flReloadCycle; + int m_iReloadSequence; + + // This is set to true if ANY animation is being played in the fire layer. + bool m_bFiring; // If this is on, then it'll continue the fire animation in the fire layer + // until it completes. + int m_iFireSequence; // (For any sequences in the fire layer, including grenade throw). + float m_flFireCycle; + + // These control grenade animations. + bool m_bThrowingGrenade; + bool m_bPrimingGrenade; + float m_flGrenadeCycle; + int m_iGrenadeSequence; + int m_iLastThrowGrenadeCounter; // used to detect when the guy threw the grenade. + + INEOPlayerAnimStateHelpers* m_pHelpers; +}; + + +INEOPlayerAnimState* CreatePlayerAnimState( CBaseAnimatingOverlay *pEntity, INEOPlayerAnimStateHelpers *pHelpers, LegAnimType_t legAnimType, bool bUseAimSequences ) +{ + CNEOPlayerAnimState *pRet = new CNEOPlayerAnimState; + pRet->InitNEO( pEntity, pHelpers, legAnimType, bUseAimSequences ); + return pRet; +} + + +CNEOPlayerAnimState::CNEOPlayerAnimState() +{ + m_pOuter = nullptr; + + m_bUnknown = false; +} + +void CNEOPlayerAnimState::InitNEO( CBaseAnimatingOverlay *pEntity, INEOPlayerAnimStateHelpers *pHelpers, LegAnimType_t legAnimType, bool bUseAimSequences ) +{ + CModAnimConfig config; + config.m_flMaxBodyYawDegrees = 90; + config.m_LegAnimType = legAnimType; + config.m_bUseAimSequences = bUseAimSequences; + + m_pHelpers = pHelpers; + + BaseClass::Init( pEntity, config ); +} + +const char* CNEOPlayerAnimState::GetWeaponSuffix() +{ + // Figure out the weapon suffix. + CWeaponNEOBase *pWeapon = m_pHelpers->NEOAnim_GetActiveWeapon(); + if ( !pWeapon ) + return nullptr; + + return pWeapon->GetNEOWpnData().szAnimationPrefix; +} + +void CNEOPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData ) +{ + switch ( event ) + { + case PLAYERANIMEVENT_FIRE_GUN_PRIMARY: + case PLAYERANIMEVENT_FIRE_GUN_SECONDARY: + // Regardless of what we're doing in the fire layer, restart it. + m_flFireCycle = 0; + m_iFireSequence = CalcFireLayerSequence( event ); + m_bFiring = m_iFireSequence != -1; + break; + + case PLAYERANIMEVENT_JUMP: + // Play the jump animation. + m_bJumping = true; + m_bFirstJumpFrame = true; + m_flJumpStartTime = gpGlobals->curtime; + break; + + case PLAYERANIMEVENT_RELOAD: + m_iReloadSequence = CalcReloadLayerSequence(); + + if ( m_iReloadSequence != -1 ) + { + m_bReloading = true; + m_flReloadCycle = 0; + } + } +} + +bool CNEOPlayerAnimState::IsThrowingGrenade() +{ + if ( m_bThrowingGrenade ) + { + // An animation event would be more appropriate here. + return m_flGrenadeCycle < g_flThrowGrenadeFraction; + } + else + { + bool bThrowPending = (m_iLastThrowGrenadeCounter != GetOuterGrenadeThrowCounter()); + return bThrowPending || IsOuterGrenadePrimed(); + } +} + +void CNEOPlayerAnimState::ClearAnimationLayers() +{ + if ( !m_pOuter ) + return; + + m_pOuter->SetNumAnimOverlays( NUM_LAYERS_WANTED ); + for ( int i = 0; i < m_pOuter->GetNumAnimOverlays(); i++ ) + { + m_pOuter->GetAnimOverlay( i )->SetOrder( CBaseAnimatingOverlay::MAX_OVERLAYS ); +#ifndef CLIENT_DLL + m_pOuter->GetAnimOverlay( i )->m_fFlags = 0; +#endif + } +} + +void CNEOPlayerAnimState::ComputeSequences( CStudioHdr *pStudioHdr ) +{ + BaseClass::ComputeSequences( pStudioHdr ); + + ComputeFireSequence( pStudioHdr ); + ComputeReloadSequence( pStudioHdr ); + ComputeGrenadeSequence( pStudioHdr ); + + C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer(); + + localPlayer->UpdateSomething2(); + localPlayer->UpdateThermoptic(); + localPlayer->NEO_MuzzleFlash(); +} + +Activity CNEOPlayerAnimState::CalcMainActivity() +{ + float flOuterSpeed = GetOuterXYSpeed(); + + if ( HandleJumping() ) + { + return ACT_HOP; + } + else + { + Activity idealActivity = ACT_IDLE; + + if ( m_pOuter->GetFlags() & FL_DUCKING ) + { + if ( flOuterSpeed > MOVING_MINIMUM_SPEED ) + idealActivity = ACT_RUN_CROUCH; + else + idealActivity = ACT_CROUCHIDLE; + } + else + { + if ( flOuterSpeed > MOVING_MINIMUM_SPEED ) + { + if ( flOuterSpeed > ARBITRARY_RUN_SPEED ) + idealActivity = ACT_RUN; + else + idealActivity = ACT_WALK; + } + else + { + idealActivity = ACT_IDLE; + } + } + + return idealActivity; + } +} + +int CNEOPlayerAnimState::CalcAimLayerSequence( float *flCycle, float *flAimSequenceWeight, bool bForceIdle ) +{ + const char *pSuffix = GetWeaponSuffix(); + + if ( !pSuffix ) + pSuffix = "Pistol"; + + if ( bForceIdle ) + { + switch ( GetCurrentMainSequenceActivity() ) + { + case ACT_CROUCHIDLE: + case ACT_RUN_CROUCH: + return CalcSequenceIndex( "%s%s", DEFAULT_CROUCH_IDLE_NAME, pSuffix ); + + default: + return CalcSequenceIndex( "%s%s", DEFAULT_IDLE_NAME, pSuffix ); + } + } + else + { + switch ( GetCurrentMainSequenceActivity() ) + { + case ACT_RUN: + return CalcSequenceIndex( "%s%s", DEFAULT_RUN_NAME, pSuffix ); + + case ACT_WALK: + case ACT_RUNTOIDLE: + case ACT_IDLETORUN: + return CalcSequenceIndex( "%s%s", DEFAULT_WALK_NAME, pSuffix ); + + case ACT_CROUCHIDLE: + return CalcSequenceIndex( "%s%s", DEFAULT_CROUCH_IDLE_NAME, pSuffix ); + + case ACT_RUN_CROUCH: + return CalcSequenceIndex( "%s%s", DEFAULT_CROUCH_WALK_NAME, pSuffix ); + + case ACT_IDLE: + default: + return CalcSequenceIndex( "%s%s", DEFAULT_IDLE_NAME, pSuffix ); + } + } +} + +bool CNEOPlayerAnimState::CanThePlayerMove() +{ + return m_pHelpers->NEOAnim_CanMove(); +} + +float CNEOPlayerAnimState::GetCurrentMaxGroundSpeed() +{ + Activity currentActivity = m_pOuter->GetSequenceActivity( m_pOuter->GetSequence() ); + + if ( currentActivity == ACT_WALK || currentActivity == ACT_IDLE ) + return ANIM_TOPSPEED_WALK; + + else if ( currentActivity == ACT_RUN ) + return ANIM_TOPSPEED_RUN; + + else if ( currentActivity == ACT_RUN_CROUCH ) + return ANIM_TOPSPEED_RUN_CROUCH; + + else + return 0; +} + +void CNEOPlayerAnimState::DebugShowAnimState( int iStartLine ) +{ + engine->Con_NPrintf( iStartLine++, "fire : %s, cycle: %.2f\n", m_bFiring ? GetSequenceName( m_pOuter->GetModelPtr(), m_iFireSequence ) : "[not firing]", m_flFireCycle ); + engine->Con_NPrintf( iStartLine++, "reload: %s, cycle: %.2f\n", m_bReloading ? GetSequenceName( m_pOuter->GetModelPtr(), m_iReloadSequence ) : "[not reloading]", m_flReloadCycle ); + BaseClass::DebugShowAnimState( iStartLine ); +} + +void CNEOPlayerAnimState::ComputePoseParam_BodyPitch( CStudioHdr *pStudioHdr ) +{ + BaseClass::ComputePoseParam_BodyPitch( pStudioHdr ); +} + +bool CNEOPlayerAnimState::HandleJumping() +{ + // Might have to look at this if statement later + if ( !m_bJumping && !(m_pOuter->GetFlags() & FL_ONGROUND) ) + { + m_bJumping = true; + m_bFirstJumpFrame = true; + m_flJumpStartTime = gpGlobals->curtime; + } + + if ( m_bJumping ) + { + if ( m_bFirstJumpFrame ) + { + m_bFirstJumpFrame = false; + RestartMainSequence(); // Reset the animation. + } + + // Don't check if he's on the ground for a sec.. sometimes the client still has the + // on-ground flag set right when the message comes in. + if ( gpGlobals->curtime - m_flJumpStartTime > 0.2f ) + { + if ( m_pOuter->GetFlags() & FL_ONGROUND ) + { + m_bJumping = false; + RestartMainSequence(); // Reset the animation. + } + } + } + + // Are we still jumping? If so, keep playing the jump animation. + return m_bJumping; +} + +void CNEOPlayerAnimState::ComputeFireSequence( CStudioHdr *pStudioHdr ) +{ + UpdateLayerSequenceGeneric( pStudioHdr, FIRESEQUENCE_LAYER, m_bFiring, m_flFireCycle, m_iFireSequence, false ); +} + +void CNEOPlayerAnimState::ComputeReloadSequence( CStudioHdr *pStudioHdr ) +{ + UpdateLayerSequenceGeneric( pStudioHdr, RELOADSEQUENCE_LAYER, m_bReloading, m_flReloadCycle, m_iReloadSequence, false ); +} + +// Should we be returning -1 when these functions fail? +int CNEOPlayerAnimState::CalcFireLayerSequence( PlayerAnimEvent_t event ) +{ + // Figure out the weapon suffix. + CWeaponNEOBase *pWeapon = m_pHelpers->NEOAnim_GetActiveWeapon(); + if ( !pWeapon ) + return 0; + + const char *pSuffix = GetWeaponSuffix(); + + if ( !pSuffix ) + return 0; + + if ( event == PLAYERANIMEVENT_THROW_GRENADE ) + pSuffix = "Gren"; + + switch ( GetCurrentMainSequenceActivity() ) + { + case ACT_PLAYER_RUN_FIRE: + case ACT_RUN: + return CalcSequenceIndex( "%s%s", DEFAULT_FIRE_RUN_NAME, pSuffix ); + + case ACT_PLAYER_WALK_FIRE: + case ACT_WALK: + return CalcSequenceIndex( "%s%s", DEFAULT_FIRE_WALK_NAME, pSuffix ); + + case ACT_PLAYER_CROUCH_FIRE: + case ACT_CROUCHIDLE: + return CalcSequenceIndex( "%s%s", DEFAULT_FIRE_CROUCH_NAME, pSuffix ); + + case ACT_PLAYER_CROUCH_WALK_FIRE: + case ACT_RUN_CROUCH: + return CalcSequenceIndex( "%s%s", DEFAULT_FIRE_CROUCH_WALK_NAME, pSuffix ); + + default: + case ACT_PLAYER_IDLE_FIRE: + return CalcSequenceIndex( "%s%s", DEFAULT_FIRE_IDLE_NAME, pSuffix ); + } +} + +int CNEOPlayerAnimState::CalcReloadLayerSequence() +{ + const char* weaponSuffix = GetWeaponSuffix(); + + if ( !weaponSuffix ) + return -1; + + char szName[ 512 ]; + + V_snprintf( szName, sizeof( szName ), "reload_%s", weaponSuffix ); + int iReloadSequence = m_pOuter->LookupSequence( szName ); + if ( iReloadSequence != -1 ) + return iReloadSequence; + + return -1; +} + + +// I'm not sure if these functions are named correctly +int CNEOPlayerAnimState::CalcGrenadePrimeSequence() +{ + return CalcSequenceIndex( "Run_Upper_Grenade" ); +} + +int CNEOPlayerAnimState::CalcGrenadeThrowSequence() +{ + return CalcSequenceIndex( "idle_shoot_gren1" ); +} + +int CNEOPlayerAnimState::GetOuterGrenadeThrowCounter() +{ + C_NEOPlayer* player = dynamic_cast(m_pOuter); + + if ( player ) + return player->m_iThrowGrenadeCounter; + + return 0; +} + +void CNEOPlayerAnimState::UpdateLayerSequenceGeneric( CStudioHdr *pStudioHdr, int iLayer, bool &bEnabled, float &flCurCycle, int &iSequence, bool bWaitAtEnd ) +{ + if ( !bEnabled || iSequence < 0 ) + return; + + // Increment the fire sequence's cycle. + flCurCycle += m_pOuter->GetSequenceCycleRate( pStudioHdr, iSequence ) * gpGlobals->frametime; + if ( flCurCycle > 1 ) + { + if ( bWaitAtEnd ) + { + flCurCycle = 1; + } + else + { + // Not firing anymore. + bEnabled = false; + iSequence = 0; + return; + } + } + + // Now dump the state into its animation layer. + CAnimationLayer *pLayer = m_pOuter->GetAnimOverlay( iLayer ); + + pLayer->m_flCycle = flCurCycle; + pLayer->m_nSequence = iSequence; + + pLayer->m_flPlaybackRate = 1.0f; + pLayer->m_flWeight = 1.0f; + pLayer->m_nOrder = iLayer; +#ifndef CLIENT_DLL + pLayer->m_fFlags |= ANIM_LAYER_ACTIVE; +#endif +} + +bool CNEOPlayerAnimState::IsOuterGrenadePrimed() +{ + CBaseCombatCharacter *pChar = m_pOuter->MyCombatCharacterPointer(); + if ( pChar ) + { + // !!! GOTTA REVERSE GRENADES FIRST !!! + //CBaseNEOGrenade *pGren = dynamic_cast(pChar->GetActiveWeapon()); + //return pGren && pGren->IsPinPulled(); + } + else + { + return NULL; + } +} + +void CNEOPlayerAnimState::ComputeGrenadeSequence( CStudioHdr *pStudioHdr ) +{ + if ( m_bThrowingGrenade ) + { + UpdateLayerSequenceGeneric( pStudioHdr, GRENADESEQUENCE_LAYER, m_bThrowingGrenade, m_flGrenadeCycle, m_iGrenadeSequence, false ); + } + else + { + // Priming the grenade isn't an event.. we just watch the player for it. + // Also play the prime animation first if he wants to throw the grenade. + bool bThrowPending = (m_iLastThrowGrenadeCounter != GetOuterGrenadeThrowCounter()); + if ( IsOuterGrenadePrimed() || bThrowPending ) + { + if ( !m_bPrimingGrenade ) + { + // If this guy just popped into our PVS, and he's got his grenade primed, then + // let's assume that it's all the way primed rather than playing the prime + // animation from the start. + if ( TimeSinceLastAnimationStateClear() < 0.4f ) + { + m_flGrenadeCycle = 1; + } + else + { + m_flGrenadeCycle = 0; + } + + m_iGrenadeSequence = CalcGrenadePrimeSequence(); + } + + m_bPrimingGrenade = true; + UpdateLayerSequenceGeneric( pStudioHdr, GRENADESEQUENCE_LAYER, m_bPrimingGrenade, m_flGrenadeCycle, m_iGrenadeSequence, true ); + + // If we're waiting to throw and we're done playing the prime animation... + if ( bThrowPending && m_flGrenadeCycle == 1 ) + { + m_iLastThrowGrenadeCounter = GetOuterGrenadeThrowCounter(); + + // Now play the throw animation. + m_iGrenadeSequence = CalcGrenadeThrowSequence(); + if ( m_iGrenadeSequence != -1 ) + { + // Configure to start playing + m_bThrowingGrenade = true; + m_bPrimingGrenade = false; + m_flGrenadeCycle = 0; + } + } + } + else + { + m_bPrimingGrenade = false; + } + } +} \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.h b/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.h index f3f38d264c9..52570dd16b1 100644 --- a/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.h +++ b/mp/src/game/shared/NeotokyoSource/neo_playeranimstate.h @@ -20,6 +20,9 @@ class CNEOPlayer; #endif +// When moving this fast, he plays run anim. +#define ARBITRARY_RUN_SPEED 175.0f + enum PlayerAnimEvent_t { PLAYERANIMEVENT_FIRE_GUN_PRIMARY=0, diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp index c3b8701c5be..23fc85d1389 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.cpp @@ -640,4 +640,9 @@ void CWeaponNEOBase::DoNEOMuzzleFlash() const char* CWeaponNEOBase::GetTeam2ViewModelName() { return ((CNEOWeaponInfo*) &GetWpnData())->m_szTeam2viewmodel; // Yeah this is kinda ugly +} + +const CNEOWeaponInfo& CWeaponNEOBase::GetNEOWpnData() const +{ + return *(CNEOWeaponInfo*) &GetWpnData(); } \ No newline at end of file diff --git a/mp/src/game/shared/NeotokyoSource/weapon_neobase.h b/mp/src/game/shared/NeotokyoSource/weapon_neobase.h index c3ef315ca1e..78d9288aced 100644 --- a/mp/src/game/shared/NeotokyoSource/weapon_neobase.h +++ b/mp/src/game/shared/NeotokyoSource/weapon_neobase.h @@ -64,6 +64,9 @@ class CWeaponNEOBase : public CBaseCombatWeapon virtual float GetRunningFov() { return 75.f; } virtual float GetAimingFov() { return 50.f; } +public: + const CNEOWeaponInfo& GetNEOWpnData() const; + public: // Let's just keep these public for a while int m_iTeam2ViewModelIndex;