Initial implementation of the Nail Grenade

This commit is contained in:
Marco Cawthorne 2023-01-27 17:23:19 -08:00
parent 0ae8d2b52a
commit bba99076d5
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 85 additions and 1 deletions

View File

@ -114,8 +114,92 @@ TFCNade_ThrowConcussion(player pl)
void
TFCNade_ThrowNail(player pl)
{
vector vecNadeVelocity;
float flTimer;
print("Throwing Nail grenade!\n");
static void TFCNade_ThrowNail_Touch(void) {
Sound_Play(self, CHAN_BODY, "weapon_handgrenade.bounce");
if (!vlen(self.velocity))
self.avelocity = g_vec_null;
}
static void TFCNade_ThrowNail_Explode(void) {
float dmg = 100;
FX_Explosion(self.origin);
Damage_Radius(self.origin, self.owner, dmg, dmg * 2.5f, TRUE, WEAPON_GLAUNCHER);
sound(self, CHAN_WEAPON, sprintf("weapons/explode%d.wav", floor(random() * 2) + 3), 1, ATTN_NORM);
NSEntity::Destroy();
}
static void TFCNade_ThrowNail_Shoot(entity source, vector euler_dir) {
static void TFCNade_ThrowNail_Shoot_Touch(void) {
if (trace_ent.iBleeds == 0) {
DecalGroups_Place("Impact.BigShot", trace_endpos + (v_forward * -2));
SurfData_Impact(trace_ent, trace_surfaceflagsi, trace_endpos, trace_plane_normal);
}
if (trace_ent.takedamage == DAMAGE_YES) {
Damage_Apply(trace_ent, self.owner.owner, 9, WEAPON_NAILGUN, DMG_BULLET);
}
remove(self);
}
makevectors(source.angles + euler_dir);
entity p = spawn();
setmodel(p, "models/nail.mdl");
setorigin(p, source.origin + (v_forward * 8) + (v_up * 2));
p.owner = source;
p.movetype = MOVETYPE_FLYMISSILE;
p.solid = SOLID_BBOX;
p.gravity = 0.5f;
p.velocity = (v_forward * 1000);
p.angles = vectoangles(p.velocity);
p.touch = TFCNade_ThrowNail_Shoot_Touch;
p.think = Util_Destroy;
}
static void TFCNade_ThrowNail_Unload(void) {
if (self.ammo_nails <= 0) {
TFCNade_ThrowNail_Explode();
return;
}
self.angles[1] += 15.0;
TFCNade_ThrowNail_Shoot(self, [0, 0, 0]);
TFCNade_ThrowNail_Shoot(self, [0, 60, 0]);
TFCNade_ThrowNail_Shoot(self, [0, 120, 0]);
TFCNade_ThrowNail_Shoot(self, [0, 180, 0]);
TFCNade_ThrowNail_Shoot(self, [0, 240, 0]);
TFCNade_ThrowNail_Shoot(self, [0, 300, 0]);
self.ammo_nails -= 6;
self.nextthink = time + 0.15f;
}
static void TFCNade_ThrowNail_Deploy(void) {
self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_NONE;
self.velocity = [0,0,0];
setorigin(self, self.origin + [0,0, 32]);
self.think = TFCNade_ThrowNail_Unload;
self.nextthink = time + 1.0f;
}
Weapons_MakeVectors(pl);
vecNadeVelocity = v_forward * 600 + v_up * 200 + crandom() * v_right * 10 + crandom() * v_up * 10;
flTimer = max(0.0, pl.gren2.GetNextThinkTime() - time);
NSRenderableEntity eNade = spawn(NSRenderableEntity);
eNade.SetModel("models/ngrenade.mdl");
eNade.SetOrigin(Weapons_GetCameraPos(pl) + (v_forward * 14) + (v_up * -4) + (v_right * 2));
eNade.SetOwner(pl);
eNade.SetMovetype(MOVETYPE_BOUNCE);
eNade.SetSolid(SOLID_BBOX);
eNade.SetGravity(1.0f);
eNade.SetVelocity(vecNadeVelocity);
eNade.SetAngularVelocity([0, 600, 0]);
eNade.ammo_nails = 200;
eNade.touch = TFCNade_ThrowNail_Touch;
eNade.ScheduleThink(TFCNade_ThrowNail_Deploy, flTimer);
}
void