hhdeath/src/shared/w_glove.qc

283 lines
5.6 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.
*/
/*QUAKED item_rune_slasher (0 0 1) (-16 -16 0) (16 16 32)
"model" "models/rune_slasher.mdl"
Household DEATH! (2003) ENTITY
Powerup/Weapon that turns players into a similar looking legally
copyrighted character.
*/
enum
{
GLOVE_IDLE,
GLOVE_DRAW,
GLOVE_HOLSTER,
GLOVE_SLICE,
GLOVE_DICE
};
void
w_glove_precache(void)
{
#ifdef SERVER
Sound_Precache("weapon_glove.hit");
Sound_Precache("weapon_glove.miss");
Sound_Precache("weapon_glove.hitbody");
Sound_Precache("weapon_glove.pickup");
precache_model("models/rune_slasher.mdl");
#else
precache_model("models/v_glove.mdl");
precache_model("models/p_glove.mdl");
#endif
}
void
w_glove_updateammo(player pl)
{
w_broom_updateammo(pl);
}
string
w_glove_wmodel(void)
{
return "models/rune_slasher.mdl";
}
string
w_glove_pmodel(player pl)
{
return "models/p_glove.mdl";
}
string
w_glove_deathmsg(void)
{
return "";
}
int
w_glove_pickup(player pl, int new, int startammo)
{
#ifdef SERVER
/* Broadcast a message and sound upon picking up Rune */
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_TEXT);
WriteByte(MSG_MULTICAST, 0);
WriteString(MSG_MULTICAST, sprintf("One... Two... %s's coming for you...", self.netname));
WriteFloat(MSG_MULTICAST, -1);
WriteFloat(MSG_MULTICAST, -1);
WriteByte(MSG_MULTICAST, 0);
WriteByte(MSG_MULTICAST, 255);
WriteByte(MSG_MULTICAST, 0);
WriteByte(MSG_MULTICAST, 0);
WriteByte(MSG_MULTICAST, 255);
WriteByte(MSG_MULTICAST, 0);
WriteByte(MSG_MULTICAST, 0);
WriteFloat(MSG_MULTICAST, 0.2);
WriteFloat(MSG_MULTICAST, 0.5);
WriteFloat(MSG_MULTICAST, 5.0);
WriteFloat(MSG_MULTICAST, 0);
msg_entity = world;
multicast([0,0,0], MULTICAST_ALL);
Sound_Play(self, CHAN_ITEM, "weapon_glove.pickup");
#endif
return (1);
}
void
w_glove_draw(player pl)
{
Weapons_SetModel("models/v_glove.mdl");
Weapons_ViewAnimation(pl, GLOVE_DRAW);
}
void
w_glove_holster(player pl)
{
Weapons_ViewAnimation(pl, GLOVE_HOLSTER);
}
void
w_glove_primary(player pl)
{
int anim = 0;
int r = 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);
if (trace_fraction >= 1.0) {
pl.w_attack_next = 0.5f;
} else {
pl.w_attack_next = 0.25f;
}
pl.w_idle_next = 2.5f;
r = (float)input_sequence % 2;
switch (r) {
case 1:
Weapons_ViewAnimation(pl, GLOVE_SLICE);
pl.w_idle_next = 3.6f;
break;
default:
Weapons_ViewAnimation(pl, GLOVE_DICE);
pl.w_idle_next = 3.6f;
break;
}
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_glove.miss");
if (trace_fraction >= 1.0) {
return;
}
/* Since it has custom decals we do both FX and decal placement */
if (trace_ent.iBleeds) {
FX_Blood(trace_endpos, [1,0,0]);
} else {
pointparticles(particleeffectnum("fx_spark.main"), trace_endpos, trace_plane_normal, 1);
r = (float)input_sequence % 2;
Decals_Place(trace_endpos, r == 1 ? "{slash1" : "{slash2");
}
if (trace_ent.takedamage) {
Damage_Apply(trace_ent, pl, Skill_GetValue("plr_crowbar", 10), WEAPON_GLOVE, DMG_BLUNT);
if (trace_ent.iBleeds) {
Sound_Play(self, CHAN_WEAPON, "weapon_glove.hitbody");
}
} else {
Sound_Play(self, CHAN_WEAPON, "weapon_glove.hit");
}
#endif
}
void
w_glove_release(player pl)
{
if (pl.w_idle_next) {
return;
}
Weapons_ViewAnimation(pl, GLOVE_IDLE);
pl.w_idle_next = 2.0f;
}
float
w_glove_aimanim(player pl)
{
return w_broom_aimanim(pl);
}
void
w_glove_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
drawsubpic(
pos,
[170,45],
"sprites/tfchud04.spr_0.tga",
[0,135/256],
[170/256,45/256],
g_hud_color,
a,
DRAWFLAG_ADDITIVE
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/tfchud03.spr_0.tga",
[0,90/256],
[170/256,45/256],
g_hud_color,
a,
DRAWFLAG_ADDITIVE
);
}
#endif
}
int
w_glove_isempty(player pl)
{
return 0;
}
weapontype_t w_glove_type(player pl)
{
return WPNTYPE_CLOSE;
}
weapon_t w_glove =
{
.name = "glove",
.id = ITEM_GLOVE,
.slot = 1,
.slot_pos = 0,
.draw = w_glove_draw,
.holster = w_glove_holster,
.primary = w_glove_primary,
.secondary = __NULL__,
.reload = __NULL__,
.release = w_glove_release,
.postdraw = __NULL__,
.precache = w_glove_precache,
.pickup = w_glove_pickup,
.updateammo = w_glove_updateammo,
.wmodel = w_glove_wmodel,
.pmodel = w_glove_pmodel,
.deathmsg = w_glove_deathmsg,
.aimanim = w_glove_aimanim,
.hudpic = w_glove_hudpic,
.weight = -10,
.isempty = w_glove_isempty,
.type = w_glove_type
};
/* entity definitions for pickups */
#ifdef SERVER
void
item_rune_slasher(void)
{
Weapons_InitItem(WEAPON_GLOVE);
}
#endif