Skip to content

Commit 9d7ab6a

Browse files
nekonomicona1batross
authored andcommitted
Some fixes for FoV, HUD, egon flare and new compilers. (#52)
* Fix warnings. * Merge some fixes from https://github.com/Fograin/hl-subs-mod.
1 parent 3401f54 commit 9d7ab6a

File tree

11 files changed

+105
-12
lines changed

11 files changed

+105
-12
lines changed

cl_dll/ev_hldm.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,17 @@ enum EGON_FIREMODE
14141414

14151415
BEAM *pBeam;
14161416
BEAM *pBeam2;
1417+
TEMPENTITY *pFlare; // Vit_amiN: egon's beam flare
1418+
1419+
void EV_EgonFlareCallback( struct tempent_s *ent, float frametime, float currenttime )
1420+
{
1421+
float delta = currenttime - ent->tentOffset.z; // time past since the last scale
1422+
if( delta >= ent->tentOffset.y )
1423+
{
1424+
ent->entity.curstate.scale += ent->tentOffset.x * delta;
1425+
ent->tentOffset.z = currenttime;
1426+
}
1427+
}
14171428

14181429
void EV_EgonFire( event_args_t *args )
14191430
{
@@ -1451,7 +1462,7 @@ void EV_EgonFire( event_args_t *args )
14511462
if( EV_IsLocal( idx ) )
14521463
gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 );
14531464

1454-
if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
1465+
if( iStartup == 1 && EV_IsLocal( idx ) && !( pBeam || pBeam2 || pFlare ) && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
14551466
{
14561467
vec3_t vecSrc, vecEnd, angles, forward, right, up;
14571468
pmtrace_t tr;
@@ -1499,8 +1510,16 @@ void EV_EgonFire( event_args_t *args )
14991510
pBeam->flags |= ( FBEAM_SINENOISE );
15001511

15011512
pBeam2 = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 5.0, 0.08, 0.7, 25, 0, 0, r, g, b );
1513+
1514+
// Vit_amiN: egon beam flare
1515+
pFlare = gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, gEngfuncs.pEventAPI->EV_FindModelIndex( EGON_FLARE_SPRITE ), kRenderGlow, kRenderFxNoDissipation, 1.0, 99999, FTENT_SPRCYCLE | FTENT_PERSIST );
15021516
}
15031517
}
1518+
1519+
if( pFlare ) // Vit_amiN: store the last mode for EV_EgonStop()
1520+
{
1521+
pFlare->tentOffset.x = ( iFireMode == FIRE_WIDE ) ? 1.0f : 0.0f;
1522+
}
15041523
}
15051524

15061525
void EV_EgonStop( event_args_t *args )
@@ -1529,6 +1548,26 @@ void EV_EgonStop( event_args_t *args )
15291548
pBeam2->die = 0.0;
15301549
pBeam2 = NULL;
15311550
}
1551+
1552+
if( pFlare ) // Vit_amiN: egon beam flare
1553+
{
1554+
pFlare->die = gEngfuncs.GetClientTime();
1555+
1556+
if( gEngfuncs.GetMaxClients() == 1 || !(pFlare->flags & FTENT_NOMODEL) )
1557+
{
1558+
if( pFlare->tentOffset.x != 0.0f ) // true for iFireMode == FIRE_WIDE
1559+
{
1560+
pFlare->callback = &EV_EgonFlareCallback;
1561+
pFlare->fadeSpeed = 2.0; // fade out will take 0.5 sec
1562+
pFlare->tentOffset.x = 10.0; // scaling speed per second
1563+
pFlare->tentOffset.y = 0.1; // min time between two scales
1564+
pFlare->tentOffset.z = pFlare->die; // the last callback run time
1565+
pFlare->flags = FTENT_FADEOUT | FTENT_CLIENTCUSTOM;
1566+
}
1567+
}
1568+
1569+
pFlare = NULL;
1570+
}
15321571
}
15331572
}
15341573
//======================

cl_dll/health.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ int CHudHealth::Draw( float flTime )
231231

232232
int iHeight = gHUD.m_iFontHeight;
233233
int iWidth = HealthWidth / 10;
234-
FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a );
234+
UnpackRGB( r, g, b, RGB_YELLOWISH );
235+
FillRGBA( x, y, iWidth, iHeight, r, g, b, a );
235236
}
236237

237238
DrawDamage( flTime );

cl_dll/hl/hl_objects.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
extern BEAM *pBeam;
3131
extern BEAM *pBeam2;
32+
extern TEMPENTITY *pFlare; // Vit_amiN: egon's energy flare
3233
void HUD_GetLastOrg( float *org );
3334

3435
void UpdateBeams( void )
@@ -75,6 +76,28 @@ void UpdateBeams( void )
7576
pBeam2->target = tr.endpos;
7677
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
7778
}
79+
80+
if( pFlare ) // Vit_amiN: beam flare
81+
{
82+
pFlare->entity.origin = tr.endpos;
83+
pFlare->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
84+
85+
if( gEngfuncs.GetMaxClients() != 1 ) // Singleplayer always draws the egon's energy beam flare
86+
{
87+
pFlare->flags |= FTENT_NOMODEL;
88+
89+
if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0 ) ) // Beam hit some non-world entity
90+
{
91+
physent_t *pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent );
92+
93+
// Not the world, let's assume that we hit something organic ( dog, cat, uncle joe, etc )
94+
if( pEntity && !( pEntity->solid == SOLID_BSP || pEntity->movetype == MOVETYPE_PUSHSTEP ) )
95+
{
96+
pFlare->flags &= ~FTENT_NOMODEL;
97+
}
98+
}
99+
}
100+
}
78101
}
79102

80103
/*
@@ -86,6 +109,6 @@ Add game specific, client-side objects here
86109
*/
87110
void Game_AddObjects( void )
88111
{
89-
if( pBeam && pBeam2 )
112+
if( pBeam || pBeam2 || pFlare ) // Vit_amiN: egon flare added
90113
UpdateBeams();
91114
}

cl_dll/hl/hl_weapons.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
extern globalvars_t *gpGlobals;
3636
extern int g_iUser1;
37+
extern bool g_hasPredictedFOV; // Vit_amiN: from HUD
3738

3839
// Pool of client side entities/entvars_t
3940
static entvars_t ev[32];
@@ -881,6 +882,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
881882
to->client.fuser2 = player.m_flNextAmmoBurn;
882883
to->client.fuser3 = player.m_flAmmoStartCharge;
883884
to->client.maxspeed = player.pev->maxspeed;
885+
g_hasPredictedFOV = true; // Vit_amiN: ready
884886

885887
//HL Weapons
886888
to->client.vuser1[0] = player.ammo_9mm;

cl_dll/hud.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf )
413413
}
414414

415415
float g_lastFOV = 0.0;
416+
bool g_hasPredictedFOV = false; // Vit_amiN: it'll became true after the first prediction
416417

417418
/*
418419
============
@@ -514,7 +515,7 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf )
514515
int def_fov = CVAR_GET_FLOAT( "default_fov" );
515516

516517
//Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
517-
if( cl_lw && cl_lw->value )
518+
if( g_hasPredictedFOV )
518519
return 1;
519520

520521
g_lastFOV = newfov;

cl_dll/hud.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class CHudScoreboard : public CHudBase
230230
void InitHUDData( void );
231231
int VidInit( void );
232232
int Draw( float flTime );
233-
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
233+
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, const char *team = NULL ); // returns the ypos where it finishes drawing
234234
void UserCmd_ShowScores( void );
235235
void UserCmd_HideScores( void );
236236
int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf );

cl_dll/hud_msg.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
extern BEAM *pBeam;
2727
extern BEAM *pBeam2;
28+
extern TEMPENTITY *pFlare; // Vit_amiN
29+
30+
extern float g_lastFOV; // Vit_amiN
31+
extern bool g_hasPredictedFOV; // Vit_amiN
2832

2933
/// USER-DEFINED SERVER MESSAGE HANDLERS
3034

@@ -48,6 +52,11 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf )
4852
// reset concussion effect
4953
m_iConcussionEffect = 0;
5054

55+
// Vit_amiN: reset the FOV
56+
m_iFOV = 0; // default_fov
57+
g_lastFOV = 0.0f;
58+
g_hasPredictedFOV = false;
59+
5160
return 1;
5261
}
5362

@@ -72,6 +81,7 @@ void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
7281

7382
//Probably not a good place to put this.
7483
pBeam = pBeam2 = NULL;
84+
pFlare = NULL; // Vit_amiN: clear egon's beam flare
7585
}
7686

7787
int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf )
@@ -107,10 +117,14 @@ int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )
107117

108118
int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
109119
{
120+
int r, g, b;
110121
BEGIN_READ( pbuf, iSize );
111122
m_iConcussionEffect = READ_BYTE();
112123
if( m_iConcussionEffect )
113-
this->m_StatusIcons.EnableIcon( "dmg_concuss", 255, 160, 0 );
124+
{
125+
UnpackRGB( r, g, b, RGB_YELLOWISH ); // Vit_amiN: fixed
126+
this->m_StatusIcons.EnableIcon( "dmg_concuss", r, g, b );
127+
}
114128
else
115129
this->m_StatusIcons.DisableIcon( "dmg_concuss" );
116130
return 1;

cl_dll/input_goldsource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
13681368
// y=ax^b; where a = 300 and b = 1.3
13691369
// also x values are in increments of 800 (so this is factored out)
13701370
// then bounds check result to level out excessively high spin rates
1371-
fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3);
1371+
fTemp = 300.0 * pow(fabs(fAxisValue) / 800.0, 1.3);
13721372
if (fTemp > 14000.0)
13731373
fTemp = 14000.0;
13741374
// restore direction information

cl_dll/scoreboard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ int CHudScoreboard::Draw( float fTime )
337337
extern float *GetClientColor( int client );
338338

339339
// returns the ypos where it finishes drawing
340-
int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team )
340+
int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, const char *team )
341341
{
342342
int can_show_packetloss = 0;
343343
int FAR_RIGHT;

dlls/monsters.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,8 @@ void CBaseMonster::StartMonster( void )
21182118
SetThink( &CBaseMonster::CallMonsterThink );
21192119
pev->nextthink += RANDOM_FLOAT( 0.1, 0.4 ); // spread think times.
21202120

2121-
if( !FStringNull( pev->targetname ) )// wait until triggered
2121+
// Vit_amiN: fixed -- now it doesn't touch any scripted_sequence target
2122+
if( !FStringNull( pev->targetname ) && !m_pCine )// wait until triggered
21222123
{
21232124
SetState( MONSTERSTATE_IDLE );
21242125
// UNDONE: Some scripted sequence monsters don't have an idle?

0 commit comments

Comments
 (0)