Недостоющие файлы Source SDK
< Ru
Из-за недавнего обновления доступного исходного кода, в модах создаваемые через Source SDK не хватает нескольких файлов. Эти файлы, в некоторых случаях, имеют решающее значение для создания проекта, и поэтому они будут опубликованы здесь в текстовом формате. Просто скопируйте текст в новый файл .CPP или .H (Соответственно) и сохраните в нужное место для вашего мода.
ibik.h
Сохраните ibik.h в: \src\public\avi\, и пройдите по сcылке [1] и как указанно в статье допишите этот код.
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
//=============================================================================
#ifndef IBIK_H
#define IBIK_H
#ifdef _WIN32
#pragma once
#endif
#include "appframework/IAppSystem.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct BGR888_t;
class IMaterial;
//-----------------------------------------------------------------------------
// Parameters for creating a new BINK
//-----------------------------------------------------------------------------
struct BIKParams_t
{
BIKParams_t() :
m_nFrameRate( 0 ), m_nFrameScale( 1 ), m_nWidth( 0 ), m_nHeight( 0 ),
m_nSampleRate( 0 ), m_nSampleBits( 0 ), m_nNumChannels( 0 )
{
m_pFileName[ 0 ] = 0;
}
char m_pFileName[ 256 ];
char m_pPathID[ 256 ];
// fps = m_nFrameRate / m_nFrameScale
// for integer framerates, set framerate to the fps, and framescale to 1
// for ntsc-style framerates like 29.97 (or 23.976 or 59.94),
// set framerate to 30,000 (or 24,000 or 60,000) and framescale to 1001
// yes, framescale is an odd naming choice, but it matching MS's AVI api
int m_nFrameRate;
int m_nFrameScale;
int m_nWidth;
int m_nHeight;
// Sound/.wav info
int m_nSampleRate;
int m_nSampleBits;
int m_nNumChannels;
};
//-----------------------------------------------------------------------------
// Handle to an BINK
//-----------------------------------------------------------------------------
typedef unsigned short BIKHandle_t;
enum
{
BIKHANDLE_INVALID = (BIKHandle_t)~0
};
//-----------------------------------------------------------------------------
// Handle to an BINK material
//-----------------------------------------------------------------------------
typedef unsigned short BIKMaterial_t;
enum
{
BIKMATERIAL_INVALID = (BIKMaterial_t)~0
};
//-----------------------------------------------------------------------------
// Main AVI interface
//-----------------------------------------------------------------------------
#define BIK_INTERFACE_VERSION "VBik001"
class IBik : public IAppSystem
{
public:
// Create/destroy a BINK material (a materialsystem IMaterial)
virtual BIKMaterial_t CreateMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID ) = 0;
virtual void DestroyMaterial( BIKMaterial_t hMaterial ) = 0;
// Update the frame (if necessary)
virtual bool Update( BIKMaterial_t hMaterial ) = 0;
// Gets the IMaterial associated with an BINK material
virtual IMaterial* GetMaterial( BIKMaterial_t hMaterial ) = 0;
// Returns the max texture coordinate of the BINK
virtual void GetTexCoordRange( BIKMaterial_t hMaterial, float *pMaxU, float *pMaxV ) = 0;
// Returns the frame size of the BINK (stored in a subrect of the material itself)
virtual void GetFrameSize( BIKMaterial_t hMaterial, int *pWidth, int *pHeight ) = 0;
// Returns the frame rate of the BINK
virtual int GetFrameRate( BIKMaterial_t hMaterial ) = 0;
// Returns the total frame count of the BINK
virtual int GetFrameCount( BIKMaterial_t hMaterial ) = 0;
// Sets the frame for an BINK material (use instead of SetTime)
virtual void SetFrame( BIKMaterial_t hMaterial, float flFrame ) = 0;
#if !defined( _X360 )
// Sets the direct sound device that Bink will decode to
virtual bool SetDirectSoundDevice( void *pDevice ) = 0;
#else
//needs to be called after xaudio is initialized
virtual bool HookXAudio( void ) = 0;
#endif
};
#endif // IBIK_H
weapon_sdkbase
Этоти файлы weapon_sdkbase.h и weapon_sdkbase.cpp по-прежнему отсутствуют при создании мода по шаблону SDK, а это приводит к
fatal error C1083: Cannot open include file: 'weapon_sdkbase.h': No such file or directory
Расположение файлов weapon_sdkbase.h и weapon_sdkbase.cpp в: \src\game\shared\sdk\
weapon_sdkbase.h
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef WEAPON_SDKBASE_H
#define WEAPON_SDKBASE_H
#ifdef _WIN32
#pragma once
#endif
#include "sdk_playeranimstate.h"
#include "sdk_weapon_parse.h"
#if defined( CLIENT_DLL )
#define CWeaponSDKBase C_WeaponSDKBase
#endif
class CSDKPlayer;
// These are the names of the ammo types that the weapon script files reference.
class CWeaponSDKBase : public CBaseCombatWeapon
{
public:
DECLARE_CLASS( CWeaponSDKBase, CBaseCombatWeapon );
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
CWeaponSDKBase();
#ifdef GAME_DLL
DECLARE_DATADESC();
#endif
#ifdef CLIENT_DLL
virtual bool ShouldPredict();
#endif
// All predicted weapons need to implement and return true
virtual bool IsPredicted() const { return true; }
virtual SDKWeaponID GetWeaponID( void ) const { return WEAPON_NONE; }
// Get SDK weapon specific weapon data.
CSDKWeaponInfo const &GetSDKWpnData() const;
// Get a pointer to the player that owns this weapon
CSDKPlayer* GetPlayerOwner() const;
// override to play custom empty sounds
virtual bool PlayEmptySound();
//Tony; these five functions return the sequences the view model uses for a particular action. -- You can override any of these in a particular weapon if you want them to do
//something different, ie: when a pistol is out of ammo, it would show a different sequence.
virtual Activity GetPrimaryAttackActivity( void ) { return ACT_VM_PRIMARYATTACK; }
virtual Activity GetIdleActivity( void ) { return ACT_VM_IDLE; }
virtual Activity GetDeployActivity( void ) { return ACT_VM_DRAW; }
virtual Activity GetReloadActivity( void ) { return ACT_VM_RELOAD; }
virtual Activity GetHolsterActivity( void ) { return ACT_VM_HOLSTER; }
virtual void WeaponIdle( void );
virtual bool Reload( void );
virtual bool Deploy();
virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
virtual void SendReloadEvents();
//Tony; added so we can have base functionality without implementing it into every weapon.
virtual void ItemPostFrame();
virtual void PrimaryAttack();
virtual void SecondaryAttack();
//Tony; default weapon spread, pretty accurate - accuracy systems would need to modify this
virtual float GetWeaponSpread() { return 0.01f; }
//Tony; by default, all weapons are automatic.
//If you add code to switch firemodes, this function would need to be overridden to return the correct current mode.
virtual int GetFireMode() const { return FM_AUTOMATIC; }
virtual float GetFireRate( void ) { return GetSDKWpnData().m_flCycleTime; };
//Tony; by default, burst fire weapons use a max of 3 shots (3 - 1)
//weapons with more, ie: a 5 round burst, can override and determine which firemode it's in.
virtual int MaxBurstShots() const { return 2; }
float GetWeaponFOV()
{
return GetSDKWpnData().m_flWeaponFOV;
}
#ifdef GAME_DLL
void SetDieThink( bool bDie );
void Die( void );
void SetWeaponModelIndex( const char *pName )
{
m_iWorldModelIndex = modelinfo->GetModelIndex( pName );
}
#endif
virtual bool CanWeaponBeDropped() const { return true; }
private:
CNetworkVar(float, m_flDecreaseShotsFired);
CWeaponSDKBase( const CWeaponSDKBase & );
};
#endif // WEAPON_SDKBASE_H
weapon_sdkbase.cpp
//\src\game\shared\sdk\weapon_sdkbase.cpp
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: http://pastebin.com/pHfTRTjp
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "in_buttons.h"
#include "takedamageinfo.h"
#include "weapon_sdkbase.h"
#include "ammodef.h"
#include "sdk_fx_shared.h"
#if defined( CLIENT_DLL )
#include "c_sdk_player.h"
#else
#include "sdk_player.h"
#endif
// ----------------------------------------------------------------------------- //
// CWeaponSDKBase tables.
// ----------------------------------------------------------------------------- //
IMPLEMENT_NETWORKCLASS_ALIASED( WeaponSDKBase, DT_WeaponSDKBase )
BEGIN_NETWORK_TABLE( CWeaponSDKBase, DT_WeaponSDKBase )
#ifdef CLIENT_DLL
RecvPropFloat( RECVINFO( m_flDecreaseShotsFired ) ),
#else
SendPropExclude( "DT_BaseAnimating", "m_nNewSequenceParity" ),
SendPropExclude( "DT_BaseAnimating", "m_nResetEventsParity" ),
SendPropFloat( SENDINFO( m_flDecreaseShotsFired ) ),
#endif
END_NETWORK_TABLE()
#ifdef CLIENT_DLL
BEGIN_PREDICTION_DATA( CWeaponSDKBase )
DEFINE_PRED_FIELD( m_flTimeWeaponIdle, FIELD_FLOAT, FTYPEDESC_OVERRIDE | FTYPEDESC_NOERRORCHECK ),
END_PREDICTION_DATA()
#endif
LINK_ENTITY_TO_CLASS( weapon_sdk_base, CWeaponSDKBase );
#ifdef GAME_DLL
BEGIN_DATADESC( CWeaponSDKBase )
// New weapon Think and Touch Functions go here..
END_DATADESC()
#endif
#ifdef CLIENT_DLL
bool CWeaponSDKBase::ShouldPredict()
{
if ( GetOwner() && GetOwner() == C_BasePlayer::GetLocalPlayer())
return true;
return BaseClass::ShouldPredict();
}
#endif
// ----------------------------------------------------------------------------- //
// CWeaponCSBase implementation.
// ----------------------------------------------------------------------------- //
CWeaponSDKBase::CWeaponSDKBase()
{
SetPredictionEligible( true );
AddSolidFlags( FSOLID_TRIGGER ); // Nothing collides with these but it gets touches.
}
const CSDKWeaponInfo &CWeaponSDKBase::GetSDKWpnData() const
{
const FileWeaponInfo_t *pWeaponInfo = &GetWpnData();
const CSDKWeaponInfo *pSDKInfo;
#ifdef _DEBUG
pSDKInfo = dynamic_cast< const CSDKWeaponInfo* >( pWeaponInfo );
Assert( pSDKInfo );
#else
pSDKInfo = static_cast< const CSDKWeaponInfo* >( pWeaponInfo );
#endif
return *pSDKInfo;
}
bool CWeaponSDKBase::PlayEmptySound()
{
CPASAttenuationFilter filter( this );
filter.UsePredictionRules();
EmitSound( filter, entindex(), "Default.ClipEmpty_Rifle" );
return 0;
}
CSDKPlayer* CWeaponSDKBase::GetPlayerOwner() const
{
return dynamic_cast< CSDKPlayer* >( GetOwner() );
}
#ifdef CLIENT_DLL
void UTIL_ClipPunchAngleOffset( QAngle &in, const QAngle &punch, const QAngle &clip )
{
QAngle final = in + punch;
//Clip each component
for ( int i = 0; i < 3; i++ )
{
if ( final[i] > clip[i] )
{
final[i] = clip[i];
}
else if ( final[i] < -clip[i] )
{
final[i] = -clip[i];
}
//Return the result
in[i] = final[i] - punch[i];
}
}
#endif
//Tony; added as a default primary attack if it doesn't get overridden, ie: by CSDKWeaponMelee
void CWeaponSDKBase::PrimaryAttack( void )
{
// If my clip is empty (and I use clips) start reload
if ( UsesClipsForAmmo1() && !m_iClip1 )
{
Reload();
return;
}
CSDKPlayer *pPlayer = GetPlayerOwner();
if (!pPlayer)
return;
//Tony; check firemodes --
switch(GetFireMode())
{
case FM_SEMIAUTOMATIC:
if (pPlayer->GetShotsFired() > 0)
return;
break;
//Tony; added an accessor to determine the max burst on a per-weapon basis.
case FM_BURST:
if (pPlayer->GetShotsFired() > MaxBurstShots())
return;
break;
}
#ifdef GAME_DLL
pPlayer->NoteWeaponFired();
#endif
pPlayer->DoMuzzleFlash();
SendWeaponAnim( GetPrimaryAttackActivity() );
// Make sure we don't fire more than the amount in the clip
if ( UsesClipsForAmmo1() )
m_iClip1 --;
else
pPlayer->RemoveAmmo(1, m_iPrimaryAmmoType );
pPlayer->IncreaseShotsFired();
float flSpread = GetWeaponSpread();
FX_FireBullets(
pPlayer->entindex(),
pPlayer->Weapon_ShootPosition(),
pPlayer->EyeAngles() + pPlayer->GetPunchAngle(),
GetWeaponID(),
0, //Tony; fire mode - this is unused at the moment, left over from CSS when SDK* was created in the first place.
CBaseEntity::GetPredictionRandomSeed() & 255,
flSpread
);
//Add our view kick in
AddViewKick();
//Tony; update our weapon idle time
SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() );
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration();
}
void CWeaponSDKBase::SecondaryAttack()
{
}
//Tony; added so we can have base functionality without implementing it into every weapon.
void CWeaponSDKBase::ItemPostFrame( void )
{
CSDKPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
//
//Tony; totally override the baseclass
//
if ( UsesClipsForAmmo1() )
CheckReload();
bool bFired = false;
// Secondary attack has priority
if ((pPlayer->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime) && pPlayer->CanAttack())
{
if (UsesSecondaryAmmo() && pPlayer->GetAmmoCount(m_iSecondaryAmmoType)<=0 )
{
if (m_flNextEmptySoundTime < gpGlobals->curtime)
{
WeaponSound(EMPTY);
m_flNextSecondaryAttack = m_flNextEmptySoundTime = gpGlobals->curtime + 0.5;
}
}
else if (pPlayer->GetWaterLevel() == 3 && m_bAltFiresUnderwater == false)
{
// This weapon doesn't fire underwater
WeaponSound(EMPTY);
m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
}
else
{
bFired = true;
SecondaryAttack();
// Secondary ammo doesn't have a reload animation
if ( UsesClipsForAmmo2() )
{
// reload clip2 if empty
if (m_iClip2 < 1)
{
pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType );
m_iClip2 = m_iClip2 + 1;
}
}
}
}
if ( !bFired && (pPlayer->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime) && pPlayer->CanAttack())
{
// Clip empty? Or out of ammo on a no-clip weapon?
if ( !IsMeleeWeapon() && (( UsesClipsForAmmo1() && m_iClip1 <= 0) || ( !UsesClipsForAmmo1() && pPlayer->GetAmmoCount(m_iPrimaryAmmoType)<=0 )) )
{
HandleFireOnEmpty();
}
else if (pPlayer->GetWaterLevel() == 3 && m_bFiresUnderwater == false)
{
// This weapon doesn't fire underwater
WeaponSound(EMPTY);
m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
}
else
{
PrimaryAttack();
}
}
// -----------------------
// Reload pressed / Clip Empty
// -----------------------
if ( pPlayer->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload)
{
// reload when reload is pressed, or if no buttons are down and weapon is empty.
Reload();
}
// -----------------------
// No buttons down
// -----------------------
if (!((pPlayer->m_nButtons & IN_ATTACK) || (pPlayer->m_nButtons & IN_ATTACK2) || (pPlayer->m_nButtons & IN_RELOAD)))
{
// no fire buttons down or reloading
if ( !ReloadOrSwitchWeapons() && ( m_bInReload == false ) )
{
WeaponIdle();
}
}
// Tony; decrease shots fired count - tweak the time as necessary.
if ( !( pPlayer->m_nButtons & IN_ATTACK ) )
{
//Tony; check firemodes -- If we're semi or burst, we will clear shots fired now that the player has let go of the button.
switch(GetFireMode())
{
case FM_SEMIAUTOMATIC:
if (pPlayer->GetShotsFired() > 0)
pPlayer->ClearShotsFired();
break;
//Tony; TODO; add an accessor to determine the max burst on a per-weapon basis!!
//DONE!
case FM_BURST:
if (pPlayer->GetShotsFired() > MaxBurstShots())
pPlayer->ClearShotsFired();
break;
}
m_bFireOnEmpty = false;
if ( (pPlayer->GetShotsFired() > 0) && (m_flDecreaseShotsFired < gpGlobals->curtime) )
{
m_flDecreaseShotsFired = gpGlobals->curtime + 0.05495;
pPlayer->DecreaseShotsFired();
}
}
}
void CWeaponSDKBase::WeaponIdle( void )
{
//Idle again if we've finished
if ( HasWeaponIdleTimeElapsed() )
{
SendWeaponAnim( GetIdleActivity() );
SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() );
}
}
bool CWeaponSDKBase::Reload( void )
{
bool fRet;
float fCacheTime = m_flNextSecondaryAttack;
fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), GetReloadActivity() );
if ( fRet )
{
SendReloadEvents();
// Undo whatever the reload process has done to our secondary
// attack timer. We allow you to interrupt reloading to fire
// a grenade.
m_flNextSecondaryAttack = GetOwner()->m_flNextAttack = fCacheTime;
WeaponSound( RELOAD );
if (GetPlayerOwner())
GetPlayerOwner()->ClearShotsFired();
}
return fRet;
}
void CWeaponSDKBase::SendReloadEvents()
{
CSDKPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
#ifdef GAME_DLL
// Send a message to any clients that have this entity to play the reload.
CPASFilter filter( pPlayer->GetAbsOrigin() );
filter.RemoveRecipient( pPlayer );
UserMessageBegin( filter, "ReloadEffect" );
WRITE_SHORT( pPlayer->entindex() );
MessageEnd();
#endif
// Make the player play his reload animation.
pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CWeaponSDKBase::Deploy( )
{
MDLCACHE_CRITICAL_SECTION();
//Tony; on deploy clear shots fired.
if (GetPlayerOwner())
GetPlayerOwner()->ClearShotsFired();
return DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), GetDeployActivity(), (char*)GetAnimPrefix() );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
//Tony; use the same name as the base context one.
#define SDK_HIDEWEAPON_THINK_CONTEXT "BaseCombatWeapon_HideThink"
bool CWeaponSDKBase::Holster( CBaseCombatWeapon *pSwitchingTo )
{
MDLCACHE_CRITICAL_SECTION();
// cancel any reload in progress.
m_bInReload = false;
// kill any think functions
SetThink(NULL);
// Some weapon's don't have holster anims yet, so detect that
float flSequenceDuration = 0;
SendWeaponAnim( GetHolsterActivity() );
{
flSequenceDuration = SequenceDuration();
}
CBaseCombatCharacter *pOwner = GetOwner();
if (pOwner)
{
pOwner->SetNextAttack( gpGlobals->curtime + flSequenceDuration );
}
// If we don't have a holster anim, hide immediately to avoid timing issues
if ( !flSequenceDuration )
{
SetWeaponVisible( false );
}
else
{
// Hide the weapon when the holster animation's finished
SetContextThink( &CBaseCombatWeapon::HideThink, gpGlobals->curtime + flSequenceDuration, SDK_HIDEWEAPON_THINK_CONTEXT );
}
return true;
}
#ifdef GAME_DLL
void CWeaponSDKBase::SetDieThink( bool bDie )
{
if( bDie )
SetContextThink( &CWeaponSDKBase::Die, gpGlobals->curtime + 45.0f, "DieContext" );
else
SetContextThink( NULL, gpGlobals->curtime, "DieContext" );
}
void CWeaponSDKBase::Die( void )
{
UTIL_Remove( this );
}
#endif
Перевод --Slam12f 21:08, 12 May 2013 (PDT)