WEAPON_FLAMER: migrate the code over from They Hunger real quick

This commit is contained in:
Marco Cawthorne 2023-01-17 21:52:01 -08:00
parent 87b84272e3
commit 0d0a91c2df
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 164 additions and 24 deletions

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org> * Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
* Copyright (c) 2019-2020 Gethyn ThomasQuail <xylemon@posteo.net>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -14,44 +15,157 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
enum
{
EGON_IDLE1,
EGON_FIDGET1,
EGON_ALTFIREON,
EGON_ALTFIRECYCLE,
EGON_ALTFIREOFF,
EGON_FIRE1,
EGON_FIRE2,
EGON_FIRE3,
EGON_FIRE4,
EGON_DRAW,
EGON_HOLSTER
};
void void
w_flamer_precache(void) w_flamer_precache(void)
{ {
#ifdef SERVER
Sound_Precache("weapon_flame.fire");
precache_model("sprites/fthrow.spr");
#endif
precache_model("models/v_flame.mdl"); precache_model("models/v_flame.mdl");
precache_model("models/w_flamer.mdl"); precache_model("models/w_egon.mdl");
precache_model("models/p_flamer.mdl"); precache_model("models/p_egon.mdl");
} }
void void
w_flamer_updateammo(player pl) w_flamer_updateammo(player pl)
{ {
#ifdef SERVER Weapons_UpdateAmmo(pl, -1, pl.m_iAmmoCells, -1);
Weapons_UpdateAmmo(pl, __NULL__, __NULL__, __NULL__);
#endif
} }
string string
w_flamer_wmodel(void) w_flamer_wmodel(void)
{ {
return "models/w_flamer.mdl"; return "models/w_egon.mdl";
} }
string string
w_flamer_pmodel(player pl) w_flamer_pmodel(player pl)
{ {
return "models/p_flamer.mdl"; return "models/p_egon.mdl";
} }
string string
w_flamer_deathmsg(void) w_flamer_deathmsg(void)
{ {
return "%s was assaulted by %s's Assault Cannon."; return "%s burned to a crisp by %s's Flamethrower.";
}
int
w_flamer_pickup(player pl, int new, int startammo)
{
return (1);
} }
void void
w_flamer_draw(player pl) w_flamer_draw(player pl)
{ {
Weapons_SetModel("models/v_flame.mdl"); Weapons_SetModel("models/v_flame.mdl");
Weapons_ViewAnimation(pl, 0); Weapons_ViewAnimation(pl, EGON_DRAW);
}
void
w_flamer_holster(player pl)
{
}
void
w_flamer_primary(player pl)
{
if (pl.w_attack_next > 0.0)
return;
/* Ammo check */
if (pl.m_iAmmoCells <= 0)
return;
pl.m_iAmmoCells--;
Weapons_ViewAnimation(pl, EGON_FIRE1);
#ifdef SERVER
static void w_flamer_die(void) {
NSEntity::Destroy();
}
static void w_flamer_touch(entity target, entity source) {
NSEntity me = (NSEntity)source;
if (target.takedamage == DAMAGE_YES) {
NSSurfacePropEntity m = (NSSurfacePropEntity)target;
m.Ignite(source, 5.0f, WEAPON_FLAMER);
}
}
Sound_Play(pl, CHAN_WEAPON, "weapon_flame.fire");
NSProjectile ball = spawn(NSProjectile);
ball.SetModel("sprites/fthrow.spr");
ball.SetRenderMode(RM_ADDITIVE);
ball.SetOwner(pl);
ball.SetImpact(w_flamer_touch);
ball.AnimateOnce(0, 15, 0.1f);
// To be added to spec
// ball.Animate(0,15);
// ball.effects |= EF_BRIGHTLIGHT;
// Also will need check for water contents (so projectile will die underwater)
Weapons_MakeVectors(pl);
ball.SetOrigin(Weapons_GetCameraPos(pl) + (v_forward * 16));
ball.SetVelocity(v_forward * 300);
#endif
pl.w_attack_next = 0.2f;
pl.w_idle_next = 0.2f;
}
void
w_flamer_reload(player pl)
{
}
void
w_flamer_release(player pl)
{
if (pl.w_attack_next > 0)
return;
if (pl.w_idle_next > 0)
return;
Weapons_ViewAnimation(pl, EGON_IDLE1);
}
void
w_flamer_crosshair(player pl)
{
#ifdef CLIENT
static vector cross_pos;
cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12];
drawsubpic(cross_pos, [24,24], "sprites/crosshairs.spr_0.tga", [72/128,48/128], [0.1875, 0.1875], [1,1,1], 1, DRAWFLAG_NORMAL);
HUD_DrawAmmo2();
vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
drawsubpic(aicon_pos, [24,24], "sprites/640hud7.spr_0.tga", [0,96/128], [24/256, 24/128], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);
#endif
} }
float float
@ -64,14 +178,23 @@ void
w_flamer_hudpic(player pl, int selected, vector pos, float a) w_flamer_hudpic(player pl, int selected, vector pos, float a)
{ {
#ifdef CLIENT #ifdef CLIENT
vector hud_col;
if (pl.m_iAmmoCells == 0)
hud_col = [1,0,0];
else
hud_col = g_hud_color;
HUD_DrawAmmoBar(pos, pl.m_iAmmoCells, 200, a);
if (selected) { if (selected) {
drawsubpic( drawsubpic(
pos, pos,
[170,45], [170,45],
"sprites/tfchud07.spr_0.tga", "sprites/tfchud04.spr_0.tga",
[0,45/256], [0,45/256],
[170/256,45/256], [170/256,45/256],
g_hud_color, hud_col,
a, a,
DRAWFLAG_ADDITIVE DRAWFLAG_ADDITIVE
); );
@ -79,10 +202,10 @@ w_flamer_hudpic(player pl, int selected, vector pos, float a)
drawsubpic( drawsubpic(
pos, pos,
[170,45], [170,45],
"sprites/tfchud07.spr_0.tga", "sprites/tfchud03.spr_0.tga",
[0,45/256], [0,0/256],
[170/256,45/256], [170/256,45/256],
g_hud_color, hud_col,
a, a,
DRAWFLAG_ADDITIVE DRAWFLAG_ADDITIVE
); );
@ -90,26 +213,43 @@ w_flamer_hudpic(player pl, int selected, vector pos, float a)
#endif #endif
} }
int
w_flamer_isempty(player pl)
{
if (pl.m_iAmmoCells <= 0)
return 1;
return 0;
}
weapontype_t
w_flamer_type(player pl)
{
return WPNTYPE_RANGED;
}
weapon_t w_flamer = weapon_t w_flamer =
{ {
.name = "flamer", .name = "flamer",
.id = ITEM_FLAMER, .id = ITEM_FLAMER,
.slot = 3, .slot = 3,
.slot_pos = 3, .slot_pos = 2,
.draw = w_flamer_draw, .draw = w_flamer_draw,
.holster = __NULL__, .holster = __NULL__,
.primary = __NULL__, .primary = w_flamer_primary,
.secondary = __NULL__, .secondary = w_flamer_release,
.reload = __NULL__, .reload = __NULL__,
.release = __NULL__, .release = w_flamer_release,
.postdraw = __NULL__, .postdraw = w_flamer_crosshair,
.precache = w_flamer_precache, .precache = w_flamer_precache,
.pickup = __NULL__, .pickup = w_flamer_pickup,
.updateammo = w_flamer_updateammo, .updateammo = w_flamer_updateammo,
.wmodel = w_flamer_wmodel, .wmodel = w_flamer_wmodel,
.pmodel = w_flamer_pmodel, .pmodel = w_flamer_pmodel,
.deathmsg = w_flamer_deathmsg, .deathmsg = w_flamer_deathmsg,
.aimanim = w_flamer_aimanim, .aimanim = w_flamer_aimanim,
.hudpic = w_flamer_hudpic, .isempty = w_flamer_isempty,
.isempty = w_asscan_isempty .type = w_flamer_type,
.hudpic = w_flamer_hudpic
}; };