Update WEAPON_EGON to work with .predraw instead of CBaseFX (deprecated)
which will allow for streamlined weapon visuals for first and thirdperson modes.
This commit is contained in:
parent
75b3ccd3a9
commit
8535399f7b
13 changed files with 79 additions and 102 deletions
|
@ -169,18 +169,7 @@ Player_PreDraw(base_player pp, int thirdperson)
|
|||
/* Handle the flashlights... */
|
||||
Player_Flashlight(pl);
|
||||
|
||||
#ifdef VALVE
|
||||
if (thirdperson && pl.gflags & GF_EGONBEAM) {
|
||||
vector src;
|
||||
vector endpos;
|
||||
|
||||
makevectors(pl.v_angle);
|
||||
src = pl.origin;
|
||||
endpos = pl.origin + (v_forward * 1024);
|
||||
traceline(src, endpos, MOVE_NORMAL, pl);
|
||||
w_egon_beamfx(gettaginfo(pl.p_model, 10), trace_endpos, pl);
|
||||
}
|
||||
#endif
|
||||
Weapons_PreDraw(thirdperson);
|
||||
|
||||
pl.Physics_SetViewParms();
|
||||
Animation_PlayerUpdate((player)pl);
|
||||
|
|
|
@ -275,7 +275,7 @@ w_crossbow_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
int r = (float)input_sequence % 2;
|
||||
int r = floor(pseudorandom() * 2.0f);
|
||||
if (r == 1) {
|
||||
if (pl.crossbow_mag) {
|
||||
Weapons_ViewAnimation(CROSSBOW_IDLE1);
|
||||
|
@ -290,7 +290,7 @@ w_crossbow_release(void)
|
|||
}
|
||||
}
|
||||
|
||||
pl.w_idle_next = 3.0f;
|
||||
pl.w_idle_next = 3.0f * 2.5f;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -26,66 +26,13 @@ Egon/Gluon-Gun Weapon
|
|||
#ifdef CLIENT
|
||||
var float TRAIL_EGONBEAM;
|
||||
|
||||
string w_egon_sparkframes[11];
|
||||
|
||||
void
|
||||
w_egon_beamfx(vector vecPos, vector vecEndPos, entity eOwner)
|
||||
{
|
||||
dynamiclight_add(vecPos + v_forward * -16, 128, [0.5, 0.5, 1.0]);
|
||||
trailparticles(TRAIL_EGONBEAM, eOwner, vecPos, vecEndPos);
|
||||
}
|
||||
|
||||
#define FXGAUSS_BEAMCOLOR [1,0.5,0]
|
||||
class FXEgon:CBaseFX
|
||||
{
|
||||
int m_iBeams;
|
||||
vector m_vecStart;
|
||||
vector m_vecAngle;
|
||||
|
||||
void(void) FXEgon;
|
||||
virtual void(void) Draw;
|
||||
};
|
||||
|
||||
void
|
||||
FXEgon::Animate_Next(void)
|
||||
{
|
||||
frame++;
|
||||
|
||||
if (frame == 11)
|
||||
frame = 0;
|
||||
|
||||
nextthink = time + 0.1f;
|
||||
}
|
||||
|
||||
void
|
||||
FXEgon::Draw(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
int iLoop = 6;
|
||||
vector src, endpos;
|
||||
vector gunpos = gettaginfo(pSeat->m_eViewModel, 33);
|
||||
|
||||
if (alpha <= 0.0f) {
|
||||
modelindex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
src = gettaginfo(pSeat->m_eViewModel, 0);
|
||||
makevectors(input_angles);
|
||||
endpos = src + v_forward * 1024;
|
||||
traceline(src, endpos, FALSE, pl);
|
||||
w_egon_beamfx(gunpos, endpos, pl);
|
||||
setorigin(this, trace_endpos + v_forward * -16);
|
||||
|
||||
setmodel(this, "sprites/xspark1.spr");
|
||||
effects = EF_ADDITIVE;
|
||||
}
|
||||
|
||||
void
|
||||
FXEgon::FXEgon(void)
|
||||
{
|
||||
CBaseFX::CBaseFX();
|
||||
think = Animate_Next;
|
||||
nextthink = time + 0.1f;
|
||||
}
|
||||
#endif
|
||||
|
||||
enum
|
||||
|
@ -115,6 +62,9 @@ void w_egon_precache(void)
|
|||
precache_model("models/v_egon.mdl");
|
||||
precache_model("models/p_egon.mdl");
|
||||
precache_model("sprites/xspark1.spr");
|
||||
|
||||
for (int i = 0; i < 11; i++)
|
||||
w_egon_sparkframes[i] = spriteframe("sprites/xspark1.spr", i, 0.0f);
|
||||
#endif
|
||||
}
|
||||
void w_egon_updateammo(player pl)
|
||||
|
@ -155,14 +105,6 @@ void w_egon_draw(void)
|
|||
|
||||
Weapons_SetModel("models/v_egon.mdl");
|
||||
Weapons_ViewAnimation(EGON_DRAW);
|
||||
|
||||
/* link the FX class */
|
||||
#ifdef CLIENT
|
||||
entity eold = self;
|
||||
self = pSeat->m_pWeaponFX;
|
||||
spawnfunc_FXEgon();
|
||||
self = eold;
|
||||
#endif
|
||||
}
|
||||
|
||||
void w_egon_holster(void)
|
||||
|
@ -185,12 +127,7 @@ void w_egon_primary(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef CLIENT
|
||||
FXEgon p = (FXEgon)pSeat->m_pWeaponFX;
|
||||
p.m_vecAngle = input_angles;
|
||||
p.m_vecStart = pl.origin + pl.view_ofs;
|
||||
p.alpha = 1.0f;
|
||||
#else
|
||||
#ifdef SERVER
|
||||
Weapons_MakeVectors();
|
||||
vector src = Weapons_GetCameraPos();
|
||||
vector endpos = src + v_forward * 1024;
|
||||
|
@ -234,13 +171,6 @@ void w_egon_release(void)
|
|||
{
|
||||
player pl = (player)self;
|
||||
|
||||
#ifdef CLIENT
|
||||
FXEgon p = (FXEgon)pSeat->m_pWeaponFX;
|
||||
p.m_vecAngle = input_angles;
|
||||
p.m_vecStart = pl.origin + pl.view_ofs;
|
||||
p.alpha = 0.0f;
|
||||
#endif
|
||||
|
||||
if (pl.mode_tempstate != 0 && pl.mode_tempstate < 3) {
|
||||
#ifdef SERVER
|
||||
sound(pl, CHAN_WEAPON, "weapons/egon_off1.wav", 1, ATTN_NORM, 100, 0);
|
||||
|
@ -260,7 +190,7 @@ void w_egon_release(void)
|
|||
if (pl.w_idle_next > 0.0f) {
|
||||
return;
|
||||
}
|
||||
int r = (float)input_sequence % 3;
|
||||
int r = floor(pseudorandom() * 3.0f);
|
||||
if (r == 1) {
|
||||
Weapons_ViewAnimation(EGON_FIDGET1);
|
||||
pl.w_idle_next = 2.666667f;
|
||||
|
@ -269,8 +199,56 @@ void w_egon_release(void)
|
|||
pl.w_idle_next = 2.0f;
|
||||
}
|
||||
pl.mode_tempstate = 0;
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
w_egon_postdraw(int thirdperson)
|
||||
{
|
||||
#ifdef CLIENT
|
||||
player pl = (player)self;
|
||||
|
||||
if (!(pl.gflags & GF_EGONBEAM))
|
||||
return;
|
||||
|
||||
vector src;
|
||||
vector endpos;
|
||||
|
||||
if (thirdperson) {
|
||||
makevectors(pl.v_angle);
|
||||
src = pl.origin;
|
||||
endpos = pl.origin + (v_forward * 1024);
|
||||
traceline(src, endpos, MOVE_NORMAL, pl);
|
||||
w_egon_beamfx(gettaginfo(pl.p_model, 10), trace_endpos, pl);
|
||||
} else {
|
||||
vector gunpos = gettaginfo(pSeat->m_eViewModel, 33);
|
||||
src = gettaginfo(pSeat->m_eViewModel, 0);
|
||||
makevectors(view_angles);
|
||||
endpos = src + v_forward * 1024;
|
||||
traceline(src, endpos, FALSE, pl);
|
||||
w_egon_beamfx(gunpos, endpos, pl);
|
||||
}
|
||||
|
||||
int i = (cltime*10) % 11;
|
||||
vector fsize = [32,32];
|
||||
makevectors(view_angles);
|
||||
trace_endpos += v_forward * -16; /* nudge towards our camera */
|
||||
dynamiclight_add(trace_endpos, 128, [0.5, 0.5, 1.0]);
|
||||
|
||||
R_BeginPolygon(w_egon_sparkframes[i], 1, 0);
|
||||
R_PolygonVertex(trace_endpos + v_right * fsize[0] - v_up * fsize[1],
|
||||
[1,1], [1,1,1], 1.0f);
|
||||
R_PolygonVertex(trace_endpos - v_right * fsize[0] - v_up * fsize[1],
|
||||
[0,1], [1,1,1], 1.0f);
|
||||
R_PolygonVertex(trace_endpos - v_right * fsize[0] + v_up * fsize[1],
|
||||
[0,0], [1,1,1], 1.0f);
|
||||
R_PolygonVertex(trace_endpos + v_right * fsize[0] + v_up * fsize[1],
|
||||
[1,0], [1,1,1], 1.0f);
|
||||
R_EndPolygon();
|
||||
#endif
|
||||
}
|
||||
|
||||
void w_egon_crosshair(void)
|
||||
{
|
||||
#ifdef CLIENT
|
||||
|
@ -330,7 +308,8 @@ weapon_t w_egon =
|
|||
.pmodel = w_egon_pmodel,
|
||||
.deathmsg = w_egon_deathmsg,
|
||||
.aimanim = w_egon_aimanim,
|
||||
.hudpic = w_egon_hudpic
|
||||
.hudpic = w_egon_hudpic,
|
||||
.predraw = w_egon_postdraw
|
||||
};
|
||||
|
||||
#ifdef SERVER
|
||||
|
|
|
@ -262,7 +262,7 @@ void w_gauss_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
int r = (float)input_sequence % 3;
|
||||
int r = floor(pseudorandom() * 3.0f);
|
||||
switch (r) {
|
||||
case 1:
|
||||
Weapons_ViewAnimation(GAUSS_IDLE2);
|
||||
|
@ -279,6 +279,7 @@ void w_gauss_release(void)
|
|||
pl.w_idle_next = 4.0f;
|
||||
break;
|
||||
}
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
|
||||
void w_gauss_crosshair(void)
|
||||
|
|
|
@ -286,7 +286,7 @@ w_glock_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
r = (float)input_sequence % 3;
|
||||
r = floor(pseudorandom() * 3.0f);
|
||||
switch (r) {
|
||||
case 1:
|
||||
Weapons_ViewAnimation(GLOCK_IDLE2);
|
||||
|
|
|
@ -210,7 +210,7 @@ void w_handgrenade_release(void)
|
|||
pl.w_idle_next = 0.5f;
|
||||
pl.mode_tempstate = 0;
|
||||
} else {
|
||||
int r = (float)input_sequence % 8;
|
||||
int r = floor(pseudorandom() * 8.0f);
|
||||
if (r == 1) {
|
||||
Weapons_ViewAnimation(HANDGRENADE_FIDGET);
|
||||
pl.w_idle_next = 2.5f;
|
||||
|
@ -218,6 +218,7 @@ void w_handgrenade_release(void)
|
|||
Weapons_ViewAnimation(HANDGRENADE_IDLE);
|
||||
pl.w_idle_next = 3.0f;
|
||||
}
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ w_hornetgun_release(void)
|
|||
}
|
||||
|
||||
int r;
|
||||
r = (float)input_sequence % 3;
|
||||
r = floor(pseudorandom() * 3.0f);
|
||||
switch (r) {
|
||||
case 1:
|
||||
Weapons_ViewAnimation(HORNETGUN_FIDGET1);
|
||||
|
@ -161,6 +161,7 @@ w_hornetgun_release(void)
|
|||
Weapons_ViewAnimation(HORNETGUN_IDLE);
|
||||
pl.w_idle_next = 1.875f;
|
||||
}
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -275,7 +275,7 @@ w_mp5_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
int r = (float)input_sequence % 3;
|
||||
int r = floor(pseudorandom() * 3.0f);
|
||||
if (r == 1) {
|
||||
Weapons_ViewAnimation(MP5_IDLE1);
|
||||
} else {
|
||||
|
|
|
@ -234,7 +234,7 @@ w_python_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
int r = (float)input_sequence % 4;
|
||||
int r = floor(pseudorandom() * 4.0f);
|
||||
|
||||
switch (r) {
|
||||
case 1:
|
||||
|
@ -254,6 +254,7 @@ w_python_release(void)
|
|||
pl.w_idle_next = 2.93f;
|
||||
break;
|
||||
}
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -217,7 +217,7 @@ void w_rpg_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
int r = (float)input_sequence % 3;
|
||||
int r = floor(pseudorandom() * 3.0f);
|
||||
|
||||
if (pl.rpg_mag > 0) {
|
||||
if (r == 1) {
|
||||
|
@ -233,7 +233,7 @@ void w_rpg_release(void)
|
|||
}
|
||||
}
|
||||
|
||||
pl.w_idle_next = 6.0f;
|
||||
pl.w_idle_next = 3.0f * 2.5f;
|
||||
}
|
||||
|
||||
void w_rpg_secondary(void)
|
||||
|
|
|
@ -302,7 +302,7 @@ w_shotgun_release(void)
|
|||
}
|
||||
|
||||
if (pl.mode_tempstate == SHOTTY_IDLE) {
|
||||
int r = (float)input_sequence % 3;
|
||||
int r = floor(pseudorandom() * 3.0f);
|
||||
switch (r) {
|
||||
case 1:
|
||||
Weapons_ViewAnimation(SHOTGUN_IDLE2);
|
||||
|
@ -317,6 +317,7 @@ w_shotgun_release(void)
|
|||
pl.w_idle_next = 2.222222f;
|
||||
break;
|
||||
}
|
||||
pl.w_idle_next *= 2.5f;
|
||||
} else if (pl.mode_tempstate == SHOTTY_RELOAD_START) {
|
||||
Weapons_ViewAnimation(SHOTGUN_START_RELOAD);
|
||||
pl.mode_tempstate = SHOTTY_RELOAD;
|
||||
|
|
|
@ -232,7 +232,7 @@ void w_snark_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
r = (float)input_sequence % 3;
|
||||
r = floor(pseudorandom() * 3.0f);
|
||||
switch (r) {
|
||||
case 0:
|
||||
Weapons_ViewAnimation(SNARK_IDLE);
|
||||
|
@ -247,6 +247,8 @@ void w_snark_release(void)
|
|||
pl.w_idle_next = 5.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
|
||||
void w_snark_precache(void)
|
||||
|
|
|
@ -323,6 +323,7 @@ w_tripmine_release(void)
|
|||
return;
|
||||
}
|
||||
|
||||
print(sprintf("weapontime: %f\n", pl.weapontime));
|
||||
int r = (float)input_sequence % 3;
|
||||
switch (r) {
|
||||
case 1:
|
||||
|
@ -338,6 +339,7 @@ w_tripmine_release(void)
|
|||
pl.w_idle_next = 3.34f;
|
||||
break;
|
||||
}
|
||||
pl.w_idle_next *= 2.5f;
|
||||
}
|
||||
|
||||
float
|
||||
|
|
Loading…
Reference in a new issue