WEAPON_C4: cleanups and fixes

This commit is contained in:
Marco Cawthorne 2024-01-03 14:16:34 -08:00
parent cb9f360dd4
commit c082c5e772
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
5 changed files with 158 additions and 66 deletions

View File

@ -51,6 +51,8 @@ Game_Worldspawn(void)
Sound_Precache("player.headshot"); Sound_Precache("player.headshot");
Sound_Precache("player.hitarmor"); Sound_Precache("player.hitarmor");
Sound_Precache("player.headshotarmor"); Sound_Precache("player.headshotarmor");
Sound_Precache("Player.FlashLightOff");
Sound_Precache("Player.FlashLightOn");
/* some Counter-Strike maps do not have weapon pickups, so we want to /* some Counter-Strike maps do not have weapon pickups, so we want to
* precache these regardless in case of someone dropping a weapon, * precache these regardless in case of someone dropping a weapon,

View File

@ -23,12 +23,10 @@ class item_c4:NSRenderableEntity
float m_flDefusalState; float m_flDefusalState;
#endif #endif
#ifdef CLIENT
float m_flAlpha;
#endif
#ifdef SERVER #ifdef SERVER
void item_c4(void); void item_c4(void);
virtual void Spawned(void);
virtual float SendEntity(entity, float); virtual float SendEntity(entity, float);
virtual void ClearProgress(void); virtual void ClearProgress(void);
virtual void OnPlayerUse(void); virtual void OnPlayerUse(void);
@ -43,6 +41,17 @@ class item_c4:NSRenderableEntity
#endif #endif
}; };
void
item_c4::item_c4(void)
{
#ifdef SERVER
m_eUser = __NULL__;
m_flBeepTime = 0.0f;
m_flExplodeTime = 0.0f;
m_flDefusalState = 0.0f;
#endif
}
#ifdef SERVER #ifdef SERVER
float float
item_c4::SendEntity(entity pvsent, float flags) item_c4::SendEntity(entity pvsent, float flags)
@ -81,7 +90,7 @@ item_c4::OnPlayerUse(void)
/* don't allow anyone else to hijack. */ /* don't allow anyone else to hijack. */
if (m_eUser == world) { if (m_eUser == world) {
m_eUser = eActivator; m_eUser = eActivator;
sound(this, CHAN_ITEM, "weapons/c4_disarm.wav", 1.0, ATTN_NONE); StartSoundDef("weapon_c4bomb.disarm", CHAN_ITEM, true);
} }
} }
@ -116,7 +125,7 @@ item_c4::Logic(void)
} }
if (m_flDefusalState > 10.0f) { if (m_flDefusalState > 10.0f) {
sound(this, CHAN_VOICE, "weapons/c4_disarmed.wav", 1.0, ATTN_NORM); StartSoundDef("weapon_c4bomb.disarmed", CHAN_VOICE, true);
rules.RoundOver(TEAM_CT, 3600, TRUE); rules.RoundOver(TEAM_CT, 3600, TRUE);
Radio_BroadcastMessage(RADIO_BOMBDEF); Radio_BroadcastMessage(RADIO_BOMBDEF);
Destroy(); Destroy();
@ -131,8 +140,8 @@ item_c4::Logic(void)
/* In Bomb Defusal, all Terrorists receive $3500 /* In Bomb Defusal, all Terrorists receive $3500
* if they won by detonating the bomb. */ * if they won by detonating the bomb. */
rules.RoundOver(TEAM_T, 3500, FALSE); rules.RoundOver(TEAM_T, 3500, FALSE);
Damage_Radius(origin, this.owner, 500, g_cstrike_bombradius, FALSE, WEAPON_C4BOMB); Damage_Radius(origin, this.real_owner, 500, g_cstrike_bombradius, false, WEAPON_C4BOMB);
Sound_Play(this, CHAN_VOICE, "weapon_c4bomb.explode"); StartSoundDef("weapon_c4bomb.explode", CHAN_VOICE, true);
for (entity e = world; (e = find(e, ::classname, "func_bomb_target"));) { for (entity e = world; (e = find(e, ::classname, "func_bomb_target"));) {
float dist = vlen(origin - e.origin); float dist = vlen(origin - e.origin);
@ -157,18 +166,16 @@ item_c4::Logic(void)
} }
m_flBeepTime = time + 1.5; m_flBeepTime = time + 1.5;
if (m_flExplodeTime - time < 2) { if (m_flExplodeTime - time < 5) {
sound(this, CHAN_VOICE, "weapons/c4_beep5.wav", 1.0, ATTN_NONE); StartSoundDef("weapon_c4bomb.beep5", CHAN_VOICE, true);
} else if (m_flExplodeTime - time < 5) {
sound(this, CHAN_VOICE, "weapons/c4_beep5.wav", 1.0, ATTN_NORM);
} else if (m_flExplodeTime - time < 10) { } else if (m_flExplodeTime - time < 10) {
sound(this, CHAN_VOICE, "weapons/c4_beep4.wav", 1.0, ATTN_NORM); StartSoundDef("weapon_c4bomb.beep4", CHAN_VOICE, true);
} else if (m_flExplodeTime - time < 20) { } else if (m_flExplodeTime - time < 20) {
sound(this, CHAN_VOICE, "weapons/c4_beep3.wav", 1.0, ATTN_NORM); StartSoundDef("weapon_c4bomb.beep3", CHAN_VOICE, true);
} else if (m_flExplodeTime - time < 30) { } else if (m_flExplodeTime - time < 30) {
sound(this, CHAN_VOICE, "weapons/c4_beep2.wav", 1.0, ATTN_NORM); StartSoundDef("weapon_c4bomb.beep2", CHAN_VOICE, true);
} else { } else {
sound(this, CHAN_VOICE, "weapons/c4_beep1.wav", 1.0, ATTN_NORM); StartSoundDef("weapon_c4bomb.beep1", CHAN_VOICE, true);
} }
} }
@ -181,8 +188,10 @@ item_c4::OnRemoveEntity(void)
} }
void void
item_c4::item_c4(void) item_c4::Spawned(void)
{ {
super::Spawned();
/* throw this in with the other temporary round entities */ /* throw this in with the other temporary round entities */
classname = "remove_me"; classname = "remove_me";
@ -194,21 +203,24 @@ item_c4::item_c4(void)
customphysics = Logic; customphysics = Logic;
PlayerUse = OnPlayerUse; PlayerUse = OnPlayerUse;
m_flExplodeTime = time + 45.0f; m_flExplodeTime = time + 45.0f;
StartSoundDef("weapon_c4bomb.plant", CHAN_WEAPON, true);
Sound_Play(this, CHAN_WEAPON, "weapon_c4bomb.plant");
} }
void void
C4Bomb_Plant(NSClientPlayer planter) C4Bomb_Plant(NSClientPlayer planter)
{ {
item_c4 bomb = spawn(item_c4); item_c4 bomb = spawn(item_c4);
bomb.owner = planter; bomb.Spawned();
bomb.real_owner = planter;
/* place directly below */ /* place directly below */
traceline(planter.origin, planter.origin + [0,0,-64], FALSE, planter); traceline(planter.origin, planter.origin + [0,0,-64], FALSE, planter);
setorigin(bomb, trace_endpos); setorigin(bomb, trace_endpos);
bomb.SendFlags = -1; bomb.SendFlags = -1;
/* push the player out if we're on top */
setorigin_safe(planter, planter.origin);
Radio_BroadcastMessage(RADIO_BOMBPL); Radio_BroadcastMessage(RADIO_BOMBPL);
CSBot_BombPlantedNotify(); CSBot_BombPlantedNotify();
g_cs_bombplanted = TRUE; g_cs_bombplanted = TRUE;
@ -219,45 +231,31 @@ C4Bomb_Plant(NSClientPlayer planter)
void void
item_c4::DrawLED(void) item_c4::DrawLED(void)
{ {
vector vecPlayer; vector cameraPos = g_view.GetCameraOrigin();
float ledAlpha = 1.0 - (time - floor(time));
int s = (float)getproperty(VF_ACTIVESEAT); if (ledAlpha > 0.0f) {
pSeat = &g_seats[s]; vector ledPos = GetOrigin() + [0,0,8];
vecPlayer = pSeat->m_vecPredictedOrigin; vector ledSize = [16,16];
m_flAlpha -= frametime;
if (m_flAlpha <= 0.0f)
m_flAlpha = 1.0f;
if (m_flAlpha > 0) {
vector forg;
vector fsize;
float falpha;
/* Scale the glow somewhat with the players distance */ /* Scale the glow somewhat with the players distance */
fsize = [16,16]; ledSize *= bound(1, vlen(cameraPos - origin) / 256, 4);
fsize *= bound(1, vlen(vecPlayer - origin) / 256, 4);
/* Fade out when the player is starting to move away */
falpha = 1 - bound(0, vlen(vecPlayer - origin) / 1024, 1);
falpha *= m_flAlpha;
/* Nudge this slightly towards the camera */ /* Nudge this slightly towards the camera */
makevectors(vectoangles(origin - vecPlayer)); makevectors(vectoangles(ledPos - cameraPos));
forg = (origin + [0,0,8]) + (v_forward * -16); ledPos += (v_forward * -16);
/* Project it, always facing the player */ /* Project it, always facing the player */
makevectors(view_angles); makevectors(g_view.GetCameraAngle());
R_BeginPolygon(g_c4bombled_spr, 1, 0); R_BeginPolygon(g_c4bombled_spr, 1, 0);
R_PolygonVertex(forg + v_right * fsize[0] - v_up * fsize[1], R_PolygonVertex(ledPos + v_right * ledSize[0] - v_up * ledSize[1],
[1,1], [1,1,1], falpha); [1,1], [1,1,1] * ledAlpha, 1.0f);
R_PolygonVertex(forg - v_right * fsize[0] - v_up * fsize[1], R_PolygonVertex(ledPos - v_right * ledSize[0] - v_up * ledSize[1],
[0,1], [1,1,1], falpha); [0,1], [1,1,1] * ledAlpha, 1.0f);
R_PolygonVertex(forg - v_right * fsize[0] + v_up * fsize[1], R_PolygonVertex(ledPos - v_right * ledSize[0] + v_up * ledSize[1],
[0,0], [1,1,1], falpha); [0,0], [1,1,1] * ledAlpha, 1.0f);
R_PolygonVertex(forg + v_right * fsize[0] + v_up * fsize[1], R_PolygonVertex(ledPos + v_right * ledSize[0] + v_up * ledSize[1],
[1,0], [1,1,1], falpha); [1,0], [1,1,1] * ledAlpha, 1.0f);
R_EndPolygon(); R_EndPolygon();
} }
} }
@ -270,14 +268,6 @@ item_c4::predraw(void)
return PREDRAW_NEXT; return PREDRAW_NEXT;
} }
void
item_c4::item_c4(void)
{
solid = SOLID_BBOX;
movetype = MOVETYPE_NONE;
drawmask = MASK_ENGINE;
}
void void
w_c4bomb_parse(void) w_c4bomb_parse(void)
{ {
@ -295,5 +285,8 @@ w_c4bomb_parse(void)
tm.modelindex = readshort(); tm.modelindex = readshort();
setorigin(tm, tm.origin); setorigin(tm, tm.origin);
setsize(tm, [-6,-6,0], [6,6,6]); setsize(tm, [-6,-6,0], [6,6,6]);
tm.solid = SOLID_BBOX;
tm.movetype = MOVETYPE_NONE;
tm.drawmask = MASK_ENGINE;
} }
#endif #endif

View File

@ -55,6 +55,11 @@ w_c4bomb_precache(void)
Sound_Precache("weapon_c4bomb.disarmed"); Sound_Precache("weapon_c4bomb.disarmed");
Sound_Precache("weapon_c4bomb.explode"); Sound_Precache("weapon_c4bomb.explode");
Sound_Precache("weapon_c4bomb.plant"); Sound_Precache("weapon_c4bomb.plant");
Sound_Precache("weapon_c4bomb.beep1");
Sound_Precache("weapon_c4bomb.beep2");
Sound_Precache("weapon_c4bomb.beep3");
Sound_Precache("weapon_c4bomb.beep4");
Sound_Precache("weapon_c4bomb.beep5");
precache_sound("weapons/c4_beep1.wav"); precache_sound("weapons/c4_beep1.wav");
precache_sound("weapons/c4_beep2.wav"); precache_sound("weapons/c4_beep2.wav");
precache_sound("weapons/c4_beep3.wav"); precache_sound("weapons/c4_beep3.wav");

View File

@ -15,18 +15,18 @@ player.hitarmor
sample player/bhit_kevlar-1.wav sample player/bhit_kevlar-1.wav
} }
player.fall Player.FallDamage
{ {
sample player/pl_pain2.wav sample player/pl_pain2.wav
sample player/pl_pain7.wav sample player/pl_pain7.wav
} }
player.lightfall Player.LightFall
{ {
sample player/pl_fallpain1.wav sample player/pl_fallpain1.wav
} }
player.die Player.Death
{ {
sample player/die1.wav sample player/die1.wav
sample player/die2.wav sample player/die2.wav
@ -34,24 +34,88 @@ player.die
sample player/death6.wav sample player/death6.wav
} }
player.gasplight Player.GaspLight
{ {
sample misc/null.wav sample misc/null.wav
} }
player.gaspheavy Player.GaspHeavy
{ {
sample misc/null.wav sample misc/null.wav
} }
player.waterexit Player.WaterExit
{ {
sample player/pl_wade1.wav sample player/pl_wade1.wav
sample player/pl_wade3.wav sample player/pl_wade3.wav
} }
player.waterenter Player.WaterEnter
{ {
sample player/pl_wade2.wav sample player/pl_wade2.wav
sample player/pl_wade4.wav sample player/pl_wade4.wav
} }
Player.DenyWeaponSelection
{
follow
omnidirectional
attenuation none
volume 0.5
sample common/wpn_denyselect.wav
}
Player.WeaponSelected
{
follow
omnidirectional
attenuation none
volume 0.5
sample common/wpn_select.wav
}
Player.WeaponSelectionMoveSlot
{
follow
omnidirectional
attenuation none
volume 0.5
sample common/wpn_moveselect.wav
}
Player.WeaponSelectionOpen
{
follow
omnidirectional
attenuation none
volume 0.5
sample common/wpn_hudon.wav
}
Player.WeaponSelectionClose
{
follow
omnidirectional
attenuation none
volume 0.5
sample common/wpn_hudoff.wav
}
Player.FlashLightOn
{
follow
volume 0.8
sample items/flashlight1.wav
}
Player.FlashLightOff
{
follow
volume 0.8
sample items/flashlight1.wav
}
SprayCan.Paint
{
sample player/sprayer.wav
}

View File

@ -21,6 +21,7 @@ weapon_awp.zoom
weapon_c4bomb.disarm weapon_c4bomb.disarm
{ {
attenuation none
sample weapons/c4_disarm.wav sample weapons/c4_disarm.wav
} }
@ -31,6 +32,7 @@ weapon_c4bomb.disarmed
weapon_c4bomb.explode weapon_c4bomb.explode
{ {
attenuation none
sample weapons/c4_explode1.wav sample weapons/c4_explode1.wav
} }
@ -39,6 +41,32 @@ weapon_c4bomb.plant
sample weapons/c4_plant.wav sample weapons/c4_plant.wav
} }
weapon_c4bomb.beep1
{
sample weapons/c4_beep1.wav
}
weapon_c4bomb.beep2
{
sample weapons/c4_beep2.wav
}
weapon_c4bomb.beep3
{
sample weapons/c4_beep3.wav
}
weapon_c4bomb.beep4
{
sample weapons/c4_beep4.wav
}
weapon_c4bomb.beep5
{
attenuation none
sample weapons/c4_beep5.wav
}
weapon_deagle.fire weapon_deagle.fire
{ {
sample weapons/deagle-1.wav sample weapons/deagle-1.wav