Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion game/jbmod/scripts/vscripts/gamemodes/sandbox.nut
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ IncludeScript( "gamemodes/base.nut" );
function OnPlayerSpawn( player )
{
player.EquipSuit();
player.GiveItem( "weapon_physcannon" );
player.GiveItem( "weapon_physgun" );
}
Binary file added game/jbmod/sound/weapons/flaregun/impact.wav
Binary file not shown.
Binary file added game/jbmod/sound/weapons/physgun_loop1.wav
Binary file not shown.
Binary file added game/jbmod/sound/weapons/physgun_loop2.wav
Binary file not shown.
Binary file added game/jbmod/sound/weapons/physgun_loop3.wav
Binary file not shown.
Binary file added game/jbmod/sound/weapons/physgun_loop4.wav
Binary file not shown.
Binary file added game/jbmod/sound/weapons/physgun_off.wav
Binary file not shown.
Binary file added game/jbmod/sound/weapons/physgun_on.wav
Binary file not shown.
1 change: 1 addition & 0 deletions src/game/client/client_jbmod.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ $Project "Client (JBMod)"
$File "$SRCDIR\game\shared\jbmod\weapon_stunstick.cpp"
$File "$SRCDIR\game\shared\jbmod\weapon_scripted.cpp"
$File "$SRCDIR\game\shared\jbmod\weapon_scripted.h"
$File "jbmod\c_weapon_physgun.cpp"
}

$Folder "UI"
Expand Down
181 changes: 181 additions & 0 deletions src/game/client/jbmod/c_weapon_physgun.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//

#include "cbase.h"
#include "hud.h"
#include "in_buttons.h"
#include "beamdraw.h"
#include "c_weapon__stubs.h"
#include "clienteffectprecachesystem.h"
#include "c_jbmod_player.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

CLIENTEFFECT_REGISTER_BEGIN( PrecacheEffectGravityGun )
CLIENTEFFECT_MATERIAL( "sprites/physbeam" )
CLIENTEFFECT_REGISTER_END()

class C_BeamQuadratic : public CDefaultClientRenderable
{
public:
C_BeamQuadratic();
void Update( C_BaseEntity *pOwner );

// IClientRenderable
virtual const Vector &GetRenderOrigin( void ) { return m_worldPosition; }
virtual const QAngle &GetRenderAngles( void ) { return vec3_angle; }
virtual const matrix3x4_t &RenderableToWorldTransform();
virtual bool ShouldDraw( void ) { return true; }
virtual bool IsTransparent( void ) { return true; }
virtual bool ShouldReceiveProjectedTextures( int flags ) { return false; }
virtual int DrawModel( int flags );

// Returns the bounds relative to the origin (render bounds)
virtual void GetRenderBounds( Vector &mins, Vector &maxs )
{
// bogus. But it should draw if you can see the end point
mins.Init( -99999, -99999, -99999 );
maxs.Init( 99999, 99999, 99999 );
}

C_BaseEntity *m_pOwner;
Vector m_targetPosition;
Vector m_worldPosition;
int m_active;
int m_glueTouching;
};


class C_WeaponGravityGun : public C_BaseCombatWeapon
{
DECLARE_CLASS( C_WeaponGravityGun, C_BaseCombatWeapon );
public:
C_WeaponGravityGun() {}

DECLARE_CLIENTCLASS();
DECLARE_PREDICTABLE();

int KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding )
{
if ( gHUD.m_iKeyBits & IN_ATTACK )
{
switch ( keynum )
{
case MOUSE_WHEEL_UP:
gHUD.m_iKeyBits |= IN_WEAPON1;
return 0;

case MOUSE_WHEEL_DOWN:
gHUD.m_iKeyBits |= IN_WEAPON2;
return 0;
}
}

// Allow engine to process
return BaseClass::KeyInput( down, keynum, pszCurrentBinding );
}

void OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
m_beam.Update( this );
}

void UpdateOnRemove( void )
{
m_beam.m_active = false;
m_beam.Update( this );

BaseClass::UpdateOnRemove();
}

private:
C_WeaponGravityGun( const C_WeaponGravityGun & );

C_BeamQuadratic m_beam;
};

STUB_WEAPON_CLASS_IMPLEMENT( weapon_physgun, C_WeaponGravityGun );

IMPLEMENT_CLIENTCLASS_DT( C_WeaponGravityGun, DT_WeaponGravityGun, CWeaponGravityGun )
RecvPropVector( RECVINFO_NAME( m_beam.m_targetPosition, m_targetPosition ) ),
RecvPropVector( RECVINFO_NAME( m_beam.m_worldPosition, m_worldPosition ) ),
RecvPropInt( RECVINFO_NAME( m_beam.m_active, m_active ) ),
RecvPropInt( RECVINFO_NAME( m_beam.m_glueTouching, m_glueTouching ) ),
END_RECV_TABLE()

C_BeamQuadratic::C_BeamQuadratic()
{
m_pOwner = NULL;
}

void C_BeamQuadratic::Update( C_BaseEntity *pOwner )
{
m_pOwner = pOwner;
if ( m_active )
{
if ( m_hRenderHandle == INVALID_CLIENT_RENDER_HANDLE )
{
ClientLeafSystem()->AddRenderable( this, RENDER_GROUP_TRANSLUCENT_ENTITY );
}
else
{
ClientLeafSystem()->RenderableChanged( m_hRenderHandle );
}
}
else if ( !m_active && m_hRenderHandle != INVALID_CLIENT_RENDER_HANDLE )
{
ClientLeafSystem()->RemoveRenderable( m_hRenderHandle );
}
}


int C_BeamQuadratic::DrawModel( int )
{
Vector points[3];
QAngle tmpAngle;

if ( !m_active )
return 0;

C_JBMod_Player *pOwner = ToJBModPlayer( m_pOwner->GetOwnerEntity() );
C_BaseEntity *pEnt = pOwner->GetRenderedWeaponModel();
if ( !pEnt )
return 0;
pEnt->GetAttachment( 1, points[0], tmpAngle );

points[1] = 0.5 * ( m_targetPosition + points[0] );

// a little noise 11t & 13t should be somewhat non-periodic looking
//points[1].z += 4*sin( gpGlobals->curtime*11 ) + 5*cos( gpGlobals->curtime*13 );
points[2] = m_worldPosition;

IMaterial *pMat = materials->FindMaterial( "sprites/physbeam", TEXTURE_GROUP_CLIENT_EFFECTS );
Vector color;
if ( m_glueTouching )
{
color.Init( 1, 0, 0 );
}
else
{
color.Init( 1, 1, 1 );
}

float scrollOffset = gpGlobals->curtime - (int)gpGlobals->curtime;
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->Bind( pMat );
DrawBeamQuadratic( points[0], points[1], points[2], 13, color, scrollOffset );
return 1;
}

const matrix3x4_t &C_BeamQuadratic::RenderableToWorldTransform()
{
static matrix3x4_t mat;
AngleMatrix( GetRenderAngles(), GetRenderOrigin(), mat );
return mat;
}
Loading
Loading