mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-04-20 16:32:30 +03:00
Merge branch 'restored-content' into dev
This commit is contained in:
commit
472032b924
74
sp/game/mod_episodic/scripts/weapon_flaregun.txt
Normal file
74
sp/game/mod_episodic/scripts/weapon_flaregun.txt
Normal file
@ -0,0 +1,74 @@
|
||||
// Pistol
|
||||
|
||||
WeaponData
|
||||
{
|
||||
// Weapon data is loaded by both the Game and Client DLLs.
|
||||
"printname" "#HL2_Pistol"
|
||||
"viewmodel" "models/weapons/v_pistol.mdl"
|
||||
"playermodel" "models/weapons/w_pistol.mdl"
|
||||
"anim_prefix" "pistol"
|
||||
"bucket" "1"
|
||||
"bucket_position" "2"
|
||||
"bucket_360" "0"
|
||||
"bucket_position_360" "0"
|
||||
|
||||
"clip_size" "1"
|
||||
"primary_ammo" "Pistol"
|
||||
"secondary_ammo" "None"
|
||||
|
||||
"weight" "2"
|
||||
"rumble" "1"
|
||||
"item_flags" "0"
|
||||
|
||||
// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
|
||||
SoundData
|
||||
{
|
||||
|
||||
"reload" "Weapon_Pistol.Reload"
|
||||
"reload_npc" "Weapon_Pistol.NPC_Reload"
|
||||
"empty" "Weapon_Pistol.Empty"
|
||||
"single_shot" "Weapon_Pistol.Single"
|
||||
"single_shot_npc" "Weapon_Pistol.NPC_Single"
|
||||
"special1" "Weapon_Pistol.Special1"
|
||||
"special2" "Weapon_Pistol.Special2"
|
||||
"burst" "Weapon_Pistol.Burst"
|
||||
}
|
||||
|
||||
// Weapon Sprite data is loaded by the Client DLL.
|
||||
TextureData
|
||||
{
|
||||
"weapon"
|
||||
{
|
||||
"font" "WeaponIcons"
|
||||
"character" "d"
|
||||
}
|
||||
"weapon_s"
|
||||
{
|
||||
"font" "WeaponIconsSelected"
|
||||
"character" "d"
|
||||
}
|
||||
"weapon_small"
|
||||
{
|
||||
"font" "WeaponIconsSmall"
|
||||
"character" "d"
|
||||
}
|
||||
"ammo"
|
||||
{
|
||||
"font" "WeaponIconsSmall"
|
||||
"character" "p"
|
||||
}
|
||||
"crosshair"
|
||||
{
|
||||
"font" "Crosshairs"
|
||||
"character" "Q"
|
||||
}
|
||||
"autoaim"
|
||||
{
|
||||
"file" "sprites/crosshairs"
|
||||
"x" "0"
|
||||
"y" "48"
|
||||
"width" "24"
|
||||
"height" "24"
|
||||
}
|
||||
}
|
||||
}
|
@ -21,4 +21,5 @@ weapon_manifest
|
||||
|
||||
// Custom
|
||||
"file" "scripts/weapon_custommelee.txt"
|
||||
"file" "scripts/weapon_flaregun.txt"
|
||||
}
|
@ -657,6 +657,8 @@ void CFlare::AddToActiveFlares( void )
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
IMPLEMENT_SERVERCLASS_ST(CFlaregun, DT_Flaregun)
|
||||
END_SEND_TABLE()
|
||||
|
||||
@ -748,4 +750,6 @@ void CFlaregun::SecondaryAttack( void )
|
||||
pFlare->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
|
||||
|
||||
WeaponSound( SINGLE );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
323
sp/src/game/server/mod/weapon_custom_flaregun.cpp
Normal file
323
sp/src/game/server/mod/weapon_custom_flaregun.cpp
Normal file
@ -0,0 +1,323 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Flare gun (fffsssssssssss!!)
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
#include "basehlcombatweapon.h"
|
||||
#include "decals.h"
|
||||
#include "soundenvelope.h"
|
||||
#include "IEffects.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "weapon_flaregun.h"
|
||||
#include "props.h"
|
||||
#include "ai_basenpc.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// Custom derived class for flare gun projectiles
|
||||
class CFlareGunProjectile : public CFlare
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS(CFlareGunProjectile, CFlare);
|
||||
static CFlareGunProjectile *Create(Vector vecOrigin, QAngle vecAngles, CBaseEntity *pOwner, float lifetime);
|
||||
void FlareGunProjectileTouch(CBaseEntity *pOther);
|
||||
|
||||
};
|
||||
|
||||
/********************************************************************
|
||||
NOTE: if you are looking at this file becase you would like flares
|
||||
to be considered as fires (and thereby trigger gas traps), be aware
|
||||
that the env_flare class is actually found in weapon_flaregun.cpp
|
||||
and is really a repurposed piece of ammunition. (env_flare isn't the
|
||||
rod-like safety flare prop, but rather the bit of flame on the end.)
|
||||
|
||||
You will have some difficulty making it work here, because CFlare
|
||||
does not inherit from CFire and will thus not be enumerated by
|
||||
CFireSphere::EnumElement(). In order to have flares be detected and
|
||||
used by this system, you will need to promote certain member functions
|
||||
of CFire into an interface class from which both CFire and CFlare
|
||||
inherit. You will also need to modify CFireSphere::EnumElement so that
|
||||
it properly disambiguates between fires and flares.
|
||||
|
||||
For some partial work towards this end, see changelist 192474.
|
||||
|
||||
********************************************************************/
|
||||
|
||||
|
||||
#define FLARE_LAUNCH_SPEED 1500
|
||||
|
||||
IMPLEMENT_SERVERCLASS_ST(CFlaregun, DT_Flaregun)
|
||||
END_SEND_TABLE()
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_flaregun, CFlaregun );
|
||||
PRECACHE_WEAPON_REGISTER( weapon_flaregun );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Precache
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFlaregun::Precache( void )
|
||||
{
|
||||
BaseClass::Precache();
|
||||
|
||||
PrecacheScriptSound( "Flare.Touch" );
|
||||
|
||||
PrecacheScriptSound( "Weapon_FlareGun.Burn" );
|
||||
|
||||
UTIL_PrecacheOther( "env_flare" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Main attack
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFlaregun::PrimaryAttack( void )
|
||||
{
|
||||
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
|
||||
|
||||
if ( pOwner == NULL )
|
||||
return;
|
||||
|
||||
if ( m_iClip1 <= 0 )
|
||||
{
|
||||
SendWeaponAnim( ACT_VM_DRYFIRE );
|
||||
pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration();
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip1 = m_iClip1 - 1;
|
||||
|
||||
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
|
||||
pOwner->m_flNextAttack = gpGlobals->curtime + 1;
|
||||
|
||||
CFlare *pFlare = CFlareGunProjectile::Create( pOwner->Weapon_ShootPosition(), pOwner->EyeAngles(), pOwner, FLARE_DURATION );
|
||||
|
||||
|
||||
if ( pFlare == NULL )
|
||||
return;
|
||||
|
||||
Vector forward;
|
||||
pOwner->EyeVectors( &forward );
|
||||
|
||||
pFlare->SetAbsVelocity( forward * 1500 );
|
||||
pFlare->SetGravity(1.0f);
|
||||
pFlare->SetFriction(0.85f);
|
||||
pFlare->SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
|
||||
|
||||
WeaponSound( SINGLE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFlaregun::SecondaryAttack( void )
|
||||
{
|
||||
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
|
||||
|
||||
if ( pOwner == NULL )
|
||||
return;
|
||||
|
||||
if ( m_iClip1 <= 0 )
|
||||
{
|
||||
SendWeaponAnim( ACT_VM_DRYFIRE );
|
||||
pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration();
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip1 = m_iClip1 - 1;
|
||||
|
||||
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
|
||||
pOwner->m_flNextAttack = gpGlobals->curtime + 1;
|
||||
|
||||
CFlare *pFlare = CFlareGunProjectile::Create( pOwner->Weapon_ShootPosition(), pOwner->EyeAngles(), pOwner, FLARE_DURATION );
|
||||
|
||||
if ( pFlare == NULL )
|
||||
return;
|
||||
|
||||
Vector forward;
|
||||
pOwner->EyeVectors( &forward );
|
||||
|
||||
pFlare->SetAbsVelocity( forward * 500 );
|
||||
pFlare->SetGravity(1.0f);
|
||||
pFlare->SetFriction( 0.85f );
|
||||
pFlare->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
|
||||
|
||||
WeaponSound( SINGLE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Create function for Flare Gun projectile
|
||||
// Input : vecOrigin -
|
||||
// vecAngles -
|
||||
// *pOwner -
|
||||
// Output : CFlare
|
||||
//-----------------------------------------------------------------------------
|
||||
CFlareGunProjectile *CFlareGunProjectile::Create(Vector vecOrigin, QAngle vecAngles, CBaseEntity *pOwner, float lifetime)
|
||||
{
|
||||
CFlareGunProjectile *pFlare = (CFlareGunProjectile *)CreateEntityByName("env_flare");
|
||||
|
||||
if (pFlare == NULL)
|
||||
return NULL;
|
||||
|
||||
UTIL_SetOrigin(pFlare, vecOrigin);
|
||||
|
||||
pFlare->SetLocalAngles(vecAngles);
|
||||
pFlare->Spawn();
|
||||
pFlare->SetTouch(&CFlareGunProjectile::FlareGunProjectileTouch);
|
||||
pFlare->SetThink(&CFlare::FlareThink);
|
||||
|
||||
//Start up the flare
|
||||
pFlare->Start(lifetime);
|
||||
|
||||
//Don't start sparking immediately
|
||||
pFlare->SetNextThink(gpGlobals->curtime + 0.5f);
|
||||
|
||||
//Burn out time
|
||||
pFlare->m_flTimeBurnOut = gpGlobals->curtime + lifetime;
|
||||
|
||||
pFlare->RemoveSolidFlags(FSOLID_NOT_SOLID);
|
||||
pFlare->AddSolidFlags(FSOLID_NOT_STANDABLE);
|
||||
|
||||
pFlare->SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
|
||||
|
||||
pFlare->SetOwnerEntity(pOwner);
|
||||
pFlare->m_pOwner = pOwner;
|
||||
|
||||
return pFlare;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Touch function for flaregun projectiles
|
||||
// Input : *pOther - The entity that the flare has collided with
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFlareGunProjectile::FlareGunProjectileTouch(CBaseEntity *pOther)
|
||||
{
|
||||
Assert(pOther);
|
||||
if (!pOther->IsSolid())
|
||||
return;
|
||||
|
||||
if ((m_nBounces < 10) && (GetWaterLevel() < 1))
|
||||
{
|
||||
// Throw some real chunks here
|
||||
g_pEffects->Sparks(GetAbsOrigin());
|
||||
}
|
||||
|
||||
//If the flare hit a person or NPC, do damage here.
|
||||
if (pOther && pOther->m_takedamage)
|
||||
{
|
||||
Vector vecNewVelocity = GetAbsVelocity();
|
||||
vecNewVelocity *= 0.1f;
|
||||
SetAbsVelocity(vecNewVelocity);
|
||||
|
||||
SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
|
||||
SetGravity(1.0f);
|
||||
|
||||
Die(0.5);
|
||||
|
||||
// Don't burn the player
|
||||
if (pOther->IsPlayer())
|
||||
return;
|
||||
|
||||
// Don't burn friendly NPCs
|
||||
CAI_BaseNPC *pNPC;
|
||||
pNPC = dynamic_cast<CAI_BaseNPC*>(pOther);
|
||||
if (pNPC && pNPC->IsPlayerAlly())
|
||||
return;
|
||||
|
||||
// If this is an ignitable entity that isn't the player or an ally, ignite it!
|
||||
CBaseAnimating *pAnim;
|
||||
pAnim = dynamic_cast<CBaseAnimating*>(pOther);
|
||||
if (pAnim)
|
||||
pAnim->IgniteLifetime(30.0f);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// hit the world, check the material type here, see if the flare should stick.
|
||||
trace_t tr;
|
||||
tr = CBaseEntity::GetTouchTrace();
|
||||
|
||||
//Only do this on the first bounce
|
||||
if (m_nBounces == 0)
|
||||
{
|
||||
const surfacedata_t *pdata = physprops->GetSurfaceData(tr.surface.surfaceProps);
|
||||
|
||||
if (pdata != NULL)
|
||||
{
|
||||
//Only embed into concrete and wood (jdw: too obscure for players?)
|
||||
//if ( ( pdata->gameMaterial == 'C' ) || ( pdata->gameMaterial == 'W' ) )
|
||||
{
|
||||
Vector impactDir = (tr.endpos - tr.startpos);
|
||||
VectorNormalize(impactDir);
|
||||
|
||||
float surfDot = tr.plane.normal.Dot(impactDir);
|
||||
|
||||
//Do not stick to ceilings or on shallow impacts
|
||||
if ((tr.plane.normal.z > -0.5f) && (surfDot < -0.9f))
|
||||
{
|
||||
RemoveSolidFlags(FSOLID_NOT_SOLID);
|
||||
AddSolidFlags(FSOLID_TRIGGER);
|
||||
UTIL_SetOrigin(this, tr.endpos + (tr.plane.normal * 2.0f));
|
||||
SetAbsVelocity(vec3_origin);
|
||||
SetMoveType(MOVETYPE_NONE);
|
||||
|
||||
SetTouch(&CFlare::FlareBurnTouch);
|
||||
|
||||
int index = decalsystem->GetDecalIndexForName("SmallScorch");
|
||||
if (index >= 0)
|
||||
{
|
||||
CBroadcastRecipientFilter filter;
|
||||
te->Decal(filter, 0.0, &tr.endpos, &tr.startpos, ENTINDEX(tr.m_pEnt), tr.hitbox, index);
|
||||
}
|
||||
|
||||
CPASAttenuationFilter filter2(this, "Flare.Touch");
|
||||
EmitSound(filter2, entindex(), "Flare.Touch");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Scorch decal
|
||||
if (GetAbsVelocity().LengthSqr() > (250 * 250))
|
||||
{
|
||||
int index = decalsystem->GetDecalIndexForName("FadingScorch");
|
||||
if (index >= 0)
|
||||
{
|
||||
CBroadcastRecipientFilter filter;
|
||||
te->Decal(filter, 0.0, &tr.endpos, &tr.startpos, ENTINDEX(tr.m_pEnt), tr.hitbox, index);
|
||||
}
|
||||
}
|
||||
|
||||
// Change our flight characteristics
|
||||
SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
|
||||
SetGravity(UTIL_ScaleForGravity(640));
|
||||
|
||||
m_nBounces++;
|
||||
|
||||
//After the first bounce, smacking into whoever fired the flare is fair game
|
||||
SetOwnerEntity(this);
|
||||
|
||||
// Slow down
|
||||
Vector vecNewVelocity = GetAbsVelocity();
|
||||
vecNewVelocity.x *= 0.8f;
|
||||
vecNewVelocity.y *= 0.8f;
|
||||
SetAbsVelocity(vecNewVelocity);
|
||||
|
||||
//Stopped?
|
||||
if (GetAbsVelocity().Length() < 64.0f)
|
||||
{
|
||||
SetAbsVelocity(vec3_origin);
|
||||
SetMoveType(MOVETYPE_NONE);
|
||||
RemoveSolidFlags(FSOLID_NOT_SOLID);
|
||||
AddSolidFlags(FSOLID_TRIGGER);
|
||||
}
|
||||
}
|
||||
}
|
@ -58,7 +58,9 @@ $Project "Server (Episodic)"
|
||||
$File "mod\npc_shadow_walker.h"
|
||||
$File "mod\npc_shadow_walker.cpp"
|
||||
$File "mod\weapon_custom_melee.h"
|
||||
} $File "$SRCDIR\game\shared\episodic\achievements_ep1.cpp"
|
||||
$File "mod\weapon_custom_flaregun.cpp"
|
||||
}
|
||||
$File "$SRCDIR\game\shared\episodic\achievements_ep1.cpp"
|
||||
$File "$SRCDIR\game\shared\episodic\achievements_ep2.cpp"
|
||||
$File "$SRCDIR\game\shared\episodic\achievements_epx.cpp"
|
||||
$File "hl2\ai_allymanager.cpp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user