|
|
#1 | |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
Hey,
I have an problem to add a new Weapon into my SourceMod. I used this Tutorial. http://www.moddb.com/ I made all the steps. (with vb2010 of course) But if i type. give weapon_colt1911 comes this error, and i am hopless what to do. ![]() Quote:
|
|
|
|
|
|
|
#2 |
![]() Join Date: Dec 2008
Reputation: 13
Posts: 25
|
In your weapon's .cpp file, search for the line that starts:
LINK_ENTITY_TO_CLASS( For your mod it should say Code:
LINK_ENTITY_TO_CLASS( weapon_colt1911, <whatever C++ Class name you are using for the gun> ); |
|
|
|
|
|
#3 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
I named it just like that:
Code:
LINK_ENTITY_TO_CLASS( weapon_colt1911, CWeaponColt1911 ); |
|
|
|
|
|
#4 |
![]() Join Date: Dec 2008
Reputation: 13
Posts: 25
|
hmm not sure then. We'd have to see more of the code to help. Could be several causes.
|
|
|
|
|
|
#5 |
![]() Join Date: Sep 2010
Reputation: 35
Posts: 453
|
Did you ever add it to the c_weapon_stubs_hl2.cpp file?
Code:
Before we compile there is one more thing to do. Open: Client > Source Files > HL2 DLL > c_weapon_stubs_hl2.cpp. Find the line: STUB_WEAPON_CLASS( weapon_pistol, WeaponPistol,C_BaseHLCombatWeapon ); Copy this and paste it under itself and change it to: STUB_WEAPON_CLASS( weapon_pwner, WeaponPwner,C_BaseHLCombatWeapon ); |
|
|
|
|
|
#6 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
The 2 Codes:
weapon_colt1911.cpp Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "npcevent.h"
#include "in_buttons.h"
#ifdef CLIENT_DLL
#include "c_hl2mp_player.h"
#else
#include "hl2mp_player.h"
#endif
#include "weapon_hl2mpbasehlmpcombatweapon.h"
#include "weapon_hl2mpbase_machinegun.h"
#define COLT1911_FASTEST_REFIRE_TIME 0.1f
#define COLT1911_FASTEST_DRY_REFIRE_TIME 0.2f
#define COLT1911_ACCURACY_SHOT_PENALTY_TIME 0.5f // Applied amount of time each shot adds to the time we must recover from
#define COLT1911_ACCURACY_MAXIMUM_PENALTY_TIME 1.5f // Maximum penalty to deal out
#ifdef CLIENT_DLL
#define CWeaponColt1911 C_WeaponColt1911
#endif
//-----------------------------------------------------------------------------
// CWeaponColt1911
//-----------------------------------------------------------------------------
class CWeaponColt1911 : public CHL2MPMachineGun
{
public:
DECLARE_CLASS( CWeaponColt1911, CHL2MPMachineGun );
CWeaponColt1911(void);
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
void Precache( void );
void ItemPostFrame( void );
void ItemPreFrame( void );
void ItemBusyFrame( void );
void PrimaryAttack( void );
void AddViewKick( void );
void DryFire( void );
void UpdatePenaltyTime( void );
Activity GetPrimaryAttackActivity( void );
virtual bool Reload( void );
virtual const Vector& GetBulletSpread( void )
{
static Vector cone;
float ramp = RemapValClamped( m_flAccuracyPenalty,
0.0f,
COLT1911_ACCURACY_MAXIMUM_PENALTY_TIME,
0.0f,
1.0f );
// We lerp from very accurate to inaccurate over time
VectorLerp( VECTOR_CONE_1DEGREES, VECTOR_CONE_6DEGREES, ramp, cone );
return cone;
}
virtual int GetMinBurst()
{
return 1;
}
virtual int GetMaxBurst()
{
return 3;
}
virtual float GetFireRate( void )
{
return 0.5f;
}
DECLARE_ACTTABLE();
private:
CNetworkVar( float, m_flSoonestPrimaryAttack );
CNetworkVar( float, m_flLastAttackTime );
CNetworkVar( float, m_flAccuracyPenalty );
CNetworkVar( int, m_nNumShotsFired );
private:
CWeaponColt1911( const CWeaponColt1911 & );
};
IMPLEMENT_NETWORKCLASS_ALIASED( WeaponColt1911, DT_WeaponColt1911 )
BEGIN_NETWORK_TABLE( CWeaponColt1911, DT_WeaponColt1911 )
#ifdef CLIENT_DLL
RecvPropTime( RECVINFO( m_flSoonestPrimaryAttack ) ),
RecvPropTime( RECVINFO( m_flLastAttackTime ) ),
RecvPropFloat( RECVINFO( m_flAccuracyPenalty ) ),
RecvPropInt( RECVINFO( m_nNumShotsFired ) ),
#else
SendPropTime( SENDINFO( m_flSoonestPrimaryAttack ) ),
SendPropTime( SENDINFO( m_flLastAttackTime ) ),
SendPropFloat( SENDINFO( m_flAccuracyPenalty ) ),
SendPropInt( SENDINFO( m_nNumShotsFired ) ),
#endif
END_NETWORK_TABLE()
#ifdef CLIENT_DLL
BEGIN_PREDICTION_DATA( CWeaponColt1911 )
DEFINE_PRED_FIELD( m_flSoonestPrimaryAttack, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flLastAttackTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flAccuracyPenalty, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_nNumShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
END_PREDICTION_DATA()
#endif
LINK_ENTITY_TO_CLASS( weapon_colt1911, CWeaponColt1911 );
PRECACHE_WEAPON_REGISTER( weapon_colt1911 );
acttable_t CWeaponColt1911::m_acttable[] =
{
{ ACT_MP_STAND_IDLE, ACT_HL2MP_IDLE_PISTOL, false },
{ ACT_MP_CROUCH_IDLE, ACT_HL2MP_IDLE_CROUCH_PISTOL, false },
{ ACT_MP_RUN, ACT_HL2MP_RUN_PISTOL, false },
{ ACT_MP_CROUCHWALK, ACT_HL2MP_WALK_CROUCH_PISTOL, false },
{ ACT_MP_ATTACK_STAND_PRIMARYFIRE, ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, false },
{ ACT_MP_ATTACK_CROUCH_PRIMARYFIRE, ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, false },
{ ACT_MP_RELOAD_STAND, ACT_HL2MP_GESTURE_RELOAD_PISTOL, false },
{ ACT_MP_RELOAD_CROUCH, ACT_HL2MP_GESTURE_RELOAD_PISTOL, false },
{ ACT_MP_JUMP, ACT_HL2MP_JUMP_PISTOL, false },
};
IMPLEMENT_ACTTABLE( CWeaponColt1911 );
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CWeaponColt1911::CWeaponColt1911( void )
{
m_flSoonestPrimaryAttack = gpGlobals->curtime;
m_flAccuracyPenalty = 0.0f;
m_fMinRange1 = 24;
m_fMaxRange1 = 1500;
m_fMinRange2 = 24;
m_fMaxRange2 = 200;
m_bFiresUnderwater = true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::Precache( void )
{
BaseClass::Precache();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::DryFire( void )
{
WeaponSound( EMPTY );
SendWeaponAnim( ACT_VM_DRYFIRE );
m_flSoonestPrimaryAttack = gpGlobals->curtime + COLT1911_FASTEST_DRY_REFIRE_TIME;
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::PrimaryAttack( void )
{
if ( ( gpGlobals->curtime - m_flLastAttackTime ) > 0.5f )
{
m_nNumShotsFired = 0;
}
else
{
m_nNumShotsFired++;
}
m_flLastAttackTime = gpGlobals->curtime;
m_flSoonestPrimaryAttack = gpGlobals->curtime + COLT1911_FASTEST_REFIRE_TIME;
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if( pOwner )
{
// Each time the player fires the Colt1911, reset the view punch. This prevents
// the aim from 'drifting off' when the player fires very quickly. This may
// not be the ideal way to achieve this, but it's cheap and it works, which is
// great for a feature we're evaluating. (sjb)
pOwner->ViewPunchReset();
}
BaseClass::PrimaryAttack();
// Add an accuracy penalty which can move past our maximum penalty time if we're really spastic
m_flAccuracyPenalty += COLT1911_ACCURACY_SHOT_PENALTY_TIME;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::UpdatePenaltyTime( void )
{
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner == NULL )
return;
// Check our penalty time decay
if ( ( ( pOwner->m_nButtons & IN_ATTACK ) == false ) && ( m_flSoonestPrimaryAttack < gpGlobals->curtime ) )
{
m_flAccuracyPenalty -= gpGlobals->frametime;
m_flAccuracyPenalty = clamp( m_flAccuracyPenalty, 0.0f, COLT1911_ACCURACY_MAXIMUM_PENALTY_TIME );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::ItemPreFrame( void )
{
UpdatePenaltyTime();
BaseClass::ItemPreFrame();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::ItemBusyFrame( void )
{
UpdatePenaltyTime();
BaseClass::ItemBusyFrame();
}
//-----------------------------------------------------------------------------
// Purpose: Allows firing as fast as button is pressed
//-----------------------------------------------------------------------------
void CWeaponColt1911::ItemPostFrame( void )
{
BaseClass::ItemPostFrame();
if ( m_bInReload )
return;
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner == NULL )
return;
if ( pOwner->m_nButtons & IN_ATTACK2 )
{
m_flLastAttackTime = gpGlobals->curtime + COLT1911_FASTEST_REFIRE_TIME;
m_flSoonestPrimaryAttack = gpGlobals->curtime + COLT1911_FASTEST_REFIRE_TIME;
m_flNextPrimaryAttack = gpGlobals->curtime + COLT1911_FASTEST_REFIRE_TIME;
}
//Allow a refire as fast as the player can click
if ( ( ( pOwner->m_nButtons & IN_ATTACK ) == false ) && ( m_flSoonestPrimaryAttack < gpGlobals->curtime ) )
{
m_flNextPrimaryAttack = gpGlobals->curtime - 0.1f;
}
else if ( ( pOwner->m_nButtons & IN_ATTACK ) && ( m_flNextPrimaryAttack < gpGlobals->curtime ) && ( m_iClip1 <= 0 ) )
{
DryFire();
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Output : int
//-----------------------------------------------------------------------------
Activity CWeaponColt1911::GetPrimaryAttackActivity( void )
{
if ( m_nNumShotsFired < 1 )
return ACT_VM_PRIMARYATTACK;
if ( m_nNumShotsFired < 2 )
return ACT_VM_RECOIL1;
if ( m_nNumShotsFired < 3 )
return ACT_VM_RECOIL2;
return ACT_VM_RECOIL3;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CWeaponColt1911::Reload( void )
{
bool fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
if ( fRet )
{
WeaponSound( RELOAD );
ToHL2MPPlayer(GetOwner())->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
m_flAccuracyPenalty = 0.0f;
}
return fRet;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponColt1911::AddViewKick( void )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if ( pPlayer == NULL )
return;
QAngle viewPunch;
viewPunch.x = SharedRandomFloat( "Colt1911pax", 0.25f, 0.5f );
viewPunch.y = SharedRandomFloat( "Colt1911pay", -.6f, .6f );
viewPunch.z = 0.0f;
//Add it to the view punch
pPlayer->ViewPunch( viewPunch );
}
Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // //=============================================================================// #include "cbase.h" #include "c_weapon__stubs.h" #include "basehlcombatweapon_shared.h" #include "c_basehlcombatweapon.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" STUB_WEAPON_CLASS( cycler_weapon, WeaponCycler, C_BaseCombatWeapon ); STUB_WEAPON_CLASS( weapon_binoculars, WeaponBinoculars, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_bugbait, WeaponBugBait, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_flaregun, Flaregun, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_annabelle, WeaponAnnabelle, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_gauss, WeaponGaussGun, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_cubemap, WeaponCubemap, C_BaseCombatWeapon ); STUB_WEAPON_CLASS( weapon_alyxgun, WeaponAlyxGun, C_HLSelectFireMachineGun ); STUB_WEAPON_CLASS( weapon_citizenpackage, WeaponCitizenPackage, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_citizensuitcase, WeaponCitizenSuitcase, C_WeaponCitizenPackage ); #ifndef HL2MP STUB_WEAPON_CLASS( weapon_colt1911, WeaponColt1911, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_pistol, WeaponPistol, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_ar2, WeaponAR2, C_HLMachineGun ); STUB_WEAPON_CLASS( weapon_frag, WeaponFrag, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_rpg, WeaponRPG, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_shotgun, WeaponShotgun, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_smg1, WeaponSMG1, C_HLSelectFireMachineGun ); STUB_WEAPON_CLASS( weapon_357, Weapon357, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_crossbow, WeaponCrossbow, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_slam, Weapon_SLAM, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_crowbar, WeaponCrowbar, C_BaseHLBludgeonWeapon ); #ifdef HL2_EPISODIC STUB_WEAPON_CLASS( weapon_hopwire, WeaponHopwire, C_BaseHLCombatWeapon ); //STUB_WEAPON_CLASS( weapon_proto1, WeaponProto1, C_BaseHLCombatWeapon ); #endif #ifdef HL2_LOSTCOAST STUB_WEAPON_CLASS( weapon_oldmanharpoon, WeaponOldManHarpoon, C_WeaponCitizenPackage ); #endif #endif |
|
|
|
|
|
#7 |
![]() Join Date: Aug 2008
Reputation: 416
Posts: 908
|
it compiles fine? Did it produce the binaries? Are the binaries copied to the correct directories?
|
|
|
|
|
|
#8 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
yep, it complies wothout errors or warnings. and yep again, it copies in the right directory.
|
|
|
|
|
|
#9 |
![]() Join Date: Aug 2011
Reputation: 12
Posts: 320
|
Does your weapons have a weapon_colt1911.txt script, in the scripts folder in your mod?
|
|
|
|
|
|
#10 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
yep, i made the exact same steps like in the tutorial.
|
|
|
|
|
|
#11 |
![]() Join Date: Aug 2011
Reputation: 12
Posts: 320
|
And you're sure that your client&server files do get copied over?
|
|
|
|
|
|
#12 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
you mean the client.dll and the server.dll?
|
|
|
|
|
|
#13 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
also, i reinstalled my src, and tryed it again, but it comes the same error.
Client.dll/server.dll works fine.
|
|
|
|
|
|
#14 |
![]() Join Date: Feb 2010
Reputation: 8
Posts: 148
|
I once had the same issue with a new weapon. Turns out Visual Studio thought the weapon's cpp file was a header file, so it wasn't being compiled in along with everything else.
Check the file's properties in Visual Studio to make sure it says 'C/C++ compiler'. |
|
|
|
|
|
#15 |
|
Join Date: Jun 2012
Reputation: 0
Posts: 8
|
It was on 'C/C++ compiler'.
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|