WEAPON_PIPEBOMB: now the pipebomb launcher is here too, although you can't explode the nades yet.

This commit is contained in:
Marco Cawthorne 2023-01-17 16:32:53 -08:00
parent 14843ee5fd
commit d2d3f54592
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
3 changed files with 143 additions and 16 deletions

View File

@ -44,6 +44,7 @@ class player:NSClientPlayer
PREDICTED_INT(mag_dbs)
PREDICTED_INT(mag_rpg)
PREDICTED_INT(mag_glauncher)
PREDICTED_INT(mag_pipebomb)
/* ammo 2 */
PREDICTED_INT(m_iAmmoRockets)
@ -112,6 +113,7 @@ player::ReceiveEntity(float new, float fl)
mag_dbs = readbyte();
mag_rpg = readbyte();
mag_glauncher = readbyte();
mag_pipebomb = readbyte();
}
if (fl & PLAYER_AMMO2) {
@ -173,6 +175,7 @@ player::PredictPreFrame(void)
SAVE_STATE(mag_dbs);
SAVE_STATE(mag_rpg);
SAVE_STATE(mag_glauncher);
SAVE_STATE(mag_pipebomb);
SAVE_STATE(m_iAmmoRockets);
SAVE_STATE(m_iAmmoNails);
@ -208,6 +211,7 @@ player::PredictPostFrame(void)
ROLL_BACK(mag_dbs);
ROLL_BACK(mag_rpg);
ROLL_BACK(mag_glauncher);
ROLL_BACK(mag_pipebomb);
ROLL_BACK(m_iAmmoRockets);
ROLL_BACK(m_iAmmoNails);
@ -241,6 +245,8 @@ player::EvaluateEntity(void)
SendFlags |= PLAYER_AMMO1;
else if (ATTR_CHANGED(mag_glauncher))
SendFlags |= PLAYER_AMMO1;
else if (ATTR_CHANGED(mag_pipebomb))
SendFlags |= PLAYER_AMMO1;
/* ammo 2 type updates */
if (ATTR_CHANGED(m_iAmmoRockets))
@ -266,6 +272,7 @@ player::EvaluateEntity(void)
SAVE_STATE(mag_dbs);
SAVE_STATE(mag_rpg);
SAVE_STATE(mag_glauncher);
SAVE_STATE(mag_pipebomb);
SAVE_STATE(m_iAmmoRockets);
SAVE_STATE(m_iAmmoNails);
@ -545,6 +552,7 @@ player::SendEntity(entity ePEnt, float flChanged)
WriteByte(MSG_ENTITY, mag_dbs);
WriteByte(MSG_ENTITY, mag_rpg);
WriteByte(MSG_ENTITY, mag_glauncher);
WriteByte(MSG_ENTITY, mag_pipebomb);
}
if (flChanged & PLAYER_AMMO2) {

View File

@ -80,13 +80,7 @@ void
w_glauncher_draw(player pl)
{
Weapons_SetModel("models/v_tfgl.mdl");
Weapons_ViewAnimation(pl, 0);
}
float
crandom(void)
{
return ((random() - 0.5f) * 2.0f);
Weapons_ViewAnimation(pl, GLAUNCHER_GDRAW);
}
void

View File

@ -17,17 +17,30 @@
void
w_pipebomb_precache(void)
{
precache_model("models/v_tfgl.mdl");
#ifdef SERVER
Sound_Precache("weapon_handgrenade.bounce");
Sound_Precache("weapon_mp5.gl");
precache_model("models/w_pipebomb.mdl");
precache_model("models/p_pipebomb.mdl");
precache_model("models/pipebomb.mdl");
#else
precache_model("models/v_tfgl.mdl");
#endif
}
void
w_pipebomb_updateammo(player pl)
{
Weapons_UpdateAmmo(pl, pl.mag_pipebomb, pl.m_iAmmoRockets, __NULL__);
}
int
w_pipebomb_pickup(player pl, int new, int startammo)
{
#ifdef SERVER
Weapons_UpdateAmmo(pl, __NULL__, __NULL__, __NULL__);
pl.mag_pipebomb = bound(0, pl.mag_pipebomb + 6, 6);
#endif
return (1);
}
string
@ -35,7 +48,6 @@ w_pipebomb_wmodel(void)
{
return "models/w_pipebomb.mdl";
}
string
w_pipebomb_pmodel(player pl)
{
@ -52,7 +64,120 @@ void
w_pipebomb_draw(player pl)
{
Weapons_SetModel("models/v_tfgl.mdl");
Weapons_ViewAnimation(pl, 0);
Weapons_ViewAnimation(pl, GLAUNCHER_PDRAW);
}
void
w_pipebomb_shootnade(player pl)
{
vector vecNadeVelocity;
static void w_pipebomb_shootnade_touch(void) {
Sound_Play(self, CHAN_BODY, "weapon_handgrenade.bounce");
if (vlen(self.velocity))
self.avelocity = g_vec_null;
}
Weapons_MakeVectors(pl);
vecNadeVelocity = v_forward * 600 + v_up * 200 + crandom() * v_right * 10 + crandom() * v_up * 10;
NSRenderableEntity eNade = spawn(NSRenderableEntity);
eNade.SetModel("models/pipebomb.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([300, 300, 300]);
eNade.SetAngles(vectoangles(eNade.GetVelocity()));
eNade.SetSkin(0);
eNade.touch = w_pipebomb_shootnade_touch;
Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.gl");
//eNade.traileffectnum = particleeffectnum("weapon_rpg.trail");
}
void
w_pipebomb_reload(player pl)
{
w_baseshotgun_reload(player::mag_pipebomb, player::m_iAmmoRockets, 6);
}
void
w_pipebomb_release(player pl)
{
int s = w_baseshotgun_release(player::mag_pipebomb, player::m_iAmmoRockets, 6);
switch (s) {
case SHOTGUN_IDLE:
Weapons_ViewAnimation(pl, GLAUNCHER_PIDLE);
pl.w_idle_next = 5.0f;
break;
case SHOTGUN_BUSY:
break;
case SHOTGUN_START_RELOAD:
Weapons_ViewAnimation(pl, GLAUNCHER_PRELOAD1);
break;
case SHOTGUN_RELOAD:
break;
case SHOTGUN_END_RELOAD:
Weapons_ViewAnimation(pl, GLAUNCHER_PRELOAD2);
break;
}
}
void
w_pipebomb_primary(player pl)
{
int s = w_baseprojectile_fire(pl, WEAPON_PIPEBOMB, player::mag_pipebomb, w_pipebomb_shootnade);
switch (s) {
case AUTO_FIRE_FAILED:
w_pipebomb_release(pl);
return;
break;
case AUTO_FIRED:
case AUTO_LAST:
Weapons_ViewAnimation(pl, GLAUNCHER_PFIRE);
Weapons_ViewPunchAngle(pl, [-1,0,0]);
pl.w_attack_next = 0.6f;
break;
case AUTO_EMPTY:
Weapons_ViewAnimation(pl, GLAUNCHER_PIDLE);
pl.w_attack_next = 0.2f;
break;
}
pl.w_idle_next = 0.6f;
}
void
w_pipebomb_postdraw(player pl)
{
#ifdef CLIENT
vector aicon_pos;
/* ammo counters */
HUD_DrawAmmo1();
HUD_DrawAmmo2();
/* ammo icon */
aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
drawsubpic(
aicon_pos,
[24,24],
"sprites/640hud7.spr_0.tga",
[120/256,72/128],
[24/256, 24/128],
g_hud_color,
pSeatLocal->m_flAmmo2Alpha,
DRAWFLAG_ADDITIVE
);
#endif
}
float
@ -99,13 +224,13 @@ weapon_t w_pipebomb =
.slot_pos = 1,
.draw = w_pipebomb_draw,
.holster = __NULL__,
.primary = __NULL__,
.primary = w_pipebomb_primary,
.secondary = __NULL__,
.reload = __NULL__,
.release = __NULL__,
.postdraw = __NULL__,
.reload = w_pipebomb_reload,
.release = w_pipebomb_release,
.postdraw = w_pipebomb_postdraw,
.precache = w_pipebomb_precache,
.pickup = __NULL__,
.pickup = w_pipebomb_pickup,
.updateammo = w_pipebomb_updateammo,
.wmodel = w_pipebomb_wmodel,
.pmodel = w_pipebomb_pmodel,