Lots of HUD, weapon improvements etc.

This commit is contained in:
Marco Cawthorne 2024-02-28 22:20:28 -08:00
parent 10477a7db5
commit 42e7b79622
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
26 changed files with 759 additions and 239 deletions

5
src/client/defs.h Normal file
View File

@ -0,0 +1,5 @@
var string g_crossFork;
var string g_crossSoda;
var string g_sprWeapons;
var string g_crossKnife;

View File

@ -0,0 +1,244 @@
/*
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
*
* 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.
*/
vector g_vecHUDNums[6] =
{
[168 / 256, 72 / 128],
[188 / 256, 72 / 128],
[208 / 256, 72 / 128],
[168 / 256, 92 / 128],
[188 / 256, 92 / 128],
[208 / 256, 92 / 128]
};
bool
HUD_DrawWeaponSelect_CanSwitch(player pl)
{
if (!pl.activeweapon)
return false;
for (int i = 1; i < g_weapons.length; i++) {
if (g_weapons[i].slot == 0 && pl.g_items & g_weapons[i].id && g_weapons[i].isempty(pl) == false) {
return true;
}
}
return false;
}
void
HUD_DrawWeaponSelect_Forward(void)
{
player pl = (player)pSeat->m_ePlayer;
if (HUD_DrawWeaponSelect_CanSwitch(pl) == false) {
pSeat->m_flHUDWeaponSelectTime = time + 3;
pSeat->m_iHUDWeaponSelected = pl.activeweapon;
return;
}
if (pSeat->m_flHUDWeaponSelectTime < time) {
pSeat->m_iHUDWeaponSelected = pl.activeweapon;
Sound_Play(pSeat->m_ePlayer, CHAN_ITEM, "Player.WeaponSelectionOpen");
} else {
Sound_Play(pSeat->m_ePlayer, CHAN_ITEM, "Player.WeaponSelectionMoveSlot");
pSeat->m_iHUDWeaponSelected--;
if (pSeat->m_iHUDWeaponSelected <= 0) {
pSeat->m_iHUDWeaponSelected = g_weapons.length - 1;
}
}
pSeat->m_flHUDWeaponSelectTime = time + 3;
if not (pl.g_items & g_weapons[pSeat->m_iHUDWeaponSelected].id)
HUD_DrawWeaponSelect_Forward();
else if (g_weapons[pSeat->m_iHUDWeaponSelected].isempty)
if (g_weapons[pSeat->m_iHUDWeaponSelected].isempty(pl) || g_weapons[pSeat->m_iHUDWeaponSelected].slot != 0 )
HUD_DrawWeaponSelect_Forward();
}
void
HUD_DrawWeaponSelect_Back(void)
{
player pl = (player)pSeat->m_ePlayer;
if (HUD_DrawWeaponSelect_CanSwitch(pl) == false) {
pSeat->m_flHUDWeaponSelectTime = time + 3;
pSeat->m_iHUDWeaponSelected = pl.activeweapon;
return;
}
if (pSeat->m_flHUDWeaponSelectTime < time) {
pSeat->m_iHUDWeaponSelected = pl.activeweapon;
Sound_Play(pSeat->m_ePlayer, CHAN_ITEM, "Player.WeaponSelectionOpen");
} else {
Sound_Play(pSeat->m_ePlayer, CHAN_ITEM, "Player.WeaponSelectionMoveSlot");
pSeat->m_iHUDWeaponSelected++;
if (pSeat->m_iHUDWeaponSelected >= g_weapons.length) {
pSeat->m_iHUDWeaponSelected = 1;
}
}
pSeat->m_flHUDWeaponSelectTime = time + 3;
if not (pl.g_items & g_weapons[pSeat->m_iHUDWeaponSelected].id)
HUD_DrawWeaponSelect_Back();
else if (g_weapons[pSeat->m_iHUDWeaponSelected].isempty)
if (g_weapons[pSeat->m_iHUDWeaponSelected].isempty(pl) || g_weapons[pSeat->m_iHUDWeaponSelected].slot != 0 )
HUD_DrawWeaponSelect_Back();
}
void
View_ForceChange(player pl, int targetWeapon);
void
HUD_DrawWeaponSelect_Trigger(void)
{
player pl = (player)pSeat->m_ePlayer;
if (pl.activeweapon != pSeat->m_iHUDWeaponSelected)
View_ForceChange(pl, pSeat->m_iHUDWeaponSelected);
Sound_Play(pSeat->m_ePlayer, CHAN_ITEM, "Player.WeaponSelected");
pSeat->m_iHUDWeaponSelected = pSeat->m_flHUDWeaponSelectTime = 0;
}
void
HUD_DrawWeaponSelect_Last(void)
{
player pl = (player)pSeat->m_ePlayer;
if (pl.g_items & g_weapons[pSeat->m_iOldWeapon].id) {
View_ForceChange(pl, pSeat->m_iOldWeapon);
}
}
int
HUD_InSlotPos(int slot, int pos)
{
player pl = (player)pSeat->m_ePlayer;
for (int i = 1; i < g_weapons.length; i++) {
if (g_weapons[i].slot == slot && g_weapons[i].slot_pos == pos) {
if (pl.g_items & g_weapons[i].id) {
return i;
} else {
return (-1);
}
}
}
return (-1);
}
void
HUD_SlotSelect(int slot)
{
player pl = (player)pSeat->m_ePlayer;
int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot;
int i;
/* when we have a special weapon equipped, we can't switch */
if (curslot != 0)
return;
if (g_textmenu != "") {
Textmenu_Input(slot);
return;
}
/* hack to see if we have ANY weapons at all. */
if (!pl.activeweapon) {
return;
}
if (pSeat->m_flHUDWeaponSelectTime < time) {
pl.StartSoundDef("Player.WeaponSelectionOpen", CHAN_ITEM, false);
} else {
pl.StartSoundDef("Player.WeaponSelectionMoveSlot", CHAN_ITEM, false);
}
/* weren't in that slot? select the first one then */
if (curslot != slot) {
for (i = 1; i < g_weapons.length; i++) {
if (g_weapons[i].slot == slot && pl.g_items & g_weapons[i].id) {
pSeat->m_iHUDWeaponSelected = i;
pSeat->m_flHUDWeaponSelectTime = time + 3;
break;
}
}
} else {
int first = -1;
for (i = 1; i < g_weapons.length; i++) {
if (g_weapons[i].slot == slot && pl.g_items & g_weapons[i].id) {
if (i < pSeat->m_iHUDWeaponSelected && first == -1) {
first = i;
} else if (i > pSeat->m_iHUDWeaponSelected) {
first = -1;
pSeat->m_iHUDWeaponSelected = i;
pSeat->m_flHUDWeaponSelectTime = time + 3;
break;
}
}
}
if (first > 0) {
pSeat->m_iHUDWeaponSelected = first;
pSeat->m_flHUDWeaponSelectTime = time + 3;
}
}
}
void
HUD_DrawWeaponSelect(void)
{
player pl = (player)pSeat->m_ePlayer;
if (!pl.activeweapon) {
return;
}
if (pSeat->m_flHUDWeaponSelectTime < time) {
if (pSeat->m_iHUDWeaponSelected) {
Sound_Play(pSeat->m_ePlayer, CHAN_ITEM, "Player.WeaponSelectionClose");
pSeat->m_iHUDWeaponSelected = 0;
}
return;
}
vector vecPos = g_hudmins + [16,16];
int b;
int wantslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot;
int wantpos = g_weapons[pSeat->m_iHUDWeaponSelected].slot_pos;
int i = 0;
int slot_selected = 0;
for (int x = 0; x < 32; x++) {
if (i == wantslot) {
slot_selected = TRUE;
if (x == wantpos) {
// Selected Sprite
Weapons_HUDPic(pl, pSeat->m_iHUDWeaponSelected, 1, vecPos, 1.0f);
drawsubpic(vecPos, [80,40], g_sprWeapons,
[160/256,200/256], [80/256,40/256], [1,1,1], 1, DRAWFLAG_ADDITIVE);
vecPos[1] += 40;
} else if ((b=HUD_InSlotPos(i, x)) != -1) {
// Unselected Sprite
Weapons_HUDPic(pl, b, 0, vecPos, 1.0f);
vecPos[1] += 40;
}
} else if (HUD_InSlotPos(i, x) != -1) {
vecPos[1] += 25;
}
}
}

View File

@ -16,7 +16,6 @@
float(entity foo, float chanid) getchannellevel = #0;
/*
=================
ClientGame_Init
@ -49,4 +48,5 @@ ClientGame_RendererRestart(string rstr)
precache_model("sprites/640_numbers.spr");
precache_model("sprites/640_suit.spr");
precache_model("sprites/640hud7.spr");
g_sprWeapons = spriteframe("sprites/640_weapons_a.spr", 0, 0.0f);
}

View File

@ -12,6 +12,7 @@
../../../src/shared/defs.h
../../../valve/src/client/defs.h
../../../src/client/defs.h
defs.h
../../../src/vgui/include.src
@ -32,7 +33,7 @@ obituary.qc
../../../valve/src/client/hud_sprite.qc
../../../valve/src/client/hud_dmgnotify.qc
hud.qc
../../../valve/src/client/hud_weaponselect.qc
hud_weaponselect.qc
../../../valve/src/client/scoreboard.qc
../../../src/client/include.src

View File

@ -129,6 +129,10 @@ HHDMultiplayerRules::PlayerSpawn(NSClientPlayer pp)
pl.activeweapon = WEAPON_BROOM;
Weapons_RefreshAmmo(pl);
for (int i = 1; i < g_weapons.length; i++) {
Weapons_AddItem(pl, i, -1);
}
Client_FixAngle(pl, pl.angles);
}

View File

@ -69,7 +69,9 @@ FX_Lego(vector pos)
setmodel(eSmoke, "sprites/stmbal1.spr");
Sound_Play(eSmoke, CHAN_WEAPON, "weapon_lego.explode");
eSmoke.effects = EF_ADDITIVE;
eSmoke.SetRenderMode(RM_ADDITIVE);
eSmoke.SetRenderColor([1,1,1]);
eSmoke.SetRenderAmt(1.0f);
eSmoke.drawmask = MASK_ENGINE;
eSmoke.SetMaxFrame(modelframecount(eSmoke.modelindex));
eSmoke.SetLoopFlag(false);

View File

@ -83,11 +83,13 @@ FX_Soda(vector pos, int col)
eSoda.SetMaxFrame(modelframecount(eSoda.modelindex));
eSoda.SetLoopFlag(false);
eSoda.SetRenderColor(color);
eSoda.SetRenderMode(RM_ADDITIVE);
eSoda.SetFramerate(20);
eSoda.nextthink = time + 0.05f;
static void Soda_Remove(void) {
remove(self);
NSEntity me = (NSEntity)self;
me.Destroy();
}
/* Has a dripping effect from spill */
@ -98,11 +100,12 @@ FX_Soda(vector pos, int col)
eSodaPart.movetype = MOVETYPE_TOSS;
eSodaPart.gravity = 0.3f;
eSodaPart.scale = 0.5f;
eSodaPart.effects = EF_ADDITIVE;
eSodaPart.SetRenderMode(RM_ADDITIVE);
eSodaPart.SetRenderAmt(1.0);
eSodaPart.drawmask = MASK_ENGINE;
eSodaPart.SetMaxFrame(modelframecount(eSodaPart.modelindex));
eSodaPart.SetLoopFlag(true);
eSodaPart.m_vecRenderColor = color;
eSodaPart.SetRenderColor(color);
eSodaPart.SetFramerate(10);
eSodaPart.touch = Soda_Remove;
eSodaPart.nextthink = time + 0.1f;

View File

@ -59,6 +59,8 @@ class player:NSClientPlayer
PREDICTED_INT(ammo_soda)
PREDICTED_INT(ammo_spray)
PREDICTED_INT(soda_choice)
#ifdef CLIENT
virtual void(float,float) ReceiveEntity;
virtual void(void) PredictPreFrame;
@ -107,6 +109,7 @@ player::ReceiveEntity(float new, float fl)
}
if (fl & PLAYER_AMMO3) {
soda_choice = readbyte();
}
if (fl & PLAYER_AMMO1 || fl & PLAYER_AMMO2 || fl & PLAYER_AMMO3)
@ -140,6 +143,8 @@ player::PredictPreFrame(void)
SAVE_STATE(ammo_legos);
SAVE_STATE(ammo_soda);
SAVE_STATE(ammo_spray);
SAVE_STATE(soda_choice);
}
/*
@ -166,6 +171,8 @@ player::PredictPostFrame(void)
ROLL_BACK(ammo_legos);
ROLL_BACK(ammo_soda);
ROLL_BACK(ammo_spray);
ROLL_BACK(soda_choice);
}
#else
@ -193,6 +200,9 @@ player::EvaluateEntity(void)
if (ATTR_CHANGED(ammo_spray))
SendFlags |= PLAYER_AMMO2;
if (ATTR_CHANGED(soda_choice))
SendFlags |= PLAYER_AMMO3;
SAVE_STATE(anim_top);
SAVE_STATE(anim_top_time);
SAVE_STATE(anim_top_delay);
@ -205,6 +215,8 @@ player::EvaluateEntity(void)
SAVE_STATE(ammo_legos);
SAVE_STATE(ammo_soda);
SAVE_STATE(ammo_spray);
SAVE_STATE(soda_choice);
}
/*
@ -259,6 +271,7 @@ player::SendEntity(entity ePEnt, float fChanged)
}
if (fChanged & PLAYER_AMMO3) {
WriteByte(MSG_ENTITY, soda_choice);
}
return (1);

View File

@ -166,42 +166,54 @@ w_broom_aimanim(player pl)
return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR;
}
int
w_broom_isempty(player pl)
{
return 0;
}
void
w_broom_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
if (w_broom_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/640hud4.spr_0.tga",
[0,0],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[80/256,0],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/640hud1.spr_0.tga",
[80,40],
g_sprWeapons,
[0,0],
[170/256,45/256],
g_hud_color,
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_broom_type(player pl)
{
return WPNTYPE_CLOSE;
}
weapon_t w_broom =
{
.name = "broom",
.id = ITEM_BROOM,
.slot = 0,
.slot_pos = 0,
.weight = -10,
.draw = w_broom_draw,
.holster = w_broom_holster,
.primary = w_broom_primary,
@ -216,7 +228,9 @@ weapon_t w_broom =
.pmodel = w_broom_pmodel,
.deathmsg = w_broom_deathmsg,
.aimanim = w_broom_aimanim,
.hudpic = w_broom_hudpic
.hudpic = w_broom_hudpic,
.isempty = w_broom_isempty,
.type = w_broom_type
};
/* entity definitions for pickups */

View File

@ -51,6 +51,7 @@ w_forks_precache(void)
precache_model("sprites/hud_fork.spr");
precache_model("models/v_fork.mdl");
precache_model("models/p_fork.mdl");
g_crossFork = spriteframe("sprites/cross_fork.spr", 0, 0.0);
#endif
}
@ -94,6 +95,12 @@ w_forks_draw(player pl)
{
Weapons_SetModel("models/v_fork.mdl");
Weapons_ViewAnimation(pl, FORKS_DRAW);
#ifdef SERVER
if (!pl.ammo_forks) {
Weapons_RemoveItem(pl, WEAPON_FORKS);
}
#endif
}
void
@ -161,15 +168,9 @@ w_forks_secondary(player pl)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_forks <= 0) {
return;
}
#else
if (pl.ammo_forks <= 0) {
return;
}
#endif
/* Secondary has an ammo based throw function */
#ifdef SERVER
@ -206,10 +207,11 @@ w_forks_secondary(player pl)
fork.touch = Fork_Touch;
setsize(fork, [0,0,0], [0,0,0]);
pl.ammo_forks--;
Sound_Play(pl, CHAN_WEAPON, "weapon_forks.throw");
#endif
pl.ammo_forks--;
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, FORKS_THROW);
@ -220,8 +222,14 @@ w_forks_secondary(player pl)
void
w_forks_release(player pl)
{
if (pl.w_idle_next > 0.0) {
if (pl.w_attack_next <= 0.0) {
#ifdef SERVER
if (!pl.ammo_forks) {
Weapons_RemoveItem(pl, WEAPON_FORKS);
}
#endif
}
return;
}
@ -247,14 +255,14 @@ w_forks_crosshair(player pl)
{
#ifdef CLIENT
static vector cross_pos;
cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12];
cross_pos = g_hudmins + (g_hudres / 2) + [-16,-16];
drawsubpic(
cross_pos,
[24,24],
"sprites/crosshairs.spr_0.tga",
[72/128,48/128],
[0.1875, 0.1875],
[1,1,1],
[32,32],
g_crossFork,
[0,0],
[1, 1],
[1,0,0],
1,
DRAWFLAG_NORMAL
);
@ -279,36 +287,47 @@ w_forks_aimanim(player pl)
return w_broom_aimanim(pl);
}
int
w_forks_isempty(player pl)
{
return (pl.ammo_forks <= 0) ? true : false;
}
void
w_forks_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
if (w_forks_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/tfchud04.spr_0.tga",
[0,135/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[80/256,80/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/tfchud03.spr_0.tga",
[0,90/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[0,80/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_forks_type(player pl)
{
return WPNTYPE_RANGED;
}
weapon_t w_forks =
{
.name = "fork",
@ -329,7 +348,10 @@ weapon_t w_forks =
.pmodel = w_forks_pmodel,
.deathmsg = w_forks_deathmsg,
.aimanim = w_forks_aimanim,
.hudpic = w_forks_hudpic
.hudpic = w_forks_hudpic,
.weight = -10,
.isempty = w_forks_isempty,
.type = w_forks_type
};
/* entity definitions for pickups */

View File

@ -190,36 +190,47 @@ 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 (selected) {
if (w_fryingpan_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/tfchud04.spr_0.tga",
[0,135/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[80/256,40/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/tfchud03.spr_0.tga",
[0,90/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[0,40/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_fryingpan_type(player pl)
{
return WPNTYPE_CLOSE;
}
weapon_t w_fryingpan =
{
.name = "fryingpan",
@ -240,7 +251,10 @@ weapon_t w_fryingpan =
.pmodel = w_fryingpan_pmodel,
.deathmsg = w_fryingpan_deathmsg,
.aimanim = w_fryingpan_aimanim,
.hudpic = w_fryingpan_hudpic
.hudpic = w_fryingpan_hudpic,
.weight = -10,
.isempty = w_fryingpan_isempty,
.type = w_fryingpan_type
};
/* entity definitions for pickups */

View File

@ -235,6 +235,17 @@ w_glove_hudpic(player pl, int selected, vector pos, float a)
#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",
@ -255,7 +266,10 @@ weapon_t w_glove =
.pmodel = w_glove_pmodel,
.deathmsg = w_glove_deathmsg,
.aimanim = w_glove_aimanim,
.hudpic = w_glove_hudpic
.hudpic = w_glove_hudpic,
.weight = -10,
.isempty = w_glove_isempty,
.type = w_glove_type
};
/* entity definitions for pickups */

View File

@ -121,40 +121,49 @@ w_hairspray_primary(player pl)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_spray <= 0) {
return;
}
#else
if (pl.ammo_spray <= 0) {
return;
}
#endif
/* Actual firing */
#ifdef CLIENT
Weapons_ViewAnimation(pl, HAIRSPRAY_FIRE);
pl.ammo_spray--;
#else
Weapons_MakeVectors(pl);
entity flame = spawn();
setmodel(flame, "sprites/flame.spr");
setorigin(flame, Weapons_GetCameraPos(pl) + (v_forward * 16));
flame.owner = self;
flame.velocity = v_forward * 300;
flame.movetype = MOVETYPE_FLYMISSILE;
flame.solid = SOLID_BBOX;
//flame.flags |= FL_LAGGEDMOVE;
flame.angles = vectoangles(flame.velocity);
flame.avelocity[2] = 10;
flame.touch = Flame_Touch;
flame.think = Flame_Touch;
flame.nextthink = time + 1.0f;
flame.effects |= EF_BRIGHTLIGHT;
setsize(flame, [0,0,0], [0,0,0]);
pl.ammo_spray--;
/* Actual firing */
#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_HAIRSPRAY);
}
}
Sound_Play(pl, CHAN_WEAPON, "weapon_hairspray.fire");
NSProjectile ball = spawn(NSProjectile);
ball.SetModel("sprites/flame.spr");
ball.SetRenderMode(RM_ADDITIVE);
ball.SetRenderColor([1,1,1]);
ball.SetRenderAmt(1.0);
ball.SetOwner(pl);
ball.SetImpact(w_flamer_touch);
ball.AnimateOnce(0, 28, 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);
/* Remove weapon if we run out of ammo */
if (pl.ammo_spray <= 0) {
@ -163,7 +172,7 @@ w_hairspray_primary(player pl)
}
#endif
pl.w_attack_next = 0.2f;
pl.w_attack_next = 0.1f;
pl.w_idle_next = 2.5f;
}
@ -187,11 +196,11 @@ w_hairspray_crosshair(player pl)
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],
[32,32],
g_crossSoda,
[0,0],
[1, 1],
[1,0,0],
1,
DRAWFLAG_NORMAL
);
@ -216,36 +225,47 @@ w_hairspray_aimanim(player pl)
return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW;
}
int
w_hairspray_isempty(player pl)
{
return 0;
}
void
w_hairspray_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
if (w_hairspray_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/tfchud04.spr_0.tga",
[0,45/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[160/256,40/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/tfchud03.spr_0.tga",
[0,0/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[160/256,0],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_hairspray_type(player pl)
{
return WPNTYPE_CLOSE;
}
weapon_t w_hairspray =
{
.name = "flame",
@ -266,7 +286,10 @@ weapon_t w_hairspray =
.pmodel = w_hairspray_pmodel,
.deathmsg = w_hairspray_deathmsg,
.aimanim = w_hairspray_aimanim,
.hudpic = w_hairspray_hudpic
.hudpic = w_hairspray_hudpic,
.weight = -10,
.isempty = w_hairspray_isempty,
.type = w_hairspray_type
};
#ifdef SERVER

View File

@ -47,6 +47,7 @@ w_knife_precache(void)
precache_model("sprites/hud_knife.spr");
precache_model("models/v_knife.mdl");
precache_model("models/p_knife.mdl");
g_crossKnife = spriteframe("sprites/cross_knife.spr", 0, 0.0);
#endif
}
@ -110,15 +111,9 @@ w_knife_primary(player pl)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_knives <= 0) {
return;
}
#else
if (pl.ammo_knives <= 0) {
return;
}
#endif
/* Actual firing */
#ifdef SERVER
@ -162,7 +157,6 @@ w_knife_primary(player pl)
/* The thrown knife has it's own movement sound */
Sound_Play(knife, CHAN_WEAPON, "weapon_knife.move");
pl.ammo_knives--;
Sound_Play(pl, CHAN_WEAPON, "weapon_knife.throw");
/* Remove weapon if we run out of knives */
@ -171,13 +165,15 @@ w_knife_primary(player pl)
return;
}
#else
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, KNIFE_THROW);
/* Knife randomly changes submodel upon firing */
int r = (float)input_sequence % 2;
Weapons_SetGeomset(r == 1 ? "geomset 0 0\n" : "geomset 0 1\n");
#endif
pl.ammo_knives--;
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, KNIFE_THROW);
pl.w_attack_next = 0.8f;
pl.w_idle_next = 5.0f;
}
@ -215,11 +211,11 @@ w_knife_crosshair(player pl)
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],
[32,32],
g_crossKnife,
[0,0],
[1, 1],
[1,0,0],
1,
DRAWFLAG_NORMAL
);
@ -244,36 +240,47 @@ w_knife_aimanim(player pl)
return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW;
}
int
w_knife_isempty(player pl)
{
return 0;
}
void
w_knife_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
if (w_knife_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/640hud5.spr_0.tga",
[0,0],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[80/256,120/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/640hud2.spr_0.tga",
[0,0],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[0,120/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_knife_type(player pl)
{
return WPNTYPE_CLOSE;
}
weapon_t w_knife =
{
.name = "knife",
@ -294,7 +301,10 @@ weapon_t w_knife =
.pmodel = w_knife_pmodel,
.deathmsg = w_knife_deathmsg,
.aimanim = w_knife_aimanim,
.hudpic = w_knife_hudpic
.hudpic = w_knife_hudpic,
.weight = -10,
.isempty = w_knife_isempty,
.type = w_knife_type
};
#ifdef SERVER

View File

@ -128,10 +128,8 @@ w_lego_throw(player pl)
void
w_lego_draw(player pl)
{
#ifdef CLIENT
Weapons_SetModel("models/v_lego.mdl");
Weapons_ViewAnimation(pl, LEGO_DRAW);
#endif
}
void
@ -153,19 +151,11 @@ w_lego_primary(player pl)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_legogrenade <= 0) {
return;
}
#else
if (pl.ammo_legogrenade <= 0) {
return;
}
#endif
#ifdef CLIENT
Weapons_ViewAnimation(pl, LEGO_PULLPIN);
#endif
pl.a_ammo3 = 1;
pl.w_attack_next = 0.5f;
@ -176,19 +166,6 @@ void
w_lego_hud(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] - 42, g_hudres[1] - 64];
@ -212,20 +189,17 @@ w_lego_release(player pl)
}
if (pl.a_ammo3 == 1) {
#ifdef CLIENT
pl.ammo_legogrenade--;
Weapons_ViewAnimation(pl, LEGO_THROW);
#else
pl.ammo_legogrenade--;
#ifdef SERVER
w_lego_throw(pl);
#endif
pl.ammo_legogrenade--;
Weapons_ViewAnimation(pl, LEGO_THROW);
pl.a_ammo3 = 2;
pl.w_attack_next = 1.0f;
pl.w_idle_next = 0.5f;
} else if (pl.a_ammo3 == 2) {
#ifdef CLIENT
Weapons_ViewAnimation(pl, LEGO_DRAW);
#else
#ifdef SERVER
if (!pl.ammo_legogrenade) {
Weapons_RemoveItem(pl, WEAPON_LEGO);
}
@ -234,9 +208,9 @@ w_lego_release(player pl)
pl.w_idle_next = 0.5f;
pl.a_ammo3 = 0;
} else {
Weapons_ViewAnimation(pl, LEGO_IDLE);
pl.w_idle_next = 3.0f;
}
Weapons_ViewAnimation(pl, LEGO_IDLE);
pl.w_idle_next = 3.0f;
}
}
float
@ -245,18 +219,47 @@ w_lego_aimanim(player pl)
return pl.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR;
}
int
w_lego_isempty(player pl)
{
return 0;
}
void
w_lego_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,0], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE);
if (w_lego_isempty(pl)) {
drawsubpic(
pos,
[80,40],
g_sprWeapons,
[80/256,200/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_NORMAL
);
} else {
drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,0], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE);
drawsubpic(
pos,
[80,40],
g_sprWeapons,
[0,200/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_lego_type(player pl)
{
return WPNTYPE_RANGED;
}
weapon_t w_lego =
{
.name = "lego",
@ -277,7 +280,10 @@ weapon_t w_lego =
.pmodel = w_lego_pmodel,
.deathmsg = w_lego_deathmsg,
.aimanim = w_lego_aimanim,
.hudpic = w_lego_hudpic
.hudpic = w_lego_hudpic,
.weight = -10,
.isempty = w_lego_isempty,
.type = w_lego_type
};
#ifdef SERVER

View File

@ -160,10 +160,10 @@ w_legolauncher_primary(player pl)
w_legolauncher_shootlego(pl);
pl.ammo_legos--;
Sound_Play(pl, CHAN_WEAPON, "weapon_legolauncher.fire");
#else
#endif
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, LEGOLAUNCHER_SHOOT);
#endif
if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
@ -197,11 +197,11 @@ w_legolauncher_crosshair(player pl)
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],
[32,32],
g_crossSoda,
[0,0],
[1, 1],
[1,0,0],
1,
DRAWFLAG_NORMAL
);
@ -228,36 +228,47 @@ w_legolauncher_aimanim(player pl)
return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW;
}
int
w_legolauncher_isempty(player pl)
{
return (pl.ammo_legos <= 0) ? true : false;
}
void
w_legolauncher_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
if (w_legolauncher_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/640hud5.spr_0.tga",
[0,0],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[160/256,120/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/640hud2.spr_0.tga",
[0,0],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[160/256,80/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_legolauncher_type(player pl)
{
return WPNTYPE_RANGED;
}
weapon_t w_legolauncher =
{
.name = "legoblock",
@ -278,7 +289,10 @@ weapon_t w_legolauncher =
.pmodel = w_legolauncher_pmodel,
.deathmsg = w_legolauncher_deathmsg,
.aimanim = w_legolauncher_aimanim,
.hudpic = w_legolauncher_hudpic
.hudpic = w_legolauncher_hudpic,
.weight = -10,
.isempty = w_legolauncher_isempty,
.type = w_legolauncher_type
};
#ifdef SERVER

View File

@ -188,10 +188,10 @@ w_machette_secondary(player pl)
#ifdef SERVER
w_machette_throw(pl);
Sound_Play(pl, CHAN_WEAPON, "weapon_machette.throw");
#else
#endif
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, MACHETTE_THROW);
#endif
if (self.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
@ -263,6 +263,17 @@ w_machette_hudpic(player pl, int selected, vector pos, float a)
#endif
}
int
w_machette_isempty(player pl)
{
return 0;
}
weapontype_t w_machette_type(player pl)
{
return WPNTYPE_RANGED;
}
weapon_t w_machette =
{
.name = "machette",
@ -283,7 +294,10 @@ weapon_t w_machette =
.pmodel = w_machette_pmodel,
.deathmsg = w_machette_deathmsg,
.aimanim = w_machette_aimanim,
.hudpic = w_machette_hudpic
.hudpic = w_machette_hudpic,
.weight = -10,
.isempty = w_machette_isempty,
.type = w_machette_type
};
/* entity definitions for pickups */

View File

@ -50,6 +50,7 @@ w_sodalauncher_precache(void)
precache_model("sprites/co2_puff.spr");
precache_model("models/v_soda.mdl");
precache_model("models/p_soda.mdl");
g_crossSoda = spriteframe("sprites/cross_soda.spr", 0, 0.0);
#endif
}
@ -93,13 +94,8 @@ w_sodalauncher_deathmsg(void)
void
w_sodalauncher_draw(player pl)
{
#ifdef CLIENT
Weapons_SetModel("models/v_soda.mdl");
Weapons_ViewAnimation(pl, SODA_DRAW);
/* needs the skin value to be set, no API yet
* the soda cans in the viewmodel sync up with
* the projectile and spill decals */
#endif
}
void
@ -134,7 +130,7 @@ w_sodalauncher_shoot(player pl)
entity soda = spawn();
setmodel(soda, "models/sodacan.mdl");
setorigin(soda, Weapons_GetCameraPos(pl) + (v_forward * 16));
soda.skin = floor(random(0,6));
soda.skin = pl.soda_choice;
soda.owner = self;
soda.velocity = v_forward * 800;
soda.angles = vectoangles(soda.velocity);
@ -158,7 +154,9 @@ w_sodalauncher_exhaust(player pl) {
setorigin(eExhaust, Weapons_GetCameraPos(pl) + (v_forward * 16));
setmodel(eExhaust, "sprites/co2_puff.spr");
eExhaust.effects = EF_ADDITIVE;
eExhaust.SetRenderMode(RM_ADDITIVE);
eExhaust.SetRenderColor([1,1,1]);
eExhaust.SetRenderAmt(1.0);
eExhaust.drawmask = MASK_ENGINE;
eExhaust.SetMaxFrame(modelframecount(eExhaust.modelindex));
eExhaust.SetLoopFlag(false);
@ -178,21 +176,16 @@ w_sodalauncher_primary(player pl)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_soda <= 0) {
return;
}
#else
if (pl.ammo_soda <= 0) {
return;
}
#endif
Weapons_ViewPunchAngle(pl, [-10,0,0]);
Weapons_ViewAnimation(pl, SODA_SHOOT_RELOAD);
/* Actual firing
* TODO make this one fast straight */
#ifdef CLIENT
Weapons_ViewPunchAngle(pl, [-10,0,0]);
Weapons_ViewAnimation(pl, SODA_SHOOT_RELOAD);
w_sodalauncher_exhaust(pl);
#else
w_sodalauncher_shoot(pl);
@ -200,6 +193,16 @@ w_sodalauncher_primary(player pl)
Sound_Play(pl, CHAN_WEAPON, "weapon_sodalauncher.fire");
#endif
pl.soda_choice++;
if (pl.soda_choice > 5) {
pl.soda_choice = 0;
}
#ifdef CLIENT
View_SetViewmodelSkin(pl.soda_choice);
#endif
pl.w_attack_next = 1.0f;
pl.w_idle_next = 10.0f;
}
@ -213,20 +216,15 @@ w_sodalauncher_secondary(player pl)
}
/* Ammo check */
#ifdef CLIENT
if (pl.ammo_soda <= 0) {
return;
}
#else
if (pl.ammo_soda <= 0) {
return;
}
#endif
Weapons_ViewPunchAngle(pl, [-10,0,0]);
Weapons_ViewAnimation(pl, SODA_SHOOT_RELOAD);
/* TODO make this one sag and slower */
#ifdef CLIENT
Weapons_ViewPunchAngle(pl, [-10,0,0]);
Weapons_ViewAnimation(pl, SODA_SHOOT_RELOAD);
w_sodalauncher_exhaust(pl);
#else
w_sodalauncher_shoot(pl);
@ -258,11 +256,11 @@ w_sodalauncher_crosshair(player pl)
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],
[32,32],
g_crossSoda,
[0,0],
[1, 1],
[1,0,0],
1,
DRAWFLAG_NORMAL
);
@ -287,36 +285,47 @@ w_sodalauncher_aimanim(player pl)
return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW;
}
int
w_sodalauncher_isempty(player pl)
{
return (pl.ammo_soda <= 0) ? true : false;
}
void
w_sodalauncher_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
if (w_sodalauncher_isempty(pl)) {
drawsubpic(
pos,
[170,45],
"sprites/640hud4.spr_0.tga",
[0,135/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[80/256,160/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
} else {
drawsubpic(
pos,
[170,45],
"sprites/640hud1.spr_0.tga",
[0,135/256],
[170/256,45/256],
g_hud_color,
[80,40],
g_sprWeapons,
[0,160/256],
[80/256,40/256],
[1,1,1],
a,
DRAWFLAG_ADDITIVE
DRAWFLAG_NORMAL
);
}
#endif
}
weapontype_t w_sodalauncher_type(player pl)
{
return WPNTYPE_RANGED;
}
weapon_t w_sodalauncher = {
.name = "sodacan",
.id = ITEM_SODALAUNCHER,
@ -336,7 +345,10 @@ weapon_t w_sodalauncher = {
.pmodel = w_sodalauncher_pmodel,
.deathmsg = w_sodalauncher_deathmsg,
.aimanim = w_sodalauncher_aimanim,
.hudpic = w_sodalauncher_hudpic
.hudpic = w_sodalauncher_hudpic,
.weight = -10,
.isempty = w_sodalauncher_isempty,
.type = w_sodalauncher_type
};
#ifdef SERVER

View File

@ -0,0 +1,7 @@
include "weapons/broom.def"
include "weapons/forks.def"
include "weapons/fryingpan.def"
include "weapons/hairspray.def"
include "weapons/knife.def"
include "weapons/legolauncher.def"
include "weapons/sodalauncher.def"

View File

@ -0,0 +1,14 @@
entityDef weapon_broom
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Broom"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_broom.mdl"
"inv_item" "$WEAPON_BROOM"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}

View File

@ -0,0 +1,14 @@
entityDef weapon_forks
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Forks"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_fork.mdl"
"inv_item" "$WEAPON_FORKS"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}

View File

@ -0,0 +1,14 @@
entityDef weapon_fryingpan
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Frying-Pan"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_pan.mdl"
"inv_item" "$WEAPON_FRYINGPAN"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}

View File

@ -0,0 +1,14 @@
entityDef weapon_hairspray
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Hairspray"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_hairspray.mdl"
"inv_item" "$WEAPON_HAIRSPRAY"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}

View File

@ -0,0 +1,14 @@
entityDef weapon_knife
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Knife"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_knife.mdl"
"inv_item" "$WEAPON_KNIFE"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}

View File

@ -0,0 +1,14 @@
entityDef weapon_legolauncher
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Lego Launcher"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_legolauncher.mdl"
"inv_item" "$WEAPON_LEGOLAUNCHER"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}

View File

@ -0,0 +1,14 @@
entityDef weapon_sodalauncher
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 -16"
"editor_maxs" "16 16 16"
"editor_usage" "Soda Launcher"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/w_soda.mdl"
"inv_item" "$WEAPON_SODALAUNCHER"
"snd_acquire" "weapon.pickup"
"snd_respawn" "item.respawn"
}