Rebased against the latest Nuclide commit.

This commit is contained in:
Marco Cawthorne 2022-03-15 19:35:42 -07:00
parent b35897d414
commit 57f09c97e2
Signed by: eukara
GPG Key ID: C196CD8BA993248A
9 changed files with 120 additions and 142 deletions

View File

@ -24,10 +24,3 @@ ClientGame_EntityUpdate(float id, float new)
return (1);
}
void
ClientGame_EntityRemove(void)
{
if (self.classname == "player")
Player_DestroyWeaponModel((base_player) self);
}

View File

@ -15,7 +15,7 @@
*/
void
Game_Input(void)
Game_Input(player pl)
{
#ifdef SERVER
CGameRules rules = (CGameRules)g_grMode;
@ -34,8 +34,7 @@ Game_Input(void)
Flashlight_Toggle();
if (cvar("sv_cheats") == 1) {
player pl = (player)self;
if (self.impulse == 101) {
if (pl.impulse == 101) {
pl.health = 100;
pl.armor = 100;
Weapons_AddItem(pl, WEAPON_HEATERPIPE, -1);
@ -47,7 +46,7 @@ Game_Input(void)
Weapons_AddItem(pl, WEAPON_SATCHEL, -1);
}
if (self.impulse == 102) {
if (pl.impulse == 102) {
// Respawn all the entities
for (entity a = world; (a = findfloat(a, ::identity, 1));) {
CBaseEntity caw = (CBaseEntity)a;
@ -57,15 +56,15 @@ Game_Input(void)
}
}
self.impulse = 0;
pl.impulse = 0;
#endif
if (input_buttons & INPUT_BUTTON0)
Weapons_Primary();
Weapons_Primary(pl);
else if (input_buttons & INPUT_BUTTON4)
Weapons_Reload();
Weapons_Reload(pl);
else if (input_buttons & INPUT_BUTTON3)
Weapons_Secondary();
Weapons_Secondary(pl);
else
Weapons_Release();
Weapons_Release(pl);
}

View File

@ -66,30 +66,29 @@ w_bradnailer_wmodel(void)
}
int
w_bradnailer_pickup(int new, int startammo)
w_bradnailer_pickup(player pl, int new, int startammo)
{
/* TODO */
return (1);
}
void
w_bradnailer_draw(void)
w_bradnailer_draw(player pl)
{
Weapons_SetModel("models/v_bradnailer.mdl");
Weapons_ViewAnimation(BNAIL_DRAW);
Weapons_ViewAnimation(pl, BNAIL_DRAW);
}
void
w_bradnailer_holster(void)
w_bradnailer_holster(player pl)
{
Weapons_ViewAnimation(BNAIL_HOLSTER);
Weapons_ViewAnimation(pl, BNAIL_HOLSTER);
}
#ifdef SERVER
void
w_bradnailer_shootnail(void)
w_bradnailer_shootnail(player pl)
{
player pl = (player)self;
static void Nail_Touch(void) {
FX_Spark(self.origin, trace_plane_normal);
if (other.takedamage == DAMAGE_YES) {
@ -101,11 +100,11 @@ w_bradnailer_shootnail(void)
remove(self);
}
Weapons_MakeVectors();
Weapons_MakeVectors(pl);
entity nail = spawn();
setmodel(nail, "models/nail.mdl");
setorigin(nail, Weapons_GetCameraPos() + (v_forward * 16));
nail.owner = self;
setorigin(nail, Weapons_GetCameraPos(pl) + (v_forward * 16));
nail.owner = pl;
nail.velocity = v_forward * 2000;
nail.movetype = MOVETYPE_FLY;
nail.solid = SOLID_BBOX;
@ -114,7 +113,7 @@ w_bradnailer_shootnail(void)
nail.touch = Nail_Touch;
setsize(nail, [0,0,0], [0,0,0]);
if (self.flags & FL_CROUCHING)
if (pl.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
@ -124,19 +123,18 @@ w_bradnailer_shootnail(void)
#endif
void
w_bradnailer_primary(void)
w_bradnailer_primary(player pl)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
return;
}
#ifdef SERVER
w_bradnailer_shootnail();
w_bradnailer_shootnail(pl);
#else
Weapons_ViewPunchAngle([-2,0,0]);
Weapons_ViewAnimation(BNAIL_SHOOT);
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, BNAIL_SHOOT);
#endif
pl.w_attack_next = 0.3f;
@ -144,9 +142,8 @@ w_bradnailer_primary(void)
}
void
w_bradnailer_secondary(void)
w_bradnailer_secondary(player pl)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
return;
@ -155,17 +152,17 @@ w_bradnailer_secondary(void)
/* Hack */
if (pl.a_ammo3 == 0) {
pl.a_ammo3 = 1;
Weapons_ViewAnimation(BNAIL_TILT);
Weapons_ViewAnimation(pl, BNAIL_TILT);
pl.w_attack_next = 0.4f;
pl.w_idle_next = pl.w_attack_next;
return;
}
#ifdef SERVER
w_bradnailer_shootnail();
w_bradnailer_shootnail(pl);
#else
Weapons_ViewPunchAngle([-2,0,0]);
Weapons_ViewAnimation(BNAIL_SHOOT2);
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, BNAIL_SHOOT2);
#endif
pl.w_attack_next = 0.2f;
@ -174,9 +171,8 @@ w_bradnailer_secondary(void)
void
w_bradnailer_release(void)
w_bradnailer_release(player pl)
{
player pl = (player)self;
if (pl.w_idle_next > 0.0) {
return;
@ -184,7 +180,7 @@ w_bradnailer_release(void)
if (pl.a_ammo3 == 1) {
pl.a_ammo3 = 0;
Weapons_ViewAnimation(BNAIL_TILTBACK);
Weapons_ViewAnimation(pl, BNAIL_TILTBACK);
pl.w_attack_next = 0.4f;
pl.w_idle_next = pl.w_attack_next;
return;
@ -193,20 +189,20 @@ w_bradnailer_release(void)
int r = (float)input_sequence % 3;
switch (r) {
case 0:
Weapons_ViewAnimation(BNAIL_IDLE1);
Weapons_ViewAnimation(pl, BNAIL_IDLE1);
break;
case 1:
Weapons_ViewAnimation(BNAIL_IDLE2);
Weapons_ViewAnimation(pl, BNAIL_IDLE2);
break;
case 2:
Weapons_ViewAnimation(BNAIL_IDLE3);
Weapons_ViewAnimation(pl, BNAIL_IDLE3);
break;
}
pl.w_idle_next = 10.0f;
}
void
w_bradnailer_hudpic(int selected, vector pos, float a)
w_bradnailer_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
@ -247,7 +243,7 @@ weapon_t w_bradnailer =
.secondary = w_bradnailer_secondary,
.reload = __NULL__,
.release = w_bradnailer_release,
.crosshair = __NULL__,
.postdraw = __NULL__,
.precache = w_bradnailer_precache,
.pickup = w_bradnailer_pickup,
.updateammo = w_bradnailer_updateammo,

View File

@ -57,39 +57,39 @@ w_cmlwbr_wmodel(void)
}
void
w_cmlwbr_draw(void)
w_cmlwbr_draw(player pl)
{
Weapons_SetModel("models/v_cmlwbr.mdl");
Weapons_ViewAnimation(CML_DRAW);
Weapons_ViewAnimation(pl, CML_DRAW);
}
void
w_cmlwbr_holster(void)
w_cmlwbr_holster(player pl)
{
Weapons_ViewAnimation(CML_HOLSTER);
Weapons_ViewAnimation(pl, CML_HOLSTER);
}
void
w_cmlwbr_primary(void)
w_cmlwbr_primary(player pl)
{
/* TODO, attack slows to crawl & player breathes */
}
void
w_cmlwbr_secondary(void)
w_cmlwbr_secondary(player pl)
{
}
void
w_cmlwbr_release(void)
w_cmlwbr_release(player pl)
{
}
void
w_cmlwbr_hudpic(int selected, vector pos, float a)
w_cmlwbr_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
@ -130,7 +130,7 @@ weapon_t w_cmlwbr =
.secondary = w_cmlwbr_secondary,
.reload = __NULL__,
.release = w_cmlwbr_release,
.crosshair = __NULL__,
.postdraw = __NULL__,
.precache = w_cmlwbr_precache,
.pickup = __NULL__,
.updateammo = w_cmlwbr_updateammo,

View File

@ -53,32 +53,32 @@ w_heaterpipe_wmodel(void)
}
void
w_heaterpipe_draw(void)
w_heaterpipe_draw(player pl)
{
Weapons_SetModel("models/v_heaterpipe.mdl");
Weapons_ViewAnimation(HPIPE_DRAW);
Weapons_ViewAnimation(pl, HPIPE_DRAW);
}
void
w_heaterpipe_holster(void)
w_heaterpipe_holster(player pl)
{
Weapons_ViewAnimation(HPIPE_HOLSTER);
Weapons_ViewAnimation(pl, HPIPE_HOLSTER);
}
void
w_heaterpipe_primary(void)
w_heaterpipe_primary(player pl)
{
/* TODO, attack slows to crawl & player breathes */
}
void
w_heaterpipe_release(void)
w_heaterpipe_release(player pl)
{
}
void
w_heaterpipe_hudpic(int selected, vector pos, float a)
w_heaterpipe_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
@ -119,7 +119,7 @@ weapon_t w_heaterpipe =
.secondary = __NULL__,
.reload = __NULL__,
.release = w_heaterpipe_release,
.crosshair = __NULL__,
.postdraw = __NULL__,
.precache = w_heaterpipe_precache,
.pickup = __NULL__,
.updateammo = w_heaterpipe_updateammo,

View File

@ -51,16 +51,15 @@ w_nailgun_wmodel(void)
}
void
w_nailgun_draw(void)
w_nailgun_draw(player pl)
{
Weapons_SetModel("models/v_nailgun.mdl");
Weapons_ViewAnimation(NAIL_DRAW);
Weapons_ViewAnimation(pl, NAIL_DRAW);
}
void
w_nailgun_primary(void)
w_nailgun_primary(player pl)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
return;
@ -82,11 +81,11 @@ w_nailgun_primary(void)
remove(self);
}
Weapons_MakeVectors();
Weapons_MakeVectors(pl);
entity nail = spawn();
setmodel(nail, "models/nail.mdl");
setorigin(nail, Weapons_GetCameraPos() + (v_forward * 16));
nail.owner = self;
setorigin(nail, Weapons_GetCameraPos(pl) + (v_forward * 16));
nail.owner = pl;
nail.velocity = v_forward * 2000;
nail.movetype = MOVETYPE_FLY;
nail.solid = SOLID_BBOX;
@ -95,7 +94,7 @@ w_nailgun_primary(void)
nail.touch = Nail_Touch;
setsize(nail, [0,0,0], [0,0,0]);
if (self.flags & FL_CROUCHING)
if (pl.flags & FL_CROUCHING)
Animation_PlayerTop(pl, ANIM_SHOOT1HAND, 0.45f);
else
Animation_PlayerTop(pl, ANIM_CR_SHOOT1HAND, 0.45f);
@ -104,8 +103,8 @@ w_nailgun_primary(void)
#else
Weapons_ViewPunchAngle([-2,0,0]);
Weapons_ViewAnimation(NAIL_SHOOT);
Weapons_ViewPunchAngle(pl, [-2,0,0]);
Weapons_ViewAnimation(pl, NAIL_SHOOT);
#endif
@ -115,18 +114,17 @@ w_nailgun_primary(void)
}
void
w_nailgun_release(void)
w_nailgun_release(player pl)
{
player pl = (player)self;
if (pl.w_idle_next > 0) {
return;
}
if (random() < 0.5) {
Weapons_ViewAnimation(NAIL_IDLE1);
Weapons_ViewAnimation(pl, NAIL_IDLE1);
} else {
Weapons_ViewAnimation(NAIL_IDLE2);
Weapons_ViewAnimation(pl, NAIL_IDLE2);
}
pl.w_idle_next = 10.0f;
@ -134,7 +132,7 @@ w_nailgun_release(void)
void
w_nailgun_hudpic(int selected, vector pos, float a)
w_nailgun_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
@ -175,7 +173,7 @@ weapon_t w_nailgun =
.secondary = __NULL__,
.reload = __NULL__,
.release = w_nailgun_release,
.crosshair = __NULL__,
.postdraw = __NULL__,
.precache = w_nailgun_precache,
.pickup = __NULL__,
.updateammo = w_nailgun_updateammo,

View File

@ -54,7 +54,7 @@ w_pipebomb_wmodel(void)
}
string
w_pipebomb_pmodel(void)
w_pipebomb_pmodel(player pl)
{
return "models/p_pipebomb.mdl";
}
@ -78,24 +78,23 @@ w_pipebomb_precache(void)
}
int
w_pipebomb_pickup(int new, int startammo)
w_pipebomb_pickup(player pl, int new, int startammo)
{
return w_satchel_pickup(new, startammo);
return w_satchel_pickup(pl, new, startammo);
}
void
w_pipebomb_draw(void)
w_pipebomb_draw(player pl)
{
Weapons_SetModel("models/v_pipebomb.mdl");
Weapons_ViewAnimation(SATCHEL_DRAW);
Weapons_ViewAnimation(pl, SATCHEL_DRAW);
#ifdef SERVER
player pl = (player)self;
Weapons_UpdateAmmo(pl, pl.satchel_chg, pl.ammo_satchel, __NULL__);
#endif
}
void
w_pipebomb_holster(void)
w_pipebomb_holster(player pl)
{
}
@ -142,9 +141,8 @@ s_pipebomb_detonate(entity master)
#endif
void
w_pipebomb_primary(void)
w_pipebomb_primary(player pl)
{
player pl = (player)self;
if (pl.w_attack_next) {
return;
@ -162,18 +160,18 @@ w_pipebomb_primary(void)
#endif
if (pl.satchel_chg <= 0) {
Weapons_ViewAnimation(RADIO_DRAW);
Weapons_ViewAnimation(pl, RADIO_DRAW);
} else {
Weapons_ViewAnimation(RADIO_USE);
Weapons_ViewAnimation(pl, RADIO_USE);
}
#ifdef SERVER
if (!pl.satchel_chg) {
vector throw;
Weapons_MakeVectors();
Weapons_MakeVectors(pl);
throw = pl.velocity + (v_forward * 274);
s_pipebomb_drop(self, pl.origin, throw);
s_pipebomb_drop(pl, pl.origin, throw);
pl.satchel_chg++;
pl.ammo_satchel--;
} else {
@ -196,9 +194,8 @@ w_pipebomb_primary(void)
}
void
w_pipebomb_secondary(void)
w_pipebomb_secondary(player pl)
{
player pl = (player)self;
if (pl.w_attack_next) {
return;
@ -217,9 +214,9 @@ w_pipebomb_secondary(void)
#ifdef SERVER
vector throw;
Weapons_MakeVectors();
Weapons_MakeVectors(pl);
throw = pl.velocity + (v_forward * 274);
s_pipebomb_drop(self, pl.origin, throw);
s_pipebomb_drop(pl, pl.origin, throw);
pl.satchel_chg++;
pl.ammo_satchel--;
Weapons_UpdateAmmo(pl, pl.satchel_chg, pl.ammo_satchel, __NULL__);
@ -229,38 +226,38 @@ w_pipebomb_secondary(void)
setmodel(pSeat->m_eViewModel, "models/v_pipebomb_watch.mdl");
#endif
Weapons_ViewAnimation(RADIO_DRAW);
Weapons_ViewAnimation(pl, RADIO_DRAW);
pl.w_attack_next = 1.0f;
pl.w_idle_next = 2.5f;
}
void
w_pipebomb_reload(void)
w_pipebomb_reload(player pl)
{
}
void
w_pipebomb_release(void)
w_pipebomb_release(player pl)
{
w_satchel_release();
w_satchel_release(pl);
}
float
w_pipebomb_aimanim(void)
w_pipebomb_aimanim(player pl)
{
return w_satchel_aimanim();
return w_satchel_aimanim(pl);
}
void
w_pipebomb_hud(void)
w_pipebomb_hud(player pl)
{
w_satchel_holster();
w_satchel_holster(pl);
}
void
w_pipebomb_hudpic(int selected, vector pos, float a)
w_pipebomb_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
@ -283,7 +280,7 @@ weapon_t w_pipebomb =
.secondary = w_pipebomb_secondary,
.reload = __NULL__,
.release = w_pipebomb_release,
.crosshair = w_pipebomb_hud,
.postdraw = w_pipebomb_hud,
.precache = w_pipebomb_precache,
.pickup = w_pipebomb_pickup,
.updateammo = w_pipebomb_updateammo,

View File

@ -61,7 +61,7 @@ w_shotgun_wmodel(void)
}
string
w_shotgun_pmodel(void)
w_shotgun_pmodel(player pl)
{
return "models/p_shotgun.mdl";
}
@ -73,10 +73,9 @@ w_shotgun_deathmsg(void)
}
int
w_shotgun_pickup(int new, int startammo)
w_shotgun_pickup(player pl, int new, int startammo)
{
#ifdef SERVER
player pl = (player)self;
if (new) {
pl.shotgun_mag = 8;
@ -92,26 +91,24 @@ w_shotgun_pickup(int new, int startammo)
}
void
w_shotgun_draw(void)
w_shotgun_draw(player pl)
{
Weapons_SetModel("models/v_shotgun.mdl");
Weapons_ViewAnimation(SHOTGUN_DRAW);
Weapons_ViewAnimation(pl, SHOTGUN_DRAW);
#ifdef SERVER
player pl = (player)self;
Weapons_UpdateAmmo(pl, pl.shotgun_mag, pl.ammo_buckshot, __NULL__);
#endif
}
void
w_shotgun_holster(void)
w_shotgun_holster(player pl)
{
Weapons_ViewAnimation(SHOTGUN_HOLSTER);
Weapons_ViewAnimation(pl, SHOTGUN_HOLSTER);
}
void
w_shotgun_primary(void)
w_shotgun_primary(player pl)
{
player pl = (player)self;
if (pl.w_attack_next) {
return;
}
@ -143,19 +140,18 @@ w_shotgun_primary(void)
Weapons_UpdateAmmo(pl, pl.shotgun_mag, pl.ammo_buckshot, __NULL__);
#else
View_SetMuzzleflash(MUZZLE_WEIRD);
Weapons_ViewPunchAngle([-5,0,0]);
Weapons_ViewPunchAngle(pl, [-5,0,0]);
pl.a_ammo1--;
#endif
Weapons_ViewAnimation(SHOTGUN_FIRE1);
Weapons_ViewAnimation(pl, SHOTGUN_FIRE1);
pl.w_attack_next = 1.1f;
pl.w_idle_next = 2.5f;
}
void
w_shotgun_reload(void)
w_shotgun_reload(player pl)
{
player pl = (player)self;
#ifdef CLIENT
if (pl.a_ammo1 >= 8) {
return;
@ -180,14 +176,13 @@ w_shotgun_reload(void)
}
void
w_shotgun_release(void)
w_shotgun_release(player pl)
{
player pl = (player)self;
/* auto-reload if need be */
if (pl.w_attack_next <= 0.0)
if (pl.a_ammo3 == SHOTTY_IDLE && pl.a_ammo1 == 0 && pl.a_ammo2 > 0) {
Weapons_Reload();
Weapons_Reload(pl);
return;
}
@ -199,19 +194,19 @@ w_shotgun_release(void)
int r = floor(random(0,2));
switch (r) {
case 0:
Weapons_ViewAnimation(SHOTGUN_IDLE1);
Weapons_ViewAnimation(pl, SHOTGUN_IDLE1);
break;
case 1:
Weapons_ViewAnimation(SHOTGUN_IDLE2);
Weapons_ViewAnimation(pl, SHOTGUN_IDLE2);
break;
}
pl.w_idle_next = 15.0f;
} else if (pl.a_ammo3 == SHOTTY_RELOAD_START) {
Weapons_ViewAnimation(SHOTGUN_START_RELOAD);
Weapons_ViewAnimation(pl, SHOTGUN_START_RELOAD);
pl.a_ammo3 = SHOTTY_RELOAD;
pl.w_idle_next = 0.65f;
} else if (pl.a_ammo3 == SHOTTY_RELOAD) {
Weapons_ViewAnimation(SHOTGUN_RELOAD);
Weapons_ViewAnimation(pl, SHOTGUN_RELOAD);
#ifdef CLIENT
pl.a_ammo1++;
pl.a_ammo2--;
@ -230,7 +225,7 @@ w_shotgun_release(void)
#endif
pl.w_idle_next = 0.5f;
} else if (pl.a_ammo3 == SHOTTY_RELOAD_END) {
Weapons_ViewAnimation(SHOTGUN_PUMP);
Weapons_ViewAnimation(pl, SHOTGUN_PUMP);
#ifdef SERVER
sound(pl, CHAN_WEAPON, "weapons/scock1.wav", 1.0, ATTN_NORM);
#endif
@ -241,7 +236,7 @@ w_shotgun_release(void)
}
void
w_shotgun_crosshair(void)
w_shotgun_crosshair(player pl)
{
#ifdef CLIENT
static vector cross_pos;
@ -255,13 +250,13 @@ w_shotgun_crosshair(void)
}
float
w_shotgun_aimanim(void)
w_shotgun_aimanim(player pl)
{
return self.flags & FL_CROUCHING ? ANIM_CR_AIMSHOTGUN : ANIM_AIMSHOTGUN;
return pl.flags & FL_CROUCHING ? ANIM_CR_AIMSHOTGUN : ANIM_AIMSHOTGUN;
}
void
w_shotgun_hudpic(int s, vector pos, float a)
w_shotgun_hudpic(player pl, int s, vector pos, float a)
{
#ifdef CLIENT
if (s) {
@ -284,7 +279,7 @@ weapon_t w_shotgun =
.secondary = __NULL__,
.reload = w_shotgun_reload,
.release = w_shotgun_release,
.crosshair = __NULL__,
.postdraw = __NULL__,
.precache = w_shotgun_precache,
.pickup = w_shotgun_pickup,
.updateammo = w_shotgun_updateammo,

View File

@ -57,26 +57,26 @@ w_xs_wmodel(void)
}
void
w_xs_draw(void)
w_xs_draw(player pl)
{
Weapons_SetModel("models/v_xs.mdl");
Weapons_ViewAnimation(XS_DRAW);
Weapons_ViewAnimation(pl, XS_DRAW);
}
void
w_xs_holster(void)
w_xs_holster(player pl)
{
Weapons_ViewAnimation(XS_HOLSTER);
Weapons_ViewAnimation(pl, XS_HOLSTER);
}
void
w_xs_primary(void)
w_xs_primary(player pl)
{
/* TODO */
}
void
w_xs_secondary(void)
w_xs_secondary(player pl)
{
/* TODO Charge up, uses ammo similar to gauss */
@ -85,13 +85,13 @@ w_xs_secondary(void)
void
w_xs_release(void)
w_xs_release(player pl)
{
}
void
w_xs_hudpic(int selected, vector pos, float a)
w_xs_hudpic(player pl, int selected, vector pos, float a)
{
#ifdef CLIENT
if (selected) {
@ -132,7 +132,7 @@ weapon_t w_xs =
.secondary = w_xs_secondary,
.reload = __NULL__,
.release = w_xs_release,
.crosshair = __NULL__,
.postdraw = __NULL__,
.precache = w_xs_precache,
.pickup = __NULL__,
.updateammo = w_xs_updateammo,