hhdeath/src/shared/w_fryingpan.qc

271 lines
5.2 KiB
Plaintext

/*
* Copyright (c) 2016-2020 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
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
enum
{
FRYINGPAN_IDLE1,
FRYINGPAN_IDLE2,
FRYINGPAN_HIT1,
FRYINGPAN_HIT2,
FRYINGPAN_DRAW,
FRYINGPAN_HOLSTER
};
void
w_fryingpan_precache(void)
{
#ifdef SERVER
Sound_Precache("weapon_fryingpan.hit");
Sound_Precache("weapon_fryingpan.miss");
Sound_Precache("weapon_fryingpan.hitbody");
precache_model("models/w_pan.mdl");
#else
precache_model("models/v_pan.mdl");
precache_model("models/p_pan.mdl");
#endif
}
void
w_fryingpan_updateammo(player pl)
{
w_broom_updateammo(pl);
}
string
w_fryingpan_wmodel(void)
{
return "models/w_pan.mdl";
}
string
w_fryingpan_pmodel(player pl)
{
return "models/p_pan.mdl";
}
string
w_fryingpan_deathmsg(void)
{
return "";
}
void
w_fryingpan_draw(player pl)
{
Weapons_SetModel("models/v_pan.mdl");
Weapons_ViewAnimation(pl, FRYINGPAN_DRAW);
}
void
w_fryingpan_holster(player pl)
{
w_broom_holster(pl);
}
void
w_fryingpan_primary(player pl)
{
int anim = 0;
vector src;
if (pl.w_attack_next) {
return;
}
Weapons_MakeVectors(pl);
src = pl.origin + pl.view_ofs;
traceline(src, src + (v_forward * 32), FALSE, pl);
pl.w_attack_next = 1.0f;
pl.w_idle_next = 2.5f;
Weapons_ViewAnimation(pl, FRYINGPAN_HIT1);
if (pl.flags & FL_CROUCHING) {
Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f);
} else {
Animation_PlayerTop(pl, ANIM_CR_SHOOTCROWBAR, 0.42f);
}
#ifdef SERVER
Sound_Play(self, CHAN_WEAPON, "weapon_fryingpan.miss");
if (trace_fraction >= 1.0) {
return;
}
/* don't bother with decals, we got squibs */
if (trace_ent.iBleeds) {
FX_Blood(trace_endpos, [1,0,0]);
} else {
SurfData_Impact(trace_ent, trace_endpos, trace_plane_normal);
}
if (trace_ent.takedamage) {
Damage_Apply(trace_ent, pl, 5, WEAPON_FRYINGPAN, DMG_BLUNT);
if (trace_ent.iBleeds) {
Sound_Play(self, CHAN_WEAPON, "weapon_fryingpan.hitbody");
}
} else {
Sound_Play(self, CHAN_WEAPON, "weapon_fryingpan.hit");
}
#endif
}
void
w_fryingpan_secondary(player pl)
{
int anim = 0;
vector src;
if (pl.w_attack_next) {
return;
}
Weapons_MakeVectors(pl);
src = pl.origin + pl.view_ofs;
traceline(src, src + (v_forward * 32), FALSE, pl);
pl.w_attack_next = 1.0f;
pl.w_idle_next = 2.5f;
Weapons_ViewAnimation(pl, FRYINGPAN_HIT2);
if (pl.flags & FL_CROUCHING) {
Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f);
} else {
Animation_PlayerTop(pl, ANIM_CR_SHOOTCROWBAR, 0.42f);
}
#ifdef SERVER
Sound_Play(self, CHAN_WEAPON, "weapon_fryingpan.miss");
if (trace_fraction >= 1.0) {
return;
}
/* don't bother with decals, we got squibs */
if (trace_ent.iBleeds) {
FX_Blood(trace_endpos, [1,0,0]);
} else {
SurfData_Impact(trace_ent, trace_endpos, trace_plane_normal);
}
if (trace_ent.takedamage) {
Damage_Apply(trace_ent, pl, 5, WEAPON_FRYINGPAN, DMG_BLUNT);
if (trace_ent.iBleeds) {
Sound_Play(self, CHAN_WEAPON, "weapon_fryingpan.hitbody");
}
} else {
Sound_Play(self, CHAN_WEAPON, "weapon_fryingpan.hit");
}
#endif
}
void
w_fryingpan_release(player pl)
{
w_broom_release(pl);
}
float
w_fryingpan_aimanim(player pl)
{
return w_broom_aimanim(pl);
}
int
w_fryingpan_isempty(player pl)
{
return 0;
}
void
w_fryingpan_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (w_fryingpan_isempty(pl)) {
drawsubpic(
pos,
[80,40],
g_sprWeapons,
[80/256,40/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[80,40],
g_sprWeapons,
[0,40/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_fryingpan_type(player pl)
{
return WPNTYPE_CLOSE;
}
weapon_t w_fryingpan =
{
.name = "fryingpan",
.id = ITEM_FRYINGPAN,
.slot = 0,
.slot_pos = 1,
.draw = w_fryingpan_draw,
.holster = w_fryingpan_holster,
.primary = w_fryingpan_primary,
.secondary = w_fryingpan_secondary,
.reload = __NULL__,
.release = w_fryingpan_release,
.postdraw = __NULL__,
.precache = w_fryingpan_precache,
.pickup = __NULL__,
.updateammo = w_fryingpan_updateammo,
.wmodel = w_fryingpan_wmodel,
.pmodel = w_fryingpan_pmodel,
.deathmsg = w_fryingpan_deathmsg,
.aimanim = w_fryingpan_aimanim,
.hudpic = w_fryingpan_hudpic,
.weight = -10,
.isempty = w_fryingpan_isempty,
.type = w_fryingpan_type
};
/* entity definitions for pickups */
#ifdef SERVER
void
weapon_fryingpan(void)
{
Weapons_InitItem(WEAPON_FRYINGPAN);
/*item_pickup item = (item_pickup)self;
item.SetRenderMode(RM_FULLBRIGHT);
item.SetRenderAmt(1.0f);*/
}
#endif