#include "extdll.h" #include "decals.h" #include "util.h" #include "cbase.h" #include "monsters.h" #include "weapons.h" #include "nodes.h" #include "player.h" #include "soundent.h" #include "shake.h" #include "gamerules.h" #define WEAPON_SHORT 16 #define SHORT_SLOT 1 #define SHORT_POSITION 0 #define SHORT_WEIGHT 20 #define WEAPON_EXPAND 17 #define EXPAND_SLOT 2 #define EXPAND_POSITION 0 #define EXPAND_WEIGHT 20 #define SHORT_MODEL_1STPERSON "models/v_9mmhandgun.mdl" //models/v_9mmhandgun.mdl #define SHORT_MODEL_3RDPERSON "models/p_9mmhandgun.mdl" //models/p_9mmhandgun.mdl #define SHORT_MODEL_WORLD "models/w_battery.mdl" #define SHORT_SOUND_SHOOT "weapons/electro5.wav" #define SHORT_SOUND_VOLUME 0.25 #define SHORT_FIRE_DELAY 0.5 // For comparison, glock's is 0.2 #define EXPAND_MODEL_1STPERSON "models/v_9mmhandgun.mdl" #define EXPAND_MODEL_3RDPERSON "models/p_9mmhandgun.mdl" #define EXPAND_MODEL_WORLD "models/w_battery.mdl" #define EXPAND_SOUND_SHOOT "weapons/electro5.wav" #define EXPAND_SOUND_VOLUME 0.40 #define EXPAND_FIRE_DELAY 0.5 #define LONG_SOUND_SHOOT "weapons/electro5.wav" #define LONG_SOUND_VOLUME 0.30 #define LONG_FIRE_DELAY 0.5 // For comparison, glock's is 0.2 #define SHORT_DAMAGE 10 #define SHORT_BEAM_RED 0 #define SHORT_BEAM_GREEN 0 #define SHORT_BEAM_BLUE 255 #define SHORT_BEAM_WIDTH 4 #define SHORT_BEAM_SPRITE "sprites/smoke.spr" #define SHORT_BEAM_BRIGHTNESS 255 // Full. #define SHORT_RANGE 8192 // Really long range. #define SHORT_OFFSET_FORWARD 0 #define SHORT_OFFSET_RIGHT 0 #define SHORT_OFFSET_UP 0 #define SHORT_BEAM_LENGTH 8 #define SHORT_BEAM_SPEED 2000 #define LONG_DAMAGE 20 #define LONG_BEAM_RED 0 #define LONG_BEAM_GREEN 255 #define LONG_BEAM_BLUE 0 #define LONG_BEAM_WIDTH 4 #define LONG_BEAM_SPRITE "sprites/smoke.spr" #define LONG_BEAM_BRIGHTNESS 255 // Full. #define LONG_RANGE 8192 // Really long range. #define LONG_OFFSET_FORWARD 0 #define LONG_OFFSET_RIGHT 0 #define LONG_OFFSET_UP 0 #define LONG_BEAM_LENGTH 8 #define LONG_BEAM_SPEED 2000 #define EXPAND_DAMAGE 40 #define EXPAND_BEAM_RED 255 #define EXPAND_BEAM_GREEN 0 #define EXPAND_BEAM_BLUE 0 #define EXPAND_BEAM_WIDTH 4 #define EXPAND_BEAM_SPRITE "sprites/smoke.spr" #define EXPAND_BEAM_BRIGHTNESS 255 #define EXPAND_RANGE 8192 #define EXPAND_OFFSET_FORWARD 0 #define EXPAND_OFFSET_RIGHT 0 #define EXPAND_OFFSET_UP 0 #define EXPAND_BEAM_LENGTH 8 #define EXPAND_BEAM_SPEED 2000 enum Short_Animations { SHORT_ANIM_IDLE1 = 0, SHORT_ANIM_IDLE2, SHORT_ANIM_IDLE3, SHORT_ANIM_SHOOT, SHORT_ANIM_SHOOT_EMPTY, SHORT_ANIM_RELOAD, SHORT_ANIM_RELOAD_NOT_EMPTY, SHORT_ANIM_DRAW, SHORT_ANIM_HOLSTER, SHORT_ANIM_ADD_SILENCER }; enum Expand_Animations { EXPAND_ANIM_IDLE1 = 0, EXPAND_ANIM_IDLE2, EXPAND_ANIM_IDLE3, EXPAND_ANIM_SHOOT, EXPAND_ANIM_SHOOT_EMPTY, EXPAND_ANIM_RELOAD, EXPAND_ANIM_RELOAD_NOT_EMPTY, EXPAND_ANIM_DRAW, EXPAND_ANIM_HOLSTER, EXPAND_ANIM_ADD_SILENCER }; class CWeaponShort : public CBasePlayerWeapon { public: int BeamSprite; void Spawn( ); void Precache( ); int iItemSlot( ) { return SHORT_SLOT + 1; } int GetItemInfo( ItemInfo* ); BOOL Deploy( ); void PrimaryAttack( ); void SecondaryAttack( ); void WeaponIdle( ); }; LINK_ENTITY_TO_CLASS( weapon_short, CWeaponShort ); class CWeaponExpand : public CBasePlayerWeapon { public: int BeamSprite; void Spawn( ); void Precache( ); int iItemSlot( ) { return EXPAND_SLOT + 1; } int GetItemInfo( ItemInfo* ); BOOL Deploy( ); void PrimaryAttack( ); void SecondaryAttack( ); void WeaponIdle( ); }; LINK_ENTITY_TO_CLASS( weapon_expand, CWeaponExpand ); class CShortBeam : public CGrenade { public: void Spawn( ); void Precache( ); void Move( ); void EXPORT Hit( CBaseEntity* ); void Explode( TraceResult*, int ); static CShortBeam* Create( Vector, Vector, CBaseEntity* ); int BeamSprite; }; class CLongBeam : public CGrenade { public: void Spawn( ); void Precache( ); void Move( ); void EXPORT Hit( CBaseEntity* ); void Explode( TraceResult*, int ); BOOL IsLong() {return TRUE;} static CLongBeam* Create( Vector, Vector, CBaseEntity* ); int BeamSprite; }; class CExpandBeam : public CGrenade { public: void Spawn( ); void Precache( ); void Move( ); void EXPORT Hit( CBaseEntity* ); void Explode(TraceResult*, int ); BOOL IsExpand() {return TRUE;} static CExpandBeam* Create( Vector, Vector, CBaseEntity* ); int BeamSprite; }; void CWeaponShort :: Spawn( ) { pev->classname = MAKE_STRING( "weapon_short" ); Precache( ); m_iId = WEAPON_SHORT; SET_MODEL( ENT(pev), SHORT_MODEL_WORLD ); FallInit( ); } void CWeaponExpand :: Spawn( ) { pev->classname = MAKE_STRING( "weapon_expand" ); Precache( ); m_iId = WEAPON_EXPAND; SET_MODEL( ENT(pev), EXPAND_MODEL_WORLD ); FallInit( ); } void CWeaponShort :: Precache( ) { PRECACHE_MODEL( SHORT_MODEL_1STPERSON ); PRECACHE_MODEL( SHORT_MODEL_3RDPERSON ); PRECACHE_MODEL( SHORT_MODEL_WORLD ); PRECACHE_SOUND( SHORT_SOUND_SHOOT ); BeamSprite = PRECACHE_MODEL( SHORT_BEAM_SPRITE ); } void CWeaponExpand :: Precache( ) { PRECACHE_MODEL( EXPAND_MODEL_1STPERSON ); PRECACHE_MODEL( EXPAND_MODEL_3RDPERSON ); PRECACHE_MODEL( EXPAND_MODEL_WORLD ); PRECACHE_SOUND( EXPAND_SOUND_SHOOT ); BeamSprite = PRECACHE_MODEL( EXPAND_BEAM_SPRITE ); } int CWeaponShort :: GetItemInfo( ItemInfo* Info ) { Info->pszName = STRING( pev->classname ); Info->pszAmmo1 = NULL; Info->iMaxAmmo1 = -1; Info->pszAmmo2 = NULL; Info->iMaxAmmo2 = -1; Info->iMaxClip = WEAPON_NOCLIP; Info->iSlot = SHORT_SLOT; Info->iPosition = SHORT_POSITION; Info->iFlags = 0; Info->iId = m_iId = WEAPON_SHORT; Info->iWeight = SHORT_WEIGHT; return 1; } int CWeaponExpand :: GetItemInfo( ItemInfo* Info ) { Info->pszName = STRING( pev->classname ); Info->pszAmmo1 = NULL; Info->iMaxAmmo1 = -1; Info->pszAmmo2 = NULL; Info->iMaxAmmo2 = -1; Info->iMaxClip = WEAPON_NOCLIP; Info->iSlot = EXPAND_SLOT; Info->iPosition = EXPAND_POSITION; Info->iFlags = 0; Info->iId = m_iId = WEAPON_EXPAND; Info->iWeight = EXPAND_WEIGHT; return 1; } BOOL CWeaponShort :: Deploy( ) { return DefaultDeploy( "", //SHORT_MODEL_1STPERSON "", //SHORT_MODEL_3RDPERSON SHORT_ANIM_DRAW, "" ); //onehanded or squeak work here } BOOL CWeaponExpand :: Deploy( ) { return DefaultDeploy( "", "", EXPAND_ANIM_DRAW, "" ); } void CWeaponShort :: PrimaryAttack( ) { // m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); // SendWeaponAnim( SHORT_ANIM_SHOOT ); EMIT_SOUND_DYN( ENT(m_pPlayer->pev), // Entity sound originates from CHAN_WEAPON, // Channel SHORT_SOUND_SHOOT, // Sound to play SHORT_SOUND_VOLUME, // Volume (0.0 to 1.0) ATTN_NORM, // Attenuation, whatever the hell that is 0, // Flags 150 ); // Pitch m_flNextPrimaryAttack = gpGlobals->time + SHORT_FIRE_DELAY; m_flNextSecondaryAttack = gpGlobals->time + LONG_FIRE_DELAY; m_flTimeWeaponIdle = gpGlobals->time + SHORT_FIRE_DELAY; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector GunPosition = m_pPlayer->GetGunPosition( ); GunPosition = GunPosition + gpGlobals->v_forward * SHORT_OFFSET_FORWARD; GunPosition = GunPosition + gpGlobals->v_right * SHORT_OFFSET_RIGHT; GunPosition = GunPosition + gpGlobals->v_up * SHORT_OFFSET_UP; CShortBeam* Beam = CShortBeam :: Create( GunPosition, m_pPlayer->pev->v_angle, m_pPlayer ); } void CWeaponExpand :: PrimaryAttack( ) { // m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); // SendWeaponAnim( EXPAND_ANIM_SHOOT ); EMIT_SOUND_DYN( ENT(m_pPlayer->pev), // Entity sound originates from CHAN_WEAPON, // Channel EXPAND_SOUND_SHOOT, // Sound to play EXPAND_SOUND_VOLUME, // Volume (0.0 to 1.0) ATTN_NORM, // Attenuation, whatever the hell that is 0, // Flags 150 ); // Pitch m_flNextPrimaryAttack = gpGlobals->time + EXPAND_FIRE_DELAY; m_flTimeWeaponIdle = gpGlobals->time + EXPAND_FIRE_DELAY; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector GunPosition = m_pPlayer->GetGunPosition( ); GunPosition = GunPosition + gpGlobals->v_forward * EXPAND_OFFSET_FORWARD; GunPosition = GunPosition + gpGlobals->v_right * EXPAND_OFFSET_RIGHT; GunPosition = GunPosition + gpGlobals->v_up * EXPAND_OFFSET_UP; CExpandBeam* Beam = CExpandBeam :: Create( GunPosition, m_pPlayer->pev->v_angle, m_pPlayer ); } void CWeaponExpand :: SecondaryAttack( ) //use this to unwedge self from solid objects { m_pPlayer->pev->origin.z += 100; m_flNextSecondaryAttack = gpGlobals->time + 10; } void CWeaponShort :: SecondaryAttack( ) { // m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); // SendWeaponAnim( SHORT_ANIM_SHOOT ); EMIT_SOUND_DYN( ENT(m_pPlayer->pev), // Entity sound originates from CHAN_WEAPON, // Channel LONG_SOUND_SHOOT, // Sound to play LONG_SOUND_VOLUME, // Volume (0.0 to 1.0) ATTN_NORM, // Attenuation, whatever the hell that is 0, // Flags 150 ); // Pitch m_flNextPrimaryAttack = gpGlobals->time + SHORT_FIRE_DELAY; m_flNextSecondaryAttack = gpGlobals->time + LONG_FIRE_DELAY; m_flTimeWeaponIdle = gpGlobals->time + LONG_FIRE_DELAY; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector GunPosition = m_pPlayer->GetGunPosition( ); GunPosition = GunPosition + gpGlobals->v_forward * SHORT_OFFSET_FORWARD; GunPosition = GunPosition + gpGlobals->v_right * SHORT_OFFSET_RIGHT; GunPosition = GunPosition + gpGlobals->v_up * SHORT_OFFSET_UP; CLongBeam* Beam = CLongBeam :: Create( GunPosition, m_pPlayer->pev->v_angle, m_pPlayer ); } void CWeaponShort :: WeaponIdle( ) { // if( m_flTimeWeaponIdle > gpGlobals->time ) return; // m_flTimeWeaponIdle = gpGlobals->time + 3.0; // SendWeaponAnim( SHORT_ANIM_IDLE1 ); } void CWeaponExpand :: WeaponIdle( ) { // if( m_flTimeWeaponIdle > gpGlobals->time ) return; // m_flTimeWeaponIdle = gpGlobals->time + 3.0; // SendWeaponAnim( EXPAND_ANIM_IDLE1 ); } void CShortBeam :: Spawn( ) { Precache( ); SET_MODEL( ENT(pev), "models/rpgrocket.mdl" ); pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; pev->rendermode = kRenderTransTexture; pev->renderamt = 0; UTIL_SetSize( pev, Vector(-0.1,-0.1,-0.1), Vector(0.1,0.1,0.1) ); UTIL_SetOrigin( pev, pev->origin ); pev->classname = MAKE_STRING( "proj_short" ); SetThink( Move ); SetTouch( Hit ); pev->angles.x -= 30; pev->velocity = gpGlobals->v_forward * SHORT_BEAM_SPEED; pev->angles.x = -(pev->angles.x + 30); pev->gravity = 0; pev->nextthink = gpGlobals->time + 0.01; pev->dmg = SHORT_DAMAGE; } void CLongBeam :: Spawn( ) { Precache( ); SET_MODEL( ENT(pev), "models/rpgrocket.mdl" ); pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; pev->rendermode = kRenderTransTexture; pev->renderamt = 0; UTIL_SetSize( pev, Vector(0,0,0), Vector(0,0,0) ); UTIL_SetOrigin( pev, pev->origin ); pev->classname = MAKE_STRING( "proj_long" ); SetThink( Move ); SetTouch( Hit ); pev->angles.x -= 30; pev->velocity = gpGlobals->v_forward * LONG_BEAM_SPEED; pev->angles.x = -(pev->angles.x + 30); pev->gravity = 0; pev->nextthink = gpGlobals->time + 0.01; pev->dmg = LONG_DAMAGE; } void CExpandBeam :: Spawn( ) { Precache( ); SET_MODEL( ENT(pev), "models/rpgrocket.mdl" ); pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; pev->rendermode = kRenderTransTexture; pev->renderamt = 0; UTIL_SetSize( pev, Vector(0,0,0), Vector(0,0,0) ); UTIL_SetOrigin( pev, pev->origin ); pev->classname = MAKE_STRING( "proj_expand" ); SetThink( Move ); SetTouch( Hit ); pev->angles.x -= 30; pev->velocity = gpGlobals->v_forward * EXPAND_BEAM_SPEED; pev->angles.x = -(pev->angles.x + 30); pev->gravity = 0; pev->nextthink = gpGlobals->time + 0.01; pev->dmg = EXPAND_DAMAGE; } void CShortBeam :: Precache( ) { BeamSprite = PRECACHE_MODEL( SHORT_BEAM_SPRITE ); PRECACHE_MODEL( "models/rpgrocket.mdl" ); } void CLongBeam :: Precache( ) { BeamSprite = PRECACHE_MODEL( SHORT_BEAM_SPRITE ); PRECACHE_MODEL( "models/rpgrocket.mdl" ); } void CExpandBeam :: Precache( ) { BeamSprite = PRECACHE_MODEL( EXPAND_BEAM_SPRITE ); PRECACHE_MODEL( "models/rpgrocket.mdl" ); } void CShortBeam :: Hit( CBaseEntity* Target ) { TraceResult TResult; Vector StartPosition; Target->Touch(this); pev->enemy = Target->edict( ); StartPosition = pev->origin - pev->velocity.Normalize( ) * 32; UTIL_TraceLine( StartPosition, StartPosition + pev->velocity.Normalize() * 64, dont_ignore_monsters, ENT( pev ), &TResult ); Explode( &TResult, DMG_BLAST ); } void CLongBeam :: Hit( CBaseEntity* Target ) { TraceResult TResult; Vector StartPosition; Target->Touch(this); pev->enemy = Target->edict( ); StartPosition = pev->origin - pev->velocity.Normalize( ) * 32; UTIL_TraceLine( StartPosition, StartPosition + pev->velocity.Normalize() * 64, dont_ignore_monsters, ENT( pev ), &TResult ); Explode( &TResult, DMG_BLAST ); } void CExpandBeam :: Hit( CBaseEntity* Target ) { TraceResult TResult; Vector StartPosition; Target->Touch(this); pev->enemy = Target->edict( ); StartPosition = pev->origin - pev->velocity.Normalize( ) * 32; UTIL_TraceLine( StartPosition, StartPosition + pev->velocity.Normalize() * 64, dont_ignore_monsters, ENT( pev ), &TResult ); Explode( &TResult, DMG_BLAST ); } void CShortBeam :: Explode( TraceResult* TResult, int DamageType ) { /* RadiusDamage( pev, VARS( pev->owner ), pev->dmg, CLASS_NONE, DamageType ); */ if( TResult->fAllSolid ) return; UTIL_DecalTrace( TResult, DECAL_GUNSHOT1 ); SUB_Remove( ); // Delete the beam. } void CLongBeam :: Explode( TraceResult* TResult, int DamageType ) { /* RadiusDamage( pev, VARS( pev->owner ), pev->dmg, CLASS_NONE, DamageType ); */ if( TResult->fAllSolid ) return; UTIL_DecalTrace( TResult, DECAL_GUNSHOT1 ); SUB_Remove( ); // Delete the beam. } void CExpandBeam :: Explode( TraceResult* TResult, int DamageType ) { /* RadiusDamage( pev, VARS( pev->owner ), pev->dmg, CLASS_NONE, DamageType ); */ if( TResult->fAllSolid ) return; UTIL_DecalTrace( TResult, DECAL_GUNSHOT1 ); SUB_Remove( ); // Delete the beam. } CShortBeam* CShortBeam :: Create( Vector Pos, Vector Aim, CBaseEntity* Owner ) { CShortBeam* Beam = GetClassPtr( (CShortBeam*)NULL ); UTIL_SetOrigin( Beam->pev, Pos ); Beam->pev->angles = Aim; Beam->Spawn( ); Beam->SetTouch( CShortBeam :: Hit ); Beam->pev->owner = Owner->edict( ); return Beam; } CLongBeam* CLongBeam :: Create( Vector Pos, Vector Aim, CBaseEntity* Owner ) { CLongBeam* Beam = GetClassPtr( (CLongBeam*)NULL ); UTIL_SetOrigin( Beam->pev, Pos ); Beam->pev->angles = Aim; Beam->Spawn( ); Beam->SetTouch( CLongBeam :: Hit ); Beam->pev->owner = Owner->edict( ); return Beam; } CExpandBeam* CExpandBeam :: Create( Vector Pos, Vector Aim, CBaseEntity* Owner ) { CExpandBeam* Beam = GetClassPtr( (CExpandBeam*)NULL ); UTIL_SetOrigin( Beam->pev, Pos ); Beam->pev->angles = Aim; Beam->Spawn( ); Beam->SetTouch( CLongBeam :: Hit ); Beam->pev->owner = Owner->edict( ); return Beam; } void CShortBeam :: Move( ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_SHORT( entindex() ); WRITE_SHORT( BeamSprite ); WRITE_BYTE( SHORT_BEAM_LENGTH ); WRITE_BYTE( SHORT_BEAM_WIDTH ); WRITE_BYTE( SHORT_BEAM_RED ); WRITE_BYTE( SHORT_BEAM_GREEN ); WRITE_BYTE( SHORT_BEAM_BLUE ); WRITE_BYTE( SHORT_BEAM_BRIGHTNESS ); MESSAGE_END( ); } void CLongBeam :: Move( ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_SHORT( entindex() ); WRITE_SHORT( BeamSprite ); WRITE_BYTE( LONG_BEAM_LENGTH ); WRITE_BYTE( LONG_BEAM_WIDTH ); WRITE_BYTE( LONG_BEAM_RED ); WRITE_BYTE( LONG_BEAM_GREEN ); WRITE_BYTE( LONG_BEAM_BLUE ); WRITE_BYTE( LONG_BEAM_BRIGHTNESS ); MESSAGE_END( ); } void CExpandBeam :: Move( ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_SHORT( entindex() ); WRITE_SHORT( BeamSprite ); WRITE_BYTE( EXPAND_BEAM_LENGTH ); WRITE_BYTE( EXPAND_BEAM_WIDTH ); WRITE_BYTE( EXPAND_BEAM_RED ); WRITE_BYTE( EXPAND_BEAM_GREEN ); WRITE_BYTE( EXPAND_BEAM_BLUE ); WRITE_BYTE( EXPAND_BEAM_BRIGHTNESS ); MESSAGE_END( ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 937 | Sam Stafford |
Renaming my guest directory to the more conventional sam_stafford. |
||
//guest/samwise/p4hl/src/dlls/weaponshort.cpp | |||||
#1 | 936 | Sam Stafford |
Adding P4HL to the public depot. See relnotes.txt for installation instructions; all relevant files are under p4hl/dist. Source code is under p4hl/src in the form of a VC++ project. |