Night Owl
8 years ago
40 changed files with 1387 additions and 230 deletions
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* This source code contains proprietary and confidential information of |
||||
* Valve LLC and its suppliers. Access to this code is restricted to |
||||
* persons who have executed a written SDK license with Valve. Any access, |
||||
* use or distribution of this code by or to any unlicensed person is illegal. |
||||
* |
||||
****/ |
||||
|
||||
#ifndef HGRUNT_H |
||||
#define HGRUNT_H |
||||
|
||||
class CHGrunt : public CSquadMonster |
||||
{ |
||||
public: |
||||
virtual void Spawn(void); |
||||
virtual void Precache(void); |
||||
void SetYawSpeed(void); |
||||
int Classify(void); |
||||
int ISoundMask(void); |
||||
void HandleAnimEvent(MonsterEvent_t *pEvent); |
||||
BOOL FCanCheckAttacks(void); |
||||
BOOL CheckMeleeAttack1(float flDot, float flDist); |
||||
BOOL CheckRangeAttack1(float flDot, float flDist); |
||||
BOOL CheckRangeAttack2(float flDot, float flDist); |
||||
void CheckAmmo(void); |
||||
void SetActivity(Activity NewActivity); |
||||
void StartTask(Task_t *pTask); |
||||
void RunTask(Task_t *pTask); |
||||
void DeathSound(void); |
||||
void PainSound(void); |
||||
void IdleSound(void); |
||||
Vector GetGunPosition(void); |
||||
void Shoot(void); |
||||
void Shotgun(void); |
||||
void PrescheduleThink(void); |
||||
void GibMonster(void); |
||||
void SpeakSentence(void); |
||||
|
||||
int Save(CSave &save); |
||||
int Restore(CRestore &restore); |
||||
|
||||
CBaseEntity *Kick(void); |
||||
Schedule_t *GetSchedule(void); |
||||
Schedule_t *GetScheduleOfType(int Type); |
||||
void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); |
||||
int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); |
||||
|
||||
int IRelationship(CBaseEntity *pTarget); |
||||
|
||||
virtual BOOL FOkToSpeak(void); |
||||
void JustSpoke(void); |
||||
|
||||
CUSTOM_SCHEDULES; |
||||
static TYPEDESCRIPTION m_SaveData[]; |
||||
|
||||
// checking the feasibility of a grenade toss is kind of costly, so we do it every couple of seconds,
|
||||
// not every server frame.
|
||||
float m_flNextGrenadeCheck; |
||||
float m_flNextPainTime; |
||||
float m_flLastEnemySightTime; |
||||
|
||||
Vector m_vecTossVelocity; |
||||
|
||||
BOOL m_fThrowGrenade; |
||||
BOOL m_fStanding; |
||||
BOOL m_fFirstEncounter;// only put on the handsign show in the squad's first encounter.
|
||||
int m_cClipSize; |
||||
|
||||
int m_voicePitch; |
||||
|
||||
int m_iBrassShell; |
||||
int m_iShotgunShell; |
||||
|
||||
int m_iSentence; |
||||
|
||||
static const char *pGruntSentences[]; |
||||
}; |
||||
|
||||
#endif // HGRUNT_H
|
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* Use, distribution, and modification of this source code and/or resulting |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "weapons.h" |
||||
#include "player.h" |
||||
#include "skill.h" |
||||
#include "items.h" |
||||
#include "gamerules.h" |
||||
|
||||
class CItemFlashlight : public CItem |
||||
{ |
||||
void Spawn(void) |
||||
{ |
||||
Precache(); |
||||
SET_MODEL(ENT(pev), "models/w_flashlight.mdl"); |
||||
CItem::Spawn(); |
||||
} |
||||
void Precache(void) |
||||
{ |
||||
PRECACHE_MODEL("models/w_flashlight.mdl"); |
||||
PRECACHE_SOUND("items/gunpickup2.wav"); |
||||
} |
||||
BOOL MyTouch(CBasePlayer *pPlayer) |
||||
{ |
||||
if (pPlayer->pev->weapons & (1 << WEAPON_FLASHLIGHT)) |
||||
return FALSE; |
||||
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM); |
||||
|
||||
pPlayer->pev->weapons |= (1 << WEAPON_FLASHLIGHT); |
||||
return TRUE; |
||||
} |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(item_flashlight, CItemFlashlight); |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* Use, distribution, and modification of this source code and/or resulting |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "weapons.h" |
||||
#include "player.h" |
||||
#include "skill.h" |
||||
#include "items.h" |
||||
#include "gamerules.h" |
||||
|
||||
extern int gmsgItemPickup; |
||||
|
||||
class CItemKevlar : public CItem |
||||
{ |
||||
void Spawn(void) |
||||
{ |
||||
Precache(); |
||||
SET_MODEL(ENT(pev), "models/w_kevlar.mdl"); |
||||
CItem::Spawn(); |
||||
} |
||||
void Precache(void) |
||||
{ |
||||
PRECACHE_MODEL("models/w_kevlar.mdl"); |
||||
PRECACHE_SOUND("player/kevlar_zipper.wav"); |
||||
} |
||||
BOOL MyTouch(CBasePlayer *pPlayer) |
||||
{ |
||||
if (pPlayer->pev->deadflag != DEAD_NO) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
if ((pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY) && |
||||
(pPlayer->pev->weapons & (1 << WEAPON_SUIT))) |
||||
{ |
||||
pPlayer->pev->armorvalue += MAX_NORMAL_BATTERY; |
||||
pPlayer->pev->armorvalue = min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY); |
||||
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "player/kevlar_zipper.wav", 1, ATTN_NORM); |
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); |
||||
WRITE_STRING(STRING(pev->classname)); |
||||
MESSAGE_END(); |
||||
|
||||
return TRUE; |
||||
} |
||||
return FALSE; |
||||
} |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(item_bodyarmour, CItemKevlar); |
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* This source code contains proprietary and confidential information of |
||||
* Valve LLC and its suppliers. Access to this code is restricted to |
||||
* persons who have executed a written SDK license with Valve. Any access, |
||||
* use or distribution of this code by or to any unlicensed person is illegal. |
||||
* |
||||
****/ |
||||
|
||||
#include "extdll.h" |
||||
#include "plane.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "schedule.h" |
||||
#include "animation.h" |
||||
#include "squadmonster.h" |
||||
#include "weapons.h" |
||||
#include "talkmonster.h" |
||||
#include "soundent.h" |
||||
#include "effects.h" |
||||
#include "customentity.h" |
||||
#include "hgrunt.h" |
||||
|
||||
class CMassn : public CHGrunt |
||||
{ |
||||
public: |
||||
void Spawn(void); |
||||
void Precache(void); |
||||
|
||||
BOOL FOkToSpeak(void); |
||||
|
||||
void DeathSound(void); |
||||
void PainSound(void); |
||||
void IdleSound(void); |
||||
|
||||
int IRelationship(CBaseEntity *pTarget); |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(monster_human_massassin, CMassn); |
||||
|
||||
//=========================================================
|
||||
// Spawn
|
||||
//=========================================================
|
||||
void CMassn::Spawn() |
||||
{ |
||||
CHGrunt::Spawn(); |
||||
|
||||
SET_MODEL(ENT(pev), "models/massn.mdl"); |
||||
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); |
||||
|
||||
MonsterInit(); |
||||
} |
||||
|
||||
//=========================================================
|
||||
// Precache - precaches all resources this monster needs
|
||||
//=========================================================
|
||||
void CMassn::Precache() |
||||
{ |
||||
CHGrunt::Precache(); |
||||
|
||||
PRECACHE_MODEL("models/massn.mdl"); |
||||
} |
||||
|
||||
//=========================================================
|
||||
// someone else is talking - don't speak
|
||||
//=========================================================
|
||||
BOOL CMassn::FOkToSpeak(void) |
||||
{ |
||||
return FALSE; |
||||
} |
||||
|
||||
//=========================================================
|
||||
// PainSound
|
||||
//=========================================================
|
||||
void CMassn::PainSound(void) |
||||
{ |
||||
} |
||||
|
||||
//=========================================================
|
||||
// DeathSound
|
||||
//=========================================================
|
||||
void CMassn::DeathSound(void) |
||||
{ |
||||
} |
||||
|
||||
//=========================================================
|
||||
// IdleSound
|
||||
//=========================================================
|
||||
void CMassn::IdleSound(void) |
||||
{ |
||||
} |
||||
|
||||
//=========================================================
|
||||
// IRelationship - overridden because Alien Grunts are
|
||||
// Human Grunt's nemesis.
|
||||
//=========================================================
|
||||
int CMassn::IRelationship(CBaseEntity *pTarget) |
||||
{ |
||||
if (FClassnameIs(pTarget->pev, "monster_human_grunt")) |
||||
{ |
||||
return R_DL; |
||||
} |
||||
else if (FClassnameIs(pTarget->pev, "monster_hassassin")) |
||||
{ |
||||
return R_AL; |
||||
} |
||||
|
||||
return CHGrunt::IRelationship(pTarget); |
||||
} |
@ -0,0 +1,253 @@
@@ -0,0 +1,253 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* Use, distribution, and modification of this source code and/or resulting |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "weapons.h" |
||||
#include "nodes.h" |
||||
#include "player.h" |
||||
#include "gamerules.h" |
||||
|
||||
void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity); |
||||
|
||||
#define PIPE_BODYHIT_VOLUME 128 |
||||
#define PIPE_WALLHIT_VOLUME 512 |
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_pipe, CPipe); |
||||
|
||||
enum pipe_e { |
||||
PIPE_IDLE1 = 0, |
||||
PIPE_DRAW, |
||||
PIPE_HOLSTER, |
||||
PIPE_ATTACK1HIT, |
||||
PIPE_ATTACK1MISS, |
||||
PIPE_ATTACK2MISS, |
||||
PIPE_ATTACK2HIT, |
||||
PIPE_ATTACK3MISS, |
||||
PIPE_ATTACK3HIT, |
||||
PIPE_IDLE2, |
||||
PIPE_IDLE3, |
||||
}; |
||||
|
||||
|
||||
void CPipe::Spawn() |
||||
{ |
||||
Precache(); |
||||
m_iId = WEAPON_PIPE; |
||||
SET_MODEL(ENT(pev), "models/w_pipe.mdl"); |
||||
m_iClip = -1; |
||||
|
||||
FallInit();// get ready to fall down.
|
||||
} |
||||
|
||||
|
||||
void CPipe::Precache(void) |
||||
{ |
||||
CCrowbar::Precache(); |
||||
|
||||
PRECACHE_MODEL("models/v_pipe.mdl"); |
||||
PRECACHE_MODEL("models/w_pipe.mdl"); |
||||
PRECACHE_MODEL("models/p_pipe.mdl"); |
||||
|
||||
m_usPipe = PRECACHE_EVENT(1, "events/pipe.sc"); |
||||
} |
||||
|
||||
int CPipe::GetItemInfo(ItemInfo *p) |
||||
{ |
||||
p->pszName = STRING(pev->classname); |
||||
p->pszAmmo1 = NULL; |
||||
p->iMaxAmmo1 = -1; |
||||
p->pszAmmo2 = NULL; |
||||
p->iMaxAmmo2 = -1; |
||||
p->iMaxClip = WEAPON_NOCLIP; |
||||
p->iSlot = 0; |
||||
p->iPosition = 1; |
||||
p->iId = WEAPON_PIPE; |
||||
p->iWeight = CROWBAR_WEIGHT; |
||||
return 1; |
||||
} |
||||
|
||||
|
||||
|
||||
BOOL CPipe::Deploy() |
||||
{ |
||||
return DefaultDeploy("models/v_pipe.mdl", "models/p_pipe.mdl", PIPE_DRAW, "pipe"); |
||||
} |
||||
|
||||
void CPipe::Holster(int skiplocal /* = 0 */) |
||||
{ |
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; |
||||
SendWeaponAnim(PIPE_HOLSTER); |
||||
} |
||||
|
||||
void CPipe::PrimaryAttack() |
||||
{ |
||||
if (!Swing(1)) |
||||
{ |
||||
SetThink(&CPipe::SwingAgain); |
||||
pev->nextthink = gpGlobals->time + 0.1f; |
||||
} |
||||
} |
||||
|
||||
int CPipe::Swing(int fFirst) |
||||
{ |
||||
int fDidHit = FALSE; |
||||
|
||||
TraceResult tr; |
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle); |
||||
Vector vecSrc = m_pPlayer->GetGunPosition(); |
||||
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; |
||||
|
||||
UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr); |
||||
|
||||
#ifndef CLIENT_DLL |
||||
if (tr.flFraction >= 1.0) |
||||
{ |
||||
UTIL_TraceHull(vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT(m_pPlayer->pev), &tr); |
||||
if (tr.flFraction < 1.0) |
||||
{ |
||||
// Calculate the point of intersection of the line (or hull) and the object we hit
|
||||
// This is and approximation of the "best" intersection
|
||||
CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit); |
||||
if (!pHit || pHit->IsBSPModel()) |
||||
FindHullIntersection(vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict()); |
||||
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
|
||||
} |
||||
} |
||||
#endif |
||||
|
||||
PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usPipe, |
||||
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, |
||||
0.0, 0, 0.0); |
||||
|
||||
|
||||
if (tr.flFraction >= 1.0) |
||||
{ |
||||
if (fFirst) |
||||
{ |
||||
// miss
|
||||
m_flNextPrimaryAttack = GetNextAttackDelay(0.5); |
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
switch (((m_iSwing++) % 2) + 1) |
||||
{ |
||||
case 0: |
||||
SendWeaponAnim(PIPE_ATTACK1HIT); break; |
||||
case 1: |
||||
SendWeaponAnim(PIPE_ATTACK2HIT); break; |
||||
case 2: |
||||
SendWeaponAnim(PIPE_ATTACK3HIT); break; |
||||
} |
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1); |
||||
|
||||
#ifndef CLIENT_DLL |
||||
|
||||
// hit
|
||||
fDidHit = TRUE; |
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); |
||||
|
||||
ClearMultiDamage(); |
||||
|
||||
if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer()) |
||||
{ |
||||
// first swing does full damage
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar * 2, gpGlobals->v_forward, &tr, DMG_CLUB); |
||||
} |
||||
else |
||||
{ |
||||
// subsequent swings do half
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB); |
||||
} |
||||
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); |
||||
|
||||
// play thwack, smack, or dong sound
|
||||
float flVol = 1.0; |
||||
int fHitWorld = TRUE; |
||||
|
||||
if (pEntity) |
||||
{ |
||||
if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) |
||||
{ |
||||
// play thwack or smack sound
|
||||
switch (RANDOM_LONG(0, 2)) |
||||
{ |
||||
case 0: |
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM, 0, 75); break; |
||||
case 1: |
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM, 0, 75); break; |
||||
case 2: |
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM, 0, 75); break; |
||||
} |
||||
m_pPlayer->m_iWeaponVolume = PIPE_BODYHIT_VOLUME; |
||||
if (!pEntity->IsAlive()) |
||||
return TRUE; |
||||
else |
||||
flVol = 0.1; |
||||
|
||||
fHitWorld = FALSE; |
||||
} |
||||
} |
||||
|
||||
// play texture hit sound
|
||||
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
|
||||
|
||||
if (fHitWorld) |
||||
{ |
||||
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, BULLET_PLAYER_CROWBAR); |
||||
|
||||
if (g_pGameRules->IsMultiplayer()) |
||||
{ |
||||
// override the volume here, cause we don't play texture sounds in multiplayer,
|
||||
// and fvolbar is going to be 0 from the above call.
|
||||
|
||||
fvolbar = 1; |
||||
} |
||||
|
||||
// also play crowbar strike
|
||||
switch (RANDOM_LONG(0, 1)) |
||||
{ |
||||
case 0: |
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 75 + RANDOM_LONG(0, 3)); // 98
|
||||
break; |
||||
case 1: |
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 75 + RANDOM_LONG(0, 3)); // 98
|
||||
break; |
||||
} |
||||
|
||||
// delay the decal a bit
|
||||
m_trHit = tr; |
||||
} |
||||
|
||||
m_pPlayer->m_iWeaponVolume = flVol * PIPE_WALLHIT_VOLUME; |
||||
#endif |
||||
m_flNextPrimaryAttack = GetNextAttackDelay(0.5f); // 0.25f
|
||||
|
||||
SetThink(&CPipe::Smack); |
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.2; |
||||
|
||||
|
||||
} |
||||
return fDidHit; |
||||
} |
@ -0,0 +1,239 @@
@@ -0,0 +1,239 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* Use, distribution, and modification of this source code and/or resulting |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "weapons.h" |
||||
#include "monsters.h" |
||||
#include "player.h" |
||||
#include "gamerules.h" |
||||
|
||||
enum sniper_e { |
||||
SNIPER_IDLE1 = 0, |
||||
SNIPER_SHOOT1, |
||||
SNIPER_SHOOT2, |
||||
SNIPER_RELOAD, |
||||
SNIPER_DRAW, |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_sniper, CSniper); |
||||
|
||||
int CSniper::GetItemInfo(ItemInfo *p) |
||||
{ |
||||
p->pszName = STRING(pev->classname); |
||||
p->pszAmmo1 = "357"; |
||||
p->iMaxAmmo1 = _357_MAX_CARRY; |
||||
p->pszAmmo2 = NULL; |
||||
p->iMaxAmmo2 = -1; |
||||
p->iMaxClip = CROSSBOW_MAX_CLIP; |
||||
p->iFlags = 0; |
||||
p->iSlot = 2; |
||||
p->iPosition = 3; |
||||
p->iId = m_iId = WEAPON_SNIPER; |
||||
p->iWeight = PYTHON_WEIGHT; |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
int CSniper::AddToPlayer(CBasePlayer *pPlayer) |
||||
{ |
||||
if (CBasePlayerWeapon::AddToPlayer(pPlayer)) |
||||
{ |
||||
MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); |
||||
WRITE_BYTE(m_iId); |
||||
MESSAGE_END(); |
||||
return TRUE; |
||||
} |
||||
return FALSE; |
||||
} |
||||
|
||||
void CSniper::Spawn() |
||||
{ |
||||
Precache(); |
||||
m_iId = WEAPON_SNIPER; |
||||
SET_MODEL(ENT(pev), "models/w_sniper.mdl"); |
||||
|
||||
m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE; |
||||
|
||||
FallInit();// get ready to fall down.
|
||||
} |
||||
|
||||
|
||||
void CSniper::Precache(void) |
||||
{ |
||||
PRECACHE_MODEL("models/v_sniper.mdl"); |
||||
PRECACHE_MODEL("models/w_sniper.mdl"); |
||||
PRECACHE_MODEL("models/p_sniper.mdl"); |
||||
|
||||
PRECACHE_MODEL("models/w_sniperclip.mdl"); |
||||
PRECACHE_SOUND("items/9mmclip1.wav"); |
||||
|
||||
PRECACHE_SOUND("weapons/sniper_reload1.wav"); |
||||
PRECACHE_SOUND("weapons/scout_bolt.wav"); |
||||
PRECACHE_SOUND("weapons/scout_clipin.wav"); |
||||
PRECACHE_SOUND("weapons/scout_clipout.wav"); |
||||
|
||||
m_usFireSniper = PRECACHE_EVENT(1, "events/sniper.sc"); |
||||
} |
||||
|
||||
BOOL CSniper::Deploy() |
||||
{ |
||||
return DefaultDeploy("models/v_sniper.mdl", "models/p_sniper.mdl", SNIPER_DRAW, "sniper", UseDecrement()); |
||||
} |
||||
|
||||
void CSniper::Holster(int skiplocal /* = 0 */) |
||||
{ |
||||
m_fInReload = FALSE;// cancel any reload in progress.
|
||||
|
||||
if (m_fInZoom) |
||||
{ |
||||
SecondaryAttack(); |
||||
} |
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; |
||||
m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); |
||||
} |
||||
|
||||
void CSniper::SecondaryAttack(void) |
||||
{ |
||||
if (m_pPlayer->pev->fov != 0) |
||||
{ |
||||
m_fInZoom = FALSE; |
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
||||
} |
||||
else if (m_pPlayer->pev->fov != 40) |
||||
{ |
||||
m_fInZoom = TRUE; |
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 40; |
||||
} |
||||
|
||||
m_flNextSecondaryAttack = 0.5; |
||||
} |
||||
|
||||
void CSniper::PrimaryAttack() |
||||
{ |
||||
// don't fire underwater
|
||||
if (m_pPlayer->pev->waterlevel == 3) |
||||
{ |
||||
PlayEmptySound(); |
||||
m_flNextPrimaryAttack = 0.15; |
||||
return; |
||||
} |
||||
|
||||
if (m_iClip <= 0) |
||||
{ |
||||
if (!m_fFireOnEmpty) |
||||
Reload(); |
||||
else |
||||
{ |
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM); |
||||
m_flNextPrimaryAttack = 0.15; |
||||
} |
||||
|
||||
return; |
||||
} |
||||
|
||||
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; |
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; |
||||
|
||||
m_iClip--; |
||||
|
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; |
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1); |
||||
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); |
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition(); |
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); |
||||
|
||||
Vector vecDir; |
||||
vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_SNIPER, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed); |
||||
|
||||
int flags; |
||||
#if defined( CLIENT_WEAPONS ) |
||||
flags = FEV_NOTHOST; |
||||
#else |
||||
flags = 0; |
||||
#endif |
||||
|
||||
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireSniper, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0); |
||||
|
||||
m_flNextPrimaryAttack = (46.0 / 35.0); |
||||
m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); |
||||
} |
||||
|
||||
|
||||
void CSniper::Reload(void) |
||||
{ |
||||
if (m_pPlayer->ammo_357 <= 0) |
||||
return; |
||||
|
||||
int iResult = DefaultReload(CROSSBOW_MAX_CLIP, SNIPER_RELOAD, 2.0); |
||||
|
||||
if (iResult) |
||||
{ |
||||
if (m_pPlayer->pev->fov != 0) |
||||
{ |
||||
m_fInZoom = FALSE; |
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
void CSniper::WeaponIdle(void) |
||||
{ |
||||
ResetEmptySound(); |
||||
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); |
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) |
||||
return; |
||||
|
||||
m_flTimeWeaponIdle = (9.0 / 16.0); |
||||
|
||||
SendWeaponAnim(SNIPER_IDLE1, UseDecrement() ? 1 : 0); |
||||
} |
||||
|
||||
|
||||
class CSniperAmmoClip : public CBasePlayerAmmo |
||||
{ |
||||
void Spawn(void) |
||||
{ |
||||
Precache(); |
||||
SET_MODEL(ENT(pev), "models/w_sniperclip.mdl"); |
||||
CBasePlayerAmmo::Spawn(); |
||||
} |
||||
void Precache(void) |
||||
{ |
||||
PRECACHE_MODEL("models/w_sniperclip.mdl"); |
||||
PRECACHE_SOUND("items/9mmclip1.wav"); |
||||
} |
||||
BOOL AddAmmo(CBaseEntity *pOther) |
||||
{ |
||||
int bResult = (pOther->GiveAmmo(AMMO_357BOX_GIVE, "357", _357_MAX_CARRY) != -1); |
||||
if (bResult) |
||||
{ |
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); |
||||
} |
||||
return bResult; |
||||
} |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(ammo_sniper, CSniperAmmoClip); |
Loading…
Reference in new issue