Concussion grenade and Hallucination grenade implementation coming along further

This commit is contained in:
Marco Cawthorne 2023-10-05 00:32:47 -07:00
parent c52f1b15db
commit f3b239abbc
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
5 changed files with 145 additions and 1 deletions

View File

@ -27,3 +27,6 @@ var string g_tfchud6_spr;
var string g_tfchud7_spr;
var int MUZZLE_ROUND;
void TFCHallucination_Insert(vector, vector);

View File

@ -0,0 +1,84 @@
class
TFCHallucination:NSEntity
{
};
void
TFCHallucination_Insert(vector viewPosition, vector viewDirection)
{
int r = 0i;
vector halluPos = viewPosition;
halluPos += v_forward * random(8, 128);
halluPos += v_up * random(-64, 128);
halluPos += v_right * random(-256, 256);
traceline(viewPosition, halluPos, MOVE_NORMAL, pSeat->m_ePlayer);
halluPos = trace_endpos;
makevectors(viewDirection);
r = (int)(floor(random(0, 8)));
switch (r) {
case 1:
for (int i = 0; i < 3; i++) {
FX_Blood(halluPos, [1,0,0]);
halluPos += v_forward * random(8, 128);
halluPos += v_up * random(-64, 128);
halluPos += v_right * random(-256, 256);
}
break;
case 2:
pointparticles(particleeffectnum("fx_explosion.main"), halluPos, [0,0,0], 1);
pSeat->m_flShakeDuration = 2;
pSeat->m_flShakeAmp = 5.0;
pSeat->m_flShakeFreq = 2;
pSeat->m_flShakeTime = 2;
pointsound(halluPos, sprintf("weapons/explode%d.wav", floor(random() * 2) + 3), 1, ATTN_NORM);
break;
case 3:
traceline(viewPosition, halluPos + (v_forward * 1024), MOVE_NORMAL, pSeat->m_ePlayer);
SurfData_Impact(world, trace_endpos, [0,0,0]);
DecalGroups_Place("Impact.Shot", trace_endpos);
pointsound(halluPos, "weapons/sbarrel1.wav", 1, ATTN_NORM);
break;
case 4:
pSeat->m_flShakeDuration = 1;
pSeat->m_flShakeAmp = 1.0;
pSeat->m_flShakeFreq = 2;
pSeat->m_flShakeTime = 2;
pointsound(halluPos, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM);
break;
case 5:
traceline(viewPosition, halluPos + (v_forward * 1024), MOVE_NORMAL, pSeat->m_ePlayer);
SurfData_Impact(world, trace_endpos, [0,0,0]);
DecalGroups_Place("Impact.Shot", trace_endpos);
pointsound(halluPos, "weapons/sniper.wav", 1, ATTN_NORM);
break;
case 6:
traceline(viewPosition, halluPos + (v_forward * 1024), MOVE_NORMAL, pSeat->m_ePlayer);
SurfData_Impact(world, trace_endpos, [0,0,0]);
DecalGroups_Place("Impact.Shot", trace_endpos);
pointsound(halluPos, "weapons/airgun_1.wav", 1, ATTN_NORM);
break;
case 7:
NSRenderableEntity eNade = spawn(NSRenderableEntity);
eNade.SetModel("models/w_grenade.mdl");
eNade.SetOrigin(halluPos);
eNade.SetMovetype(MOVETYPE_BOUNCE);
eNade.SetSolid(SOLID_NOT);
eNade.SetGravity(1.0f);
eNade.SetVelocity(v_forward * random(-320,320) + v_right * random(-64, 64) + v_up * 200);
eNade.SetAngularVelocity([300, 300, 300]);
eNade.SetAngles(vectoangles(eNade.GetVelocity()));
eNade.ScheduleThink(eNade.Destroy, 5.0f);
eNade.drawmask = MASK_ENGINE;
pointsound(halluPos, "weapons/grenade_hit3.wav", 1, ATTN_NORM);
break;
default:
pointsound(halluPos, "weapons/rocketfire1.wav", 1, ATTN_NORM);
break;
}
};

View File

@ -29,6 +29,7 @@ init.qc
entities.qc
cmds.qc
game_event.qc
hallucination.qc
../../../valve/src/client/camera.qc
../../../valve/src/client/viewmodel.qc
../../../valve/src/client/view.qc

View File

@ -90,6 +90,19 @@ TFCNade_ThrowConcussion(player pl)
}
static void TFCNade_ThrowConcussion_Explode(void) {
for (player f = world; (f = (player)find(f, ::classname, "player"));) {
float dist = vlen(f.origin - self.origin);
if (dist < 256) {
vector pushVel;
f.m_flIdleScale = 15.0f;
makevectors(f.origin - self.origin);
pushVel = v_forward * 300;
pushVel[2] += 300;
f.SetVelocity(pushVel);
}
}
NSEntity::Destroy();
}
@ -335,6 +348,13 @@ TFCNade_ThrowHallucination(player pl)
}
static void TFCNade_ThrowConcussion_Explode(void) {
for (player f = world; (f = (player)find(f, ::classname, "player"));) {
float dist = vlen(f.origin - self.origin);
if (dist < 192) {
f.m_flHallucination = 15.0f;
}
}
NSEntity::Destroy();
}

View File

@ -58,6 +58,9 @@ class player:NSClientPlayer
/* ammo 3 */
PREDICTED_INT(mode_tempstate)
PREDICTED_FLOAT(m_flIdleScale)
PREDICTED_FLOAT(m_flHallucination)
virtual void Physics_Jump(void);
virtual float Physics_MaxSpeed(void);
@ -76,6 +79,8 @@ class player:NSClientPlayer
virtual void UpdateAliveCam(void);
virtual void UpdatePlayerAttachments(bool);
float m_flNextHallucination;
#else
NSTimer gren1;
NSTimer gren2;
@ -98,7 +103,7 @@ class player:NSClientPlayer
virtual void ServerInputFrame(void);
nonvirtual void TFC_FragSelf(void);
nonvirtual void TFC_FragSelf(void);
nonvirtual void TFC_ThrowSecondary(void);
#endif
};
@ -328,6 +333,13 @@ player::UpdateAliveCam(void)
g_view.SetCameraOrigin(cam_pos);
Camera_StrafeRoll(view_angles);
if (m_flIdleScale > 0.0) {
float wave = sin(time);
view_angles[0] -= m_flIdleScale * sin(1 * time) * 0.9;
view_angles[1] -= m_flIdleScale * sin(2 * time) * 0.9;
view_angles[2] -= m_flIdleScale * sin(0.5 * time) * 0.3;
}
g_view.SetCameraAngle(view_angles);
if (vehicle) {
@ -381,6 +393,8 @@ player::ReceiveEntity(float new, float flChanged)
READENTITY_BYTE(mode_tempstate, PLAYER_AMMO3)
READENTITY_BYTE(classtype, PLAYER_AMMO3)
READENTITY_FLOAT(m_flIdleScale, PLAYER_AMMO3)
READENTITY_FLOAT(m_flHallucination, PLAYER_AMMO3)
setorigin(this, origin);
@ -400,6 +414,14 @@ player::ReceiveEntity(float new, float flChanged)
if (flChanged & PLAYER_ITEMS || flChanged & PLAYER_HEALTH)
HUD_ItemNotify_Check(this);
if (m_flHallucination > 0.0) {
if (m_flNextHallucination > time)
return;
TFCHallucination_Insert(origin, v_angle);
m_flNextHallucination = time + 0.5f + random();
}
}
/*
@ -436,6 +458,8 @@ player::PredictPreFrame(void)
SAVE_STATE(mode_tempstate)
SAVE_STATE(classtype)
SAVE_STATE(m_flIdleScale)
SAVE_STATE(m_flHallucination)
}
/*
@ -471,6 +495,8 @@ player::PredictPostFrame(void)
ROLL_BACK(mode_tempstate)
ROLL_BACK(classtype)
ROLL_BACK(m_flIdleScale)
ROLL_BACK(m_flHallucination)
}
#else
@ -480,6 +506,12 @@ player::ServerInputFrame(void)
super::ServerInputFrame();
gflags &= ~GF_NOBUILDZONE;
gflags &= ~GF_NOGRENADEZONE;
m_flIdleScale -= input_timelength;
m_flHallucination -= input_timelength;
if (m_flIdleScale <= 0.0)
m_flIdleScale = 0.0f;
}
void
@ -509,6 +541,8 @@ player::EvaluateEntity(void)
EVALUATE_FIELD(mode_tempstate, PLAYER_AMMO3)
EVALUATE_FIELD(classtype, PLAYER_AMMO3)
EVALUATE_FIELD(m_flIdleScale, PLAYER_AMMO3)
EVALUATE_FIELD(m_flHallucination, PLAYER_AMMO3)
}
void
@ -777,6 +811,8 @@ player::SendEntity(entity ePEnt, float flChanged)
SENDENTITY_BYTE(mode_tempstate, PLAYER_AMMO3)
SENDENTITY_BYTE(classtype, PLAYER_AMMO3)
SENDENTITY_FLOAT(m_flIdleScale, PLAYER_AMMO3)
SENDENTITY_FLOAT(m_flHallucination, PLAYER_AMMO3)
return (1);
}