Minor tweaks to the weapons, notably WEAPON_GAUSS.

This commit is contained in:
Marco Cawthorne 2022-08-12 14:29:08 -07:00
parent 21d4c7dab5
commit f8f9703df3
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
17 changed files with 115 additions and 75 deletions

View File

@ -124,7 +124,7 @@ HUD_DrawNums(float fNumber, vector vecPos, float fAlpha, vector vColor)
int i = fNumber;
if (i > 0) {
while (i > 0) {
HUD_DrawNumber((float)i % 10, vecPos, fAlpha, vColor);
HUD_DrawNumber((float)i % 10.0f, vecPos, fAlpha, vColor);
i = i / 10;
vecPos[0] -= 20;
}

View File

@ -1,4 +1,5 @@
#pragma target fte_6301
#pragma target fte_5768
//#pragma flag enable assumeint
#pragma progs_dat "../../csprogs.dat"
#define CSQC

View File

@ -1,4 +1,5 @@
#pragma target fte_6301
#pragma target fte_5768_5768
//#pragma flag enable assumeint
#pragma progs_dat "../../menu.dat"
#define MENU
#define GAME_DIR "valve"

View File

@ -61,7 +61,7 @@ class monster_barney:NSTalkMonster
virtual int(void) AttackMelee;
virtual int(void) AttackRanged;
virtual void(monsterState_e, monsterState_e) StateChanged;
virtual void(monsterState_t, monsterState_t) StateChanged;
};
int
@ -118,7 +118,7 @@ monster_barney::AttackRanged(void)
void
monster_barney::StateChanged(monsterState_e oldState, monsterState_e newState)
monster_barney::StateChanged(monsterState_t oldState, monsterState_t newState)
{
super::StateChanged(oldState, newState);

View File

@ -1,4 +1,5 @@
#pragma target fte
#pragma target fte_5768
//#pragma flag enable assumeint
#pragma progs_dat "../../progs.dat"
#define QWSSQC

View File

@ -135,7 +135,8 @@ FX_GaussBeam(vector vecPos, vector vecAngle, int numBeams, entity eOwner)
vector vecSrc;
vector vecEndPos;
vector vecDir;
vector vecFirstImpact = [0,0,0];
vector vecCurPlane;
vector vecCurPos;
int totalBeams = numBeams;
makevectors(vecAngle);
@ -143,38 +144,43 @@ FX_GaussBeam(vector vecPos, vector vecAngle, int numBeams, entity eOwner)
vecSrc = vecPos;
vecEndPos = vecSrc + v_forward * 1024;
traceline(vecSrc, vecEndPos, FALSE, eOwner);
vecCurPlane = trace_plane_normal;
vecCurPos = trace_endpos;
trailparticles(TRAIL_GAUSSBEAM, eOwner, vecSrc + (v_right * 8) + (v_up * -12), trace_endpos);
FX_GaussBeam_Piece(trace_endpos, vecDir * -1);
Decals_Place(trace_endpos, "{gaussshot1");
/* Decals_Place modifies trace_* globals, so cache */
if (totalBeams > 1)
vecFirstImpact = trace_endpos;
makevectors(vecAngle);
vecDir = v_forward;
trace_plane_normal = vecCurPlane;
trace_endpos = vecCurPos;
while (numBeams > 0) {
float n;
vector r;
n = -dotproduct(trace_plane_normal, vecDir);
r = 2 * trace_plane_normal * n + vecDir;
vecDir = r;
vecSrc = trace_endpos + (vecDir * 1);
vector newDir;
trace_plane_normal = vecCurPlane;
trace_endpos = vecCurPos;
newDir = vecDir - 2 * (vecDir * trace_plane_normal) * trace_plane_normal;
vecDir = newDir;
vecSrc = trace_endpos + (vecDir * -1);
vecEndPos = trace_endpos + (vecDir * 8192);
traceline(vecSrc, vecEndPos, FALSE, eOwner);
vecCurPlane = trace_plane_normal;
vecCurPos = trace_endpos;
trailparticles(TRAIL_GAUSSBEAM, eOwner, vecSrc, trace_endpos);
FX_GaussBeam_Piece(trace_endpos, vecDir);
numBeams--;
#if 1
if (serverkeyfloat("*bspversion") == BSPVER_HL)
if (getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos)) != "sky") {
Decals_Place(trace_endpos, "{gaussshot1");
} else {
break;
}
#endif
}
/* higher energy means the first impact will leave a hole as well */
if (totalBeams > 1)
Decals_Place(vecFirstImpact, "{gaussshot1");
#endif
}

View File

@ -256,6 +256,8 @@ player::PredictPostFrame(void)
void
player::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "anim_top", anim_top);
SaveFloat(handle, "anim_top_time", anim_top_time);
SaveFloat(handle, "anim_top_delay", anim_top_delay);
@ -289,8 +291,6 @@ player::Save(float handle)
SaveInt(handle, "ammo_gauss_volume", ammo_gauss_volume);
SaveInt(handle, "ammo_rpg_state", ammo_rpg_state);
SaveInt(handle, "mode_tempstate", mode_tempstate);
super::Save(handle);
}
void

View File

@ -175,7 +175,7 @@ w_crossbow_primary(player pl)
/* ammo check */
if ((pl.crossbow_mag <= 0i) ? true : false) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_crossbow.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_crossbow.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;

View File

@ -112,7 +112,7 @@ w_crowbar_primary(player pl)
}
pl.w_idle_next = 2.5f;
int r = (float)input_sequence % 3;
int r = (float)input_sequence % 3.0f;
switch (r) {
case 0:
Weapons_ViewAnimation(pl, trace_fraction >= 1 ? CBAR_ATTACK1MISS:CBAR_ATTACK1HIT);

View File

@ -131,7 +131,7 @@ void w_egon_primary(player pl)
bool out_of_ammo = (pl.ammo_uranium <= 0i) ? true : false;
if (out_of_ammo || pl.WaterLevel() >= WATERLEVEL_SUBMERGED) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_egon.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_egon.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
w_egon_release(pl);
@ -147,7 +147,7 @@ void w_egon_primary(player pl)
Client_ShakeOnce(trace_endpos, 128, 0.2, 1.0, 1.0f);
#endif
int r = (float)input_sequence % 2;
int r = (float)input_sequence % 2.0f;
pl.ammo_uranium--;
pl.gflags |= GF_EGONBEAM;
@ -247,7 +247,7 @@ w_egon_postdraw(player pl, int thirdperson)
w_egon_beamfx(gunpos, endpos, pl);
}
int i = (cltime*10) % 11;
int i = (cltime*10.0f) % 11.0f;
vector fsize = [32,32];
makevectors(view_angles);
trace_endpos += v_forward * -16; /* nudge towards our camera */

View File

@ -36,6 +36,13 @@ enum
GAUSS_DRAW
};
enum
{
GAUSSTATE_IDLE,
GAUSSTATE_REVVINGUP,
GAUSSTATE_FULL
};
void w_gauss_release(player pl);
void w_gauss_precache(void)
@ -88,7 +95,7 @@ int w_gauss_pickup(player pl, int new, int startammo)
void w_gauss_draw(player pl)
{
pl.mode_tempstate = 0;
pl.mode_tempstate = GAUSSTATE_IDLE;
Weapons_SetModel("models/v_gauss.mdl");
Weapons_ViewAnimation(pl, GAUSS_DRAW);
}
@ -102,14 +109,22 @@ void w_gauss_holster(player pl)
void w_gauss_fire(player pl, int one)
{
int iLoop = 6;
vector vecCurPlane;
vector vecCurPos;
vector vecSrc;
vector vecEndPos;
vector vecDir;
Weapons_MakeVectors(pl);
vector src = Weapons_GetCameraPos(pl);
vector endpos = src + v_forward * 1024;
traceline(src, endpos, FALSE, pl);
vecDir = v_forward;
vecSrc = Weapons_GetCameraPos(pl);
vecEndPos = vecSrc + v_forward * 1024;
traceline(vecSrc, vecEndPos, FALSE, pl);
vecCurPlane = trace_plane_normal;
vecCurPos = trace_endpos;
sound(pl, CHAN_WEAPON, "weapons/gauss2.wav", 1, ATTN_NORM);
int iDamage = one ? 20 : 200;
int iDamage = one ? 20 : (int)rint((bound(0, pl.ammo_gauss_volume, 10) * 20));
if (serverkeyfloat("*bspversion") == BSPVER_HL)
if (getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos)) == "sky") {
@ -126,24 +141,31 @@ void w_gauss_fire(player pl, int one)
} else {
/* Apply force */
if (pl.flags & FL_ONGROUND) {
pl.velocity += v_forward * -400;
pl.velocity += v_forward * (-iDamage * 2);
} else {
pl.velocity += v_forward * -800;
pl.velocity += v_forward * (-iDamage * 4);
}
}
// reflection equation:
vector dir = v_forward;
Weapons_MakeVectors(pl);
vecDir = v_forward;
trace_plane_normal = vecCurPlane;
trace_endpos = vecCurPos;
while (iLoop > 0) {
float n;
vector r;
n = -dotproduct(trace_plane_normal, dir);
r = 2 * trace_plane_normal * n + dir;
dir = r;
src = trace_endpos + (dir * 1);
endpos = trace_endpos + (dir * 8192);
traceline(src, endpos, FALSE, pl);
vector newDir;
trace_plane_normal = vecCurPlane;
trace_endpos = vecCurPos;
newDir = vecDir - 2 * (vecDir * trace_plane_normal) * trace_plane_normal;
vecDir = newDir;
vecSrc = trace_endpos + (vecDir * -1);
vecEndPos = trace_endpos + (vecDir * 8192);
traceline(vecSrc, vecEndPos, FALSE, pl);
vecCurPlane = trace_plane_normal;
vecCurPos = trace_endpos;
iLoop--;
if (trace_ent.takedamage == DAMAGE_YES) {
Damage_Apply(trace_ent, pl, iDamage, WEAPON_GAUSS, DMG_ELECTRO);
sound(trace_ent, CHAN_ITEM, sprintf("weapons/electro%d.wav", random(0,3)+4), 1, ATTN_NORM);
@ -162,7 +184,7 @@ void w_gauss_primary(player pl)
/* Ammo check */
if ((pl.ammo_uranium < 2) || (pl.WaterLevel() >= WATERLEVEL_SUBMERGED)) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_gauss.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_gauss.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;
@ -192,16 +214,14 @@ void w_gauss_release(player pl)
return;
}
/* Reset the pitch sound shift */
pl.ammo_gauss_volume = 0;
if (pl.mode_tempstate == 1) {
if (pl.mode_tempstate == GAUSSTATE_REVVINGUP) {
pl.w_attack_next = 0.0f;
pl.w_idle_next = 4.0f;
pl.w_idle_next = 0.5f;
w_gauss_primary(pl);
pl.mode_tempstate = 0;
pl.ammo_gauss_volume = 0;
pl.mode_tempstate = GAUSSTATE_IDLE;
return;
} else if (pl.mode_tempstate == 2) {
} else if (pl.mode_tempstate == GAUSSTATE_FULL) {
Weapons_ViewAnimation(pl, GAUSS_FIRE1);
if (pl.flags & FL_CROUCHING)
@ -212,11 +232,12 @@ void w_gauss_release(player pl)
Weapons_ViewPunchAngle(pl, [-5,0,0]);
#ifdef SERVER
w_gauss_fire(pl, 0);
pl.ammo_gauss_volume = 0;
FX_GaussBeam(Weapons_GetCameraPos(pl), input_angles, 6, pl);
#endif
pl.w_attack_next = 1.5f;
pl.w_idle_next = 4.0f;
pl.mode_tempstate = 0;
pl.mode_tempstate = GAUSSTATE_IDLE;
return;
}
@ -246,10 +267,18 @@ void w_gauss_secondary(player pl)
if (pl.gflags & GF_SEMI_TOGGLED)
return;
/* Ammo check */
/* release gauss when out of ammo and revving */
if (pl.ammo_uranium <= 0) {
if (pl.mode_tempstate > GAUSSTATE_IDLE) {
w_gauss_release(pl);
return;
}
}
/* regular ammo check */
if ((pl.ammo_uranium <= 0) || (pl.WaterLevel() >= WATERLEVEL_SUBMERGED)) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_gauss.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_gauss.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;
@ -257,37 +286,39 @@ void w_gauss_secondary(player pl)
pl.w_attack_next = 0.1f;
/* Ammo check */
if (pl.ammo_uranium <= 0) {
if (pl.mode_tempstate > 0) {
w_gauss_release(pl);
}
return;
}
/* take away 10 uranium max */
if (pl.ammo_gauss_volume < 10)
pl.ammo_uranium--;
/* Set pitch sound shift */
pl.ammo_gauss_volume += 1;
/* holding it for too long, damage our owner */
if (pl.ammo_gauss_volume > 100) {
pl.ammo_gauss_volume = 100;
#ifdef SERVER
Damage_Apply(pl, pl, 10, DMG_ELECTRO, WEAPON_GAUSS);
#endif
pl.mode_tempstate = 0;
pl.mode_tempstate = GAUSSTATE_IDLE;
pl.w_attack_next = 0.5f;
pl.w_idle_next = 0.5f;
pl.ammo_gauss_volume = 0;
Weapons_ViewAnimation(pl, GAUSS_IDLE1);
}
if (pl.mode_tempstate == 1) {
if (pl.mode_tempstate == GAUSSTATE_REVVINGUP) {
Weapons_ViewAnimation(pl, GAUSS_SPIN);
pl.mode_tempstate = 2;
pl.mode_tempstate = GAUSSTATE_FULL;
pl.w_idle_next = 0.5f;
pl.w_attack_next = 0.5f;
} else if (!pl.mode_tempstate) {
Weapons_ViewAnimation(pl, GAUSS_SPINUP);
pl.mode_tempstate = 1;
pl.mode_tempstate = GAUSSTATE_REVVINGUP;
#ifdef SERVER
sound(pl, CHAN_WEAPON, "ambience/pulsemachine.wav", 2, ATTN_NORM);
#endif
pl.w_idle_next = 0.5f;
pl.w_attack_next = 0.5f;
}
}

View File

@ -162,7 +162,7 @@ w_glock_primary(player pl)
/* ammo check */
if ((pl.glock_mag <= 0i) ? true : false) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_glock.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_glock.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;
@ -207,7 +207,7 @@ w_glock_secondary(player pl)
/* ammo check */
if ((pl.glock_mag <= 0i) ? true : false) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_glock.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_glock.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;

View File

@ -171,7 +171,7 @@ w_mp5_primary(player pl)
bool out_of_ammo = (pl.mp5_mag <= 0i) ? true : false;
if (out_of_ammo || (pl.WaterLevel() >= WATERLEVEL_SUBMERGED)) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_mp5.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;
@ -230,7 +230,7 @@ w_mp5_secondary(player pl)
bool out_of_ammo = (pl.ammo_m203_grenade <= 0i) ? true : false;
if (out_of_ammo || pl.WaterLevel() >= WATERLEVEL_SUBMERGED) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_mp5.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;

View File

@ -136,7 +136,7 @@ w_python_primary(player pl)
/* Ammo check */
if ((pl.python_mag <= 0) || (pl.WaterLevel() >= WATERLEVEL_SUBMERGED)) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_357.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_357.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;

View File

@ -109,7 +109,7 @@ void w_rpg_primary(player pl)
/* ammo check */
if ((pl.rpg_mag <= 0i) ? true : false) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_rpg.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_rpg.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;

View File

@ -182,7 +182,7 @@ w_shotgun_primary(player pl)
/* Ammo check */
if ((pl.shotgun_mag <= 0) || (pl.WaterLevel() >= WATERLEVEL_SUBMERGED)) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_shotgun.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_shotgun.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;
@ -248,7 +248,7 @@ w_shotgun_secondary(player pl)
/* Ammo check */
if ((pl.shotgun_mag <= 1) || (pl.WaterLevel() >= WATERLEVEL_SUBMERGED)) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_shotgun.empty");
Sound_Play(pl, CHAN_AUTO, "weapon_shotgun.empty");
#endif
pl.gflags |= GF_SEMI_TOGGLED;
return;

View File

@ -322,7 +322,7 @@ w_tripmine_release(player pl)
return;
}
int r = (float)input_sequence % 3;
int r = (float)input_sequence % 3.0f;
switch (r) {
case 1:
Weapons_ViewAnimation(pl, TRIPMINE_IDLE1);