Handle muzzleflashes differently.

Originally I thought that the model event calls would decide which
muzzleflash to use. It WORKED close enough for CS afterall. It turns out
that the numbers must relate to size or something else which I have yet
to figure out. Either way this unbreaks muzzleflashes in Half-Life and soon
when I port the weapons from CS' system over to the predicted weapon system
from FreeHL, they'll get it too.
This commit is contained in:
Marco Cawthorne 2019-09-04 03:56:36 +02:00
parent 205cd5856f
commit 50c1aced6e
7 changed files with 55 additions and 39 deletions

View file

@ -56,6 +56,11 @@ var float PARTICLE_SPARK;
var float DECAL_SHOT;
var float DECAL_GLASS;
/* muzzleflash indices */
var int MUZZLE_SMALL;
var int MUZZLE_RIFLE;
var int MUZZLE_WEIRD;
/* misc globals */
vector video_mins;
vector video_res;
@ -65,7 +70,8 @@ vector mouse_pos;
float clframetime;
/* prototypes */
void View_SetMuzzleflash(int);
void View_UpdateWeapon(entity, entity);
void View_AddPunchAngle( vector vAdd );
void View_PlayAnimation( int iSequence );
void View_AddPunchAngle(vector);
void View_PlayAnimation(int);
void Game_Input(void);

View file

@ -64,27 +64,27 @@ void Event_ProcessModel(float fTimeStamp, int iCode, string sData)
localsound(sData, CHAN_AUTO, 1.0);
} else if (iCode == 5001) {
pSeat->eMuzzleflash.alpha = 1.0f;
pSeat->eMuzzleflash.scale = 0.5;
pSeat->eMuzzleflash.scale = 0.25;
pSeat->eMuzzleflash.skin = pSeat->fNumBones;
setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
//setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
Event_EjectShell();
} else if(iCode == 5011) {
pSeat->eMuzzleflash.alpha = 1.0f;
pSeat->eMuzzleflash.scale = 0.5;
pSeat->eMuzzleflash.scale = 0.25;
pSeat->eMuzzleflash.skin = pSeat->fNumBones + 1;
setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
//setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
Event_EjectShell();
} else if (iCode == 5021) {
pSeat->eMuzzleflash.alpha = 1.0f;
pSeat->eMuzzleflash.scale = 0.5;
pSeat->eMuzzleflash.scale = 0.25;
pSeat->eMuzzleflash.skin = pSeat->fNumBones + 2;
setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
//setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
Event_EjectShell();
} else if (iCode == 5031) {
pSeat->eMuzzleflash.alpha = 1.0f;
pSeat->eMuzzleflash.scale = 0.5;
pSeat->eMuzzleflash.scale = 0.25;
pSeat->eMuzzleflash.skin = pSeat->fNumBones + 3;
setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
//setmodel(pSeat->eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1)));
Event_EjectShell();
}
}

View file

@ -17,7 +17,8 @@
var int autocvar_v_cambob = FALSE;
var int autocvar_v_camroll = TRUE;
void View_Init(void)
void
View_Init(void)
{
#ifdef CSTRIKE
string wm;
@ -39,9 +40,21 @@ void View_Init(void)
pSeat->eMuzzleflash.renderflags = RF_ADDITIVE;
}
}
/* there's also muzzleflash.spr, but that's just MUZZLE_SMALL again */
MUZZLE_RIFLE = (int)getmodelindex("sprites/muzzleflash1.spr");
MUZZLE_SMALL = (int)getmodelindex("sprites/muzzleflash2.spr");
MUZZLE_WEIRD = (int)getmodelindex("sprites/muzzleflash3.spr");
}
void View_CalcViewport(int s, float fWinWidth, float fWinHeight)
void
View_SetMuzzleflash(int index)
{
pSeat->eMuzzleflash.modelindex = (float)index;
}
void
View_CalcViewport(int s, float fWinWidth, float fWinHeight)
{
//FIXME: this is awkward. renderscene internally rounds to pixels.
//on the other hand, drawpic uses linear filtering and multisample and stuff.
@ -67,12 +80,8 @@ void View_CalcViewport(int s, float fWinWidth, float fWinHeight)
}
}
/*
====================
View_CalcBob
====================
*/
void View_CalcBob(void)
void
View_CalcBob(void)
{
float cycle;
@ -100,7 +109,8 @@ void View_CalcBob(void)
pSeat->fBob = bound(-7, fBob, 4);
}
float View_CalcRoll(void)
float
View_CalcRoll(void)
{
float roll;
makevectors(view_angles);
@ -110,13 +120,8 @@ float View_CalcRoll(void)
return autocvar_v_camroll ? roll : 0;
}
/*
=================
View_CalcCameraBob
=================
*/
void View_CalcCamBob(void)
void
View_CalcCamBob(void)
{
float flPlayerSpeed;
@ -210,8 +215,9 @@ void View_DrawViewModel(void)
float fBaseTime = eViewModel.frame1time;
eViewModel.frame2time = pl.weapontime;
eViewModel.frame1time = pl.weapontime;
processmodelevents(eViewModel.modelindex, eViewModel.frame, fBaseTime, eViewModel.frame1time, Event_ProcessModel);
processmodelevents(eViewModel.modelindex, eViewModel.frame, fBaseTime,
eViewModel.frame1time, Event_ProcessModel);
makevectors(view_angles);
eViewModel.angles = view_angles;
eViewModel.origin = pSeat->vPlayerOrigin + pl.view_ofs;
@ -219,7 +225,7 @@ void View_DrawViewModel(void)
+ (v_forward * autocvar_v_gunofs[0])
+ (v_right * autocvar_v_gunofs[1])
+ (v_up * autocvar_v_gunofs[2]);
// Left-handed weapons
if (autocvar_v_lefthanded) {
v_right *= -1;
@ -231,7 +237,7 @@ void View_DrawViewModel(void)
eViewModel.renderflags -= RF_USEAXIS;
}
}
// Give the gun a tilt effect like in old HL/CS versions
if (autocvar_v_bobclassic == 1) {
eViewModel.angles[2] = -pSeat->fBob;

View file

@ -87,6 +87,7 @@ void w_glock_primary(void)
return;
}
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-2,0,0]);
#else
if (!pl.glock_mag) {
@ -107,10 +108,10 @@ void w_glock_primary(void)
#endif
if (pl.a_ammo1) {
Weapons_ViewAnimation(GLOCK_SHOOT);
} else {
Weapons_ViewAnimation(GLOCK_SHOOT_EMPTY);
}
Weapons_ViewAnimation(GLOCK_SHOOT);
} else {
Weapons_ViewAnimation(GLOCK_SHOOT_EMPTY);
}
pl.w_attack_next = 0.3f;
pl.w_idle_next = 5.0f;

View file

@ -99,14 +99,15 @@ void w_mp5_primary(void)
#endif
if (random() < 0.5) {
Weapons_ViewAnimation(MP5_FIRE1);
} else {
Weapons_ViewAnimation(MP5_FIRE2);
}
Weapons_ViewAnimation(MP5_FIRE1);
} else {
Weapons_ViewAnimation(MP5_FIRE2);
}
/* Actual firing */
/* Actual firing */
#ifdef CSQC
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE);
Weapons_ViewPunchAngle([random(-2, 2),0,0]);
#else
/* Singleplayer is more accurate */

View file

@ -105,6 +105,7 @@ void w_python_primary(void)
Weapons_UpdateAmmo(pl, pl.python_mag, pl.ammo_357, __NULL__);
#else
pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_SMALL);
Weapons_ViewPunchAngle([-10,0,0]);
#endif
Weapons_ViewAnimation(PYTHON_FIRE1);

View file

@ -120,6 +120,7 @@ void w_shotgun_primary(void)
pl.shotgun_mag--;
Weapons_UpdateAmmo(pl, pl.shotgun_mag, pl.ammo_buckshot, __NULL__);
#else
View_SetMuzzleflash(MUZZLE_WEIRD);
Weapons_ViewPunchAngle([-5,0,0]);
pl.a_ammo1--;
#endif