Revert some changes from PR

This commit is contained in:
a1batross 2016-08-08 15:01:16 +06:00
commit 008234143e
229 changed files with 29635 additions and 31529 deletions

View File

@ -26,9 +26,9 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE( m_MOTD, MOTD ); DECLARE_MESSAGE( m_MOTD, MOTD )
int CHudMOTD :: Init( void ) int CHudMOTD::Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
@ -42,13 +42,13 @@ int CHudMOTD :: Init( void )
return 1; return 1;
} }
int CHudMOTD :: VidInit( void ) int CHudMOTD::VidInit( void )
{ {
// Load sprites here // Load sprites here
return 1; return 1;
} }
void CHudMOTD :: Reset( void ) void CHudMOTD::Reset( void )
{ {
m_iFlags &= ~HUD_ACTIVE; // start out inactive m_iFlags &= ~HUD_ACTIVE; // start out inactive
m_szMOTD[0] = 0; m_szMOTD[0] = 0;
@ -60,7 +60,7 @@ void CHudMOTD :: Reset( void )
#define ROW_GAP 13 #define ROW_GAP 13
#define ROW_RANGE_MIN 30 #define ROW_RANGE_MIN 30
#define ROW_RANGE_MAX ( ScreenHeight - 100 ) #define ROW_RANGE_MAX ( ScreenHeight - 100 )
int CHudMOTD :: Draw( float fTime ) int CHudMOTD::Draw( float fTime )
{ {
gHUD.m_iNoConsolePrint &= ~( 1 << 1 ); gHUD.m_iNoConsolePrint &= ~( 1 << 1 );
if( !m_bShow ) if( !m_bShow )
@ -68,60 +68,61 @@ int CHudMOTD :: Draw( float fTime )
gHUD.m_iNoConsolePrint |= 1 << 1; gHUD.m_iNoConsolePrint |= 1 << 1;
bool bScroll; bool bScroll;
// find the top of where the MOTD should be drawn, so the whole thing is centered in the screen // find the top of where the MOTD should be drawn, so the whole thing is centered in the screen
int ypos = (ScreenHeight - LINE_HEIGHT * m_iLines)/2; // shift it up slightly int ypos = ( ScreenHeight - LINE_HEIGHT * m_iLines ) / 2; // shift it up slightly
char *ch = m_szMOTD; char *ch = m_szMOTD;
int xpos = (ScreenWidth - gHUD.m_scrinfo.charWidths[ 'M' ] * m_iMaxLength) / 2; int xpos = ( ScreenWidth - gHUD.m_scrinfo.charWidths['M'] * m_iMaxLength ) / 2;
if( xpos < 30 ) xpos = 30; if( xpos < 30 )
int xmax = xpos + gHUD.m_scrinfo.charWidths[ 'M' ] * m_iMaxLength; xpos = 30;
int xmax = xpos + gHUD.m_scrinfo.charWidths['M'] * m_iMaxLength;
int height = LINE_HEIGHT * m_iLines; int height = LINE_HEIGHT * m_iLines;
int ypos_r=ypos; int ypos_r=ypos;
if( height > ROW_RANGE_MAX ) if( height > ROW_RANGE_MAX )
{ {
ypos = ROW_RANGE_MIN + 7 + scroll; ypos = ROW_RANGE_MIN + 7 + scroll;
if( ypos > ROW_RANGE_MIN + 4 ) if( ypos > ROW_RANGE_MIN + 4 )
scroll-= (ypos - ( ROW_RANGE_MIN + 4))/3.0; scroll-= ( ypos - ( ROW_RANGE_MIN + 4 ) ) / 3.0;
if( ypos + height < ROW_RANGE_MAX ) if( ypos + height < ROW_RANGE_MAX )
scroll+= (ROW_RANGE_MAX - (ypos + height))/ 3.0; scroll+= ( ROW_RANGE_MAX - ( ypos + height ) ) / 3.0;
ypos_r = ROW_RANGE_MIN; ypos_r = ROW_RANGE_MIN;
height = ROW_RANGE_MAX; height = ROW_RANGE_MAX;
} }
int ymax = ypos + height; int ymax = ypos + height;
if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30; if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30;
gHUD.DrawDarkRectangle(xpos-5, ypos_r - 5, xmax - xpos+10, height + 10); gHUD.DrawDarkRectangle( xpos - 5, ypos_r - 5, xmax - xpos + 10, height + 10 );
while ( *ch ) while( *ch )
{ {
char *next_line; char *next_line;
int line_length = 0; // count the length of the current line int line_length = 0; // count the length of the current line
for ( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ ) for( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
line_length += gHUD.m_scrinfo.charWidths[ *next_line ]; line_length += gHUD.m_scrinfo.charWidths[*next_line];
char *top = next_line; char *top = next_line;
if ( *top == '\n' ) if( *top == '\n' )
*top = 0; *top = 0;
else else
top = NULL; top = NULL;
// find where to start drawing the line // find where to start drawing the line
if( (ypos > ROW_RANGE_MIN) && (ypos + LINE_HEIGHT <= ypos_r + height) ) if( ( ypos > ROW_RANGE_MIN ) && ( ypos + LINE_HEIGHT <= ypos_r + height ) )
gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 ); gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 );
ypos += LINE_HEIGHT; ypos += LINE_HEIGHT;
if ( top ) // restore if( top ) // restore
*top = '\n'; *top = '\n';
ch = next_line; ch = next_line;
if ( *ch == '\n' ) if( *ch == '\n' )
ch++; ch++;
if ( ypos > (ScreenHeight - 20) ) if( ypos > ( ScreenHeight - 20 ) )
break; // don't let it draw too low break; // don't let it draw too low
} }
return 1; return 1;
} }
int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
{ {
if ( m_iFlags & HUD_ACTIVE ) if( m_iFlags & HUD_ACTIVE )
{ {
Reset(); // clear the current MOTD in prep for this one Reset(); // clear the current MOTD in prep for this one
} }
@ -131,17 +132,16 @@ int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
int is_finished = READ_BYTE(); int is_finished = READ_BYTE();
strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) ); strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) );
if ( is_finished ) if( is_finished )
{ {
int length = 0; int length = 0;
m_iMaxLength = 0; m_iMaxLength = 0;
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
for( char *sz = m_szMOTD; *sz != 0; sz++ ) // count the number of lines in the MOTD
for ( char *sz = m_szMOTD; *sz != 0; sz++ ) // count the number of lines in the MOTD
{ {
if ( *sz == '\n' ) if( *sz == '\n' )
{ {
m_iLines++; m_iLines++;
if( length > m_iMaxLength ) if( length > m_iMaxLength )

File diff suppressed because it is too large Load Diff

View File

@ -29,74 +29,74 @@ public:
public: public:
// Public Interfaces // Public Interfaces
virtual int StudioDrawModel ( int flags ); virtual int StudioDrawModel( int flags );
virtual int StudioDrawPlayer ( int flags, struct entity_state_s *pplayer ); virtual int StudioDrawPlayer( int flags, struct entity_state_s *pplayer );
public: public:
// Local interfaces // Local interfaces
// //
// Look up animation data for sequence // Look up animation data for sequence
virtual mstudioanim_t *StudioGetAnim ( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc ); virtual mstudioanim_t *StudioGetAnim( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
// Interpolate model position and angles and set up matrices // Interpolate model position and angles and set up matrices
virtual void StudioSetUpTransform (int trivial_accept); virtual void StudioSetUpTransform( int trivial_accept );
// Set up model bone positions // Set up model bone positions
virtual void StudioSetupBones ( void ); virtual void StudioSetupBones( void );
// Find final attachment points // Find final attachment points
virtual void StudioCalcAttachments ( void ); virtual void StudioCalcAttachments( void );
// Save bone matrices and names // Save bone matrices and names
virtual void StudioSaveBones( void ); virtual void StudioSaveBones( void );
// Merge cached bones with current bones for model // Merge cached bones with current bones for model
virtual void StudioMergeBones ( model_t *m_pSubModel ); virtual void StudioMergeBones( model_t *m_pSubModel );
// Determine interpolation fraction // Determine interpolation fraction
virtual float StudioEstimateInterpolant( void ); virtual float StudioEstimateInterpolant( void );
// Determine current frame for rendering // Determine current frame for rendering
virtual float StudioEstimateFrame ( mstudioseqdesc_t *pseqdesc ); virtual float StudioEstimateFrame( mstudioseqdesc_t *pseqdesc );
// Apply special effects to transform matrix // Apply special effects to transform matrix
virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] ); virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
// Spherical interpolation of bones // Spherical interpolation of bones
virtual void StudioSlerpBones ( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s ); virtual void StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
// Compute bone adjustments ( bone controllers ) // Compute bone adjustments( bone controllers )
virtual void StudioCalcBoneAdj ( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen ); virtual void StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen );
// Get bone quaternions // Get bone quaternions
virtual void StudioCalcBoneQuaterion ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q ); virtual void StudioCalcBoneQuaterion( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q );
// Get bone positions // Get bone positions
virtual void StudioCalcBonePosition ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos ); virtual void StudioCalcBonePosition( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos );
// Compute rotations // Compute rotations
virtual void StudioCalcRotations ( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f ); virtual void StudioCalcRotations( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f );
// Send bones and verts to renderer // Send bones and verts to renderer
virtual void StudioRenderModel ( void ); virtual void StudioRenderModel( void );
// Finalize rendering // Finalize rendering
virtual void StudioRenderFinal (void); virtual void StudioRenderFinal( void );
// GL&D3D vs. Software renderer finishing functions // GL&D3D vs. Software renderer finishing functions
virtual void StudioRenderFinal_Software ( void ); virtual void StudioRenderFinal_Software( void );
virtual void StudioRenderFinal_Hardware ( void ); virtual void StudioRenderFinal_Hardware( void );
// Player specific data // Player specific data
// Determine pitch and blending amounts for players // Determine pitch and blending amounts for players
virtual void StudioPlayerBlend ( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch ); virtual void StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch );
// Estimate gait frame for player // Estimate gait frame for player
virtual void StudioEstimateGait ( entity_state_t *pplayer ); virtual void StudioEstimateGait( entity_state_t *pplayer );
// Process movement of player // Process movement of player
virtual void StudioProcessGait ( entity_state_t *pplayer ); virtual void StudioProcessGait( entity_state_t *pplayer );
public: public:
@ -156,20 +156,20 @@ public:
// Number of bones in bone cache // Number of bones in bone cache
int m_nCachedBones; int m_nCachedBones;
// Names of cached bones // Names of cached bones
char m_nCachedBoneNames[ MAXSTUDIOBONES ][ 32 ]; char m_nCachedBoneNames[MAXSTUDIOBONES][32];
// Cached bone & light transformation matrices // Cached bone & light transformation matrices
float m_rgCachedBoneTransform [ MAXSTUDIOBONES ][ 3 ][ 4 ]; float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4];
float m_rgCachedLightTransform[ MAXSTUDIOBONES ][ 3 ][ 4 ]; float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4];
// Software renderer scale factors // Software renderer scale factors
float m_fSoftwareXScale, m_fSoftwareYScale; float m_fSoftwareXScale, m_fSoftwareYScale;
// Current view vectors and render origin // Current view vectors and render origin
float m_vUp[ 3 ]; float m_vUp[3];
float m_vRight[ 3 ]; float m_vRight[3];
float m_vNormal[ 3 ]; float m_vNormal[3];
float m_vRenderOrigin[ 3 ]; float m_vRenderOrigin[3];
// Model render counters ( from engine ) // Model render counters ( from engine )
int *m_pStudioModelCount; int *m_pStudioModelCount;
@ -177,13 +177,13 @@ public:
// Matrices // Matrices
// Model to world transformation // Model to world transformation
float (*m_protationmatrix)[ 3 ][ 4 ]; float (*m_protationmatrix)[3][4];
// Model to view transformation // Model to view transformation
float (*m_paliastransform)[ 3 ][ 4 ]; float (*m_paliastransform)[3][4];
// Concatenated bone and light transforms // Concatenated bone and light transforms
float (*m_pbonetransform) [ MAXSTUDIOBONES ][ 3 ][ 4 ]; float (*m_pbonetransform)[MAXSTUDIOBONES][3][4];
float (*m_plighttransform)[ MAXSTUDIOBONES ][ 3 ][ 4 ]; float (*m_plighttransform)[MAXSTUDIOBONES][3][4];
}; };
#endif // STUDIOMODELRENDERER_H #endif // STUDIOMODELRENDERER_H

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,6 @@
#define MAX_WEAPON_NAME 128 #define MAX_WEAPON_NAME 128
#define WEAPON_FLAGS_SELECTONEMPTY 1 #define WEAPON_FLAGS_SELECTONEMPTY 1
#define WEAPON_IS_ONTARGET 0x40 #define WEAPON_IS_ONTARGET 0x40
@ -57,6 +56,4 @@ struct WEAPON
}; };
typedef int AMMO; typedef int AMMO;
#endif #endif

View File

@ -24,10 +24,10 @@
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal ); DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal )
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon ); DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon )
int CHudAmmoSecondary :: Init( void ) int CHudAmmoSecondary::Init( void )
{ {
HOOK_MESSAGE( SecAmmoVal ); HOOK_MESSAGE( SecAmmoVal );
HOOK_MESSAGE( SecAmmoIcon ); HOOK_MESSAGE( SecAmmoIcon );
@ -35,7 +35,7 @@ int CHudAmmoSecondary :: Init( void )
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
m_HUD_ammoicon = 0; m_HUD_ammoicon = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
Reset(); Reset();
@ -43,67 +43,68 @@ int CHudAmmoSecondary :: Init( void )
return 1; return 1;
} }
void CHudAmmoSecondary :: Reset( void ) void CHudAmmoSecondary::Reset( void )
{ {
m_fFade = 0; m_fFade = 0;
} }
int CHudAmmoSecondary :: VidInit( void ) int CHudAmmoSecondary::VidInit( void )
{ {
return 1; return 1;
} }
int CHudAmmoSecondary :: Draw(float flTime) int CHudAmmoSecondary::Draw( float flTime )
{ {
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) if( ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) )
return 1; return 1;
// draw secondary ammo icons above normal ammo readout // draw secondary ammo icons above normal ammo readout
int a, x, y, r, g, b, AmmoWidth; int a, x, y, r, g, b, AmmoWidth;
UnpackRGB( r, g, b, RGB_YELLOWISH ); UnpackRGB( r, g, b, RGB_YELLOWISH );
a = (int) max( MIN_ALPHA, m_fFade ); a = (int)max( MIN_ALPHA, m_fFade );
if (m_fFade > 0) if( m_fFade > 0 )
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons m_fFade -= ( gHUD.m_flTimeDelta * 20 ); // slowly lower alpha to fade out icons
ScaleColors( r, g, b, a ); ScaleColors( r, g, b, a );
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values y = ScreenHeight - ( gHUD.m_iFontHeight * 4 ); // this is one font height higher than the weapon ammo values
x = ScreenWidth - AmmoWidth; x = ScreenWidth - AmmoWidth;
if ( m_HUD_ammoicon ) if( m_HUD_ammoicon )
{ {
// Draw the ammo icon // Draw the ammo icon
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left); x -= ( gHUD.GetSpriteRect( m_HUD_ammoicon ).right - gHUD.GetSpriteRect( m_HUD_ammoicon ).left );
y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom); y -= ( gHUD.GetSpriteRect( m_HUD_ammoicon ).top - gHUD.GetSpriteRect( m_HUD_ammoicon ).bottom );
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b ); SPR_Set( gHUD.GetSprite( m_HUD_ammoicon ), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_ammoicon ) );
} }
else else
{ // move the cursor by the '0' char instead, since we don't have an icon to work with {
// move the cursor by the '0' char instead, since we don't have an icon to work with
x -= AmmoWidth; x -= AmmoWidth;
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom); y -= ( gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).top - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).bottom );
} }
// draw the ammo counts, in reverse order, from right to left // draw the ammo counts, in reverse order, from right to left
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- ) for( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
{ {
if ( m_iAmmoAmounts[i] < 0 ) if( m_iAmmoAmounts[i] < 0 )
continue; // negative ammo amounts imply that they shouldn't be drawn continue; // negative ammo amounts imply that they shouldn't be drawn
// half a char gap between the ammo number and the previous pic // half a char gap between the ammo number and the previous pic
x -= (AmmoWidth / 2); x -= ( AmmoWidth / 2 );
// draw the number, right-aligned // draw the number, right-aligned
x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth); x -= ( gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth );
gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b ); gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
if ( i != 0 ) if( i != 0 )
{ {
// draw the divider bar // draw the divider bar
x -= (AmmoWidth / 2); x -= ( AmmoWidth / 2 );
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a); FillRGBA( x, y, ( AmmoWidth/10 ), gHUD.m_iFontHeight, r, g, b, a );
} }
} }
@ -113,7 +114,7 @@ int CHudAmmoSecondary :: Draw(float flTime)
// Message handler for Secondary Ammo Value // Message handler for Secondary Ammo Value
// accepts one value: // accepts one value:
// string: sprite name // string: sprite name
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf ) int CHudAmmoSecondary::MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() ); m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
@ -126,12 +127,12 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, vo
// takes two values: // takes two values:
// byte: ammo index // byte: ammo index
// byte: ammo value // byte: ammo value
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf ) int CHudAmmoSecondary::MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int index = READ_BYTE(); int index = READ_BYTE();
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES ) if( index < 0 || index >= MAX_SEC_AMMO_VALUES )
return 1; return 1;
m_iAmmoAmounts[index] = READ_BYTE(); m_iAmmoAmounts[index] = READ_BYTE();
@ -139,13 +140,14 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi
// check to see if there is anything left to draw // check to see if there is anything left to draw
int count = 0; int count = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
{ {
count += max( 0, m_iAmmoAmounts[i] ); count += max( 0, m_iAmmoAmounts[i] );
} }
if ( count == 0 ) if( count == 0 )
{ // the ammo fields are all empty, so turn off this hud area {
// the ammo fields are all empty, so turn off this hud area
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
} }
@ -155,5 +157,3 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi
return 1; return 1;
} }

View File

@ -28,9 +28,9 @@
HistoryResource gHR; HistoryResource gHR;
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5) #define AMMO_PICKUP_GAP ( gHR.iHistoryGap + 5 )
#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2)) #define AMMO_PICKUP_PICK_HEIGHT ( 32 + ( gHR.iHistoryGap * 2 ) )
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100) #define AMMO_PICKUP_HEIGHT_MAX ( ScreenHeight - 100 )
#define MAX_ITEM_NAME 32 #define MAX_ITEM_NAME 32
int HISTORY_DRAW_TIME = 5; int HISTORY_DRAW_TIME = 5;
@ -43,13 +43,14 @@ struct ITEM_INFO
wrect_t rect; wrect_t rect;
}; };
void HistoryResource :: AddToHistory( int iType, int iId, int iCount ) void HistoryResource::AddToHistory( int iType, int iId, int iCount )
{ {
if ( iType == HISTSLOT_AMMO && !iCount ) if( iType == HISTSLOT_AMMO && !iCount )
return; // no amount, so don't add return; // no amount, so don't add
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) if( ( ( ( AMMO_PICKUP_GAP * iCurrentHistorySlot ) + AMMO_PICKUP_PICK_HEIGHT ) > AMMO_PICKUP_HEIGHT_MAX ) || ( iCurrentHistorySlot >= MAX_HISTORY ) )
{ // the pic would have to be drawn too high {
// the pic would have to be drawn too high
// so start from the bottom // so start from the bottom
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
@ -63,13 +64,14 @@ void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
} }
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount ) void HistoryResource::AddToHistory( int iType, const char *szName, int iCount )
{ {
if ( iType != HISTSLOT_ITEM ) if( iType != HISTSLOT_ITEM )
return; return;
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) if( ( ( ( AMMO_PICKUP_GAP * iCurrentHistorySlot ) + AMMO_PICKUP_PICK_HEIGHT ) > AMMO_PICKUP_HEIGHT_MAX ) || ( iCurrentHistorySlot >= MAX_HISTORY ) )
{ // the pic would have to be drawn too high {
// the pic would have to be drawn too high
// so start from the bottom // so start from the bottom
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
@ -77,9 +79,8 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
// I am really unhappy with all the code in this file // I am really unhappy with all the code in this file
int i = gHUD.GetSpriteIndex( szName ); int i = gHUD.GetSpriteIndex( szName );
if ( i == -1 ) if( i == -1 )
return; // unknown sprite name, don't add it to history return; // unknown sprite name, don't add it to history
freeslot->iId = i; freeslot->iId = i;
@ -90,12 +91,11 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
} }
void HistoryResource::CheckClearHistory( void )
void HistoryResource :: CheckClearHistory( void )
{ {
for ( int i = 0; i < MAX_HISTORY; i++ ) for( int i = 0; i < MAX_HISTORY; i++ )
{ {
if ( rgAmmoHistory[i].type ) if( rgAmmoHistory[i].type )
return; return;
} }
@ -105,79 +105,81 @@ void HistoryResource :: CheckClearHistory( void )
// //
// Draw Ammo pickup history // Draw Ammo pickup history
// //
int HistoryResource :: DrawAmmoHistory( float flTime ) int HistoryResource::DrawAmmoHistory( float flTime )
{ {
for ( int i = 0; i < MAX_HISTORY; i++ ) for( int i = 0; i < MAX_HISTORY; i++ )
{ {
if ( rgAmmoHistory[i].type ) if( rgAmmoHistory[i].type )
{ {
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME ); rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
if ( rgAmmoHistory[i].DisplayTime <= flTime ) if( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired {
// pic drawing time has expired
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) ); memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
CheckClearHistory(); CheckClearHistory();
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO ) else if( rgAmmoHistory[i].type == HISTSLOT_AMMO )
{ {
wrect_t rcPic; wrect_t rcPic;
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic ); HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
int r, g, b; int r, g, b;
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r, g, b, RGB_YELLOWISH );
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors( r, g, b, min( scale, 255 ) );
// Draw the pic // Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24; int xpos = ScreenWidth - 24;
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic if( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
{ // the dll has to make sure it has sent info the weapons you need {
// the dll has to make sure it has sent info the weapons you need
SPR_Set( *spr, r, g, b ); SPR_Set( *spr, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rcPic ); SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
} }
// do not draw black console string // do not draw black console string
if( !(( hud_textmode->value == 2 ) && ( scale < 200 )) ) if( !( ( hud_textmode->value == 2 ) && ( scale < 200 ) ) )
// Draw the number // Draw the number
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP ) else if( rgAmmoHistory[i].type == HISTSLOT_WEAP )
{ {
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId ); WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
if ( !weap ) if( !weap )
return 1; // we don't know about the weapon yet, so don't draw anything return 1; // we don't know about the weapon yet, so don't draw anything
int r, g, b; int r, g, b;
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r,g,b, RGB_YELLOWISH );
if ( !gWR.HasAmmo( weap ) ) if( !gWR.HasAmmo( weap ) )
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red UnpackRGB( r, g, b, RGB_REDISH ); // if the weapon doesn't have ammo, display it as red
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors( r, g, b, min( scale, 255 ) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) );
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left); int xpos = ScreenWidth - ( weap->rcInactive.right - weap->rcInactive.left );
SPR_Set( weap->hInactive, r, g, b ); SPR_Set( weap->hInactive, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive ); SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM ) else if( rgAmmoHistory[i].type == HISTSLOT_ITEM )
{ {
int r, g, b; int r, g, b;
if ( !rgAmmoHistory[i].iId ) if( !rgAmmoHistory[i].iId )
continue; // sprite not loaded continue; // sprite not loaded
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId ); wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r, g, b, RGB_YELLOWISH );
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors( r, g, b, min( scale, 255 ) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) );
int xpos = ScreenWidth - (rect.right - rect.left) - 10; int xpos = ScreenWidth - ( rect.right - rect.left ) - 10;
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b ); SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rect ); SPR_DrawAdditive( 0, xpos, ypos, &rect );
@ -185,8 +187,5 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
} }
} }
return 1; return 1;
} }

View File

@ -26,7 +26,7 @@ private:
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
// counts of weapons * ammo // counts of weapons * ammo
WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there WEAPON* rgSlots[MAX_WEAPON_SLOTS + 1][MAX_WEAPON_POSITIONS + 1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there
int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
public: public:
@ -49,25 +49,25 @@ public:
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; } WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
void AddWeapon( WEAPON *wp ) void AddWeapon( WEAPON *wp )
{ {
rgWeapons[ wp->iId ] = *wp; rgWeapons[wp->iId] = *wp;
LoadWeaponSprites( &rgWeapons[ wp->iId ] ); LoadWeaponSprites( &rgWeapons[wp->iId] );
} }
void PickupWeapon( WEAPON *wp ) void PickupWeapon( WEAPON *wp )
{ {
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp; rgSlots[wp->iSlot][wp->iSlotPos] = wp;
} }
void DropWeapon( WEAPON *wp ) void DropWeapon( WEAPON *wp )
{ {
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL; rgSlots[wp->iSlot][wp->iSlotPos] = NULL;
} }
void DropAllWeapons( void ) void DropAllWeapons( void )
{ {
for ( int i = 0; i < MAX_WEAPONS; i++ ) for( int i = 0; i < MAX_WEAPONS; i++ )
{ {
if ( rgWeapons[i].iId ) if( rgWeapons[i].iId )
DropWeapon( &rgWeapons[i] ); DropWeapon( &rgWeapons[i] );
} }
} }
@ -94,13 +94,12 @@ public:
extern WeaponsResource gWR; extern WeaponsResource gWR;
#define MAX_HISTORY 12 #define MAX_HISTORY 12
enum { enum {
HISTSLOT_EMPTY, HISTSLOT_EMPTY,
HISTSLOT_AMMO, HISTSLOT_AMMO,
HISTSLOT_WEAP, HISTSLOT_WEAP,
HISTSLOT_ITEM, HISTSLOT_ITEM
}; };
class HistoryResource class HistoryResource
@ -138,6 +137,3 @@ public:
}; };
extern HistoryResource gHR; extern HistoryResource gHR;

View File

@ -25,23 +25,22 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE(m_Battery, Battery) DECLARE_MESSAGE( m_Battery, Battery )
int CHudBattery::Init(void) int CHudBattery::Init( void )
{ {
m_iBat = 0; m_iBat = 0;
m_fFade = 0; m_fFade = 0;
m_iFlags = 0; m_iFlags = 0;
HOOK_MESSAGE(Battery); HOOK_MESSAGE( Battery );
gHUD.AddHudElem(this); gHUD.AddHudElem( this );
return 1; return 1;
}; }
int CHudBattery::VidInit( void )
int CHudBattery::VidInit(void)
{ {
int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" ); int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" ); int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
@ -52,17 +51,16 @@ int CHudBattery::VidInit(void)
m_iHeight = m_prc2->bottom - m_prc1->top; m_iHeight = m_prc2->bottom - m_prc1->top;
m_fFade = 0; m_fFade = 0;
return 1; return 1;
}; }
int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) int CHudBattery::MsgFunc_Battery( const char *pszName, int iSize, void *pbuf )
{ {
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int x = READ_SHORT(); int x = READ_SHORT();
if (x != m_iBat) if( x != m_iBat )
{ {
m_fFade = FADE_TIME; m_fFade = FADE_TIME;
m_iBat = x; m_iBat = x;
@ -71,68 +69,65 @@ int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
return 1; return 1;
} }
int CHudBattery::Draw( float flTime )
int CHudBattery::Draw(float flTime)
{ {
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) if( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
return 1; return 1;
int r, g, b, x, y, a; int r, g, b, x, y, a;
wrect_t rc; wrect_t rc;
rc = *m_prc2; rc = *m_prc2;
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 rc.top += m_iHeight * ( (float)( 100 - ( min( 100,m_iBat ) ) ) * 0.01 ); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r, g, b, RGB_YELLOWISH );
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) )
return 1; return 1;
// Has health changed? Flash the health # // Has health changed? Flash the health #
if (m_fFade) if( m_fFade )
{ {
if (m_fFade > FADE_TIME) if( m_fFade > FADE_TIME )
m_fFade = FADE_TIME; m_fFade = FADE_TIME;
m_fFade -= (gHUD.m_flTimeDelta * 20); m_fFade -= ( gHUD.m_flTimeDelta * 20 );
if (m_fFade <= 0) if( m_fFade <= 0 )
{ {
a = 128; a = 128;
m_fFade = 0; m_fFade = 0;
} }
// Fade the health number back to dim // Fade the health number back to dim
a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128;
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
} }
else else
a = MIN_ALPHA; a = MIN_ALPHA;
ScaleColors(r, g, b, a ); ScaleColors( r, g, b, a );
int iOffset = (m_prc1->bottom - m_prc1->top)/6; int iOffset = ( m_prc1->bottom - m_prc1->top ) / 6;
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = ScreenWidth/5; x = ScreenWidth / 5;
// make sure we have the right sprite handles // make sure we have the right sprite handles
if ( !m_hSprite1 ) if( !m_hSprite1 )
m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) ); m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
if ( !m_hSprite2 ) if( !m_hSprite2 )
m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) ); m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
SPR_Set(m_hSprite1, r, g, b ); SPR_Set( m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset, m_prc1); SPR_DrawAdditive( 0, x, y - iOffset, m_prc1 );
if (rc.bottom > rc.top) if( rc.bottom > rc.top )
{ {
SPR_Set(m_hSprite2, r, g, b ); SPR_Set( m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc); SPR_DrawAdditive( 0, x, y - iOffset + ( rc.top - m_prc2->top ), &rc );
} }
x += (m_prc1->right - m_prc1->left); x += ( m_prc1->right - m_prc1->left );
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b); x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b );
return 1; return 1;
} }

View File

@ -18,7 +18,6 @@ extern int cam_thirdperson;
void CAM_Init( void ); void CAM_Init( void );
void CAM_ClearStates( void ); void CAM_ClearStates( void );
void CAM_StartMouseMove(void); void CAM_StartMouseMove( void );
void CAM_EndMouseMove(void); void CAM_EndMouseMove( void );
#endif // _CAMERA_H_ #endif // _CAMERA_H_

View File

@ -32,7 +32,7 @@ extern "C"
cl_enginefunc_t gEngfuncs; cl_enginefunc_t gEngfuncs;
CHud gHUD; CHud gHUD;
mobile_engfuncs_t *gMobileEngfuncs = NULL; mobile_engfuncs_t *gMobileEngfuncs = NULL;
void InitInput (void); void InitInput( void );
void EV_HookEvents( void ); void EV_HookEvents( void );
void IN_Commands( void ); void IN_Commands( void );
@ -73,16 +73,16 @@ int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
{ {
int iret = 0; int iret = 0;
switch ( hullnumber ) switch( hullnumber )
{ {
case 0: // Normal player case 0: // Normal player
mins = Vector(-16, -16, -36); mins = Vector( -16, -16, -36 );
maxs = Vector(16, 16, 36); maxs = Vector( 16, 16, 36 );
iret = 1; iret = 1;
break; break;
case 1: // Crouched player case 1: // Crouched player
mins = Vector(-16, -16, -18 ); mins = Vector( -16, -16, -18 );
maxs = Vector(16, 16, 18 ); maxs = Vector( 16, 16, 18 );
iret = 1; iret = 1;
break; break;
case 2: // Point based hull case 2: // Point based hull
@ -136,10 +136,10 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{ {
gEngfuncs = *pEnginefuncs; gEngfuncs = *pEnginefuncs;
if (iVersion != CLDLL_INTERFACE_VERSION) if( iVersion != CLDLL_INTERFACE_VERSION )
return 0; return 0;
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t)); memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) );
EV_HookEvents(); EV_HookEvents();
@ -198,7 +198,6 @@ void DLLEXPORT HUD_Init( void )
gHUD.Init(); gHUD.Init();
} }
/* /*
========================== ==========================
HUD_Redraw HUD_Redraw
@ -215,7 +214,6 @@ int DLLEXPORT HUD_Redraw( float time, int intermission )
return 1; return 1;
} }
/* /*
========================== ==========================
HUD_UpdateClientData HUD_UpdateClientData
@ -229,11 +227,11 @@ returns 1 if anything has been changed, 0 otherwise.
========================== ==========================
*/ */
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime ) int DLLEXPORT HUD_UpdateClientData( client_data_t *pcldata, float flTime )
{ {
IN_Commands(); IN_Commands();
return gHUD.UpdateClientData(pcldata, flTime ); return gHUD.UpdateClientData( pcldata, flTime );
} }
/* /*
@ -258,11 +256,9 @@ Called by engine every frame that client .dll is loaded
*/ */
void DLLEXPORT HUD_Frame( double time ) void DLLEXPORT HUD_Frame( double time )
{ { gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
} }
/* /*
========================== ==========================
HUD_VoiceStatus HUD_VoiceStatus
@ -271,7 +267,7 @@ Called when a player starts or stops talking.
========================== ==========================
*/ */
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking) void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
{ {
} }

View File

@ -28,7 +28,7 @@
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned short word; typedef unsigned short word;
typedef float vec_t; typedef float vec_t;
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf );
#include "util_vector.h" #include "util_vector.h"

View File

@ -15,6 +15,7 @@
// //
// cl_util.h // cl_util.h
// //
#include "exportdef.h" #include "exportdef.h"
#include "cvardef.h" #include "cvardef.h"
@ -25,72 +26,70 @@
// Macros to hook function calls into the HUD object // Macros to hook function calls into the HUD object
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x ); #define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg( #x, __MsgFunc_##x );
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \ #define DECLARE_MESSAGE(y, x) int __MsgFunc_##x( const char *pszName, int iSize, void *pbuf ) \
{ \ { \
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \ return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
} }
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y ); #define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \ #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
{ \ { \
gHUD.y.UserCmd_##x( ); \ gHUD.y.UserCmd_##x( ); \
} }
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); } inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); } inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); } inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); }
#define SPR_Load (*gEngfuncs.pfnSPR_Load) #define SPR_Load ( *gEngfuncs.pfnSPR_Load )
#define SPR_Set (*gEngfuncs.pfnSPR_Set) #define SPR_Set ( *gEngfuncs.pfnSPR_Set )
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) #define SPR_Frames ( *gEngfuncs.pfnSPR_Frames )
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList) #define SPR_GetList ( *gEngfuncs.pfnSPR_GetList )
// SPR_Draw draws a the current sprite as solid // SPR_Draw draws a the current sprite as solid
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) #define SPR_Draw ( *gEngfuncs.pfnSPR_Draw )
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) // SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) #define SPR_DrawHoles ( *gEngfuncs.pfnSPR_DrawHoles )
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency) // SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) #define SPR_DrawAdditive ( *gEngfuncs.pfnSPR_DrawAdditive )
// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen. // SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen.
#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor) #define SPR_EnableScissor ( *gEngfuncs.pfnSPR_EnableScissor )
// SPR_DisableScissor disables the clipping rect // SPR_DisableScissor disables the clipping rect
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) #define SPR_DisableScissor ( *gEngfuncs.pfnSPR_DisableScissor )
// //
#define FillRGBA (*gEngfuncs.pfnFillRGBA) #define FillRGBA ( *gEngfuncs.pfnFillRGBA )
// ScreenHeight returns the height of the screen, in pixels // ScreenHeight returns the height of the screen, in pixels
#define ScreenHeight (gHUD.m_scrinfo.iHeight) #define ScreenHeight ( gHUD.m_scrinfo.iHeight )
// ScreenWidth returns the width of the screen, in pixels // ScreenWidth returns the width of the screen, in pixels
#define ScreenWidth (gHUD.m_scrinfo.iWidth) #define ScreenWidth ( gHUD.m_scrinfo.iWidth )
// Use this to set any co-ords in 640x480 space // Use this to set any co-ords in 640x480 space
#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f)) #define XRES(x) ( (int)( float(x) * ( (float)ScreenWidth / 640.0f ) + 0.5f ) )
#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f)) #define YRES(y) ( (int)( float(y) * ( (float)ScreenHeight / 480.0f ) + 0.5f ) )
// use this to project world coordinates to screen coordinates // use this to project world coordinates to screen coordinates
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f ) #define XPROJECT(x) ( ( 1.0f + (x) ) * ScreenWidth * 0.5f )
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f ) #define YPROJECT(y) ( ( 1.0f - (y) ) * ScreenHeight * 0.5f )
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) #define GetScreenInfo ( *gEngfuncs.pfnGetScreenInfo )
#define ServerCmd (*gEngfuncs.pfnServerCmd) #define ServerCmd ( *gEngfuncs.pfnServerCmd )
#define ClientCmd (*gEngfuncs.pfnClientCmd) #define ClientCmd ( *gEngfuncs.pfnClientCmd )
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) #define SetCrosshair ( *gEngfuncs.pfnSetCrosshair )
#define AngleVectors (*gEngfuncs.pfnAngleVectors) #define AngleVectors ( *gEngfuncs.pfnAngleVectors )
extern cvar_t *hud_textmode; extern cvar_t *hud_textmode;
extern float g_hud_text_color[3]; extern float g_hud_text_color[3];
inline void DrawSetTextColor(float r, float g, float b) inline void DrawSetTextColor( float r, float g, float b )
{ {
if( hud_textmode->value == 1 ) if( hud_textmode->value == 1 )
g_hud_text_color[0]=r, g_hud_text_color[1] = g, g_hud_text_color[2] = b; g_hud_text_color[0] = r, g_hud_text_color[1] = g, g_hud_text_color[2] = b;
else else
gEngfuncs.pfnDrawSetTextColor( r, g, b ); gEngfuncs.pfnDrawSetTextColor( r, g, b );
} }
// Gets the height & width of a sprite, at the specified frame // Gets the height & width of a sprite, at the specified frame
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); } inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); } inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
@ -104,7 +103,7 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, in
inline int DrawConsoleString( int x, int y, const char *string ) inline int DrawConsoleString( int x, int y, const char *string )
{ {
if( hud_textmode->value == 1 ) if( hud_textmode->value == 1 )
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255*g_hud_text_color[0], 255*g_hud_text_color[1], 255*g_hud_text_color[2]); return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] );
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string ); return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
} }
@ -120,7 +119,7 @@ inline int ConsoleStringLen( const char *string )
{ {
int _width = 0, _height = 0; int _width = 0, _height = 0;
if( hud_textmode->value == 1 ) if( hud_textmode->value == 1 )
return gHUD.DrawHudStringLen((char*)string); return gHUD.DrawHudStringLen( (char*)string );
GetConsoleStringSize( string, &_width, &_height ); GetConsoleStringSize( string, &_width, &_height );
return _width; return _width;
} }
@ -136,7 +135,7 @@ inline void CenterPrint( const char *string )
} }
// returns the players name of entity no. // returns the players name of entity no.
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) #define GetPlayerInfo ( *gEngfuncs.pfnGetPlayerInfo )
// sound functions // sound functions
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
@ -148,16 +147,16 @@ inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex(
void ScaleColors( int &r, int &g, int &b, int a ); void ScaleColors( int &r, int &g, int &b, int a );
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) #define DotProduct(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2])
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} #define VectorSubtract(a, b, c) { (c)[0] = (a)[0] - (b)[0]; (c)[1] = (a)[1] - (b)[1]; (c)[2] = (a)[2] - (b)[2]; }
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} #define VectorAdd(a, b, c) { (c)[0] = (a)[0] + (b)[0]; (c)[1] = (a)[1] + (b)[1]; (c)[2] = (a)[2] + (b)[2]; }
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} #define VectorCopy(a, b) { (b)[0] = (a)[0]; (b)[1] = (a)[1]; (b)[2] = (a)[2]; }
inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;} inline void VectorClear( float *a ) { a[0] = 0.0; a[1] = 0.0; a[2] = 0.0; }
float Length(const float *v); float Length( const float *v );
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc); void VectorMA( const float *veca, float scale, const float *vecb, float *vecc );
void VectorScale (const float *in, float scale, float *out); void VectorScale( const float *in, float scale, float *out );
float VectorNormalize (float *v); float VectorNormalize( float *v );
void VectorInverse ( float *v ); void VectorInverse( float *v );
extern vec3_t vec3_origin; extern vec3_t vec3_origin;
@ -166,11 +165,11 @@ extern vec3_t vec3_origin;
// disable 'truncation from 'const double' to 'float' warning message // disable 'truncation from 'const double' to 'float' warning message
#pragma warning( disable: 4305 ) #pragma warning( disable: 4305 )
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\
{\ {\
r = (ulRGB & 0xFF0000) >>16;\ r = ( ulRGB & 0xFF0000 ) >> 16;\
g = (ulRGB & 0xFF00) >> 8;\ g = ( ulRGB & 0xFF00 ) >> 8;\
b = ulRGB & 0xFF;\ b = ulRGB & 0xFF;\
} }
HSPRITE LoadSprite(const char *pszName); HSPRITE LoadSprite( const char *pszName );

View File

@ -41,14 +41,14 @@ COM_Log
Log debug messages to file ( appends ) Log debug messages to file ( appends )
==================== ====================
*/ */
void COM_Log( char *pszFile, char *fmt, ...) void COM_Log( char *pszFile, char *fmt, ... )
{ {
va_list argptr; va_list argptr;
char string[1024]; char string[1024];
FILE *fp; FILE *fp;
char *pfilename; char *pfilename;
if ( !pszFile ) if( !pszFile )
{ {
pfilename = "c:\\hllog.txt"; pfilename = "c:\\hllog.txt";
} }
@ -57,15 +57,15 @@ void COM_Log( char *pszFile, char *fmt, ...)
pfilename = pszFile; pfilename = pszFile;
} }
va_start (argptr,fmt); va_start( argptr, fmt );
vsprintf (string, fmt,argptr); vsprintf( string, fmt, argptr );
va_end (argptr); va_end( argptr );
fp = fopen( pfilename, "a+t"); fp = fopen( pfilename, "a+t");
if (fp) if( fp )
{ {
fprintf(fp, "%s", string); fprintf( fp, "%s", string );
fclose(fp); fclose( fp );
} }
} }
@ -83,7 +83,7 @@ Change weapon model animation
void HUD_SendWeaponAnim( int iAnim, int body, int force ) void HUD_SendWeaponAnim( int iAnim, int body, int force )
{ {
// Don't actually change it. // Don't actually change it.
if ( !g_runfuncs && !force ) if( !g_runfuncs && !force )
return; return;
g_currentanim = iAnim; g_currentanim = iAnim;
@ -113,7 +113,7 @@ Play a sound, if we are seeing this command for the first time
*/ */
void HUD_PlaySound( char *sound, float volume ) void HUD_PlaySound( char *sound, float volume )
{ {
if ( !g_runfuncs || !g_finalstate ) if( !g_runfuncs || !g_finalstate )
return; return;
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin ); gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
@ -132,7 +132,7 @@ void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short event
vec3_t org; vec3_t org;
vec3_t ang; vec3_t ang;
if ( !g_runfuncs || !g_finalstate ) if( !g_runfuncs || !g_finalstate )
return; return;
// Weapon prediction events are assumed to occur at the player's origin // Weapon prediction events are assumed to occur at the player's origin
@ -151,7 +151,6 @@ void HUD_SetMaxSpeed( const edict_t *ed, float speed )
{ {
} }
/* /*
===================== =====================
UTIL_WeaponTimeBase UTIL_WeaponTimeBase
@ -167,7 +166,7 @@ float UTIL_WeaponTimeBase( void )
static unsigned int glSeed = 0; static unsigned int glSeed = 0;
unsigned int seed_table[ 256 ] = unsigned int seed_table[256] =
{ {
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103, 28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103,
27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315, 27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315,
@ -190,14 +189,14 @@ unsigned int seed_table[ 256 ] =
unsigned int U_Random( void ) unsigned int U_Random( void )
{ {
glSeed *= 69069; glSeed *= 69069;
glSeed += seed_table[ glSeed & 0xff ]; glSeed += seed_table[glSeed & 0xff];
return ( ++glSeed & 0x0fffffff ); return ( ++glSeed & 0x0fffffff );
} }
void U_Srand( unsigned int seed ) void U_Srand( unsigned int seed )
{ {
glSeed = seed_table[ seed & 0xff ]; glSeed = seed_table[seed & 0xff];
} }
/* /*
@ -212,7 +211,7 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
U_Srand( (int)seed + low + high ); U_Srand( (int)seed + low + high );
range = high - low + 1; range = high - low + 1;
if ( !(range - 1) ) if( !( range - 1 ) )
{ {
return low; return low;
} }
@ -225,7 +224,7 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
offset = rnum % range; offset = rnum % range;
return (low + offset); return ( low + offset );
} }
} }
@ -236,7 +235,6 @@ UTIL_SharedRandomFloat
*/ */
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
{ {
//
unsigned int range; unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high ); U_Srand( (int)seed + *(int *)&low + *(int *)&high );
@ -245,7 +243,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
U_Random(); U_Random();
range = high - low; range = high - low;
if ( !range ) if( !range )
{ {
return low; return low;
} }
@ -258,7 +256,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
offset = (float)tensixrand / 65536.0; offset = (float)tensixrand / 65536.0;
return (low + offset * range ); return ( low + offset * range );
} }
} }
@ -270,8 +268,26 @@ stub functions for such things as precaching. So we don't have to modify weapon
is compiled into both game and client .dlls. is compiled into both game and client .dlls.
====================== ======================
*/ */
int stub_PrecacheModel ( char* s ) { return 0; } int stub_PrecacheModel( char* s )
int stub_PrecacheSound ( char* s ) { return 0; } {
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; } return 0;
const char *stub_NameForFunction ( unsigned long function ) { return "func"; } }
void stub_SetModel ( edict_t *e, const char *m ) {}
int stub_PrecacheSound( char* s )
{
return 0;
}
unsigned short stub_PrecacheEvent( int type, const char *s )
{
return 0;
}
const char *stub_NameForFunction( unsigned long function )
{
return "func";
}
void stub_SetModel( edict_t *e, const char *m )
{
}

View File

@ -20,7 +20,7 @@ extern "C"
void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
} }
void COM_Log( char *pszFile, char *fmt, ...); void COM_Log( char *pszFile, char *fmt, ... );
int CL_IsDead( void ); int CL_IsDead( void );
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
@ -34,9 +34,8 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed );
int stub_PrecacheModel( char* s ); int stub_PrecacheModel( char* s );
int stub_PrecacheSound( char* s ); int stub_PrecacheSound( char* s );
unsigned short stub_PrecacheEvent( int type, const char *s ); unsigned short stub_PrecacheEvent( int type, const char *s );
const char *stub_NameForFunction ( unsigned long function ); const char *stub_NameForFunction( unsigned long function );
void stub_SetModel ( struct edict_s *e, const char *m ); void stub_SetModel( struct edict_s *e, const char *m );
extern cvar_t *cl_lw; extern cvar_t *cl_lw;
@ -44,5 +43,4 @@ extern int g_runfuncs;
extern vec3_t v_angles; extern vec3_t v_angles;
extern float g_lastFOV; extern float g_lastFOV;
extern struct local_state_s *g_finalstate; extern struct local_state_s *g_finalstate;
#endif #endif

View File

@ -15,6 +15,7 @@
// //
// death notice // death notice
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
@ -22,11 +23,11 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE( m_DeathNotice, DeathMsg ); DECLARE_MESSAGE( m_DeathNotice, DeathMsg )
struct DeathNoticeItem { struct DeathNoticeItem {
char szKiller[MAX_PLAYER_NAME_LENGTH*2]; char szKiller[MAX_PLAYER_NAME_LENGTH * 2];
char szVictim[MAX_PLAYER_NAME_LENGTH*2]; char szVictim[MAX_PLAYER_NAME_LENGTH * 2];
int iId; // the index number of the associated sprite int iId; // the index number of the associated sprite
int iSuicide; int iSuicide;
int iTeamKill; int iTeamKill;
@ -41,7 +42,7 @@ static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 32 #define DEATHNOTICE_TOP 32
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ]; DeathNoticeItem rgDeathNoticeList[MAX_DEATHNOTICES + 1];
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 }; float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
float g_ColorRed[3] = { 1.0, 0.25, 0.25 }; float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
@ -51,21 +52,20 @@ float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
float *GetClientColor( int clientIndex ) float *GetClientColor( int clientIndex )
{ {
switch ( g_PlayerExtraInfo[clientIndex].teamnumber ) switch( g_PlayerExtraInfo[clientIndex].teamnumber )
{ {
case 1: return g_ColorBlue; case 1: return g_ColorBlue;
case 2: return g_ColorRed; case 2: return g_ColorRed;
case 3: return g_ColorYellow; case 3: return g_ColorYellow;
case 4: return g_ColorGreen; case 4: return g_ColorGreen;
case 0: return g_ColorYellow; case 0: return g_ColorYellow;
default: return g_ColorGrey;
default : return g_ColorGrey;
} }
return NULL; return NULL;
} }
int CHudDeathNotice :: Init( void ) int CHudDeathNotice::Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
@ -76,33 +76,32 @@ int CHudDeathNotice :: Init( void )
return 1; return 1;
} }
void CHudDeathNotice::InitHUDData( void )
void CHudDeathNotice :: InitHUDData( void )
{ {
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) ); memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
} }
int CHudDeathNotice::VidInit( void )
int CHudDeathNotice :: VidInit( void )
{ {
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" ); m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
return 1; return 1;
} }
int CHudDeathNotice :: Draw( float flTime ) int CHudDeathNotice::Draw( float flTime )
{ {
int x, y, r, g, b; int x, y, r, g, b;
for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) for( int i = 0; i < MAX_DEATHNOTICES; i++ )
{ {
if ( rgDeathNoticeList[i].iId == 0 ) if( rgDeathNoticeList[i].iId == 0 )
break; // we've gone through them all break; // we've gone through them all
if ( rgDeathNoticeList[i].flDisplayTime < flTime ) if( rgDeathNoticeList[i].flDisplayTime < flTime )
{ // display time has expired {
// display time has expired
// remove the current item from the list // remove the current item from the list
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i + 1], sizeof(DeathNoticeItem) * ( MAX_DEATHNOTICES - i ) );
i--; // continue on the next item; stop the counter getting incremented i--; // continue on the next item; stop the counter getting incremented
continue; continue;
} }
@ -111,26 +110,26 @@ int CHudDeathNotice :: Draw( float flTime )
// Only draw if the viewport will let me // Only draw if the viewport will let me
// vgui dropped out // vgui dropped out
//if ( gViewPort && gViewPort->AllowedToPrintText() ) //if( gViewPort && gViewPort->AllowedToPrintText() )
{ {
// Draw the death notice // Draw the death notice
y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!! y = YRES( DEATHNOTICE_TOP ) + 2 + ( 20 * i ); //!!!
int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; int id = ( rgDeathNoticeList[i].iId == -1 ) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); x = ScreenWidth - ConsoleStringLen( rgDeathNoticeList[i].szVictim ) - ( gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left );
if ( !rgDeathNoticeList[i].iSuicide ) if( !rgDeathNoticeList[i].iSuicide )
{ {
x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); x -= ( 5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
// Draw killers name // Draw killers name
if ( rgDeathNoticeList[i].KillerColor ) if( rgDeathNoticeList[i].KillerColor )
DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
} }
r = 255; g = 80; b = 0; r = 255; g = 80; b = 0;
if ( rgDeathNoticeList[i].iTeamKill ) if( rgDeathNoticeList[i].iTeamKill )
{ {
r = 10; g = 240; b = 10; // display it in sickly green r = 10; g = 240; b = 10; // display it in sickly green
} }
@ -139,12 +138,12 @@ int CHudDeathNotice :: Draw( float flTime )
SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_Set( gHUD.GetSprite(id), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); x += ( gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left );
// Draw victims name (if it was a player that was killed) // Draw victims name (if it was a player that was killed)
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE) if( rgDeathNoticeList[i].iNonPlayerKill == FALSE )
{ {
if ( rgDeathNoticeList[i].VictimColor ) if( rgDeathNoticeList[i].VictimColor )
DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
} }
@ -155,7 +154,7 @@ int CHudDeathNotice :: Draw( float flTime )
} }
// This message handler may be better off elsewhere // This message handler may be better off elsewhere
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf ) int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
{ {
int i; int i;
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
@ -167,30 +166,29 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
char killedwith[32]; char killedwith[32];
strcpy( killedwith, "d_" ); strcpy( killedwith, "d_" );
strncat( killedwith, READ_STRING(), 32 ); strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 );
gHUD.m_Spectator.DeathMessage( victim );
gHUD.m_Spectator.DeathMessage(victim); for( i = 0; i < MAX_DEATHNOTICES; i++ )
for ( i = 0; i < MAX_DEATHNOTICES; i++ )
{ {
if ( rgDeathNoticeList[i].iId == 0 ) if( rgDeathNoticeList[i].iId == 0 )
break; break;
} }
if ( i == MAX_DEATHNOTICES ) if( i == MAX_DEATHNOTICES )
{ // move the rest of the list forward to make room for this item {
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES ); // move the rest of the list forward to make room for this item
memmove( rgDeathNoticeList, rgDeathNoticeList + 1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
i = MAX_DEATHNOTICES - 1; i = MAX_DEATHNOTICES - 1;
} }
//if (gViewPort) //if(gViewPort)
// gViewPort->GetAllPlayersInfo(); // gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo();
// Get the Killer's name // Get the Killer's name
char *killer_name = g_PlayerInfoList[ killer ].name; char *killer_name = g_PlayerInfoList[killer].name;
if ( !killer_name ) if( !killer_name )
{ {
killer_name = ""; killer_name = "";
rgDeathNoticeList[i].szKiller[0] = 0; rgDeathNoticeList[i].szKiller[0] = 0;
@ -199,14 +197,14 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
{ {
rgDeathNoticeList[i].KillerColor = GetClientColor( killer ); rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH ); strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0; rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH - 1] = 0;
} }
// Get the Victim's name // Get the Victim's name
char *victim_name = NULL; char *victim_name = NULL;
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun) // If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
if ( ((char)victim) != -1 ) if ( ( (char)victim ) != -1 )
victim_name = g_PlayerInfoList[ victim ].name; victim_name = g_PlayerInfoList[victim].name;
if ( !victim_name ) if ( !victim_name )
{ {
victim_name = ""; victim_name = "";
@ -216,16 +214,16 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
{ {
rgDeathNoticeList[i].VictimColor = GetClientColor( victim ); rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH ); strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0; rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH - 1] = 0;
} }
// Is it a non-player object kill? // Is it a non-player object kill?
if ( ((char)victim) == -1 ) if ( ( (char)victim ) == -1 )
{ {
rgDeathNoticeList[i].iNonPlayerKill = TRUE; rgDeathNoticeList[i].iNonPlayerKill = TRUE;
// Store the object's name in the Victim slot (skip the d_ bit) // Store the object's name in the Victim slot (skip the d_ bit)
strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 ); strcpy( rgDeathNoticeList[i].szVictim, killedwith + 2 );
} }
else else
{ {
@ -244,7 +242,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" ); DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" );
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME; rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME;
if (rgDeathNoticeList[i].iNonPlayerKill) if( rgDeathNoticeList[i].iNonPlayerKill )
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed a " ); ConsolePrint( " killed a " );
@ -254,11 +252,11 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
else else
{ {
// record the death notice in the console // record the death notice in the console
if ( rgDeathNoticeList[i].iSuicide ) if( rgDeathNoticeList[i].iSuicide )
{ {
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
if ( !strcmp( killedwith, "d_world" ) ) if( !strcmp( killedwith, "d_world" ) )
{ {
ConsolePrint( " died" ); ConsolePrint( " died" );
} }
@ -267,7 +265,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
ConsolePrint( " killed self" ); ConsolePrint( " killed self" );
} }
} }
else if ( rgDeathNoticeList[i].iTeamKill ) else if( rgDeathNoticeList[i].iTeamKill )
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed his teammate " ); ConsolePrint( " killed his teammate " );
@ -280,17 +278,17 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
} }
if ( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill ) if( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
{ {
ConsolePrint( " with " ); ConsolePrint( " with " );
// replace the code names with the 'real' names // replace the code names with the 'real' names
if ( !strcmp( killedwith+2, "egon" ) ) if( !strcmp( killedwith + 2, "egon" ) )
strcpy( killedwith, "d_gluon gun" ); strcpy( killedwith, "d_gluon gun" );
if ( !strcmp( killedwith+2, "gauss" ) ) if ( !strcmp( killedwith + 2, "gauss" ) )
strcpy( killedwith, "d_tau cannon" ); strcpy( killedwith, "d_tau cannon" );
ConsolePrint( killedwith+2 ); // skip over the "d_" part ConsolePrint( killedwith + 2 ); // skip over the "d_" part
} }
ConsolePrint( "\n" ); ConsolePrint( "\n" );
@ -298,7 +296,3 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
return 1; return 1;
} }

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "demo.h" #include "demo.h"
@ -41,14 +42,14 @@ Write some data to the demo stream
void Demo_WriteBuffer( int type, int size, unsigned char *buffer ) void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
{ {
int pos = 0; int pos = 0;
unsigned char buf[ 32 * 1024 ]; unsigned char buf[32 * 1024];
*( int * )&buf[pos] = type; *(int *)&buf[pos] = type;
pos+=sizeof( int ); pos += sizeof(int);
memcpy( &buf[pos], buffer, size ); memcpy( &buf[pos], buffer, size );
// Write full buffer out // Write full buffer out
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf ); gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof(int), buf );
} }
/* /*
@ -63,36 +64,36 @@ void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
int type; int type;
int i = 0; int i = 0;
type = *( int * )buffer; type = *(int *)buffer;
i += sizeof( int ); i += sizeof(int);
switch ( type ) switch( type )
{ {
case TYPE_SNIPERDOT: case TYPE_SNIPERDOT:
g_demosniper = *(int * )&buffer[ i ]; g_demosniper = *(int *)&buffer[i];
i += sizeof( int ); i += sizeof(int);
if ( g_demosniper ) if( g_demosniper )
{ {
g_demosniperdamage = *( int * )&buffer[ i ]; g_demosniperdamage = *(int *)&buffer[i];
i += sizeof( int ); i += sizeof(int);
g_demosniperangles[ 0 ] = *(float *)&buffer[i]; g_demosniperangles[0] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
g_demosniperangles[ 1 ] = *(float *)&buffer[i]; g_demosniperangles[1] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
g_demosniperangles[ 2 ] = *(float *)&buffer[i]; g_demosniperangles[2] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
g_demosniperorg[ 0 ] = *(float *)&buffer[i]; g_demosniperorg[0] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
g_demosniperorg[ 1 ] = *(float *)&buffer[i]; g_demosniperorg[1] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
g_demosniperorg[ 2 ] = *(float *)&buffer[i]; g_demosniperorg[2] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
} }
break; break;
case TYPE_ZOOM: case TYPE_ZOOM:
g_demozoom = *(float * )&buffer[ i ]; g_demozoom = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof(float);
break; break;
default: default:
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );

View File

@ -23,5 +23,4 @@ extern int g_demosniperdamage;
extern float g_demosniperorg[3]; extern float g_demosniperorg[3];
extern float g_demosniperangles[3]; extern float g_demosniperangles[3];
extern float g_demozoom; extern float g_demozoom;
#endif #endif

View File

@ -20,7 +20,6 @@
#include "pmtrace.h" #include "pmtrace.h"
#include "pm_shared.h" #include "pm_shared.h"
void Game_AddObjects( void ); void Game_AddObjects( void );
extern vec3_t v_origin; extern vec3_t v_origin;
@ -47,7 +46,7 @@ HUD_AddEntity
*/ */
int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname ) int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname )
{ {
switch ( type ) switch( type )
{ {
case ET_NORMAL: case ET_NORMAL:
case ET_PLAYER: case ET_PLAYER:
@ -62,14 +61,13 @@ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *mode
// each frame every entity passes this function, so the overview hooks // each frame every entity passes this function, so the overview hooks
// it to filter the overview entities // it to filter the overview entities
if ( g_iUser1 ) if( g_iUser1 )
{ {
gHUD.m_Spectator.AddOverviewEntity( type, ent, modelname ); gHUD.m_Spectator.AddOverviewEntity( type, ent, modelname );
if ( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) && if( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) &&
ent->index == g_iUser2 ) ent->index == g_iUser2 )
return 0; // don't draw the player we are following in eye return 0; // don't draw the player we are following in eye
} }
return 1; return 1;
@ -136,8 +134,8 @@ void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct
dst->framerate = src->framerate; dst->framerate = src->framerate;
dst->body = src->body; dst->body = src->body;
memcpy( &dst->controller[0], &src->controller[0], 4 * sizeof( byte ) ); memcpy( &dst->controller[0], &src->controller[0], 4 * sizeof(byte) );
memcpy( &dst->blending[0], &src->blending[0], 2 * sizeof( byte ) ); memcpy( &dst->blending[0], &src->blending[0], 2 * sizeof(byte) );
VectorCopy( src->basevelocity, dst->basevelocity ); VectorCopy( src->basevelocity, dst->basevelocity );
@ -152,7 +150,7 @@ void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct
// Save off some data so other areas of the Client DLL can get to it // Save off some data so other areas of the Client DLL can get to it
cl_entity_t *player = gEngfuncs.GetLocalPlayer(); // Get the local player's index cl_entity_t *player = gEngfuncs.GetLocalPlayer(); // Get the local player's index
if ( dst->number == player->index ) if( dst->number == player->index )
{ {
g_iPlayerClass = dst->playerclass; g_iPlayerClass = dst->playerclass;
g_iTeamNumber = dst->team; g_iTeamNumber = dst->team;
@ -173,7 +171,7 @@ Because we can predict an arbitrary number of frames before the server responds
update is occupying. update is occupying.
========================= =========================
*/ */
void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd ) void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd )
{ {
ps->oldbuttons = pps->oldbuttons; ps->oldbuttons = pps->oldbuttons;
ps->flFallVelocity = pps->flFallVelocity; ps->flFallVelocity = pps->flFallVelocity;
@ -204,14 +202,13 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct
// Duck prevention // Duck prevention
pcd->iuser3 = ppcd->iuser3; pcd->iuser3 = ppcd->iuser3;
if ( gEngfuncs.IsSpectateOnly() ) if( gEngfuncs.IsSpectateOnly() )
{ {
// in specator mode we tell the engine who we want to spectate and how // in specator mode we tell the engine who we want to spectate and how
// iuser3 is not used for duck prevention (since the spectator can't duck at all) // iuser3 is not used for duck prevention (since the spectator can't duck at all)
pcd->iuser1 = g_iUser1; // observer mode pcd->iuser1 = g_iUser1; // observer mode
pcd->iuser2 = g_iUser2; // first target pcd->iuser2 = g_iUser2; // first target
pcd->iuser3 = g_iUser3; // second target pcd->iuser3 = g_iUser3; // second target
} }
// Fire prevention // Fire prevention
@ -225,7 +222,7 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct
VectorCopy( ppcd->vuser3, pcd->vuser3 ); VectorCopy( ppcd->vuser3, pcd->vuser3 );
VectorCopy( ppcd->vuser4, pcd->vuser4 ); VectorCopy( ppcd->vuser4, pcd->vuser4 );
memcpy( wd, pwd, 32 * sizeof( weapon_data_t ) ); memcpy( wd, pwd, 32 * sizeof(weapon_data_t) );
} }
/* /*
@ -243,35 +240,33 @@ void MoveModel( void )
// Load it up with some bogus data // Load it up with some bogus data
player = gEngfuncs.GetLocalPlayer(); player = gEngfuncs.GetLocalPlayer();
if ( !player ) if( !player )
return; return;
mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex ); mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex );
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
for ( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
{ {
// Don't draw over ourself... // Don't draw over ourself...
if ( ( i == 1 ) && ( j == 1 ) ) if( ( i == 1 ) && ( j == 1 ) )
continue; continue;
mymodel[ i * 3 + j ] = *player; mymodel[i * 3 + j] = *player;
mymodel[ i * 3 + j ].player = 0; mymodel[i * 3 + j].player = 0;
mymodel[ i * 3 + j ].model = mod; mymodel[i * 3 + j].model = mod;
mymodel[ i * 3 + j ].curstate.modelindex = modelindex; mymodel[i * 3 + j].curstate.modelindex = modelindex;
// Move it out a bit // Move it out a bit
mymodel[ i * 3 + j ].origin[0] = player->origin[0] + 50 * ( 1 - i ); mymodel[i * 3 + j].origin[0] = player->origin[0] + 50 * ( 1 - i );
mymodel[ i * 3 + j ].origin[1] = player->origin[1] + 50 * ( 1 - j ); mymodel[i * 3 + j].origin[1] = player->origin[1] + 50 * ( 1 - j );
gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &mymodel[i*3+j] ); gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &mymodel[i * 3 + j] );
} }
} }
} }
#endif #endif
//#define TRACE_TEST //#define TRACE_TEST
@ -285,12 +280,12 @@ void TraceModel( void )
{ {
cl_entity_t *ent; cl_entity_t *ent;
if ( hitent <= 0 ) if( hitent <= 0 )
return; return;
// Load it up with some bogus data // Load it up with some bogus data
ent = gEngfuncs.GetEntityByIndex( hitent ); ent = gEngfuncs.GetEntityByIndex( hitent );
if ( !ent ) if( !ent )
return; return;
hit = *ent; hit = *ent;
@ -302,7 +297,6 @@ void TraceModel( void )
gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &hit ); gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &hit );
} }
#endif #endif
*/ */
@ -311,9 +305,9 @@ void ParticleCallback( struct particle_s *particle, float frametime )
{ {
int i; int i;
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
particle->org[ i ] += particle->vel[ i ] * frametime; particle->org[i] += particle->vel[i] * frametime;
} }
} }
@ -325,10 +319,10 @@ void Particles( void )
curtime = gEngfuncs.GetClientTime(); curtime = gEngfuncs.GetClientTime();
if ( ( curtime - lasttime ) < 2.0 ) if( ( curtime - lasttime ) < 2.0 )
return; return;
if ( !color ) if( !color )
{ {
color = gEngfuncs.pfnRegisterVariable ( "color","255 0 0", 0 ); color = gEngfuncs.pfnRegisterVariable ( "color","255 0 0", 0 );
} }
@ -339,20 +333,20 @@ void Particles( void )
particle_t *p; particle_t *p;
int i, j; int i, j;
for ( i = 0; i < 1000; i++ ) for( i = 0; i < 1000; i++ )
{ {
int r, g, b; int r, g, b;
p = gEngfuncs.pEfxAPI->R_AllocParticle( ParticleCallback ); p = gEngfuncs.pEfxAPI->R_AllocParticle( ParticleCallback );
if ( !p ) if( !p )
break; break;
for ( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
{ {
p->org[ j ] = v_origin[ j ] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 );; p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 );
p->vel[ j ] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 ); p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 );
} }
if ( color ) if( color )
{ {
sscanf( color->string, "%i %i %i", &r, &g, &b ); sscanf( color->string, "%i %i %i", &r, &g, &b );
} }
@ -373,13 +367,13 @@ void Particles( void )
*/ */
/* /*
void TempEntCallback ( struct tempent_s *ent, float frametime, float currenttime ) void TempEntCallback( struct tempent_s *ent, float frametime, float currenttime )
{ {
int i; int i;
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
ent->entity.curstate.origin[ i ] += ent->entity.baseline.origin[ i ] * frametime; ent->entity.curstate.origin[i] += ent->entity.baseline.origin[i] * frametime;
} }
} }
@ -390,7 +384,7 @@ void TempEnts( void )
curtime = gEngfuncs.GetClientTime(); curtime = gEngfuncs.GetClientTime();
if ( ( curtime - lasttime ) < 10.0 ) if( ( curtime - lasttime ) < 10.0 )
return; return;
lasttime = curtime; lasttime = curtime;
@ -403,27 +397,27 @@ void TempEnts( void )
mod = gEngfuncs.CL_LoadModel( "sprites/laserdot.spr", &index ); mod = gEngfuncs.CL_LoadModel( "sprites/laserdot.spr", &index );
for ( i = 0; i < 100; i++ ) for( i = 0; i < 100; i++ )
{ {
for ( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
{ {
origin[ j ] = v_origin[ j ]; origin[j] = v_origin[j];
if ( j != 2 ) if( j != 2 )
{ {
origin[ j ] += 75; origin[j] += 75;
} }
} }
p = gEngfuncs.pEfxAPI->CL_TentEntAllocCustom( (float *)&origin, mod, 0, TempEntCallback ); p = gEngfuncs.pEfxAPI->CL_TentEntAllocCustom( (float *)&origin, mod, 0, TempEntCallback );
if ( !p ) if( !p )
break; break;
for ( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
{ {
p->entity.curstate.origin[ j ] = origin[ j ]; p->entity.curstate.origin[j] = origin[j];
// Store velocity in baseline origin // Store velocity in baseline origin
p->entity.baseline.origin[ j ] = gEngfuncs.pfnRandomFloat( -100, 100 ); p->entity.baseline.origin[j] = gEngfuncs.pfnRandomFloat( -100, 100 );
} }
// p->die is set to current time so all you have to do is add an additional time to it // p->die is set to current time so all you have to do is add an additional time to it
@ -433,9 +427,9 @@ void TempEnts( void )
*/ */
#if defined( BEAM_TEST ) #if defined( BEAM_TEST )
// Note can't index beam[ 0 ] in Beam callback, so don't use that index // Note can't index beam[0] in Beam callback, so don't use that index
// Room for 1 beam ( 0 can't be used ) // Room for 1 beam ( 0 can't be used )
static cl_entity_t beams[ 2 ]; static cl_entity_t beams[2];
void BeamEndModel( void ) void BeamEndModel( void )
{ {
@ -445,15 +439,15 @@ void BeamEndModel( void )
// Load it up with some bogus data // Load it up with some bogus data
player = gEngfuncs.GetLocalPlayer(); player = gEngfuncs.GetLocalPlayer();
if ( !player ) if( !player )
return; return;
mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex ); mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex );
if ( !mod ) if( !mod )
return; return;
// Slot 1 // Slot 1
model = &beams[ 1 ]; model = &beams[1];
*model = *player; *model = *player;
model->player = 0; model->player = 0;
@ -482,20 +476,20 @@ void Beams( void )
BeamEndModel(); BeamEndModel();
curtime = gEngfuncs.GetClientTime(); curtime = gEngfuncs.GetClientTime();
float end[ 3 ]; float end[3];
if ( ( curtime - lasttime ) < 10.0 ) if( ( curtime - lasttime ) < 10.0 )
return; return;
mod = gEngfuncs.CL_LoadModel( "sprites/laserbeam.spr", &index ); mod = gEngfuncs.CL_LoadModel( "sprites/laserbeam.spr", &index );
if ( !mod ) if( !mod )
return; return;
lasttime = curtime; lasttime = curtime;
end [ 0 ] = v_origin.x + 100; end[0] = v_origin.x + 100;
end [ 1 ] = v_origin.y + 100; end[1] = v_origin.y + 100;
end [ 2 ] = v_origin.z; end[2] = v_origin.z;
BEAM *p1; BEAM *p1;
p1 = gEngfuncs.pEfxAPI->R_BeamEntPoint( -1, end, index, p1 = gEngfuncs.pEfxAPI->R_BeamEntPoint( -1, end, index,
@ -519,7 +513,6 @@ void DLLEXPORT HUD_CreateEntities( void )
#if defined( TEST_IT ) #if defined( TEST_IT )
MoveModel(); MoveModel();
#endif #endif
#if defined( TRACE_TEST ) #if defined( TRACE_TEST )
TraceModel(); TraceModel();
#endif #endif
@ -530,11 +523,9 @@ void DLLEXPORT HUD_CreateEntities( void )
/* /*
TempEnts(); TempEnts();
*/ */
#if defined( BEAM_TEST ) #if defined( BEAM_TEST )
Beams(); Beams();
#endif #endif
// Add in any game specific objects // Add in any game specific objects
Game_AddObjects(); Game_AddObjects();
} }
@ -552,19 +543,19 @@ void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct
switch( event->event ) switch( event->event )
{ {
case 5001: case 5001:
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options) ); gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options ) );
break; break;
case 5011: case 5011:
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options) ); gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options ) );
break; break;
case 5021: case 5021:
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options) ); gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options ) );
break; break;
case 5031: case 5031:
gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options) ); gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options ) );
break; break;
case 5002: case 5002:
gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options), -100, 100 ); gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options ), -100, 100 );
break; break;
// Client side sound // Client side sound
case 5004: case 5004:
@ -610,19 +601,19 @@ void DLLEXPORT HUD_TempEntUpdate (
gEngfuncs.pEventAPI->EV_PushPMStates(); gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players. // Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( -1 ); gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 );
// !!!BUGBUG -- This needs to be time based // !!!BUGBUG -- This needs to be time based
gTempEntFrame = (gTempEntFrame+1) & 31; gTempEntFrame = ( gTempEntFrame + 1 ) & 31;
pTemp = *ppTempEntActive; pTemp = *ppTempEntActive;
// !!! Don't simulate while paused.... This is sort of a hack, revisit. // !!! Don't simulate while paused.... This is sort of a hack, revisit.
if ( frametime <= 0 ) if( frametime <= 0 )
{ {
while ( pTemp ) while( pTemp )
{ {
if ( !(pTemp->flags & FTENT_NOMODEL ) ) if( !( pTemp->flags & FTENT_NOMODEL ) )
{ {
Callback_AddVisibleEntity( &pTemp->entity ); Callback_AddVisibleEntity( &pTemp->entity );
} }
@ -637,7 +628,7 @@ void DLLEXPORT HUD_TempEntUpdate (
gravity = -frametime * cl_gravity; gravity = -frametime * cl_gravity;
gravitySlow = gravity * 0.5; gravitySlow = gravity * 0.5;
while ( pTemp ) while( pTemp )
{ {
int active; int active;
@ -645,25 +636,24 @@ void DLLEXPORT HUD_TempEntUpdate (
life = pTemp->die - client_time; life = pTemp->die - client_time;
pnext = pTemp->next; pnext = pTemp->next;
if ( life < 0 ) if( life < 0 )
{ {
if ( pTemp->flags & FTENT_FADEOUT ) if( pTemp->flags & FTENT_FADEOUT )
{ {
if (pTemp->entity.curstate.rendermode == kRenderNormal) if( pTemp->entity.curstate.rendermode == kRenderNormal)
pTemp->entity.curstate.rendermode = kRenderTransTexture; pTemp->entity.curstate.rendermode = kRenderTransTexture;
pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * ( 1 + life * pTemp->fadeSpeed ); pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * ( 1 + life * pTemp->fadeSpeed );
if ( pTemp->entity.curstate.renderamt <= 0 ) if( pTemp->entity.curstate.renderamt <= 0 )
active = 0; active = 0;
} }
else else
active = 0; active = 0;
} }
if ( !active ) // Kill it if( !active ) // Kill it
{ {
pTemp->next = *ppTempEntFree; pTemp->next = *ppTempEntFree;
*ppTempEntFree = pTemp; *ppTempEntFree = pTemp;
if ( !pprev ) // Deleting at head of list if( !pprev ) // Deleting at head of list
*ppTempEntActive = pnext; *ppTempEntActive = pnext;
else else
pprev->next = pnext; pprev->next = pnext;
@ -674,11 +664,11 @@ void DLLEXPORT HUD_TempEntUpdate (
VectorCopy( pTemp->entity.origin, pTemp->entity.prevstate.origin ); VectorCopy( pTemp->entity.origin, pTemp->entity.prevstate.origin );
if ( pTemp->flags & FTENT_SPARKSHOWER ) if( pTemp->flags & FTENT_SPARKSHOWER )
{ {
// Adjust speed if it's time // Adjust speed if it's time
// Scale is next think time // Scale is next think time
if ( client_time > pTemp->entity.baseline.scale ) if( client_time > pTemp->entity.baseline.scale )
{ {
// Show Sparks // Show Sparks
gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 ); gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 );
@ -686,7 +676,7 @@ void DLLEXPORT HUD_TempEntUpdate (
// Reduce life // Reduce life
pTemp->entity.baseline.framerate -= 0.1; pTemp->entity.baseline.framerate -= 0.1;
if ( pTemp->entity.baseline.framerate <= 0.0 ) if( pTemp->entity.baseline.framerate <= 0.0 )
{ {
pTemp->die = client_time; pTemp->die = client_time;
} }
@ -700,7 +690,7 @@ void DLLEXPORT HUD_TempEntUpdate (
} }
} }
} }
else if ( pTemp->flags & FTENT_PLYRATTACHMENT ) else if( pTemp->flags & FTENT_PLYRATTACHMENT )
{ {
cl_entity_t *pClient; cl_entity_t *pClient;
@ -708,16 +698,16 @@ void DLLEXPORT HUD_TempEntUpdate (
VectorAdd( pClient->origin, pTemp->tentOffset, pTemp->entity.origin ); VectorAdd( pClient->origin, pTemp->tentOffset, pTemp->entity.origin );
} }
else if ( pTemp->flags & FTENT_SINEWAVE ) else if( pTemp->flags & FTENT_SINEWAVE )
{ {
pTemp->x += pTemp->entity.baseline.origin[0] * frametime; pTemp->x += pTemp->entity.baseline.origin[0] * frametime;
pTemp->y += pTemp->entity.baseline.origin[1] * frametime; pTemp->y += pTemp->entity.baseline.origin[1] * frametime;
pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * (10*pTemp->entity.curstate.framerate); pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * ( 10 * pTemp->entity.curstate.framerate );
pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * (8*pTemp->entity.curstate.framerate); pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * ( 8 * pTemp->entity.curstate.framerate );
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
} }
else if ( pTemp->flags & FTENT_SPIRAL ) else if( pTemp->flags & FTENT_SPIRAL )
{ {
float s, c; float s, c;
s = sin( pTemp->entity.baseline.origin[2] + fastFreq ); s = sin( pTemp->entity.baseline.origin[2] + fastFreq );
@ -727,21 +717,20 @@ void DLLEXPORT HUD_TempEntUpdate (
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp ); pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp );
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
} }
else else
{ {
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime; pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime;
} }
if ( pTemp->flags & FTENT_SPRANIMATE ) if( pTemp->flags & FTENT_SPRANIMATE )
{ {
pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate; pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate;
if ( pTemp->entity.curstate.frame >= pTemp->frameMax ) if( pTemp->entity.curstate.frame >= pTemp->frameMax )
{ {
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame); pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)( pTemp->entity.curstate.frame );
if ( !(pTemp->flags & FTENT_SPRANIMATELOOP) ) if( !( pTemp->flags & FTENT_SPRANIMATELOOP ) )
{ {
// this animating sprite isn't set to loop, so destroy it. // this animating sprite isn't set to loop, so destroy it.
pTemp->die = client_time; pTemp->die = client_time;
@ -750,21 +739,21 @@ void DLLEXPORT HUD_TempEntUpdate (
} }
} }
} }
else if ( pTemp->flags & FTENT_SPRCYCLE ) else if( pTemp->flags & FTENT_SPRCYCLE )
{ {
pTemp->entity.curstate.frame += frametime * 10; pTemp->entity.curstate.frame += frametime * 10;
if ( pTemp->entity.curstate.frame >= pTemp->frameMax ) if( pTemp->entity.curstate.frame >= pTemp->frameMax )
{ {
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame); pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)( pTemp->entity.curstate.frame );
} }
} }
// Experiment // Experiment
#if 0 #if 0
if ( pTemp->flags & FTENT_SCALE ) if( pTemp->flags & FTENT_SCALE )
pTemp->entity.curstate.framerate += 20.0 * (frametime / pTemp->entity.curstate.framerate); pTemp->entity.curstate.framerate += 20.0 * ( frametime / pTemp->entity.curstate.framerate );
#endif #endif
if ( pTemp->flags & FTENT_ROTATE ) if( pTemp->flags & FTENT_ROTATE )
{ {
pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime; pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime;
pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime; pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime;
@ -773,12 +762,12 @@ void DLLEXPORT HUD_TempEntUpdate (
VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles ); VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles );
} }
if ( pTemp->flags & (FTENT_COLLIDEALL | FTENT_COLLIDEWORLD) ) if( pTemp->flags & ( FTENT_COLLIDEALL | FTENT_COLLIDEWORLD ) )
{ {
vec3_t traceNormal; vec3_t traceNormal( 0.0f, 0.0f, 0.0f );
float traceFraction = 1; float traceFraction = 1;
if ( pTemp->flags & FTENT_COLLIDEALL ) if( pTemp->flags & FTENT_COLLIDEALL )
{ {
pmtrace_t pmtrace; pmtrace_t pmtrace;
physent_t *pe; physent_t *pe;
@ -787,24 +776,23 @@ void DLLEXPORT HUD_TempEntUpdate (
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace ); gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace );
if( pmtrace.fraction != 1 )
if ( pmtrace.fraction != 1 )
{ {
pe = gEngfuncs.pEventAPI->EV_GetPhysent( pmtrace.ent ); pe = gEngfuncs.pEventAPI->EV_GetPhysent( pmtrace.ent );
if ( !pmtrace.ent || ( pe->info != pTemp->clientIndex ) ) if( !pmtrace.ent || ( pe->info != pTemp->clientIndex ) )
{ {
traceFraction = pmtrace.fraction; traceFraction = pmtrace.fraction;
VectorCopy( pmtrace.plane.normal, traceNormal ); VectorCopy( pmtrace.plane.normal, traceNormal );
if ( pTemp->hitcallback ) if( pTemp->hitcallback )
{ {
(*pTemp->hitcallback)( pTemp, &pmtrace ); (*pTemp->hitcallback)( pTemp, &pmtrace );
} }
} }
} }
} }
else if ( pTemp->flags & FTENT_COLLIDEWORLD ) else if( pTemp->flags & FTENT_COLLIDEWORLD )
{ {
pmtrace_t pmtrace; pmtrace_t pmtrace;
@ -812,59 +800,59 @@ void DLLEXPORT HUD_TempEntUpdate (
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace ); gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace );
if ( pmtrace.fraction != 1 ) if( pmtrace.fraction != 1 )
{ {
traceFraction = pmtrace.fraction; traceFraction = pmtrace.fraction;
VectorCopy( pmtrace.plane.normal, traceNormal ); VectorCopy( pmtrace.plane.normal, traceNormal );
if ( pTemp->flags & FTENT_SPARKSHOWER ) if( pTemp->flags & FTENT_SPARKSHOWER )
{ {
// Chop spark speeds a bit more // Chop spark speeds a bit more
// //
VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin ); VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin );
if ( Length( pTemp->entity.baseline.origin ) < 10 ) if( Length( pTemp->entity.baseline.origin ) < 10 )
{ {
pTemp->entity.baseline.framerate = 0.0; pTemp->entity.baseline.framerate = 0.0;
} }
} }
if ( pTemp->hitcallback ) if( pTemp->hitcallback )
{ {
(*pTemp->hitcallback)( pTemp, &pmtrace ); (*pTemp->hitcallback)( pTemp, &pmtrace );
} }
} }
} }
if ( traceFraction != 1 ) // Decent collision now, and damping works if( traceFraction != 1 ) // Decent collision now, and damping works
{ {
float proj, damp; float proj, damp;
// Place at contact point // Place at contact point
VectorMA( pTemp->entity.prevstate.origin, traceFraction*frametime, pTemp->entity.baseline.origin, pTemp->entity.origin ); VectorMA( pTemp->entity.prevstate.origin, traceFraction * frametime, pTemp->entity.baseline.origin, pTemp->entity.origin );
// Damp velocity // Damp velocity
damp = pTemp->bounceFactor; damp = pTemp->bounceFactor;
if ( pTemp->flags & (FTENT_GRAVITY|FTENT_SLOWGRAVITY) ) if( pTemp->flags & ( FTENT_GRAVITY | FTENT_SLOWGRAVITY ) )
{ {
damp *= 0.5; damp *= 0.5;
if ( traceNormal[2] > 0.9 ) // Hit floor? if( traceNormal[2] > 0.9 ) // Hit floor?
{ {
if ( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 ) if( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 )
{ {
damp = 0; // Stop damp = 0; // Stop
pTemp->flags &= ~(FTENT_ROTATE|FTENT_GRAVITY|FTENT_SLOWGRAVITY|FTENT_COLLIDEWORLD|FTENT_SMOKETRAIL); pTemp->flags &= ~( FTENT_ROTATE | FTENT_GRAVITY | FTENT_SLOWGRAVITY | FTENT_COLLIDEWORLD | FTENT_SMOKETRAIL);
pTemp->entity.angles[0] = 0; pTemp->entity.angles[0] = 0;
pTemp->entity.angles[2] = 0; pTemp->entity.angles[2] = 0;
} }
} }
} }
if (pTemp->hitSound) if( pTemp->hitSound )
{ {
Callback_TempEntPlaySound(pTemp, damp); Callback_TempEntPlaySound( pTemp, damp );
} }
if (pTemp->flags & FTENT_COLLIDEKILL) if( pTemp->flags & FTENT_COLLIDEKILL )
{ {
// die on impact // die on impact
pTemp->flags &= ~FTENT_FADEOUT; pTemp->flags &= ~FTENT_FADEOUT;
@ -873,16 +861,16 @@ void DLLEXPORT HUD_TempEntUpdate (
else else
{ {
// Reflect velocity // Reflect velocity
if ( damp != 0 ) if( damp != 0 )
{ {
proj = DotProduct( pTemp->entity.baseline.origin, traceNormal ); proj = DotProduct( pTemp->entity.baseline.origin, traceNormal );
VectorMA( pTemp->entity.baseline.origin, -proj*2, traceNormal, pTemp->entity.baseline.origin ); VectorMA( pTemp->entity.baseline.origin, -proj * 2, traceNormal, pTemp->entity.baseline.origin );
// Reflect rotation (fake) // Reflect rotation (fake)
pTemp->entity.angles[1] = -pTemp->entity.angles[1]; pTemp->entity.angles[1] = -pTemp->entity.angles[1];
} }
if ( damp != 1 ) if( damp != 1 )
{ {
VectorScale( pTemp->entity.baseline.origin, damp, pTemp->entity.baseline.origin ); VectorScale( pTemp->entity.baseline.origin, damp, pTemp->entity.baseline.origin );
@ -892,11 +880,10 @@ void DLLEXPORT HUD_TempEntUpdate (
} }
} }
if( ( pTemp->flags & FTENT_FLICKER ) && gTempEntFrame == pTemp->entity.curstate.effects )
if ( (pTemp->flags & FTENT_FLICKER) && gTempEntFrame == pTemp->entity.curstate.effects )
{ {
dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight (0); dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight(0);
VectorCopy (pTemp->entity.origin, dl->origin); VectorCopy( pTemp->entity.origin, dl->origin );
dl->radius = 60; dl->radius = 60;
dl->color.r = 255; dl->color.r = 255;
dl->color.g = 120; dl->color.g = 120;
@ -904,30 +891,30 @@ void DLLEXPORT HUD_TempEntUpdate (
dl->die = client_time + 0.01; dl->die = client_time + 0.01;
} }
if ( pTemp->flags & FTENT_SMOKETRAIL ) if( pTemp->flags & FTENT_SMOKETRAIL )
{ {
gEngfuncs.pEfxAPI->R_RocketTrail (pTemp->entity.prevstate.origin, pTemp->entity.origin, 1); gEngfuncs.pEfxAPI->R_RocketTrail( pTemp->entity.prevstate.origin, pTemp->entity.origin, 1 );
} }
if ( pTemp->flags & FTENT_GRAVITY ) if( pTemp->flags & FTENT_GRAVITY )
pTemp->entity.baseline.origin[2] += gravity; pTemp->entity.baseline.origin[2] += gravity;
else if ( pTemp->flags & FTENT_SLOWGRAVITY ) else if( pTemp->flags & FTENT_SLOWGRAVITY )
pTemp->entity.baseline.origin[2] += gravitySlow; pTemp->entity.baseline.origin[2] += gravitySlow;
if ( pTemp->flags & FTENT_CLIENTCUSTOM ) if( pTemp->flags & FTENT_CLIENTCUSTOM )
{ {
if ( pTemp->callback ) if( pTemp->callback )
{ {
( *pTemp->callback )( pTemp, frametime, client_time ); (*pTemp->callback)( pTemp, frametime, client_time );
} }
} }
// Cull to PVS (not frustum cull, just PVS) // Cull to PVS (not frustum cull, just PVS)
if ( !(pTemp->flags & FTENT_NOMODEL ) ) if( !( pTemp->flags & FTENT_NOMODEL ) )
{ {
if ( !Callback_AddVisibleEntity( &pTemp->entity ) ) if( !Callback_AddVisibleEntity( &pTemp->entity ) )
{ {
if ( !(pTemp->flags & FTENT_PERSIST) ) if( !( pTemp->flags & FTENT_PERSIST ) )
{ {
pTemp->die = client_time; // If we can't draw it this frame, just dump it. pTemp->die = client_time; // If we can't draw it this frame, just dump it.
pTemp->flags &= ~FTENT_FADEOUT; // Don't fade out, just die pTemp->flags &= ~FTENT_FADEOUT; // Don't fade out, just die
@ -937,7 +924,6 @@ void DLLEXPORT HUD_TempEntUpdate (
} }
pTemp = pnext; pTemp = pnext;
} }
finish: finish:
// Restore state info // Restore state info
gEngfuncs.pEventAPI->EV_PopPMStates(); gEngfuncs.pEventAPI->EV_PopPMStates();
@ -959,9 +945,9 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
#if defined( BEAM_TEST ) #if defined( BEAM_TEST )
// None by default, you would return a valic pointer if you create a client side // None by default, you would return a valic pointer if you create a client side
// beam and attach it to a client side entity. // beam and attach it to a client side entity.
if ( index > 0 && index <= 1 ) if( index > 0 && index <= 1 )
{ {
return &beams[ index ]; return &beams[index];
} }
else else
{ {
@ -971,4 +957,3 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
return NULL; return NULL;
#endif #endif
} }

View File

@ -13,6 +13,7 @@
* *
****/ ****/
// shared event functions // shared event functions
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
@ -25,7 +26,7 @@
#include "event_api.h" #include "event_api.h"
#include "pm_shared.h" #include "pm_shared.h"
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) ) #define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || ( g_iUser1 && ( gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) ) )
/* /*
================= =================
GetEntity GetEntity
@ -71,7 +72,7 @@ Is the entity's index in the player range?
*/ */
qboolean EV_IsPlayer( int idx ) qboolean EV_IsPlayer( int idx )
{ {
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() ) if( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
return true; return true;
return false; return false;
@ -87,8 +88,8 @@ Is the entity == the local player
qboolean EV_IsLocal( int idx ) qboolean EV_IsLocal( int idx )
{ {
// check if we are in some way in first person spec mode // check if we are in some way in first person spec mode
if ( IS_FIRSTPERSON_SPEC ) if( IS_FIRSTPERSON_SPEC )
return (g_iUser2 == idx); return ( g_iUser2 == idx );
else else
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false; return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
} }
@ -110,15 +111,15 @@ void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
VectorClear( view_ofs ); VectorClear( view_ofs );
view_ofs[2] = DEFAULT_VIEWHEIGHT; view_ofs[2] = DEFAULT_VIEWHEIGHT;
if ( EV_IsPlayer( idx ) ) if( EV_IsPlayer( idx ) )
{ {
// in spec mode use entity viewheigh, not own // in spec mode use entity viewheigh, not own
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC ) if( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
{ {
// Grab predicted result for local player // Grab predicted result for local player
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
} }
else if ( args->ducking == 1 ) else if( args->ducking == 1 )
{ {
view_ofs[2] = VEC_DUCK_VIEW; view_ofs[2] = VEC_DUCK_VIEW;
} }
@ -162,13 +163,13 @@ void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity,
VectorClear( view_ofs ); VectorClear( view_ofs );
view_ofs[2] = DEFAULT_VIEWHEIGHT; view_ofs[2] = DEFAULT_VIEWHEIGHT;
if ( EV_IsPlayer( idx ) ) if( EV_IsPlayer( idx ) )
{ {
if ( EV_IsLocal( idx ) ) if( EV_IsLocal( idx ) )
{ {
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
} }
else if ( args->ducking == 1 ) else if( args->ducking == 1 )
{ {
view_ofs[2] = VEC_DUCK_VIEW; view_ofs[2] = VEC_DUCK_VIEW;
} }
@ -177,7 +178,7 @@ void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity,
fR = gEngfuncs.pfnRandomFloat( 50, 70 ); fR = gEngfuncs.pfnRandomFloat( 50, 70 );
fU = gEngfuncs.pfnRandomFloat( 100, 150 ); fU = gEngfuncs.pfnRandomFloat( 100, 150 );
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25; ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale; ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
@ -195,7 +196,7 @@ void EV_MuzzleFlash( void )
{ {
// Add muzzle flash to current weapon model // Add muzzle flash to current weapon model
cl_entity_t *ent = GetViewEntity(); cl_entity_t *ent = GetViewEntity();
if ( !ent ) if( !ent )
{ {
return; return;
} }

File diff suppressed because it is too large Load Diff

View File

@ -20,10 +20,11 @@ typedef enum
BULLET_MONSTER_9MM, BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5, BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM, BULLET_MONSTER_12MM
} Bullet; }Bullet;
enum glock_e { enum glock_e
{
GLOCK_IDLE1 = 0, GLOCK_IDLE1 = 0,
GLOCK_IDLE2, GLOCK_IDLE2,
GLOCK_IDLE3, GLOCK_IDLE3,
@ -36,7 +37,8 @@ enum glock_e {
GLOCK_ADD_SILENCER GLOCK_ADD_SILENCER
}; };
enum shotgun_e { enum shotgun_e
{
SHOTGUN_IDLE = 0, SHOTGUN_IDLE = 0,
SHOTGUN_FIRE, SHOTGUN_FIRE,
SHOTGUN_FIRE2, SHOTGUN_FIRE2,
@ -58,10 +60,11 @@ enum mp5_e
MP5_DEPLOY, MP5_DEPLOY,
MP5_FIRE1, MP5_FIRE1,
MP5_FIRE2, MP5_FIRE2,
MP5_FIRE3, MP5_FIRE3
}; };
enum python_e { enum python_e
{
PYTHON_IDLE1 = 0, PYTHON_IDLE1 = 0,
PYTHON_FIDGET, PYTHON_FIDGET,
PYTHON_FIRE1, PYTHON_FIRE1,
@ -75,7 +78,8 @@ enum python_e {
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging #define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged #define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
enum gauss_e { enum gauss_e
{
GAUSS_IDLE = 0, GAUSS_IDLE = 0,
GAUSS_IDLE2, GAUSS_IDLE2,
GAUSS_FIDGET, GAUSS_FIDGET,
@ -91,5 +95,4 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName );
void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ); void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType );
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount ); int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY ); void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
#endif // EV_HLDMH #endif // EV_HLDMH

View File

@ -15,49 +15,6 @@
#define FTENT_FADEOUT 0x00000080 #define FTENT_FADEOUT 0x00000080
#define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
// time-based damage
//mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN
#define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisioning
#define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
//TF ADDITIONS
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
#define DMG_AIMED (1 << 28) // Does Hit location damage
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
#define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31)
// Some of these are HL/TFC specific? // Some of these are HL/TFC specific?
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype ); void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin ); void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
@ -69,5 +26,4 @@ void EV_CreateTracer( float *start, float *end );
struct cl_entity_s *GetEntity( int idx ); struct cl_entity_s *GetEntity( int idx );
struct cl_entity_s *GetViewEntity( void ); struct cl_entity_s *GetViewEntity( void );
void EV_MuzzleFlash( void ); void EV_MuzzleFlash( void );
#endif // EVENTSCRIPTSH #endif // EVENTSCRIPTSH

View File

@ -25,76 +25,71 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE( m_Flash, FlashBat )
DECLARE_MESSAGE( m_Flash, Flashlight )
DECLARE_MESSAGE(m_Flash, FlashBat)
DECLARE_MESSAGE(m_Flash, Flashlight)
#define BAT_NAME "sprites/%d_Flashlight.spr" #define BAT_NAME "sprites/%d_Flashlight.spr"
int CHudFlashlight::Init(void) int CHudFlashlight::Init( void )
{ {
m_fFade = 0; m_fFade = 0;
m_fOn = 0; m_fOn = 0;
HOOK_MESSAGE(Flashlight); HOOK_MESSAGE( Flashlight );
HOOK_MESSAGE(FlashBat); HOOK_MESSAGE( FlashBat );
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
gHUD.AddHudElem(this); gHUD.AddHudElem( this );
return 1; return 1;
}; }
void CHudFlashlight::Reset(void) void CHudFlashlight::Reset( void )
{ {
m_fFade = 0; m_fFade = 0;
m_fOn = 0; m_fOn = 0;
} }
int CHudFlashlight::VidInit(void) int CHudFlashlight::VidInit( void )
{ {
int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" ); int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" );
int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" ); int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" );
int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" ); int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" );
m_hSprite1 = gHUD.GetSprite(HUD_flash_empty); m_hSprite1 = gHUD.GetSprite( HUD_flash_empty );
m_hSprite2 = gHUD.GetSprite(HUD_flash_full); m_hSprite2 = gHUD.GetSprite( HUD_flash_full );
m_hBeam = gHUD.GetSprite(HUD_flash_beam); m_hBeam = gHUD.GetSprite( HUD_flash_beam );
m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty); m_prc1 = &gHUD.GetSpriteRect( HUD_flash_empty );
m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full); m_prc2 = &gHUD.GetSpriteRect( HUD_flash_full );
m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam); m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam);
m_iWidth = m_prc2->right - m_prc2->left; m_iWidth = m_prc2->right - m_prc2->left;
return 1; return 1;
}; }
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ) int CHudFlashlight::MsgFunc_FlashBat( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int x = READ_BYTE(); int x = READ_BYTE();
m_iBat = x; m_iBat = x;
m_flBat = ((float)x)/100.0; m_flBat = ( (float)x ) / 100.0;
return 1; return 1;
} }
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ) int CHudFlashlight::MsgFunc_Flashlight( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_fOn = READ_BYTE(); m_fOn = READ_BYTE();
int x = READ_BYTE(); int x = READ_BYTE();
m_iBat = x; m_iBat = x;
m_flBat = ((float)x)/100.0; m_flBat = ( (float)x ) / 100.0;
return 1; return 1;
} }
int CHudFlashlight::Draw(float flTime) int CHudFlashlight::Draw( float flTime )
{ {
static bool show = ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ); static bool show = ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) );
if( show != !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) ) if( show != !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) )
@ -105,54 +100,54 @@ int CHudFlashlight::Draw(float flTime)
gMobileEngfuncs->pfnTouchHideButtons( "flashlight", !show ); gMobileEngfuncs->pfnTouchHideButtons( "flashlight", !show );
} }
} }
if ( !show ) if( !show )
return 1; return 1;
int r, g, b, x, y, a; int r, g, b, x, y, a;
wrect_t rc; wrect_t rc;
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) )
return 1; return 1;
if (m_fOn) if( m_fOn )
a = 225; a = 225;
else else
a = MIN_ALPHA; a = MIN_ALPHA;
if (m_flBat < 0.20) if( m_flBat < 0.20 )
UnpackRGB(r,g,b, RGB_REDISH); UnpackRGB( r,g,b, RGB_REDISH );
else else
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r,g,b, RGB_YELLOWISH );
ScaleColors(r, g, b, a); ScaleColors( r, g, b, a );
y = (m_prc1->bottom - m_prc2->top)/2; y = ( m_prc1->bottom - m_prc2->top ) / 2;
x = ScreenWidth - m_iWidth - m_iWidth/2 ; x = ScreenWidth - m_iWidth - m_iWidth / 2 ;
// Draw the flashlight casing // Draw the flashlight casing
SPR_Set(m_hSprite1, r, g, b ); SPR_Set( m_hSprite1, r, g, b );
SPR_DrawAdditive( 0, x, y, m_prc1); SPR_DrawAdditive( 0, x, y, m_prc1 );
if ( m_fOn ) if( m_fOn )
{ // draw the flashlight beam {
x = ScreenWidth - m_iWidth/2; // draw the flashlight beam
x = ScreenWidth - m_iWidth / 2;
SPR_Set( m_hBeam, r, g, b ); SPR_Set( m_hBeam, r, g, b );
SPR_DrawAdditive( 0, x, y, m_prcBeam ); SPR_DrawAdditive( 0, x, y, m_prcBeam );
} }
// draw the flashlight energy level // draw the flashlight energy level
x = ScreenWidth - m_iWidth - m_iWidth/2 ; x = ScreenWidth - m_iWidth - m_iWidth / 2;
int iOffset = m_iWidth * (1.0 - m_flBat); int iOffset = m_iWidth * ( 1.0 - m_flBat );
if (iOffset < m_iWidth) if( iOffset < m_iWidth )
{ {
rc = *m_prc2; rc = *m_prc2;
rc.left += iOffset; rc.left += iOffset;
SPR_Set(m_hSprite2, r, g, b ); SPR_Set( m_hSprite2, r, g, b );
SPR_DrawAdditive( 0, x + iOffset, y, &rc); SPR_DrawAdditive( 0, x + iOffset, y, &rc );
} }
return 1; return 1;
} }

View File

@ -26,28 +26,28 @@
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE(m_Geiger, Geiger ) DECLARE_MESSAGE( m_Geiger, Geiger )
int CHudGeiger::Init(void) int CHudGeiger::Init( void )
{ {
HOOK_MESSAGE( Geiger ); HOOK_MESSAGE( Geiger );
m_iGeigerRange = 0; m_iGeigerRange = 0;
m_iFlags = 0; m_iFlags = 0;
gHUD.AddHudElem(this); gHUD.AddHudElem( this );
srand( (unsigned)time( NULL ) ); srand( (unsigned)time( NULL ) );
return 1; return 1;
}; }
int CHudGeiger::VidInit(void) int CHudGeiger::VidInit( void )
{ {
return 1; return 1;
}; }
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf) int CHudGeiger::MsgFunc_Geiger( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -61,95 +61,95 @@ int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
return 1; return 1;
} }
int CHudGeiger::Draw (float flTime) int CHudGeiger::Draw( float flTime )
{ {
int pct; int pct;
float flvol = 0.0f; float flvol = 0.0f;
int rg[3]; int rg[3];
int i; int i;
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0) if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 )
{ {
// peicewise linear is better than continuous formula for this // peicewise linear is better than continuous formula for this
if (m_iGeigerRange > 800) if( m_iGeigerRange > 800 )
{ {
pct = 0; //Con_Printf ( "range > 800\n"); pct = 0; //Con_Printf( "range > 800\n" );
} }
else if (m_iGeigerRange > 600) else if( m_iGeigerRange > 600 )
{ {
pct = 2; pct = 2;
flvol = 0.4; //Con_Printf ( "range > 600\n"); flvol = 0.4; //Con_Printf( "range > 600\n" );
rg[0] = 1; rg[0] = 1;
rg[1] = 1; rg[1] = 1;
i = 2; i = 2;
} }
else if (m_iGeigerRange > 500) else if( m_iGeigerRange > 500 )
{ {
pct = 4; pct = 4;
flvol = 0.5; //Con_Printf ( "range > 500\n"); flvol = 0.5; //Con_Printf( "range > 500\n" );
rg[0] = 1; rg[0] = 1;
rg[1] = 2; rg[1] = 2;
i = 2; i = 2;
} }
else if (m_iGeigerRange > 400) else if( m_iGeigerRange > 400 )
{ {
pct = 8; pct = 8;
flvol = 0.6; //Con_Printf ( "range > 400\n"); flvol = 0.6; //Con_Printf( "range > 400\n" );
rg[0] = 1; rg[0] = 1;
rg[1] = 2; rg[1] = 2;
rg[2] = 3; rg[2] = 3;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 300) else if( m_iGeigerRange > 300 )
{ {
pct = 8; pct = 8;
flvol = 0.7; //Con_Printf ( "range > 300\n"); flvol = 0.7; //Con_Printf( "range > 300\n" );
rg[0] = 2; rg[0] = 2;
rg[1] = 3; rg[1] = 3;
rg[2] = 4; rg[2] = 4;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 200) else if( m_iGeigerRange > 200 )
{ {
pct = 28; pct = 28;
flvol = 0.78; //Con_Printf ( "range > 200\n"); flvol = 0.78; //Con_Printf( "range > 200\n" );
rg[0] = 2; rg[0] = 2;
rg[1] = 3; rg[1] = 3;
rg[2] = 4; rg[2] = 4;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 150) else if( m_iGeigerRange > 150 )
{ {
pct = 40; pct = 40;
flvol = 0.80; //Con_Printf ( "range > 150\n"); flvol = 0.80; //Con_Printf( "range > 150\n" );
rg[0] = 3; rg[0] = 3;
rg[1] = 4; rg[1] = 4;
rg[2] = 5; rg[2] = 5;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 100) else if( m_iGeigerRange > 100 )
{ {
pct = 60; pct = 60;
flvol = 0.85; //Con_Printf ( "range > 100\n"); flvol = 0.85; //Con_Printf( "range > 100\n" );
rg[0] = 3; rg[0] = 3;
rg[1] = 4; rg[1] = 4;
rg[2] = 5; rg[2] = 5;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 75) else if( m_iGeigerRange > 75 )
{ {
pct = 80; pct = 80;
flvol = 0.9; //Con_Printf ( "range > 75\n"); flvol = 0.9; //Con_Printf( "range > 75\n" );
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
rg[0] = 4; rg[0] = 4;
rg[1] = 5; rg[1] = 5;
rg[2] = 6; rg[2] = 6;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 50) else if( m_iGeigerRange > 50 )
{ {
pct = 90; pct = 90;
flvol = 0.95; //Con_Printf ( "range > 50\n"); flvol = 0.95; //Con_Printf( "range > 50\n" );
rg[0] = 5; rg[0] = 5;
rg[1] = 6; rg[1] = 6;
i = 2; i = 2;
@ -157,26 +157,25 @@ int CHudGeiger::Draw (float flTime)
else else
{ {
pct = 95; pct = 95;
flvol = 1.0; //Con_Printf ( "range < 50\n"); flvol = 1.0; //Con_Printf( "range < 50\n" );
rg[0] = 5; rg[0] = 5;
rg[1] = 6; rg[1] = 6;
i = 2; i = 2;
} }
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); flvol = ( flvol * ( (rand() & 127) ) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
if ((rand() & 127) < pct || (rand() & 127) < pct) if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct )
{ {
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100); //S_StartDynamicSound( -1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100 );
char sz[256]; char sz[256];
int j = rand() & 1; int j = rand() & 1;
if (i > 2) if( i > 2 )
j += rand() & 1; j += rand() & 1;
sprintf(sz, "player/geiger%d.wav", j + 1); sprintf( sz, "player/geiger%d.wav", j + 1 );
PlaySound(sz, flvol); PlaySound( sz, flvol );
} }
} }

View File

@ -29,8 +29,8 @@
#include "mobility_int.h" #include "mobility_int.h"
DECLARE_MESSAGE(m_Health, Health ) DECLARE_MESSAGE( m_Health, Health )
DECLARE_MESSAGE(m_Health, Damage ) DECLARE_MESSAGE( m_Health, Damage )
#define PAIN_NAME "sprites/%d_pain.spr" #define PAIN_NAME "sprites/%d_pain.spr"
#define DAMAGE_NAME "sprites/%d_dmg.spr" #define DAMAGE_NAME "sprites/%d_dmg.spr"
@ -53,10 +53,10 @@ int giDmgFlags[NUM_DMG_TYPES] =
DMG_HALLUC DMG_HALLUC
}; };
int CHudHealth::Init(void) int CHudHealth::Init( void )
{ {
HOOK_MESSAGE(Health); HOOK_MESSAGE( Health );
HOOK_MESSAGE(Damage); HOOK_MESSAGE( Damage );
m_iHealth = 100; m_iHealth = 100;
m_fFade = 0; m_fFade = 0;
m_iFlags = 0; m_iFlags = 0;
@ -65,10 +65,9 @@ int CHudHealth::Init(void)
giDmgHeight = 0; giDmgHeight = 0;
giDmgWidth = 0; giDmgWidth = 0;
memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES); memset( m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES );
gHUD.AddHudElem( this );
gHUD.AddHudElem(this);
return 1; return 1;
} }
@ -77,28 +76,28 @@ void CHudHealth::Reset( void )
// make sure the pain compass is cleared when the player respawns // make sure the pain compass is cleared when the player respawns
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0; m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
// force all the flashing damage icons to expire // force all the flashing damage icons to expire
m_bitsDamage = 0; m_bitsDamage = 0;
for ( int i = 0; i < NUM_DMG_TYPES; i++ ) for( int i = 0; i < NUM_DMG_TYPES; i++ )
{ {
m_dmg[i].fExpire = 0; m_dmg[i].fExpire = 0;
} }
} }
int CHudHealth::VidInit(void) int CHudHealth::VidInit( void )
{ {
m_hSprite = 0; m_hSprite = 0;
m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1; m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1;
m_HUD_cross = gHUD.GetSpriteIndex( "cross" ); m_HUD_cross = gHUD.GetSpriteIndex( "cross" );
giDmgHeight = gHUD.GetSpriteRect(m_HUD_dmg_bio).right - gHUD.GetSpriteRect(m_HUD_dmg_bio).left; giDmgHeight = gHUD.GetSpriteRect( m_HUD_dmg_bio ).right - gHUD.GetSpriteRect( m_HUD_dmg_bio ).left;
giDmgWidth = gHUD.GetSpriteRect(m_HUD_dmg_bio).bottom - gHUD.GetSpriteRect(m_HUD_dmg_bio).top; giDmgWidth = gHUD.GetSpriteRect( m_HUD_dmg_bio ).bottom - gHUD.GetSpriteRect( m_HUD_dmg_bio ).top;
return 1; return 1;
} }
int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf ) int CHudHealth::MsgFunc_Health( const char *pszName, int iSize, void *pbuf )
{ {
// TODO: update local health data // TODO: update local health data
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -107,7 +106,7 @@ int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
// Only update the fade if we've changed health // Only update the fade if we've changed health
if (x != m_iHealth) if( x != m_iHealth )
{ {
m_fFade = FADE_TIME; m_fFade = FADE_TIME;
m_iHealth = x; m_iHealth = x;
@ -116,8 +115,7 @@ int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
return 1; return 1;
} }
int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )
int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -127,21 +125,22 @@ int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
vec3_t vecFrom; vec3_t vecFrom;
for ( int i = 0 ; i < 3 ; i++) for( int i = 0; i < 3; i++ )
vecFrom[i] = READ_COORD(); vecFrom[i] = READ_COORD();
UpdateTiles(gHUD.m_flTime, bitsDamage); UpdateTiles( gHUD.m_flTime, bitsDamage );
// Actually took damage? // Actually took damage?
if ( damageTaken > 0 || armor > 0 ) if( damageTaken > 0 || armor > 0 )
{ {
CalcDamageDirection(vecFrom); CalcDamageDirection( vecFrom );
if( gMobileEngfuncs && damageTaken > 0 ) if( gMobileEngfuncs && damageTaken > 0 )
{ {
float time = damageTaken * 4.0f; float time = damageTaken * 4.0f;
if( time > 200.0f ) time = 200.0f; if( time > 200.0f )
time = 200.0f;
gMobileEngfuncs->pfnVibrate( time, 0 ); gMobileEngfuncs->pfnVibrate( time, 0 );
} }
} }
@ -149,25 +148,24 @@ int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
return 1; return 1;
} }
// Returns back a color from the // Returns back a color from the
// Green <-> Yellow <-> Red ramp // Green <-> Yellow <-> Red ramp
void CHudHealth::GetPainColor( int &r, int &g, int &b ) void CHudHealth::GetPainColor( int &r, int &g, int &b )
{ {
int iHealth = m_iHealth; int iHealth = m_iHealth;
if (iHealth > 25) if( iHealth > 25 )
iHealth -= 25; iHealth -= 25;
else if ( iHealth < 0 ) else if( iHealth < 0 )
iHealth = 0; iHealth = 0;
#if 0 #if 0
g = iHealth * 255 / 100; g = iHealth * 255 / 100;
r = 255 - g; r = 255 - g;
b = 0; b = 0;
#else #else
if (m_iHealth > 25) if( m_iHealth > 25 )
{ {
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r, g, b, RGB_YELLOWISH );
} }
else else
{ {
@ -178,132 +176,128 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b )
#endif #endif
} }
int CHudHealth::Draw(float flTime) int CHudHealth::Draw( float flTime )
{ {
int r, g, b; int r, g, b;
int a = 0, x, y; int a = 0, x, y;
int HealthWidth; int HealthWidth;
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() ) if( ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) || gEngfuncs.IsSpectateOnly() )
return 1; return 1;
if ( !m_hSprite ) if( !m_hSprite )
m_hSprite = LoadSprite(PAIN_NAME); m_hSprite = LoadSprite( PAIN_NAME );
// Has health changed? Flash the health # // Has health changed? Flash the health #
if (m_fFade) if( m_fFade )
{ {
m_fFade -= (gHUD.m_flTimeDelta * 20); m_fFade -= ( gHUD.m_flTimeDelta * 20 );
if (m_fFade <= 0) if( m_fFade <= 0 )
{ {
a = MIN_ALPHA; a = MIN_ALPHA;
m_fFade = 0; m_fFade = 0;
} }
// Fade the health number back to dim // Fade the health number back to dim
a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128;
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
} }
else else
a = MIN_ALPHA; a = MIN_ALPHA;
// If health is getting low, make it bright red // If health is getting low, make it bright red
if (m_iHealth <= 15) if( m_iHealth <= 15 )
a = 255; a = 255;
GetPainColor( r, g, b ); GetPainColor( r, g, b );
ScaleColors(r, g, b, a ); ScaleColors( r, g, b, a );
// Only draw health if we have the suit. // Only draw health if we have the suit.
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT))) if( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) )
{ {
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; HealthWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left; int CrossWidth = gHUD.GetSpriteRect( m_HUD_cross ).right - gHUD.GetSpriteRect( m_HUD_cross ).left;
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = CrossWidth /2; x = CrossWidth / 2;
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b); SPR_Set( gHUD.GetSprite( m_HUD_cross ), r, g, b );
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross)); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_cross ) );
x = CrossWidth + HealthWidth / 2; x = CrossWidth + HealthWidth / 2;
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b); x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b );
x += HealthWidth/2; x += HealthWidth / 2;
int iHeight = gHUD.m_iFontHeight; int iHeight = gHUD.m_iFontHeight;
int iWidth = HealthWidth/10; int iWidth = HealthWidth / 10;
FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a); FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a );
} }
DrawDamage(flTime); DrawDamage( flTime );
return DrawPain(flTime); return DrawPain( flTime );
} }
void CHudHealth::CalcDamageDirection(vec3_t vecFrom) void CHudHealth::CalcDamageDirection( vec3_t vecFrom )
{ {
vec3_t forward, right, up; vec3_t forward, right, up;
float side, front; float side, front;
vec3_t vecOrigin, vecAngles; vec3_t vecOrigin, vecAngles;
if (!vecFrom[0] && !vecFrom[1] && !vecFrom[2]) if( !vecFrom[0] && !vecFrom[1] && !vecFrom[2] )
{ {
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0; m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
return; return;
} }
memcpy( vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t) );
memcpy( vecAngles, gHUD.m_vecAngles, sizeof(vec3_t) );
memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t)); VectorSubtract( vecFrom, vecOrigin, vecFrom );
memcpy(vecAngles, gHUD.m_vecAngles, sizeof(vec3_t));
VectorSubtract (vecFrom, vecOrigin, vecFrom);
float flDistToTarget = vecFrom.Length(); float flDistToTarget = vecFrom.Length();
vecFrom = vecFrom.Normalize(); vecFrom = vecFrom.Normalize();
AngleVectors (vecAngles, forward, right, up); AngleVectors( vecAngles, forward, right, up );
front = DotProduct (vecFrom, right); front = DotProduct( vecFrom, right );
side = DotProduct (vecFrom, forward); side = DotProduct( vecFrom, forward );
if (flDistToTarget <= 50) if( flDistToTarget <= 50 )
{ {
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1; m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1;
} }
else else
{ {
if (side > 0) if( side > 0 )
{ {
if (side > 0.3) if( side > 0.3 )
m_fAttackFront = max(m_fAttackFront, side); m_fAttackFront = max( m_fAttackFront, side );
} }
else else
{ {
float f = fabs(side); float f = fabs( side );
if (f > 0.3) if( f > 0.3 )
m_fAttackRear = max(m_fAttackRear, f); m_fAttackRear = max( m_fAttackRear, f );
} }
if (front > 0) if( front > 0 )
{ {
if (front > 0.3) if( front > 0.3 )
m_fAttackRight = max(m_fAttackRight, front); m_fAttackRight = max( m_fAttackRight, front );
} }
else else
{ {
float f = fabs(front); float f = fabs( front );
if (f > 0.3) if( f > 0.3 )
m_fAttackLeft = max(m_fAttackLeft, f); m_fAttackLeft = max( m_fAttackLeft, f );
} }
} }
} }
int CHudHealth::DrawPain(float flTime) int CHudHealth::DrawPain( float flTime )
{ {
if (!(m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight)) if( !( m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight) )
return 1; return 1;
int r, g, b; int r, g, b;
@ -315,58 +309,60 @@ int CHudHealth::DrawPain(float flTime)
float fFade = gHUD.m_flTimeDelta * 2; float fFade = gHUD.m_flTimeDelta * 2;
// SPR_Draw top // SPR_Draw top
if (m_fAttackFront > 0.4) if( m_fAttackFront > 0.4 )
{ {
GetPainColor(r,g,b); GetPainColor( r, g, b );
shade = a * max( m_fAttackFront, 0.5 ); shade = a * max( m_fAttackFront, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors( r, g, b, shade );
SPR_Set(m_hSprite, r, g, b ); SPR_Set( m_hSprite, r, g, b );
x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2; x = ScreenWidth / 2 - SPR_Width( m_hSprite, 0 ) / 2;
y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3; y = ScreenHeight / 2 - SPR_Height( m_hSprite, 0 ) * 3;
SPR_DrawAdditive(0, x, y, NULL); SPR_DrawAdditive( 0, x, y, NULL );
m_fAttackFront = max( 0, m_fAttackFront - fFade ); m_fAttackFront = max( 0, m_fAttackFront - fFade );
} else } else
m_fAttackFront = 0; m_fAttackFront = 0;
if (m_fAttackRight > 0.4) if( m_fAttackRight > 0.4 )
{ {
GetPainColor(r,g,b); GetPainColor( r, g, b );
shade = a * max( m_fAttackRight, 0.5 ); shade = a * max( m_fAttackRight, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors( r, g, b, shade );
SPR_Set(m_hSprite, r, g, b ); SPR_Set( m_hSprite, r, g, b );
x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2; x = ScreenWidth / 2 + SPR_Width( m_hSprite, 1 ) * 2;
y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2; y = ScreenHeight / 2 - SPR_Height( m_hSprite,1 ) / 2;
SPR_DrawAdditive(1, x, y, NULL); SPR_DrawAdditive( 1, x, y, NULL );
m_fAttackRight = max( 0, m_fAttackRight - fFade ); m_fAttackRight = max( 0, m_fAttackRight - fFade );
} else }
else
m_fAttackRight = 0; m_fAttackRight = 0;
if (m_fAttackRear > 0.4) if( m_fAttackRear > 0.4 )
{ {
GetPainColor(r,g,b); GetPainColor( r, g, b );
shade = a * max( m_fAttackRear, 0.5 ); shade = a * max( m_fAttackRear, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors( r, g, b, shade );
SPR_Set(m_hSprite, r, g, b ); SPR_Set( m_hSprite, r, g, b );
x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2; x = ScreenWidth / 2 - SPR_Width( m_hSprite, 2 ) / 2;
y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2; y = ScreenHeight / 2 + SPR_Height( m_hSprite, 2 ) * 2;
SPR_DrawAdditive(2, x, y, NULL); SPR_DrawAdditive( 2, x, y, NULL );
m_fAttackRear = max( 0, m_fAttackRear - fFade ); m_fAttackRear = max( 0, m_fAttackRear - fFade );
} else }
else
m_fAttackRear = 0; m_fAttackRear = 0;
if (m_fAttackLeft > 0.4) if( m_fAttackLeft > 0.4 )
{ {
GetPainColor(r,g,b); GetPainColor( r, g, b );
shade = a * max( m_fAttackLeft, 0.5 ); shade = a * max( m_fAttackLeft, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors( r, g, b, shade );
SPR_Set(m_hSprite, r, g, b ); SPR_Set( m_hSprite, r, g, b );
x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3; x = ScreenWidth / 2 - SPR_Width( m_hSprite, 3 ) * 3;
y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2; y = ScreenHeight / 2 - SPR_Height( m_hSprite,3 ) / 2;
SPR_DrawAdditive(3, x, y, NULL); SPR_DrawAdditive( 3, x, y, NULL );
m_fAttackLeft = max( 0, m_fAttackLeft - fFade ); m_fAttackLeft = max( 0, m_fAttackLeft - fFade );
} else } else
@ -375,42 +371,34 @@ int CHudHealth::DrawPain(float flTime)
return 1; return 1;
} }
int CHudHealth::DrawDamage(float flTime) int CHudHealth::DrawDamage( float flTime )
{ {
int i, r, g, b, a; int i, r, g, b, a;
DAMAGE_IMAGE *pdmg; DAMAGE_IMAGE *pdmg;
if (!m_bitsDamage) if( !m_bitsDamage )
return 1; return 1;
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r, g, b, RGB_YELLOWISH );
a = (int)( fabs(sin(flTime*2)) * 256.0); a = (int)( fabs( sin( flTime * 2 ) ) * 256.0 );
ScaleColors(r, g, b, a);
// Draw all the items
for (i = 0; i < NUM_DMG_TYPES; i++)
{
if (m_bitsDamage & giDmgFlags[i])
{
pdmg = &m_dmg[i];
SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b );
SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i));
}
}
ScaleColors( r, g, b, a );
// check for bits that should be expired // check for bits that should be expired
for ( i = 0; i < NUM_DMG_TYPES; i++ ) for( i = 0; i < NUM_DMG_TYPES; i++ )
{
if( m_bitsDamage & giDmgFlags[i] )
{ {
pdmg = &m_dmg[i]; pdmg = &m_dmg[i];
if ( m_bitsDamage & giDmgFlags[i] ) // Draw all the items
{ SPR_Set( gHUD.GetSprite( m_HUD_dmg_bio + i ), r, g, b );
SPR_DrawAdditive( 0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect( m_HUD_dmg_bio + i ) );
pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire ); pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
if ( pdmg->fExpire <= flTime // when the time has expired if( pdmg->fExpire <= flTime // when the time has expired
&& a < 40 ) // and the flash is at the low point of the cycle && a < 40 ) // and the flash is at the low point of the cycle
{ {
pdmg->fExpire = 0; pdmg->fExpire = 0;
@ -419,10 +407,10 @@ int CHudHealth::DrawDamage(float flTime)
pdmg->x = pdmg->y = 0; pdmg->x = pdmg->y = 0;
// move everyone above down // move everyone above down
for (int j = 0; j < NUM_DMG_TYPES; j++) for( int j = 0; j < NUM_DMG_TYPES; j++ )
{ {
pdmg = &m_dmg[j]; pdmg = &m_dmg[j];
if ((pdmg->y) && (pdmg->y < y)) if( ( pdmg->y ) && ( pdmg->y < y ) )
pdmg->y += giDmgHeight; pdmg->y += giDmgHeight;
} }
@ -435,44 +423,42 @@ int CHudHealth::DrawDamage(float flTime)
return 1; return 1;
} }
void CHudHealth::UpdateTiles( float flTime, long bitsDamage )
void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
{ {
DAMAGE_IMAGE *pdmg; DAMAGE_IMAGE *pdmg;
// Which types are new? // Which types are new?
long bitsOn = ~m_bitsDamage & bitsDamage; long bitsOn = ~m_bitsDamage & bitsDamage;
for (int i = 0; i < NUM_DMG_TYPES; i++) for( int i = 0; i < NUM_DMG_TYPES; i++ )
{ {
pdmg = &m_dmg[i]; pdmg = &m_dmg[i];
// Is this one already on? // Is this one already on?
if (m_bitsDamage & giDmgFlags[i]) if( m_bitsDamage & giDmgFlags[i] )
{ {
pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration
if (!pdmg->fBaseline) if( !pdmg->fBaseline )
pdmg->fBaseline = flTime; pdmg->fBaseline = flTime;
} }
// Are we just turning it on? // Are we just turning it on?
if (bitsOn & giDmgFlags[i]) if( bitsOn & giDmgFlags[i] )
{ {
// put this one at the bottom // put this one at the bottom
pdmg->x = giDmgWidth/8; pdmg->x = giDmgWidth / 8;
pdmg->y = ScreenHeight - giDmgHeight * 2; pdmg->y = ScreenHeight - giDmgHeight * 2;
pdmg->fExpire=flTime + DMG_IMAGE_LIFE; pdmg->fExpire=flTime + DMG_IMAGE_LIFE;
// move everyone else up // move everyone else up
for (int j = 0; j < NUM_DMG_TYPES; j++) for( int j = 0; j < NUM_DMG_TYPES; j++ )
{ {
if (j == i) if( j == i )
continue; continue;
pdmg = &m_dmg[j]; pdmg = &m_dmg[j];
if (pdmg->y) if( pdmg->y )
pdmg->y -= giDmgHeight; pdmg->y -= giDmgHeight;
} }
pdmg = &m_dmg[i]; pdmg = &m_dmg[i];
} }

View File

@ -23,6 +23,7 @@
#define DMG_IMAGE_NERVE 5 #define DMG_IMAGE_NERVE 5
#define DMG_IMAGE_RAD 6 #define DMG_IMAGE_RAD 6
#define DMG_IMAGE_SHOCK 7 #define DMG_IMAGE_SHOCK 7
//tf defines //tf defines
#define DMG_IMAGE_CALTROP 8 #define DMG_IMAGE_CALTROP 8
#define DMG_IMAGE_TRANQ 9 #define DMG_IMAGE_TRANQ 9
@ -46,12 +47,10 @@
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death #define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. #define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
// time-based damage // time-based damage
//mask off TF-specific stuff too //mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage #define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning #define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN #define DMG_FIRSTTIMEBASED DMG_DROWN
@ -78,35 +77,33 @@
// TF Healing Additions for TakeHealth // TF Healing Additions for TakeHealth
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE #define DMG_IGNORE_MAXHEALTH DMG_IGNITE
// TF Redefines since we never use the originals // TF Redefines since we never use the originals
#define DMG_NAIL DMG_SLASH #define DMG_NAIL DMG_SLASH
#define DMG_NOT_SELF DMG_FREEZE #define DMG_NOT_SELF DMG_FREEZE
#define DMG_TRANQ DMG_MORTAR #define DMG_TRANQ DMG_MORTAR
#define DMG_CONCUSS DMG_SONIC #define DMG_CONCUSS DMG_SONIC
typedef struct typedef struct
{ {
float fExpire; float fExpire;
float fBaseline; float fBaseline;
int x, y; int x, y;
} DAMAGE_IMAGE; }DAMAGE_IMAGE;
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudHealth: public CHudBase class CHudHealth : public CHudBase
{ {
public: public:
virtual int Init( void ); virtual int Init( void );
virtual int VidInit( void ); virtual int VidInit( void );
virtual int Draw(float fTime); virtual int Draw( float fTime );
virtual void Reset( void ); virtual void Reset( void );
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf); int MsgFunc_Health( const char *pszName, int iSize, void *pbuf );
int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf); int MsgFunc_Damage( const char *pszName, int iSize, void *pbuf );
int m_iHealth; int m_iHealth;
int m_HUD_dmg_bio; int m_HUD_dmg_bio;
int m_HUD_cross; int m_HUD_cross;
@ -120,8 +117,8 @@ private:
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES]; DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
int m_bitsDamage; int m_bitsDamage;
int DrawPain(float fTime); int DrawPain( float fTime );
int DrawDamage(float fTime); int DrawDamage( float fTime );
void CalcDamageDirection(vec3_t vecFrom); void CalcDamageDirection( vec3_t vecFrom );
void UpdateTiles(float fTime, long bits); void UpdateTiles( float fTime, long bits );
}; };

View File

@ -21,6 +21,7 @@ This file contains "stubs" of class member implementations so that we can predic
add in the functionality you need. add in the functionality you need.
========================== ==========================
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cbase.h" #include "cbase.h"
@ -38,26 +39,26 @@ globalvars_t *gpGlobals;
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS]; ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { } void EMIT_SOUND_DYN( edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch ) { }
// CBaseEntity Stubs // CBaseEntity Stubs
int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; } int CBaseEntity::TakeHealth( float flHealth, int bitsDamageType ) { return 1; }
int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { return 1; } int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 1; }
CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; } CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; }
int CBaseEntity::Save( CSave &save ) { return 1; } int CBaseEntity::Save( CSave &save ) { return 1; }
int CBaseEntity::Restore( CRestore &restore ) { return 1; } int CBaseEntity::Restore( CRestore &restore ) { return 1; }
void CBaseEntity::SetObjectCollisionBox( void ) { } void CBaseEntity::SetObjectCollisionBox( void ) { }
int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; } int CBaseEntity::Intersects( CBaseEntity *pOther ) { return 0; }
void CBaseEntity :: MakeDormant( void ) { } void CBaseEntity::MakeDormant( void ) { }
int CBaseEntity :: IsDormant( void ) { return 0; } int CBaseEntity::IsDormant( void ) { return 0; }
BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; } BOOL CBaseEntity::IsInWorld( void ) { return TRUE; }
int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; }
int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; } int CBaseEntity::DamageDecal( int bitsDamageType ) { return -1; }
CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; }
void CBaseEntity::SUB_Remove( void ) { } void CBaseEntity::SUB_Remove( void ) { }
// CBaseDelay Stubs // CBaseDelay Stubs
void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { } void CBaseDelay::KeyValue( struct KeyValueData_s * ) { }
int CBaseDelay::Restore( class CRestore & ) { return 1; } int CBaseDelay::Restore( class CRestore & ) { return 1; }
int CBaseDelay::Save( class CSave & ) { return 1; } int CBaseDelay::Save( class CSave & ) { return 1; }
@ -67,7 +68,7 @@ int CBaseAnimating::Save( class CSave & ) { return 1; }
// DEBUG Stubs // DEBUG Stubs
edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; } edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; }
void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { } void DBG_AssertFunction( BOOL fExpr, const char *szExpr, const char *szFile, int szLine, const char *szMessage) { }
// UTIL_* Stubs // UTIL_* Stubs
void UTIL_PrecacheOther( const char *szClassname ) { } void UTIL_PrecacheOther( const char *szClassname ) { }
@ -85,7 +86,7 @@ void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const c
// CBaseToggle Stubs // CBaseToggle Stubs
int CBaseToggle::Restore( class CRestore & ) { return 1; } int CBaseToggle::Restore( class CRestore & ) { return 1; }
int CBaseToggle::Save( class CSave & ) { return 1; } int CBaseToggle::Save( class CSave & ) { return 1; }
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { } void CBaseToggle::KeyValue( struct KeyValueData_s * ) { }
// CGrenade Stubs // CGrenade Stubs
void CGrenade::BounceSound( void ) { } void CGrenade::BounceSound( void ) { }
@ -93,7 +94,7 @@ void CGrenade::Explode( Vector, Vector ) { }
void CGrenade::Explode( TraceResult *, int ) { } void CGrenade::Explode( TraceResult *, int ) { }
void CGrenade::Killed( entvars_t *, int ) { } void CGrenade::Killed( entvars_t *, int ) { }
void CGrenade::Spawn( void ) { } void CGrenade::Spawn( void ) { }
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ){ return 0; } CGrenade *CGrenade::ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ){ return 0; }
CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ){ return 0; } CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ){ return 0; }
void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ){ } void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ){ }
@ -108,140 +109,139 @@ void CBeam::PointEntInit( const Vector &start, int endIndex ) { }
CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; } CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; }
void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { } void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { }
CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; }
CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; } void CBaseMonster::Eat( float flFullDuration ) { }
void CBaseMonster :: Eat ( float flFullDuration ) { } BOOL CBaseMonster::FShouldEat( void ) { return TRUE; }
BOOL CBaseMonster :: FShouldEat ( void ) { return TRUE; } void CBaseMonster::BarnacleVictimBitten( entvars_t *pevBarnacle ) { }
void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { } void CBaseMonster::BarnacleVictimReleased( void ) { }
void CBaseMonster :: BarnacleVictimReleased ( void ) { } void CBaseMonster::Listen( void ) { }
void CBaseMonster :: Listen ( void ) { } float CBaseMonster::FLSoundVolume( CSound *pSound ) { return 0.0; }
float CBaseMonster :: FLSoundVolume ( CSound *pSound ) { return 0.0; } BOOL CBaseMonster::FValidateHintType( short sHint ) { return FALSE; }
BOOL CBaseMonster :: FValidateHintType ( short sHint ) { return FALSE; } void CBaseMonster::Look( int iDistance ) { }
void CBaseMonster :: Look ( int iDistance ) { } int CBaseMonster::ISoundMask( void ) { return 0; }
int CBaseMonster :: ISoundMask ( void ) { return 0; } CSound *CBaseMonster::PBestSound( void ) { return NULL; }
CSound* CBaseMonster :: PBestSound ( void ) { return NULL; } CSound *CBaseMonster::PBestScent( void ) { return NULL; }
CSound* CBaseMonster :: PBestScent ( void ) { return NULL; } float CBaseAnimating::StudioFrameAdvance( float flInterval ) { return 0.0; }
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; } void CBaseMonster::MonsterThink( void ) { }
void CBaseMonster :: MonsterThink ( void ) { } void CBaseMonster::MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { }
void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { } int CBaseMonster::IgnoreConditions( void ) { return 0; }
int CBaseMonster :: IgnoreConditions ( void ) { return 0; } void CBaseMonster::RouteClear( void ) { }
void CBaseMonster :: RouteClear ( void ) { } void CBaseMonster::RouteNew( void ) { }
void CBaseMonster :: RouteNew ( void ) { } BOOL CBaseMonster::FRouteClear( void ) { return FALSE; }
BOOL CBaseMonster :: FRouteClear ( void ) { return FALSE; } BOOL CBaseMonster::FRefreshRoute( void ) { return 0; }
BOOL CBaseMonster :: FRefreshRoute ( void ) { return 0; }
BOOL CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) { return FALSE; } BOOL CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) { return FALSE; }
BOOL CBaseMonster::MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; } BOOL CBaseMonster::MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; }
BOOL CBaseMonster::MoveToTarget( Activity movementAct, float waitTime ) { return FALSE; } BOOL CBaseMonster::MoveToTarget( Activity movementAct, float waitTime ) { return FALSE; }
BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; } BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; }
int ShouldSimplify( int routeType ) { return TRUE; } int ShouldSimplify( int routeType ) { return TRUE; }
void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) { } void CBaseMonster::RouteSimplify( CBaseEntity *pTargetEnt ) { }
BOOL CBaseMonster :: FBecomeProne ( void ) { return TRUE; } BOOL CBaseMonster::FBecomeProne( void ) { return TRUE; }
BOOL CBaseMonster :: CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; } BOOL CBaseMonster::CheckRangeAttack1( float flDot, float flDist ) { return FALSE; }
BOOL CBaseMonster :: CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; } BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) { return FALSE; }
BOOL CBaseMonster :: CheckMeleeAttack1 ( float flDot, float flDist ) { return FALSE; } BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) { return FALSE; }
BOOL CBaseMonster :: CheckMeleeAttack2 ( float flDot, float flDist ) { return FALSE; } BOOL CBaseMonster::CheckMeleeAttack2( float flDot, float flDist ) { return FALSE; }
void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) { } void CBaseMonster::CheckAttacks( CBaseEntity *pTarget, float flDist ) { }
BOOL CBaseMonster :: FCanCheckAttacks ( void ) { return FALSE; } BOOL CBaseMonster::FCanCheckAttacks( void ) { return FALSE; }
int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) { return 0; } int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) { return 0; }
void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { } void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { }
BOOL CBaseMonster :: PopEnemy( ) { return FALSE; } BOOL CBaseMonster::PopEnemy() { return FALSE; }
void CBaseMonster :: SetActivity ( Activity NewActivity ) { } void CBaseMonster::SetActivity( Activity NewActivity ) { }
void CBaseMonster :: SetSequenceByName ( char *szSequence ) { } void CBaseMonster::SetSequenceByName( char *szSequence ) { }
int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; } int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; }
float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; } float CBaseMonster::OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; }
void CBaseMonster :: AdvanceRoute ( float distance ) { } void CBaseMonster::AdvanceRoute( float distance ) { }
int CBaseMonster :: RouteClassify( int iMoveFlag ) { return 0; } int CBaseMonster::RouteClassify( int iMoveFlag ) { return 0; }
BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { return FALSE; } BOOL CBaseMonster::BuildRoute( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { return FALSE; }
void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) { } void CBaseMonster::InsertWaypoint( Vector vecLocation, int afMoveFlags ) { }
BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return FALSE; } BOOL CBaseMonster::FTriangulate( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return FALSE; }
void CBaseMonster :: Move ( float flInterval ) { } void CBaseMonster::Move( float flInterval ) { }
BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) { return FALSE; } BOOL CBaseMonster::ShouldAdvanceRoute( float flWaypointDist ) { return FALSE; }
void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { } void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { }
void CBaseMonster :: MonsterInit ( void ) { } void CBaseMonster::MonsterInit( void ) { }
void CBaseMonster :: MonsterInitThink ( void ) { } void CBaseMonster::MonsterInitThink( void ) { }
void CBaseMonster :: StartMonster ( void ) { } void CBaseMonster::StartMonster( void ) { }
void CBaseMonster :: MovementComplete( void ) { } void CBaseMonster::MovementComplete( void ) { }
int CBaseMonster::TaskIsRunning( void ) { return 0; } int CBaseMonster::TaskIsRunning( void ) { return 0; }
int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; } int CBaseMonster::IRelationship( CBaseEntity *pTarget ) { return 0; }
BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; } BOOL CBaseMonster::FindCover( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; }
BOOL CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; } BOOL CBaseMonster::BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; }
CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) { return NULL; } CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) { return NULL; }
BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) { return FALSE; } BOOL CBaseMonster::FInViewCone( CBaseEntity *pEntity ) { return FALSE; }
BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) { return FALSE; } BOOL CBaseMonster::FInViewCone( Vector *pOrigin ) { return FALSE; }
BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) { return FALSE; } BOOL CBaseEntity::FVisible( CBaseEntity *pEntity ) { return FALSE; }
BOOL CBaseEntity :: FVisible ( const Vector &vecOrigin ) { return FALSE; } BOOL CBaseEntity::FVisible( const Vector &vecOrigin ) { return FALSE; }
void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { } void CBaseMonster::MakeIdealYaw( Vector vecTarget ) { }
float CBaseMonster::FlYawDiff ( void ) { return 0.0; } float CBaseMonster::FlYawDiff( void ) { return 0.0; }
float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; } float CBaseMonster::ChangeYaw( int yawSpeed ) { return 0; }
float CBaseMonster::VecToYaw ( Vector vecDir ) { return 0.0; } float CBaseMonster::VecToYaw( Vector vecDir ) { return 0.0; }
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; } int CBaseAnimating::LookupActivity( int activity ) { return 0; }
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; } int CBaseAnimating::LookupActivityHeaviest( int activity ) { return 0; }
void CBaseMonster :: SetEyePosition ( void ) { } void CBaseMonster::SetEyePosition( void ) { }
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; } int CBaseAnimating::LookupSequence( const char *label ) { return 0; }
void CBaseAnimating :: ResetSequenceInfo ( ) { } void CBaseAnimating::ResetSequenceInfo() { }
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; } BOOL CBaseAnimating::GetSequenceFlags() { return FALSE; }
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { } void CBaseAnimating::DispatchAnimEvents( float flInterval ) { }
void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) { } void CBaseMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) { }
float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; } float CBaseAnimating::SetBoneController ( int iController, float flValue ) { return 0.0; }
void CBaseAnimating :: InitBoneControllers ( void ) { } void CBaseAnimating::InitBoneControllers ( void ) { }
float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; } float CBaseAnimating::SetBlending( int iBlender, float flValue ) { return 0; }
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { } void CBaseAnimating::GetBonePosition( int iBone, Vector &origin, Vector &angles ) { }
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { } void CBaseAnimating::GetAttachment( int iAttachment, Vector &origin, Vector &angles ) { }
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; } int CBaseAnimating::FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; }
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { } void CBaseAnimating::GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { }
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { } void CBaseAnimating::SetBodygroup( int iGroup, int iValue ) { }
int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; } int CBaseAnimating::GetBodygroup( int iGroup ) { return 0; }
Vector CBaseMonster :: GetGunPosition( void ) { return g_vecZero; } Vector CBaseMonster::GetGunPosition( void ) { return g_vecZero; }
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } void CBaseEntity::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { }
void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { } void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { }
void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { } void CBaseEntity::TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { }
void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { } void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { }
BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) { return TRUE; } BOOL CBaseMonster::FGetNodeRoute( Vector vecDest ) { return TRUE; }
int CBaseMonster :: FindHintNode ( void ) { return NO_NODE; } int CBaseMonster::FindHintNode( void ) { return NO_NODE; }
void CBaseMonster::ReportAIState( void ) { } void CBaseMonster::ReportAIState( void ) { }
void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { } void CBaseMonster::KeyValue( KeyValueData *pkvd ) { }
BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; } BOOL CBaseMonster::FCheckAITrigger( void ) { return FALSE; }
int CBaseMonster :: CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) { return FALSE; } int CBaseMonster::CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) { return FALSE; }
BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ) { return FALSE; } BOOL CBaseMonster::FindLateralCover( const Vector &vecThreat, const Vector &vecViewOffset ) { return FALSE; }
Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) { return g_vecZero; } Vector CBaseMonster::ShootAtEnemy( const Vector &shootOrigin ) { return g_vecZero; }
BOOL CBaseMonster :: FacingIdeal( void ) { return FALSE; } BOOL CBaseMonster::FacingIdeal( void ) { return FALSE; }
BOOL CBaseMonster :: FCanActiveIdle ( void ) { return FALSE; } BOOL CBaseMonster::FCanActiveIdle( void ) { return FALSE; }
void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { } void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { }
void CBaseMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) { } void CBaseMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) { }
void CBaseMonster::SentenceStop( void ) { } void CBaseMonster::SentenceStop( void ) { }
void CBaseMonster::CorpseFallThink( void ) { } void CBaseMonster::CorpseFallThink( void ) { }
void CBaseMonster :: MonsterInitDead( void ) { } void CBaseMonster::MonsterInitDead( void ) { }
BOOL CBaseMonster :: BBoxFlat ( void ) { return TRUE; } BOOL CBaseMonster::BBoxFlat( void ) { return TRUE; }
BOOL CBaseMonster :: GetEnemy ( void ) { return FALSE; } BOOL CBaseMonster::GetEnemy( void ) { return FALSE; }
void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
CBaseEntity* CBaseMonster :: DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } CBaseEntity* CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; }
BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { return FALSE; } BOOL CBaseMonster::ShouldFadeOnDeath( void ) { return FALSE; }
void CBaseMonster :: RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
void CBaseMonster :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
void CBaseMonster::FadeMonster( void ) { } void CBaseMonster::FadeMonster( void ) { }
void CBaseMonster :: GibMonster( void ) { } void CBaseMonster::GibMonster( void ) { }
BOOL CBaseMonster :: HasHumanGibs( void ) { return FALSE; } BOOL CBaseMonster::HasHumanGibs( void ) { return FALSE; }
BOOL CBaseMonster :: HasAlienGibs( void ) { return FALSE; } BOOL CBaseMonster::HasAlienGibs( void ) { return FALSE; }
Activity CBaseMonster :: GetDeathActivity ( void ) { return ACT_DIE_HEADSHOT; } Activity CBaseMonster::GetDeathActivity( void ) { return ACT_DIE_HEADSHOT; }
MONSTERSTATE CBaseMonster :: GetIdealState ( void ) { return MONSTERSTATE_ALERT; } MONSTERSTATE CBaseMonster::GetIdealState( void ) { return MONSTERSTATE_ALERT; }
Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) { return NULL; } Schedule_t* CBaseMonster::GetScheduleOfType( int Type ) { return NULL; }
Schedule_t *CBaseMonster :: GetSchedule ( void ) { return NULL; } Schedule_t *CBaseMonster::GetSchedule( void ) { return NULL; }
void CBaseMonster :: RunTask ( Task_t *pTask ) { } void CBaseMonster::RunTask( Task_t *pTask ) { }
void CBaseMonster :: StartTask ( Task_t *pTask ) { } void CBaseMonster::StartTask( Task_t *pTask ) { }
Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) { return NULL;} Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) { return NULL;}
void CBaseMonster::BecomeDead( void ) {} void CBaseMonster::BecomeDead( void ) {}
void CBaseMonster :: RunAI ( void ) {} void CBaseMonster::RunAI( void ) {}
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {} void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) {}
int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return 0; } int CBaseMonster::TakeHealth(float flHealth, int bitsDamageType) { return 0; }
int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
int CBaseMonster::Restore( class CRestore & ) { return 1; } int CBaseMonster::Restore( class CRestore & ) { return 1; }
int CBaseMonster::Save( class CSave & ) { return 1; } int CBaseMonster::Save( class CSave & ) { return 1; }
int TrainSpeed(int iSpeed, int iMax) { return 0; } int TrainSpeed( int iSpeed, int iMax ) { return 0; }
void CBasePlayer :: DeathSound( void ) { } void CBasePlayer::DeathSound( void ) { }
int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return 0; } int CBasePlayer::TakeHealth( float flHealth, int bitsDamageType ) { return 0; }
void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } void CBasePlayer::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { }
int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
void CBasePlayer::PackDeadPlayerItems( void ) { } void CBasePlayer::PackDeadPlayerItems( void ) { }
void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { } void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { }
void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { } void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { }
@ -250,77 +250,77 @@ BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; }
void CBasePlayer::PlayerDeathThink(void) { } void CBasePlayer::PlayerDeathThink(void) { }
void CBasePlayer::StartDeathCam( void ) { } void CBasePlayer::StartDeathCam( void ) { }
void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { } void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { }
void CBasePlayer::PlayerUse ( void ) { } void CBasePlayer::PlayerUse( void ) { }
void CBasePlayer::Jump() { } void CBasePlayer::Jump() { }
void CBasePlayer::Duck( ) { } void CBasePlayer::Duck() { }
int CBasePlayer::Classify ( void ) { return 0; } int CBasePlayer::Classify( void ) { return 0; }
void CBasePlayer::PreThink(void) { } void CBasePlayer::PreThink(void) { }
void CBasePlayer::CheckTimeBasedDamage() { } void CBasePlayer::CheckTimeBasedDamage() { }
void CBasePlayer :: UpdateGeigerCounter( void ) { } void CBasePlayer::UpdateGeigerCounter( void ) { }
void CBasePlayer::CheckSuitUpdate() { } void CBasePlayer::CheckSuitUpdate() { }
void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { } void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { }
void CBasePlayer :: UpdatePlayerSound ( void ) { } void CBasePlayer::UpdatePlayerSound ( void ) { }
void CBasePlayer::PostThink() { } void CBasePlayer::PostThink() { }
void CBasePlayer :: Precache( void ) { } void CBasePlayer::Precache( void ) { }
int CBasePlayer::Save( CSave &save ) { return 0; } int CBasePlayer::Save( CSave &save ) { return 0; }
void CBasePlayer::RenewItems(void) { } void CBasePlayer::RenewItems( void ) { }
int CBasePlayer::Restore( CRestore &restore ) { return 0; } int CBasePlayer::Restore( CRestore &restore ) { return 0; }
void CBasePlayer::SelectNextItem( int iItem ) { } void CBasePlayer::SelectNextItem( int iItem ) { }
BOOL CBasePlayer::HasWeapons( void ) { return FALSE; } BOOL CBasePlayer::HasWeapons( void ) { return FALSE; }
void CBasePlayer::SelectPrevItem( int iItem ) { } void CBasePlayer::SelectPrevItem( int iItem ) { }
CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; } CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; }
BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; } BOOL CBasePlayer::FlashlightIsOn( void ) { return FALSE; }
void CBasePlayer :: FlashlightTurnOn( void ) { } void CBasePlayer::FlashlightTurnOn( void ) { }
void CBasePlayer :: FlashlightTurnOff( void ) { } void CBasePlayer::FlashlightTurnOff( void ) { }
void CBasePlayer :: ForceClientDllUpdate( void ) { } void CBasePlayer::ForceClientDllUpdate( void ) { }
void CBasePlayer::ImpulseCommands( ) { } void CBasePlayer::ImpulseCommands() { }
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPreFrame() { }
void CBasePlayer::ItemPostFrame() { } void CBasePlayer::ItemPostFrame() { }
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }
int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; } int CBasePlayer::GetAmmoIndex( const char *psz ) { return -1; }
void CBasePlayer::SendAmmoUpdate(void) { } void CBasePlayer::SendAmmoUpdate(void) { }
void CBasePlayer :: UpdateClientData( void ) { } void CBasePlayer::UpdateClientData( void ) { }
BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; } BOOL CBasePlayer::FBecomeProne( void ) { return TRUE; }
void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { } void CBasePlayer::BarnacleVictimBitten( entvars_t *pevBarnacle ) { }
void CBasePlayer :: BarnacleVictimReleased ( void ) { } void CBasePlayer::BarnacleVictimReleased( void ) { }
int CBasePlayer :: Illumination( void ) { return 0; } int CBasePlayer::Illumination( void ) { return 0; }
void CBasePlayer :: EnableControl(BOOL fControl) { } void CBasePlayer::EnableControl( BOOL fControl ) { }
Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; } Vector CBasePlayer::GetAutoaimVector( float flDelta ) { return g_vecZero; }
Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; } Vector CBasePlayer::AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; }
void CBasePlayer :: ResetAutoaim( ) { } void CBasePlayer::ResetAutoaim() { }
void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { } void CBasePlayer::SetCustomDecalFrames( int nFrames ) { }
int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; } int CBasePlayer::GetCustomDecalFrames( void ) { return -1; }
void CBasePlayer::DropPlayerItem ( char *pszItemName ) { } void CBasePlayer::DropPlayerItem( char *pszItemName ) { }
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; } BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
Vector CBasePlayer :: GetGunPosition( void ) { return g_vecZero; } Vector CBasePlayer::GetGunPosition( void ) { return g_vecZero; }
const char *CBasePlayer::TeamID( void ) { return ""; } const char *CBasePlayer::TeamID( void ) { return ""; }
int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) { return 0; }
void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { }
void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { }
void ClearMultiDamage(void) { } void ClearMultiDamage( void ) { }
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { } void ApplyMultiDamage( entvars_t *pevInflictor, entvars_t *pevAttacker ) { }
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { } void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { }
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { } void SpawnBlood( Vector vecSpot, int bloodColor, float flDamage ) { }
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; } int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; }
void DecalGunshot( TraceResult *pTrace, int iBulletType ) { } void DecalGunshot( TraceResult *pTrace, int iBulletType ) { }
void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { } void EjectBrass( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { }
void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { } void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { }
int CBasePlayerItem::Restore( class CRestore & ) { return 1; } int CBasePlayerItem::Restore( class CRestore & ) { return 1; }
int CBasePlayerItem::Save( class CSave & ) { return 1; } int CBasePlayerItem::Save( class CSave & ) { return 1; }
int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; } int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; }
int CBasePlayerWeapon::Save( class CSave & ) { return 1; } int CBasePlayerWeapon::Save( class CSave & ) { return 1; }
void CBasePlayerItem :: SetObjectCollisionBox( void ) { } void CBasePlayerItem::SetObjectCollisionBox( void ) { }
void CBasePlayerItem :: FallInit( void ) { } void CBasePlayerItem::FallInit( void ) { }
void CBasePlayerItem::FallThink ( void ) { } void CBasePlayerItem::FallThink( void ) { }
void CBasePlayerItem::Materialize( void ) { } void CBasePlayerItem::Materialize( void ) { }
void CBasePlayerItem::AttemptToMaterialize( void ) { } void CBasePlayerItem::AttemptToMaterialize( void ) { }
void CBasePlayerItem :: CheckRespawn ( void ) { } void CBasePlayerItem::CheckRespawn( void ) { }
CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; } CBaseEntity *CBasePlayerItem::Respawn( void ) { return NULL; }
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { } void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { }
void CBasePlayerItem::DestroyItem( void ) { } void CBasePlayerItem::DestroyItem( void ) { }
int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; } int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; }
@ -331,17 +331,17 @@ void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; } int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; } int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; } int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; } BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; }
BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; } BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; }
BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; } BOOL CBasePlayerWeapon::IsUseable( void ) { return TRUE; }
int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; } int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; }
int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; } int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; }
void CBasePlayerAmmo::Spawn( void ) { } void CBasePlayerAmmo::Spawn( void ) { }
CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; } CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; }
void CBasePlayerAmmo::Materialize( void ) { } void CBasePlayerAmmo::Materialize( void ) { }
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) { }
int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
void CBasePlayerWeapon::RetireWeapon( void ) { } void CBasePlayerWeapon::RetireWeapon( void ) { }
void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {} void CSoundEnt::InsertSound( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {}
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){}

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "../hud.h" #include "../hud.h"
#include "../cl_util.h" #include "../cl_util.h"
#include "event_api.h" #include "event_api.h"
@ -38,8 +39,6 @@ void EV_HornetGunFire( struct event_args_s *args );
void EV_TripmineFire( struct event_args_s *args ); void EV_TripmineFire( struct event_args_s *args );
void EV_SnarkFire( struct event_args_s *args ); void EV_SnarkFire( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args );
} }

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "../hud.h" #include "../hud.h"
#include "../cl_util.h" #include "../cl_util.h"
#include "../demo.h" #include "../demo.h"
@ -30,7 +31,7 @@ extern BEAM *pBeam;
extern BEAM *pBeam2; extern BEAM *pBeam2;
void HUD_GetLastOrg( float *org ); void HUD_GetLastOrg( float *org );
void UpdateBeams ( void ) void UpdateBeams( void )
{ {
vec3_t forward, vecSrc, vecEnd, origin, angles, right, up; vec3_t forward, vecSrc, vecEnd, origin, angles, right, up;
vec3_t view_ofs; vec3_t view_ofs;
@ -56,20 +57,20 @@ void UpdateBeams ( void )
gEngfuncs.pEventAPI->EV_PushPMStates(); gEngfuncs.pEventAPI->EV_PushPMStates();
// Now add in all of the players. // Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 );
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PopPMStates(); gEngfuncs.pEventAPI->EV_PopPMStates();
if ( pBeam ) if( pBeam )
{ {
pBeam->target = tr.endpos; pBeam->target = tr.endpos;
pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
} }
if ( pBeam2 ) if( pBeam2 )
{ {
pBeam2->target = tr.endpos; pBeam2->target = tr.endpos;
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
@ -85,6 +86,6 @@ Add game specific, client-side objects here
*/ */
void Game_AddObjects( void ) void Game_AddObjects( void )
{ {
if ( pBeam && pBeam2 ) if( pBeam && pBeam2 )
UpdateBeams(); UpdateBeams();
} }

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cbase.h" #include "cbase.h"
@ -35,7 +36,7 @@ extern globalvars_t *gpGlobals;
extern int g_iUser1; extern int g_iUser1;
// Pool of client side entities/entvars_t // Pool of client side entities/entvars_t
static entvars_t ev[ 32 ]; static entvars_t ev[32];
static int num_ents = 0; static int num_ents = 0;
// The entity we'll use to represent the local client // The entity we'll use to represent the local client
@ -44,7 +45,7 @@ static CBasePlayer player;
// Local version of game .dll global variables ( time, etc. ) // Local version of game .dll global variables ( time, etc. )
static globalvars_t Globals; static globalvars_t Globals;
static CBasePlayerWeapon *g_pWpns[ 32 ]; static CBasePlayerWeapon *g_pWpns[32];
float g_flApplyVel = 0.0; float g_flApplyVel = 0.0;
int g_irunninggausspred = 0; int g_irunninggausspred = 0;
@ -67,7 +68,6 @@ CSatchel g_Satchel;
CTripmine g_Tripmine; CTripmine g_Tripmine;
CSqueak g_Snark; CSqueak g_Snark;
/* /*
====================== ======================
AlertMessage AlertMessage
@ -80,9 +80,9 @@ void AlertMessage( ALERT_TYPE atype, char *szFmt, ... )
va_list argptr; va_list argptr;
static char string[1024]; static char string[1024];
va_start (argptr, szFmt); va_start( argptr, szFmt );
vsprintf (string, szFmt,argptr); vsprintf( string, szFmt, argptr );
va_end (argptr); va_end( argptr );
gEngfuncs.Con_Printf( "cl: " ); gEngfuncs.Con_Printf( "cl: " );
gEngfuncs.Con_Printf( string ); gEngfuncs.Con_Printf( string );
@ -90,12 +90,13 @@ void AlertMessage( ALERT_TYPE atype, char *szFmt, ... )
//Returns if it's multiplayer. //Returns if it's multiplayer.
//Mostly used by the client side weapons. //Mostly used by the client side weapons.
bool bIsMultiplayer ( void ) bool bIsMultiplayer( void )
{ {
return gEngfuncs.GetMaxClients() == 1 ? 0 : 1; return gEngfuncs.GetMaxClients() == 1 ? 0 : 1;
} }
//Just loads a v_ model. //Just loads a v_ model.
void LoadVModel ( char *szViewModel, CBasePlayer *m_pPlayer ) void LoadVModel( char *szViewModel, CBasePlayer *m_pPlayer )
{ {
gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel );
} }
@ -110,50 +111,49 @@ we set up the m_pPlayer field.
*/ */
void HUD_PrepEntity( CBaseEntity *pEntity, CBasePlayer *pWeaponOwner ) void HUD_PrepEntity( CBaseEntity *pEntity, CBasePlayer *pWeaponOwner )
{ {
memset( &ev[ num_ents ], 0, sizeof( entvars_t ) ); memset( &ev[num_ents], 0, sizeof(entvars_t) );
pEntity->pev = &ev[ num_ents++ ]; pEntity->pev = &ev[num_ents++];
pEntity->Precache(); pEntity->Precache();
pEntity->Spawn(); pEntity->Spawn();
if ( pWeaponOwner ) if( pWeaponOwner )
{ {
ItemInfo info; ItemInfo info;
((CBasePlayerWeapon *)pEntity)->m_pPlayer = pWeaponOwner; ( (CBasePlayerWeapon *)pEntity )->m_pPlayer = pWeaponOwner;
((CBasePlayerWeapon *)pEntity)->GetItemInfo( &info ); ( (CBasePlayerWeapon *)pEntity )->GetItemInfo( &info );
g_pWpns[ info.iId ] = (CBasePlayerWeapon *)pEntity; g_pWpns[info.iId] = (CBasePlayerWeapon *)pEntity;
} }
} }
/* /*
===================== =====================
CBaseEntity :: Killed CBaseEntity::Killed
If weapons code "kills" an entity, just set its effects to EF_NODRAW If weapons code "kills" an entity, just set its effects to EF_NODRAW
===================== =====================
*/ */
void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) void CBaseEntity::Killed( entvars_t *pevAttacker, int iGib )
{ {
pev->effects |= EF_NODRAW; pev->effects |= EF_NODRAW;
} }
/* /*
===================== =====================
CBasePlayerWeapon :: DefaultReload CBasePlayerWeapon::DefaultReload
===================== =====================
*/ */
BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, int body ) BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, int body )
{ {
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return FALSE; return FALSE;
int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] );
if (j == 0) if( j == 0 )
return FALSE; return FALSE;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay;
@ -169,32 +169,32 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay,
/* /*
===================== =====================
CBasePlayerWeapon :: CanDeploy CBasePlayerWeapon::CanDeploy
===================== =====================
*/ */
BOOL CBasePlayerWeapon :: CanDeploy( void ) BOOL CBasePlayerWeapon::CanDeploy( void )
{ {
BOOL bHasAmmo = 0; BOOL bHasAmmo = 0;
if ( !pszAmmo1() ) if( !pszAmmo1() )
{ {
// this weapon doesn't use ammo, can always deploy. // this weapon doesn't use ammo, can always deploy.
return TRUE; return TRUE;
} }
if ( pszAmmo1() ) if( pszAmmo1() )
{ {
bHasAmmo |= (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0); bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0 );
} }
if ( pszAmmo2() ) if( pszAmmo2() )
{ {
bHasAmmo |= (m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0); bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0 );
} }
if (m_iClip > 0) if( m_iClip > 0 )
{ {
bHasAmmo |= 1; bHasAmmo |= 1;
} }
if (!bHasAmmo) if( !bHasAmmo )
{ {
return FALSE; return FALSE;
} }
@ -204,13 +204,13 @@ BOOL CBasePlayerWeapon :: CanDeploy( void )
/* /*
===================== =====================
CBasePlayerWeapon :: DefaultDeploy CBasePlayerWeapon::DefaultDeploy
===================== =====================
*/ */
BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body ) BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body )
{ {
if ( !CanDeploy() ) if( !CanDeploy() )
return FALSE; return FALSE;
gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel );
@ -225,13 +225,13 @@ BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel,
/* /*
===================== =====================
CBasePlayerWeapon :: PlayEmptySound CBasePlayerWeapon::PlayEmptySound
===================== =====================
*/ */
BOOL CBasePlayerWeapon :: PlayEmptySound( void ) BOOL CBasePlayerWeapon::PlayEmptySound( void )
{ {
if (m_iPlayEmptySound) if( m_iPlayEmptySound )
{ {
HUD_PlaySound( "weapons/357_cock1.wav", 0.8 ); HUD_PlaySound( "weapons/357_cock1.wav", 0.8 );
m_iPlayEmptySound = 0; m_iPlayEmptySound = 0;
@ -242,11 +242,11 @@ BOOL CBasePlayerWeapon :: PlayEmptySound( void )
/* /*
===================== =====================
CBasePlayerWeapon :: ResetEmptySound CBasePlayerWeapon::ResetEmptySound
===================== =====================
*/ */
void CBasePlayerWeapon :: ResetEmptySound( void ) void CBasePlayerWeapon::ResetEmptySound( void )
{ {
m_iPlayEmptySound = 1; m_iPlayEmptySound = 1;
} }
@ -290,16 +290,16 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD
{ {
float x, y, z; float x, y, z;
for ( ULONG iShot = 1; iShot <= cShots; iShot++ ) for( ULONG iShot = 1; iShot <= cShots; iShot++ )
{ {
if ( pevAttacker == NULL ) if( pevAttacker == NULL )
{ {
// get circular gaussian spread // get circular gaussian spread
do { do {
x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 );
y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 );
z = x*x+y*y; z = x * x + y * y;
} while (z > 1); } while( z > 1 );
} }
else else
{ {
@ -309,10 +309,9 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD
y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 ); y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 );
z = x * x + y * y; z = x * x + y * y;
} }
} }
return Vector ( x * vecSpread.x, y * vecSpread.y, 0.0 ); return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 );
} }
/* /*
@ -324,11 +323,11 @@ Handles weapon firing, reloading, etc.
*/ */
void CBasePlayerWeapon::ItemPostFrame( void ) void CBasePlayerWeapon::ItemPostFrame( void )
{ {
if ((m_fInReload) && (m_pPlayer->m_flNextAttack <= 0.0)) if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= 0.0 ) )
{ {
#if 0 // FIXME, need ammo on client to make this work right #if 0 // FIXME, need ammo on client to make this work right
// complete the reload. // complete the reload.
int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] );
// Add them to the clip // Add them to the clip
m_iClip += j; m_iClip += j;
@ -339,9 +338,9 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_fInReload = FALSE; m_fInReload = FALSE;
} }
if ((m_pPlayer->pev->button & IN_ATTACK2) && (m_flNextSecondaryAttack <= 0.0)) if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && ( m_flNextSecondaryAttack <= 0.0 ) )
{ {
if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )
{ {
m_fFireOnEmpty = TRUE; m_fFireOnEmpty = TRUE;
} }
@ -349,28 +348,27 @@ void CBasePlayerWeapon::ItemPostFrame( void )
SecondaryAttack(); SecondaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK2; m_pPlayer->pev->button &= ~IN_ATTACK2;
} }
else if ((m_pPlayer->pev->button & IN_ATTACK) && (m_flNextPrimaryAttack <= 0.0)) else if( ( m_pPlayer->pev->button & IN_ATTACK ) && ( m_flNextPrimaryAttack <= 0.0 ) )
{ {
if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )
{ {
m_fFireOnEmpty = TRUE; m_fFireOnEmpty = TRUE;
} }
PrimaryAttack(); PrimaryAttack();
} }
else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload )
{ {
// reload when reload is pressed, or if no buttons are down and weapon is empty. // reload when reload is pressed, or if no buttons are down and weapon is empty.
Reload(); Reload();
} }
else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) ) else if( !( m_pPlayer->pev->button & ( IN_ATTACK | IN_ATTACK2 ) ) )
{ {
// no fire buttons down // no fire buttons down
m_fFireOnEmpty = FALSE; m_fFireOnEmpty = FALSE;
// weapon is useable. Reload if empty and weapon has waited as long as it has to after firing // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing
if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < 0.0 ) if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < 0.0 )
{ {
Reload(); Reload();
return; return;
@ -381,7 +379,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
} }
// catch all // catch all
if ( ShouldWeaponIdle() ) if( ShouldWeaponIdle() )
{ {
WeaponIdle(); WeaponIdle();
} }
@ -394,29 +392,28 @@ CBasePlayer::SelectItem
Switch weapons Switch weapons
===================== =====================
*/ */
void CBasePlayer::SelectItem(const char *pstr) void CBasePlayer::SelectItem( const char *pstr )
{ {
if (!pstr) if( !pstr )
return; return;
CBasePlayerItem *pItem = NULL; CBasePlayerItem *pItem = NULL;
if (!pItem) if( !pItem )
return; return;
if( pItem == m_pActiveItem )
if (pItem == m_pActiveItem)
return; return;
if (m_pActiveItem) if( m_pActiveItem )
m_pActiveItem->Holster( ); m_pActiveItem->Holster();
m_pLastItem = m_pActiveItem; m_pLastItem = m_pActiveItem;
m_pActiveItem = pItem; m_pActiveItem = pItem;
if (m_pActiveItem) if( m_pActiveItem )
{ {
m_pActiveItem->Deploy( ); m_pActiveItem->Deploy();
} }
} }
@ -426,20 +423,20 @@ CBasePlayer::SelectLastItem
===================== =====================
*/ */
void CBasePlayer::SelectLastItem(void) void CBasePlayer::SelectLastItem( void )
{ {
if (!m_pLastItem) if( !m_pLastItem )
{ {
return; return;
} }
if ( m_pActiveItem && !m_pActiveItem->CanHolster() ) if( m_pActiveItem && !m_pActiveItem->CanHolster() )
{ {
return; return;
} }
if (m_pActiveItem) if( m_pActiveItem )
m_pActiveItem->Holster( ); m_pActiveItem->Holster();
CBasePlayerItem *pTemp = m_pActiveItem; CBasePlayerItem *pTemp = m_pActiveItem;
m_pActiveItem = m_pLastItem; m_pActiveItem = m_pLastItem;
@ -456,8 +453,8 @@ CBasePlayer::Killed
void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib )
{ {
// Holster weapon immediately, to allow it to cleanup // Holster weapon immediately, to allow it to cleanup
if ( m_pActiveItem ) if( m_pActiveItem )
m_pActiveItem->Holster( ); m_pActiveItem->Holster();
g_irunninggausspred = false; g_irunninggausspred = false;
} }
@ -470,7 +467,7 @@ CBasePlayer::Spawn
*/ */
void CBasePlayer::Spawn( void ) void CBasePlayer::Spawn( void )
{ {
if (m_pActiveItem) if( m_pActiveItem )
m_pActiveItem->Deploy( ); m_pActiveItem->Deploy( );
g_irunninggausspred = false; g_irunninggausspred = false;
@ -485,7 +482,7 @@ Don't actually trace, but act like the trace didn't hit anything.
*/ */
void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr ) void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr )
{ {
memset( ptr, 0, sizeof( *ptr ) ); memset( ptr, 0, sizeof(*ptr) );
ptr->flFraction = 1.0; ptr->flFraction = 1.0;
} }
@ -501,10 +498,10 @@ void UTIL_ParticleBox( CBasePlayer *player, float *mins, float *maxs, float life
int i; int i;
vec3_t mmin, mmax; vec3_t mmin, mmax;
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
mmin[ i ] = player->pev->origin[ i ] + mins[ i ]; mmin[i] = player->pev->origin[i] + mins[i];
mmax[ i ] = player->pev->origin[ i ] + maxs[ i ]; mmax[i] = player->pev->origin[i] + maxs[i];
} }
gEngfuncs.pEfxAPI->R_ParticleBox( (float *)&mmin, (float *)&mmax, 5.0, 0, 255, 0 ); gEngfuncs.pEfxAPI->R_ParticleBox( (float *)&mmin, (float *)&mmax, 5.0, 0, 255, 0 );
@ -533,13 +530,13 @@ void UTIL_ParticleBoxes( void )
// Now add in all of the players. // Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( player->index - 1 ); gEngfuncs.pEventAPI->EV_SetSolidPlayers ( player->index - 1 );
for ( idx = 1; idx < 100; idx++ ) for( idx = 1; idx < 100; idx++ )
{ {
pe = gEngfuncs.pEventAPI->EV_GetPhysent( idx ); pe = gEngfuncs.pEventAPI->EV_GetPhysent( idx );
if ( !pe ) if( !pe )
break; break;
if ( pe->info >= 1 && pe->info <= gEngfuncs.GetMaxClients() ) if( pe->info >= 1 && pe->info <= gEngfuncs.GetMaxClients() )
{ {
mins = pe->origin + pe->mins; mins = pe->origin + pe->mins;
maxs = pe->origin + pe->maxs; maxs = pe->origin + pe->maxs;
@ -575,16 +572,15 @@ void CBasePlayerWeapon::PrintState( void )
COM_Log( "c:\\hl.log", "%.4f ", gpGlobals->time ); COM_Log( "c:\\hl.log", "%.4f ", gpGlobals->time );
COM_Log( "c:\\hl.log", "%.4f ", m_pPlayer->m_flNextAttack ); COM_Log( "c:\\hl.log", "%.4f ", m_pPlayer->m_flNextAttack );
COM_Log( "c:\\hl.log", "%.4f ", m_flNextPrimaryAttack ); COM_Log( "c:\\hl.log", "%.4f ", m_flNextPrimaryAttack );
COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time); COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time );
COM_Log( "c:\\hl.log", "%i ", m_iClip ); COM_Log( "c:\\hl.log", "%i ", m_iClip );
} }
int RandomLong( int a, int b ) int RandomLong( int a, int b )
{ {
return gEngfuncs.pfnRandomLong(a, b); return gEngfuncs.pfnRandomLong( a, b );
} }
/* /*
===================== =====================
HUD_InitClientWeapons HUD_InitClientWeapons
@ -595,7 +591,7 @@ Set up weapons, player and functions needed to run weapons code client-side.
void HUD_InitClientWeapons( void ) void HUD_InitClientWeapons( void )
{ {
static int initialized = 0; static int initialized = 0;
if ( initialized ) if( initialized )
return; return;
initialized = 1; initialized = 1;
@ -624,23 +620,23 @@ void HUD_InitClientWeapons( void )
g_engfuncs.pfnRandomLong = gEngfuncs.pfnRandomLong; g_engfuncs.pfnRandomLong = gEngfuncs.pfnRandomLong;
// Allocate a slot for the local player // Allocate a slot for the local player
HUD_PrepEntity( &player , NULL ); HUD_PrepEntity( &player, NULL );
// Allocate slot(s) for each weapon that we are going to be predicting // Allocate slot(s) for each weapon that we are going to be predicting
HUD_PrepEntity( &g_Glock , &player ); HUD_PrepEntity( &g_Glock, &player );
HUD_PrepEntity( &g_Crowbar , &player ); HUD_PrepEntity( &g_Crowbar, &player );
HUD_PrepEntity( &g_Python , &player ); HUD_PrepEntity( &g_Python, &player );
HUD_PrepEntity( &g_Mp5 , &player ); HUD_PrepEntity( &g_Mp5, &player );
HUD_PrepEntity( &g_Crossbow , &player ); HUD_PrepEntity( &g_Crossbow, &player );
HUD_PrepEntity( &g_Shotgun , &player ); HUD_PrepEntity( &g_Shotgun, &player );
HUD_PrepEntity( &g_Rpg , &player ); HUD_PrepEntity( &g_Rpg, &player );
HUD_PrepEntity( &g_Gauss , &player ); HUD_PrepEntity( &g_Gauss, &player );
HUD_PrepEntity( &g_Egon , &player ); HUD_PrepEntity( &g_Egon, &player );
HUD_PrepEntity( &g_HGun , &player ); HUD_PrepEntity( &g_HGun, &player );
HUD_PrepEntity( &g_HandGren , &player ); HUD_PrepEntity( &g_HandGren, &player );
HUD_PrepEntity( &g_Satchel , &player ); HUD_PrepEntity( &g_Satchel, &player );
HUD_PrepEntity( &g_Tripmine , &player ); HUD_PrepEntity( &g_Tripmine, &player );
HUD_PrepEntity( &g_Snark , &player ); HUD_PrepEntity( &g_Snark, &player );
} }
/* /*
@ -655,7 +651,7 @@ void HUD_GetLastOrg( float *org )
int i; int i;
// Return last origin // Return last origin
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
org[i] = previousorigin[i]; org[i] = previousorigin[i];
} }
@ -673,9 +669,9 @@ void HUD_SetLastOrg( void )
int i; int i;
// Offset final origin by view_offset // Offset final origin by view_offset
for ( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
previousorigin[i] = g_finalstate->playerstate.origin[i] + g_finalstate->client.view_ofs[ i ]; previousorigin[i] = g_finalstate->playerstate.origin[i] + g_finalstate->client.view_ofs[i];
} }
} }
@ -692,11 +688,9 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
int buttonsChanged; int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL; CBasePlayerWeapon *pWeapon = NULL;
CBasePlayerWeapon *pCurrent; CBasePlayerWeapon *pCurrent;
weapon_data_t nulldata, *pfrom, *pto; weapon_data_t nulldata = {0}, *pfrom, *pto;
static int lasthealth; static int lasthealth;
memset( &nulldata, 0, sizeof( nulldata ) );
HUD_InitClientWeapons(); HUD_InitClientWeapons();
// Get current clock // Get current clock
@ -704,60 +698,47 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
// Fill in data based on selected weapon // Fill in data based on selected weapon
// FIXME, make this a method in each weapon? where you pass in an entity_state_t *? // FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
switch ( from->client.m_iId ) switch( from->client.m_iId )
{ {
case WEAPON_CROWBAR: case WEAPON_CROWBAR:
pWeapon = &g_Crowbar; pWeapon = &g_Crowbar;
break; break;
case WEAPON_GLOCK: case WEAPON_GLOCK:
pWeapon = &g_Glock; pWeapon = &g_Glock;
break; break;
case WEAPON_PYTHON: case WEAPON_PYTHON:
pWeapon = &g_Python; pWeapon = &g_Python;
break; break;
case WEAPON_MP5: case WEAPON_MP5:
pWeapon = &g_Mp5; pWeapon = &g_Mp5;
break; break;
case WEAPON_CROSSBOW: case WEAPON_CROSSBOW:
pWeapon = &g_Crossbow; pWeapon = &g_Crossbow;
break; break;
case WEAPON_SHOTGUN: case WEAPON_SHOTGUN:
pWeapon = &g_Shotgun; pWeapon = &g_Shotgun;
break; break;
case WEAPON_RPG: case WEAPON_RPG:
pWeapon = &g_Rpg; pWeapon = &g_Rpg;
break; break;
case WEAPON_GAUSS: case WEAPON_GAUSS:
pWeapon = &g_Gauss; pWeapon = &g_Gauss;
break; break;
case WEAPON_EGON: case WEAPON_EGON:
pWeapon = &g_Egon; pWeapon = &g_Egon;
break; break;
case WEAPON_HORNETGUN: case WEAPON_HORNETGUN:
pWeapon = &g_HGun; pWeapon = &g_HGun;
break; break;
case WEAPON_HANDGRENADE: case WEAPON_HANDGRENADE:
pWeapon = &g_HandGren; pWeapon = &g_HandGren;
break; break;
case WEAPON_SATCHEL: case WEAPON_SATCHEL:
pWeapon = &g_Satchel; pWeapon = &g_Satchel;
break; break;
case WEAPON_TRIPMINE: case WEAPON_TRIPMINE:
pWeapon = &g_Tripmine; pWeapon = &g_Tripmine;
break; break;
case WEAPON_SNARK: case WEAPON_SNARK:
pWeapon = &g_Snark; pWeapon = &g_Snark;
break; break;
@ -770,14 +751,13 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
// If we are running events/etc. go ahead and see if we // If we are running events/etc. go ahead and see if we
// managed to die between last frame and this one // managed to die between last frame and this one
// If so, run the appropriate player killed or spawn function // If so, run the appropriate player killed or spawn function
if ( g_runfuncs ) if( g_runfuncs )
{ {
if ( to->client.health <= 0 && lasthealth > 0 ) if( to->client.health <= 0 && lasthealth > 0 )
{ {
player.Killed( NULL, 0 ); player.Killed( NULL, 0 );
} }
else if ( to->client.health > 0 && lasthealth <= 0 ) else if( to->client.health > 0 && lasthealth <= 0 )
{ {
player.Spawn(); player.Spawn();
} }
@ -786,22 +766,22 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
} }
// We are not predicting the current weapon, just bow out here. // We are not predicting the current weapon, just bow out here.
if ( !pWeapon ) if( !pWeapon )
return; return;
for ( i = 0; i < 32; i++ ) for( i = 0; i < 32; i++ )
{ {
pCurrent = g_pWpns[ i ]; pCurrent = g_pWpns[i];
if ( !pCurrent ) if( !pCurrent )
{ {
continue; continue;
} }
pfrom = &from->weapondata[ i ]; pfrom = &from->weapondata[i];
pCurrent->m_fInReload = pfrom->m_fInReload; pCurrent->m_fInReload = pfrom->m_fInReload;
pCurrent->m_fInSpecialReload = pfrom->m_fInSpecialReload; pCurrent->m_fInSpecialReload = pfrom->m_fInSpecialReload;
// pCurrent->m_flPumpTime = pfrom->m_flPumpTime; //pCurrent->m_flPumpTime = pfrom->m_flPumpTime;
pCurrent->m_iClip = pfrom->m_iClip; pCurrent->m_iClip = pfrom->m_iClip;
pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack; pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack;
pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack; pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack;
@ -813,10 +793,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
pCurrent->m_fInAttack = pfrom->iuser2; pCurrent->m_fInAttack = pfrom->iuser2;
pCurrent->m_fireState = pfrom->iuser3; pCurrent->m_fireState = pfrom->iuser3;
pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[ 2 ]; pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2];
pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[ 0 ]; pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0];
player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ] = (int)from->client.vuser4[ 1 ]; player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType] = (int)from->client.vuser4[1];
player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ] = (int)from->client.vuser4[ 2 ]; player.m_rgAmmo[pCurrent->m_iSecondaryAmmoType] = (int)from->client.vuser4[2];
} }
// For random weapon events, use this seed to seed random # generator // For random weapon events, use this seed to seed random # generator
@ -826,13 +806,13 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.m_afButtonLast = from->playerstate.oldbuttons; player.m_afButtonLast = from->playerstate.oldbuttons;
// Which buttsons chave changed // Which buttsons chave changed
buttonsChanged = (player.m_afButtonLast ^ cmd->buttons); // These buttons have changed this frame buttonsChanged = ( player.m_afButtonLast ^ cmd->buttons ); // These buttons have changed this frame
// Debounced button codes for pressed/released // Debounced button codes for pressed/released
// The changed ones still down are "pressed" // The changed ones still down are "pressed"
player.m_afButtonPressed = buttonsChanged & cmd->buttons; player.m_afButtonPressed = buttonsChanged & cmd->buttons;
// The ones not down are "released" // The ones not down are "released"
player.m_afButtonReleased = buttonsChanged & (~cmd->buttons); player.m_afButtonReleased = buttonsChanged & ( ~cmd->buttons );
// Set player variables that weapons code might check/alter // Set player variables that weapons code might check/alter
player.pev->button = cmd->buttons; player.pev->button = cmd->buttons;
@ -860,25 +840,24 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.ammo_hornets = (int)from->client.vuser2[0]; player.ammo_hornets = (int)from->client.vuser2[0];
player.ammo_rockets = (int)from->client.ammo_rockets; player.ammo_rockets = (int)from->client.ammo_rockets;
// Point to current weapon object // Point to current weapon object
if ( from->client.m_iId ) if( from->client.m_iId )
{ {
player.m_pActiveItem = g_pWpns[ from->client.m_iId ]; player.m_pActiveItem = g_pWpns[from->client.m_iId];
} }
if ( player.m_pActiveItem->m_iId == WEAPON_RPG ) if( player.m_pActiveItem->m_iId == WEAPON_RPG )
{ {
( ( CRpg * )player.m_pActiveItem)->m_fSpotActive = (int)from->client.vuser2[ 1 ]; ( (CRpg *)player.m_pActiveItem )->m_fSpotActive = (int)from->client.vuser2[1];
( ( CRpg * )player.m_pActiveItem)->m_cActiveRockets = (int)from->client.vuser2[ 2 ]; ( (CRpg *)player.m_pActiveItem )->m_cActiveRockets = (int)from->client.vuser2[2];
} }
// Don't go firing anything if we have died. // Don't go firing anything if we have died.
// Or if we don't have a weapon model deployed // Or if we don't have a weapon model deployed
if ( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) && if( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) &&
!CL_IsDead() && player.pev->viewmodel && !g_iUser1 ) !CL_IsDead() && player.pev->viewmodel && !g_iUser1 )
{ {
if ( player.m_flNextAttack <= 0 ) if( player.m_flNextAttack <= 0 )
{ {
pWeapon->ItemPostFrame(); pWeapon->ItemPostFrame();
} }
@ -888,25 +867,25 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
to->client.m_iId = from->client.m_iId; to->client.m_iId = from->client.m_iId;
// Now see if we issued a changeweapon command ( and we're not dead ) // Now see if we issued a changeweapon command ( and we're not dead )
if ( cmd->weaponselect && ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) ) if( cmd->weaponselect && ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) )
{ {
// Switched to a different weapon? // Switched to a different weapon?
if ( from->weapondata[ cmd->weaponselect ].m_iId == cmd->weaponselect ) if( from->weapondata[cmd->weaponselect].m_iId == cmd->weaponselect )
{ {
CBasePlayerWeapon *pNew = g_pWpns[ cmd->weaponselect ]; CBasePlayerWeapon *pNew = g_pWpns[cmd->weaponselect];
if ( pNew && ( pNew != pWeapon ) ) if( pNew && ( pNew != pWeapon ) )
{ {
// Put away old weapon // Put away old weapon
if (player.m_pActiveItem) if( player.m_pActiveItem )
player.m_pActiveItem->Holster( ); player.m_pActiveItem->Holster();
player.m_pLastItem = player.m_pActiveItem; player.m_pLastItem = player.m_pActiveItem;
player.m_pActiveItem = pNew; player.m_pActiveItem = pNew;
// Deploy new weapon // Deploy new weapon
if (player.m_pActiveItem) if( player.m_pActiveItem )
{ {
player.m_pActiveItem->Deploy( ); player.m_pActiveItem->Deploy();
} }
// Update weapon id so we can predict things correctly. // Update weapon id so we can predict things correctly.
@ -935,45 +914,45 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
to->client.vuser2[0] = player.ammo_hornets; to->client.vuser2[0] = player.ammo_hornets;
to->client.ammo_rockets = player.ammo_rockets; to->client.ammo_rockets = player.ammo_rockets;
if ( player.m_pActiveItem->m_iId == WEAPON_RPG ) if( player.m_pActiveItem->m_iId == WEAPON_RPG )
{ {
from->client.vuser2[ 1 ] = ( ( CRpg * )player.m_pActiveItem)->m_fSpotActive; from->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive;
from->client.vuser2[ 2 ] = ( ( CRpg * )player.m_pActiveItem)->m_cActiveRockets; from->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets;
} }
// Make sure that weapon animation matches what the game .dll is telling us // Make sure that weapon animation matches what the game .dll is telling us
// over the wire ( fixes some animation glitches ) // over the wire ( fixes some animation glitches )
if ( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) ) if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) )
{ {
int body = 2; int body = 2;
//Pop the model to body 0. //Pop the model to body 0.
if ( pWeapon == &g_Tripmine ) if( pWeapon == &g_Tripmine )
body = 0; body = 0;
//Show laser sight/scope combo //Show laser sight/scope combo
if ( pWeapon == &g_Python && bIsMultiplayer() ) if( pWeapon == &g_Python && bIsMultiplayer() )
body = 1; body = 1;
// Force a fixed anim down to viewmodel // Force a fixed anim down to viewmodel
HUD_SendWeaponAnim( to->client.weaponanim, body, 1 ); HUD_SendWeaponAnim( to->client.weaponanim, body, 1 );
} }
for ( i = 0; i < 32; i++ ) for( i = 0; i < 32; i++ )
{ {
pCurrent = g_pWpns[ i ]; pCurrent = g_pWpns[i];
pto = &to->weapondata[ i ]; pto = &to->weapondata[i];
if ( !pCurrent ) if( !pCurrent )
{ {
memset( pto, 0, sizeof( weapon_data_t ) ); memset( pto, 0, sizeof(weapon_data_t) );
continue; continue;
} }
pto->m_fInReload = pCurrent->m_fInReload; pto->m_fInReload = pCurrent->m_fInReload;
pto->m_fInSpecialReload = pCurrent->m_fInSpecialReload; pto->m_fInSpecialReload = pCurrent->m_fInSpecialReload;
// pto->m_flPumpTime = pCurrent->m_flPumpTime; //pto->m_flPumpTime = pCurrent->m_flPumpTime;
pto->m_iClip = pCurrent->m_iClip; pto->m_iClip = pCurrent->m_iClip;
pto->m_flNextPrimaryAttack = pCurrent->m_flNextPrimaryAttack; pto->m_flNextPrimaryAttack = pCurrent->m_flNextPrimaryAttack;
pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack; pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack;
@ -995,42 +974,42 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType; to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType;
to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType; to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType;
to->client.vuser4[1] = player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ]; to->client.vuser4[1] = player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType];
to->client.vuser4[2] = player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ]; to->client.vuser4[2] = player.m_rgAmmo[pCurrent->m_iSecondaryAmmoType];
/* if ( pto->m_flPumpTime != -9999 ) /* if( pto->m_flPumpTime != -9999 )
{ {
pto->m_flPumpTime -= cmd->msec / 1000.0; pto->m_flPumpTime -= cmd->msec / 1000.0;
if ( pto->m_flPumpTime < -0.001 ) if( pto->m_flPumpTime < -0.001 )
pto->m_flPumpTime = -0.001; pto->m_flPumpTime = -0.001;
}*/ }*/
if ( pto->m_fNextAimBonus < -1.0 ) if( pto->m_fNextAimBonus < -1.0 )
{ {
pto->m_fNextAimBonus = -1.0; pto->m_fNextAimBonus = -1.0;
} }
if ( pto->m_flNextPrimaryAttack < -1.0 ) if( pto->m_flNextPrimaryAttack < -1.0 )
{ {
pto->m_flNextPrimaryAttack = -1.0; pto->m_flNextPrimaryAttack = -1.0;
} }
if ( pto->m_flNextSecondaryAttack < -0.001 ) if( pto->m_flNextSecondaryAttack < -0.001 )
{ {
pto->m_flNextSecondaryAttack = -0.001; pto->m_flNextSecondaryAttack = -0.001;
} }
if ( pto->m_flTimeWeaponIdle < -0.001 ) if( pto->m_flTimeWeaponIdle < -0.001 )
{ {
pto->m_flTimeWeaponIdle = -0.001; pto->m_flTimeWeaponIdle = -0.001;
} }
if ( pto->m_flNextReload < -0.001 ) if( pto->m_flNextReload < -0.001 )
{ {
pto->m_flNextReload = -0.001; pto->m_flNextReload = -0.001;
} }
if ( pto->fuser1 < -0.001 ) if( pto->fuser1 < -0.001 )
{ {
pto->fuser1 = -0.001; pto->fuser1 = -0.001;
} }
@ -1038,19 +1017,19 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
// m_flNextAttack is now part of the weapons, but is part of the player instead // m_flNextAttack is now part of the weapons, but is part of the player instead
to->client.m_flNextAttack -= cmd->msec / 1000.0; to->client.m_flNextAttack -= cmd->msec / 1000.0;
if ( to->client.m_flNextAttack < -0.001 ) if( to->client.m_flNextAttack < -0.001 )
{ {
to->client.m_flNextAttack = -0.001; to->client.m_flNextAttack = -0.001;
} }
to->client.fuser2 -= cmd->msec / 1000.0; to->client.fuser2 -= cmd->msec / 1000.0;
if ( to->client.fuser2 < -0.001 ) if( to->client.fuser2 < -0.001 )
{ {
to->client.fuser2 = -0.001; to->client.fuser2 = -0.001;
} }
to->client.fuser3 -= cmd->msec / 1000.0; to->client.fuser3 -= cmd->msec / 1000.0;
if ( to->client.fuser3 < -0.001 ) if( to->client.fuser3 < -0.001 )
{ {
to->client.fuser3 = -0.001; to->client.fuser3 = -0.001;
} }
@ -1078,7 +1057,7 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s
g_runfuncs = runfuncs; g_runfuncs = runfuncs;
#if defined( CLIENT_WEAPONS ) #if defined( CLIENT_WEAPONS )
if ( cl_lw && cl_lw->value ) if( cl_lw && cl_lw->value )
{ {
HUD_WeaponsPostThink( from, to, cmd, time, random_seed ); HUD_WeaponsPostThink( from, to, cmd, time, random_seed );
} }
@ -1088,7 +1067,7 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s
to->client.fov = g_lastFOV; to->client.fov = g_lastFOV;
} }
if ( g_irunninggausspred == 1 ) if( g_irunninggausspred == 1 )
{ {
Vector forward; Vector forward;
gEngfuncs.pfnAngleVectors( v_angles, forward, NULL, NULL ); gEngfuncs.pfnAngleVectors( v_angles, forward, NULL, NULL );

View File

@ -25,71 +25,69 @@
#include "parsemsg.h" #include "parsemsg.h"
#include "hud_servers.h" #include "hud_servers.h"
#include "demo.h" #include "demo.h"
#include "demo_api.h" #include "demo_api.h"
cvar_t *hud_textmode; cvar_t *hud_textmode;
float g_hud_text_color[3]; float g_hud_text_color[3];
extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iRes, int iCount );
extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount);
extern cvar_t *sensitivity; extern cvar_t *sensitivity;
cvar_t *cl_lw = NULL; cvar_t *cl_lw = NULL;
void ShutdownInput (void); void ShutdownInput( void );
//DECLARE_MESSAGE(m_Logo, Logo) //DECLARE_MESSAGE( m_Logo, Logo )
int __MsgFunc_Logo(const char *pszName, int iSize, void *pbuf) int __MsgFunc_Logo( const char *pszName, int iSize, void *pbuf )
{ {
return gHUD.MsgFunc_Logo(pszName, iSize, pbuf ); return gHUD.MsgFunc_Logo( pszName, iSize, pbuf );
} }
//DECLARE_MESSAGE(m_Logo, Logo) //DECLARE_MESSAGE( m_Logo, Logo )
int __MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf) int __MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf )
{ {
return gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf ); return gHUD.MsgFunc_ResetHUD( pszName, iSize, pbuf );
} }
int __MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf) int __MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{ {
gHUD.MsgFunc_InitHUD( pszName, iSize, pbuf ); gHUD.MsgFunc_InitHUD( pszName, iSize, pbuf );
return 1; return 1;
} }
int __MsgFunc_ViewMode(const char *pszName, int iSize, void *pbuf) int __MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{ {
gHUD.MsgFunc_ViewMode( pszName, iSize, pbuf ); gHUD.MsgFunc_ViewMode( pszName, iSize, pbuf );
return 1; return 1;
} }
int __MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) int __MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf )
{ {
return gHUD.MsgFunc_SetFOV( pszName, iSize, pbuf ); return gHUD.MsgFunc_SetFOV( pszName, iSize, pbuf );
} }
int __MsgFunc_Concuss(const char *pszName, int iSize, void *pbuf) int __MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{ {
return gHUD.MsgFunc_Concuss( pszName, iSize, pbuf ); return gHUD.MsgFunc_Concuss( pszName, iSize, pbuf );
} }
int __MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ) int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf )
{ {
return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf ); return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf );
} }
// TFFree Command Menu // TFFree Command Menu
void __CmdFunc_OpenCommandMenu(void) void __CmdFunc_OpenCommandMenu( void )
{ {
} }
// TFC "special" command // TFC "special" command
void __CmdFunc_InputPlayerSpecial(void) void __CmdFunc_InputPlayerSpecial( void )
{ {
} }
void __CmdFunc_CloseCommandMenu(void) void __CmdFunc_CloseCommandMenu( void )
{ {
} }
@ -102,59 +100,58 @@ void __CmdFunc_ToggleServerBrowser( void )
} }
// TFFree Command Menu Message Handlers // TFFree Command Menu Message Handlers
int __MsgFunc_ValClass(const char *pszName, int iSize, void *pbuf) int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_TeamNames(const char *pszName, int iSize, void *pbuf) int __MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_Feign(const char *pszName, int iSize, void *pbuf) int __MsgFunc_Feign( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_Detpack(const char *pszName, int iSize, void *pbuf) int __MsgFunc_Detpack( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_VGUIMenu(const char *pszName, int iSize, void *pbuf) int __MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_BuildSt(const char *pszName, int iSize, void *pbuf) int __MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_RandomPC(const char *pszName, int iSize, void *pbuf) int __MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_ServerName(const char *pszName, int iSize, void *pbuf) int __MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
int __MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf )
int __MsgFunc_Spectator(const char *pszName, int iSize, void *pbuf)
{ {
return 0; return 0;
} }
int __MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf) int __MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf )
{ {
return 0; return 0;
} }
// This is called every time the DLL is loaded // This is called every time the DLL is loaded
void CHud :: Init( void ) void CHud::Init( void )
{ {
HOOK_MESSAGE( Logo ); HOOK_MESSAGE( Logo );
HOOK_MESSAGE( ResetHUD ); HOOK_MESSAGE( ResetHUD );
@ -201,7 +198,7 @@ void CHud :: Init( void )
m_pSpriteList = NULL; m_pSpriteList = NULL;
// Clear any old HUD list // Clear any old HUD list
if ( m_pHudList ) if( m_pHudList )
{ {
HUDLIST *pList; HUDLIST *pList;
while ( m_pHudList ) while ( m_pHudList )
@ -235,22 +232,21 @@ void CHud :: Init( void )
m_Menu.Init(); m_Menu.Init();
MsgFunc_ResetHUD( 0, 0, NULL );
MsgFunc_ResetHUD(0, 0, NULL );
} }
// CHud destructor // CHud destructor
// cleans up memory allocated for m_rg* arrays // cleans up memory allocated for m_rg* arrays
CHud :: ~CHud() CHud::~CHud()
{ {
delete [] m_rghSprites; delete[] m_rghSprites;
delete [] m_rgrcRects; delete[] m_rgrcRects;
delete [] m_rgszSpriteNames; delete[] m_rgszSpriteNames;
if ( m_pHudList ) if( m_pHudList )
{ {
HUDLIST *pList; HUDLIST *pList;
while ( m_pHudList ) while( m_pHudList )
{ {
pList = m_pHudList; pList = m_pHudList;
m_pHudList = m_pHudList->pNext; m_pHudList = m_pHudList->pNext;
@ -258,59 +254,57 @@ CHud :: ~CHud()
} }
m_pHudList = NULL; m_pHudList = NULL;
} }
} }
// GetSpriteIndex() // GetSpriteIndex()
// searches through the sprite list loaded from hud.txt for a name matching SpriteName // searches through the sprite list loaded from hud.txt for a name matching SpriteName
// returns an index into the gHUD.m_rghSprites[] array // returns an index into the gHUD.m_rghSprites[] array
// returns 0 if sprite not found // returns 0 if sprite not found
int CHud :: GetSpriteIndex( const char *SpriteName ) int CHud::GetSpriteIndex( const char *SpriteName )
{ {
// look through the loaded sprite name list for SpriteName // look through the loaded sprite name list for SpriteName
for ( int i = 0; i < m_iSpriteCount; i++ ) for( int i = 0; i < m_iSpriteCount; i++ )
{ {
if ( strncmp( SpriteName, m_rgszSpriteNames + (i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 ) if( strncmp( SpriteName, m_rgszSpriteNames + ( i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 )
return i; return i;
} }
return -1; // invalid sprite return -1; // invalid sprite
} }
void CHud :: VidInit( void ) void CHud::VidInit( void )
{ {
int j; int j;
m_scrinfo.iSize = sizeof(m_scrinfo); m_scrinfo.iSize = sizeof(m_scrinfo);
GetScreenInfo(&m_scrinfo); GetScreenInfo( &m_scrinfo );
// ---------- // ----------
// Load Sprites // Load Sprites
// --------- // ---------
// m_hsprFont = LoadSprite("sprites/%d_font.spr"); //m_hsprFont = LoadSprite("sprites/%d_font.spr");
m_hsprLogo = 0; m_hsprLogo = 0;
m_hsprCursor = 0; m_hsprCursor = 0;
if (ScreenWidth < 640) if( ScreenWidth < 640 )
m_iRes = 320; m_iRes = 320;
else else
m_iRes = 640; m_iRes = 640;
// Only load this once // Only load this once
if ( !m_pSpriteList ) if( !m_pSpriteList )
{ {
// we need to load the hud.txt, and all sprites within // we need to load the hud.txt, and all sprites within
m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes); m_pSpriteList = SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes );
if (m_pSpriteList) if( m_pSpriteList )
{ {
// count the number of sprites of the appropriate res // count the number of sprites of the appropriate res
m_iSpriteCount = 0; m_iSpriteCount = 0;
client_sprite_t *p = m_pSpriteList; client_sprite_t *p = m_pSpriteList;
for ( j = 0; j < m_iSpriteCountAllRes; j++ ) for( j = 0; j < m_iSpriteCountAllRes; j++ )
{ {
if ( p->iRes == m_iRes ) if( p->iRes == m_iRes )
m_iSpriteCount++; m_iSpriteCount++;
p++; p++;
} }
@ -322,13 +316,13 @@ void CHud :: VidInit( void )
p = m_pSpriteList; p = m_pSpriteList;
int index = 0; int index = 0;
for ( j = 0; j < m_iSpriteCountAllRes; j++ ) for( j = 0; j < m_iSpriteCountAllRes; j++ )
{ {
if ( p->iRes == m_iRes ) if( p->iRes == m_iRes )
{ {
char sz[256]; char sz[256];
sprintf(sz, "sprites/%s.spr", p->szSprite); sprintf( sz, "sprites/%s.spr", p->szSprite );
m_rghSprites[index] = SPR_Load(sz); m_rghSprites[index] = SPR_Load( sz );
m_rgrcRects[index] = p->rc; m_rgrcRects[index] = p->rc;
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
@ -347,16 +341,16 @@ void CHud :: VidInit( void )
// count the number of sprites of the appropriate res // count the number of sprites of the appropriate res
m_iSpriteCount = 0; m_iSpriteCount = 0;
for ( j = 0; j < m_iSpriteCountAllRes; j++ ) for( j = 0; j < m_iSpriteCountAllRes; j++ )
{ {
if ( p->iRes == m_iRes ) if( p->iRes == m_iRes )
m_iSpriteCount++; m_iSpriteCount++;
p++; p++;
} }
delete [] m_rghSprites; delete[] m_rghSprites;
delete [] m_rgrcRects; delete[] m_rgrcRects;
delete [] m_rgszSpriteNames; delete[] m_rgszSpriteNames;
// allocated memory for sprite handle arrays // allocated memory for sprite handle arrays
m_rghSprites = new HSPRITE[m_iSpriteCount]; m_rghSprites = new HSPRITE[m_iSpriteCount];
@ -365,13 +359,13 @@ void CHud :: VidInit( void )
p = m_pSpriteList; p = m_pSpriteList;
int index = 0; int index = 0;
for ( j = 0; j < m_iSpriteCountAllRes; j++ ) for( j = 0; j < m_iSpriteCountAllRes; j++ )
{ {
if ( p->iRes == m_iRes ) if( p->iRes == m_iRes )
{ {
char sz[256]; char sz[256];
sprintf( sz, "sprites/%s.spr", p->szSprite ); sprintf( sz, "sprites/%s.spr", p->szSprite );
m_rghSprites[index] = SPR_Load(sz); m_rghSprites[index] = SPR_Load( sz );
m_rgrcRects[index] = p->rc; m_rgrcRects[index] = p->rc;
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
@ -404,10 +398,9 @@ void CHud :: VidInit( void )
m_StatusIcons.VidInit(); m_StatusIcons.VidInit();
m_Scoreboard.VidInit(); m_Scoreboard.VidInit();
m_MOTD.VidInit(); m_MOTD.VidInit();
} }
int CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -425,7 +418,7 @@ COM_FileBase
============ ============
*/ */
// Extracts the base name of a file (no path, no extension, assumes '/' as path separator) // Extracts the base name of a file (no path, no extension, assumes '/' as path separator)
void COM_FileBase ( const char *in, char *out) void COM_FileBase ( const char *in, char *out )
{ {
int len, start, end; int len, start, end;
@ -433,21 +426,20 @@ void COM_FileBase ( const char *in, char *out)
// scan backward for '.' // scan backward for '.'
end = len - 1; end = len - 1;
while ( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' ) while( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' )
end--; end--;
if ( in[end] != '.' ) // no '.', copy to end if( in[end] != '.' ) // no '.', copy to end
end = len-1; end = len - 1;
else else
end--; // Found ',', copy to left of '.' end--; // Found ',', copy to left of '.'
// Scan backward for '/' // Scan backward for '/'
start = len-1; start = len - 1;
while ( start >= 0 && in[start] != '/' && in[start] != '\\' ) while( start >= 0 && in[start] != '/' && in[start] != '\\' )
start--; start--;
if ( in[start] != '/' && in[start] != '\\' ) if( in[start] != '/' && in[start] != '\\' )
start = 0; start = 0;
else else
start++; start++;
@ -457,6 +449,7 @@ void COM_FileBase ( const char *in, char *out)
// Copy partial string // Copy partial string
strncpy( out, &in[start], len ); strncpy( out, &in[start], len );
// Terminate it // Terminate it
out[len] = 0; out[len] = 0;
} }
@ -470,13 +463,13 @@ HUD_IsGame
int HUD_IsGame( const char *game ) int HUD_IsGame( const char *game )
{ {
const char *gamedir; const char *gamedir;
char gd[ 1024 ]; char gd[1024];
gamedir = gEngfuncs.pfnGetGameDirectory(); gamedir = gEngfuncs.pfnGetGameDirectory();
if ( gamedir && gamedir[0] ) if( gamedir && gamedir[0] )
{ {
COM_FileBase( gamedir, gd ); COM_FileBase( gamedir, gd );
if ( !stricmp( gd, game ) ) if( !stricmp( gd, game ) )
return 1; return 1;
} }
return 0; return 0;
@ -491,27 +484,27 @@ Returns last FOV
*/ */
float HUD_GetFOV( void ) float HUD_GetFOV( void )
{ {
if ( gEngfuncs.pDemoAPI->IsRecording() ) if( gEngfuncs.pDemoAPI->IsRecording() )
{ {
// Write it // Write it
int i = 0; int i = 0;
unsigned char buf[ 100 ]; unsigned char buf[100];
// Active // Active
*( float * )&buf[ i ] = g_lastFOV; *(float *)&buf[i] = g_lastFOV;
i += sizeof( float ); i += sizeof(float);
Demo_WriteBuffer( TYPE_ZOOM, i, buf ); Demo_WriteBuffer( TYPE_ZOOM, i, buf );
} }
if ( gEngfuncs.pDemoAPI->IsPlayingback() ) if( gEngfuncs.pDemoAPI->IsPlayingback() )
{ {
g_lastFOV = g_demozoom; g_lastFOV = g_demozoom;
} }
return g_lastFOV; return g_lastFOV;
} }
int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -519,12 +512,12 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
int def_fov = CVAR_GET_FLOAT( "default_fov" ); int def_fov = CVAR_GET_FLOAT( "default_fov" );
//Weapon prediction already takes care of changing the fog. ( g_lastFOV ). //Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
if ( cl_lw && cl_lw->value ) if( cl_lw && cl_lw->value )
return 1; return 1;
g_lastFOV = newfov; g_lastFOV = newfov;
if ( newfov == 0 ) if( newfov == 0 )
{ {
m_iFOV = def_fov; m_iFOV = def_fov;
} }
@ -536,7 +529,7 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
// the clients fov is actually set in the client data update section of the hud // the clients fov is actually set in the client data update section of the hud
// Set a new sensitivity // Set a new sensitivity
if ( m_iFOV == def_fov ) if( m_iFOV == def_fov )
{ {
// reset to saved sensitivity // reset to saved sensitivity
m_flMouseSensitivity = 0; m_flMouseSensitivity = 0;
@ -550,24 +543,23 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
return 1; return 1;
} }
void CHud::AddHudElem( CHudBase *phudelem )
void CHud::AddHudElem(CHudBase *phudelem)
{ {
HUDLIST *pdl, *ptemp; HUDLIST *pdl, *ptemp;
//phudelem->Think(); //phudelem->Think();
if (!phudelem) if( !phudelem )
return; return;
pdl = (HUDLIST *)malloc(sizeof(HUDLIST)); pdl = (HUDLIST *)malloc( sizeof(HUDLIST) );
if (!pdl) if( !pdl )
return; return;
memset(pdl, 0, sizeof(HUDLIST)); memset( pdl, 0, sizeof(HUDLIST) );
pdl->p = phudelem; pdl->p = phudelem;
if (!m_pHudList) if( !m_pHudList )
{ {
m_pHudList = pdl; m_pHudList = pdl;
return; return;
@ -575,7 +567,7 @@ void CHud::AddHudElem(CHudBase *phudelem)
ptemp = m_pHudList; ptemp = m_pHudList;
while (ptemp->pNext) while( ptemp->pNext )
ptemp = ptemp->pNext; ptemp = ptemp->pNext;
ptemp->pNext = pdl; ptemp->pNext = pdl;
@ -585,5 +577,3 @@ float CHud::GetSensitivity( void )
{ {
return m_flMouseSensitivity; return m_flMouseSensitivity;
} }

View File

@ -20,7 +20,6 @@
// CHud handles the message, calculation, and drawing the HUD // CHud handles the message, calculation, and drawing the HUD
// //
#define RGB_YELLOWISH 0x00FFA000 //255,160,0 #define RGB_YELLOWISH 0x00FFA000 //255,160,0
#define RGB_REDISH 0x00FF1010 //255,160,0 #define RGB_REDISH 0x00FF1010 //255,160,0
#define RGB_GREENISH 0x0000A000 //0,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0
@ -36,7 +35,8 @@
#define HUDELEM_ACTIVE 1 #define HUDELEM_ACTIVE 1
typedef struct { typedef struct
{
int x, y; int x, y;
} POSITION; } POSITION;
@ -44,16 +44,16 @@ enum
{ {
MAX_PLAYERS = 64, MAX_PLAYERS = 64,
MAX_TEAMS = 64, MAX_TEAMS = 64,
MAX_TEAM_NAME = 16, MAX_TEAM_NAME = 16
}; };
typedef struct { typedef struct
unsigned char r,g,b,a; {
unsigned char r, g, b, a;
} RGBA; } RGBA;
typedef struct cvar_s cvar_t; typedef struct cvar_s cvar_t;
#define HUD_ACTIVE 1 #define HUD_ACTIVE 1
#define HUD_INTERMISSION 2 #define HUD_INTERMISSION 2
@ -71,42 +71,39 @@ public:
int m_type; int m_type;
int m_iFlags; // active, moving, int m_iFlags; // active, moving,
virtual ~CHudBase() {} virtual ~CHudBase() {}
virtual int Init( void ) {return 0;} virtual int Init( void ) { return 0; }
virtual int VidInit( void ) {return 0;} virtual int VidInit( void ) { return 0; }
virtual int Draw(float flTime) {return 0;} virtual int Draw( float flTime ) { return 0; }
virtual void Think(void) {return;} virtual void Think( void ) { return; }
virtual void Reset(void) {return;} virtual void Reset( void ) { return; }
virtual void InitHUDData( void ) {} // called every time a server is connected to virtual void InitHUDData( void ) {} // called every time a server is connected to
}; };
struct HUDLIST { struct HUDLIST
{
CHudBase *p; CHudBase *p;
HUDLIST *pNext; HUDLIST *pNext;
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
#include "hud_spectator.h" #include "hud_spectator.h"
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudAmmo: public CHudBase class CHudAmmo : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
int Draw(float flTime); int Draw( float flTime );
void Think(void); void Think( void );
void Reset(void); void Reset( void );
int DrawWList(float flTime); int DrawWList( float flTime );
int MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf); int MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf );
int MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf); int MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf );
int MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf); int MsgFunc_AmmoX( const char *pszName, int iSize, void *pbuf );
int MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf ); int MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf );
int MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf ); int MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf );
int MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf ); int MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf );
@ -133,14 +130,12 @@ private:
WEAPON *m_pWeapon; WEAPON *m_pWeapon;
int m_HUD_bucket0; int m_HUD_bucket0;
int m_HUD_selection; int m_HUD_selection;
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudAmmoSecondary : public CHudBase
class CHudAmmoSecondary: public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
@ -176,29 +171,27 @@ class CHudGeiger: public CHudBase
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
int Draw(float flTime); int Draw( float flTime );
int MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf); int MsgFunc_Geiger( const char *pszName, int iSize, void *pbuf );
private: private:
int m_iGeigerRange; int m_iGeigerRange;
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudTrain: public CHudBase class CHudTrain : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
int Draw(float flTime); int Draw( float flTime );
int MsgFunc_Train(const char *pszName, int iSize, void *pbuf); int MsgFunc_Train( const char *pszName, int iSize, void *pbuf );
private: private:
HSPRITE m_hSprite; HSPRITE m_hSprite;
int m_iPos; int m_iPos;
}; };
// //
@ -206,7 +199,6 @@ private:
// //
// REMOVED: Vgui has replaced this. // REMOVED: Vgui has replaced this.
// //
class CHudMOTD : public CHudBase class CHudMOTD : public CHudBase
{ {
public: public:
@ -223,14 +215,13 @@ public:
protected: protected:
static int MOTD_DISPLAY_TIME; static int MOTD_DISPLAY_TIME;
char m_szMOTD[ MAX_MOTD_LENGTH ]; char m_szMOTD[MAX_MOTD_LENGTH];
int m_iLines; int m_iLines;
int m_iMaxLength; int m_iMaxLength;
}; };
class CHudScoreboard : public CHudBase
class CHudScoreboard: public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
@ -257,7 +248,6 @@ public:
void GetAllPlayersInfo( void ); void GetAllPlayersInfo( void );
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
@ -274,10 +264,11 @@ public:
int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ); int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf );
protected: protected:
enum { enum
{
MAX_STATUSTEXT_LENGTH = 128, MAX_STATUSTEXT_LENGTH = 128,
MAX_STATUSBAR_VALUES = 8, MAX_STATUSBAR_VALUES = 8,
MAX_STATUSBAR_LINES = 2, MAX_STATUSBAR_LINES = 2
}; };
char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn
@ -296,7 +287,7 @@ protected:
// REMOVED: Vgui has replaced this. // REMOVED: Vgui has replaced this.
// //
/* /*
class CHudScoreboard: public CHudBase class CHudScoreboard : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
@ -319,9 +310,9 @@ public:
int m_iShowscoresHeld; int m_iShowscoresHeld;
void GetAllPlayersInfo( void ); void GetAllPlayersInfo( void );
private: private:
struct cvar_s *cl_showpacketloss; struct cvar_s *cl_showpacketloss;
}; };
*/ */
@ -348,11 +339,10 @@ struct team_info_t
int teamnumber; int teamnumber;
}; };
extern hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine extern hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine
extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll
extern team_info_t g_TeamInfo[MAX_TEAMS+1]; extern team_info_t g_TeamInfo[MAX_TEAMS + 1];
extern int g_IsSpectator[MAX_PLAYERS+1]; extern int g_IsSpectator[MAX_PLAYERS + 1];
// //
//----------------------------------------------------- //-----------------------------------------------------
@ -404,10 +394,9 @@ public:
int MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ); int MsgFunc_SayText( const char *pszName, int iSize, void *pbuf );
void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 ); void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 );
void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ); void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line );
friend class CHudSpectator; friend class CHudSpectator;
private: private:
struct cvar_s * m_HUD_saytext; struct cvar_s * m_HUD_saytext;
struct cvar_s * m_HUD_saytext_time; struct cvar_s * m_HUD_saytext_time;
}; };
@ -415,13 +404,13 @@ private:
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudBattery: public CHudBase class CHudBattery : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
int Draw(float flTime); int Draw( float flTime );
int MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ); int MsgFunc_Battery( const char *pszName, int iSize, void *pbuf );
private: private:
HSPRITE m_hSprite1; HSPRITE m_hSprite1;
@ -433,7 +422,6 @@ private:
int m_iHeight; // width of the battery innards int m_iHeight; // width of the battery innards
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
@ -442,10 +430,10 @@ class CHudFlashlight: public CHudBase
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
int Draw(float flTime); int Draw( float flTime );
void Reset( void ); void Reset( void );
int MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ); int MsgFunc_Flashlight( const char *pszName, int iSize, void *pbuf );
int MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ); int MsgFunc_FlashBat( const char *pszName, int iSize, void *pbuf );
private: private:
HSPRITE m_hSprite1; HSPRITE m_hSprite1;
@ -486,28 +474,28 @@ struct message_parms_t
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudTextMessage: public CHudBase class CHudTextMessage : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ); static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size );
static char *BufferedLocaliseTextString( const char *msg ); static char *BufferedLocaliseTextString( const char *msg );
char *LookupString( const char *msg_name, int *msg_dest = NULL ); char *LookupString( const char *msg_name, int *msg_dest = NULL );
int MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf); int MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf );
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudMessage: public CHudBase class CHudMessage : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
int Draw(float flTime); int Draw( float flTime );
int MsgFunc_HudText(const char *pszName, int iSize, void *pbuf); int MsgFunc_HudText( const char *pszName, int iSize, void *pbuf );
int MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf); int MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf );
float FadeBlend( float fadein, float fadeout, float hold, float localTime ); float FadeBlend( float fadein, float fadeout, float hold, float localTime );
int XPosition( float x, int width, int lineWidth ); int XPosition( float x, int width, int lineWidth );
@ -536,28 +524,27 @@ private:
// //
#define MAX_SPRITE_NAME_LENGTH 24 #define MAX_SPRITE_NAME_LENGTH 24
class CHudStatusIcons: public CHudBase class CHudStatusIcons : public CHudBase
{ {
public: public:
int Init( void ); int Init( void );
int VidInit( void ); int VidInit( void );
void Reset( void ); void Reset( void );
int Draw(float flTime); int Draw( float flTime );
int MsgFunc_StatusIcon(const char *pszName, int iSize, void *pbuf); int MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf );
enum { enum
{
MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH, MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH,
MAX_ICONSPRITES = 4, MAX_ICONSPRITES = 4
}; };
//had to make these public so CHud could access them (to enable concussion icon) //had to make these public so CHud could access them (to enable concussion icon)
//could use a friend declaration instead... //could use a friend declaration instead...
void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue );
void DisableIcon( char *pszIconName ); void DisableIcon( char *pszIconName );
private: private:
typedef struct typedef struct
{ {
char szSpriteName[MAX_ICONSPRITENAME_LENGTH]; char szSpriteName[MAX_ICONSPRITENAME_LENGTH];
@ -567,15 +554,11 @@ private:
} icon_sprite_t; } icon_sprite_t;
icon_sprite_t m_IconList[MAX_ICONSPRITES]; icon_sprite_t m_IconList[MAX_ICONSPRITES];
}; };
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHud class CHud
{ {
private: private:
@ -589,7 +572,6 @@ private:
int m_iConcussionEffect; int m_iConcussionEffect;
public: public:
HSPRITE m_hsprCursor; HSPRITE m_hsprCursor;
float m_flTime; // the current client time float m_flTime; // the current client time
float m_fOldTime; // the time at which the HUD was last redrawn float m_fOldTime; // the time at which the HUD was last redrawn
@ -605,13 +587,13 @@ public:
cvar_t *m_pCvarDraw; cvar_t *m_pCvarDraw;
int m_iFontHeight; int m_iFontHeight;
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b ); int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b );
int DrawHudString(int x, int y, int iMaxX, char *szString, int r, int g, int b ); int DrawHudString( int x, int y, int iMaxX, char *szString, int r, int g, int b );
int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ); int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b );
int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ); int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
int GetNumWidth(int iNumber, int iFlags); int GetNumWidth( int iNumber, int iFlags );
int DrawHudStringLen( char *szIt ); int DrawHudStringLen( char *szIt );
void DrawDarkRectangle( int x, int y, int wide, int tall); void DrawDarkRectangle( int x, int y, int wide, int tall );
private: private:
// the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded. // the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded.
@ -624,7 +606,7 @@ private:
public: public:
HSPRITE GetSprite( int index ) HSPRITE GetSprite( int index )
{ {
return (index < 0) ? 0 : m_rghSprites[index]; return ( index < 0 ) ? 0 : m_rghSprites[index];
} }
wrect_t& GetSpriteRect( int index ) wrect_t& GetSpriteRect( int index )
@ -632,7 +614,6 @@ public:
return m_rgrcRects[index]; return m_rgrcRects[index];
} }
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
CHudAmmo m_Ammo; CHudAmmo m_Ammo;
@ -653,7 +634,6 @@ public:
CHudScoreboard m_Scoreboard; CHudScoreboard m_Scoreboard;
CHudMOTD m_MOTD; CHudMOTD m_MOTD;
void Init( void ); void Init( void );
void VidInit( void ); void VidInit( void );
void Think(void); void Think(void);
@ -664,13 +644,13 @@ public:
~CHud(); // destructor, frees allocated memory ~CHud(); // destructor, frees allocated memory
// user messages // user messages
int _cdecl MsgFunc_Damage(const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_Damage( const char *pszName, int iSize, void *pbuf );
int _cdecl MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf );
int _cdecl MsgFunc_Logo(const char *pszName, int iSize, void *pbuf); int _cdecl MsgFunc_Logo( const char *pszName, int iSize, void *pbuf );
int _cdecl MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf); int _cdecl MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf );
void _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ); void _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf );
void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ); void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf );
int _cdecl MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf); int _cdecl MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf );
int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf );
// Screen information // Screen information
@ -685,13 +665,11 @@ public:
int m_iNoConsolePrint; int m_iNoConsolePrint;
void AddHudElem(CHudBase *p); void AddHudElem( CHudBase *p );
float GetSensitivity(); float GetSensitivity();
}; };
extern CHud gHUD; extern CHud gHUD;
extern int g_iPlayerClass; extern int g_iPlayerClass;
@ -699,4 +677,3 @@ extern int g_iTeamNumber;
extern int g_iUser1; extern int g_iUser1;
extern int g_iUser2; extern int g_iUser2;
extern int g_iUser3; extern int g_iUser3;

View File

@ -11,9 +11,8 @@
#include "exportdef.h" #include "exportdef.h"
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf );
#include "wrect.h" #include "wrect.h"
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
#endif #endif

View File

@ -28,16 +28,16 @@ extern BEAM *pBeam2;
/// USER-DEFINED SERVER MESSAGE HANDLERS /// USER-DEFINED SERVER MESSAGE HANDLERS
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf )
{ {
ASSERT( iSize == 0 ); ASSERT( iSize == 0 );
// clear all hud data // clear all hud data
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while ( pList ) while( pList )
{ {
if ( pList->p ) if( pList->p )
pList->p->Reset(); pList->p->Reset();
pList = pList->pNext; pList = pList->pNext;
} }
@ -51,21 +51,21 @@ int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
return 1; return 1;
} }
void CAM_ToFirstPerson(void); void CAM_ToFirstPerson( void );
void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ) void CHud::MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{ {
CAM_ToFirstPerson(); CAM_ToFirstPerson();
} }
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{ {
// prepare all hud data // prepare all hud data
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while (pList) while( pList )
{ {
if ( pList->p ) if( pList->p )
pList->p->InitHUDData(); pList->p->InitHUDData();
pList = pList->pNext; pList = pList->pNext;
} }
@ -74,8 +74,7 @@ void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
pBeam = pBeam2 = NULL; pBeam = pBeam2 = NULL;
} }
int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf )
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_Teamplay = READ_BYTE(); m_Teamplay = READ_BYTE();
@ -83,8 +82,7 @@ int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
return 1; return 1;
} }
int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )
int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
{ {
int armor, blood; int armor, blood;
Vector from; Vector from;
@ -95,26 +93,25 @@ int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
armor = READ_BYTE(); armor = READ_BYTE();
blood = READ_BYTE(); blood = READ_BYTE();
for (i=0 ; i<3 ; i++) for( i = 0; i < 3; i++)
from[i] = READ_COORD(); from[i] = READ_COORD();
count = (blood * 0.5) + (armor * 0.5); count = ( blood * 0.5 ) + ( armor * 0.5 );
if (count < 10) if( count < 10 )
count = 10; count = 10;
// TODO: kick viewangles, show damage visually // TODO: kick viewangles, show damage visually
return 1; return 1;
} }
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_iConcussionEffect = READ_BYTE(); m_iConcussionEffect = READ_BYTE();
if (m_iConcussionEffect) if( m_iConcussionEffect )
this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0); this->m_StatusIcons.EnableIcon( "dmg_concuss", 255, 160, 0 );
else else
this->m_StatusIcons.DisableIcon("dmg_concuss"); this->m_StatusIcons.DisableIcon( "dmg_concuss" );
return 1; return 1;
} }

View File

@ -20,7 +20,6 @@
#include "cl_util.h" #include "cl_util.h"
//#include "triangleapi.h" //#include "triangleapi.h"
#define MAX_LOGO_FRAMES 56 #define MAX_LOGO_FRAMES 56
int grgLogoFrame[MAX_LOGO_FRAMES] = int grgLogoFrame[MAX_LOGO_FRAMES] =
@ -30,7 +29,6 @@ int grgLogoFrame[MAX_LOGO_FRAMES] =
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31 29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
}; };
extern int g_iVisibleMouse; extern int g_iVisibleMouse;
float HUD_GetFOV( void ); float HUD_GetFOV( void );
@ -38,20 +36,20 @@ float HUD_GetFOV( void );
extern cvar_t *sensitivity; extern cvar_t *sensitivity;
// Think // Think
void CHud::Think(void) void CHud::Think( void )
{ {
int newfov; int newfov;
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while (pList) while( pList )
{ {
if (pList->p->m_iFlags & HUD_ACTIVE) if( pList->p->m_iFlags & HUD_ACTIVE )
pList->p->Think(); pList->p->Think();
pList = pList->pNext; pList = pList->pNext;
} }
newfov = HUD_GetFOV(); newfov = HUD_GetFOV();
if ( newfov == 0 ) if( newfov == 0 )
{ {
m_iFOV = default_fov->value; m_iFOV = default_fov->value;
} }
@ -61,9 +59,8 @@ void CHud::Think(void)
} }
// the clients fov is actually set in the client data update section of the hud // the clients fov is actually set in the client data update section of the hud
// Set a new sensitivity // Set a new sensitivity
if ( m_iFOV == default_fov->value ) if( m_iFOV == default_fov->value )
{ {
// reset to saved sensitivity // reset to saved sensitivity
m_flMouseSensitivity = 0; m_flMouseSensitivity = 0;
@ -75,8 +72,9 @@ void CHud::Think(void)
} }
// think about default fov // think about default fov
if ( m_iFOV == 0 ) if( m_iFOV == 0 )
{ // only let players adjust up in fov, and only if they are not overriden by something else {
// only let players adjust up in fov, and only if they are not overriden by something else
m_iFOV = max( default_fov->value, 90 ); m_iFOV = max( default_fov->value, 90 );
} }
} }
@ -84,7 +82,7 @@ void CHud::Think(void)
// Redraw // Redraw
// step through the local data, placing the appropriate graphics & text as appropriate // step through the local data, placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise // returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission ) int CHud::Redraw( float flTime, int intermission )
{ {
m_fOldTime = m_flTime; // save time of previous redraw m_fOldTime = m_flTime; // save time of previous redraw
m_flTime = flTime; m_flTime = flTime;
@ -92,13 +90,12 @@ int CHud :: Redraw( float flTime, int intermission )
static float m_flShotTime = 0; static float m_flShotTime = 0;
// Clock was reset, reset delta // Clock was reset, reset delta
if ( m_flTimeDelta < 0 ) if( m_flTimeDelta < 0 )
m_flTimeDelta = 0; m_flTimeDelta = 0;
if( m_flShotTime && m_flShotTime < flTime )
if (m_flShotTime && m_flShotTime < flTime)
{ {
gEngfuncs.pfnClientCmd("snapshot\n"); gEngfuncs.pfnClientCmd( "snapshot\n" );
m_flShotTime = 0; m_flShotTime = 0;
} }
@ -107,20 +104,21 @@ int CHud :: Redraw( float flTime, int intermission )
// if no redrawing is necessary // if no redrawing is necessary
// return 0; // return 0;
if ( m_pCvarDraw->value ) if( m_pCvarDraw->value )
{ {
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while (pList) while( pList )
{ {
if ( !intermission ) if( !intermission )
{ {
if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) ) if ( ( pList->p->m_iFlags & HUD_ACTIVE ) && !( m_iHideHUDDisplay & HIDEHUD_ALL ) )
pList->p->Draw(flTime); pList->p->Draw( flTime );
} }
else else
{ // it's an intermission, so only draw hud elements that are set to draw during intermissions {
if ( pList->p->m_iFlags & HUD_INTERMISSION ) // it's an intermission, so only draw hud elements that are set to draw during intermissions
if( pList->p->m_iFlags & HUD_INTERMISSION )
pList->p->Draw( flTime ); pList->p->Draw( flTime );
} }
@ -129,42 +127,42 @@ int CHud :: Redraw( float flTime, int intermission )
} }
// are we in demo mode? do we need to draw the logo in the top corner? // are we in demo mode? do we need to draw the logo in the top corner?
if (m_iLogo) if( m_iLogo )
{ {
int x, y, i; int x, y, i;
if (m_hsprLogo == 0) if( m_hsprLogo == 0 )
m_hsprLogo = LoadSprite("sprites/%d_logo.spr"); m_hsprLogo = LoadSprite( "sprites/%d_logo.spr" );
SPR_Set(m_hsprLogo, 250, 250, 250 ); SPR_Set( m_hsprLogo, 250, 250, 250 );
x = SPR_Width(m_hsprLogo, 0); x = SPR_Width( m_hsprLogo, 0 );
x = ScreenWidth - x; x = ScreenWidth - x;
y = SPR_Height(m_hsprLogo, 0)/2; y = SPR_Height( m_hsprLogo, 0 ) / 2;
// Draw the logo at 20 fps // Draw the logo at 20 fps
int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES; int iFrame = (int)( flTime * 20 ) % MAX_LOGO_FRAMES;
i = grgLogoFrame[iFrame] - 1; i = grgLogoFrame[iFrame] - 1;
SPR_DrawAdditive(i, x, y, NULL); SPR_DrawAdditive( i, x, y, NULL );
} }
/* /*
if ( g_iVisibleMouse ) if( g_iVisibleMouse )
{ {
void IN_GetMousePos( int *mx, int *my ); void IN_GetMousePos( int *mx, int *my );
int mx, my; int mx, my;
IN_GetMousePos( &mx, &my ); IN_GetMousePos( &mx, &my );
if (m_hsprCursor == 0) if( m_hsprCursor == 0 )
{ {
char sz[256]; char sz[256];
sprintf( sz, "sprites/cursor.spr" ); sprintf( sz, "sprites/cursor.spr" );
m_hsprCursor = SPR_Load( sz ); m_hsprCursor = SPR_Load( sz );
} }
SPR_Set(m_hsprCursor, 250, 250, 250 ); SPR_Set( m_hsprCursor, 250, 250, 250 );
// Draw the logo at 20 fps // Draw the logo at 20 fps
SPR_DrawAdditive( 0, mx, my, NULL ); SPR_DrawAdditive( 0, mx, my, NULL );
@ -177,9 +175,9 @@ int CHud :: Redraw( float flTime, int intermission )
void ScaleColors( int &r, int &g, int &b, int a ) void ScaleColors( int &r, int &g, int &b, int a )
{ {
float x = (float)a / 255; float x = (float)a / 255;
r = (int)(r * x); r = (int)( r * x );
g = (int)(g * x); g = (int)( g * x );
b = (int)(b * x); b = (int)( b * x );
} }
const unsigned char colors[8][3] = const unsigned char colors[8][3] =
@ -194,11 +192,11 @@ const unsigned char colors[8][3] =
{240, 180, 24} {240, 180, 24}
}; };
int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
{ {
if( hud_textmode->value == 2 ) if( hud_textmode->value == 2 )
{ {
gEngfuncs.pfnDrawSetTextColor( r/255.0, g/255.0, b/255.0 ); gEngfuncs.pfnDrawSetTextColor( r / 255.0, g / 255.0, b / 255.0 );
return gEngfuncs.pfnDrawConsoleString( xpos, ypos, (char*) szIt ); return gEngfuncs.pfnDrawConsoleString( xpos, ypos, (char*) szIt );
} }
@ -206,18 +204,18 @@ int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int
TextMessageDrawChar( 0, 0, 0, 0, 0, 0 ); TextMessageDrawChar( 0, 0, 0, 0, 0, 0 );
// draw the string until we hit the null character or a newline character // draw the string until we hit the null character or a newline character
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ ) for( ; *szIt != 0 && *szIt != '\n'; szIt++ )
{ {
int w = gHUD.m_scrinfo.charWidths[ 'M' ]; int w = gHUD.m_scrinfo.charWidths['M'];
if ( xpos + w > iMaxX ) if( xpos + w > iMaxX )
return xpos; return xpos;
if( (*szIt == '^') && (*(szIt + 1) >= '0') && (*(szIt + 1) <= '7') ) if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') )
{ {
szIt++; szIt++;
r = colors[ *szIt - '0' ][0]; r = colors[*szIt - '0'][0];
g = colors[ *szIt - '0' ][1]; g = colors[*szIt - '0'][1];
b = colors[ *szIt - '0' ][2]; b = colors[*szIt - '0'][2];
if( !*(++szIt)) if( !*(++szIt) )
return xpos; return xpos;
} }
int c = (unsigned int)(unsigned char)*szIt; int c = (unsigned int)(unsigned char)*szIt;
@ -228,67 +226,65 @@ int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int
return xpos; return xpos;
} }
int CHud :: DrawHudStringLen( char *szIt ) int CHud::DrawHudStringLen( char *szIt )
{ {
int l = 0; int l = 0;
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ ) for( ; *szIt != 0 && *szIt != '\n'; szIt++ )
{ {
l += gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ]; l += gHUD.m_scrinfo.charWidths[(unsigned char)*szIt];
} }
return l; return l;
} }
int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
{ {
char szString[32]; char szString[32];
sprintf( szString, "%d", iNumber ); sprintf( szString, "%d", iNumber );
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b ); return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
} }
// draws a string from right to left (right-aligned) // draws a string from right to left (right-aligned)
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ) int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b )
{ {
// find the end of the string // find the end of the string
for( char *szIt = szString; *szIt != 0; szIt++ ) for( char *szIt = szString; *szIt != 0; szIt++ )
xpos -= gHUD.m_scrinfo.charWidths[ (unsigned char) *szIt ]; xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt];
if( xpos < iMinX ) if( xpos < iMinX )
xpos = iMinX; xpos = iMinX;
DrawHudString( xpos, ypos, gHUD.m_scrinfo.iWidth, szString, r, g, b ); DrawHudString( xpos, ypos, gHUD.m_scrinfo.iWidth, szString, r, g, b );
return xpos; return xpos;
} }
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b) int CHud::DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b )
{ {
int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left; int iWidth = GetSpriteRect( m_HUD_number_0 ).right - GetSpriteRect( m_HUD_number_0 ).left;
int k; int k;
if (iNumber > 0) if( iNumber > 0 )
{ {
// SPR_Draw 100's // SPR_Draw 100's
if (iNumber >= 100) if( iNumber >= 100 )
{ {
k = iNumber/100; k = iNumber / 100;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b ); SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k)); SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ) );
x += iWidth; x += iWidth;
} }
else if (iFlags & (DHN_3DIGITS)) else if( iFlags & ( DHN_3DIGITS ) )
{ {
//SPR_DrawAdditive( 0, x, y, &rc ); //SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth; x += iWidth;
} }
// SPR_Draw 10's // SPR_Draw 10's
if (iNumber >= 10) if( iNumber >= 10 )
{ {
k = (iNumber % 100)/10; k = ( iNumber % 100 ) / 10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b ); SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k)); SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ) );
x += iWidth; x += iWidth;
} }
else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS)) else if( iFlags & ( DHN_3DIGITS | DHN_2DIGITS ) )
{ {
//SPR_DrawAdditive( 0, x, y, &rc ); //SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth; x += iWidth;
@ -296,70 +292,66 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
// SPR_Draw ones // SPR_Draw ones
k = iNumber % 10; k = iNumber % 10;
SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b ); SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b );
SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k)); SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ) );
x += iWidth; x += iWidth;
} }
else if (iFlags & DHN_DRAWZERO) else if( iFlags & DHN_DRAWZERO )
{ {
SPR_Set(GetSprite(m_HUD_number_0), r, g, b ); SPR_Set( GetSprite( m_HUD_number_0 ), r, g, b );
// SPR_Draw 100's // SPR_Draw 100's
if (iFlags & (DHN_3DIGITS)) if( iFlags & ( DHN_3DIGITS ) )
{ {
//SPR_DrawAdditive( 0, x, y, &rc ); //SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth; x += iWidth;
} }
if (iFlags & (DHN_3DIGITS | DHN_2DIGITS)) if( iFlags & ( DHN_3DIGITS | DHN_2DIGITS ) )
{ {
//SPR_DrawAdditive( 0, x, y, &rc ); //SPR_DrawAdditive( 0, x, y, &rc );
x += iWidth; x += iWidth;
} }
// SPR_Draw ones // SPR_Draw ones
SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 ) );
SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0));
x += iWidth; x += iWidth;
} }
return x; return x;
} }
int CHud::GetNumWidth( int iNumber, int iFlags ) int CHud::GetNumWidth( int iNumber, int iFlags )
{ {
if (iFlags & (DHN_3DIGITS)) if( iFlags & ( DHN_3DIGITS ) )
return 3; return 3;
if (iFlags & (DHN_2DIGITS)) if( iFlags & ( DHN_2DIGITS ) )
return 2; return 2;
if (iNumber <= 0) if( iNumber <= 0 )
{ {
if (iFlags & (DHN_DRAWZERO)) if( iFlags & ( DHN_DRAWZERO ) )
return 1; return 1;
else else
return 0; return 0;
} }
if (iNumber < 10) if( iNumber < 10 )
return 1; return 1;
if (iNumber < 100) if( iNumber < 100 )
return 2; return 2;
return 3; return 3;
} }
void CHud::DrawDarkRectangle( int x, int y, int wide, int tall ) void CHud::DrawDarkRectangle( int x, int y, int wide, int tall )
{ {
//gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); //gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
gEngfuncs.pfnFillRGBABlend( x, y, wide, tall, 0, 0, 0, 255 * 0.6 ); gEngfuncs.pfnFillRGBABlend( x, y, wide, tall, 0, 0, 0, 255 * 0.6 );
FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 ); FillRGBA( x + 1, y, wide - 1, 1, 255, 140, 0, 255 );
FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 ); FillRGBA( x, y, 1, tall - 1, 255, 140, 0, 255 );
FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 ); FillRGBA( x + wide - 1, y + 1, 1, tall - 1, 255, 140, 0, 255 );
FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 ); FillRGBA( x, y + tall - 1, wide - 1, 1, 255, 140, 0, 255 );
} }

View File

@ -39,7 +39,7 @@ Callback from engine
*/ */
void NET_CALLBACK ListResponse( struct net_response_s *response ) void NET_CALLBACK ListResponse( struct net_response_s *response )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->ListResponse( response ); g_pServers->ListResponse( response );
} }
@ -54,7 +54,7 @@ Callback from engine
*/ */
void NET_CALLBACK ServerResponse( struct net_response_s *response ) void NET_CALLBACK ServerResponse( struct net_response_s *response )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->ServerResponse( response ); g_pServers->ServerResponse( response );
} }
@ -69,7 +69,7 @@ Callback from engine
*/ */
void NET_CALLBACK PingResponse( struct net_response_s *response ) void NET_CALLBACK PingResponse( struct net_response_s *response )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->PingResponse( response ); g_pServers->PingResponse( response );
} }
@ -84,11 +84,12 @@ Callback from engine
*/ */
void NET_CALLBACK RulesResponse( struct net_response_s *response ) void NET_CALLBACK RulesResponse( struct net_response_s *response )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->RulesResponse( response ); g_pServers->RulesResponse( response );
} }
} }
/* /*
=================== ===================
PlayersResponse PlayersResponse
@ -98,11 +99,12 @@ Callback from engine
*/ */
void NET_CALLBACK PlayersResponse( struct net_response_s *response ) void NET_CALLBACK PlayersResponse( struct net_response_s *response )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->PlayersResponse( response ); g_pServers->PlayersResponse( response );
} }
} }
/* /*
=================== ===================
ListResponse ListResponse
@ -115,20 +117,20 @@ void CHudServers::ListResponse( struct net_response_s *response )
request_t *p; request_t *p;
int c = 0; int c = 0;
if ( !( response->error == NET_SUCCESS ) ) if( !( response->error == NET_SUCCESS ) )
return; return;
if ( response->type != NETAPI_REQUEST_SERVERLIST ) if( response->type != NETAPI_REQUEST_SERVERLIST )
return; return;
if ( response->response ) if( response->response )
{ {
list = ( request_t * ) response->response; list = ( request_t * ) response->response;
while ( list ) while ( list )
{ {
c++; c++;
//if ( c < 40 ) //if( c < 40 )
{ {
// Copy from parsed stuff // Copy from parsed stuff
p = new request_t; p = new request_t;
@ -161,23 +163,23 @@ void CHudServers::ServerResponse( struct net_response_s *response )
request_t *p; request_t *p;
server_t *browser; server_t *browser;
int len; int len;
char sz[ 32 ]; char sz[32];
// Remove from active list // Remove from active list
p = FindRequest( response->context, m_pActiveList ); p = FindRequest( response->context, m_pActiveList );
if ( p ) if( p )
{ {
RemoveServerFromList( &m_pActiveList, p ); RemoveServerFromList( &m_pActiveList, p );
m_nActiveQueries--; m_nActiveQueries--;
} }
if ( response->error != NET_SUCCESS ) if( response->error != NET_SUCCESS )
return; return;
switch ( response->type ) switch ( response->type )
{ {
case NETAPI_REQUEST_DETAILS: case NETAPI_REQUEST_DETAILS:
if ( response->response ) if( response->response )
{ {
szresponse = (char *)response->response; szresponse = (char *)response->response;
len = strlen( szresponse ) + 100 + 1; len = strlen( szresponse ) + 100 + 1;
@ -185,7 +187,7 @@ void CHudServers::ServerResponse( struct net_response_s *response )
browser = new server_t; browser = new server_t;
browser->remote_address = response->remote_address; browser->remote_address = response->remote_address;
browser->info = new char[ len ]; browser->info = new char[len];
browser->ping = (int)( 1000.0 * response->ping ); browser->ping = (int)( 1000.0 * response->ping );
strcpy( browser->info, szresponse ); strcpy( browser->info, szresponse );
@ -208,12 +210,12 @@ PingResponse
*/ */
void CHudServers::PingResponse( struct net_response_s *response ) void CHudServers::PingResponse( struct net_response_s *response )
{ {
char sz[ 32 ]; char sz[32];
if ( response->error != NET_SUCCESS ) if( response->error != NET_SUCCESS )
return; return;
switch ( response->type ) switch( response->type )
{ {
case NETAPI_REQUEST_PING: case NETAPI_REQUEST_PING:
sprintf( sz, "%.2f", 1000.0 * response->ping ); sprintf( sz, "%.2f", 1000.0 * response->ping );
@ -235,13 +237,13 @@ void CHudServers::RulesResponse( struct net_response_s *response )
{ {
char *szresponse; char *szresponse;
if ( response->error != NET_SUCCESS ) if( response->error != NET_SUCCESS )
return; return;
switch ( response->type ) switch( response->type )
{ {
case NETAPI_REQUEST_RULES: case NETAPI_REQUEST_RULES:
if ( response->response ) if( response->response )
{ {
szresponse = (char *)response->response; szresponse = (char *)response->response;
@ -263,13 +265,13 @@ void CHudServers::PlayersResponse( struct net_response_s *response )
{ {
char *szresponse; char *szresponse;
if ( response->error != NET_SUCCESS ) if( response->error != NET_SUCCESS )
return; return;
switch ( response->type ) switch( response->type )
{ {
case NETAPI_REQUEST_PLAYERS: case NETAPI_REQUEST_PLAYERS:
if ( response->response ) if( response->response )
{ {
szresponse = (char *)response->response; szresponse = (char *)response->response;
@ -292,20 +294,20 @@ int CHudServers::CompareServers( server_t *p1, server_t *p2 )
{ {
const char *n1, *n2; const char *n1, *n2;
if ( p1->ping < p2->ping ) if( p1->ping < p2->ping )
return 1; return 1;
if ( p1->ping == p2->ping ) if( p1->ping == p2->ping )
{ {
// Pings equal, sort by second key: hostname // Pings equal, sort by second key: hostname
if ( p1->info && p2->info ) if( p1->info && p2->info )
{ {
n1 = NET_API->ValueForKey( p1->info, "hostname" ); n1 = NET_API->ValueForKey( p1->info, "hostname" );
n2 = NET_API->ValueForKey( p2->info, "hostname" ); n2 = NET_API->ValueForKey( p2->info, "hostname" );
if ( n1 && n2 ) if( n1 && n2 )
{ {
if ( stricmp( n1, n2 ) < 0 ) if( stricmp( n1, n2 ) < 0 )
return 1; return 1;
} }
} }
@ -322,9 +324,9 @@ AddServer
*/ */
void CHudServers::AddServer( server_t **ppList, server_t *p ) void CHudServers::AddServer( server_t **ppList, server_t *p )
{ {
server_t *list; server_t *list;
if ( !ppList || ! p ) if( !ppList || ! p )
return; return;
m_nServerCount++; m_nServerCount++;
@ -333,7 +335,7 @@ server_t *list;
list = *ppList; list = *ppList;
// Head of list? // Head of list?
if ( !list ) if( !list )
{ {
p->next = NULL; p->next = NULL;
*ppList = p; *ppList = p;
@ -341,17 +343,17 @@ server_t *list;
} }
// Put on head of list // Put on head of list
if ( CompareServers( p, list ) ) if( CompareServers( p, list ) )
{ {
p->next = *ppList; p->next = *ppList;
*ppList = p; *ppList = p;
} }
else else
{ {
while ( list->next ) while( list->next )
{ {
// Insert before list next // Insert before list next
if ( CompareServers( p, list->next ) ) if( CompareServers( p, list->next ) )
{ {
p->next = list->next->next; p->next = list->next->next;
list->next = p; list->next = p;
@ -377,15 +379,15 @@ void CHudServers::Think( double time )
{ {
m_fElapsed += time; m_fElapsed += time;
if ( !m_nRequesting ) if( !m_nRequesting )
return; return;
if ( !m_nQuerying ) if( !m_nQuerying )
return; return;
QueryThink(); QueryThink();
if ( ServerListSize() > 0 ) if( ServerListSize() > 0 )
return; return;
m_dStarted = 0.0; m_dStarted = 0.0;
@ -405,25 +407,25 @@ void CHudServers::QueryThink( void )
{ {
request_t *p; request_t *p;
if ( !m_nRequesting || m_nDone ) if( !m_nRequesting || m_nDone )
return; return;
if ( !m_nQuerying ) if( !m_nQuerying )
return; return;
if ( m_nActiveQueries > MAX_QUERIES ) if( m_nActiveQueries > MAX_QUERIES )
return; return;
// Nothing left // Nothing left
if ( !m_pServerList ) if( !m_pServerList )
return; return;
while ( 1 ) while( 1 )
{ {
p = m_pServerList; p = m_pServerList;
// No more in list? // No more in list?
if ( !p ) if( !p )
break; break;
// Move to next // Move to next
@ -443,7 +445,7 @@ void CHudServers::QueryThink( void )
m_pActiveList = p; m_pActiveList = p;
// Too many active? // Too many active?
if ( m_nActiveQueries > MAX_QUERIES ) if( m_nActiveQueries > MAX_QUERIES )
break; break;
} }
} }
@ -461,14 +463,14 @@ int CHudServers::ServerListSize( void )
request_t *p; request_t *p;
p = m_pServerList; p = m_pServerList;
while ( p ) while( p )
{ {
c++; c++;
p = p->next; p = p->next;
} }
p = m_pActiveList; p = m_pActiveList;
while ( p ) while( p )
{ {
c++; c++;
p = p->next; p = p->next;
@ -488,9 +490,9 @@ CHudServers::request_t *CHudServers::FindRequest( int context, request_t *pList
{ {
request_t *p; request_t *p;
p = pList; p = pList;
while ( p ) while( p )
{ {
if ( context == p->context ) if( context == p->context )
return p; return p;
p = p->next; p = p->next;
@ -510,14 +512,14 @@ void CHudServers::RemoveServerFromList( request_t **ppList, request_t *item )
request_t *p, *n; request_t *p, *n;
request_t *newlist = NULL; request_t *newlist = NULL;
if ( !ppList ) if( !ppList )
return; return;
p = *ppList; p = *ppList;
while ( p ) while( p )
{ {
n = p->next; n = p->next;
if ( p != item ) if( p != item )
{ {
p->next = newlist; p->next = newlist;
newlist = p; newlist = p;
@ -537,11 +539,11 @@ void CHudServers::ClearRequestList( request_t **ppList )
{ {
request_t *p, *n; request_t *p, *n;
if ( !ppList ) if( !ppList )
return; return;
p = *ppList; p = *ppList;
while ( p ) while( p )
{ {
n = p->next; n = p->next;
delete p; delete p;
@ -560,11 +562,11 @@ void CHudServers::ClearServerList( server_t **ppList )
{ {
server_t *p, *n; server_t *p, *n;
if ( !ppList ) if( !ppList )
return; return;
p = *ppList; p = *ppList;
while ( p ) while( p )
{ {
n = p->next; n = p->next;
delete[] p->info; delete[] p->info;
@ -585,11 +587,11 @@ int CompareField( CHudServers::server_t *p1, CHudServers::server_t *p2, const ch
fv1 = atof( sz1 ); fv1 = atof( sz1 );
fv2 = atof( sz2 ); fv2 = atof( sz2 );
if ( fv1 && fv2 ) if( fv1 && fv2 )
{ {
if ( fv1 > fv2 ) if( fv1 > fv2 )
return iSortOrder; return iSortOrder;
else if ( fv1 < fv2 ) else if( fv1 < fv2 )
return -iSortOrder; return -iSortOrder;
else else
return 0; return 0;
@ -601,7 +603,7 @@ int CompareField( CHudServers::server_t *p1, CHudServers::server_t *p2, const ch
int CALLBACK ServerListCompareFunc( CHudServers::server_t *p1, CHudServers::server_t *p2, const char *fieldname ) int CALLBACK ServerListCompareFunc( CHudServers::server_t *p1, CHudServers::server_t *p2, const char *fieldname )
{ {
if (!p1 || !p2) // No meaningful comparison if(!p1 || !p2) // No meaningful comparison
return 0; return 0;
int iSortOrder = 1; int iSortOrder = 1;
@ -613,8 +615,8 @@ int CALLBACK ServerListCompareFunc( CHudServers::server_t *p1, CHudServers::serv
return retval; return retval;
} }
static char g_fieldname[ 256 ]; static char g_fieldname[256];
int __cdecl FnServerCompare(const void *elem1, const void *elem2 ) int __cdecl FnServerCompare( const void *elem1, const void *elem2 )
{ {
CHudServers::server_t *list1, *list2; CHudServers::server_t *list1, *list2;
@ -628,7 +630,7 @@ void CHudServers::SortServers( const char *fieldname )
{ {
server_t *p; server_t *p;
// Create a list // Create a list
if ( !m_pServers ) if( !m_pServers )
return; return;
strcpy( g_fieldname, fieldname ); strcpy( g_fieldname, fieldname );
@ -637,7 +639,7 @@ void CHudServers::SortServers( const char *fieldname )
int c = 0; int c = 0;
p = m_pServers; p = m_pServers;
while ( p ) while( p )
{ {
c++; c++;
p = p->next; p = p->next;
@ -645,21 +647,21 @@ void CHudServers::SortServers( const char *fieldname )
server_t **pSortArray; server_t **pSortArray;
pSortArray = new server_t *[ c ]; pSortArray = new server_t *[c];
memset( pSortArray, 0, c * sizeof( server_t * ) ); memset( pSortArray, 0, c * sizeof(server_t*) );
// Now copy the list into the pSortArray: // Now copy the list into the pSortArray:
p = m_pServers; p = m_pServers;
i = 0; i = 0;
while ( p ) while( p )
{ {
pSortArray[ i++ ] = p; pSortArray[i++] = p;
p = p->next; p = p->next;
} }
// Now do that actual sorting. // Now do that actual sorting.
size_t nCount = c; size_t nCount = c;
size_t nSize = sizeof( server_t * ); size_t nSize = sizeof(server_t*);
qsort( qsort(
pSortArray, pSortArray,
@ -670,11 +672,11 @@ void CHudServers::SortServers( const char *fieldname )
// Now rebuild the list. // Now rebuild the list.
m_pServers = pSortArray[0]; m_pServers = pSortArray[0];
for ( i = 0; i < c - 1; i++ ) for( i = 0; i < c - 1; i++ )
{ {
pSortArray[ i ]->next = pSortArray[ i + 1 ]; pSortArray[i]->next = pSortArray[i + 1];
} }
pSortArray[ c - 1 ]->next = NULL; pSortArray[c - 1]->next = NULL;
// Clean Up. // Clean Up.
delete[] pSortArray; delete[] pSortArray;
@ -693,9 +695,9 @@ CHudServers::server_t *CHudServers::GetServer( int server )
server_t *p; server_t *p;
p = m_pServers; p = m_pServers;
while ( p ) while( p )
{ {
if ( c == server ) if( c == server )
return p; return p;
c++; c++;
@ -714,7 +716,7 @@ Return info ( key/value ) string for particular server
char *CHudServers::GetServerInfo( int server ) char *CHudServers::GetServerInfo( int server )
{ {
server_t *p = GetServer( server ); server_t *p = GetServer( server );
if ( p ) if( p )
{ {
return p->info; return p->info;
} }
@ -747,7 +749,7 @@ Loads the master server addresses from file and into the passed in array
int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr ) int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr )
{ {
int i; int i;
char szMaster[ 256 ]; char szMaster[256];
char szMasterFile[256]; char szMasterFile[256];
char *pbuffer = NULL; char *pbuffer = NULL;
char *pstart = NULL ; char *pstart = NULL ;
@ -764,30 +766,30 @@ int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr
// See if there is a command line override // See if there is a command line override
i = gEngfuncs.CheckParm( "-comm", &pstart ); i = gEngfuncs.CheckParm( "-comm", &pstart );
if ( i && pstart ) if( i && pstart )
{ {
strcpy (szMasterFile, pstart ); strcpy( szMasterFile, pstart );
} }
// Read them in from proper file // Read them in from proper file
pbuffer = (char *)gEngfuncs.COM_LoadFile( szMasterFile, 5, NULL ); // Use malloc pbuffer = (char *)gEngfuncs.COM_LoadFile( szMasterFile, 5, NULL ); // Use malloc
if ( !pbuffer ) if( !pbuffer )
{ {
goto finish_master; goto finish_master;
} }
pstart = pbuffer; pstart = pbuffer;
while ( nCount < maxservers ) while( nCount < maxservers )
{ {
pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken );
if ( strlen(m_szToken) <= 0) if( strlen( m_szToken ) <= 0)
break; break;
bIgnore = true; bIgnore = true;
if ( !stricmp( m_szToken, "Master" ) ) if( !stricmp( m_szToken, "Master" ) )
{ {
nDefaultPort = PORT_MASTER; nDefaultPort = PORT_MASTER;
bIgnore = FALSE; bIgnore = FALSE;
@ -795,74 +797,72 @@ int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr
// Now parse all addresses between { } // Now parse all addresses between { }
pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken );
if ( strlen(m_szToken) <= 0 ) if( strlen( m_szToken ) <= 0 )
break; break;
if ( stricmp ( m_szToken, "{" ) ) if( stricmp( m_szToken, "{" ) )
break; break;
// Parse addresses until we get to "}" // Parse addresses until we get to "}"
while ( nCount < maxservers ) while( nCount < maxservers )
{ {
char base[256]; char base[256];
// Now parse all addresses between { } // Now parse all addresses between { }
pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken );
if (strlen(m_szToken) <= 0) if( strlen( m_szToken ) <= 0 )
break; break;
if ( !stricmp ( m_szToken, "}" ) ) if( !stricmp ( m_szToken, "}" ) )
break; break;
sprintf( base, "%s", m_szToken ); sprintf( base, "%s", m_szToken );
pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken );
if (strlen(m_szToken) <= 0) if( strlen( m_szToken ) <= 0 )
break; break;
if ( stricmp( m_szToken, ":" ) ) if( stricmp( m_szToken, ":" ) )
break; break;
pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken );
if (strlen(m_szToken) <= 0) if( strlen( m_szToken ) <= 0 )
break; break;
nPort = atoi ( m_szToken ); nPort = atoi( m_szToken );
if ( !nPort ) if( !nPort )
nPort = nDefaultPort; nPort = nDefaultPort;
sprintf( szAdr, "%s:%i", base, nPort ); sprintf( szAdr, "%s:%i", base, nPort );
// Can we resolve it any better // Can we resolve it any better
if ( !NET_API->StringToAdr( szAdr, &adr ) ) if( !NET_API->StringToAdr( szAdr, &adr ) )
bIgnore = true; bIgnore = true;
if ( !bIgnore ) if( !bIgnore )
{ {
padr[ nCount++ ] = adr; padr[nCount++] = adr;
} }
} }
} }
finish_master: finish_master:
if ( !nCount ) if( !nCount )
{ {
sprintf( szMaster, VALVE_MASTER_ADDRESS ); // IP:PORT string sprintf( szMaster, VALVE_MASTER_ADDRESS ); // IP:PORT string
// Convert to netadr_t // Convert to netadr_t
if ( NET_API->StringToAdr ( szMaster, &adr ) ) if( NET_API->StringToAdr( szMaster, &adr ) )
{ {
padr[nCount++] = adr;
padr[ nCount++ ] = adr;
} }
} }
*count = nCount; *count = nCount;
if ( pbuffer ) if( pbuffer )
{ {
gEngfuncs.COM_FreeFile( pbuffer ); gEngfuncs.COM_FreeFile( pbuffer );
} }
@ -886,7 +886,7 @@ void CHudServers::RequestList( void )
int count = 0; int count = 0;
netadr_t adr; netadr_t adr;
if ( !LoadMasterAddresses( 1, &count, &adr ) ) if( !LoadMasterAddresses( 1, &count, &adr ) )
{ {
gEngfuncs.Con_DPrintf( "SendRequest: Unable to read master server addresses\n" ); gEngfuncs.Con_DPrintf( "SendRequest: Unable to read master server addresses\n" );
return; return;
@ -914,10 +914,9 @@ void CHudServers::RequestBroadcastList( int clearpending )
m_nDone = 0; m_nDone = 0;
m_dStarted = m_fElapsed; m_dStarted = m_fElapsed;
netadr_t adr; netadr_t adr = {0};
memset( &adr, 0, sizeof( adr ) );
if ( clearpending ) if( clearpending )
{ {
ClearRequestList( &m_pActiveList ); ClearRequestList( &m_pActiveList );
ClearRequestList( &m_pServerList ); ClearRequestList( &m_pServerList );
@ -932,7 +931,7 @@ void CHudServers::RequestBroadcastList( int clearpending )
// Make sure networking system has started. // Make sure networking system has started.
NET_API->InitNetworking(); NET_API->InitNetworking();
if ( clearpending ) if( clearpending )
{ {
// Kill off left overs if any // Kill off left overs if any
NET_API->CancelAllRequests(); NET_API->CancelAllRequests();
@ -954,7 +953,7 @@ void CHudServers::ServerPing( int server )
server_t *p; server_t *p;
p = GetServer( server ); p = GetServer( server );
if ( !p ) if( !p )
return; return;
// Make sure networking system has started. // Make sure networking system has started.
@ -969,7 +968,7 @@ void CHudServers::ServerRules( int server )
server_t *p; server_t *p;
p = GetServer( server ); p = GetServer( server );
if ( !p ) if( !p )
return; return;
// Make sure networking system has started. // Make sure networking system has started.
@ -984,7 +983,7 @@ void CHudServers::ServerPlayers( int server )
server_t *p; server_t *p;
p = GetServer( server ); p = GetServer( server );
if ( !p ) if( !p )
return; return;
// Make sure networking system has started. // Make sure networking system has started.
@ -999,7 +998,6 @@ int CHudServers::isQuerying()
return m_nRequesting ? 1 : 0; return m_nRequesting ? 1 : 0;
} }
/* /*
=================== ===================
GetServerCount GetServerCount
@ -1031,7 +1029,6 @@ CHudServers::CHudServers( void )
m_fElapsed = 0.0; m_fElapsed = 0.0;
m_pPingRequest = NULL; m_pPingRequest = NULL;
m_pRulesRequest = NULL; m_pRulesRequest = NULL;
m_pPlayersRequest = NULL; m_pPlayersRequest = NULL;
@ -1051,20 +1048,19 @@ CHudServers::~CHudServers( void )
m_nServerCount = 0; m_nServerCount = 0;
if ( m_pPingRequest ) if( m_pPingRequest )
{ {
delete m_pPingRequest; delete m_pPingRequest;
m_pPingRequest = NULL; m_pPingRequest = NULL;
} }
if ( m_pRulesRequest ) if( m_pRulesRequest )
{ {
delete m_pRulesRequest; delete m_pRulesRequest;
m_pRulesRequest = NULL; m_pRulesRequest = NULL;
} }
if ( m_pPlayersRequest ) if( m_pPlayersRequest )
{ {
delete m_pPlayersRequest; delete m_pPlayersRequest;
m_pPlayersRequest = NULL; m_pPlayersRequest = NULL;
@ -1085,7 +1081,7 @@ ServersGetCount
*/ */
int ServersGetCount( void ) int ServersGetCount( void )
{ {
if ( g_pServers ) if( g_pServers )
{ {
return g_pServers->GetServerCount(); return g_pServers->GetServerCount();
} }
@ -1094,7 +1090,7 @@ int ServersGetCount( void )
int ServersIsQuerying( void ) int ServersIsQuerying( void )
{ {
if ( g_pServers ) if( g_pServers )
{ {
return g_pServers->isQuerying(); return g_pServers->isQuerying();
} }
@ -1109,7 +1105,7 @@ ServersGetInfo
*/ */
const char *ServersGetInfo( int server ) const char *ServersGetInfo( int server )
{ {
if ( g_pServers ) if( g_pServers )
{ {
return g_pServers->GetServerInfo( server ); return g_pServers->GetServerInfo( server );
} }
@ -1119,7 +1115,7 @@ const char *ServersGetInfo( int server )
void SortServers( const char *fieldname ) void SortServers( const char *fieldname )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->SortServers( fieldname ); g_pServers->SortServers( fieldname );
} }
@ -1133,7 +1129,7 @@ ServersShutdown
*/ */
void ServersShutdown( void ) void ServersShutdown( void )
{ {
if ( g_pServers ) if( g_pServers )
{ {
delete g_pServers; delete g_pServers;
g_pServers = NULL; g_pServers = NULL;
@ -1162,7 +1158,7 @@ ServersThink
*/ */
void ServersThink( double time ) void ServersThink( double time )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->Think( time ); g_pServers->Think( time );
} }
@ -1176,7 +1172,7 @@ ServersCancel
*/ */
void ServersCancel( void ) void ServersCancel( void )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->CancelRequest(); g_pServers->CancelRequest();
} }
@ -1191,7 +1187,7 @@ ServersList
*/ */
void ServersList( void ) void ServersList( void )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->RequestList(); g_pServers->RequestList();
} }
@ -1199,7 +1195,7 @@ void ServersList( void )
void BroadcastServersList( int clearpending ) void BroadcastServersList( int clearpending )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->RequestBroadcastList( clearpending ); g_pServers->RequestBroadcastList( clearpending );
} }
@ -1207,7 +1203,7 @@ void BroadcastServersList( int clearpending )
void ServerPing( int server ) void ServerPing( int server )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->ServerPing( server ); g_pServers->ServerPing( server );
} }
@ -1215,7 +1211,7 @@ void ServerPing( int server )
void ServerRules( int server ) void ServerRules( int server )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->ServerRules( server ); g_pServers->ServerRules( server );
} }
@ -1223,7 +1219,7 @@ void ServerRules( int server )
void ServerPlayers( int server ) void ServerPlayers( int server )
{ {
if ( g_pServers ) if( g_pServers )
{ {
g_pServers->ServerPlayers( server ); g_pServers->ServerPlayers( server );
} }

View File

@ -37,5 +37,4 @@ int ServersGetCount( void );
const char *ServersGetInfo( int server ); const char *ServersGetInfo( int server );
int ServersIsQuerying( void ); int ServersIsQuerying( void );
void SortServers( const char *fieldname ); void SortServers( const char *fieldname );
#endif // HUD_SERVERSH #endif // HUD_SERVERSH

View File

@ -73,7 +73,7 @@ private:
server_t *GetServer( int server ); server_t *GetServer( int server );
// //
char m_szToken[ 1024 ]; char m_szToken[1024];
int m_nRequesting; int m_nRequesting;
int m_nDone; int m_nDone;
@ -94,5 +94,4 @@ private:
request_t *m_pRulesRequest; request_t *m_pRulesRequest;
request_t *m_pPlayersRequest; request_t *m_pPlayersRequest;
}; };
#endif // HUD_SERVERS_PRIVH #endif // HUD_SERVERS_PRIVH

File diff suppressed because it is too large Load Diff

View File

@ -11,8 +11,6 @@
#include "cl_entity.h" #include "cl_entity.h"
#define INSET_OFF 0 #define INSET_OFF 0
#define INSET_CHASE_FREE 1 #define INSET_CHASE_FREE 1
#define INSET_IN_EYE 2 #define INSET_IN_EYE 2
@ -21,8 +19,6 @@
#define MAX_SPEC_HUD_MESSAGES 8 #define MAX_SPEC_HUD_MESSAGES 8
#define OVERVIEW_TILE_SIZE 128 // don't change this #define OVERVIEW_TILE_SIZE 128 // don't change this
#define OVERVIEW_MAX_LAYERS 1 #define OVERVIEW_MAX_LAYERS 1
@ -30,7 +26,8 @@
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it ) // Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
typedef struct overviewInfo_s { typedef struct overviewInfo_s
{
char map[64]; // cl.levelname or empty char map[64]; // cl.levelname or empty
vec3_t origin; // center of map vec3_t origin; // center of map
float zoom; // zoom of map images float zoom; // zoom of map images
@ -45,8 +42,8 @@ typedef struct overviewInfo_s {
int insetWindowWidth; int insetWindowWidth;
} overviewInfo_t; } overviewInfo_t;
typedef struct overviewEntity_s { typedef struct overviewEntity_s
{
HSPRITE hSprite; HSPRITE hSprite;
struct cl_entity_s * entity; struct cl_entity_s * entity;
double killTime; double killTime;
@ -58,11 +55,11 @@ class CHudSpectator : public CHudBase
{ {
public: public:
void Reset(); void Reset();
int ToggleInset(bool allowOff); int ToggleInset( bool allowOff );
void CheckSettings(); void CheckSettings();
void InitHUDData( void ); void InitHUDData( void );
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime); bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime );
void DeathMessage(int victim); void DeathMessage( int victim );
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname ); bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
void CheckOverviewEntities(); void CheckOverviewEntities();
void DrawOverview(); void DrawOverview();
@ -71,17 +68,17 @@ public:
void DrawOverviewLayer(); void DrawOverviewLayer();
void LoadMapSprites(); void LoadMapSprites();
bool ParseOverviewFile(); bool ParseOverviewFile();
bool IsActivePlayer(cl_entity_t * ent); bool IsActivePlayer( cl_entity_t * ent );
void SetModes(int iMainMode, int iInsetMode); void SetModes( int iMainMode, int iInsetMode );
void HandleButtonsDown(int ButtonPressed); void HandleButtonsDown( int ButtonPressed );
void HandleButtonsUp(int ButtonPressed); void HandleButtonsUp( int ButtonPressed );
void FindNextPlayer( bool bReverse ); void FindNextPlayer( bool bReverse );
void DirectorMessage( int iSize, void *pbuf ); void DirectorMessage( int iSize, void *pbuf );
void SetSpectatorStartPosition(); void SetSpectatorStartPosition();
int Init(); int Init();
int VidInit(); int VidInit();
int Draw(float flTime); int Draw( float flTime );
int m_iDrawCycle; int m_iDrawCycle;
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES]; client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
@ -94,19 +91,17 @@ public:
float m_mapZoom; // zoom the user currently uses float m_mapZoom; // zoom the user currently uses
vec3_t m_mapOrigin; // origin where user rotates around vec3_t m_mapOrigin; // origin where user rotates around
cvar_t * m_drawnames; cvar_t *m_drawnames;
cvar_t * m_drawcone; cvar_t *m_drawcone;
cvar_t * m_drawstatus; cvar_t *m_drawstatus;
cvar_t * m_autoDirector; cvar_t *m_autoDirector;
cvar_t * m_pip; cvar_t *m_pip;
qboolean m_chatEnabled; qboolean m_chatEnabled;
vec3_t m_cameraOrigin; // a help camera vec3_t m_cameraOrigin; // a help camera
vec3_t m_cameraAngles; // and it's angles vec3_t m_cameraAngles; // and it's angles
private: private:
vec3_t m_vPlayerPos[MAX_PLAYERS]; vec3_t m_vPlayerPos[MAX_PLAYERS];
HSPRITE m_hsprPlayerBlue; HSPRITE m_hsprPlayerBlue;
@ -121,12 +116,11 @@ private:
wrect_t m_crosshairRect; wrect_t m_crosshairRect;
struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame struct model_s *m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame
float m_flNextObserverInput; float m_flNextObserverInput;
float m_zoomDelta; float m_zoomDelta;
float m_moveDelta; float m_moveDelta;
int m_lastPrimaryObject; int m_lastPrimaryObject;
int m_lastSecondaryObject; int m_lastSecondaryObject;
}; };
#endif // SPECTATOR_H #endif // SPECTATOR_H

View File

@ -29,10 +29,10 @@ extern float v_idlescale;
float in_fov; float in_fov;
extern void HUD_SetCmdBits( int bits ); extern void HUD_SetCmdBits( int bits );
int CHud::UpdateClientData(client_data_t *cdata, float time) int CHud::UpdateClientData( client_data_t *cdata, float time )
{ {
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t)); memcpy( m_vecOrigin, cdata->origin, sizeof(vec3_t) );
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t)); memcpy( m_vecAngles, cdata->viewangles, sizeof(vec3_t) );
m_iKeyBits = CL_ButtonBits( 0 ); m_iKeyBits = CL_ButtonBits( 0 );
m_iWeaponBits = cdata->iWeaponBits; m_iWeaponBits = cdata->iWeaponBits;
@ -50,5 +50,3 @@ int CHud::UpdateClientData(client_data_t *cdata, float time)
// return 1 if in anything in the client_data struct has been changed, 0 otherwise // return 1 if in anything in the client_data struct has been changed, 0 otherwise
return 1; return 1;
} }

View File

@ -15,8 +15,7 @@
#include "camera.h" #include "camera.h"
#include "in_defs.h" #include "in_defs.h"
float CL_KeyState( kbutton_t *key );
float CL_KeyState (kbutton_t *key);
extern "C" extern "C"
{ {
@ -66,11 +65,10 @@ cvar_t *c_mindistance;
// pitch, yaw, dist // pitch, yaw, dist
vec3_t cam_ofs; vec3_t cam_ofs;
// In third person // In third person
int cam_thirdperson; int cam_thirdperson;
int cam_mousemove; //true if we are moving the cam with the mouse, False if not int cam_mousemove; //true if we are moving the cam with the mouse, False if not
int iMouseInUse=0; int iMouseInUse = 0;
int cam_distancemove; int cam_distancemove;
extern int mouse_x, mouse_y; //used to determine what the current x and y values are extern int mouse_x, mouse_y; //used to determine what the current x and y values are
int cam_old_mouse_x, cam_old_mouse_y; //holds the last ticks mouse movement int cam_old_mouse_x, cam_old_mouse_y; //holds the last ticks mouse movement
@ -87,7 +85,6 @@ void CAM_ToFirstPerson(void);
void CAM_StartDistance(void); void CAM_StartDistance(void);
void CAM_EndDistance(void); void CAM_EndDistance(void);
//-------------------------------------------------- Local Functions //-------------------------------------------------- Local Functions
float MoveToward( float cur, float goal, float maxspeed ) float MoveToward( float cur, float goal, float maxspeed )
@ -118,7 +115,6 @@ float MoveToward( float cur, float goal, float maxspeed )
} }
} }
// bring cur back into range // bring cur back into range
if( cur < 0 ) if( cur < 0 )
cur += 360.0; cur += 360.0;
@ -128,7 +124,6 @@ float MoveToward( float cur, float goal, float maxspeed )
return cur; return cur;
} }
//-------------------------------------------------- Gobal Functions //-------------------------------------------------- Gobal Functions
typedef struct typedef struct
@ -143,7 +138,7 @@ typedef struct
qboolean monsterclip; qboolean monsterclip;
} moveclip_t; } moveclip_t;
extern trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); extern trace_t SV_ClipMoveToEntity( edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end );
void DLLEXPORT CAM_Think( void ) void DLLEXPORT CAM_Think( void )
{ {
@ -158,16 +153,14 @@ void DLLEXPORT CAM_Think( void )
#endif #endif
vec3_t viewangles; vec3_t viewangles;
switch( (int) cam_command->value ) switch( (int)cam_command->value )
{ {
case CAM_COMMAND_TOTHIRDPERSON: case CAM_COMMAND_TOTHIRDPERSON:
CAM_ToThirdPerson(); CAM_ToThirdPerson();
break; break;
case CAM_COMMAND_TOFIRSTPERSON: case CAM_COMMAND_TOFIRSTPERSON:
CAM_ToFirstPerson(); CAM_ToFirstPerson();
break; break;
case CAM_COMMAND_NONE: case CAM_COMMAND_NONE:
default: default:
break; break;
@ -175,113 +168,108 @@ void DLLEXPORT CAM_Think( void )
if( !cam_thirdperson ) if( !cam_thirdperson )
return; return;
#ifdef LATER #ifdef LATER
if ( cam_contain->value ) if( cam_contain->value )
{ {
gEngfuncs.GetClientOrigin( origin ); gEngfuncs.GetClientOrigin( origin );
ext[0] = ext[1] = ext[2] = 0.0; ext[0] = ext[1] = ext[2] = 0.0;
} }
#endif #endif
camAngles[PITCH] = cam_idealpitch->value;
camAngles[ PITCH ] = cam_idealpitch->value; camAngles[YAW] = cam_idealyaw->value;
camAngles[ YAW ] = cam_idealyaw->value;
dist = cam_idealdist->value; dist = cam_idealdist->value;
// //
//movement of the camera with the mouse //movement of the camera with the mouse
// //
if (cam_mousemove) if( cam_mousemove )
{ {
//get windows cursor position //get windows cursor position
GetCursorPos (&cam_mouse); GetCursorPos( &cam_mouse );
//check for X delta values and adjust accordingly //check for X delta values and adjust accordingly
//eventually adjust YAW based on amount of movement //eventually adjust YAW based on amount of movement
//don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera //don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera
if (!cam_distancemove) if( !cam_distancemove )
{ {
//keep the camera within certain limits around the player (ie avoid certain bad viewing angles) //keep the camera within certain limits around the player (ie avoid certain bad viewing angles)
if (cam_mouse.x>gEngfuncs.GetWindowCenterX()) if( cam_mouse.x>gEngfuncs.GetWindowCenterX() )
{ {
//if ((camAngles[YAW]>=225.0)||(camAngles[YAW]<135.0)) //if( ( camAngles[YAW] >= 225.0 ) || ( camAngles[YAW] < 135.0 ) )
if (camAngles[YAW]<c_maxyaw->value) if( camAngles[YAW] < c_maxyaw->value )
{ {
camAngles[ YAW ] += (CAM_ANGLE_MOVE)*((cam_mouse.x-gEngfuncs.GetWindowCenterX())/2); camAngles[YAW] += CAM_ANGLE_MOVE * ( ( cam_mouse.x - gEngfuncs.GetWindowCenterX() ) / 2 );
} }
if (camAngles[YAW]>c_maxyaw->value) if( camAngles[YAW] > c_maxyaw->value )
{ {
camAngles[YAW] = c_maxyaw->value;
camAngles[YAW]=c_maxyaw->value;
} }
} }
else if (cam_mouse.x<gEngfuncs.GetWindowCenterX()) else if( cam_mouse.x<gEngfuncs.GetWindowCenterX() )
{ {
//if ((camAngles[YAW]<=135.0)||(camAngles[YAW]>225.0)) //if( ( camAngles[YAW] <= 135.0 ) || ( camAngles[YAW] > 225.0 ) )
if (camAngles[YAW]>c_minyaw->value) if( camAngles[YAW] > c_minyaw->value )
{ {
camAngles[ YAW ] -= (CAM_ANGLE_MOVE)* ((gEngfuncs.GetWindowCenterX()-cam_mouse.x)/2); camAngles[YAW] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterX() - cam_mouse.x ) / 2 );
} }
if (camAngles[YAW]<c_minyaw->value) if( camAngles[YAW] < c_minyaw->value )
{ {
camAngles[YAW]=c_minyaw->value; camAngles[YAW] = c_minyaw->value;
} }
} }
//check for y delta values and adjust accordingly //check for y delta values and adjust accordingly
//eventually adjust PITCH based on amount of movement //eventually adjust PITCH based on amount of movement
//also make sure camera is within bounds //also make sure camera is within bounds
if (cam_mouse.y>gEngfuncs.GetWindowCenterY()) if( cam_mouse.y>gEngfuncs.GetWindowCenterY() )
{ {
if(camAngles[PITCH]<c_maxpitch->value) if( camAngles[PITCH] < c_maxpitch->value )
{ {
camAngles[PITCH] +=(CAM_ANGLE_MOVE)* ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2); camAngles[PITCH] += CAM_ANGLE_MOVE * ( ( cam_mouse.y - gEngfuncs.GetWindowCenterY() ) / 2 );
} }
if (camAngles[PITCH]>c_maxpitch->value) if( camAngles[PITCH] > c_maxpitch->value )
{ {
camAngles[PITCH]=c_maxpitch->value; camAngles[PITCH] = c_maxpitch->value;
} }
} }
else if (cam_mouse.y<gEngfuncs.GetWindowCenterY()) else if( cam_mouse.y<gEngfuncs.GetWindowCenterY() )
{ {
if (camAngles[PITCH]>c_minpitch->value) if( camAngles[PITCH] > c_minpitch->value )
{ {
camAngles[PITCH] -= (CAM_ANGLE_MOVE)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2); camAngles[PITCH] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterY() - cam_mouse.y ) / 2 );
} }
if (camAngles[PITCH]<c_minpitch->value) if( camAngles[PITCH] < c_minpitch->value )
{ {
camAngles[PITCH]=c_minpitch->value; camAngles[PITCH] = c_minpitch->value;
} }
} }
//set old mouse coordinates to current mouse coordinates //set old mouse coordinates to current mouse coordinates
//since we are done with the mouse //since we are done with the mouse
if( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
{ {
cam_old_mouse_x=cam_mouse.x*flSensitivity; cam_old_mouse_x = cam_mouse.x * flSensitivity;
cam_old_mouse_y=cam_mouse.y*flSensitivity; cam_old_mouse_y = cam_mouse.y * flSensitivity;
} }
else else
{ {
cam_old_mouse_x=cam_mouse.x; cam_old_mouse_x = cam_mouse.x;
cam_old_mouse_y=cam_mouse.y; cam_old_mouse_y = cam_mouse.y;
} }
SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY()); SetCursorPos( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() );
} }
} }
//Nathan code here //Nathan code here
if( CL_KeyState( &cam_pitchup ) ) if( CL_KeyState( &cam_pitchup ) )
camAngles[ PITCH ] += CAM_ANGLE_DELTA; camAngles[PITCH] += CAM_ANGLE_DELTA;
else if( CL_KeyState( &cam_pitchdown ) ) else if( CL_KeyState( &cam_pitchdown ) )
camAngles[ PITCH ] -= CAM_ANGLE_DELTA; camAngles[PITCH] -= CAM_ANGLE_DELTA;
if( CL_KeyState( &cam_yawleft ) ) if( CL_KeyState( &cam_yawleft ) )
camAngles[ YAW ] -= CAM_ANGLE_DELTA; camAngles[YAW] -= CAM_ANGLE_DELTA;
else if( CL_KeyState( &cam_yawright ) ) else if( CL_KeyState( &cam_yawright ) )
camAngles[ YAW ] += CAM_ANGLE_DELTA; camAngles[YAW] += CAM_ANGLE_DELTA;
if( CL_KeyState( &cam_in ) ) if( CL_KeyState( &cam_in ) )
{ {
@ -289,44 +277,43 @@ void DLLEXPORT CAM_Think( void )
if( dist < CAM_MIN_DIST ) if( dist < CAM_MIN_DIST )
{ {
// If we go back into first person, reset the angle // If we go back into first person, reset the angle
camAngles[ PITCH ] = 0; camAngles[PITCH] = 0;
camAngles[ YAW ] = 0; camAngles[YAW] = 0;
dist = CAM_MIN_DIST; dist = CAM_MIN_DIST;
} }
} }
else if( CL_KeyState( &cam_out ) ) else if( CL_KeyState( &cam_out ) )
dist += CAM_DIST_DELTA; dist += CAM_DIST_DELTA;
if (cam_distancemove) if( cam_distancemove )
{ {
if (cam_mouse.y>gEngfuncs.GetWindowCenterY()) if( cam_mouse.y > gEngfuncs.GetWindowCenterY() )
{ {
if(dist<c_maxdistance->value) if( dist < c_maxdistance->value )
{ {
dist +=CAM_DIST_DELTA * ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2); dist += CAM_DIST_DELTA * ( ( cam_mouse.y - gEngfuncs.GetWindowCenterY() ) / 2);
} }
if (dist>c_maxdistance->value) if( dist > c_maxdistance->value )
{ {
dist=c_maxdistance->value; dist = c_maxdistance->value;
} }
} }
else if (cam_mouse.y<gEngfuncs.GetWindowCenterY()) else if( cam_mouse.y < gEngfuncs.GetWindowCenterY() )
{ {
if (dist>c_mindistance->value) if( dist > c_mindistance->value )
{ {
dist -= (CAM_DIST_DELTA)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2); dist -= CAM_DIST_DELTA * ( ( gEngfuncs.GetWindowCenterY() - cam_mouse.y ) / 2 );
} }
if (dist<c_mindistance->value) if ( dist < c_mindistance->value )
{ {
dist=c_mindistance->value; dist = c_mindistance->value;
} }
} }
//set old mouse coordinates to current mouse coordinates //set old mouse coordinates to current mouse coordinates
//since we are done with the mouse //since we are done with the mouse
cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity(); cam_old_mouse_x = cam_mouse.x * gHUD.GetSensitivity();
cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity(); cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity();
SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY()); SetCursorPos( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() );
} }
#ifdef LATER #ifdef LATER
if( cam_contain->value ) if( cam_contain->value )
@ -334,17 +321,17 @@ void DLLEXPORT CAM_Think( void )
// check new ideal // check new ideal
VectorCopy( origin, pnt ); VectorCopy( origin, pnt );
AngleVectors( camAngles, camForward, camRight, camUp ); AngleVectors( camAngles, camForward, camRight, camUp );
for (i=0 ; i<3 ; i++) for( i = 0; i < 3; i++ )
pnt[i] += -dist*camForward[i]; pnt[i] += -dist * camForward[i];
// check line from r_refdef.vieworg to pnt // check line from r_refdef.vieworg to pnt
memset ( &clip, 0, sizeof ( moveclip_t ) ); memset( &clip, 0, sizeof(moveclip_t) );
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt ); clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
if( clip.trace.fraction == 1.0 ) if( clip.trace.fraction == 1.0 )
{ {
// update ideal // update ideal
cam_idealpitch->value = camAngles[ PITCH ]; cam_idealpitch->value = camAngles[PITCH];
cam_idealyaw->value = camAngles[ YAW ]; cam_idealyaw->value = camAngles[YAW];
cam_idealdist->value = dist; cam_idealdist->value = dist;
} }
} }
@ -352,8 +339,8 @@ void DLLEXPORT CAM_Think( void )
#endif #endif
{ {
// update ideal // update ideal
cam_idealpitch->value = camAngles[ PITCH ]; cam_idealpitch->value = camAngles[PITCH];
cam_idealyaw->value = camAngles[ YAW ]; cam_idealyaw->value = camAngles[YAW];
cam_idealdist->value = dist; cam_idealdist->value = dist;
} }
@ -364,91 +351,136 @@ void DLLEXPORT CAM_Think( void )
if( cam_snapto->value ) if( cam_snapto->value )
{ {
camAngles[ YAW ] = cam_idealyaw->value + viewangles[ YAW ]; camAngles[YAW] = cam_idealyaw->value + viewangles[YAW];
camAngles[ PITCH ] = cam_idealpitch->value + viewangles[ PITCH ]; camAngles[PITCH] = cam_idealpitch->value + viewangles[PITCH];
camAngles[ 2 ] = cam_idealdist->value; camAngles[2] = cam_idealdist->value;
} }
else else
{ {
if( camAngles[ YAW ] - viewangles[ YAW ] != cam_idealyaw->value ) if( camAngles[YAW] - viewangles[YAW] != cam_idealyaw->value )
camAngles[ YAW ] = MoveToward( camAngles[ YAW ], cam_idealyaw->value + viewangles[ YAW ], CAM_ANGLE_SPEED ); camAngles[YAW] = MoveToward( camAngles[YAW], cam_idealyaw->value + viewangles[YAW], CAM_ANGLE_SPEED );
if( camAngles[ PITCH ] - viewangles[ PITCH ] != cam_idealpitch->value ) if( camAngles[PITCH] - viewangles[PITCH] != cam_idealpitch->value )
camAngles[ PITCH ] = MoveToward( camAngles[ PITCH ], cam_idealpitch->value + viewangles[ PITCH ], CAM_ANGLE_SPEED ); camAngles[PITCH] = MoveToward( camAngles[PITCH], cam_idealpitch->value + viewangles[PITCH], CAM_ANGLE_SPEED );
if( fabs( camAngles[ 2 ] - cam_idealdist->value ) < 2.0 ) if( fabs( camAngles[2] - cam_idealdist->value ) < 2.0 )
camAngles[ 2 ] = cam_idealdist->value; camAngles[2] = cam_idealdist->value;
else else
camAngles[ 2 ] += ( cam_idealdist->value - camAngles[ 2 ] ) / 4.0; camAngles[2] += ( cam_idealdist->value - camAngles[2] ) / 4.0;
} }
#ifdef LATER #ifdef LATER
if( cam_contain->value ) if( cam_contain->value )
{ {
// Test new position // Test new position
dist = camAngles[ ROLL ]; dist = camAngles[ROLL];
camAngles[ ROLL ] = 0; camAngles[ROLL] = 0;
VectorCopy( origin, pnt ); VectorCopy( origin, pnt );
AngleVectors( camAngles, camForward, camRight, camUp ); AngleVectors( camAngles, camForward, camRight, camUp );
for (i=0 ; i<3 ; i++) for( i = 0; i < 3; i++ )
pnt[i] += -dist*camForward[i]; pnt[i] += -dist * camForward[i];
// check line from r_refdef.vieworg to pnt // check line from r_refdef.vieworg to pnt
memset ( &clip, 0, sizeof ( moveclip_t ) ); memset( &clip, 0, sizeof(moveclip_t) );
ext[0] = ext[1] = ext[2] = 0.0; ext[0] = ext[1] = ext[2] = 0.0;
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt ); clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
if( clip.trace.fraction != 1.0 ) if( clip.trace.fraction != 1.0 )
return; return;
} }
#endif #endif
cam_ofs[ 0 ] = camAngles[ 0 ]; cam_ofs[0] = camAngles[0];
cam_ofs[ 1 ] = camAngles[ 1 ]; cam_ofs[1] = camAngles[1];
cam_ofs[ 2 ] = dist; cam_ofs[2] = dist;
} }
extern void KeyDown (kbutton_t *b); // HACK extern void KeyDown( kbutton_t *b ); // HACK
extern void KeyUp (kbutton_t *b); // HACK extern void KeyUp( kbutton_t *b ); // HACK
void CAM_PitchUpDown(void) { KeyDown( &cam_pitchup ); } void CAM_PitchUpDown( void )
void CAM_PitchUpUp(void) { KeyUp( &cam_pitchup ); } {
void CAM_PitchDownDown(void) { KeyDown( &cam_pitchdown ); } KeyDown( &cam_pitchup );
void CAM_PitchDownUp(void) { KeyUp( &cam_pitchdown ); } }
void CAM_YawLeftDown(void) { KeyDown( &cam_yawleft ); }
void CAM_YawLeftUp(void) { KeyUp( &cam_yawleft ); }
void CAM_YawRightDown(void) { KeyDown( &cam_yawright ); }
void CAM_YawRightUp(void) { KeyUp( &cam_yawright ); }
void CAM_InDown(void) { KeyDown( &cam_in ); }
void CAM_InUp(void) { KeyUp( &cam_in ); }
void CAM_OutDown(void) { KeyDown( &cam_out ); }
void CAM_OutUp(void) { KeyUp( &cam_out ); }
void CAM_ToThirdPerson(void) void CAM_PitchUpUp( void )
{
KeyUp( &cam_pitchup );
}
void CAM_PitchDownDown( void )
{
KeyDown( &cam_pitchdown );
}
void CAM_PitchDownUp( void )
{
KeyUp( &cam_pitchdown );
}
void CAM_YawLeftDown( void )
{
KeyDown( &cam_yawleft );
}
void CAM_YawLeftUp( void )
{
KeyUp( &cam_yawleft );
}
void CAM_YawRightDown( void )
{
KeyDown( &cam_yawright );
}
void CAM_YawRightUp( void )
{
KeyUp( &cam_yawright );
}
void CAM_InDown( void )
{
KeyDown( &cam_in );
}
void CAM_InUp( void )
{
KeyUp( &cam_in );
}
void CAM_OutDown( void )
{
KeyDown( &cam_out );
}
void CAM_OutUp( void )
{
KeyUp( &cam_out );
}
void CAM_ToThirdPerson( void )
{ {
vec3_t viewangles; vec3_t viewangles;
#if !defined( _DEBUG ) #if !defined( _DEBUG )
if ( gEngfuncs.GetMaxClients() > 1 ) if( gEngfuncs.GetMaxClients() > 1 )
{ {
// no thirdperson in multiplayer. // no thirdperson in multiplayer.
return; return;
} }
#endif #endif
gEngfuncs.GetViewAngles( (float *)viewangles ); gEngfuncs.GetViewAngles( (float *)viewangles );
if( !cam_thirdperson ) if( !cam_thirdperson )
{ {
cam_thirdperson = 1; cam_thirdperson = 1;
cam_ofs[ YAW ] = viewangles[ YAW ]; cam_ofs[YAW] = viewangles[YAW];
cam_ofs[ PITCH ] = viewangles[ PITCH ]; cam_ofs[PITCH] = viewangles[PITCH];
cam_ofs[ 2 ] = CAM_MIN_DIST; cam_ofs[2] = CAM_MIN_DIST;
} }
gEngfuncs.Cvar_SetValue( "cam_command", 0 ); gEngfuncs.Cvar_SetValue( "cam_command", 0 );
} }
void CAM_ToFirstPerson(void) void CAM_ToFirstPerson( void )
{ {
cam_thirdperson = 0; cam_thirdperson = 0;
@ -482,19 +514,19 @@ void CAM_Init( void )
gEngfuncs.pfnAddCommand( "-camdistance", CAM_EndDistance ); gEngfuncs.pfnAddCommand( "-camdistance", CAM_EndDistance );
gEngfuncs.pfnAddCommand( "snapto", CAM_ToggleSnapto ); gEngfuncs.pfnAddCommand( "snapto", CAM_ToggleSnapto );
cam_command = gEngfuncs.pfnRegisterVariable ( "cam_command", "0", 0 ); // tells camera to go to thirdperson cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "0", 0 ); // tells camera to go to thirdperson
cam_snapto = gEngfuncs.pfnRegisterVariable ( "cam_snapto", "0", 0 ); // snap to thirdperson view cam_snapto = gEngfuncs.pfnRegisterVariable( "cam_snapto", "0", 0 ); // snap to thirdperson view
cam_idealyaw = gEngfuncs.pfnRegisterVariable ( "cam_idealyaw", "90", 0 ); // thirdperson yaw cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "90", 0 ); // thirdperson yaw
cam_idealpitch = gEngfuncs.pfnRegisterVariable ( "cam_idealpitch", "0", 0 ); // thirperson pitch cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "0", 0 ); // thirperson pitch
cam_idealdist = gEngfuncs.pfnRegisterVariable ( "cam_idealdist", "64", 0 ); // thirdperson distance cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "64", 0 ); // thirdperson distance
cam_contain = gEngfuncs.pfnRegisterVariable ( "cam_contain", "0", 0 ); // contain camera to world cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "0", 0 ); // contain camera to world
c_maxpitch = gEngfuncs.pfnRegisterVariable ( "c_maxpitch", "90.0", 0 ); c_maxpitch = gEngfuncs.pfnRegisterVariable( "c_maxpitch", "90.0", 0 );
c_minpitch = gEngfuncs.pfnRegisterVariable ( "c_minpitch", "0.0", 0 ); c_minpitch = gEngfuncs.pfnRegisterVariable( "c_minpitch", "0.0", 0 );
c_maxyaw = gEngfuncs.pfnRegisterVariable ( "c_maxyaw", "135.0", 0 ); c_maxyaw = gEngfuncs.pfnRegisterVariable( "c_maxyaw", "135.0", 0 );
c_minyaw = gEngfuncs.pfnRegisterVariable ( "c_minyaw", "-135.0", 0 ); c_minyaw = gEngfuncs.pfnRegisterVariable( "c_minyaw", "-135.0", 0 );
c_maxdistance = gEngfuncs.pfnRegisterVariable ( "c_maxdistance", "200.0", 0 ); c_maxdistance = gEngfuncs.pfnRegisterVariable( "c_maxdistance", "200.0", 0 );
c_mindistance = gEngfuncs.pfnRegisterVariable ( "c_mindistance", "30.0", 0 ); c_mindistance = gEngfuncs.pfnRegisterVariable( "c_mindistance", "30.0", 0 );
} }
void CAM_ClearStates( void ) void CAM_ClearStates( void )
@ -517,101 +549,100 @@ void CAM_ClearStates( void )
cam_snapto->value = 0; cam_snapto->value = 0;
cam_distancemove = 0; cam_distancemove = 0;
cam_ofs[ 0 ] = 0.0; cam_ofs[0] = 0.0;
cam_ofs[ 1 ] = 0.0; cam_ofs[1] = 0.0;
cam_ofs[ 2 ] = CAM_MIN_DIST; cam_ofs[2] = CAM_MIN_DIST;
cam_idealpitch->value = viewangles[ PITCH ]; cam_idealpitch->value = viewangles[PITCH];
cam_idealyaw->value = viewangles[ YAW ]; cam_idealyaw->value = viewangles[YAW];
cam_idealdist->value = CAM_MIN_DIST; cam_idealdist->value = CAM_MIN_DIST;
} }
void CAM_StartMouseMove(void) void CAM_StartMouseMove( void )
{ {
float flSensitivity; float flSensitivity;
//only move the cam with mouse if we are in third person. //only move the cam with mouse if we are in third person.
if (cam_thirdperson) if( cam_thirdperson )
{ {
//set appropriate flags and initialize the old mouse position //set appropriate flags and initialize the old mouse position
//variables for mouse camera movement //variables for mouse camera movement
if (!cam_mousemove) if( !cam_mousemove )
{ {
cam_mousemove=1; cam_mousemove = 1;
iMouseInUse=1; iMouseInUse = 1;
GetCursorPos (&cam_mouse); GetCursorPos( &cam_mouse );
if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 ) if( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
{ {
cam_old_mouse_x=cam_mouse.x*flSensitivity; cam_old_mouse_x = cam_mouse.x * flSensitivity;
cam_old_mouse_y=cam_mouse.y*flSensitivity; cam_old_mouse_y = cam_mouse.y * flSensitivity;
} }
else else
{ {
cam_old_mouse_x=cam_mouse.x; cam_old_mouse_x = cam_mouse.x;
cam_old_mouse_y=cam_mouse.y; cam_old_mouse_y = cam_mouse.y;
} }
} }
} }
//we are not in 3rd person view..therefore do not allow camera movement //we are not in 3rd person view..therefore do not allow camera movement
else else
{ {
cam_mousemove=0; cam_mousemove = 0;
iMouseInUse=0; iMouseInUse = 0;
} }
} }
//the key has been released for camera movement //the key has been released for camera movement
//tell the engine that mouse camera movement is off //tell the engine that mouse camera movement is off
void CAM_EndMouseMove(void) void CAM_EndMouseMove( void )
{ {
cam_mousemove=0; cam_mousemove = 0;
iMouseInUse=0; iMouseInUse = 0;
} }
//---------------------------------------------------------- //----------------------------------------------------------
//routines to start the process of moving the cam in or out //routines to start the process of moving the cam in or out
//using the mouse //using the mouse
//---------------------------------------------------------- //----------------------------------------------------------
void CAM_StartDistance(void) void CAM_StartDistance( void )
{ {
//only move the cam with mouse if we are in third person. //only move the cam with mouse if we are in third person.
if (cam_thirdperson) if( cam_thirdperson )
{ {
//set appropriate flags and initialize the old mouse position //set appropriate flags and initialize the old mouse position
//variables for mouse camera movement //variables for mouse camera movement
if (!cam_distancemove) if( !cam_distancemove )
{ {
cam_distancemove=1; cam_distancemove = 1;
cam_mousemove=1; cam_mousemove = 1;
iMouseInUse=1; iMouseInUse = 1;
GetCursorPos (&cam_mouse); GetCursorPos( &cam_mouse );
cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity(); cam_old_mouse_x = cam_mouse.x * gHUD.GetSensitivity();
cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity(); cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity();
} }
} }
//we are not in 3rd person view..therefore do not allow camera movement //we are not in 3rd person view..therefore do not allow camera movement
else else
{ {
cam_distancemove=0; cam_distancemove = 0;
cam_mousemove=0; cam_mousemove = 0;
iMouseInUse=0; iMouseInUse = 0;
} }
} }
//the key has been released for camera movement //the key has been released for camera movement
//tell the engine that mouse camera movement is off //tell the engine that mouse camera movement is off
void CAM_EndDistance(void) void CAM_EndDistance( void )
{ {
cam_distancemove=0; cam_distancemove = 0;
cam_mousemove=0; cam_mousemove = 0;
iMouseInUse=0; iMouseInUse = 0;
} }
int DLLEXPORT CL_IsThirdPerson( void ) int DLLEXPORT CL_IsThirdPerson( void )
{ {
return (cam_thirdperson ? 1 : 0) || (g_iUser1 && (g_iUser2 == gEngfuncs.GetLocalPlayer()->index) ); return ( cam_thirdperson ? 1 : 0 ) || ( g_iUser1 && ( g_iUser2 == gEngfuncs.GetLocalPlayer()->index ) );
} }
void DLLEXPORT CL_CameraOffset( float *ofs ) void DLLEXPORT CL_CameraOffset( float *ofs )

View File

@ -21,12 +21,12 @@
#include <windows.h> #include <windows.h>
#undef HSPRITE #undef HSPRITE
#else #else
typedef struct point_s{ typedef struct point_s
{
int x; int x;
int y; int y;
} POINT; } POINT;
#define GetCursorPos(x) #define GetCursorPos(x)
#define SetCursorPos(x,y) #define SetCursorPos(x,y)
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -93,47 +93,46 @@ void IN_ToggleButtons( float forwardmove, float sidemove )
} }
} }
if ( forwardmove > 0.7 && !( moveflags & F )) if( forwardmove > 0.7 && !( moveflags & F ) )
{ {
moveflags |= F; moveflags |= F;
in_forward.state |= BUTTON_DOWN; in_forward.state |= BUTTON_DOWN;
} }
if ( forwardmove < 0.7 && ( moveflags & F )) if( forwardmove < 0.7 && ( moveflags & F ) )
{ {
moveflags &= ~F; moveflags &= ~F;
in_forward.state &= ~BUTTON_DOWN; in_forward.state &= ~BUTTON_DOWN;
} }
if ( forwardmove < -0.7 && !( moveflags & B )) if( forwardmove < -0.7 && !( moveflags & B ) )
{ {
moveflags |= B; moveflags |= B;
in_back.state |= BUTTON_DOWN; in_back.state |= BUTTON_DOWN;
} }
if ( forwardmove > -0.7 && ( moveflags & B )) if( forwardmove > -0.7 && ( moveflags & B ) )
{ {
moveflags &= ~B; moveflags &= ~B;
in_back.state &= ~BUTTON_DOWN; in_back.state &= ~BUTTON_DOWN;
} }
if ( sidemove > 0.9 && !( moveflags & R )) if( sidemove > 0.9 && !( moveflags & R ) )
{ {
moveflags |= R; moveflags |= R;
in_moveright.state |= BUTTON_DOWN; in_moveright.state |= BUTTON_DOWN;
} }
if ( sidemove < 0.9 && ( moveflags & R )) if( sidemove < 0.9 && ( moveflags & R ) )
{ {
moveflags &= ~R; moveflags &= ~R;
in_moveright.state &= ~BUTTON_DOWN; in_moveright.state &= ~BUTTON_DOWN;
} }
if ( sidemove < -0.9 && !( moveflags & L )) if( sidemove < -0.9 && !( moveflags & L ) )
{ {
moveflags |= L; moveflags |= L;
in_moveleft.state |= BUTTON_DOWN; in_moveleft.state |= BUTTON_DOWN;
} }
if ( sidemove > -0.9 && ( moveflags & L )) if( sidemove > -0.9 && ( moveflags & L ) )
{ {
moveflags &= ~L; moveflags &= ~L;
in_moveleft.state &= ~BUTTON_DOWN; in_moveleft.state &= ~BUTTON_DOWN;
} }
} }
void IN_ClientMoveEvent( float forwardmove, float sidemove ) void IN_ClientMoveEvent( float forwardmove, float sidemove )
@ -150,6 +149,7 @@ void IN_ClientLookEvent( float relyaw, float relpitch )
rel_yaw += relyaw; rel_yaw += relyaw;
rel_pitch += relpitch; rel_pitch += relpitch;
} }
// Rotate camera and add move values to usercmd // Rotate camera and add move values to usercmd
void IN_Move( float frametime, usercmd_t *cmd ) void IN_Move( float frametime, usercmd_t *cmd )
{ {
@ -198,14 +198,14 @@ void IN_Move( float frametime, usercmd_t *cmd )
viewangles[YAW] -= ac_sidemove * 5; viewangles[YAW] -= ac_sidemove * 5;
ac_sidemove = 0; ac_sidemove = 0;
} }
if(gHUD.m_MOTD.m_bShow) if( gHUD.m_MOTD.m_bShow )
gHUD.m_MOTD.scroll += rel_pitch; gHUD.m_MOTD.scroll += rel_pitch;
else else
viewangles[PITCH] += rel_pitch; viewangles[PITCH] += rel_pitch;
if (viewangles[PITCH] > cl_pitchdown->value) if( viewangles[PITCH] > cl_pitchdown->value )
viewangles[PITCH] = cl_pitchdown->value; viewangles[PITCH] = cl_pitchdown->value;
if (viewangles[PITCH] < -cl_pitchup->value) if( viewangles[PITCH] < -cl_pitchup->value )
viewangles[PITCH] = -cl_pitchup->value; viewangles[PITCH] = -cl_pitchup->value;
// HACKHACK: change viewangles directly in viewcode, // HACKHACK: change viewangles directly in viewcode,
@ -219,9 +219,12 @@ void IN_Move( float frametime, usercmd_t *cmd )
if( ac_movecount ) if( ac_movecount )
{ {
IN_ToggleButtons( ac_forwardmove / ac_movecount, ac_sidemove / ac_movecount ); IN_ToggleButtons( ac_forwardmove / ac_movecount, ac_sidemove / ac_movecount );
if( ac_forwardmove ) cmd->forwardmove = ac_forwardmove * cl_forwardspeed->value / ac_movecount;
if( ac_sidemove ) cmd->sidemove = ac_sidemove * cl_sidespeed->value / ac_movecount; if( ac_forwardmove )
if( (in_speed.state & 1) && ( ac_sidemove || ac_forwardmove ) ) cmd->forwardmove = ac_forwardmove * cl_forwardspeed->value / ac_movecount;
if( ac_sidemove )
cmd->sidemove = ac_sidemove * cl_sidespeed->value / ac_movecount;
if( ( in_speed.state & 1 ) && ( ac_sidemove || ac_forwardmove ) )
{ {
cmd->forwardmove *= cl_movespeedkey->value; cmd->forwardmove *= cl_movespeedkey->value;
cmd->sidemove *= cl_movespeedkey->value; cmd->sidemove *= cl_movespeedkey->value;
@ -238,12 +241,12 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate )
// perform button actions // perform button actions
for( int i = 0; i < 5; i++ ) for( int i = 0; i < 5; i++ )
{ {
if(( mstate & (1 << i)) && !( mouse_oldbuttonstate & (1 << i))) if( ( mstate & ( 1 << i ) ) && !( mouse_oldbuttonstate & ( 1 << i ) ) )
{ {
gEngfuncs.Key_Event( K_MOUSE1 + i, 1 ); gEngfuncs.Key_Event( K_MOUSE1 + i, 1 );
} }
if( !( mstate & (1 << i)) && ( mouse_oldbuttonstate & (1 << i))) if( !( mstate & ( 1 << i ) ) && ( mouse_oldbuttonstate & ( 1 << i ) ) )
{ {
gEngfuncs.Key_Event( K_MOUSE1 + i, 0 ); gEngfuncs.Key_Event( K_MOUSE1 + i, 0 );
} }
@ -254,39 +257,40 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate )
// Stubs // Stubs
extern "C" void DLLEXPORT IN_ClearStates ( void ) extern "C" void DLLEXPORT IN_ClearStates( void )
{ {
//gEngfuncs.Con_Printf("IN_ClearStates\n"); //gEngfuncs.Con_Printf( "IN_ClearStates\n" );
} }
extern "C" void DLLEXPORT IN_ActivateMouse ( void ) extern "C" void DLLEXPORT IN_ActivateMouse( void )
{ {
//gEngfuncs.Con_Printf("IN_ActivateMouse\n"); //gEngfuncs.Con_Printf( "IN_ActivateMouse\n" );
} }
extern "C" void DLLEXPORT IN_DeactivateMouse ( void ) extern "C" void DLLEXPORT IN_DeactivateMouse( void )
{ {
//gEngfuncs.Con_Printf("IN_DeactivateMouse\n"); //gEngfuncs.Con_Printf( "IN_DeactivateMouse\n" );
} }
extern "C" void DLLEXPORT IN_Accumulate ( void ) extern "C" void DLLEXPORT IN_Accumulate( void )
{ {
//gEngfuncs.Con_Printf("IN_Accumulate\n"); //gEngfuncs.Con_Printf( "IN_Accumulate\n" );
} }
void IN_Commands ( void ) void IN_Commands( void )
{ {
//gEngfuncs.Con_Printf("IN_Commands\n"); //gEngfuncs.Con_Printf( "IN_Commands\n" );
} }
void IN_Shutdown ( void ) void IN_Shutdown( void )
{ {
} }
// Register cvars and reset data // Register cvars and reset data
void IN_Init( void ) void IN_Init( void )
{ {
sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity", "3", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE );
in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick", "0", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE );
cl_laddermode = gEngfuncs.pfnRegisterVariable ( "cl_laddermode", "2", FCVAR_ARCHIVE ); cl_laddermode = gEngfuncs.pfnRegisterVariable( "cl_laddermode", "2", FCVAR_ARCHIVE );
ac_forwardmove = ac_sidemove = rel_yaw = rel_pitch = 0; ac_forwardmove = ac_sidemove = rel_yaw = rel_pitch = 0;
} }

View File

@ -30,9 +30,9 @@ extern "C"
{ {
void DLLEXPORT IN_ActivateMouse( void ); void DLLEXPORT IN_ActivateMouse( void );
void DLLEXPORT IN_DeactivateMouse( void ); void DLLEXPORT IN_DeactivateMouse( void );
void DLLEXPORT IN_MouseEvent (int mstate); void DLLEXPORT IN_MouseEvent( int mstate );
void DLLEXPORT IN_Accumulate (void); void DLLEXPORT IN_Accumulate( void );
void DLLEXPORT IN_ClearStates (void); void DLLEXPORT IN_ClearStates( void );
} }
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
@ -106,9 +106,9 @@ DWORD dwAxisFlags[JOY_MAX_AXES] =
JOY_RETURNV JOY_RETURNV
}; };
DWORD dwAxisMap[ JOY_MAX_AXES ]; DWORD dwAxisMap[JOY_MAX_AXES];
DWORD dwControlMap[ JOY_MAX_AXES ]; DWORD dwControlMap[JOY_MAX_AXES];
PDWORD pdwRawValue[ JOY_MAX_AXES ]; PDWORD pdwRawValue[JOY_MAX_AXES];
// none of these cvars are saved over a session // none of these cvars are saved over a session
// this means that advanced controller configuration needs to be executed // this means that advanced controller configuration needs to be executed
@ -149,11 +149,11 @@ static JOYINFOEX ji;
Force_CenterView_f Force_CenterView_f
=========== ===========
*/ */
void Force_CenterView_f (void) void Force_CenterView_f( void )
{ {
vec3_t viewangles; vec3_t viewangles;
if (!iMouseInUse) if( !iMouseInUse )
{ {
gEngfuncs.GetViewAngles( (float *)viewangles ); gEngfuncs.GetViewAngles( (float *)viewangles );
viewangles[PITCH] = 0; viewangles[PITCH] = 0;
@ -166,12 +166,12 @@ void Force_CenterView_f (void)
IN_ActivateMouse IN_ActivateMouse
=========== ===========
*/ */
void DLLEXPORT IN_ActivateMouse (void) void DLLEXPORT IN_ActivateMouse( void )
{ {
if (mouseinitialized) if( mouseinitialized )
{ {
if (mouseparmsvalid) if( mouseparmsvalid )
restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, newmouseparms, 0 );
mouseactive = 1; mouseactive = 1;
} }
} }
@ -181,13 +181,12 @@ void DLLEXPORT IN_ActivateMouse (void)
IN_DeactivateMouse IN_DeactivateMouse
=========== ===========
*/ */
void DLLEXPORT IN_DeactivateMouse (void) void DLLEXPORT IN_DeactivateMouse( void )
{ {
if (mouseinitialized) if( mouseinitialized )
{ {
if (restore_spi) if( restore_spi )
SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); SystemParametersInfo( SPI_SETMOUSE, 0, originalmouseparms, 0 );
mouseactive = 0; mouseactive = 0;
} }
} }
@ -197,26 +196,26 @@ void DLLEXPORT IN_DeactivateMouse (void)
IN_StartupMouse IN_StartupMouse
=========== ===========
*/ */
void IN_StartupMouse (void) void IN_StartupMouse( void )
{ {
if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) if( gEngfuncs.CheckParm( "-nomouse", NULL ) )
return; return;
mouseinitialized = 1; mouseinitialized = 1;
mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, originalmouseparms, 0 );
if (mouseparmsvalid) if( mouseparmsvalid )
{ {
if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) if( gEngfuncs.CheckParm( "-noforcemspd", NULL ) )
newmouseparms[2] = originalmouseparms[2]; newmouseparms[2] = originalmouseparms[2];
if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) if( gEngfuncs.CheckParm( "-noforcemaccel", NULL ) )
{ {
newmouseparms[0] = originalmouseparms[0]; newmouseparms[0] = originalmouseparms[0];
newmouseparms[1] = originalmouseparms[1]; newmouseparms[1] = originalmouseparms[1];
} }
if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) if( gEngfuncs.CheckParm( "-noforcemparms", NULL ) )
{ {
newmouseparms[0] = originalmouseparms[0]; newmouseparms[0] = originalmouseparms[0];
newmouseparms[1] = originalmouseparms[1]; newmouseparms[1] = originalmouseparms[1];
@ -232,7 +231,7 @@ void IN_StartupMouse (void)
IN_Shutdown IN_Shutdown
=========== ===========
*/ */
void IN_Shutdown (void) void IN_Shutdown( void )
{ {
IN_DeactivateMouse (); IN_DeactivateMouse ();
} }
@ -266,26 +265,26 @@ void IN_ResetMouse( void )
IN_MouseEvent IN_MouseEvent
=========== ===========
*/ */
void DLLEXPORT IN_MouseEvent (int mstate) void DLLEXPORT IN_MouseEvent( int mstate )
{ {
int i; int i;
if ( iMouseInUse || g_iVisibleMouse ) if( iMouseInUse || g_iVisibleMouse )
return; return;
// perform button actions // perform button actions
for (i=0 ; i<mouse_buttons ; i++) for( i = 0; i < mouse_buttons; i++ )
{ {
if ( (mstate & (1<<i)) && if( ( mstate & ( 1 << i ) ) &&
!(mouse_oldbuttonstate & (1<<i)) ) !( mouse_oldbuttonstate & ( 1 << i ) ) )
{ {
gEngfuncs.Key_Event (K_MOUSE1 + i, 1); gEngfuncs.Key_Event( K_MOUSE1 + i, 1 );
} }
if ( !(mstate & (1<<i)) && if( !( mstate & ( 1 << i ) ) &&
(mouse_oldbuttonstate & (1<<i)) ) ( mouse_oldbuttonstate & ( 1 << i ) ) )
{ {
gEngfuncs.Key_Event (K_MOUSE1 + i, 0); gEngfuncs.Key_Event( K_MOUSE1 + i, 0 );
} }
} }
@ -297,7 +296,7 @@ void DLLEXPORT IN_MouseEvent (int mstate)
IN_MouseMove IN_MouseMove
=========== ===========
*/ */
void IN_MouseMove ( float frametime, usercmd_t *cmd) void IN_MouseMove( float frametime, usercmd_t *cmd )
{ {
int mx, my; int mx, my;
vec3_t viewangles; vec3_t viewangles;
@ -306,9 +305,9 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
//jjb - this disbles normal mouse control if the user is trying to //jjb - this disbles normal mouse control if the user is trying to
// move the camera, or if the mouse cursor is visible or if we're in intermission // move the camera, or if the mouse cursor is visible or if we're in intermission
if ( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission ) if( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission )
{ {
GetCursorPos (&current_pos); GetCursorPos( &current_pos );
mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum;
my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum;
@ -316,10 +315,10 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
mx_accum = 0; mx_accum = 0;
my_accum = 0; my_accum = 0;
if (m_filter->value) if( m_filter->value )
{ {
mouse_x = (mx + old_mouse_x) * 0.5; mouse_x = ( mx + old_mouse_x ) * 0.5;
mouse_y = (my + old_mouse_y) * 0.5; mouse_y = ( my + old_mouse_y ) * 0.5;
} }
else else
{ {
@ -330,7 +329,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
old_mouse_x = mx; old_mouse_x = mx;
old_mouse_y = my; old_mouse_y = my;
if ( gHUD.GetSensitivity() != 0 ) if( gHUD.GetSensitivity() != 0 )
{ {
mouse_x *= gHUD.GetSensitivity(); mouse_x *= gHUD.GetSensitivity();
mouse_y *= gHUD.GetSensitivity(); mouse_y *= gHUD.GetSensitivity();
@ -342,22 +341,22 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
} }
// add mouse X/Y movement to cmd // add mouse X/Y movement to cmd
if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_mlook.state & 1 ) ) )
cmd->sidemove += m_side->value * mouse_x; cmd->sidemove += m_side->value * mouse_x;
else else
viewangles[YAW] -= m_yaw->value * mouse_x; viewangles[YAW] -= m_yaw->value * mouse_x;
if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) )
{ {
viewangles[PITCH] += m_pitch->value * mouse_y; viewangles[PITCH] += m_pitch->value * mouse_y;
if (viewangles[PITCH] > cl_pitchdown->value) if( viewangles[PITCH] > cl_pitchdown->value )
viewangles[PITCH] = cl_pitchdown->value; viewangles[PITCH] = cl_pitchdown->value;
if (viewangles[PITCH] < -cl_pitchup->value) if( viewangles[PITCH] < -cl_pitchup->value )
viewangles[PITCH] = -cl_pitchup->value; viewangles[PITCH] = -cl_pitchup->value;
} }
else else
{ {
if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) if( ( in_strafe.state & 1 ) && gEngfuncs.IsNoClipping() )
{ {
cmd->upmove -= m_forward->value * mouse_y; cmd->upmove -= m_forward->value * mouse_y;
} }
@ -368,7 +367,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
} }
// if the mouse has moved, force it to the center, so there's room to move // if the mouse has moved, force it to the center, so there's room to move
if ( mx || my ) if( mx || my )
{ {
IN_ResetMouse(); IN_ResetMouse();
} }
@ -394,14 +393,14 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
IN_Accumulate IN_Accumulate
=========== ===========
*/ */
void DLLEXPORT IN_Accumulate (void) void DLLEXPORT IN_Accumulate( void )
{ {
//only accumulate mouse if we are not moving the camera with the mouse //only accumulate mouse if we are not moving the camera with the mouse
if ( !iMouseInUse && !g_iVisibleMouse ) if( !iMouseInUse && !g_iVisibleMouse )
{ {
if (mouseactive) if( mouseactive )
{ {
GetCursorPos (&current_pos); GetCursorPos( &current_pos );
mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX();
my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); my_accum += current_pos.y - gEngfuncs.GetWindowCenterY();
@ -410,7 +409,6 @@ void DLLEXPORT IN_Accumulate (void)
IN_ResetMouse(); IN_ResetMouse();
} }
} }
} }
/* /*
@ -418,9 +416,9 @@ void DLLEXPORT IN_Accumulate (void)
IN_ClearStates IN_ClearStates
=================== ===================
*/ */
void DLLEXPORT IN_ClearStates (void) void DLLEXPORT IN_ClearStates( void )
{ {
if ( !mouseactive ) if( !mouseactive )
return; return;
mx_accum = 0; mx_accum = 0;
@ -433,7 +431,7 @@ void DLLEXPORT IN_ClearStates (void)
IN_StartupJoystick IN_StartupJoystick
=============== ===============
*/ */
void IN_StartupJoystick (void) void IN_StartupJoystick( void )
{ {
int numdevs; int numdevs;
JOYCAPS jc; JOYCAPS jc;
@ -443,40 +441,40 @@ void IN_StartupJoystick (void)
joy_avail = 0; joy_avail = 0;
// abort startup if user requests no joystick // abort startup if user requests no joystick
if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) if( gEngfuncs.CheckParm( "-nojoy", NULL ) )
return; return;
// verify joystick driver is present // verify joystick driver is present
if ((numdevs = joyGetNumDevs ()) == 0) if( ( numdevs = joyGetNumDevs() ) == 0 )
{ {
gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); gEngfuncs.Con_DPrintf( "joystick not found -- driver not present\n\n" );
return; return;
} }
// cycle through the joystick ids for the first valid one // cycle through the joystick ids for the first valid one
for (joy_id=0 ; joy_id<numdevs ; joy_id++) for( joy_id = 0; joy_id < numdevs; joy_id++ )
{ {
memset (&ji, 0, sizeof(ji)); memset( &ji, 0, sizeof(ji) );
ji.dwSize = sizeof(ji); ji.dwSize = sizeof(ji);
ji.dwFlags = JOY_RETURNCENTERED; ji.dwFlags = JOY_RETURNCENTERED;
if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR) if( ( mmr = joyGetPosEx( joy_id, &ji ) ) == JOYERR_NOERROR )
break; break;
} }
// abort startup if we didn't find a valid joystick // abort startup if we didn't find a valid joystick
if (mmr != JOYERR_NOERROR) if( mmr != JOYERR_NOERROR )
{ {
gEngfuncs.Con_DPrintf ("joystick not found -- no valid joysticks (%x)\n\n", mmr); gEngfuncs.Con_DPrintf( "joystick not found -- no valid joysticks (%x)\n\n", mmr );
return; return;
} }
// get the capabilities of the selected joystick // get the capabilities of the selected joystick
// abort startup if command fails // abort startup if command fails
memset (&jc, 0, sizeof(jc)); memset( &jc, 0, sizeof(jc) );
if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR) if( ( mmr = joyGetDevCaps( joy_id, &jc, sizeof(jc) ) ) != JOYERR_NOERROR )
{ {
gEngfuncs.Con_DPrintf ("joystick not found -- invalid joystick capabilities (%x)\n\n", mmr); gEngfuncs.Con_DPrintf( "joystick not found -- invalid joystick capabilities (%x)\n\n", mmr );
return; return;
} }
@ -489,20 +487,19 @@ void IN_StartupJoystick (void)
// mark the joystick as available and advanced initialization not completed // mark the joystick as available and advanced initialization not completed
// this is needed as cvars are not available during initialization // this is needed as cvars are not available during initialization
gEngfuncs.Con_Printf ("joystick found\n\n", mmr); gEngfuncs.Con_Printf( "joystick found\n\n", mmr );
joy_avail = 1; joy_avail = 1;
joy_advancedinit = 0; joy_advancedinit = 0;
} }
/* /*
=========== ===========
RawValuePointer RawValuePointer
=========== ===========
*/ */
PDWORD RawValuePointer (int axis) PDWORD RawValuePointer( int axis )
{ {
switch (axis) switch( axis )
{ {
case JOY_AXIS_X: case JOY_AXIS_X:
return &ji.dwXpos; return &ji.dwXpos;
@ -521,29 +518,27 @@ PDWORD RawValuePointer (int axis)
return &ji.dwXpos; return &ji.dwXpos;
} }
/* /*
=========== ===========
Joy_AdvancedUpdate_f Joy_AdvancedUpdate_f
=========== ===========
*/ */
void Joy_AdvancedUpdate_f (void) void Joy_AdvancedUpdate_f( void )
{ {
// called once by IN_ReadJoystick and by user whenever an update is needed // called once by IN_ReadJoystick and by user whenever an update is needed
// cvars are now available // cvars are now available
int i; int i;
DWORD dwTemp; DWORD dwTemp;
// initialize all the maps // initialize all the maps
for (i = 0; i < JOY_MAX_AXES; i++) for( i = 0; i < JOY_MAX_AXES; i++ )
{ {
dwAxisMap[i] = AxisNada; dwAxisMap[i] = AxisNada;
dwControlMap[i] = JOY_ABSOLUTE_AXIS; dwControlMap[i] = JOY_ABSOLUTE_AXIS;
pdwRawValue[i] = RawValuePointer(i); pdwRawValue[i] = RawValuePointer(i);
} }
if( joy_advanced->value == 0.0) if( joy_advanced->value == 0.0 )
{ {
// default joystick initialization // default joystick initialization
// 2 axes only with joystick control // 2 axes only with joystick control
@ -554,134 +549,130 @@ void Joy_AdvancedUpdate_f (void)
} }
else else
{ {
if ( strcmp ( joy_name->string, "joystick") != 0 ) if( strcmp( joy_name->string, "joystick" ) != 0 )
{ {
// notify user of advanced controller // notify user of advanced controller
gEngfuncs.Con_Printf ("\n%s configured\n\n", joy_name->string); gEngfuncs.Con_Printf( "\n%s configured\n\n", joy_name->string );
} }
// advanced initialization here // advanced initialization here
// data supplied by user via joy_axisn cvars // data supplied by user via joy_axisn cvars
dwTemp = (DWORD) joy_advaxisx->value; dwTemp = (DWORD)joy_advaxisx->value;
dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f;
dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS;
dwTemp = (DWORD) joy_advaxisy->value; dwTemp = (DWORD)joy_advaxisy->value;
dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f;
dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS;
dwTemp = (DWORD) joy_advaxisz->value; dwTemp = (DWORD)joy_advaxisz->value;
dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f;
dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS;
dwTemp = (DWORD) joy_advaxisr->value; dwTemp = (DWORD)joy_advaxisr->value;
dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f;
dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS;
dwTemp = (DWORD) joy_advaxisu->value; dwTemp = (DWORD)joy_advaxisu->value;
dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f;
dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS;
dwTemp = (DWORD) joy_advaxisv->value; dwTemp = (DWORD)joy_advaxisv->value;
dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f;
dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS;
} }
// compute the axes to collect from DirectInput // compute the axes to collect from DirectInput
joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
for (i = 0; i < JOY_MAX_AXES; i++) for( i = 0; i < JOY_MAX_AXES; i++ )
{ {
if (dwAxisMap[i] != AxisNada) if( dwAxisMap[i] != AxisNada )
{ {
joy_flags |= dwAxisFlags[i]; joy_flags |= dwAxisFlags[i];
} }
} }
} }
/* /*
=========== ===========
IN_Commands IN_Commands
=========== ===========
*/ */
void IN_Commands (void) void IN_Commands( void )
{ {
int i, key_index; int i, key_index;
DWORD buttonstate, povstate; DWORD buttonstate, povstate;
if (!joy_avail) if( !joy_avail )
{ {
return; return;
} }
// loop through the joystick buttons // loop through the joystick buttons
// key a joystick event or auxillary event for higher number buttons for each state change // key a joystick event or auxillary event for higher number buttons for each state change
buttonstate = ji.dwButtons; buttonstate = ji.dwButtons;
for (i=0 ; i < (int)joy_numbuttons ; i++) for( i = 0; i < (int)joy_numbuttons; i++ )
{ {
if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) ) if( ( buttonstate & ( 1 << i ) ) && !( joy_oldbuttonstate & ( 1 << i ) ) )
{ {
key_index = (i < 4) ? K_JOY1 : K_AUX1; key_index = ( i < 4 ) ? K_JOY1 : K_AUX1;
gEngfuncs.Key_Event (key_index + i, 1); gEngfuncs.Key_Event( key_index + i, 1 );
} }
if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) ) if( !( buttonstate & ( 1 << i ) ) && ( joy_oldbuttonstate & ( 1 << i ) ) )
{ {
key_index = (i < 4) ? K_JOY1 : K_AUX1; key_index = ( i < 4 ) ? K_JOY1 : K_AUX1;
gEngfuncs.Key_Event (key_index + i, 0); gEngfuncs.Key_Event( key_index + i, 0 );
} }
} }
joy_oldbuttonstate = buttonstate; joy_oldbuttonstate = buttonstate;
if (joy_haspov) if( joy_haspov )
{ {
// convert POV information into 4 bits of state information // convert POV information into 4 bits of state information
// this avoids any potential problems related to moving from one // this avoids any potential problems related to moving from one
// direction to another without going through the center position // direction to another without going through the center position
povstate = 0; povstate = 0;
if(ji.dwPOV != JOY_POVCENTERED) if( ji.dwPOV != JOY_POVCENTERED )
{ {
if (ji.dwPOV == JOY_POVFORWARD) if( ji.dwPOV == JOY_POVFORWARD )
povstate |= 0x01; povstate |= 0x01;
if (ji.dwPOV == JOY_POVRIGHT) if( ji.dwPOV == JOY_POVRIGHT )
povstate |= 0x02; povstate |= 0x02;
if (ji.dwPOV == JOY_POVBACKWARD) if( ji.dwPOV == JOY_POVBACKWARD )
povstate |= 0x04; povstate |= 0x04;
if (ji.dwPOV == JOY_POVLEFT) if( ji.dwPOV == JOY_POVLEFT )
povstate |= 0x08; povstate |= 0x08;
} }
// determine which bits have changed and key an auxillary event for each change // determine which bits have changed and key an auxillary event for each change
for (i=0 ; i < 4 ; i++) for( i = 0; i < 4; i++ )
{ {
if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) ) if( ( povstate & ( 1 << i ) ) && !( joy_oldpovstate & ( 1 << i ) ) )
{ {
gEngfuncs.Key_Event (K_AUX29 + i, 1); gEngfuncs.Key_Event( K_AUX29 + i, 1 );
} }
if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) ) if( !( povstate & ( 1 << i ) ) && ( joy_oldpovstate & ( 1 << i ) ) )
{ {
gEngfuncs.Key_Event (K_AUX29 + i, 0); gEngfuncs.Key_Event( K_AUX29 + i, 0 );
} }
} }
joy_oldpovstate = povstate; joy_oldpovstate = povstate;
} }
} }
/* /*
=============== ===============
IN_ReadJoystick IN_ReadJoystick
=============== ===============
*/ */
int IN_ReadJoystick (void) int IN_ReadJoystick( void )
{ {
memset( &ji, 0, sizeof(ji) );
memset (&ji, 0, sizeof(ji));
ji.dwSize = sizeof(ji); ji.dwSize = sizeof(ji);
ji.dwFlags = joy_flags; ji.dwFlags = joy_flags;
if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR) if( joyGetPosEx( joy_id, &ji ) == JOYERR_NOERROR )
{ {
// this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
// rather than having 32768 be the zero point, they have the zero point at 32668 // rather than having 32768 be the zero point, they have the zero point at 32668
// go figure -- anyway, now we get the full resolution out of the device // go figure -- anyway, now we get the full resolution out of the device
if (joy_wwhack1->value != 0.0) if( joy_wwhack1->value != 0.0 )
{ {
ji.dwUpos += 100; ji.dwUpos += 100;
} }
@ -692,19 +683,18 @@ int IN_ReadJoystick (void)
// read error occurred // read error occurred
// turning off the joystick seems too harsh for 1 read error,\ // turning off the joystick seems too harsh for 1 read error,\
// but what should be done? // but what should be done?
// Con_Printf ("IN_ReadJoystick: no response\n"); // Con_Printf( "IN_ReadJoystick: no response\n" );
// joy_avail = 0; // joy_avail = 0;
return 0; return 0;
} }
} }
/* /*
=========== ===========
IN_JoyMove IN_JoyMove
=========== ===========
*/ */
void IN_JoyMove ( float frametime, usercmd_t *cmd ) void IN_JoyMove( float frametime, usercmd_t *cmd )
{ {
float speed, aspeed; float speed, aspeed;
float fAxisValue, fTemp; float fAxisValue, fTemp;
@ -713,7 +703,6 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
gEngfuncs.GetViewAngles( (float *)viewangles ); gEngfuncs.GetViewAngles( (float *)viewangles );
// complete initialization if first time in // complete initialization if first time in
// this is needed as cvars are not available at initialization time // this is needed as cvars are not available at initialization time
if( joy_advancedinit != 1 ) if( joy_advancedinit != 1 )
@ -723,18 +712,18 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
} }
// verify joystick is available and that the user wants to use it // verify joystick is available and that the user wants to use it
if (!joy_avail || !in_joystick->value) if( !joy_avail || !in_joystick->value )
{ {
return; return;
} }
// collect the joystick data, if possible // collect the joystick data, if possible
if (IN_ReadJoystick () != 1) if( IN_ReadJoystick () != 1 )
{ {
return; return;
} }
if (in_speed.state & 1) if( in_speed.state & 1 )
speed = cl_movespeedkey->value; speed = cl_movespeedkey->value;
else else
speed = 1; speed = 1;
@ -742,126 +731,121 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
aspeed = speed * frametime; aspeed = speed * frametime;
// loop through the axes // loop through the axes
for (i = 0; i < JOY_MAX_AXES; i++) for( i = 0; i < JOY_MAX_AXES; i++ )
{ {
// get the floating point zero-centered, potentially-inverted data for the current axis // get the floating point zero-centered, potentially-inverted data for the current axis
fAxisValue = (float) *pdwRawValue[i]; fAxisValue = (float) *pdwRawValue[i];
// move centerpoint to zero // move centerpoint to zero
fAxisValue -= 32768.0; fAxisValue -= 32768.0;
if (joy_wwhack2->value != 0.0) if( joy_wwhack2->value != 0.0 )
{ {
if (dwAxisMap[i] == AxisTurn) if( dwAxisMap[i] == AxisTurn )
{ {
// this is a special formula for the Logitech WingMan Warrior // this is a special formula for the Logitech WingMan Warrior
// y=ax^b; where a = 300 and b = 1.3 // y=ax^b; where a = 300 and b = 1.3
// also x values are in increments of 800 (so this is factored out) // also x values are in increments of 800 (so this is factored out)
// then bounds check result to level out excessively high spin rates // then bounds check result to level out excessively high spin rates
fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3); fTemp = 300.0 * pow( abs( fAxisValue ) / 800.0, 1.3 );
if (fTemp > 14000.0) if( fTemp > 14000.0 )
fTemp = 14000.0; fTemp = 14000.0;
// restore direction information // restore direction information
fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp; fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : -fTemp;
} }
} }
// convert range from -32768..32767 to -1..1 // convert range from -32768..32767 to -1..1
fAxisValue /= 32768.0; fAxisValue /= 32768.0;
switch (dwAxisMap[i]) switch( dwAxisMap[i] )
{ {
case AxisForward: case AxisForward:
if ((joy_advanced->value == 0.0) && (in_jlook.state & 1)) if( ( joy_advanced->value == 0.0 ) && ( in_jlook.state & 1 ) )
{ {
// user wants forward control to become look control // user wants forward control to become look control
if (fabs(fAxisValue) > joy_pitchthreshold->value) if( fabs( fAxisValue ) > joy_pitchthreshold->value )
{ {
// if mouse invert is on, invert the joystick pitch value // if mouse invert is on, invert the joystick pitch value
// only absolute control support here (joy_advanced is 0) // only absolute control support here (joy_advanced is 0)
if (m_pitch->value < 0.0) if( m_pitch->value < 0.0 )
{ {
viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
} }
else else
{ {
viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
} }
} }
} }
else else
{ {
// user wants forward control to be forward control // user wants forward control to be forward control
if (fabs(fAxisValue) > joy_forwardthreshold->value) if( fabs( fAxisValue ) > joy_forwardthreshold->value )
{ {
cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value; cmd->forwardmove += ( fAxisValue * joy_forwardsensitivity->value ) * speed * cl_forwardspeed->value;
} }
} }
break; break;
case AxisSide: case AxisSide:
if (fabs(fAxisValue) > joy_sidethreshold->value) if( fabs( fAxisValue ) > joy_sidethreshold->value )
{ {
cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; cmd->sidemove += ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value;
} }
break; break;
case AxisTurn: case AxisTurn:
if ((in_strafe.state & 1) || (lookstrafe->value && (in_jlook.state & 1))) if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_jlook.state & 1 ) ) )
{ {
// user wants turn control to become side control // user wants turn control to become side control
if (fabs(fAxisValue) > joy_sidethreshold->value) if( fabs( fAxisValue ) > joy_sidethreshold->value )
{ {
cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; cmd->sidemove -= ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value;
} }
} }
else else
{ {
// user wants turn control to be turn control // user wants turn control to be turn control
if (fabs(fAxisValue) > joy_yawthreshold->value) if( fabs( fAxisValue ) > joy_yawthreshold->value )
{ {
if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) if( dwControlMap[i] == JOY_ABSOLUTE_AXIS )
{ {
viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value; viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value;
} }
else else
{ {
viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0; viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * speed * 180.0;
} }
} }
} }
break; break;
case AxisLook: case AxisLook:
if (in_jlook.state & 1) if( in_jlook.state & 1 )
{ {
if (fabs(fAxisValue) > joy_pitchthreshold->value) if( fabs( fAxisValue ) > joy_pitchthreshold->value )
{ {
// pitch movement detected and pitch movement desired by user // pitch movement detected and pitch movement desired by user
if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) if( dwControlMap[i] == JOY_ABSOLUTE_AXIS )
{ {
viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
} }
else else
{ {
viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0; viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * speed * 180.0;
} }
} }
} }
break; break;
default: default:
break; break;
} }
} }
// bounds check pitch // bounds check pitch
if (viewangles[PITCH] > cl_pitchdown->value) if( viewangles[PITCH] > cl_pitchdown->value )
viewangles[PITCH] = cl_pitchdown->value; viewangles[PITCH] = cl_pitchdown->value;
if (viewangles[PITCH] < -cl_pitchup->value) if( viewangles[PITCH] < -cl_pitchup->value )
viewangles[PITCH] = -cl_pitchup->value; viewangles[PITCH] = -cl_pitchup->value;
gEngfuncs.SetViewAngles( (float *)viewangles ); gEngfuncs.SetViewAngles( (float *)viewangles );
} }
/* /*
@ -869,14 +853,14 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
IN_Move IN_Move
=========== ===========
*/ */
void IN_Move ( float frametime, usercmd_t *cmd) void IN_Move( float frametime, usercmd_t *cmd )
{ {
if ( !iMouseInUse && mouseactive ) if( !iMouseInUse && mouseactive )
{ {
IN_MouseMove ( frametime, cmd); IN_MouseMove( frametime, cmd );
} }
IN_JoyMove ( frametime, cmd); IN_JoyMove( frametime, cmd );
} }
/* /*
@ -884,30 +868,30 @@ void IN_Move ( float frametime, usercmd_t *cmd)
IN_Init IN_Init
=========== ===========
*/ */
void IN_Init (void) void IN_Init( void )
{ {
m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); m_filter = gEngfuncs.pfnRegisterVariable( "m_filter","0", FCVAR_ARCHIVE );
sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting.
in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick","0", FCVAR_ARCHIVE );
joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); joy_name = gEngfuncs.pfnRegisterVariable( "joyname", "joystick", 0 );
joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); joy_advanced = gEngfuncs.pfnRegisterVariable( "joyadvanced", "0", 0 );
joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); joy_advaxisx = gEngfuncs.pfnRegisterVariable( "joyadvaxisx", "0", 0 );
joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); joy_advaxisy = gEngfuncs.pfnRegisterVariable( "joyadvaxisy", "0", 0 );
joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); joy_advaxisz = gEngfuncs.pfnRegisterVariable( "joyadvaxisz", "0", 0 );
joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); joy_advaxisr = gEngfuncs.pfnRegisterVariable( "joyadvaxisr", "0", 0 );
joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); joy_advaxisu = gEngfuncs.pfnRegisterVariable( "joyadvaxisu", "0", 0 );
joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); joy_advaxisv = gEngfuncs.pfnRegisterVariable( "joyadvaxisv", "0", 0 );
joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); joy_forwardthreshold = gEngfuncs.pfnRegisterVariable( "joyforwardthreshold", "0.15", 0 );
joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); joy_sidethreshold = gEngfuncs.pfnRegisterVariable( "joysidethreshold", "0.15", 0 );
joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); joy_pitchthreshold = gEngfuncs.pfnRegisterVariable( "joypitchthreshold", "0.15", 0 );
joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); joy_yawthreshold = gEngfuncs.pfnRegisterVariable( "joyyawthreshold", "0.15", 0 );
joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable( "joyforwardsensitivity", "-1.0", 0 );
joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); joy_sidesensitivity = gEngfuncs.pfnRegisterVariable( "joysidesensitivity", "-1.0", 0 );
joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable( "joypitchsensitivity", "1.0", 0 );
joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); joy_yawsensitivity = gEngfuncs.pfnRegisterVariable( "joyyawsensitivity", "-1.0", 0 );
joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); joy_wwhack1 = gEngfuncs.pfnRegisterVariable( "joywwhack1", "0.0", 0 );
joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); joy_wwhack2 = gEngfuncs.pfnRegisterVariable( "joywwhack2", "0.0", 0 );
gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f);
gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);

View File

@ -14,5 +14,4 @@ typedef struct kbutton_s
int down[2]; // key nums holding it down int down[2]; // key nums holding it down
int state; // low bit is down state int state; // low bit is down state
} kbutton_t; } kbutton_t;
#endif // !KBUTTONH #endif // !KBUTTONH

View File

@ -17,23 +17,22 @@
// //
// generic menu handler // generic menu handler
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#define MAX_MENU_STRING 512 #define MAX_MENU_STRING 512
char g_szMenuString[MAX_MENU_STRING]; char g_szMenuString[MAX_MENU_STRING];
char g_szPrelocalisedMenuString[MAX_MENU_STRING]; char g_szPrelocalisedMenuString[MAX_MENU_STRING];
int KB_ConvertString( char *in, char **ppout ); int KB_ConvertString( char *in, char **ppout );
DECLARE_MESSAGE( m_Menu, ShowMenu ); DECLARE_MESSAGE( m_Menu, ShowMenu )
int CHudMenu :: Init( void ) int CHudMenu::Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
@ -44,33 +43,34 @@ int CHudMenu :: Init( void )
return 1; return 1;
} }
void CHudMenu :: InitHUDData( void ) void CHudMenu::InitHUDData( void )
{ {
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_bitsValidSlots = 0; m_bitsValidSlots = 0;
Reset(); Reset();
} }
void CHudMenu :: Reset( void ) void CHudMenu::Reset( void )
{ {
g_szPrelocalisedMenuString[0] = 0; g_szPrelocalisedMenuString[0] = 0;
m_fWaitingForMore = FALSE; m_fWaitingForMore = FALSE;
} }
int CHudMenu :: VidInit( void ) int CHudMenu::VidInit( void )
{ {
return 1; return 1;
} }
int CHudMenu :: Draw( float flTime ) int CHudMenu::Draw( float flTime )
{ {
int i; int i;
// check for if menu is set to disappear // check for if menu is set to disappear
if ( m_flShutoffTime > 0 ) if( m_flShutoffTime > 0 )
{ {
if ( m_flShutoffTime <= gHUD.m_flTime ) if( m_flShutoffTime <= gHUD.m_flTime )
{ // times up, shutoff {
// times up, shutoff
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
@ -78,32 +78,28 @@ int CHudMenu :: Draw( float flTime )
} }
// don't draw the menu if the scoreboard is being shown // don't draw the menu if the scoreboard is being shown
// draw the menu, along the left-hand side of the screen // draw the menu, along the left-hand side of the screen
// count the number of newlines // count the number of newlines
int nlc = 0; int nlc = 0;
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) for( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
{ {
if ( g_szMenuString[i] == '\n' ) if ( g_szMenuString[i] == '\n' )
nlc++; nlc++;
} }
// center it // center it
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text int y = ( ScreenHeight / 2 ) - ( ( nlc / 2 ) * 12 ) - 40; // make sure it is above the say text
int x = 20; int x = 20;
i = 0; i = 0;
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' ) while( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
{ {
gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 ); gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
y += 12; y += 12;
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' ) while( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
i++; i++;
if ( g_szMenuString[i] == '\n' ) if( g_szMenuString[i] == '\n' )
i++; i++;
} }
@ -111,10 +107,10 @@ int CHudMenu :: Draw( float flTime )
} }
// selects an item from the menu // selects an item from the menu
void CHudMenu :: SelectMenuItem( int menu_item ) void CHudMenu::SelectMenuItem( int menu_item )
{ {
// if menu_item is in a valid slot, send a menuselect command to the server // if menu_item is in a valid slot, send a menuselect command to the server
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) ) if( ( menu_item > 0 ) && ( m_bitsValidSlots & ( 1 << ( menu_item - 1 ) ) ) )
{ {
char szbuf[32]; char szbuf[32];
sprintf( szbuf, "menuselect %d\n", menu_item ); sprintf( szbuf, "menuselect %d\n", menu_item );
@ -126,7 +122,6 @@ void CHudMenu :: SelectMenuItem( int menu_item )
} }
} }
// Message handler for ShowMenu message // Message handler for ShowMenu message
// takes four values: // takes four values:
// short: a bitfield of keys that are valid input // short: a bitfield of keys that are valid input
@ -134,7 +129,7 @@ void CHudMenu :: SelectMenuItem( int menu_item )
// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string // byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string
// string: menu string to display // string: menu string to display
// if this message is never received, then scores will simply be the combined totals of the players. // if this message is never received, then scores will simply be the combined totals of the players.
int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
{ {
char *temp = NULL; char *temp = NULL;
@ -144,29 +139,31 @@ int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
int DisplayTime = READ_CHAR(); int DisplayTime = READ_CHAR();
int NeedMore = READ_BYTE(); int NeedMore = READ_BYTE();
if ( DisplayTime > 0 ) if( DisplayTime > 0 )
m_flShutoffTime = DisplayTime + gHUD.m_flTime; m_flShutoffTime = DisplayTime + gHUD.m_flTime;
else else
m_flShutoffTime = -1; m_flShutoffTime = -1;
if ( m_bitsValidSlots ) if( m_bitsValidSlots )
{ {
if ( !m_fWaitingForMore ) // this is the start of a new menu if( !m_fWaitingForMore ) // this is the start of a new menu
{ {
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
} }
else else
{ // append to the current menu string {
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) ); // append to the current menu string
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) );
} }
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not) g_szPrelocalisedMenuString[MAX_MENU_STRING - 1] = 0; // ensure null termination (strncat/strncpy does not)
if ( !NeedMore ) if( !NeedMore )
{ // we have the whole string, so we can localise it now {
// we have the whole string, so we can localise it now
strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ); strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) );
// Swap in characters // Swap in characters
if ( KB_ConvertString( g_szMenuString, &temp ) ) if( KB_ConvertString( g_szMenuString, &temp ) )
{ {
strcpy( g_szMenuString, temp ); strcpy( g_szMenuString, temp );
free( temp ); free( temp );

View File

@ -32,17 +32,17 @@ client_textmessage_t g_pCustomMessage;
char *g_pCustomName = "Custom"; char *g_pCustomName = "Custom";
char g_pCustomText[1024]; char g_pCustomText[1024];
int CHudMessage::Init(void) int CHudMessage::Init( void )
{ {
HOOK_MESSAGE( HudText ); HOOK_MESSAGE( HudText );
HOOK_MESSAGE( GameTitle ); HOOK_MESSAGE( GameTitle );
gHUD.AddHudElem(this); gHUD.AddHudElem( this );
Reset(); Reset();
return 1; return 1;
}; }
int CHudMessage::VidInit( void ) int CHudMessage::VidInit( void )
{ {
@ -50,35 +50,33 @@ int CHudMessage::VidInit( void )
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" ); m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" );
return 1; return 1;
}; }
void CHudMessage::Reset( void ) void CHudMessage::Reset( void )
{ {
memset( m_pMessages, 0, sizeof( m_pMessages[0] ) * maxHUDMessages ); memset( m_pMessages, 0, sizeof(m_pMessages[0]) * maxHUDMessages );
memset( m_startTime, 0, sizeof( m_startTime[0] ) * maxHUDMessages ); memset( m_startTime, 0, sizeof(m_startTime[0]) * maxHUDMessages );
m_gameTitleTime = 0; m_gameTitleTime = 0;
m_pGameTitle = NULL; m_pGameTitle = NULL;
} }
float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime ) float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime )
{ {
float fadeTime = fadein + hold; float fadeTime = fadein + hold;
float fadeBlend; float fadeBlend;
if ( localTime < 0 ) if( localTime < 0 )
return 0; return 0;
if ( localTime < fadein ) if( localTime < fadein )
{ {
fadeBlend = 1 - ((fadein - localTime) / fadein); fadeBlend = 1 - ( ( fadein - localTime ) / fadein );
} }
else if ( localTime > fadeTime ) else if( localTime > fadeTime )
{ {
if ( fadeout > 0 ) if( fadeout > 0 )
fadeBlend = 1 - ((localTime - fadeTime) / fadeout); fadeBlend = 1 - ( ( localTime - fadeTime ) / fadeout );
else else
fadeBlend = 0; fadeBlend = 0;
} }
@ -93,38 +91,37 @@ int CHudMessage::XPosition( float x, int width, int totalWidth )
{ {
int xPos; int xPos;
if ( x == -1 ) if( x == -1 )
{ {
xPos = (ScreenWidth - width) / 2; xPos = ( ScreenWidth - width ) / 2;
} }
else else
{ {
if ( x < 0 ) if( x < 0 )
xPos = (1.0 + x) * ScreenWidth - totalWidth; // Alight right xPos = ( 1.0 + x ) * ScreenWidth - totalWidth; // Alight right
else else
xPos = x * ScreenWidth; xPos = x * ScreenWidth;
} }
if ( xPos + width > ScreenWidth ) if( xPos + width > ScreenWidth )
xPos = ScreenWidth - width; xPos = ScreenWidth - width;
else if ( xPos < 0 ) else if( xPos < 0 )
xPos = 0; xPos = 0;
return xPos; return xPos;
} }
int CHudMessage::YPosition( float y, int height ) int CHudMessage::YPosition( float y, int height )
{ {
int yPos; int yPos;
if ( y == -1 ) // Centered? if( y == -1 ) // Centered?
yPos = (ScreenHeight - height) * 0.5; yPos = ( ScreenHeight - height ) * 0.5;
else else
{ {
// Alight bottom? // Alight bottom?
if ( y < 0 ) if ( y < 0 )
yPos = (1.0 + y) * ScreenHeight - height; // Alight bottom yPos = ( 1.0 + y ) * ScreenHeight - height; // Alight bottom
else // align top else // align top
yPos = y * ScreenHeight; yPos = y * ScreenHeight;
} }
@ -137,7 +134,6 @@ int CHudMessage::YPosition( float y, int height )
return yPos; return yPos;
} }
void CHudMessage::MessageScanNextChar( void ) void CHudMessage::MessageScanNextChar( void )
{ {
int srcRed, srcGreen, srcBlue, destRed = 0, destGreen = 0, destBlue = 0; int srcRed, srcGreen, srcBlue, destRed = 0, destGreen = 0, destBlue = 0;
@ -156,10 +152,9 @@ void CHudMessage::MessageScanNextChar( void )
destRed = destGreen = destBlue = 0; destRed = destGreen = destBlue = 0;
blend = m_parms.fadeBlend; blend = m_parms.fadeBlend;
break; break;
case 2: case 2:
m_parms.charTime += m_parms.pMessage->fadein; m_parms.charTime += m_parms.pMessage->fadein;
if ( m_parms.charTime > m_parms.time ) if( m_parms.charTime > m_parms.time )
{ {
srcRed = srcGreen = srcBlue = 0; srcRed = srcGreen = srcBlue = 0;
blend = 0; // pure source blend = 0; // pure source
@ -185,23 +180,22 @@ void CHudMessage::MessageScanNextChar( void )
} }
break; break;
} }
if ( blend > 255 ) if( blend > 255 )
blend = 255; blend = 255;
else if ( blend < 0 ) else if( blend < 0 )
blend = 0; blend = 0;
m_parms.r = ((srcRed * (255-blend)) + (destRed * blend)) >> 8; m_parms.r = ( ( srcRed * ( 255 - blend ) ) + ( destRed * blend ) ) >> 8;
m_parms.g = ((srcGreen * (255-blend)) + (destGreen * blend)) >> 8; m_parms.g = ( ( srcGreen * (255 - blend ) ) + ( destGreen * blend ) ) >> 8;
m_parms.b = ((srcBlue * (255-blend)) + (destBlue * blend)) >> 8; m_parms.b = ( ( srcBlue * ( 255 - blend ) ) + ( destBlue * blend ) ) >> 8;
if ( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 ) if( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 )
{ {
if ( m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]) <= ScreenWidth ) if( m_parms.x >= 0 && m_parms.y >= 0 && ( m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text] ) <= ScreenWidth )
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 ); TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 );
} }
} }
void CHudMessage::MessageScanStart( void ) void CHudMessage::MessageScanStart( void )
{ {
switch( m_parms.pMessage->effect ) switch( m_parms.pMessage->effect )
@ -212,14 +206,14 @@ void CHudMessage::MessageScanStart( void )
m_parms.fadeTime = m_parms.pMessage->fadein + m_parms.pMessage->holdtime; m_parms.fadeTime = m_parms.pMessage->fadein + m_parms.pMessage->holdtime;
if ( m_parms.time < m_parms.pMessage->fadein ) if( m_parms.time < m_parms.pMessage->fadein )
{ {
m_parms.fadeBlend = ((m_parms.pMessage->fadein - m_parms.time) * (1.0/m_parms.pMessage->fadein) * 255); m_parms.fadeBlend = ( ( m_parms.pMessage->fadein - m_parms.time ) * ( 1.0 / m_parms.pMessage->fadein ) * 255 );
} }
else if ( m_parms.time > m_parms.fadeTime ) else if( m_parms.time > m_parms.fadeTime )
{ {
if ( m_parms.pMessage->fadeout > 0 ) if( m_parms.pMessage->fadeout > 0 )
m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255); m_parms.fadeBlend = ( ( ( m_parms.time - m_parms.fadeTime ) / m_parms.pMessage->fadeout) * 255);
else else
m_parms.fadeBlend = 255; // Pure dest (off) m_parms.fadeBlend = 255; // Pure dest (off)
} }
@ -227,15 +221,14 @@ void CHudMessage::MessageScanStart( void )
m_parms.fadeBlend = 0; // Pure source (on) m_parms.fadeBlend = 0; // Pure source (on)
m_parms.charTime = 0; m_parms.charTime = 0;
if ( m_parms.pMessage->effect == 1 && (rand()%100) < 10 ) if( m_parms.pMessage->effect == 1 && ( rand() % 100 ) < 10 )
m_parms.charTime = 1; m_parms.charTime = 1;
break; break;
case 2: case 2:
m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime; m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime;
if ( m_parms.time > m_parms.fadeTime && m_parms.pMessage->fadeout > 0 ) if ( m_parms.time > m_parms.fadeTime && m_parms.pMessage->fadeout > 0 )
m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255); m_parms.fadeBlend = ( ( ( m_parms.time - m_parms.fadeTime ) / m_parms.pMessage->fadeout ) * 255 );
else else
m_parms.fadeBlend = 0; m_parms.fadeBlend = 0;
break; break;
@ -257,12 +250,12 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
length = 0; length = 0;
width = 0; width = 0;
m_parms.totalWidth = 0; m_parms.totalWidth = 0;
while ( *pText ) while( *pText )
{ {
if ( *pText == '\n' ) if( *pText == '\n' )
{ {
m_parms.lines++; m_parms.lines++;
if ( width > m_parms.totalWidth ) if( width > m_parms.totalWidth )
m_parms.totalWidth = width; m_parms.totalWidth = width;
width = 0; width = 0;
} }
@ -272,8 +265,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
length++; length++;
} }
m_parms.length = length; m_parms.length = length;
m_parms.totalHeight = (m_parms.lines * gHUD.m_scrinfo.iCharHeight); m_parms.totalHeight = ( m_parms.lines * gHUD.m_scrinfo.iCharHeight );
m_parms.y = YPosition( pMessage->y, m_parms.totalHeight ); m_parms.y = YPosition( pMessage->y, m_parms.totalHeight );
pText = pMessage->pMessage; pText = pMessage->pMessage;
@ -282,11 +274,11 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
MessageScanStart(); MessageScanStart();
for ( i = 0; i < m_parms.lines; i++ ) for( i = 0; i < m_parms.lines; i++ )
{ {
m_parms.lineLength = 0; m_parms.lineLength = 0;
m_parms.width = 0; m_parms.width = 0;
while ( *pText && *pText != '\n' ) while( *pText && *pText != '\n' )
{ {
unsigned char c = *pText; unsigned char c = *pText;
line[m_parms.lineLength] = c; line[m_parms.lineLength] = c;
@ -299,13 +291,13 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
m_parms.x = XPosition( pMessage->x, m_parms.width, m_parms.totalWidth ); m_parms.x = XPosition( pMessage->x, m_parms.width, m_parms.totalWidth );
for ( j = 0; j < m_parms.lineLength; j++ ) for( j = 0; j < m_parms.lineLength; j++ )
{ {
m_parms.text = line[j]; m_parms.text = line[j];
int next = m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]; int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text];
MessageScanNextChar(); MessageScanNextChar();
if ( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth ) if( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth )
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b ); TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b );
m_parms.x = next; m_parms.x = next;
} }
@ -314,7 +306,6 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
} }
} }
int CHudMessage::Draw( float fTime ) int CHudMessage::Draw( float fTime )
{ {
int i, drawn; int i, drawn;
@ -323,53 +314,52 @@ int CHudMessage::Draw( float fTime )
drawn = 0; drawn = 0;
if ( m_gameTitleTime > 0 ) if( m_gameTitleTime > 0 )
{ {
float localTime = gHUD.m_flTime - m_gameTitleTime; float localTime = gHUD.m_flTime - m_gameTitleTime;
float brightness; float brightness;
// Maybe timer isn't set yet // Maybe timer isn't set yet
if ( m_gameTitleTime > gHUD.m_flTime ) if( m_gameTitleTime > gHUD.m_flTime )
m_gameTitleTime = gHUD.m_flTime; m_gameTitleTime = gHUD.m_flTime;
if ( localTime > (m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout) ) if( localTime > ( m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout ) )
m_gameTitleTime = 0; m_gameTitleTime = 0;
else else
{ {
brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime ); brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime );
int halfWidth = gHUD.GetSpriteRect(m_HUD_title_half).right - gHUD.GetSpriteRect(m_HUD_title_half).left; int halfWidth = gHUD.GetSpriteRect( m_HUD_title_half ).right - gHUD.GetSpriteRect( m_HUD_title_half ).left;
int fullWidth = halfWidth + gHUD.GetSpriteRect(m_HUD_title_life).right - gHUD.GetSpriteRect(m_HUD_title_life).left; int fullWidth = halfWidth + gHUD.GetSpriteRect( m_HUD_title_life ).right - gHUD.GetSpriteRect( m_HUD_title_life ).left;
int fullHeight = gHUD.GetSpriteRect(m_HUD_title_half).bottom - gHUD.GetSpriteRect(m_HUD_title_half).top; int fullHeight = gHUD.GetSpriteRect( m_HUD_title_half ).bottom - gHUD.GetSpriteRect( m_HUD_title_half ).top;
int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth ); int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth );
int y = YPosition( m_pGameTitle->y, fullHeight ); int y = YPosition( m_pGameTitle->y, fullHeight );
SPR_Set( gHUD.GetSprite( m_HUD_title_half ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_title_half ) );
SPR_Set( gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); SPR_Set( gHUD.GetSprite( m_HUD_title_life ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half) ); SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect( m_HUD_title_life ) );
SPR_Set( gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life) );
drawn = 1; drawn = 1;
} }
} }
// Fixup level transitions // Fixup level transitions
for ( i = 0; i < maxHUDMessages; i++ ) for( i = 0; i < maxHUDMessages; i++ )
{ {
// Assume m_parms.time contains last time // Assume m_parms.time contains last time
if ( m_pMessages[i] ) if( m_pMessages[i] )
{ {
pMessage = m_pMessages[i]; pMessage = m_pMessages[i];
if ( m_startTime[i] > gHUD.m_flTime ) if( m_startTime[i] > gHUD.m_flTime )
m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this
} }
} }
for ( i = 0; i < maxHUDMessages; i++ ) for( i = 0; i < maxHUDMessages; i++ )
{ {
if ( m_pMessages[i] ) if( m_pMessages[i] )
{ {
pMessage = m_pMessages[i]; pMessage = m_pMessages[i];
@ -383,11 +373,11 @@ int CHudMessage::Draw( float fTime )
// Fade in is per character in scanning messages // Fade in is per character in scanning messages
case 2: case 2:
endTime = m_startTime[i] + (pMessage->fadein * strlen( pMessage->pMessage )) + pMessage->fadeout + pMessage->holdtime; endTime = m_startTime[i] + ( pMessage->fadein * strlen( pMessage->pMessage ) ) + pMessage->fadeout + pMessage->holdtime;
break; break;
} }
if ( fTime <= endTime ) if( fTime <= endTime )
{ {
float messageTime = fTime - m_startTime[i]; float messageTime = fTime - m_startTime[i];
@ -410,29 +400,28 @@ int CHudMessage::Draw( float fTime )
// Remember the time -- to fix up level transitions // Remember the time -- to fix up level transitions
m_parms.time = gHUD.m_flTime; m_parms.time = gHUD.m_flTime;
// Don't call until we get another message // Don't call until we get another message
if ( !drawn ) if( !drawn )
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
} }
void CHudMessage::MessageAdd( const char *pName, float time ) void CHudMessage::MessageAdd( const char *pName, float time )
{ {
int i,j; int i, j;
client_textmessage_t *tempMessage; client_textmessage_t *tempMessage;
for ( i = 0; i < maxHUDMessages; i++ ) for( i = 0; i < maxHUDMessages; i++ )
{ {
if ( !m_pMessages[i] ) if( !m_pMessages[i] )
{ {
// Trim off a leading # if it's there // Trim off a leading # if it's there
if ( pName[0] == '#' ) if( pName[0] == '#' )
tempMessage = TextMessageGet( pName+1 ); tempMessage = TextMessageGet( pName + 1 );
else else
tempMessage = TextMessageGet( pName ); tempMessage = TextMessageGet( pName );
// If we couldnt find it in the titles.txt, just create it // If we couldnt find it in the titles.txt, just create it
if ( !tempMessage ) if( !tempMessage )
{ {
g_pCustomMessage.effect = 2; g_pCustomMessage.effect = 2;
g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100; g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100;
@ -453,18 +442,18 @@ void CHudMessage::MessageAdd( const char *pName, float time )
tempMessage = &g_pCustomMessage; tempMessage = &g_pCustomMessage;
} }
for ( j = 0; j < maxHUDMessages; j++ ) for( j = 0; j < maxHUDMessages; j++ )
{ {
if ( m_pMessages[j] ) if( m_pMessages[j] )
{ {
// is this message already in the list // is this message already in the list
if ( !strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) ) if( !strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) )
{ {
return; return;
} }
// get rid of any other messages in same location (only one displays at a time) // get rid of any other messages in same location (only one displays at a time)
if ( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 ) if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 )
{ {
if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 ) if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 )
{ {
@ -481,7 +470,6 @@ void CHudMessage::MessageAdd( const char *pName, float time )
} }
} }
int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -489,48 +477,47 @@ int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
char *pString = READ_STRING(); char *pString = READ_STRING();
MessageAdd( pString, gHUD.m_flTime ); MessageAdd( pString, gHUD.m_flTime );
// Remember the time -- to fix up level transitions // Remember the time -- to fix up level transitions
m_parms.time = gHUD.m_flTime; m_parms.time = gHUD.m_flTime;
// Turn on drawing // Turn on drawing
if ( !(m_iFlags & HUD_ACTIVE) ) if( !( m_iFlags & HUD_ACTIVE ) )
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
return 1; return 1;
} }
int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf ) int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf )
{ {
m_pGameTitle = TextMessageGet( "GAMETITLE" ); m_pGameTitle = TextMessageGet( "GAMETITLE" );
if ( m_pGameTitle != NULL ) if( m_pGameTitle != NULL )
{ {
m_gameTitleTime = gHUD.m_flTime; m_gameTitleTime = gHUD.m_flTime;
// Turn on drawing // Turn on drawing
if ( !(m_iFlags & HUD_ACTIVE) ) if( !( m_iFlags & HUD_ACTIVE ) )
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
} }
return 1; return 1;
} }
void CHudMessage::MessageAdd(client_textmessage_t * newMessage ) void CHudMessage::MessageAdd( client_textmessage_t * newMessage )
{ {
m_parms.time = gHUD.m_flTime; m_parms.time = gHUD.m_flTime;
// Turn on drawing // Turn on drawing
if ( !(m_iFlags & HUD_ACTIVE) ) if( !( m_iFlags & HUD_ACTIVE ) )
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
for ( int i = 0; i < maxHUDMessages; i++ ) for( int i = 0; i < maxHUDMessages; i++ )
{ {
if ( !m_pMessages[i] ) if( !m_pMessages[i] )
{ {
m_pMessages[i] = newMessage; m_pMessages[i] = newMessage;
m_startTime[i] = gHUD.m_flTime; m_startTime[i] = gHUD.m_flTime;
return; return;
} }
} }
} }

View File

@ -34,8 +34,8 @@ int CHudOverview::Init()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int CHudOverview::VidInit() int CHudOverview::VidInit()
{ {
m_hsprPlayer = gEngfuncs.pfnSPR_Load("sprites/ring.spr"); m_hsprPlayer = gEngfuncs.pfnSPR_Load( "sprites/ring.spr" );
m_hsprViewcone = gEngfuncs.pfnSPR_Load("sprites/camera.spr"); m_hsprViewcone = gEngfuncs.pfnSPR_Load( "sprites/camera.spr" );
return 1; return 1;
} }
@ -45,42 +45,42 @@ int CHudOverview::VidInit()
// Input : flTime - // Input : flTime -
// intermission - // intermission -
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int CHudOverview::Draw(float flTime) int CHudOverview::Draw( float flTime )
{ {
#if 0 #if 0
// only draw in overview mode // only draw in overview mode
if (!gEngfuncs.Overview_GetOverviewState()) if( !gEngfuncs.Overview_GetOverviewState() )
return 1; return 1;
// make sure we have player info // make sure we have player info
// gViewPort->GetAllPlayersInfo(); //gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo();
// calculate player size on the overview // calculate player size on the overview
int x1, y1, x2, y2; int x1, y1, x2, y2;
float v0[3]={0,0,0}, v1[3]={64,64,0}; float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f };
gEngfuncs.Overview_WorldToScreen(v0, &x1, &y1); gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 );
gEngfuncs.Overview_WorldToScreen(v1, &x2, &y2); gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 );
float scale = abs(x2 - x1); float scale = abs( x2 - x1 );
// loop through all the players and draw them on the map // loop through all the players and draw them on the map
for (int i = 1; i < MAX_PLAYERS; i++) for( int i = 1; i < MAX_PLAYERS; i++ )
{ {
cl_entity_t *pl = gEngfuncs.GetEntityByIndex(i); cl_entity_t *pl = gEngfuncs.GetEntityByIndex( i );
if (pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT) if( pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT )
{ {
int x, y, z = 0; int x, y, z = 0;
float v[3]={pl->origin[0], pl->origin[1], 0}; float v[3] = { pl->origin[0], pl->origin[1], 0 };
gEngfuncs.Overview_WorldToScreen(v, &x, &y); gEngfuncs.Overview_WorldToScreen( v, &x, &y );
// hack in some team colors // hack in some team colors
float r, g, bc; float r, g, bc;
if (g_PlayerExtraInfo[i].teamnumber == 1) if( g_PlayerExtraInfo[i].teamnumber == 1 )
{ {
r = 0.0f; g = 0.0f; bc = 1.0f; r = 0.0f; g = 0.0f; bc = 1.0f;
} }
else if (g_PlayerExtraInfo[i].teamnumber == 2) else if( g_PlayerExtraInfo[i].teamnumber == 2 )
{ {
r = 1.0f; g = 0.0f; bc = 0.0f; r = 1.0f; g = 0.0f; bc = 0.0f;
} }
@ -91,50 +91,50 @@ int CHudOverview::Draw(float flTime)
} }
// set the current texture // set the current texture
gEngfuncs.pTriAPI->SpriteTexture((struct model_s *)gEngfuncs.GetSpritePointer(m_hsprPlayer), 0); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprPlayer ), 0 );
// additive render mode // additive render mode
gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
// no culling // no culling
gEngfuncs.pTriAPI->CullFace(TRI_NONE); gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// draw a square // draw a square
gEngfuncs.pTriAPI->Begin(TRI_QUADS); gEngfuncs.pTriAPI->Begin( TRI_QUADS );
// set the color to be that of the team // set the color to be that of the team
gEngfuncs.pTriAPI->Color4f(r, g, bc, 1.0f); gEngfuncs.pTriAPI->Color4f( r, g, bc, 1.0f );
// calculate rotational matrix // calculate rotational matrix
vec3_t a, b, angles; vec3_t a, b, angles;
float rmatrix[3][4]; // transformation matrix float rmatrix[3][4]; // transformation matrix
VectorCopy(pl->angles, angles); VectorCopy( pl->angles, angles );
angles[0] = 0.0f; angles[0] = 0.0f;
angles[1] += 90.f; angles[1] += 90.f;
angles[1] = -angles[1]; angles[1] = -angles[1];
angles[2] = 0.0f; angles[2] = 0.0f;
AngleMatrix(angles, rmatrix); AngleMatrix( angles, rmatrix );
a[2] = 0; a[2] = 0;
a[0] = -scale; a[1] = -scale; a[0] = -scale; a[1] = -scale;
VectorTransform(a, rmatrix , b ); VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f(x + b[0], y + b[1], z); gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
a[0]=-scale; a[1] = scale; a[0] = -scale; a[1] = scale;
VectorTransform(a, rmatrix , b ); VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z); gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
a[0]=scale; a[1] = scale; a[0] = scale; a[1] = scale;
VectorTransform(a, rmatrix , b ); VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z); gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
a[0]=scale; a[1] = -scale; a[0] = scale; a[1] = -scale;
VectorTransform(a, rmatrix , b ); VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z); gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
// finish up // finish up
gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->End();
@ -142,11 +142,10 @@ int CHudOverview::Draw(float flTime)
// draw the players name and health underneath // draw the players name and health underneath
char string[256]; char string[256];
sprintf(string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health); sprintf( string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health );
DrawConsoleString(x, y + (1.1 * scale), string); DrawConsoleString( x, y + ( 1.1 * scale ), string );
} }
} }
#endif #endif
return 1; return 1;
} }
@ -156,8 +155,7 @@ int CHudOverview::Draw(float flTime)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CHudOverview::InitHUDData() void CHudOverview::InitHUDData()
{ {
// this block would force the spectator view to be on //this block would force the spectator view to be on
// gEngfuncs.Overview_SetDrawOverview( 1 ); //gEngfuncs.Overview_SetDrawOverview( 1 );
// gEngfuncs.Overview_SetDrawInset( 0 ); //gEngfuncs.Overview_SetDrawInset( 0 );
} }

View File

@ -9,7 +9,6 @@
#define OVERVIEW_H #define OVERVIEW_H
#pragma once #pragma once
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Handles the drawing of the top-down map and all the things on it // Purpose: Handles the drawing of the top-down map and all the things on it
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -19,13 +18,11 @@ public:
int Init(); int Init();
int VidInit(); int VidInit();
int Draw(float flTime); int Draw( float flTime );
void InitHUDData( void ); void InitHUDData( void );
private: private:
HSPRITE m_hsprPlayer; HSPRITE m_hsprPlayer;
HSPRITE m_hsprViewcone; HSPRITE m_hsprViewcone;
}; };
#endif // OVERVIEW_H #endif // OVERVIEW_H

View File

@ -15,6 +15,7 @@
// //
// parsemsg.cpp // parsemsg.cpp
// //
typedef unsigned char byte; typedef unsigned char byte;
#define true 1 #define true 1
@ -31,12 +32,11 @@ void BEGIN_READ( void *buf, int size )
gpBuf = (byte*)buf; gpBuf = (byte*)buf;
} }
int READ_CHAR( void ) int READ_CHAR( void )
{ {
int c; int c;
if (giRead + 1 > giSize) if( giRead + 1 > giSize )
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
@ -52,7 +52,7 @@ int READ_BYTE( void )
{ {
int c; int c;
if (giRead+1 > giSize) if( giRead + 1 > giSize )
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
@ -68,13 +68,13 @@ int READ_SHORT( void )
{ {
int c; int c;
if (giRead+2 > giSize) if( giRead + 2 > giSize )
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); c = (short)( gpBuf[giRead] + ( gpBuf[giRead + 1] << 8 ) );
giRead += 2; giRead += 2;
@ -86,18 +86,17 @@ int READ_WORD( void )
return READ_SHORT(); return READ_SHORT();
} }
int READ_LONG( void ) int READ_LONG( void )
{ {
int c; int c;
if (giRead+4 > giSize) if( giRead + 4 > giSize )
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); c = gpBuf[giRead] + ( gpBuf[giRead + 1] << 8 ) + ( gpBuf[giRead + 2] << 16 ) + ( gpBuf[giRead + 3] << 24 );
giRead += 4; giRead += 4;
@ -114,12 +113,12 @@ float READ_FLOAT( void )
} dat; } dat;
dat.b[0] = gpBuf[giRead]; dat.b[0] = gpBuf[giRead];
dat.b[1] = gpBuf[giRead+1]; dat.b[1] = gpBuf[giRead + 1];
dat.b[2] = gpBuf[giRead+2]; dat.b[2] = gpBuf[giRead + 2];
dat.b[3] = gpBuf[giRead+3]; dat.b[3] = gpBuf[giRead + 3];
giRead += 4; giRead += 4;
// dat.l = LittleLong (dat.l); //dat.l = LittleLong( dat.l );
return dat.f; return dat.f;
} }
@ -127,22 +126,22 @@ float READ_FLOAT( void )
char* READ_STRING( void ) char* READ_STRING( void )
{ {
static char string[2048]; static char string[2048];
int l,c; int l, c;
string[0] = 0; string[0] = 0;
l = 0; l = 0;
do do
{ {
if ( giRead+1 > giSize ) if( giRead+1 > giSize )
break; // no more characters break; // no more characters
c = READ_BYTE(); c = READ_BYTE();
if (c == -1 || c == 0) if( c == -1 || c == 0 )
break; break;
string[l] = c; string[l] = c;
l++; l++;
} while (l < sizeof(string)-1); }while( l < sizeof(string) - 1 );
string[l] = 0; string[l] = 0;
@ -151,16 +150,15 @@ char* READ_STRING( void )
float READ_COORD( void ) float READ_COORD( void )
{ {
return (float)(READ_SHORT() * (1.0/8)); return (float)( READ_SHORT() * ( 1.0 / 8 ) );
} }
float READ_ANGLE( void ) float READ_ANGLE( void )
{ {
return (float)(READ_CHAR() * (360.0/256)); return (float)( READ_CHAR() * ( 360.0 / 256 ) );
} }
float READ_HIRESANGLE( void ) float READ_HIRESANGLE( void )
{ {
return (float)(READ_SHORT() * (360.0/65536)); return (float)( READ_SHORT() * ( 360.0 / 65536 ) );
} }

View File

@ -25,7 +25,6 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
extern float *GetClientColor( int clientIndex ); extern float *GetClientColor( int clientIndex );
#define MAX_LINES 5 #define MAX_LINES 5
@ -36,17 +35,17 @@ extern float *GetClientColor( int clientIndex );
#define LINE_START 10 #define LINE_START 10
static float SCROLL_SPEED = 5; static float SCROLL_SPEED = 5;
static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ]; static char g_szLineBuffer[MAX_LINES + 1][MAX_CHARS_PER_LINE];
static float *g_pflNameColors[ MAX_LINES + 1 ]; static float *g_pflNameColors[MAX_LINES + 1];
static int g_iNameLengths[ MAX_LINES + 1 ]; static int g_iNameLengths[MAX_LINES + 1];
static float flScrollTime = 0; // the time at which the lines next scroll up static float flScrollTime = 0; // the time at which the lines next scroll up
static int Y_START = 0; static int Y_START = 0;
static int line_height = 0; static int line_height = 0;
DECLARE_MESSAGE( m_SayText, SayText ); DECLARE_MESSAGE( m_SayText, SayText )
int CHudSayText :: Init( void ) int CHudSayText::Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
@ -62,20 +61,18 @@ int CHudSayText :: Init( void )
return 1; return 1;
} }
void CHudSayText::InitHUDData( void )
void CHudSayText :: InitHUDData( void )
{ {
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer ); memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
memset( g_pflNameColors, 0, sizeof g_pflNameColors ); memset( g_pflNameColors, 0, sizeof g_pflNameColors );
memset( g_iNameLengths, 0, sizeof g_iNameLengths ); memset( g_iNameLengths, 0, sizeof g_iNameLengths );
} }
int CHudSayText :: VidInit( void ) int CHudSayText::VidInit( void )
{ {
return 1; return 1;
} }
int ScrollTextUp( void ) int ScrollTextUp( void )
{ {
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
@ -85,7 +82,7 @@ int ScrollTextUp( void )
memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) ); memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) );
g_szLineBuffer[MAX_LINES-1][0] = 0; g_szLineBuffer[MAX_LINES-1][0] = 0;
if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines if( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines
{ {
g_szLineBuffer[0][0] = 2; g_szLineBuffer[0][0] = 2;
return 1 + ScrollTextUp(); return 1 + ScrollTextUp();
@ -94,7 +91,7 @@ int ScrollTextUp( void )
return 1; return 1;
} }
int CHudSayText :: Draw( float flTime ) int CHudSayText::Draw( float flTime )
{ {
int y = Y_START; int y = Y_START;
@ -104,32 +101,33 @@ int CHudSayText :: Draw( float flTime )
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value ); flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
if ( flScrollTime <= flTime ) if( flScrollTime <= flTime )
{ {
if ( *g_szLineBuffer[0] ) if( *g_szLineBuffer[0] )
{ {
flScrollTime = flTime + m_HUD_saytext_time->value; flScrollTime = flTime + m_HUD_saytext_time->value;
// push the console up // push the console up
ScrollTextUp(); ScrollTextUp();
} }
else else
{ // buffer is empty, just disable drawing of this section {
// buffer is empty, just disable drawing of this section
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
} }
} }
for ( int i = 0; i < MAX_LINES; i++ ) for( int i = 0; i < MAX_LINES; i++ )
{ {
if ( *g_szLineBuffer[i] ) if( *g_szLineBuffer[i] )
{ {
if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] ) if( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] )
{ {
// it's a saytext string // it's a saytext string
static char buf[MAX_PLAYER_NAME_LENGTH+32]; static char buf[MAX_PLAYER_NAME_LENGTH + 32];
// draw the first x characters in the player color // draw the first x characters in the player color
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) ); strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32 ) );
buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0; buf[min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 )] = 0;
DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] ); DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
int x = DrawConsoleString( LINE_START, y, buf ); int x = DrawConsoleString( LINE_START, y, buf );
@ -146,11 +144,10 @@ int CHudSayText :: Draw( float flTime )
y += line_height; y += line_height;
} }
return 1; return 1;
} }
int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) int CHudSayText::MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
@ -160,18 +157,18 @@ int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
return 1; return 1;
} }
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{ {
int i; int i;
ConsolePrint( pszBuf ); ConsolePrint( pszBuf );
// find an empty string slot // find an empty string slot
for ( i = 0; i < MAX_LINES; i++ ) for( i = 0; i < MAX_LINES; i++ )
{ {
if ( ! *g_szLineBuffer[i] ) if( !( *g_szLineBuffer[i] ) )
break; break;
} }
if ( i == MAX_LINES ) if( i == MAX_LINES )
{ {
// force scroll buffer up // force scroll buffer up
ScrollTextUp(); ScrollTextUp();
@ -182,30 +179,30 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
g_pflNameColors[i] = NULL; g_pflNameColors[i] = NULL;
// if it's a say message, search for the players name in the string // if it's a say message, search for the players name in the string
if ( *pszBuf == 2 && clientIndex > 0 ) if( *pszBuf == 2 && clientIndex > 0 )
{ {
GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] ); GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] );
const char *pName = g_PlayerInfoList[clientIndex].name; const char *pName = g_PlayerInfoList[clientIndex].name;
if ( pName ) if( pName )
{ {
const char *nameInString = strstr( pszBuf, pName ); const char *nameInString = strstr( pszBuf, pName );
if ( nameInString ) if( nameInString )
{ {
g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf); g_iNameLengths[i] = strlen( pName ) + ( nameInString - pszBuf );
g_pflNameColors[i] = GetClientColor( clientIndex ); g_pflNameColors[i] = GetClientColor( clientIndex );
} }
} }
} }
strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) ); strncpy( g_szLineBuffer[i], pszBuf, max( iBufSize - 1, MAX_CHARS_PER_LINE - 1 ) );
// make sure the text fits in one line // make sure the text fits in one line
EnsureTextFitsInOneLineAndWrapIfHaveTo( i ); EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
// Set scroll time // Set scroll time
if ( i == 0 ) if( i == 0 )
{ {
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value; flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
} }
@ -213,56 +210,57 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
PlaySound( "misc/talk.wav", 1 ); PlaySound( "misc/talk.wav", 1 );
if ( ScreenHeight >= 480 ) if( ScreenHeight >= 480 )
Y_START = ScreenHeight - 60; Y_START = ScreenHeight - 60;
else else
Y_START = ScreenHeight - 45; Y_START = ScreenHeight - 45;
Y_START -= (line_height * (MAX_LINES+1)); Y_START -= ( line_height * ( MAX_LINES + 1 ) );
} }
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) void CHudSayText::EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
{ {
int line_width = 0; int line_width = 0;
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height ); GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
if ( (line_width + LINE_START) > MAX_LINE_WIDTH ) if( ( line_width + LINE_START ) > MAX_LINE_WIDTH )
{ // string is too long to fit on line {
// string is too long to fit on line
// scan the string until we find what word is too long, and wrap the end of the sentence after the word // scan the string until we find what word is too long, and wrap the end of the sentence after the word
int length = LINE_START; int length = LINE_START;
int tmp_len = 0; int tmp_len = 0;
char *last_break = NULL; char *last_break = NULL;
for ( char *x = g_szLineBuffer[line]; *x != 0; x++ ) for( char *x = g_szLineBuffer[line]; *x != 0; x++ )
{ {
// check for a color change, if so skip past it // check for a color change, if so skip past it
if ( x[0] == '/' && x[1] == '(' ) if( x[0] == '/' && x[1] == '(' )
{ {
x += 2; x += 2;
// skip forward until past mode specifier // skip forward until past mode specifier
while ( *x != 0 && *x != ')' ) while ( *x != 0 && *x != ')' )
x++; x++;
if ( *x != 0 ) if( *x != 0 )
x++; x++;
if ( *x == 0 ) if( *x == 0 )
break; break;
} }
char buf[2]; char buf[2];
buf[1] = 0; buf[1] = 0;
if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character if( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character
last_break = x; last_break = x;
buf[0] = *x; // get the length of the current character buf[0] = *x; // get the length of the current character
GetConsoleStringSize( buf, &tmp_len, &line_height ); GetConsoleStringSize( buf, &tmp_len, &line_height );
length += tmp_len; length += tmp_len;
if ( length > MAX_LINE_WIDTH ) if( length > MAX_LINE_WIDTH )
{ // needs to be broken up {
if ( !last_break ) // needs to be broken up
last_break = x-1; if( !last_break )
last_break = x - 1;
x = last_break; x = last_break;
@ -270,33 +268,33 @@ void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
int j; int j;
do do
{ {
for ( j = 0; j < MAX_LINES; j++ ) for( j = 0; j < MAX_LINES; j++ )
{ {
if ( ! *g_szLineBuffer[j] ) if( !( *g_szLineBuffer[j] ) )
break; break;
} }
if ( j == MAX_LINES ) if( j == MAX_LINES )
{ {
// need to make more room to display text, scroll stuff up then fix the pointers // need to make more room to display text, scroll stuff up then fix the pointers
int linesmoved = ScrollTextUp(); int linesmoved = ScrollTextUp();
line -= linesmoved; line -= linesmoved;
last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved); last_break = last_break - ( sizeof(g_szLineBuffer[0]) * linesmoved );
} }
} }
while ( j == MAX_LINES ); while( j == MAX_LINES );
// copy remaining string into next buffer, making sure it starts with a space character // copy remaining string into next buffer, making sure it starts with a space character
if ( (char)*last_break == (char)' ' ) if( (char)*last_break == (char)' ' )
{ {
int linelen = strlen(g_szLineBuffer[j]); int linelen = strlen( g_szLineBuffer[j] );
int remaininglen = strlen(last_break); int remaininglen = strlen( last_break );
if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE ) if( ( linelen - remaininglen ) <= MAX_CHARS_PER_LINE )
strcat( g_szLineBuffer[j], last_break ); strcat( g_szLineBuffer[j], last_break );
} }
else else
{ {
if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE ) if ( ( strlen( g_szLineBuffer[j] ) - strlen( last_break ) - 2 ) < MAX_CHARS_PER_LINE )
{ {
strcat( g_szLineBuffer[j], " " ); strcat( g_szLineBuffer[j], " " );
strcat( g_szLineBuffer[j], last_break ); strcat( g_szLineBuffer[j], last_break );

View File

@ -27,9 +27,9 @@
#include <stdio.h> #include <stdio.h>
cvar_t *cl_showpacketloss; cvar_t *cl_showpacketloss;
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll
team_info_t g_TeamInfo[MAX_TEAMS+1]; team_info_t g_TeamInfo[MAX_TEAMS + 1];
int g_iUser1; int g_iUser1;
int g_iUser2; int g_iUser2;
int g_iUser3; int g_iUser3;
@ -38,14 +38,14 @@ int g_iPlayerClass;
//#include "vgui_TeamFortressViewport.h" //#include "vgui_TeamFortressViewport.h"
DECLARE_COMMAND( m_Scoreboard, ShowScores ); DECLARE_COMMAND( m_Scoreboard, ShowScores )
DECLARE_COMMAND( m_Scoreboard, HideScores ); DECLARE_COMMAND( m_Scoreboard, HideScores )
DECLARE_MESSAGE( m_Scoreboard, ScoreInfo ); DECLARE_MESSAGE( m_Scoreboard, ScoreInfo )
DECLARE_MESSAGE( m_Scoreboard, TeamInfo ); DECLARE_MESSAGE( m_Scoreboard, TeamInfo )
DECLARE_MESSAGE( m_Scoreboard, TeamScore ); DECLARE_MESSAGE( m_Scoreboard, TeamScore )
int CHudScoreboard :: Init( void ) int CHudScoreboard::Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
@ -64,14 +64,13 @@ int CHudScoreboard :: Init( void )
return 1; return 1;
} }
int CHudScoreboard::VidInit( void )
int CHudScoreboard :: VidInit( void )
{ {
// Load sprites here // Load sprites here
return 1; return 1;
} }
void CHudScoreboard :: InitHUDData( void ) void CHudScoreboard::InitHUDData( void )
{ {
memset( g_PlayerExtraInfo, 0, sizeof g_PlayerExtraInfo ); memset( g_PlayerExtraInfo, 0, sizeof g_PlayerExtraInfo );
m_iLastKilledBy = 0; m_iLastKilledBy = 0;
@ -105,19 +104,18 @@ We have a minimum width of 1-320 - we could have the field widths scale with it?
int SCOREBOARD_WIDTH = 320; int SCOREBOARD_WIDTH = 320;
// Y positions // Y positions
#define ROW_GAP 13 #define ROW_GAP 13
#define ROW_RANGE_MIN 15 #define ROW_RANGE_MIN 15
#define ROW_RANGE_MAX ( ScreenHeight - 50 ) #define ROW_RANGE_MAX ( ScreenHeight - 50 )
int CHudScoreboard :: Draw( float fTime ) int CHudScoreboard::Draw( float fTime )
{ {
int i, j, can_show_packetloss = 0; int i, j, can_show_packetloss = 0;
int FAR_RIGHT; int FAR_RIGHT;
gHUD.m_iNoConsolePrint &= ~( 1 << 0 ); gHUD.m_iNoConsolePrint &= ~( 1 << 0 );
if ( !m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission ) if( !m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission )
return 1; return 1;
gHUD.m_iNoConsolePrint |= 1 << 0; gHUD.m_iNoConsolePrint |= 1 << 0;
@ -125,7 +123,7 @@ int CHudScoreboard :: Draw( float fTime )
GetAllPlayersInfo(); GetAllPlayersInfo();
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders // Packetloss removed on Kelly 'shipping nazi' Bailey's orders
if ( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) )
{ {
can_show_packetloss = 1; can_show_packetloss = 1;
SCOREBOARD_WIDTH = 400; SCOREBOARD_WIDTH = 400;
@ -138,16 +136,16 @@ int CHudScoreboard :: Draw( float fTime )
// just sort the list on the fly // just sort the list on the fly
// list is sorted first by frags, then by deaths // list is sorted first by frags, then by deaths
float list_slot = 0; float list_slot = 0;
int xpos_rel = (ScreenWidth - SCOREBOARD_WIDTH) / 2; int xpos_rel = ( ScreenWidth - SCOREBOARD_WIDTH ) / 2;
// print the heading line // print the heading line
int ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); int ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP );
int xpos = NAME_RANGE_MIN + xpos_rel; int xpos = NAME_RANGE_MIN + xpos_rel;
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
FAR_RIGHT += 5; FAR_RIGHT += 5;
gHUD.DrawDarkRectangle(xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX); gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX );
if ( !gHUD.m_Teamplay ) if( !gHUD.m_Teamplay )
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 );
else else
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 );
@ -157,20 +155,19 @@ int CHudScoreboard :: Draw( float fTime )
gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 );
gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 );
if ( can_show_packetloss ) if( can_show_packetloss )
{ {
gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 );
} }
list_slot += 1.2; list_slot += 1.2;
ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP );
xpos = NAME_RANGE_MIN + xpos_rel; xpos = NAME_RANGE_MIN + xpos_rel;
FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255); // draw the seperator line FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line
list_slot += 0.8; list_slot += 0.8;
if ( !gHUD.m_Teamplay ) if( !gHUD.m_Teamplay )
{ {
// it's not teamplay, so just draw a simple player list // it's not teamplay, so just draw a simple player list
DrawPlayers( xpos_rel, list_slot ); DrawPlayers( xpos_rel, list_slot );
@ -178,32 +175,32 @@ int CHudScoreboard :: Draw( float fTime )
} }
// clear out team scores // clear out team scores
for ( i = 1; i <= m_iNumTeams; i++ ) for( i = 1; i <= m_iNumTeams; i++ )
{ {
if ( !g_TeamInfo[i].scores_overriden ) if( !g_TeamInfo[i].scores_overriden )
g_TeamInfo[i].frags = g_TeamInfo[i].deaths = 0; g_TeamInfo[i].frags = g_TeamInfo[i].deaths = 0;
g_TeamInfo[i].ping = g_TeamInfo[i].packetloss = 0; g_TeamInfo[i].ping = g_TeamInfo[i].packetloss = 0;
} }
// recalc the team scores, then draw them // recalc the team scores, then draw them
for ( i = 1; i < MAX_PLAYERS; i++ ) for( i = 1; i < MAX_PLAYERS; i++ )
{ {
//if ( g_PlayerInfoList[i].name == NULL ) //if( g_PlayerInfoList[i].name == NULL )
// continue; // empty player slot, skip // continue; // empty player slot, skip
if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) if( g_PlayerExtraInfo[i].teamname[0] == 0 )
continue; // skip over players who are not in a team continue; // skip over players who are not in a team
// find what team this player is in // find what team this player is in
for ( j = 1; j <= m_iNumTeams; j++ ) for( j = 1; j <= m_iNumTeams; j++ )
{ {
if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) if( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) )
break; break;
} }
if ( j > m_iNumTeams ) // player is not in a team, skip to the next guy if( j > m_iNumTeams ) // player is not in a team, skip to the next guy
continue; continue;
if ( !g_TeamInfo[j].scores_overriden ) if( !g_TeamInfo[j].scores_overriden )
{ {
g_TeamInfo[j].frags += g_PlayerExtraInfo[i].frags; g_TeamInfo[j].frags += g_PlayerExtraInfo[i].frags;
g_TeamInfo[j].deaths += g_PlayerExtraInfo[i].deaths; g_TeamInfo[j].deaths += g_PlayerExtraInfo[i].deaths;
@ -212,18 +209,18 @@ int CHudScoreboard :: Draw( float fTime )
g_TeamInfo[j].ping += g_PlayerInfoList[i].ping; g_TeamInfo[j].ping += g_PlayerInfoList[i].ping;
g_TeamInfo[j].packetloss += g_PlayerInfoList[i].packetloss; g_TeamInfo[j].packetloss += g_PlayerInfoList[i].packetloss;
if ( g_PlayerInfoList[i].thisplayer ) if( g_PlayerInfoList[i].thisplayer )
g_TeamInfo[j].ownteam = TRUE; g_TeamInfo[j].ownteam = TRUE;
else else
g_TeamInfo[j].ownteam = FALSE; g_TeamInfo[j].ownteam = FALSE;
} }
// find team ping/packetloss averages // find team ping/packetloss averages
for ( i = 1; i <= m_iNumTeams; i++ ) for( i = 1; i <= m_iNumTeams; i++ )
{ {
g_TeamInfo[i].already_drawn = FALSE; g_TeamInfo[i].already_drawn = FALSE;
if ( g_TeamInfo[i].players > 0 ) if( g_TeamInfo[i].players > 0 )
{ {
g_TeamInfo[i].ping /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping g_TeamInfo[i].ping /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping
g_TeamInfo[i].packetloss /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping g_TeamInfo[i].packetloss /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping
@ -231,19 +228,19 @@ int CHudScoreboard :: Draw( float fTime )
} }
// Draw the teams // Draw the teams
while ( 1 ) while( 1 )
{ {
int highest_frags = -99999; int lowest_deaths = 99999; int highest_frags = -99999; int lowest_deaths = 99999;
int best_team = 0; int best_team = 0;
for ( i = 1; i <= m_iNumTeams; i++ ) for( i = 1; i <= m_iNumTeams; i++ )
{ {
if ( g_TeamInfo[i].players < 0 ) if( g_TeamInfo[i].players < 0 )
continue; continue;
if ( !g_TeamInfo[i].already_drawn && g_TeamInfo[i].frags >= highest_frags ) if( !g_TeamInfo[i].already_drawn && g_TeamInfo[i].frags >= highest_frags )
{ {
if ( g_TeamInfo[i].frags > highest_frags || g_TeamInfo[i].deaths < lowest_deaths ) if( g_TeamInfo[i].frags > highest_frags || g_TeamInfo[i].deaths < lowest_deaths )
{ {
best_team = i; best_team = i;
lowest_deaths = g_TeamInfo[i].deaths; lowest_deaths = g_TeamInfo[i].deaths;
@ -253,22 +250,22 @@ int CHudScoreboard :: Draw( float fTime )
} }
// draw the best team on the scoreboard // draw the best team on the scoreboard
if ( !best_team ) if( !best_team )
break; break;
// draw out the best team // draw out the best team
team_info_t *team_info = &g_TeamInfo[best_team]; team_info_t *team_info = &g_TeamInfo[best_team];
ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP );
// check we haven't drawn too far down // check we haven't drawn too far down
if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border if( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border
break; break;
xpos = NAME_RANGE_MIN + xpos_rel; xpos = NAME_RANGE_MIN + xpos_rel;
int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish
if ( team_info->ownteam ) // if it is their team, draw the background different color if( team_info->ownteam ) // if it is their team, draw the background different color
{ {
// overlay the background in blue, then draw the score text over it // overlay the background in blue, then draw the score text over it
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 );
@ -293,14 +290,14 @@ int CHudScoreboard :: Draw( float fTime )
// draw ping & packetloss // draw ping & packetloss
static char buf[64]; static char buf[64];
sprintf( buf, "%d", team_info->ping ); sprintf( buf, "%d", team_info->ping );
xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25; xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2) + PING_RANGE_MIN + xpos_rel + 25;
UnpackRGB( r, g, b, RGB_YELLOWISH ); UnpackRGB( r, g, b, RGB_YELLOWISH );
gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b ); gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b );
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders // Packetloss removed on Kelly 'shipping nazi' Bailey's orders
if ( can_show_packetloss ) if( can_show_packetloss )
{ {
xpos = ((PL_RANGE_MAX - PL_RANGE_MIN) / 2) + PL_RANGE_MIN + xpos_rel + 25; xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2) + PL_RANGE_MIN + xpos_rel + 25;
sprintf( buf, " %d", team_info->packetloss ); sprintf( buf, " %d", team_info->packetloss );
gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b );
@ -319,15 +316,17 @@ int CHudScoreboard :: Draw( float fTime )
return 1; return 1;
} }
extern float *GetClientColor( int client ); extern float *GetClientColor( int client );
// returns the ypos where it finishes drawing // returns the ypos where it finishes drawing
int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team ) int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team )
{ {
int can_show_packetloss = 0; int can_show_packetloss = 0;
int FAR_RIGHT; int FAR_RIGHT;
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders // Packetloss removed on Kelly 'shipping nazi' Bailey's orders
if ( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) )
{ {
can_show_packetloss = 1; can_show_packetloss = 1;
SCOREBOARD_WIDTH = 400; SCOREBOARD_WIDTH = 400;
@ -341,20 +340,21 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset
FAR_RIGHT += 5; FAR_RIGHT += 5;
// draw the players, in order, and restricted to team if set // draw the players, in order, and restricted to team if set
while ( 1 ) while( 1 )
{ {
// Find the top ranking player // Find the top ranking player
int highest_frags = -99999; int lowest_deaths = 99999; int highest_frags = -99999;
int lowest_deaths = 99999;
int best_player = 0; int best_player = 0;
for ( int i = 1; i < MAX_PLAYERS; i++ ) for( int i = 1; i < MAX_PLAYERS; i++ )
{ {
if ( g_PlayerInfoList[i].name && g_PlayerExtraInfo[i].frags >= highest_frags ) if( g_PlayerInfoList[i].name && g_PlayerExtraInfo[i].frags >= highest_frags )
{ {
if ( !(team && stricmp(g_PlayerExtraInfo[i].teamname, team)) ) // make sure it is the specified team if( !( team && stricmp( g_PlayerExtraInfo[i].teamname, team ) ) ) // make sure it is the specified team
{ {
extra_player_info_t *pl_info = &g_PlayerExtraInfo[i]; extra_player_info_t *pl_info = &g_PlayerExtraInfo[i];
if ( pl_info->frags > highest_frags || pl_info->deaths < lowest_deaths ) if( pl_info->frags > highest_frags || pl_info->deaths < lowest_deaths )
{ {
best_player = i; best_player = i;
lowest_deaths = pl_info->deaths; lowest_deaths = pl_info->deaths;
@ -364,34 +364,36 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset
} }
} }
if ( !best_player ) if( !best_player )
break; break;
// draw out the best player // draw out the best player
hud_player_info_t *pl_info = &g_PlayerInfoList[best_player]; hud_player_info_t *pl_info = &g_PlayerInfoList[best_player];
int ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); int ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP );
// check we haven't drawn too far down // check we haven't drawn too far down
if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border if( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border
break; break;
int xpos = NAME_RANGE_MIN + xpos_rel; int xpos = NAME_RANGE_MIN + xpos_rel;
int r = 255, g = 255, b = 255; int r = 255, g = 255, b = 255;
float *colors = GetClientColor( best_player ); float *colors = GetClientColor( best_player );
r *= colors[0], g *= colors[1], b *= colors[2]; r *= colors[0], g *= colors[1], b *= colors[2];
if ( best_player == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) if( best_player == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime )
{ {
if ( pl_info->thisplayer ) if( pl_info->thisplayer )
{ // green is the suicide color? i wish this could do grey... {
// green is the suicide color? i wish this could do grey...
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 );
} }
else else
{ // Highlight the killers name - overlay the background in red, then draw the score text over it {
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) ); // Highlight the killers name - overlay the background in red, then draw the score text over it
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) );
} }
} }
else if ( pl_info->thisplayer ) // if it is their name, draw it a different color else if( pl_info->thisplayer ) // if it is their name, draw it a different color
{ {
// overlay the background in blue, then draw the score text over it // overlay the background in blue, then draw the score text over it
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 );
@ -415,13 +417,13 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset
// draw ping & packetloss // draw ping & packetloss
static char buf[64]; static char buf[64];
sprintf( buf, "%d", g_PlayerInfoList[best_player].ping ); sprintf( buf, "%d", g_PlayerInfoList[best_player].ping );
xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25; xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2 ) + PING_RANGE_MIN + xpos_rel + 25;
gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b ); gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b );
// Packetloss removed on Kelly 'shipping nazi' Bailey's orders // Packetloss removed on Kelly 'shipping nazi' Bailey's orders
if ( can_show_packetloss ) if( can_show_packetloss )
{ {
if ( g_PlayerInfoList[best_player].packetloss >= 63 ) if( g_PlayerInfoList[best_player].packetloss >= 63 )
{ {
UnpackRGB( r, g, b, RGB_REDISH ); UnpackRGB( r, g, b, RGB_REDISH );
sprintf( buf, " !!!!" ); sprintf( buf, " !!!!" );
@ -431,7 +433,7 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset
sprintf( buf, " %d", g_PlayerInfoList[best_player].packetloss ); sprintf( buf, " %d", g_PlayerInfoList[best_player].packetloss );
} }
xpos = ((PL_RANGE_MAX - PL_RANGE_MIN) / 2) + PL_RANGE_MIN + xpos_rel + 25; xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2 ) + PL_RANGE_MIN + xpos_rel + 25;
gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b );
} }
@ -443,19 +445,18 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset
return list_slot; return list_slot;
} }
void CHudScoreboard::GetAllPlayersInfo( void )
void CHudScoreboard :: GetAllPlayersInfo( void )
{ {
for ( int i = 1; i < MAX_PLAYERS; i++ ) for( int i = 1; i < MAX_PLAYERS; i++ )
{ {
GetPlayerInfo( i, &g_PlayerInfoList[i] ); GetPlayerInfo( i, &g_PlayerInfoList[i] );
if ( g_PlayerInfoList[i].thisplayer ) if( g_PlayerInfoList[i].thisplayer )
m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine
} }
} }
int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ) int CHudScoreboard::MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf )
{ {
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
@ -466,7 +467,7 @@ int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *p
short playerclass = READ_SHORT(); short playerclass = READ_SHORT();
short teamnumber = READ_SHORT(); short teamnumber = READ_SHORT();
if ( cl > 0 && cl <= MAX_PLAYERS ) if( cl > 0 && cl <= MAX_PLAYERS )
{ {
g_PlayerExtraInfo[cl].frags = frags; g_PlayerExtraInfo[cl].frags = frags;
g_PlayerExtraInfo[cl].deaths = deaths; g_PlayerExtraInfo[cl].deaths = deaths;
@ -483,21 +484,21 @@ int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *p
// accepts two values: // accepts two values:
// byte: client number // byte: client number
// string: client team name // string: client team name
int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf ) int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf )
{ {
int i, j; int i, j;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
short cl = READ_BYTE(); short cl = READ_BYTE();
if ( cl > 0 && cl <= MAX_PLAYERS ) if( cl > 0 && cl <= MAX_PLAYERS )
{ // set the players team {
// set the players team
strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME ); strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME );
} }
// rebuild the list of teams // rebuild the list of teams
// clear out player counts from teams // clear out player counts from teams
for ( i = 1; i <= m_iNumTeams; i++ ) for( i = 1; i <= m_iNumTeams; i++ )
{ {
g_TeamInfo[i].players = 0; g_TeamInfo[i].players = 0;
} }
@ -505,30 +506,31 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb
// rebuild the team list // rebuild the team list
GetAllPlayersInfo(); GetAllPlayersInfo();
m_iNumTeams = 0; m_iNumTeams = 0;
for ( i = 1; i < MAX_PLAYERS; i++ ) for( i = 1; i < MAX_PLAYERS; i++ )
{ {
//if ( g_PlayerInfoList[i].name == NULL ) //if ( g_PlayerInfoList[i].name == NULL )
// continue; // continue;
if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) if( g_PlayerExtraInfo[i].teamname[0] == 0 )
continue; // skip over players who are not in a team continue; // skip over players who are not in a team
// is this player in an existing team? // is this player in an existing team?
for ( j = 1; j <= m_iNumTeams; j++ ) for( j = 1; j <= m_iNumTeams; j++ )
{ {
if ( g_TeamInfo[j].name[0] == '\0' ) if( g_TeamInfo[j].name[0] == '\0' )
break; break;
if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) if( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) )
break; break;
} }
if ( j > m_iNumTeams ) if( j > m_iNumTeams )
{ // they aren't in a listed team, so make a new one
// search through for an empty team slot
for ( j = 1; j <= m_iNumTeams; j++ )
{ {
if ( g_TeamInfo[j].name[0] == '\0' ) // they aren't in a listed team, so make a new one
// search through for an empty team slot
for( j = 1; j <= m_iNumTeams; j++ )
{
if( g_TeamInfo[j].name[0] == '\0' )
break; break;
} }
m_iNumTeams = max( j, m_iNumTeams ); m_iNumTeams = max( j, m_iNumTeams );
@ -541,9 +543,9 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb
} }
// clear out any empty teams // clear out any empty teams
for ( i = 1; i <= m_iNumTeams; i++ ) for( i = 1; i <= m_iNumTeams; i++ )
{ {
if ( g_TeamInfo[i].players < 1 ) if( g_TeamInfo[i].players < 1 )
memset( &g_TeamInfo[i], 0, sizeof(team_info_t) ); memset( &g_TeamInfo[i], 0, sizeof(team_info_t) );
} }
@ -556,19 +558,19 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb
// short: teams kills // short: teams kills
// short: teams deaths // short: teams deaths
// if this message is never received, then scores will simply be the combined totals of the players. // if this message is never received, then scores will simply be the combined totals of the players.
int CHudScoreboard :: MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ) int CHudScoreboard::MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
char *TeamName = READ_STRING(); char *TeamName = READ_STRING();
int i; int i;
// find the team matching the name // find the team matching the name
for ( i = 1; i <= m_iNumTeams; i++ ) for( i = 1; i <= m_iNumTeams; i++ )
{ {
if ( !stricmp( TeamName, g_TeamInfo[i].name ) ) if( !stricmp( TeamName, g_TeamInfo[i].name ) )
break; break;
} }
if ( i > m_iNumTeams ) if( i > m_iNumTeams )
return 1; return 1;
// use this new score data instead of combined player scores // use this new score data instead of combined player scores
@ -579,27 +581,25 @@ int CHudScoreboard :: MsgFunc_TeamScore( const char *pszName, int iSize, void *p
return 1; return 1;
} }
void CHudScoreboard :: DeathMsg( int killer, int victim ) void CHudScoreboard::DeathMsg( int killer, int victim )
{ {
// if we were the one killed, or the world killed us, set the scoreboard to indicate suicide // if we were the one killed, or the world killed us, set the scoreboard to indicate suicide
if ( victim == m_iPlayerNum || killer == 0 ) if( victim == m_iPlayerNum || killer == 0 )
{ {
m_iLastKilledBy = killer ? killer : m_iPlayerNum; m_iLastKilledBy = killer ? killer : m_iPlayerNum;
m_fLastKillTime = gHUD.m_flTime + 10; // display who we were killed by for 10 seconds m_fLastKillTime = gHUD.m_flTime + 10; // display who we were killed by for 10 seconds
if ( killer == m_iPlayerNum ) if( killer == m_iPlayerNum )
m_iLastKilledBy = m_iPlayerNum; m_iLastKilledBy = m_iPlayerNum;
} }
} }
void CHudScoreboard::UserCmd_ShowScores( void )
void CHudScoreboard :: UserCmd_ShowScores( void )
{ {
m_iShowscoresHeld = TRUE; m_iShowscoresHeld = TRUE;
} }
void CHudScoreboard :: UserCmd_HideScores( void ) void CHudScoreboard::UserCmd_HideScores( void )
{ {
m_iShowscoresHeld = FALSE; m_iShowscoresHeld = FALSE;
} }

View File

@ -15,6 +15,7 @@
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#include <windows.h> #include <windows.h>
#include <dsound.h> #include <dsound.h>
#include <mmsystem.h> #include <mmsystem.h>
@ -116,10 +117,10 @@ int Eng_LoadFunctions( HMODULE hMod )
engine_api_func pfnEngineAPI; engine_api_func pfnEngineAPI;
pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" ); pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" );
if ( !pfnEngineAPI ) if( !pfnEngineAPI )
return 0; return 0;
if ( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) ) if( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) )
return 0; return 0;
// All is okay // All is okay
@ -132,11 +133,11 @@ int Eng_LoadFunctions( HMODULE hMod )
void LoadSoundAPIs( void ) void LoadSoundAPIs( void )
{ {
hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" ); hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" );
if ( hEngine ) if( hEngine )
{ {
if ( Eng_LoadFunctions( hEngine ) ) if( Eng_LoadFunctions( hEngine ) )
{ {
if ( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer ) if( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer )
{ {
engineapi.S_GetDSPointer(&lpDS, &lpDSBuf); engineapi.S_GetDSPointer(&lpDS, &lpDSBuf);
lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer(); lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer();

View File

@ -15,6 +15,7 @@
// //
// status_icons.cpp // status_icons.cpp
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
@ -25,7 +26,7 @@
#include "parsemsg.h" #include "parsemsg.h"
#include "event_api.h" #include "event_api.h"
DECLARE_MESSAGE( m_StatusIcons, StatusIcon ); DECLARE_MESSAGE( m_StatusIcons, StatusIcon )
int CHudStatusIcons::Init( void ) int CHudStatusIcons::Init( void )
{ {
@ -40,7 +41,6 @@ int CHudStatusIcons::Init( void )
int CHudStatusIcons::VidInit( void ) int CHudStatusIcons::VidInit( void )
{ {
return 1; return 1;
} }
@ -53,16 +53,16 @@ void CHudStatusIcons::Reset( void )
// Draw status icons along the left-hand side of the screen // Draw status icons along the left-hand side of the screen
int CHudStatusIcons::Draw( float flTime ) int CHudStatusIcons::Draw( float flTime )
{ {
if (gEngfuncs.IsSpectateOnly()) if( gEngfuncs.IsSpectateOnly() )
return 1; return 1;
// find starting position to draw from, along right-hand side of screen // find starting position to draw from, along right-hand side of screen
int x = 5; int x = 5;
int y = ScreenHeight / 2; int y = ScreenHeight / 2;
// loop through icon list, and draw any valid icons drawing up from the middle of screen // loop through icon list, and draw any valid icons drawing up from the middle of screen
for ( int i = 0; i < MAX_ICONSPRITES; i++ ) for( int i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( m_IconList[i].spr ) if( m_IconList[i].spr )
{ {
y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5; y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
@ -87,7 +87,7 @@ int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *p
int ShouldEnable = READ_BYTE(); int ShouldEnable = READ_BYTE();
char *pszIconName = READ_STRING(); char *pszIconName = READ_STRING();
if ( ShouldEnable ) if( ShouldEnable )
{ {
int r = READ_BYTE(); int r = READ_BYTE();
int g = READ_BYTE(); int g = READ_BYTE();
@ -109,24 +109,24 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned
int i; int i;
// check to see if the sprite is in the current list // check to see if the sprite is in the current list
for ( i = 0; i < MAX_ICONSPRITES; i++ ) for( i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) if( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
break; break;
} }
if ( i == MAX_ICONSPRITES ) if( i == MAX_ICONSPRITES )
{ {
// icon not in list, so find an empty slot to add to // icon not in list, so find an empty slot to add to
for ( i = 0; i < MAX_ICONSPRITES; i++ ) for( i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( !m_IconList[i].spr ) if( !m_IconList[i].spr )
break; break;
} }
} }
// if we've run out of space in the list, overwrite the first icon // if we've run out of space in the list, overwrite the first icon
if ( i == MAX_ICONSPRITES ) if( i == MAX_ICONSPRITES )
{ {
i = 0; i = 0;
} }
@ -142,7 +142,7 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned
strcpy( m_IconList[i].szSpriteName, pszIconName ); strcpy( m_IconList[i].szSpriteName, pszIconName );
// Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds) // Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds)
if ( strstr(m_IconList[i].szSpriteName, "grenade") ) if( strstr(m_IconList[i].szSpriteName, "grenade") )
{ {
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer(); cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer();
gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
@ -152,12 +152,12 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned
void CHudStatusIcons::DisableIcon( char *pszIconName ) void CHudStatusIcons::DisableIcon( char *pszIconName )
{ {
// find the sprite is in the current list // find the sprite is in the current list
for ( int i = 0; i < MAX_ICONSPRITES; i++ ) for( int i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) if( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
{ {
// clear the item from the list // clear the item from the list
memset( &m_IconList[i], 0, sizeof( icon_sprite_t ) ); memset( &m_IconList[i], 0, sizeof(icon_sprite_t) );
return; return;
} }
} }

View File

@ -26,15 +26,15 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE( m_StatusBar, StatusText ); DECLARE_MESSAGE( m_StatusBar, StatusText )
DECLARE_MESSAGE( m_StatusBar, StatusValue ); DECLARE_MESSAGE( m_StatusBar, StatusValue )
#define STATUSBAR_ID_LINE 1 #define STATUSBAR_ID_LINE 1
float *GetClientColor( int clientIndex ); float *GetClientColor( int clientIndex );
extern float g_ColorYellow[3]; extern float g_ColorYellow[3];
int CHudStatusBar :: Init( void ) int CHudStatusBar::Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
@ -48,19 +48,18 @@ int CHudStatusBar :: Init( void )
return 1; return 1;
} }
int CHudStatusBar :: VidInit( void ) int CHudStatusBar::VidInit( void )
{ {
// Load sprites here // Load sprites here
return 1; return 1;
} }
void CHudStatusBar :: Reset( void ) void CHudStatusBar::Reset( void )
{ {
int i = 0; int i = 0;
m_iFlags &= ~HUD_ACTIVE; // start out inactive m_iFlags &= ~HUD_ACTIVE; // start out inactive
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ ) for( i = 0; i < MAX_STATUSBAR_LINES; i++ )
m_szStatusText[i][0] = 0; m_szStatusText[i][0] = 0;
memset( m_iStatusValues, 0, sizeof m_iStatusValues ); memset( m_iStatusValues, 0, sizeof m_iStatusValues );
@ -71,11 +70,10 @@ void CHudStatusBar :: Reset( void )
m_pflNameColors[i] = g_ColorYellow; m_pflNameColors[i] = g_ColorYellow;
} }
void CHudStatusBar :: ParseStatusString( int line_num ) void CHudStatusBar::ParseStatusString( int line_num )
{ {
// localise string first // localise string first
char szBuffer[MAX_STATUSTEXT_LENGTH]; char szBuffer[MAX_STATUSTEXT_LENGTH] = {0};
memset( szBuffer, 0, sizeof szBuffer );
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH ); gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
// parse m_szStatusText & m_iStatusValues into m_szStatusBar // parse m_szStatusText & m_iStatusValues into m_szStatusBar
@ -85,29 +83,31 @@ void CHudStatusBar :: ParseStatusString( int line_num )
char *src_start = src, *dst_start = dst; char *src_start = src, *dst_start = dst;
while ( *src != 0 ) while( *src != 0 )
{ {
while ( *src == '\n' ) while( *src == '\n' )
src++; // skip over any newlines src++; // skip over any newlines
if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) ) if( ( ( src - src_start ) >= MAX_STATUSTEXT_LENGTH ) || ( ( dst - dst_start ) >= MAX_STATUSTEXT_LENGTH ) )
break; break;
int index = atoi( src ); int index = atoi( src );
// should we draw this line? // should we draw this line?
if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) ) if( ( index >= 0 && index < MAX_STATUSBAR_VALUES ) && ( m_iStatusValues[index] != 0 ) )
{ // parse this line and append result to the status bar {
// parse this line and append result to the status bar
while ( *src >= '0' && *src <= '9' ) while ( *src >= '0' && *src <= '9' )
src++; src++;
if ( *src == '\n' || *src == 0 ) if( *src == '\n' || *src == 0 )
continue; // no more left in this text line continue; // no more left in this text line
// copy the text, char by char, until we hit a % or a \n // copy the text, char by char, until we hit a % or a \n
while ( *src != '\n' && *src != 0 ) while( *src != '\n' && *src != 0 )
{ {
if ( *src != '%' ) if( *src != '%' )
{ // just copy the character {
// just copy the character
*dst = *src; *dst = *src;
dst++, src++; dst++, src++;
} }
@ -126,20 +126,20 @@ void CHudStatusBar :: ParseStatusString( int line_num )
// move over descriptor, then get and move over the index // move over descriptor, then get and move over the index
index = atoi( ++src ); index = atoi( ++src );
while ( *src >= '0' && *src <= '9' ) while( *src >= '0' && *src <= '9' )
src++; src++;
if ( index >= 0 && index < MAX_STATUSBAR_VALUES ) if( index >= 0 && index < MAX_STATUSBAR_VALUES )
{ {
int indexval = m_iStatusValues[index]; int indexval = m_iStatusValues[index];
// get the string to substitute in place of the %XX // get the string to substitute in place of the %XX
char szRepString[MAX_PLAYER_NAME_LENGTH]; char szRepString[MAX_PLAYER_NAME_LENGTH];
switch ( valtype ) switch( valtype )
{ {
case 'p': // player name case 'p': // player name
GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] ); GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
if ( g_PlayerInfoList[indexval].name != NULL ) if( g_PlayerInfoList[indexval].name != NULL )
{ {
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH ); strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
m_pflNameColors[line_num] = GetClientColor( indexval ); m_pflNameColors[line_num] = GetClientColor( indexval );
@ -148,7 +148,6 @@ void CHudStatusBar :: ParseStatusString( int line_num )
{ {
strcpy( szRepString, "******" ); strcpy( szRepString, "******" );
} }
break; break;
case 'i': // number case 'i': // number
sprintf( szRepString, "%d", indexval ); sprintf( szRepString, "%d", indexval );
@ -157,7 +156,7 @@ void CHudStatusBar :: ParseStatusString( int line_num )
szRepString[0] = 0; szRepString[0] = 0;
} }
for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ ) for( char *cp = szRepString; *cp != 0 && ( ( dst - dst_start ) < MAX_STATUSTEXT_LENGTH ); cp++, dst++ )
*dst = *cp; *dst = *cp;
} }
} }
@ -166,17 +165,17 @@ void CHudStatusBar :: ParseStatusString( int line_num )
else else
{ {
// skip to next line of text // skip to next line of text
while ( *src != 0 && *src != '\n' ) while( *src != 0 && *src != '\n' )
src++; src++;
} }
} }
} }
int CHudStatusBar :: Draw( float fTime ) int CHudStatusBar::Draw( float fTime )
{ {
if ( m_bReparseString ) if( m_bReparseString )
{ {
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) for( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{ {
m_pflNameColors[i] = g_ColorYellow; m_pflNameColors[i] = g_ColorYellow;
ParseStatusString( i ); ParseStatusString( i );
@ -184,10 +183,10 @@ int CHudStatusBar :: Draw( float fTime )
m_bReparseString = FALSE; m_bReparseString = FALSE;
} }
int Y_START = ScreenHeight - YRES(32 + 4); int Y_START = ScreenHeight - YRES( 32 + 4 );
// Draw the status bar lines // Draw the status bar lines
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) for( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{ {
int TextHeight, TextWidth; int TextHeight, TextWidth;
GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight ); GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
@ -196,13 +195,13 @@ int CHudStatusBar :: Draw( float fTime )
int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen
// let user set status ID bar centering // let user set status ID bar centering
if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") ) if( ( i == STATUSBAR_ID_LINE ) && CVAR_GET_FLOAT( "hud_centerid" ) )
{ {
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 ); x = max( 0, max( 2, ( ScreenWidth - TextWidth ) ) / 2 );
y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid")); y = ( ScreenHeight / 2 ) + ( TextHeight * CVAR_GET_FLOAT( "hud_centerid" ) );
} }
if ( m_pflNameColors[i] ) if( m_pflNameColors[i] )
DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] ); DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
DrawConsoleString( x, y, m_szStatusBar[i] ); DrawConsoleString( x, y, m_szStatusBar[i] );
@ -223,19 +222,19 @@ int CHudStatusBar :: Draw( float fTime )
// if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline // if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline
// %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X] // %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X]
// %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X] // %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X]
int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf ) int CHudStatusBar::MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int line = READ_BYTE(); int line = READ_BYTE();
if ( line < 0 || line >= MAX_STATUSBAR_LINES ) if( line < 0 || line >= MAX_STATUSBAR_LINES )
return 1; return 1;
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH ); strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long) m_szStatusText[line][MAX_STATUSTEXT_LENGTH - 1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
if ( m_szStatusText[0] == 0 ) if( m_szStatusText[0] == 0 )
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
else else
m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar
@ -249,12 +248,12 @@ int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *p
// accepts two values: // accepts two values:
// byte: index into the status value array // byte: index into the status value array
// short: value to store // short: value to store
int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ) int CHudStatusBar::MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int index = READ_BYTE(); int index = READ_BYTE();
if ( index < 1 || index >= MAX_STATUSBAR_VALUES ) if( index < 1 || index >= MAX_STATUSBAR_VALUES )
return 1; // index out of range return 1; // index out of range
m_iStatusValues[index] = READ_SHORT(); m_iStatusValues[index] = READ_SHORT();

View File

@ -18,31 +18,31 @@ AngleMatrix
==================== ====================
*/ */
void AngleMatrix (const float *angles, float (*matrix)[4] ) void AngleMatrix( const float *angles, float (*matrix)[4] )
{ {
float angle; float angle;
float sr, sp, sy, cr, cp, cy; float sr, sp, sy, cr, cp, cy;
angle = angles[YAW] * (M_PI*2 / 360); angle = angles[YAW] * ( M_PI*2 / 360 );
sy = sin(angle); sy = sin( angle );
cy = cos(angle); cy = cos( angle );
angle = angles[PITCH] * (M_PI*2 / 360); angle = angles[PITCH] * ( M_PI*2 / 360 );
sp = sin(angle); sp = sin( angle );
cp = cos(angle); cp = cos( angle );
angle = angles[ROLL] * (M_PI*2 / 360); angle = angles[ROLL] * ( M_PI*2 / 360 );
sr = sin(angle); sr = sin( angle );
cr = cos(angle); cr = cos( angle );
// matrix = (YAW * PITCH) * ROLL // matrix = (YAW * PITCH) * ROLL
matrix[0][0] = cp*cy; matrix[0][0] = cp * cy;
matrix[1][0] = cp*sy; matrix[1][0] = cp * sy;
matrix[2][0] = -sp; matrix[2][0] = -sp;
matrix[0][1] = sr*sp*cy+cr*-sy; matrix[0][1] = sr * sp * cy + cr * -sy;
matrix[1][1] = sr*sp*sy+cr*cy; matrix[1][1] = sr * sp * sy + cr * cy;
matrix[2][1] = sr*cp; matrix[2][1] = sr * cp;
matrix[0][2] = (cr*sp*cy+-sr*-sy); matrix[0][2] = (cr * sp * cy + -sr * -sy);
matrix[1][2] = (cr*sp*sy+-sr*cy); matrix[1][2] = (cr * sp * sy + -sr* cy);
matrix[2][2] = cr*cp; matrix[2][2] = cr * cp;
matrix[0][3] = 0.0; matrix[0][3] = 0.0;
matrix[1][3] = 0.0; matrix[1][3] = 0.0;
matrix[2][3] = 0.0; matrix[2][3] = 0.0;
@ -54,12 +54,12 @@ VectorCompare
==================== ====================
*/ */
int VectorCompare (const float *v1, const float *v2) int VectorCompare( const float *v1, const float *v2 )
{ {
int i; int i;
for (i=0 ; i<3 ; i++) for( i = 0; i < 3; i++ )
if (v1[i] != v2[i]) if( v1[i] != v2[i] )
return 0; return 0;
return 1; return 1;
@ -71,7 +71,7 @@ CrossProduct
==================== ====================
*/ */
void CrossProduct (const float *v1, const float *v2, float *cross) void CrossProduct( const float *v1, const float *v2, float *cross )
{ {
cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
@ -84,7 +84,7 @@ VectorTransform
==================== ====================
*/ */
void VectorTransform (const float *in1, float in2[3][4], float *out) void VectorTransform( const float *in1, float in2[3][4], float *out )
{ {
out[0] = DotProduct(in1, in2[0]) + in2[0][3]; out[0] = DotProduct(in1, in2[0]) + in2[0][3];
out[1] = DotProduct(in1, in2[1]) + in2[1][3]; out[1] = DotProduct(in1, in2[1]) + in2[1][3];
@ -97,7 +97,7 @@ ConcatTransforms
================ ================
*/ */
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) void ConcatTransforms( float in1[3][4], float in2[3][4], float out[3][4] )
{ {
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
in1[0][2] * in2[2][0]; in1[0][2] * in2[2][0];
@ -140,19 +140,19 @@ void AngleQuaternion( float *angles, vec4_t quaternion )
// FIXME: rescale the inputs to 1/2 angle // FIXME: rescale the inputs to 1/2 angle
angle = angles[2] * 0.5; angle = angles[2] * 0.5;
sy = sin(angle); sy = sin( angle );
cy = cos(angle); cy = cos( angle );
angle = angles[1] * 0.5; angle = angles[1] * 0.5;
sp = sin(angle); sp = sin( angle );
cp = cos(angle); cp = cos( angle );
angle = angles[0] * 0.5; angle = angles[0] * 0.5;
sr = sin(angle); sr = sin( angle );
cr = cos(angle); cr = cos( angle );
quaternion[0] = sr*cp*cy-cr*sp*sy; // X quaternion[0] = sr * cp * cy - cr * sp * sy; // X
quaternion[1] = cr*sp*cy+sr*cp*sy; // Y quaternion[1] = cr * sp * cy + sr * cp * sy; // Y
quaternion[2] = cr*cp*sy-sr*sp*cy; // Z quaternion[2] = cr * cp * sy - sr * sp * cy; // Z
quaternion[3] = cr*cp*cy+sr*sp*sy; // W quaternion[3] = cr * cp * cy + sr * sp * sy; // W
} }
/* /*
@ -170,36 +170,37 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
float a = 0; float a = 0;
float b = 0; float b = 0;
for (i = 0; i < 4; i++) for( i = 0; i < 4; i++ )
{ {
a += (p[i]-q[i])*(p[i]-q[i]); a += ( p[i] - q[i] ) * ( p[i] - q[i] );
b += (p[i]+q[i])*(p[i]+q[i]); b += ( p[i] + q[i] ) * ( p[i] + q[i] );
} }
if (a > b) if(a > b)
{ {
for (i = 0; i < 4; i++) for( i = 0; i < 4; i++ )
{ {
q[i] = -q[i]; q[i] = -q[i];
} }
} }
cosom = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] + p[3]*q[3]; cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3];
if ((1.0 + cosom) > 0.000001) if( ( 1.0 + cosom ) > 0.000001 )
{ {
if ((1.0 - cosom) > 0.000001) if( ( 1.0 - cosom ) > 0.000001 )
{ {
omega = acos( cosom ); omega = acos( cosom );
sinom = sin( omega ); sinom = sin( omega );
sclp = sin( (1.0 - t)*omega) / sinom; sclp = sin( ( 1.0 - t ) * omega ) / sinom;
sclq = sin( t*omega ) / sinom; sclq = sin( t * omega ) / sinom;
} }
else else
{ {
sclp = 1.0 - t; sclp = 1.0 - t;
sclq = t; sclq = t;
} }
for (i = 0; i < 4; i++) { for( i = 0; i < 4; i++ )
{
qt[i] = sclp * p[i] + sclq * q[i]; qt[i] = sclp * p[i] + sclq * q[i];
} }
} }
@ -209,9 +210,9 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
qt[1] = q[0]; qt[1] = q[0];
qt[2] = -q[3]; qt[2] = -q[3];
qt[3] = q[2]; qt[3] = q[2];
sclp = sin( (1.0 - t) * (0.5 * M_PI)); sclp = sin( ( 1.0 - t ) * ( 0.5 * M_PI ) );
sclq = sin( t * (0.5 * M_PI)); sclq = sin( t * ( 0.5 * M_PI ) );
for (i = 0; i < 3; i++) for( i = 0; i < 3; i++ )
{ {
qt[i] = sclp * p[i] + sclq * qt[i]; qt[i] = sclp * p[i] + sclq * qt[i];
} }

View File

@ -25,16 +25,15 @@
#define ROLL 2 #define ROLL 2
#endif #endif
#define FDotProduct( a, b ) (fabs((a[0])*(b[0])) + fabs((a[1])*(b[1])) + fabs((a[2])*(b[2]))) #define FDotProduct( a, b ) ( fabs( ( a[0] ) * ( b[0] ) ) + fabs( ( a[1] ) * ( b[1] ) ) + fabs( ( a[2] ) * ( b[2] ) ) )
void AngleMatrix (const float *angles, float (*matrix)[4] ); void AngleMatrix( const float *angles, float (*matrix)[4] );
int VectorCompare (const float *v1, const float *v2); int VectorCompare( const float *v1, const float *v2 );
void CrossProduct (const float *v1, const float *v2, float *cross); void CrossProduct( const float *v1, const float *v2, float *cross );
void VectorTransform (const float *in1, float in2[3][4], float *out); void VectorTransform( const float *in1, float in2[3][4], float *out );
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); void ConcatTransforms( float in1[3][4], float in2[3][4], float out[3][4] );
void MatrixCopy( float in[3][4], float out[3][4] ); void MatrixCopy( float in[3][4], float out[3][4] );
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] ); void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] );
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ); void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt );
void AngleQuaternion( float *angles, vec4_t quaternion ); void AngleQuaternion( float *angles, vec4_t quaternion );
#endif // STUDIO_UTIL_H #endif // STUDIO_UTIL_H

View File

@ -26,10 +26,9 @@
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE( m_TextMessage, TextMsg )
DECLARE_MESSAGE( m_TextMessage, TextMsg ); int CHudTextMessage::Init( void )
int CHudTextMessage::Init(void)
{ {
HOOK_MESSAGE( TextMsg ); HOOK_MESSAGE( TextMsg );
@ -38,7 +37,7 @@ int CHudTextMessage::Init(void)
Reset(); Reset();
return 1; return 1;
}; }
// Searches through the string for any msg names (indicated by a '#') // Searches through the string for any msg names (indicated by a '#')
// any found are looked up in titles.txt and the new message substituted // any found are looked up in titles.txt and the new message substituted
@ -46,14 +45,14 @@ int CHudTextMessage::Init(void)
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
{ {
char *dst = dst_buffer; char *dst = dst_buffer;
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
{ {
if ( *src == '#' ) if( *src == '#' )
{ {
// cut msg name out of string // cut msg name out of string
static char word_buf[255]; static char word_buf[255];
char *wdst = word_buf, *word_start = src; char *wdst = word_buf, *word_start = src;
for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ ) for( ++src; ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ); wdst++, src++ )
{ {
*wdst = *src; *wdst = *src;
} }
@ -61,7 +60,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in
// lookup msg name in titles.txt // lookup msg name in titles.txt
client_textmessage_t *clmsg = TextMessageGet( word_buf ); client_textmessage_t *clmsg = TextMessageGet( word_buf );
if ( !clmsg || !(clmsg->pMessage) ) if( !clmsg || !( clmsg->pMessage ) )
{ {
src = word_start; src = word_start;
*dst = *src; *dst = *src;
@ -70,7 +69,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in
} }
// copy string into message over the msg name // copy string into message over the msg name
for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ )
{ {
*dst = *wsrc; *dst = *wsrc;
} }
@ -84,7 +83,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in
} }
} }
dst_buffer[buffer_size-1] = 0; // ensure null termination dst_buffer[buffer_size - 1] = 0; // ensure null termination
return dst_buffer; return dst_buffer;
} }
@ -99,30 +98,31 @@ char *CHudTextMessage::BufferedLocaliseTextString( const char *msg )
// Simplified version of LocaliseTextString; assumes string is only one word // Simplified version of LocaliseTextString; assumes string is only one word
char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
{ {
if ( !msg ) if( !msg )
return ""; return "";
// '#' character indicates this is a reference to a string in titles.txt, and not the string itself // '#' character indicates this is a reference to a string in titles.txt, and not the string itself
if ( msg[0] == '#' ) if( msg[0] == '#' )
{ {
// this is a message name, so look up the real message // this is a message name, so look up the real message
client_textmessage_t *clmsg = TextMessageGet( msg+1 ); client_textmessage_t *clmsg = TextMessageGet( msg + 1 );
if ( !clmsg || !(clmsg->pMessage) ) if( !clmsg || !(clmsg->pMessage) )
return (char*)msg; // lookup failed, so return the original string return (char*)msg; // lookup failed, so return the original string
if ( msg_dest ) if( msg_dest )
{ {
// check to see if titles.txt info overrides msg destination // check to see if titles.txt info overrides msg destination
// if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination // if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination
if ( clmsg->effect < 0 ) // if( clmsg->effect < 0 ) //
*msg_dest = -clmsg->effect; *msg_dest = -clmsg->effect;
} }
return (char*)clmsg->pMessage; return (char*)clmsg->pMessage;
} }
else else
{ // nothing special about this message, so just return the same string {
// nothing special about this message, so just return the same string
return (char*)msg; return (char*)msg;
} }
} }
@ -130,7 +130,7 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
void StripEndNewlineFromString( char *str ) void StripEndNewlineFromString( char *str )
{ {
int s = strlen( str ) - 1; int s = strlen( str ) - 1;
if ( str[s] == '\n' || str[s] == '\r' ) if( str[s] == '\n' || str[s] == '\r' )
str[s] = 0; str[s] = 0;
} }
@ -138,8 +138,8 @@ void StripEndNewlineFromString( char *str )
// returns a pointer to str // returns a pointer to str
char* ConvertCRtoNL( char *str ) char* ConvertCRtoNL( char *str )
{ {
for ( char *ch = str; *ch != 0; ch++ ) for( char *ch = str; *ch != 0; ch++ )
if ( *ch == '\r' ) if( *ch == '\r' )
*ch = '\n'; *ch = '\n';
return str; return str;
} }
@ -181,24 +181,21 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf
StripEndNewlineFromString( sstr4 ); StripEndNewlineFromString( sstr4 );
char *psz = szBuf[5]; char *psz = szBuf[5];
switch ( msg_dest ) switch( msg_dest )
{ {
case HUD_PRINTCENTER: case HUD_PRINTCENTER:
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
CenterPrint( ConvertCRtoNL( psz ) ); CenterPrint( ConvertCRtoNL( psz ) );
break; break;
case HUD_PRINTNOTIFY: case HUD_PRINTNOTIFY:
psz[0] = 1; // mark this message to go into the notify buffer psz[0] = 1; // mark this message to go into the notify buffer
sprintf( psz+1, msg_text, sstr1, sstr2, sstr3, sstr4 ); sprintf( psz + 1, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) ); ConsolePrint( ConvertCRtoNL( psz ) );
break; break;
case HUD_PRINTTALK: case HUD_PRINTTALK:
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
break; break;
case HUD_PRINTCONSOLE: case HUD_PRINTCONSOLE:
sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) ); ConsolePrint( ConvertCRtoNL( psz ) );

View File

@ -362,7 +362,6 @@ enum
// Silent Spy Feign // Silent Spy Feign
#define TF_SPY_SILENTDIE 199 #define TF_SPY_SILENTDIE 199
/*==================================================*/ /*==================================================*/
/* Defines for the ENGINEER's Building ability */ /* Defines for the ENGINEER's Building ability */
/*==================================================*/ /*==================================================*/
@ -458,28 +457,28 @@ enum
// HL-compatible weapon numbers // HL-compatible weapon numbers
#define WEAPON_HOOK 1 #define WEAPON_HOOK 1
#define WEAPON_BIOWEAPON (WEAPON_HOOK+1) #define WEAPON_BIOWEAPON (WEAPON_HOOK + 1)
#define WEAPON_MEDIKIT (WEAPON_HOOK+2) #define WEAPON_MEDIKIT (WEAPON_HOOK + 2)
#define WEAPON_SPANNER (WEAPON_HOOK+3) #define WEAPON_SPANNER (WEAPON_HOOK + 3)
#define WEAPON_AXE (WEAPON_HOOK+4) #define WEAPON_AXE (WEAPON_HOOK + 4)
#define WEAPON_SNIPER_RIFLE (WEAPON_HOOK+5) #define WEAPON_SNIPER_RIFLE (WEAPON_HOOK + 5)
#define WEAPON_AUTO_RIFLE (WEAPON_HOOK+6) #define WEAPON_AUTO_RIFLE (WEAPON_HOOK + 6)
#define WEAPON_TF_SHOTGUN (WEAPON_HOOK+7) #define WEAPON_TF_SHOTGUN (WEAPON_HOOK + 7)
#define WEAPON_SUPER_SHOTGUN (WEAPON_HOOK+8) #define WEAPON_SUPER_SHOTGUN (WEAPON_HOOK + 8)
#define WEAPON_NAILGUN (WEAPON_HOOK+9) #define WEAPON_NAILGUN (WEAPON_HOOK + 9)
#define WEAPON_SUPER_NAILGUN (WEAPON_HOOK+10) #define WEAPON_SUPER_NAILGUN (WEAPON_HOOK + 10)
#define WEAPON_GRENADE_LAUNCHER (WEAPON_HOOK+11) #define WEAPON_GRENADE_LAUNCHER (WEAPON_HOOK + 11)
#define WEAPON_FLAMETHROWER (WEAPON_HOOK+12) #define WEAPON_FLAMETHROWER (WEAPON_HOOK + 12)
#define WEAPON_ROCKET_LAUNCHER (WEAPON_HOOK+13) #define WEAPON_ROCKET_LAUNCHER (WEAPON_HOOK + 13)
#define WEAPON_INCENDIARY (WEAPON_HOOK+14) #define WEAPON_INCENDIARY (WEAPON_HOOK + 14)
#define WEAPON_ASSAULT_CANNON (WEAPON_HOOK+16) #define WEAPON_ASSAULT_CANNON (WEAPON_HOOK + 16)
#define WEAPON_LIGHTNING (WEAPON_HOOK+17) #define WEAPON_LIGHTNING (WEAPON_HOOK + 17)
#define WEAPON_DETPACK (WEAPON_HOOK+18) #define WEAPON_DETPACK (WEAPON_HOOK + 18)
#define WEAPON_TRANQ (WEAPON_HOOK+19) #define WEAPON_TRANQ (WEAPON_HOOK + 19)
#define WEAPON_LASER (WEAPON_HOOK+20) #define WEAPON_LASER (WEAPON_HOOK + 20)
#define WEAPON_PIPEBOMB_LAUNCHER (WEAPON_HOOK+21) #define WEAPON_PIPEBOMB_LAUNCHER (WEAPON_HOOK + 21)
#define WEAPON_KNIFE (WEAPON_HOOK+22) #define WEAPON_KNIFE (WEAPON_HOOK + 22)
#define WEAPON_BENCHMARK (WEAPON_HOOK+23) #define WEAPON_BENCHMARK (WEAPON_HOOK + 23)
/*==================================================*/ /*==================================================*/
/* New Weapon Related Defines */ /* New Weapon Related Defines */
@ -1382,8 +1381,5 @@ public:
void Spawn( void ); void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
}; };
#endif // TF_DEFS_ONLY #endif // TF_DEFS_ONLY
#endif // __TF_DEFS_H #endif // __TF_DEFS_H

View File

@ -24,59 +24,56 @@
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE(m_Train, Train ) DECLARE_MESSAGE( m_Train, Train )
int CHudTrain::Init( void )
int CHudTrain::Init(void)
{ {
HOOK_MESSAGE( Train ); HOOK_MESSAGE( Train );
m_iPos = 0; m_iPos = 0;
m_iFlags = 0; m_iFlags = 0;
gHUD.AddHudElem(this); gHUD.AddHudElem( this );
return 1; return 1;
}; }
int CHudTrain::VidInit(void) int CHudTrain::VidInit( void )
{ {
m_hSprite = 0; m_hSprite = 0;
return 1; return 1;
}; }
int CHudTrain::Draw(float fTime) int CHudTrain::Draw( float fTime )
{ {
if ( !m_hSprite ) if( !m_hSprite )
m_hSprite = LoadSprite("sprites/%d_train.spr"); m_hSprite = LoadSprite( "sprites/%d_train.spr" );
if (m_iPos) if( m_iPos )
{ {
int r, g, b, x, y; int r, g, b, x, y;
UnpackRGB(r,g,b, RGB_YELLOWISH); UnpackRGB( r, g, b, RGB_YELLOWISH );
SPR_Set(m_hSprite, r, g, b ); SPR_Set( m_hSprite, r, g, b );
// This should show up to the right and part way up the armor number // This should show up to the right and part way up the armor number
y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight; y = ScreenHeight - SPR_Height( m_hSprite, 0 ) - gHUD.m_iFontHeight;
x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4; x = ScreenWidth / 3 + SPR_Width( m_hSprite, 0 ) / 4;
SPR_DrawAdditive( m_iPos - 1, x, y, NULL);
SPR_DrawAdditive( m_iPos - 1, x, y, NULL );
} }
return 1; return 1;
} }
int CHudTrain::MsgFunc_Train( const char *pszName, int iSize, void *pbuf )
int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
// update Train data // update Train data
m_iPos = READ_BYTE(); m_iPos = READ_BYTE();
if (m_iPos) if( m_iPos )
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
else else
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;

View File

@ -21,7 +21,7 @@ extern "C"
{ {
void DLLEXPORT HUD_DrawNormalTriangles( void ); void DLLEXPORT HUD_DrawNormalTriangles( void );
void DLLEXPORT HUD_DrawTransparentTriangles( void ); void DLLEXPORT HUD_DrawTransparentTriangles( void );
}; }
//#define TEST_IT //#define TEST_IT
#if defined( TEST_IT ) #if defined( TEST_IT )
@ -40,7 +40,7 @@ void Draw_Triangles( void )
// Load it up with some bogus data // Load it up with some bogus data
player = gEngfuncs.GetLocalPlayer(); player = gEngfuncs.GetLocalPlayer();
if ( !player ) if( !player )
return; return;
org = player->origin; org = player->origin;
@ -48,14 +48,14 @@ void Draw_Triangles( void )
org.x += 50; org.x += 50;
org.y += 50; org.y += 50;
if (gHUD.m_hsprCursor == 0) if( gHUD.m_hsprCursor == 0 )
{ {
char sz[256]; char sz[256];
sprintf( sz, "sprites/cursor.spr" ); sprintf( sz, "sprites/cursor.spr" );
gHUD.m_hsprCursor = SPR_Load( sz ); gHUD.m_hsprCursor = SPR_Load( sz );
} }
if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 )) if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) )
{ {
return; return;
} }
@ -86,7 +86,6 @@ void Draw_Triangles( void )
gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
} }
#endif #endif
/* /*
@ -98,9 +97,7 @@ Non-transparent triangles-- add them here
*/ */
void DLLEXPORT HUD_DrawNormalTriangles( void ) void DLLEXPORT HUD_DrawNormalTriangles( void )
{ {
gHUD.m_Spectator.DrawOverview(); gHUD.m_Spectator.DrawOverview();
#if defined( TEST_IT ) #if defined( TEST_IT )
// Draw_Triangles(); // Draw_Triangles();
#endif #endif
@ -115,7 +112,6 @@ Render any triangles with transparent rendermode needs here
*/ */
void DLLEXPORT HUD_DrawTransparentTriangles( void ) void DLLEXPORT HUD_DrawTransparentTriangles( void )
{ {
#if defined( TEST_IT ) #if defined( TEST_IT )
// Draw_Triangles(); // Draw_Triangles();
#endif #endif

View File

@ -32,17 +32,17 @@
extern vec3_t vec3_origin; extern vec3_t vec3_origin;
double sqrt(double x); double sqrt( double x );
float Length(const float *v) float Length( const float *v )
{ {
int i; int i;
float length; float length;
length = 0; length = 0;
for (i=0 ; i< 3 ; i++) for( i = 0; i < 3; i++ )
length += v[i]*v[i]; length += v[i] * v[i];
length = sqrt (length); // FIXME length = sqrt( length ); // FIXME
return length; return length;
} }
@ -51,23 +51,23 @@ void VectorAngles( const float *forward, float *angles )
{ {
float tmp, yaw, pitch; float tmp, yaw, pitch;
if (forward[1] == 0 && forward[0] == 0) if( forward[1] == 0 && forward[0] == 0 )
{ {
yaw = 0; yaw = 0;
if (forward[2] > 0) if( forward[2] > 0 )
pitch = 90; pitch = 90;
else else
pitch = 270; pitch = 270;
} }
else else
{ {
yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); yaw = ( atan2( forward[1], forward[0]) * 180 / M_PI );
if (yaw < 0) if( yaw < 0 )
yaw += 360; yaw += 360;
tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]); tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] );
pitch = (atan2(forward[2], tmp) * 180 / M_PI); pitch = ( atan2( forward[2], tmp ) * 180 / M_PI );
if (pitch < 0) if( pitch < 0 )
pitch += 360; pitch += 360;
} }
@ -76,58 +76,56 @@ void VectorAngles( const float *forward, float *angles )
angles[2] = 0; angles[2] = 0;
} }
float VectorNormalize (float *v) float VectorNormalize( float *v )
{ {
float length, ilength; float length, ilength;
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
length = sqrt (length); // FIXME length = sqrt( length ); // FIXME
if (length) if( length )
{ {
ilength = 1/length; ilength = 1 / length;
v[0] *= ilength; v[0] *= ilength;
v[1] *= ilength; v[1] *= ilength;
v[2] *= ilength; v[2] *= ilength;
} }
return length; return length;
} }
void VectorInverse ( float *v ) void VectorInverse( float *v )
{ {
v[0] = -v[0]; v[0] = -v[0];
v[1] = -v[1]; v[1] = -v[1];
v[2] = -v[2]; v[2] = -v[2];
} }
void VectorScale (const float *in, float scale, float *out) void VectorScale( const float *in, float scale, float *out )
{ {
out[0] = in[0]*scale; out[0] = in[0] * scale;
out[1] = in[1]*scale; out[1] = in[1] * scale;
out[2] = in[2]*scale; out[2] = in[2] * scale;
} }
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc) void VectorMA( const float *veca, float scale, const float *vecb, float *vecc )
{ {
vecc[0] = veca[0] + scale*vecb[0]; vecc[0] = veca[0] + scale * vecb[0];
vecc[1] = veca[1] + scale*vecb[1]; vecc[1] = veca[1] + scale * vecb[1];
vecc[2] = veca[2] + scale*vecb[2]; vecc[2] = veca[2] + scale * vecb[2];
} }
HSPRITE LoadSprite(const char *pszName) HSPRITE LoadSprite( const char *pszName )
{ {
int i; int i;
char sz[256]; char sz[256];
if (ScreenWidth < 640) if( ScreenWidth < 640 )
i = 320; i = 320;
else else
i = 640; i = 640;
sprintf(sz, pszName, i); sprintf( sz, pszName, i );
return SPR_Load(sz); return SPR_Load( sz );
} }

View File

@ -33,21 +33,21 @@ typedef float vec_t; // needed before including progdefs.h
class Vector2D class Vector2D
{ {
public: public:
inline Vector2D(void) { } inline Vector2D( void ) { }
inline Vector2D(float X, float Y) { x = X; y = Y; } inline Vector2D( float X, float Y ) { x = X; y = Y; }
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } inline Vector2D operator+( const Vector2D& v ) const { return Vector2D(x+v.x, y+v.y); }
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } inline Vector2D operator-( const Vector2D& v ) const { return Vector2D(x-v.x, y-v.y); }
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } inline Vector2D operator*( float fl ) const { return Vector2D(x*fl, y*fl); }
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } inline Vector2D operator/( float fl ) const { return Vector2D(x/fl, y/fl); }
inline float Length(void) const { return (float)sqrt(x*x + y*y ); } inline float Length( void ) const { return (float)sqrt(x*x + y*y ); }
inline Vector2D Normalize ( void ) const inline Vector2D Normalize( void ) const
{ {
Vector2D vec2; Vector2D vec2;
float flLen = Length(); float flLen = Length();
if ( flLen == 0 ) if( flLen == 0 )
{ {
return Vector2D( (float)0, (float)0 ); return Vector2D( (float)0, (float)0 );
} }
@ -61,46 +61,46 @@ public:
vec_t x, y; vec_t x, y;
}; };
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } inline float DotProduct( const Vector2D& a, const Vector2D& b ) { return( a.x * b.x + a.y * b.y ); }
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } inline Vector2D operator*( float fl, const Vector2D& v ) { return v * fl; }
//========================================================= //=========================================================
// 3D Vector // 3D Vector
//========================================================= //=========================================================
class Vector // same data-layout as engine's vec3_t, class Vector // same data-layout as engine's vec3_t,
{ // which is a vec_t[3] { //which is a vec_t[3]
public: public:
// Construction/destruction // Construction/destruction
inline Vector(void) { } inline Vector( void ) { }
inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; } inline Vector( float X, float Y, float Z ) { x = X; y = Y; z = Z; }
inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } inline Vector( double X, double Y, double Z ) { x = (float)X; y = (float)Y; z = (float)Z; }
inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } inline Vector( int X, int Y, int Z ) { x = (float)X; y = (float)Y; z = (float)Z; }
inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; } inline Vector( const Vector& v ) { x = v.x; y = v.y; z = v.z; }
inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } inline Vector( float rgfl[3] ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
// Operators // Operators
inline Vector operator-(void) const { return Vector(-x,-y,-z); } inline Vector operator-( void ) const { return Vector( -x, -y, -z ); }
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } inline int operator==( const Vector& v ) const { return x == v.x && y == v.y && z == v.z; }
inline int operator!=(const Vector& v) const { return !(*this==v); } inline int operator!=( const Vector& v ) const { return !( *this == v ); }
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } inline Vector operator+( const Vector& v ) const { return Vector( x + v.x, y + v.y, z + v.z ); }
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } inline Vector operator-( const Vector& v ) const { return Vector( x - v.x, y - v.y, z - v.z ); }
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } inline Vector operator*( float fl ) const { return Vector( x * fl, y * fl, z * fl ); }
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } inline Vector operator/( float fl ) const { return Vector( x / fl, y / fl, z / fl ); }
// Methods // Methods
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } inline void CopyToArray( float* rgfl ) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; }
inline float Length(void) const { return (float)sqrt(x*x + y*y + z*z); } inline float Length( void ) const { return (float)sqrt( x * x + y * y + z * z); }
operator float *() { return &x; } // Vectors will now automatically convert to float * when needed operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed
inline Vector Normalize(void) const inline Vector Normalize( void ) const
{ {
float flLen = Length(); float flLen = Length();
if (flLen == 0) return Vector(0,0,1); // ???? if( flLen == 0 ) return Vector( 0, 0, 1); // ????
flLen = 1 / flLen; flLen = 1 / flLen;
return Vector(x * flLen, y * flLen, z * flLen); return Vector( x * flLen, y * flLen, z * flLen );
} }
inline Vector2D Make2D ( void ) const inline Vector2D Make2D( void ) const
{ {
Vector2D Vec2; Vector2D Vec2;
@ -109,13 +109,18 @@ public:
return Vec2; return Vec2;
} }
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
inline float Length2D( void ) const
{
return (float)sqrt( x * x + y * y );
}
// Members // Members
vec_t x, y, z; vec_t x, y, z;
}; };
inline Vector operator*(float fl, const Vector& v) { return v * fl; }
inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } inline Vector operator*( float fl, const Vector& v ) { return v * fl; }
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + a.y * b.y + a.z * b.z ); }
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); }
#define vec3_t Vector #define vec3_t Vector

File diff suppressed because it is too large Load Diff

View File

@ -11,5 +11,4 @@
void V_StartPitchDrift( void ); void V_StartPitchDrift( void );
void V_StopPitchDrift( void ); void V_StopPitchDrift( void );
#endif // !VIEWH #endif // !VIEWH

View File

@ -119,7 +119,7 @@ enum
AMBIENT_SKY, // wind AMBIENT_SKY, // wind
AMBIENT_SLIME, // never used in quake AMBIENT_SLIME, // never used in quake
AMBIENT_LAVA, // never used in quake AMBIENT_LAVA, // never used in quake
NUM_AMBIENTS, // automatic ambient sounds NUM_AMBIENTS // automatic ambient sounds
}; };
// //

View File

@ -699,7 +699,7 @@ enum
kRenderGlow, // src*a+dest -- No Z buffer checks kRenderGlow, // src*a+dest -- No Z buffer checks
kRenderTransAlpha, // src*srca+dest*(1-srca) kRenderTransAlpha, // src*srca+dest*(1-srca)
kRenderTransAdd, // src*a+dest kRenderTransAdd, // src*a+dest
kRenderWorldGlow, // Same as kRenderGlow but not fixed size in screen space kRenderWorldGlow // Same as kRenderGlow but not fixed size in screen space
}; };
enum enum
@ -724,7 +724,7 @@ enum
kRenderFxDeadPlayer, // kRenderAmt is the player index kRenderFxDeadPlayer, // kRenderAmt is the player index
kRenderFxExplode, // Scale up really big! kRenderFxExplode, // Scale up really big!
kRenderFxGlowShell, // Glowing Shell kRenderFxGlowShell, // Glowing Shell
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!)
}; };
typedef unsigned int func_t; typedef unsigned int func_t;

View File

@ -19,7 +19,7 @@
typedef enum typedef enum
{ {
TRI_FRONT = 0, TRI_FRONT = 0,
TRI_NONE = 1, TRI_NONE = 1
} TRICULLSTYLE; } TRICULLSTYLE;
#define TRI_API_VERSION 1 #define TRI_API_VERSION 1

View File

@ -65,8 +65,8 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \
gman.cpp \ gman.cpp \
h_ai.cpp \ h_ai.cpp \
h_battery.cpp \ h_battery.cpp \
h_cine.cpp \
h_cycler.cpp \ h_cycler.cpp \
h_cine.cpp \
h_export.cpp \ h_export.cpp \
handgrenade.cpp \ handgrenade.cpp \
hassassin.cpp \ hassassin.cpp \
@ -114,8 +114,8 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \
subs.cpp \ subs.cpp \
talkmonster.cpp \ talkmonster.cpp \
teamplay_gamerules.cpp \ teamplay_gamerules.cpp \
tempmonster.cpp \
tentacle.cpp \ tentacle.cpp \
tempentity.cpp \
triggers.cpp \ triggers.cpp \
tripmine.cpp \ tripmine.cpp \
turret.cpp \ turret.cpp \

View File

@ -16,7 +16,6 @@
#ifndef ACTIVITY_H #ifndef ACTIVITY_H
#define ACTIVITY_H #define ACTIVITY_H
typedef enum { typedef enum {
ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity
ACT_IDLE = 1, ACT_IDLE = 1,
@ -94,16 +93,14 @@ typedef enum {
ACT_FLINCH_LEFTARM, ACT_FLINCH_LEFTARM,
ACT_FLINCH_RIGHTARM, ACT_FLINCH_RIGHTARM,
ACT_FLINCH_LEFTLEG, ACT_FLINCH_LEFTLEG,
ACT_FLINCH_RIGHTLEG, ACT_FLINCH_RIGHTLEG
} Activity; } Activity;
typedef struct
typedef struct { {
int type; int type;
char *name; char *name;
} activity_map_t; } activity_map_t;
extern activity_map_t activity_map[]; extern activity_map_t activity_map[];
#endif //ACTIVITY_H #endif //ACTIVITY_H

View File

@ -14,6 +14,7 @@
****/ ****/
//========================================================= //=========================================================
//========================================================= //=========================================================
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cbase.h" #include "cbase.h"
@ -55,7 +56,7 @@ TYPEDESCRIPTION CFlockingFlyerFlock::m_SaveData[] =
DEFINE_FIELD( CFlockingFlyerFlock, m_flFlockRadius, FIELD_FLOAT ), DEFINE_FIELD( CFlockingFlyerFlock, m_flFlockRadius, FIELD_FLOAT ),
}; };
IMPLEMENT_SAVERESTORE( CFlockingFlyerFlock, CBaseMonster ); IMPLEMENT_SAVERESTORE( CFlockingFlyerFlock, CBaseMonster )
//========================================================= //=========================================================
//========================================================= //=========================================================
@ -106,8 +107,9 @@ public:
float m_flAlertTime; float m_flAlertTime;
float m_flFlockNextSoundTime; float m_flFlockNextSoundTime;
}; };
LINK_ENTITY_TO_CLASS( monster_flyer, CFlockingFlyer );
LINK_ENTITY_TO_CLASS( monster_flyer_flock, CFlockingFlyerFlock ); LINK_ENTITY_TO_CLASS( monster_flyer, CFlockingFlyer )
LINK_ENTITY_TO_CLASS( monster_flyer_flock, CFlockingFlyerFlock )
TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] = TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] =
{ {
@ -122,60 +124,59 @@ TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] =
DEFINE_FIELD( CFlockingFlyer, m_flLastBlockedTime, FIELD_TIME ), DEFINE_FIELD( CFlockingFlyer, m_flLastBlockedTime, FIELD_TIME ),
DEFINE_FIELD( CFlockingFlyer, m_flFakeBlockedTime, FIELD_TIME ), DEFINE_FIELD( CFlockingFlyer, m_flFakeBlockedTime, FIELD_TIME ),
DEFINE_FIELD( CFlockingFlyer, m_flAlertTime, FIELD_TIME ), DEFINE_FIELD( CFlockingFlyer, m_flAlertTime, FIELD_TIME ),
// DEFINE_FIELD( CFlockingFlyer, m_flFlockNextSoundTime, FIELD_TIME ), // don't need to save //DEFINE_FIELD( CFlockingFlyer, m_flFlockNextSoundTime, FIELD_TIME ), // don't need to save
}; };
IMPLEMENT_SAVERESTORE( CFlockingFlyer, CBaseMonster ); IMPLEMENT_SAVERESTORE( CFlockingFlyer, CBaseMonster )
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyerFlock :: KeyValue( KeyValueData *pkvd ) void CFlockingFlyerFlock::KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "iFlockSize")) if( FStrEq( pkvd->szKeyName, "iFlockSize" ) )
{ {
m_cFlockSize = atoi(pkvd->szValue); m_cFlockSize = atoi( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "flFlockRadius")) else if( FStrEq( pkvd->szKeyName, "flFlockRadius" ) )
{ {
m_flFlockRadius = atof(pkvd->szValue); m_flFlockRadius = atof( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyerFlock :: Spawn( ) void CFlockingFlyerFlock::Spawn()
{ {
Precache( ); Precache();
SpawnFlock(); SpawnFlock();
REMOVE_ENTITY(ENT(pev)); // dump the spawn ent REMOVE_ENTITY( ENT( pev ) ); // dump the spawn ent
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyerFlock :: Precache( ) void CFlockingFlyerFlock::Precache()
{ {
//PRECACHE_MODEL("models/aflock.mdl"); //PRECACHE_MODEL( "models/aflock.mdl" );
PRECACHE_MODEL("models/boid.mdl"); PRECACHE_MODEL( "models/boid.mdl ");
PrecacheFlockSounds(); PrecacheFlockSounds();
} }
void CFlockingFlyerFlock::PrecacheFlockSounds( void )
void CFlockingFlyerFlock :: PrecacheFlockSounds( void )
{ {
PRECACHE_SOUND("boid/boid_alert1.wav" ); PRECACHE_SOUND( "boid/boid_alert1.wav" );
PRECACHE_SOUND("boid/boid_alert2.wav" ); PRECACHE_SOUND( "boid/boid_alert2.wav" );
PRECACHE_SOUND("boid/boid_idle1.wav" ); PRECACHE_SOUND( "boid/boid_idle1.wav" );
PRECACHE_SOUND("boid/boid_idle2.wav" ); PRECACHE_SOUND( "boid/boid_idle2.wav" );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyerFlock :: SpawnFlock( void ) void CFlockingFlyerFlock::SpawnFlock( void )
{ {
float R = m_flFlockRadius; float R = m_flFlockRadius;
int iCount; int iCount;
@ -184,11 +185,11 @@ void CFlockingFlyerFlock :: SpawnFlock( void )
pLeader = pBoid = NULL; pLeader = pBoid = NULL;
for ( iCount = 0 ; iCount < m_cFlockSize ; iCount++ ) for( iCount = 0; iCount < m_cFlockSize; iCount++ )
{ {
pBoid = GetClassPtr( (CFlockingFlyer *)NULL ); pBoid = GetClassPtr( (CFlockingFlyer *)NULL );
if ( !pLeader ) if( !pLeader )
{ {
// make this guy the leader. // make this guy the leader.
pLeader = pBoid; pLeader = pBoid;
@ -202,7 +203,7 @@ void CFlockingFlyerFlock :: SpawnFlock( void )
vecSpot.z = RANDOM_FLOAT( 0, 16 ); vecSpot.z = RANDOM_FLOAT( 0, 16 );
vecSpot = pev->origin + vecSpot; vecSpot = pev->origin + vecSpot;
UTIL_SetOrigin(pBoid->pev, vecSpot); UTIL_SetOrigin( pBoid->pev, vecSpot );
pBoid->pev->movetype = MOVETYPE_FLY; pBoid->pev->movetype = MOVETYPE_FLY;
pBoid->SpawnCommonCode(); pBoid->SpawnCommonCode();
pBoid->pev->flags &= ~FL_ONGROUND; pBoid->pev->flags &= ~FL_ONGROUND;
@ -211,9 +212,9 @@ void CFlockingFlyerFlock :: SpawnFlock( void )
pBoid->pev->frame = 0; pBoid->pev->frame = 0;
pBoid->pev->nextthink = gpGlobals->time + 0.2; pBoid->pev->nextthink = gpGlobals->time + 0.2;
pBoid->SetThink( &CFlockingFlyer :: IdleThink ); pBoid->SetThink( &CFlockingFlyer::IdleThink );
if ( pBoid != pLeader ) if( pBoid != pLeader )
{ {
pLeader->SquadAdd( pBoid ); pLeader->SquadAdd( pBoid );
} }
@ -222,9 +223,9 @@ void CFlockingFlyerFlock :: SpawnFlock( void )
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: Spawn( ) void CFlockingFlyer::Spawn()
{ {
Precache( ); Precache();
SpawnCommonCode(); SpawnCommonCode();
pev->frame = 0; pev->frame = 0;
@ -234,52 +235,60 @@ void CFlockingFlyer :: Spawn( )
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: Precache( ) void CFlockingFlyer::Precache()
{ {
//PRECACHE_MODEL("models/aflock.mdl"); //PRECACHE_MODEL( "models/aflock.mdl" );
PRECACHE_MODEL("models/boid.mdl"); PRECACHE_MODEL( "models/boid.mdl" );
CFlockingFlyerFlock::PrecacheFlockSounds(); CFlockingFlyerFlock::PrecacheFlockSounds();
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: MakeSound( void ) void CFlockingFlyer::MakeSound( void )
{ {
if ( m_flAlertTime > gpGlobals->time ) if( m_flAlertTime > gpGlobals->time )
{ {
// make agitated sounds // make agitated sounds
switch ( RANDOM_LONG( 0, 1 ) ) switch ( RANDOM_LONG( 0, 1 ) )
{ {
case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_alert1.wav", 1, ATTN_NORM ); break; case 0:
case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_alert2.wav", 1, ATTN_NORM ); break; EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "boid/boid_alert1.wav", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "boid/boid_alert2.wav", 1, ATTN_NORM );
break;
} }
return; return;
} }
// make normal sound // make normal sound
switch ( RANDOM_LONG( 0, 1 ) ) switch( RANDOM_LONG( 0, 1 ) )
{ {
case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle1.wav", 1, ATTN_NORM ); break; case 0:
case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle2.wav", 1, ATTN_NORM ); break; EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle1.wav", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle2.wav", 1, ATTN_NORM );
break;
} }
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: Killed( entvars_t *pevAttacker, int iGib ) void CFlockingFlyer::Killed( entvars_t *pevAttacker, int iGib )
{ {
CFlockingFlyer *pSquad; CFlockingFlyer *pSquad;
pSquad = (CFlockingFlyer *)m_pSquadLeader; pSquad = (CFlockingFlyer *)m_pSquadLeader;
while ( pSquad ) while( pSquad )
{ {
pSquad->m_flAlertTime = gpGlobals->time + 15; pSquad->m_flAlertTime = gpGlobals->time + 15;
pSquad = (CFlockingFlyer *)pSquad->m_pSquadNext; pSquad = (CFlockingFlyer *)pSquad->m_pSquadNext;
} }
if ( m_pSquadLeader ) if( m_pSquadLeader )
{ {
m_pSquadLeader->SquadRemove( this ); m_pSquadLeader->SquadRemove( this );
} }
@ -289,18 +298,18 @@ void CFlockingFlyer :: Killed( entvars_t *pevAttacker, int iGib )
pev->framerate = 0; pev->framerate = 0;
pev->effects = EF_NOINTERP; pev->effects = EF_NOINTERP;
UTIL_SetSize( pev, Vector(0,0,0), Vector(0,0,0) ); UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
pev->movetype = MOVETYPE_TOSS; pev->movetype = MOVETYPE_TOSS;
SetThink( &CFlockingFlyer::FallHack ); SetThink( &CFlockingFlyer::FallHack );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
} }
void CFlockingFlyer :: FallHack( void ) void CFlockingFlyer::FallHack( void )
{ {
if ( pev->flags & FL_ONGROUND ) if( pev->flags & FL_ONGROUND )
{ {
if ( !FClassnameIs ( pev->groundentity, "worldspawn" ) ) if( !FClassnameIs ( pev->groundentity, "worldspawn" ) )
{ {
pev->flags &= ~FL_ONGROUND; pev->flags &= ~FL_ONGROUND;
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
@ -315,10 +324,10 @@ void CFlockingFlyer :: FallHack( void )
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: SpawnCommonCode( ) void CFlockingFlyer::SpawnCommonCode()
{ {
pev->deadflag = DEAD_NO; pev->deadflag = DEAD_NO;
pev->classname = MAKE_STRING("monster_flyer"); pev->classname = MAKE_STRING( "monster_flyer" );
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
@ -327,31 +336,34 @@ void CFlockingFlyer :: SpawnCommonCode( )
m_fPathBlocked = FALSE;// obstacles will be detected m_fPathBlocked = FALSE;// obstacles will be detected
m_flFieldOfView = 0.2; m_flFieldOfView = 0.2;
//SET_MODEL(ENT(pev), "models/aflock.mdl"); //SET_MODEL( ENT( pev ), "models/aflock.mdl" );
SET_MODEL(ENT(pev), "models/boid.mdl"); SET_MODEL( ENT( pev ), "models/boid.mdl" );
// UTIL_SetSize(pev, Vector(0,0,0), Vector(0,0,0)); //UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
UTIL_SetSize(pev, Vector(-5,-5,0), Vector(5,5,2)); UTIL_SetSize( pev, Vector( -5, -5, 0 ), Vector( 5, 5, 2 ) );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: BoidAdvanceFrame ( ) void CFlockingFlyer::BoidAdvanceFrame()
{ {
float flapspeed = (pev->speed - pev->armorvalue) / AFLOCK_ACCELERATE; float flapspeed = ( pev->speed - pev->armorvalue ) / AFLOCK_ACCELERATE;
pev->armorvalue = pev->armorvalue * .8 + pev->speed * .2; pev->armorvalue = pev->armorvalue * .8 + pev->speed * .2;
if (flapspeed < 0) flapspeed = -flapspeed; if( flapspeed < 0 )
if (flapspeed < 0.25) flapspeed = 0.25; flapspeed = -flapspeed;
if (flapspeed > 1.9) flapspeed = 1.9; if( flapspeed < 0.25 )
flapspeed = 0.25;
if( flapspeed > 1.9 )
flapspeed = 1.9;
pev->framerate = flapspeed; pev->framerate = flapspeed;
// lean // lean
pev->avelocity.x = - (pev->angles.x + flapspeed * 5); pev->avelocity.x = -( pev->angles.x + flapspeed * 5 );
// bank // bank
pev->avelocity.z = - (pev->angles.z + pev->avelocity.y); pev->avelocity.z = -( pev->angles.z + pev->avelocity.y );
// pev->framerate = flapspeed; // pev->framerate = flapspeed;
StudioFrameAdvance( 0.1 ); StudioFrameAdvance( 0.1 );
@ -359,12 +371,12 @@ void CFlockingFlyer :: BoidAdvanceFrame ( )
//========================================================= //=========================================================
//========================================================= //=========================================================
void CFlockingFlyer :: IdleThink( void ) void CFlockingFlyer::IdleThink( void )
{ {
pev->nextthink = gpGlobals->time + 0.2; pev->nextthink = gpGlobals->time + 0.2;
// see if there's a client in the same pvs as the monster // see if there's a client in the same pvs as the monster
if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) )
{ {
SetThink( &CFlockingFlyer::Start ); SetThink( &CFlockingFlyer::Start );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
@ -374,11 +386,11 @@ void CFlockingFlyer :: IdleThink( void )
//========================================================= //=========================================================
// Start - player enters the pvs, so get things going. // Start - player enters the pvs, so get things going.
//========================================================= //=========================================================
void CFlockingFlyer :: Start( void ) void CFlockingFlyer::Start( void )
{ {
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
if ( IsLeader() ) if( IsLeader() )
{ {
SetThink( &CFlockingFlyer::FlockLeaderThink ); SetThink( &CFlockingFlyer::FlockLeaderThink );
} }
@ -386,24 +398,22 @@ void CFlockingFlyer :: Start( void )
{ {
SetThink( &CFlockingFlyer::FlockFollowerThink ); SetThink( &CFlockingFlyer::FlockFollowerThink );
} }
/* /*
Vector vecTakeOff; Vector vecTakeOff;
vecTakeOff = Vector ( 0 , 0 , 0 ); vecTakeOff = Vector( 0, 0, 0 );
vecTakeOff.z = 50 + RANDOM_FLOAT ( 0, 100 ); vecTakeOff.z = 50 + RANDOM_FLOAT( 0, 100 );
vecTakeOff.x = 20 - RANDOM_FLOAT ( 0, 40); vecTakeOff.x = 20 - RANDOM_FLOAT( 0, 40 );
vecTakeOff.y = 20 - RANDOM_FLOAT ( 0, 40); vecTakeOff.y = 20 - RANDOM_FLOAT( 0, 40 );
pev->velocity = vecTakeOff; pev->velocity = vecTakeOff;
pev->speed = pev->velocity.Length(); pev->speed = pev->velocity.Length();
pev->sequence = 0; pev->sequence = 0;
*/ */
SetActivity ( ACT_FLY ); SetActivity( ACT_FLY );
ResetSequenceInfo( ); ResetSequenceInfo();
BoidAdvanceFrame( ); BoidAdvanceFrame();
pev->speed = AFLOCK_FLY_SPEED;// no delay! pev->speed = AFLOCK_FLY_SPEED;// no delay!
} }
@ -411,9 +421,9 @@ void CFlockingFlyer :: Start( void )
//========================================================= //=========================================================
// Leader boid calls this to form a flock from surrounding boids // Leader boid calls this to form a flock from surrounding boids
//========================================================= //=========================================================
void CFlockingFlyer :: FormFlock( void ) void CFlockingFlyer::FormFlock( void )
{ {
if ( !InSquad() ) if( !InSquad() )
{ {
// I am my own leader // I am my own leader
m_pSquadLeader = this; m_pSquadLeader = this;
@ -422,14 +432,14 @@ void CFlockingFlyer :: FormFlock( void )
CBaseEntity *pEntity = NULL; CBaseEntity *pEntity = NULL;
while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, AFLOCK_MAX_RECRUIT_RADIUS )) != NULL) while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, AFLOCK_MAX_RECRUIT_RADIUS ) ) != NULL )
{ {
CBaseMonster *pRecruit = pEntity->MyMonsterPointer( ); CBaseMonster *pRecruit = pEntity->MyMonsterPointer();
if ( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine ) if( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine )
{ {
// Can we recruit this guy? // Can we recruit this guy?
if ( FClassnameIs ( pRecruit->pev, "monster_flyer" ) ) if( FClassnameIs ( pRecruit->pev, "monster_flyer" ) )
{ {
squadCount++; squadCount++;
SquadAdd( (CFlockingFlyer *)pRecruit ); SquadAdd( (CFlockingFlyer *)pRecruit );
@ -445,18 +455,18 @@ void CFlockingFlyer :: FormFlock( void )
//========================================================= //=========================================================
// Searches for boids that are too close and pushes them away // Searches for boids that are too close and pushes them away
//========================================================= //=========================================================
void CFlockingFlyer :: SpreadFlock( ) void CFlockingFlyer::SpreadFlock()
{ {
Vector vecDir; Vector vecDir;
float flSpeed;// holds vector magnitude while we fiddle with the direction float flSpeed;// holds vector magnitude while we fiddle with the direction
CFlockingFlyer *pList = m_pSquadLeader; CFlockingFlyer *pList = m_pSquadLeader;
while ( pList ) while( pList )
{ {
if ( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE ) if( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE )
{ {
// push the other away // push the other away
vecDir = ( pList->pev->origin - pev->origin ); vecDir = pList->pev->origin - pev->origin;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
// store the magnitude of the other boid's velocity, and normalize it so we // store the magnitude of the other boid's velocity, and normalize it so we
@ -476,19 +486,19 @@ void CFlockingFlyer :: SpreadFlock( )
// //
// This function should **ONLY** be called when Caller's velocity is normalized!! // This function should **ONLY** be called when Caller's velocity is normalized!!
//========================================================= //=========================================================
void CFlockingFlyer :: SpreadFlock2 ( ) void CFlockingFlyer::SpreadFlock2()
{ {
Vector vecDir; Vector vecDir;
CFlockingFlyer *pList = m_pSquadLeader; CFlockingFlyer *pList = m_pSquadLeader;
while ( pList ) while( pList )
{ {
if ( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE ) if( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE )
{ {
vecDir = ( pev->origin - pList->pev->origin ); vecDir = pev->origin - pList->pev->origin;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
pev->velocity = (pev->velocity + vecDir); pev->velocity = pev->velocity + vecDir;
} }
pList = pList->m_pSquadNext; pList = pList->m_pSquadNext;
@ -498,14 +508,14 @@ void CFlockingFlyer :: SpreadFlock2 ( )
//========================================================= //=========================================================
// FBoidPathBlocked - returns TRUE if there is an obstacle ahead // FBoidPathBlocked - returns TRUE if there is an obstacle ahead
//========================================================= //=========================================================
BOOL CFlockingFlyer :: FPathBlocked( ) BOOL CFlockingFlyer::FPathBlocked()
{ {
TraceResult tr; TraceResult tr;
Vector vecDist;// used for general measurements Vector vecDist;// used for general measurements
Vector vecDir;// used for general measurements Vector vecDir;// used for general measurements
BOOL fBlocked; BOOL fBlocked;
if ( m_flFakeBlockedTime > gpGlobals->time ) if( m_flFakeBlockedTime > gpGlobals->time )
{ {
m_flLastBlockedTime = gpGlobals->time; m_flLastBlockedTime = gpGlobals->time;
return TRUE; return TRUE;
@ -518,42 +528,41 @@ BOOL CFlockingFlyer :: FPathBlocked( )
fBlocked = FALSE;// assume the way ahead is clear fBlocked = FALSE;// assume the way ahead is clear
// check for obstacle ahead // check for obstacle ahead
UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
if (tr.flFraction != 1.0) if( tr.flFraction != 1.0 )
{ {
m_flLastBlockedTime = gpGlobals->time; m_flLastBlockedTime = gpGlobals->time;
fBlocked = TRUE; fBlocked = TRUE;
} }
// extra wide checks // extra wide checks
UTIL_TraceLine(pev->origin + gpGlobals->v_right * 12, pev->origin + gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin + gpGlobals->v_right * 12, pev->origin + gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
if (tr.flFraction != 1.0) if( tr.flFraction != 1.0 )
{ {
m_flLastBlockedTime = gpGlobals->time; m_flLastBlockedTime = gpGlobals->time;
fBlocked = TRUE; fBlocked = TRUE;
} }
UTIL_TraceLine(pev->origin - gpGlobals->v_right * 12, pev->origin - gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin - gpGlobals->v_right * 12, pev->origin - gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
if (tr.flFraction != 1.0) if( tr.flFraction != 1.0 )
{ {
m_flLastBlockedTime = gpGlobals->time; m_flLastBlockedTime = gpGlobals->time;
fBlocked = TRUE; fBlocked = TRUE;
} }
if ( !fBlocked && gpGlobals->time - m_flLastBlockedTime > 6 ) if( !fBlocked && gpGlobals->time - m_flLastBlockedTime > 6 )
{ {
// not blocked, and it's been a few seconds since we've actually been blocked. // not blocked, and it's been a few seconds since we've actually been blocked.
m_flFakeBlockedTime = gpGlobals->time + RANDOM_LONG(1, 3); m_flFakeBlockedTime = gpGlobals->time + RANDOM_LONG( 1, 3 );
} }
return fBlocked; return fBlocked;
} }
//========================================================= //=========================================================
// Leader boids use this think every tenth // Leader boids use this think every tenth
//========================================================= //=========================================================
void CFlockingFlyer :: FlockLeaderThink( void ) void CFlockingFlyer::FlockLeaderThink( void )
{ {
TraceResult tr; TraceResult tr;
Vector vecDist;// used for general measurements Vector vecDist;// used for general measurements
@ -562,16 +571,15 @@ void CFlockingFlyer :: FlockLeaderThink( void )
float flLeftSide; float flLeftSide;
float flRightSide; float flRightSide;
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
UTIL_MakeVectors ( pev->angles ); UTIL_MakeVectors( pev->angles );
// is the way ahead clear? // is the way ahead clear?
if ( !FPathBlocked () ) if( !FPathBlocked () )
{ {
// if the boid is turning, stop the trend. // if the boid is turning, stop the trend.
if ( m_fTurning ) if( m_fTurning )
{ {
m_fTurning = FALSE; m_fTurning = FALSE;
pev->avelocity.y = 0; pev->avelocity.y = 0;
@ -579,12 +587,12 @@ void CFlockingFlyer :: FlockLeaderThink( void )
m_fPathBlocked = FALSE; m_fPathBlocked = FALSE;
if (pev->speed <= AFLOCK_FLY_SPEED ) if( pev->speed <= AFLOCK_FLY_SPEED )
pev->speed+= 5; pev->speed += 5;
pev->velocity = gpGlobals->v_forward * pev->speed; pev->velocity = gpGlobals->v_forward * pev->speed;
BoidAdvanceFrame( ); BoidAdvanceFrame();
return; return;
} }
@ -592,25 +600,25 @@ void CFlockingFlyer :: FlockLeaderThink( void )
// IF we get this far in the function, the leader's path is blocked! // IF we get this far in the function, the leader's path is blocked!
m_fPathBlocked = TRUE; m_fPathBlocked = TRUE;
if ( !m_fTurning)// something in the way and boid is not already turning to avoid if( !m_fTurning )// something in the way and boid is not already turning to avoid
{ {
// measure clearance on left and right to pick the best dir to turn // measure clearance on left and right to pick the best dir to turn
UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
vecDist = (tr.vecEndPos - pev->origin); vecDist = ( tr.vecEndPos - pev->origin );
flRightSide = vecDist.Length(); flRightSide = vecDist.Length();
UTIL_TraceLine(pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
vecDist = (tr.vecEndPos - pev->origin); vecDist = tr.vecEndPos - pev->origin;
flLeftSide = vecDist.Length(); flLeftSide = vecDist.Length();
// turn right if more clearance on right side // turn right if more clearance on right side
if ( flRightSide > flLeftSide ) if( flRightSide > flLeftSide )
{ {
pev->avelocity.y = -AFLOCK_TURN_RATE; pev->avelocity.y = -AFLOCK_TURN_RATE;
m_fTurning = TRUE; m_fTurning = TRUE;
} }
// default to left turn :) // default to left turn :)
else if ( flLeftSide > flRightSide ) else if( flLeftSide > flRightSide )
{ {
pev->avelocity.y = AFLOCK_TURN_RATE; pev->avelocity.y = AFLOCK_TURN_RATE;
m_fTurning = TRUE; m_fTurning = TRUE;
@ -620,7 +628,7 @@ void CFlockingFlyer :: FlockLeaderThink( void )
// equidistant. Pick randomly between left and right. // equidistant. Pick randomly between left and right.
m_fTurning = TRUE; m_fTurning = TRUE;
if ( RANDOM_LONG( 0, 1 ) == 0 ) if( RANDOM_LONG( 0, 1 ) == 0 )
{ {
pev->avelocity.y = AFLOCK_TURN_RATE; pev->avelocity.y = AFLOCK_TURN_RATE;
} }
@ -630,23 +638,23 @@ void CFlockingFlyer :: FlockLeaderThink( void )
} }
} }
} }
SpreadFlock( ); SpreadFlock();
pev->velocity = gpGlobals->v_forward * pev->speed; pev->velocity = gpGlobals->v_forward * pev->speed;
// check and make sure we aren't about to plow into the ground, don't let it happen // check and make sure we aren't about to plow into the ground, don't let it happen
UTIL_TraceLine(pev->origin, pev->origin - gpGlobals->v_up * 16, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_up * 16, ignore_monsters, ENT( pev ), &tr );
if (tr.flFraction != 1.0 && pev->velocity.z < 0 ) if( tr.flFraction != 1.0 && pev->velocity.z < 0 )
pev->velocity.z = 0; pev->velocity.z = 0;
// maybe it did, though. // maybe it did, though.
if ( FBitSet (pev->flags, FL_ONGROUND) ) if( FBitSet( pev->flags, FL_ONGROUND ) )
{ {
UTIL_SetOrigin (pev, pev->origin + Vector ( 0 , 0 , 1 ) ); UTIL_SetOrigin( pev, pev->origin + Vector( 0, 0, 1 ) );
pev->velocity.z = 0; pev->velocity.z = 0;
} }
if ( m_flFlockNextSoundTime < gpGlobals->time ) if( m_flFlockNextSoundTime < gpGlobals->time )
{ {
MakeSound(); MakeSound();
m_flFlockNextSoundTime = gpGlobals->time + RANDOM_FLOAT( 1, 3 ); m_flFlockNextSoundTime = gpGlobals->time + RANDOM_FLOAT( 1, 3 );
@ -660,7 +668,7 @@ void CFlockingFlyer :: FlockLeaderThink( void )
//========================================================= //=========================================================
// follower boids execute this code when flocking // follower boids execute this code when flocking
//========================================================= //=========================================================
void CFlockingFlyer :: FlockFollowerThink( void ) void CFlockingFlyer::FlockFollowerThink( void )
{ {
TraceResult tr; TraceResult tr;
Vector vecDist; Vector vecDist;
@ -670,7 +678,7 @@ void CFlockingFlyer :: FlockFollowerThink( void )
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
if ( IsLeader() || !InSquad() ) if( IsLeader() || !InSquad() )
{ {
// the leader has been killed and this flyer suddenly finds himself the leader. // the leader has been killed and this flyer suddenly finds himself the leader.
SetThink( &CFlockingFlyer::FlockLeaderThink ); SetThink( &CFlockingFlyer::FlockLeaderThink );
@ -686,16 +694,16 @@ void CFlockingFlyer :: FlockFollowerThink( void )
// //
// We can see the leader, so try to catch up to it // We can see the leader, so try to catch up to it
// //
if ( FInViewCone ( m_pSquadLeader ) ) if( FInViewCone ( m_pSquadLeader ) )
{ {
// if we're too far away, speed up // if we're too far away, speed up
if ( flDistToLeader > AFLOCK_TOO_FAR ) if( flDistToLeader > AFLOCK_TOO_FAR )
{ {
m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 1.5; m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 1.5;
} }
// if we're too close, slow down // if we're too close, slow down
else if ( flDistToLeader < AFLOCK_TOO_CLOSE ) else if( flDistToLeader < AFLOCK_TOO_CLOSE )
{ {
m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5; m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5;
} }
@ -712,23 +720,23 @@ void CFlockingFlyer :: FlockFollowerThink( void )
pev->velocity = pev->velocity.Normalize(); pev->velocity = pev->velocity.Normalize();
// if we are too far from leader, average a vector towards it into our current velocity // if we are too far from leader, average a vector towards it into our current velocity
if ( flDistToLeader > AFLOCK_TOO_FAR ) if( flDistToLeader > AFLOCK_TOO_FAR )
{ {
vecDirToLeader = vecDirToLeader.Normalize(); vecDirToLeader = vecDirToLeader.Normalize();
pev->velocity = (pev->velocity + vecDirToLeader) * 0.5; pev->velocity = (pev->velocity + vecDirToLeader) * 0.5;
} }
// clamp speeds and handle acceleration // clamp speeds and handle acceleration
if ( m_flGoalSpeed > AFLOCK_FLY_SPEED * 2 ) if( m_flGoalSpeed > AFLOCK_FLY_SPEED * 2 )
{ {
m_flGoalSpeed = AFLOCK_FLY_SPEED * 2; m_flGoalSpeed = AFLOCK_FLY_SPEED * 2;
} }
if ( pev->speed < m_flGoalSpeed ) if( pev->speed < m_flGoalSpeed )
{ {
pev->speed += AFLOCK_ACCELERATE; pev->speed += AFLOCK_ACCELERATE;
} }
else if ( pev->speed > m_flGoalSpeed ) else if( pev->speed > m_flGoalSpeed )
{ {
pev->speed -= AFLOCK_ACCELERATE; pev->speed -= AFLOCK_ACCELERATE;
} }
@ -740,11 +748,11 @@ void CFlockingFlyer :: FlockFollowerThink( void )
/* /*
// Is this boid's course blocked? // Is this boid's course blocked?
if ( FBoidPathBlocked (pev) ) if( FBoidPathBlocked( pev ) )
{ {
// course is still blocked from last time. Just keep flying along adjusted // course is still blocked from last time. Just keep flying along adjusted
// velocity // velocity
if ( m_fCourseAdjust ) if( m_fCourseAdjust )
{ {
pev->velocity = m_vecAdjustedVelocity * pev->speed; pev->velocity = m_vecAdjustedVelocity * pev->speed;
return; return;
@ -755,21 +763,21 @@ void CFlockingFlyer :: FlockFollowerThink( void )
// use VELOCITY, not angles, not all boids point the direction they are flying // use VELOCITY, not angles, not all boids point the direction they are flying
//vecDir = UTIL_VecToAngles( pev->velocity ); //vecDir = UTIL_VecToAngles( pev->velocity );
//UTIL_MakeVectors ( vecDir ); //UTIL_MakeVectors( vecDir );
UTIL_MakeVectors ( pev->angles ); UTIL_MakeVectors( pev->angles );
// measure clearance on left and right to pick the best dir to turn // measure clearance on left and right to pick the best dir to turn
UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
vecDist = (tr.vecEndPos - pev->origin); vecDist = tr.vecEndPos - pev->origin;
flRightSide = vecDist.Length(); flRightSide = vecDist.Length();
UTIL_TraceLine(pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr );
vecDist = (tr.vecEndPos - pev->origin); vecDist = tr.vecEndPos - pev->origin;
flLeftSide = vecDist.Length(); flLeftSide = vecDist.Length();
// slide right if more clearance on right side // slide right if more clearance on right side
if ( flRightSide > flLeftSide ) if( flRightSide > flLeftSide )
{ {
m_vecAdjustedVelocity = gpGlobals->v_right; m_vecAdjustedVelocity = gpGlobals->v_right;
} }
@ -786,13 +794,12 @@ void CFlockingFlyer :: FlockFollowerThink( void )
m_fCourseAdjust = FALSE; m_fCourseAdjust = FALSE;
*/ */
//========================================================= //=========================================================
// //
// SquadUnlink(), Unlink the squad pointers. // SquadUnlink(), Unlink the squad pointers.
// //
//========================================================= //=========================================================
void CFlockingFlyer :: SquadUnlink( void ) void CFlockingFlyer::SquadUnlink( void )
{ {
m_pSquadLeader = NULL; m_pSquadLeader = NULL;
m_pSquadNext = NULL; m_pSquadNext = NULL;
@ -803,9 +810,9 @@ void CFlockingFlyer :: SquadUnlink( void )
// SquadAdd(), add pAdd to my squad // SquadAdd(), add pAdd to my squad
// //
//========================================================= //=========================================================
void CFlockingFlyer :: SquadAdd( CFlockingFlyer *pAdd ) void CFlockingFlyer::SquadAdd( CFlockingFlyer *pAdd )
{ {
ASSERT( pAdd!=NULL ); ASSERT( pAdd != NULL );
ASSERT( !pAdd->InSquad() ); ASSERT( !pAdd->InSquad() );
ASSERT( this->IsLeader() ); ASSERT( this->IsLeader() );
@ -813,33 +820,34 @@ void CFlockingFlyer :: SquadAdd( CFlockingFlyer *pAdd )
m_pSquadNext = pAdd; m_pSquadNext = pAdd;
pAdd->m_pSquadLeader = this; pAdd->m_pSquadLeader = this;
} }
//========================================================= //=========================================================
// //
// SquadRemove(), remove pRemove from my squad. // SquadRemove(), remove pRemove from my squad.
// If I am pRemove, promote m_pSquadNext to leader // If I am pRemove, promote m_pSquadNext to leader
// //
//========================================================= //=========================================================
void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove ) void CFlockingFlyer::SquadRemove( CFlockingFlyer *pRemove )
{ {
ASSERT( pRemove!=NULL ); ASSERT( pRemove != NULL );
ASSERT( this->IsLeader() ); ASSERT( this->IsLeader() );
ASSERT( pRemove->m_pSquadLeader == this ); ASSERT( pRemove->m_pSquadLeader == this );
if ( SquadCount() > 2 ) if( SquadCount() > 2 )
{ {
// Removing the leader, promote m_pSquadNext to leader // Removing the leader, promote m_pSquadNext to leader
if ( pRemove == this ) if( pRemove == this )
{ {
CFlockingFlyer *pLeader = m_pSquadNext; CFlockingFlyer *pLeader = m_pSquadNext;
// copy the enemy LKP to the new leader // copy the enemy LKP to the new leader
pLeader->m_vecEnemyLKP = m_vecEnemyLKP; pLeader->m_vecEnemyLKP = m_vecEnemyLKP;
if ( pLeader ) if( pLeader )
{ {
CFlockingFlyer *pList = pLeader; CFlockingFlyer *pList = pLeader;
while ( pList ) while( pList )
{ {
pList->m_pSquadLeader = pLeader; pList->m_pSquadLeader = pLeader;
pList = pList->m_pSquadNext; pList = pList->m_pSquadNext;
@ -853,7 +861,7 @@ void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove )
CFlockingFlyer *pList = this; CFlockingFlyer *pList = this;
// Find the node before pRemove // Find the node before pRemove
while ( pList->m_pSquadNext != pRemove ) while( pList->m_pSquadNext != pRemove )
{ {
// assert to test valid list construction // assert to test valid list construction
ASSERT( pList->m_pSquadNext != NULL ); ASSERT( pList->m_pSquadNext != NULL );
@ -872,17 +880,18 @@ void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove )
else else
SquadDisband(); SquadDisband();
} }
//========================================================= //=========================================================
// //
// SquadCount(), return the number of members of this squad // SquadCount(), return the number of members of this squad
// callable from leaders & followers // callable from leaders & followers
// //
//========================================================= //=========================================================
int CFlockingFlyer :: SquadCount( void ) int CFlockingFlyer::SquadCount( void )
{ {
CFlockingFlyer *pList = m_pSquadLeader; CFlockingFlyer *pList = m_pSquadLeader;
int squadCount = 0; int squadCount = 0;
while ( pList ) while( pList )
{ {
squadCount++; squadCount++;
pList = pList->m_pSquadNext; pList = pList->m_pSquadNext;
@ -896,12 +905,12 @@ int CFlockingFlyer :: SquadCount( void )
// SquadDisband(), Unlink all squad members // SquadDisband(), Unlink all squad members
// //
//========================================================= //=========================================================
void CFlockingFlyer :: SquadDisband( void ) void CFlockingFlyer::SquadDisband( void )
{ {
CFlockingFlyer *pList = m_pSquadLeader; CFlockingFlyer *pList = m_pSquadLeader;
CFlockingFlyer *pNext; CFlockingFlyer *pNext;
while ( pList ) while( pList )
{ {
pNext = pList->m_pSquadNext; pNext = pList->m_pSquadNext;
pList->SquadUnlink(); pList->SquadUnlink();

View File

@ -32,7 +32,7 @@
enum enum
{ {
SCHED_AGRUNT_SUPPRESS = LAST_COMMON_SCHEDULE + 1, SCHED_AGRUNT_SUPPRESS = LAST_COMMON_SCHEDULE + 1,
SCHED_AGRUNT_THREAT_DISPLAY, SCHED_AGRUNT_THREAT_DISPLAY
}; };
//========================================================= //=========================================================
@ -41,7 +41,7 @@ enum
enum enum
{ {
TASK_AGRUNT_SETUP_HIDE_ATTACK = LAST_COMMON_TASK + 1, TASK_AGRUNT_SETUP_HIDE_ATTACK = LAST_COMMON_TASK + 1,
TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE, TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE
}; };
int iAgruntMuzzleFlash; int iAgruntMuzzleFlash;
@ -64,8 +64,6 @@ int iAgruntMuzzleFlash;
#define AGRUNT_AE_LEFT_PUNCH ( 12 ) #define AGRUNT_AE_LEFT_PUNCH ( 12 )
#define AGRUNT_AE_RIGHT_PUNCH ( 13 ) #define AGRUNT_AE_RIGHT_PUNCH ( 13 )
#define AGRUNT_MELEE_DIST 100 #define AGRUNT_MELEE_DIST 100
class CAGrunt : public CSquadMonster class CAGrunt : public CSquadMonster
@ -73,9 +71,9 @@ class CAGrunt : public CSquadMonster
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void SetYawSpeed ( void ); void SetYawSpeed( void );
int Classify ( void ); int Classify( void );
int ISoundMask ( void ); int ISoundMask( void );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );
void SetObjectCollisionBox( void ) void SetObjectCollisionBox( void )
{ {
@ -83,22 +81,22 @@ public:
pev->absmax = pev->origin + Vector( 32, 32, 85 ); pev->absmax = pev->origin + Vector( 32, 32, 85 );
} }
Schedule_t* GetSchedule ( void ); Schedule_t *GetSchedule( void );
Schedule_t* GetScheduleOfType ( int Type ); Schedule_t *GetScheduleOfType( int Type );
BOOL FCanCheckAttacks ( void ); BOOL FCanCheckAttacks( void );
BOOL CheckMeleeAttack1 ( float flDot, float flDist ); BOOL CheckMeleeAttack1( float flDot, float flDist );
BOOL CheckRangeAttack1 ( float flDot, float flDist ); BOOL CheckRangeAttack1( float flDot, float flDist );
void StartTask ( Task_t *pTask ); void StartTask( Task_t *pTask );
void AlertSound( void ); void AlertSound( void );
void DeathSound ( void ); void DeathSound( void );
void PainSound ( void ); void PainSound( void );
void AttackSound ( void ); void AttackSound( void );
void PrescheduleThink ( void ); void PrescheduleThink( void );
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
int IRelationship( CBaseEntity *pTarget ); int IRelationship( CBaseEntity *pTarget );
void StopTalking ( void ); void StopTalking( void );
BOOL ShouldSpeak( void ); BOOL ShouldSpeak( void );
CUSTOM_SCHEDULES; CUSTOM_SCHEDULES
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
@ -122,7 +120,8 @@ public:
float m_flNextWordTime; float m_flNextWordTime;
int m_iLastWord; int m_iLastWord;
}; };
LINK_ENTITY_TO_CLASS( monster_alien_grunt, CAGrunt );
LINK_ENTITY_TO_CLASS( monster_alien_grunt, CAGrunt )
TYPEDESCRIPTION CAGrunt::m_SaveData[] = TYPEDESCRIPTION CAGrunt::m_SaveData[] =
{ {
@ -134,7 +133,7 @@ TYPEDESCRIPTION CAGrunt::m_SaveData[] =
DEFINE_FIELD( CAGrunt, m_iLastWord, FIELD_INTEGER ), DEFINE_FIELD( CAGrunt, m_iLastWord, FIELD_INTEGER ),
}; };
IMPLEMENT_SAVERESTORE( CAGrunt, CSquadMonster ); IMPLEMENT_SAVERESTORE( CAGrunt, CSquadMonster )
const char *CAGrunt::pAttackHitSounds[] = const char *CAGrunt::pAttackHitSounds[] =
{ {
@ -192,42 +191,39 @@ const char *CAGrunt::pAlertSounds[] =
// IRelationship - overridden because Human Grunts are // IRelationship - overridden because Human Grunts are
// Alien Grunt's nemesis. // Alien Grunt's nemesis.
//========================================================= //=========================================================
int CAGrunt::IRelationship ( CBaseEntity *pTarget ) int CAGrunt::IRelationship( CBaseEntity *pTarget )
{ {
if ( FClassnameIs( pTarget->pev, "monster_human_grunt" ) ) if( FClassnameIs( pTarget->pev, "monster_human_grunt" ) )
{ {
return R_NM; return R_NM;
} }
return CSquadMonster :: IRelationship( pTarget ); return CSquadMonster::IRelationship( pTarget );
} }
//========================================================= //=========================================================
// ISoundMask // ISoundMask
//========================================================= //=========================================================
int CAGrunt :: ISoundMask ( void ) int CAGrunt::ISoundMask( void )
{ {
return bits_SOUND_WORLD | return ( bits_SOUND_WORLD | bits_SOUND_COMBAT | bits_SOUND_PLAYER | bits_SOUND_DANGER );
bits_SOUND_COMBAT |
bits_SOUND_PLAYER |
bits_SOUND_DANGER;
} }
//========================================================= //=========================================================
// TraceAttack // TraceAttack
//========================================================= //=========================================================
void CAGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) void CAGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType )
{ {
if ( ptr->iHitgroup == 10 && (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_CLUB))) if( ptr->iHitgroup == 10 && ( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_CLUB ) ) )
{ {
// hit armor // hit armor
if ( pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0,10) < 1) ) if( pev->dmgtime != gpGlobals->time || ( RANDOM_LONG( 0, 10 ) < 1 ) )
{ {
UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2) ); UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2 ) );
pev->dmgtime = gpGlobals->time; pev->dmgtime = gpGlobals->time;
} }
if ( RANDOM_LONG( 0, 1 ) == 0 ) if( RANDOM_LONG( 0, 1 ) == 0 )
{ {
Vector vecTracerDir = vecDir; Vector vecTracerDir = vecDir;
@ -250,12 +246,12 @@ void CAGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecD
} }
flDamage -= 20; flDamage -= 20;
if (flDamage <= 0) if( flDamage <= 0 )
flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated
} }
else else
{ {
SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage);// a little surface blood. SpawnBlood( ptr->vecEndPos, BloodColor(), flDamage );// a little surface blood.
TraceBleed( flDamage, vecDir, ptr, bitsDamageType ); TraceBleed( flDamage, vecDir, ptr, bitsDamageType );
} }
@ -267,7 +263,7 @@ void CAGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecD
//========================================================= //=========================================================
void CAGrunt::StopTalking( void ) void CAGrunt::StopTalking( void )
{ {
m_flNextWordTime = m_flNextSpeakTime = gpGlobals->time + 10 + RANDOM_LONG(0, 10); m_flNextWordTime = m_flNextSpeakTime = gpGlobals->time + 10 + RANDOM_LONG( 0, 10 );
} }
//========================================================= //=========================================================
@ -275,15 +271,15 @@ void CAGrunt::StopTalking( void )
//========================================================= //=========================================================
BOOL CAGrunt::ShouldSpeak( void ) BOOL CAGrunt::ShouldSpeak( void )
{ {
if ( m_flNextSpeakTime > gpGlobals->time ) if( m_flNextSpeakTime > gpGlobals->time )
{ {
// my time to talk is still in the future. // my time to talk is still in the future.
return FALSE; return FALSE;
} }
if ( pev->spawnflags & SF_MONSTER_GAG ) if( pev->spawnflags & SF_MONSTER_GAG )
{ {
if ( m_MonsterState != MONSTERSTATE_COMBAT ) if( m_MonsterState != MONSTERSTATE_COMBAT )
{ {
// if gagged, don't talk outside of combat. // if gagged, don't talk outside of combat.
// if not going to talk because of this, put the talk time // if not going to talk because of this, put the talk time
@ -300,26 +296,26 @@ BOOL CAGrunt::ShouldSpeak( void )
//========================================================= //=========================================================
// PrescheduleThink // PrescheduleThink
//========================================================= //=========================================================
void CAGrunt :: PrescheduleThink ( void ) void CAGrunt::PrescheduleThink( void )
{ {
if ( ShouldSpeak() ) if( ShouldSpeak() )
{ {
if ( m_flNextWordTime < gpGlobals->time ) if( m_flNextWordTime < gpGlobals->time )
{ {
int num = -1; int num = -1;
do do
{ {
num = RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1); num = RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) - 1 );
} while( num == m_iLastWord ); } while( num == m_iLastWord );
m_iLastWord = num; m_iLastWord = num;
// play a new sound // play a new sound
EMIT_SOUND ( ENT(pev), CHAN_VOICE, pIdleSounds[ num ], 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_VOICE, pIdleSounds[num], 1.0, ATTN_NORM );
// is this word our last? // is this word our last?
if ( RANDOM_LONG( 1, 10 ) <= 1 ) if( RANDOM_LONG( 1, 10 ) <= 1 )
{ {
// stop talking. // stop talking.
StopTalking(); StopTalking();
@ -335,39 +331,39 @@ void CAGrunt :: PrescheduleThink ( void )
//========================================================= //=========================================================
// DieSound // DieSound
//========================================================= //=========================================================
void CAGrunt :: DeathSound ( void ) void CAGrunt::DeathSound( void )
{ {
StopTalking(); StopTalking();
EMIT_SOUND ( ENT(pev), CHAN_VOICE, pDieSounds[RANDOM_LONG(0,ARRAYSIZE(pDieSounds)-1)], 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_VOICE, pDieSounds[RANDOM_LONG( 0, ARRAYSIZE( pDieSounds ) - 1 )], 1.0, ATTN_NORM );
} }
//========================================================= //=========================================================
// AlertSound // AlertSound
//========================================================= //=========================================================
void CAGrunt :: AlertSound ( void ) void CAGrunt::AlertSound( void )
{ {
StopTalking(); StopTalking();
EMIT_SOUND ( ENT(pev), CHAN_VOICE, pAlertSounds[RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1)], 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM );
} }
//========================================================= //=========================================================
// AttackSound // AttackSound
//========================================================= //=========================================================
void CAGrunt :: AttackSound ( void ) void CAGrunt::AttackSound( void )
{ {
StopTalking(); StopTalking();
EMIT_SOUND ( ENT(pev), CHAN_VOICE, pAttackSounds[RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1)], 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM );
} }
//========================================================= //=========================================================
// PainSound // PainSound
//========================================================= //=========================================================
void CAGrunt :: PainSound ( void ) void CAGrunt::PainSound( void )
{ {
if ( m_flNextPainTime > gpGlobals->time ) if( m_flNextPainTime > gpGlobals->time )
{ {
return; return;
} }
@ -376,14 +372,14 @@ void CAGrunt :: PainSound ( void )
StopTalking(); StopTalking();
EMIT_SOUND ( ENT(pev), CHAN_VOICE, pPainSounds[RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1)], 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM );
} }
//========================================================= //=========================================================
// Classify - indicates this monster's place in the // Classify - indicates this monster's place in the
// relationship table. // relationship table.
//========================================================= //=========================================================
int CAGrunt :: Classify ( void ) int CAGrunt::Classify( void )
{ {
return CLASS_ALIEN_MILITARY; return CLASS_ALIEN_MILITARY;
} }
@ -392,17 +388,19 @@ int CAGrunt :: Classify ( void )
// SetYawSpeed - allows each sequence to have a different // SetYawSpeed - allows each sequence to have a different
// turn rate associated with it. // turn rate associated with it.
//========================================================= //=========================================================
void CAGrunt :: SetYawSpeed ( void ) void CAGrunt::SetYawSpeed( void )
{ {
int ys; int ys;
switch ( m_Activity ) switch( m_Activity )
{ {
case ACT_TURN_LEFT: case ACT_TURN_LEFT:
case ACT_TURN_RIGHT: case ACT_TURN_RIGHT:
ys = 110; ys = 110;
break; break;
default: ys = 100; default:
ys = 100;
break;
} }
pev->yaw_speed = ys; pev->yaw_speed = ys;
@ -414,7 +412,7 @@ void CAGrunt :: SetYawSpeed ( void )
// //
// Returns number of events handled, 0 if none. // Returns number of events handled, 0 if none.
//========================================================= //=========================================================
void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
switch( pEvent->event ) switch( pEvent->event )
{ {
@ -429,7 +427,7 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent )
Vector vecDirToEnemy; Vector vecDirToEnemy;
Vector angDir; Vector angDir;
if (HasConditions( bits_COND_SEE_ENEMY)) if( HasConditions( bits_COND_SEE_ENEMY ) )
{ {
vecDirToEnemy = ( ( m_vecEnemyLKP ) - pev->origin ); vecDirToEnemy = ( ( m_vecEnemyLKP ) - pev->origin );
angDir = UTIL_VecToAngles( vecDirToEnemy ); angDir = UTIL_VecToAngles( vecDirToEnemy );
@ -445,7 +443,7 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent )
pev->effects = EF_MUZZLEFLASH; pev->effects = EF_MUZZLEFLASH;
// make angles +-180 // make angles +-180
if (angDir.x > 180) if( angDir.x > 180 )
{ {
angDir.x = angDir.x - 360; angDir.x = angDir.x - 360;
} }
@ -468,38 +466,49 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent )
UTIL_MakeVectors ( pHornet->pev->angles ); UTIL_MakeVectors ( pHornet->pev->angles );
pHornet->pev->velocity = gpGlobals->v_forward * 300; pHornet->pev->velocity = gpGlobals->v_forward * 300;
switch( RANDOM_LONG ( 0 , 2 ) )
switch ( RANDOM_LONG ( 0 , 2 ) )
{ {
case 0: EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, "agrunt/ag_fire1.wav", 1.0, ATTN_NORM, 0, 100 ); break; case 0:
case 1: EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, "agrunt/ag_fire2.wav", 1.0, ATTN_NORM, 0, 100 ); break; EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire1.wav", 1.0, ATTN_NORM, 0, 100 );
case 2: EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, "agrunt/ag_fire3.wav", 1.0, ATTN_NORM, 0, 100 ); break; break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire2.wav", 1.0, ATTN_NORM, 0, 100 );
break;
case 2:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire3.wav", 1.0, ATTN_NORM, 0, 100 );
break;
} }
CBaseMonster *pHornetMonster = pHornet->MyMonsterPointer(); CBaseMonster *pHornetMonster = pHornet->MyMonsterPointer();
if ( pHornetMonster ) if( pHornetMonster )
{ {
pHornetMonster->m_hEnemy = m_hEnemy; pHornetMonster->m_hEnemy = m_hEnemy;
} }
} }
break; break;
case AGRUNT_AE_LEFT_FOOT: case AGRUNT_AE_LEFT_FOOT:
switch (RANDOM_LONG(0,1)) switch( RANDOM_LONG( 0, 1 ) )
{ {
// left foot // left foot
case 0: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder2.wav", 1, ATTN_NORM, 0, 70 ); break; case 0:
case 1: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder4.wav", 1, ATTN_NORM, 0, 70 ); break; EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder2.wav", 1, ATTN_NORM, 0, 70 );
break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder4.wav", 1, ATTN_NORM, 0, 70 );
break;
} }
break; break;
case AGRUNT_AE_RIGHT_FOOT: case AGRUNT_AE_RIGHT_FOOT:
// right foot // right foot
switch (RANDOM_LONG(0,1)) switch( RANDOM_LONG( 0, 1 ) )
{ {
case 0: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder1.wav", 1, ATTN_NORM, 0, 70 ); break; case 0:
case 1: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder3.wav", 1, ATTN_NORM, 0 ,70); break; EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder1.wav", 1, ATTN_NORM, 0, 70 );
break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder3.wav", 1, ATTN_NORM, 0 ,70);
break;
} }
break; break;
@ -507,62 +516,60 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, gSkillData.agruntDmgPunch, DMG_CLUB ); CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, gSkillData.agruntDmgPunch, DMG_CLUB );
if ( pHurt ) if( pHurt )
{ {
pHurt->pev->punchangle.y = -25; pHurt->pev->punchangle.y = -25;
pHurt->pev->punchangle.x = 8; pHurt->pev->punchangle.x = 8;
// OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above. // OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above.
if ( pHurt->IsPlayer() ) if( pHurt->IsPlayer() )
{ {
// this is a player. Knock him around. // this is a player. Knock him around.
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250;
} }
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) );
Vector vecArmPos, vecArmAng; Vector vecArmPos, vecArmAng;
GetAttachment( 0, vecArmPos, vecArmAng ); GetAttachment( 0, vecArmPos, vecArmAng );
SpawnBlood(vecArmPos, pHurt->BloodColor(), 25);// a little surface blood. SpawnBlood( vecArmPos, pHurt->BloodColor(), 25 );// a little surface blood.
} }
else else
{ {
// Play a random attack miss sound // Play a random attack miss sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) );
} }
} }
break; break;
case AGRUNT_AE_RIGHT_PUNCH: case AGRUNT_AE_RIGHT_PUNCH:
{ {
CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, gSkillData.agruntDmgPunch, DMG_CLUB ); CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, gSkillData.agruntDmgPunch, DMG_CLUB );
if ( pHurt ) if( pHurt )
{ {
pHurt->pev->punchangle.y = 25; pHurt->pev->punchangle.y = 25;
pHurt->pev->punchangle.x = 8; pHurt->pev->punchangle.x = 8;
// OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above. // OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above.
if ( pHurt->IsPlayer() ) if( pHurt->IsPlayer() )
{ {
// this is a player. Knock him around. // this is a player. Knock him around.
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250;
} }
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) );
Vector vecArmPos, vecArmAng; Vector vecArmPos, vecArmAng;
GetAttachment( 0, vecArmPos, vecArmAng ); GetAttachment( 0, vecArmPos, vecArmAng );
SpawnBlood(vecArmPos, pHurt->BloodColor(), 25);// a little surface blood. SpawnBlood( vecArmPos, pHurt->BloodColor(), 25 );// a little surface blood.
} }
else else
{ {
// Play a random attack miss sound // Play a random attack miss sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) );
} }
} }
break; break;
default: default:
CSquadMonster::HandleAnimEvent( pEvent ); CSquadMonster::HandleAnimEvent( pEvent );
break; break;
@ -572,12 +579,12 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent )
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CAGrunt :: Spawn() void CAGrunt::Spawn()
{ {
Precache( ); Precache();
SET_MODEL(ENT(pev), "models/agrunt.mdl"); SET_MODEL( ENT( pev ), "models/agrunt.mdl" );
UTIL_SetSize(pev, Vector(-32, -32, 0), Vector(32, 32, 64)); UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
@ -591,8 +598,7 @@ void CAGrunt :: Spawn()
m_HackedGunPos = Vector( 24, 64, 48 ); m_HackedGunPos = Vector( 24, 64, 48 );
m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10 + RANDOM_LONG(0, 10); m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10 + RANDOM_LONG( 0, 10 );
MonsterInit(); MonsterInit();
} }
@ -600,33 +606,32 @@ void CAGrunt :: Spawn()
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CAGrunt :: Precache() void CAGrunt::Precache()
{ {
int i; int i;
PRECACHE_MODEL("models/agrunt.mdl"); PRECACHE_MODEL( "models/agrunt.mdl" );
for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ )
PRECACHE_SOUND((char *)pAttackHitSounds[i]); PRECACHE_SOUND( (char *)pAttackHitSounds[i] );
for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ )
PRECACHE_SOUND((char *)pAttackMissSounds[i]); PRECACHE_SOUND( (char *)pAttackMissSounds[i] );
for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ )
PRECACHE_SOUND((char *)pIdleSounds[i]); PRECACHE_SOUND( (char *)pIdleSounds[i] );
for ( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ )
PRECACHE_SOUND((char *)pDieSounds[i]); PRECACHE_SOUND( (char *)pDieSounds[i] );
for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ )
PRECACHE_SOUND((char *)pPainSounds[i]); PRECACHE_SOUND( (char *)pPainSounds[i] );
for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ )
PRECACHE_SOUND((char *)pAttackSounds[i]); PRECACHE_SOUND( (char *)pAttackSounds[i] );
for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ )
PRECACHE_SOUND((char *)pAlertSounds[i]);
for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ )
PRECACHE_SOUND( (char *)pAlertSounds[i] );
PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" );
@ -654,7 +659,7 @@ Schedule_t slAGruntFail[] =
{ {
{ {
tlAGruntFail, tlAGruntFail,
ARRAYSIZE ( tlAGruntFail ), ARRAYSIZE( tlAGruntFail ),
bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1, bits_COND_CAN_MELEE_ATTACK1,
0, 0,
@ -677,7 +682,7 @@ Schedule_t slAGruntCombatFail[] =
{ {
{ {
tlAGruntCombatFail, tlAGruntCombatFail,
ARRAYSIZE ( tlAGruntCombatFail ), ARRAYSIZE( tlAGruntCombatFail ),
bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1, bits_COND_CAN_MELEE_ATTACK1,
0, 0,
@ -701,13 +706,12 @@ Schedule_t slAGruntStandoff[] =
{ {
{ {
tlAGruntStandoff, tlAGruntStandoff,
ARRAYSIZE ( tlAGruntStandoff ), ARRAYSIZE( tlAGruntStandoff ),
bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_SEE_ENEMY | bits_COND_SEE_ENEMY |
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Agrunt Standoff" "Agrunt Standoff"
} }
@ -726,7 +730,7 @@ Schedule_t slAGruntSuppress[] =
{ {
{ {
tlAGruntSuppressHornet, tlAGruntSuppressHornet,
ARRAYSIZE ( tlAGruntSuppressHornet ), ARRAYSIZE( tlAGruntSuppressHornet ),
0, 0,
0, 0,
"AGrunt Suppress Hornet", "AGrunt Suppress Hornet",
@ -747,17 +751,15 @@ Schedule_t slAGruntRangeAttack1[] =
{ {
{ {
tlAGruntRangeAttack1, tlAGruntRangeAttack1,
ARRAYSIZE ( tlAGruntRangeAttack1 ), ARRAYSIZE( tlAGruntRangeAttack1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_HEAVY_DAMAGE, bits_COND_HEAVY_DAMAGE,
0, 0,
"AGrunt Range Attack1" "AGrunt Range Attack1"
}, },
}; };
Task_t tlAGruntHiddenRangeAttack1[] = Task_t tlAGruntHiddenRangeAttack1[] =
{ {
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_STANDOFF }, { TASK_SET_FAIL_SCHEDULE, (float)SCHED_STANDOFF },
@ -775,7 +777,6 @@ Schedule_t slAGruntHiddenRangeAttack[] =
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"AGrunt Hidden Range Attack1" "AGrunt Hidden Range Attack1"
}, },
@ -800,7 +801,7 @@ Schedule_t slAGruntTakeCoverFromEnemy[] =
{ {
{ {
tlAGruntTakeCoverFromEnemy, tlAGruntTakeCoverFromEnemy,
ARRAYSIZE ( tlAGruntTakeCoverFromEnemy ), ARRAYSIZE( tlAGruntTakeCoverFromEnemy ),
bits_COND_NEW_ENEMY, bits_COND_NEW_ENEMY,
0, 0,
"AGruntTakeCoverFromEnemy" "AGruntTakeCoverFromEnemy"
@ -837,7 +838,7 @@ Schedule_t slAGruntVictoryDance[] =
{ {
{ {
tlAGruntVictoryDance, tlAGruntVictoryDance,
ARRAYSIZE ( tlAGruntVictoryDance ), ARRAYSIZE( tlAGruntVictoryDance ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE, bits_COND_HEAVY_DAMAGE,
@ -859,11 +860,10 @@ Schedule_t slAGruntThreatDisplay[] =
{ {
{ {
tlAGruntThreatDisplay, tlAGruntThreatDisplay,
ARRAYSIZE ( tlAGruntThreatDisplay ), ARRAYSIZE( tlAGruntThreatDisplay ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE, bits_COND_HEAVY_DAMAGE,
bits_SOUND_PLAYER | bits_SOUND_PLAYER |
bits_SOUND_COMBAT | bits_SOUND_COMBAT |
bits_SOUND_WORLD, bits_SOUND_WORLD,
@ -884,16 +884,16 @@ DEFINE_CUSTOM_SCHEDULES( CAGrunt )
slAGruntThreatDisplay, slAGruntThreatDisplay,
}; };
IMPLEMENT_CUSTOM_SCHEDULES( CAGrunt, CSquadMonster ); IMPLEMENT_CUSTOM_SCHEDULES( CAGrunt, CSquadMonster )
//========================================================= //=========================================================
// FCanCheckAttacks - this is overridden for alien grunts // FCanCheckAttacks - this is overridden for alien grunts
// because they can use their smart weapons against unseen // because they can use their smart weapons against unseen
// enemies. Base class doesn't attack anyone it can't see. // enemies. Base class doesn't attack anyone it can't see.
//========================================================= //=========================================================
BOOL CAGrunt :: FCanCheckAttacks ( void ) BOOL CAGrunt::FCanCheckAttacks( void )
{ {
if ( !HasConditions( bits_COND_ENEMY_TOOFAR ) ) if( !HasConditions( bits_COND_ENEMY_TOOFAR ) )
{ {
return TRUE; return TRUE;
} }
@ -907,9 +907,9 @@ BOOL CAGrunt :: FCanCheckAttacks ( void )
// CheckMeleeAttack1 - alien grunts zap the crap out of // CheckMeleeAttack1 - alien grunts zap the crap out of
// any enemy that gets too close. // any enemy that gets too close.
//========================================================= //=========================================================
BOOL CAGrunt :: CheckMeleeAttack1 ( float flDot, float flDist ) BOOL CAGrunt::CheckMeleeAttack1( float flDot, float flDist )
{ {
if ( HasConditions ( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != NULL ) if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != NULL )
{ {
return TRUE; return TRUE;
} }
@ -923,14 +923,14 @@ BOOL CAGrunt :: CheckMeleeAttack1 ( float flDot, float flDist )
// tracelines are done, so we may not want to do this every // tracelines are done, so we may not want to do this every
// server frame. Definitely not while firing. // server frame. Definitely not while firing.
//========================================================= //=========================================================
BOOL CAGrunt :: CheckRangeAttack1 ( float flDot, float flDist ) BOOL CAGrunt::CheckRangeAttack1( float flDot, float flDist )
{ {
if ( gpGlobals->time < m_flNextHornetAttackCheck ) if( gpGlobals->time < m_flNextHornetAttackCheck )
{ {
return m_fCanHornetAttack; return m_fCanHornetAttack;
} }
if ( HasConditions( bits_COND_SEE_ENEMY ) && flDist >= AGRUNT_MELEE_DIST && flDist <= 1024 && flDot >= 0.5 && NoFriendlyFire() ) if( HasConditions( bits_COND_SEE_ENEMY ) && flDist >= AGRUNT_MELEE_DIST && flDist <= 1024 && flDot >= 0.5 && NoFriendlyFire() )
{ {
TraceResult tr; TraceResult tr;
Vector vecArmPos, vecArmDir; Vector vecArmPos, vecArmDir;
@ -939,10 +939,10 @@ BOOL CAGrunt :: CheckRangeAttack1 ( float flDot, float flDist )
// !!!LATER - we may wish to do something different for projectile weapons as opposed to instant-hit // !!!LATER - we may wish to do something different for projectile weapons as opposed to instant-hit
UTIL_MakeVectors( pev->angles ); UTIL_MakeVectors( pev->angles );
GetAttachment( 0, vecArmPos, vecArmDir ); GetAttachment( 0, vecArmPos, vecArmDir );
// UTIL_TraceLine( vecArmPos, vecArmPos + gpGlobals->v_forward * 256, ignore_monsters, ENT(pev), &tr); //UTIL_TraceLine( vecArmPos, vecArmPos + gpGlobals->v_forward * 256, ignore_monsters, ENT( pev ), &tr );
UTIL_TraceLine( vecArmPos, m_hEnemy->BodyTarget(vecArmPos), dont_ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( vecArmPos, m_hEnemy->BodyTarget( vecArmPos ), dont_ignore_monsters, ENT( pev ), &tr );
if ( tr.flFraction == 1.0 || tr.pHit == m_hEnemy->edict() ) if( tr.flFraction == 1.0 || tr.pHit == m_hEnemy->edict() )
{ {
m_flNextHornetAttackCheck = gpGlobals->time + RANDOM_FLOAT( 2, 5 ); m_flNextHornetAttackCheck = gpGlobals->time + RANDOM_FLOAT( 2, 5 );
m_fCanHornetAttack = TRUE; m_fCanHornetAttack = TRUE;
@ -958,35 +958,33 @@ BOOL CAGrunt :: CheckRangeAttack1 ( float flDot, float flDist )
//========================================================= //=========================================================
// StartTask // StartTask
//========================================================= //=========================================================
void CAGrunt :: StartTask ( Task_t *pTask ) void CAGrunt::StartTask( Task_t *pTask )
{ {
switch ( pTask->iTask ) switch( pTask->iTask )
{ {
case TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE: case TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE:
{ {
UTIL_MakeVectors( pev->angles ); UTIL_MakeVectors( pev->angles );
if ( BuildRoute ( m_vecEnemyLKP - gpGlobals->v_forward * 50, bits_MF_TO_LOCATION, NULL ) ) if( BuildRoute( m_vecEnemyLKP - gpGlobals->v_forward * 50, bits_MF_TO_LOCATION, NULL ) )
{ {
TaskComplete(); TaskComplete();
} }
else else
{ {
ALERT ( at_aiconsole, "AGruntGetPathToEnemyCorpse failed!!\n" ); ALERT( at_aiconsole, "AGruntGetPathToEnemyCorpse failed!!\n" );
TaskFail(); TaskFail();
} }
} }
break; break;
case TASK_AGRUNT_SETUP_HIDE_ATTACK: case TASK_AGRUNT_SETUP_HIDE_ATTACK:
// alien grunt shoots hornets back out into the open from a concealed location. // alien grunt shoots hornets back out into the open from a concealed location.
// try to find a spot to throw that gives the smart weapon a good chance of finding the enemy. // try to find a spot to throw that gives the smart weapon a good chance of finding the enemy.
// ideally, this spot is along a line that is perpendicular to a line drawn from the agrunt to the enemy. // ideally, this spot is along a line that is perpendicular to a line drawn from the agrunt to the enemy.
CBaseMonster *pEnemyMonsterPtr; CBaseMonster *pEnemyMonsterPtr;
pEnemyMonsterPtr = m_hEnemy->MyMonsterPointer(); pEnemyMonsterPtr = m_hEnemy->MyMonsterPointer();
if ( pEnemyMonsterPtr ) if( pEnemyMonsterPtr )
{ {
Vector vecCenter; Vector vecCenter;
TraceResult tr; TraceResult tr;
@ -997,61 +995,60 @@ void CAGrunt :: StartTask ( Task_t *pTask )
UTIL_VecToAngles( m_vecEnemyLKP - pev->origin ); UTIL_VecToAngles( m_vecEnemyLKP - pev->origin );
UTIL_TraceLine( Center() + gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( Center() + gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr );
if ( tr.flFraction == 1.0 ) if( tr.flFraction == 1.0 )
{ {
MakeIdealYaw ( pev->origin + gpGlobals->v_right * 128 ); MakeIdealYaw( pev->origin + gpGlobals->v_right * 128 );
fSkip = TRUE; fSkip = TRUE;
TaskComplete(); TaskComplete();
} }
if ( !fSkip ) if( !fSkip )
{ {
UTIL_TraceLine( Center() - gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( Center() - gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr );
if ( tr.flFraction == 1.0 ) if( tr.flFraction == 1.0 )
{ {
MakeIdealYaw ( pev->origin - gpGlobals->v_right * 128 ); MakeIdealYaw( pev->origin - gpGlobals->v_right * 128 );
fSkip = TRUE; fSkip = TRUE;
TaskComplete(); TaskComplete();
} }
} }
if ( !fSkip ) if( !fSkip )
{ {
UTIL_TraceLine( Center() + gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( Center() + gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr );
if ( tr.flFraction == 1.0 ) if( tr.flFraction == 1.0 )
{ {
MakeIdealYaw ( pev->origin + gpGlobals->v_right * 256 ); MakeIdealYaw( pev->origin + gpGlobals->v_right * 256 );
fSkip = TRUE; fSkip = TRUE;
TaskComplete(); TaskComplete();
} }
} }
if ( !fSkip ) if( !fSkip )
{ {
UTIL_TraceLine( Center() - gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine( Center() - gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr );
if ( tr.flFraction == 1.0 ) if( tr.flFraction == 1.0 )
{ {
MakeIdealYaw ( pev->origin - gpGlobals->v_right * 256 ); MakeIdealYaw( pev->origin - gpGlobals->v_right * 256 );
fSkip = TRUE; fSkip = TRUE;
TaskComplete(); TaskComplete();
} }
} }
if ( !fSkip ) if( !fSkip )
{ {
TaskFail(); TaskFail();
} }
} }
else else
{ {
ALERT ( at_aiconsole, "AGRunt - no enemy monster ptr!!!\n" ); ALERT( at_aiconsole, "AGRunt - no enemy monster ptr!!!\n" );
TaskFail(); TaskFail();
} }
break; break;
default: default:
CSquadMonster :: StartTask ( pTask ); CSquadMonster::StartTask( pTask );
break; break;
} }
} }
@ -1062,125 +1059,120 @@ void CAGrunt :: StartTask ( Task_t *pTask )
// monster's member function to get a pointer to a schedule // monster's member function to get a pointer to a schedule
// of the proper type. // of the proper type.
//========================================================= //=========================================================
Schedule_t *CAGrunt :: GetSchedule ( void ) Schedule_t *CAGrunt::GetSchedule( void )
{ {
if ( HasConditions(bits_COND_HEAR_SOUND) ) if( HasConditions( bits_COND_HEAR_SOUND ) )
{ {
CSound *pSound; CSound *pSound;
pSound = PBestSound(); pSound = PBestSound();
ASSERT( pSound != NULL ); ASSERT( pSound != NULL );
if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) )
{ {
// dangerous sound nearby! // dangerous sound nearby!
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND );
} }
} }
switch ( m_MonsterState ) switch( m_MonsterState )
{ {
case MONSTERSTATE_COMBAT: case MONSTERSTATE_COMBAT:
{ {
// dead enemy // dead enemy
if ( HasConditions( bits_COND_ENEMY_DEAD ) ) if( HasConditions( bits_COND_ENEMY_DEAD ) )
{ {
// call base class, all code to handle dead enemies is centralized there. // call base class, all code to handle dead enemies is centralized there.
return CBaseMonster :: GetSchedule(); return CBaseMonster::GetSchedule();
} }
if ( HasConditions(bits_COND_NEW_ENEMY) ) if( HasConditions( bits_COND_NEW_ENEMY ) )
{ {
return GetScheduleOfType( SCHED_WAKE_ANGRY ); return GetScheduleOfType( SCHED_WAKE_ANGRY );
} }
// zap player! // zap player!
if ( HasConditions ( bits_COND_CAN_MELEE_ATTACK1 ) ) if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) )
{ {
AttackSound();// this is a total hack. Should be parto f the schedule AttackSound();// this is a total hack. Should be parto f the schedule
return GetScheduleOfType ( SCHED_MELEE_ATTACK1 ); return GetScheduleOfType( SCHED_MELEE_ATTACK1 );
} }
if ( HasConditions ( bits_COND_HEAVY_DAMAGE ) ) if( HasConditions( bits_COND_HEAVY_DAMAGE ) )
{ {
return GetScheduleOfType( SCHED_SMALL_FLINCH ); return GetScheduleOfType( SCHED_SMALL_FLINCH );
} }
// can attack // can attack
if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) && OccupySlot ( bits_SLOTS_AGRUNT_HORNET ) ) if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) && OccupySlot ( bits_SLOTS_AGRUNT_HORNET ) )
{ {
return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ); return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
} }
if ( OccupySlot ( bits_SLOT_AGRUNT_CHASE ) ) if( OccupySlot ( bits_SLOT_AGRUNT_CHASE ) )
{ {
return GetScheduleOfType ( SCHED_CHASE_ENEMY ); return GetScheduleOfType( SCHED_CHASE_ENEMY );
} }
return GetScheduleOfType ( SCHED_STANDOFF ); return GetScheduleOfType( SCHED_STANDOFF );
} }
break;
default:
break;
} }
return CSquadMonster :: GetSchedule(); return CSquadMonster::GetSchedule();
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
Schedule_t* CAGrunt :: GetScheduleOfType ( int Type ) Schedule_t *CAGrunt::GetScheduleOfType( int Type )
{ {
switch ( Type ) switch( Type )
{ {
case SCHED_TAKE_COVER_FROM_ENEMY: case SCHED_TAKE_COVER_FROM_ENEMY:
return &slAGruntTakeCoverFromEnemy[ 0 ]; return &slAGruntTakeCoverFromEnemy[0];
break; break;
case SCHED_RANGE_ATTACK1: case SCHED_RANGE_ATTACK1:
if ( HasConditions( bits_COND_SEE_ENEMY ) ) if( HasConditions( bits_COND_SEE_ENEMY ) )
{ {
//normal attack //normal attack
return &slAGruntRangeAttack1[ 0 ]; return &slAGruntRangeAttack1[0];
} }
else else
{ {
// attack an unseen enemy // attack an unseen enemy
// return &slAGruntHiddenRangeAttack[ 0 ]; // return &slAGruntHiddenRangeAttack[0];
return &slAGruntRangeAttack1[ 0 ]; return &slAGruntRangeAttack1[0];
} }
break; break;
case SCHED_AGRUNT_THREAT_DISPLAY: case SCHED_AGRUNT_THREAT_DISPLAY:
return &slAGruntThreatDisplay[ 0 ]; return &slAGruntThreatDisplay[0];
break; break;
case SCHED_AGRUNT_SUPPRESS: case SCHED_AGRUNT_SUPPRESS:
return &slAGruntSuppress[ 0 ]; return &slAGruntSuppress[0];
break; break;
case SCHED_STANDOFF: case SCHED_STANDOFF:
return &slAGruntStandoff[ 0 ]; return &slAGruntStandoff[0];
break; break;
case SCHED_VICTORY_DANCE: case SCHED_VICTORY_DANCE:
return &slAGruntVictoryDance[ 0 ]; return &slAGruntVictoryDance[0];
break; break;
case SCHED_FAIL: case SCHED_FAIL:
// no fail schedule specified, so pick a good generic one. // no fail schedule specified, so pick a good generic one.
{ {
if ( m_hEnemy != NULL ) if( m_hEnemy != NULL )
{ {
// I have an enemy // I have an enemy
// !!!LATER - what if this enemy is really far away and i'm chasing him? // !!!LATER - what if this enemy is really far away and i'm chasing him?
// this schedule will make me stop, face his last known position for 2 // this schedule will make me stop, face his last known position for 2
// seconds, and then try to move again // seconds, and then try to move again
return &slAGruntCombatFail[ 0 ]; return &slAGruntCombatFail[0];
} }
return &slAGruntFail[ 0 ]; return &slAGruntFail[0];
} }
break; break;
} }
return CSquadMonster :: GetScheduleOfType( Type ); return CSquadMonster::GetScheduleOfType( Type );
} }

View File

@ -37,25 +37,24 @@ class CAirtank : public CGrenade
int m_state; int m_state;
}; };
LINK_ENTITY_TO_CLASS( item_airtank, CAirtank )
LINK_ENTITY_TO_CLASS( item_airtank, CAirtank );
TYPEDESCRIPTION CAirtank::m_SaveData[] = TYPEDESCRIPTION CAirtank::m_SaveData[] =
{ {
DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ), DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ),
}; };
IMPLEMENT_SAVERESTORE( CAirtank, CGrenade ); IMPLEMENT_SAVERESTORE( CAirtank, CGrenade )
void CAirtank::Spawn( void )
void CAirtank :: Spawn( void )
{ {
Precache( ); Precache();
// motor // motor
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/w_oxygen.mdl"); SET_MODEL( ENT( pev ), "models/w_oxygen.mdl" );
UTIL_SetSize(pev, Vector( -16, -16, 0), Vector(16, 16, 36)); UTIL_SetSize( pev, Vector( -16, -16, 0), Vector( 16, 16, 36 ) );
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
SetTouch( &CAirtank::TankTouch ); SetTouch( &CAirtank::TankTouch );
@ -70,12 +69,11 @@ void CAirtank :: Spawn( void )
void CAirtank::Precache( void ) void CAirtank::Precache( void )
{ {
PRECACHE_MODEL("models/w_oxygen.mdl"); PRECACHE_MODEL( "models/w_oxygen.mdl" );
PRECACHE_SOUND("doors/aliendoor3.wav"); PRECACHE_SOUND( "doors/aliendoor3.wav" );
} }
void CAirtank::Killed( entvars_t *pevAttacker, int iGib )
void CAirtank :: Killed( entvars_t *pevAttacker, int iGib )
{ {
pev->owner = ENT( pevAttacker ); pev->owner = ENT( pevAttacker );
@ -84,7 +82,6 @@ void CAirtank :: Killed( entvars_t *pevAttacker, int iGib )
Explode( pev->origin, Vector( 0, 0, -1 ) ); Explode( pev->origin, Vector( 0, 0, -1 ) );
} }
void CAirtank::TankThink( void ) void CAirtank::TankThink( void )
{ {
// Fire trigger // Fire trigger
@ -92,16 +89,15 @@ void CAirtank::TankThink( void )
SUB_UseTargets( this, USE_TOGGLE, 0 ); SUB_UseTargets( this, USE_TOGGLE, 0 );
} }
void CAirtank::TankTouch( CBaseEntity *pOther ) void CAirtank::TankTouch( CBaseEntity *pOther )
{ {
if ( !pOther->IsPlayer() ) if( !pOther->IsPlayer() )
return; return;
if (!m_state) if( !m_state )
{ {
// "no oxygen" sound // "no oxygen" sound
EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM );
return; return;
} }
@ -109,7 +105,7 @@ void CAirtank::TankTouch( CBaseEntity *pOther )
pOther->pev->air_finished = gpGlobals->time + 12; pOther->pev->air_finished = gpGlobals->time + 12;
// suit recharge sound // suit recharge sound
EMIT_SOUND( ENT(pev), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM );
// recharge airtank in 30 seconds // recharge airtank in 30 seconds
pev->nextthink = gpGlobals->time + 30; pev->nextthink = gpGlobals->time + 30;

View File

@ -35,36 +35,35 @@ TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ), DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ),
}; };
IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ); IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay )
//========================================================= //=========================================================
// StudioFrameAdvance - advance the animation frame up to the current time // StudioFrameAdvance - advance the animation frame up to the current time
// if an flInterval is passed in, only advance animation that number of seconds // if an flInterval is passed in, only advance animation that number of seconds
//========================================================= //=========================================================
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) float CBaseAnimating::StudioFrameAdvance( float flInterval )
{ {
if (flInterval == 0.0) if( flInterval == 0.0 )
{ {
flInterval = (gpGlobals->time - pev->animtime); flInterval = gpGlobals->time - pev->animtime;
if (flInterval <= 0.001) if( flInterval <= 0.001 )
{ {
pev->animtime = gpGlobals->time; pev->animtime = gpGlobals->time;
return 0.0; return 0.0;
} }
} }
if (! pev->animtime) if( !pev->animtime )
flInterval = 0.0; flInterval = 0.0;
pev->frame += flInterval * m_flFrameRate * pev->framerate; pev->frame += flInterval * m_flFrameRate * pev->framerate;
pev->animtime = gpGlobals->time; pev->animtime = gpGlobals->time;
if (pev->frame < 0.0 || pev->frame >= 256.0) if( pev->frame < 0.0 || pev->frame >= 256.0 )
{ {
if (m_fSequenceLoops) if( m_fSequenceLoops )
pev->frame -= (int)(pev->frame / 256.0) * 256.0; pev->frame -= (int)( pev->frame / 256.0 ) * 256.0;
else else
pev->frame = (pev->frame < 0.0) ? 0 : 255; pev->frame = ( pev->frame < 0.0 ) ? 0 : 255;
m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
} }
@ -74,10 +73,10 @@ float CBaseAnimating :: StudioFrameAdvance ( float flInterval )
//========================================================= //=========================================================
// LookupActivity // LookupActivity
//========================================================= //=========================================================
int CBaseAnimating :: LookupActivity ( int activity ) int CBaseAnimating::LookupActivity( int activity )
{ {
ASSERT( activity != 0 ); ASSERT( activity != 0 );
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
return ::LookupActivity( pmodel, pev, activity ); return ::LookupActivity( pmodel, pev, activity );
} }
@ -88,44 +87,41 @@ int CBaseAnimating :: LookupActivity ( int activity )
// Get activity with highest 'weight' // Get activity with highest 'weight'
// //
//========================================================= //=========================================================
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) int CBaseAnimating::LookupActivityHeaviest( int activity )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
return ::LookupActivityHeaviest( pmodel, pev, activity ); return ::LookupActivityHeaviest( pmodel, pev, activity );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
int CBaseAnimating :: LookupSequence ( const char *label ) int CBaseAnimating::LookupSequence( const char *label )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
return ::LookupSequence( pmodel, label ); return ::LookupSequence( pmodel, label );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBaseAnimating :: ResetSequenceInfo ( ) void CBaseAnimating::ResetSequenceInfo()
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed ); GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed );
m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0); m_fSequenceLoops = ( ( GetSequenceFlags() & STUDIO_LOOPING ) != 0 );
pev->animtime = gpGlobals->time; pev->animtime = gpGlobals->time;
pev->framerate = 1.0; pev->framerate = 1.0;
m_fSequenceFinished = FALSE; m_fSequenceFinished = FALSE;
m_flLastEventCheck = gpGlobals->time; m_flLastEventCheck = gpGlobals->time;
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
BOOL CBaseAnimating :: GetSequenceFlags( ) BOOL CBaseAnimating::GetSequenceFlags()
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
return ::GetSequenceFlags( pmodel, pev ); return ::GetSequenceFlags( pmodel, pev );
} }
@ -133,13 +129,13 @@ BOOL CBaseAnimating :: GetSequenceFlags( )
//========================================================= //=========================================================
// DispatchAnimEvents // DispatchAnimEvents
//========================================================= //=========================================================
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) void CBaseAnimating::DispatchAnimEvents( float flInterval )
{ {
MonsterEvent_t event; MonsterEvent_t event;
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
if ( !pmodel ) if( !pmodel )
{ {
ALERT( at_aiconsole, "Gibbed monster is thinking!\n" ); ALERT( at_aiconsole, "Gibbed monster is thinking!\n" );
return; return;
@ -149,37 +145,36 @@ void CBaseAnimating :: DispatchAnimEvents ( float flInterval )
flInterval = 0.1; flInterval = 0.1;
// FIX: this still sometimes hits events twice // FIX: this still sometimes hits events twice
float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate; float flStart = pev->frame + ( m_flLastEventCheck - pev->animtime ) * m_flFrameRate * pev->framerate;
float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate; float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate;
m_flLastEventCheck = pev->animtime + flInterval; m_flLastEventCheck = pev->animtime + flInterval;
m_fSequenceFinished = FALSE; m_fSequenceFinished = FALSE;
if (flEnd >= 256 || flEnd <= 0.0) if( flEnd >= 256 || flEnd <= 0.0 )
m_fSequenceFinished = TRUE; m_fSequenceFinished = TRUE;
int index = 0; int index = 0;
while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 ) while( ( index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 )
{ {
HandleAnimEvent( &event ); HandleAnimEvent( &event );
} }
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
float CBaseAnimating :: SetBoneController ( int iController, float flValue ) float CBaseAnimating::SetBoneController( int iController, float flValue )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
return SetController( pmodel, pev, iController, flValue ); return SetController( pmodel, pev, iController, flValue );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBaseAnimating :: InitBoneControllers ( void ) void CBaseAnimating::InitBoneControllers( void )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
SetController( pmodel, pev, 0, 0.0 ); SetController( pmodel, pev, 0, 0.0 );
SetController( pmodel, pev, 1, 0.0 ); SetController( pmodel, pev, 1, 0.0 );
@ -189,38 +184,38 @@ void CBaseAnimating :: InitBoneControllers ( void )
//========================================================= //=========================================================
//========================================================= //=========================================================
float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) float CBaseAnimating::SetBlending( int iBlender, float flValue )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
return ::SetBlending( pmodel, pev, iBlender, flValue ); return ::SetBlending( pmodel, pev, iBlender, flValue );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) void CBaseAnimating::GetBonePosition( int iBone, Vector &origin, Vector &angles )
{ {
GET_BONE_POSITION( ENT(pev), iBone, origin, angles ); GET_BONE_POSITION( ENT( pev ), iBone, origin, angles );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) void CBaseAnimating::GetAttachment( int iAttachment, Vector &origin, Vector &angles )
{ {
GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles ); GET_ATTACHMENT( ENT( pev ), iAttachment, origin, angles );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) int CBaseAnimating::FindTransition( int iEndingSequence, int iGoalSequence, int *piDir )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT( pev ) );
if (piDir == NULL) if( piDir == NULL )
{ {
int iDir; int iDir;
int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir ); int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir );
if (iDir != 1) if( iDir != 1 )
return -1; return -1;
else else
return sequence; return sequence;
@ -231,46 +226,45 @@ int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, in
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) void CBaseAnimating::GetAutomovement( Vector &origin, Vector &angles, float flInterval )
{ {
} }
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) void CBaseAnimating::SetBodygroup( int iGroup, int iValue )
{ {
::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue ); ::SetBodygroup( GET_MODEL_PTR( ENT( pev ) ), pev, iGroup, iValue );
} }
int CBaseAnimating :: GetBodygroup( int iGroup ) int CBaseAnimating::GetBodygroup( int iGroup )
{ {
return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup ); return ::GetBodygroup( GET_MODEL_PTR( ENT( pev ) ), pev, iGroup );
} }
int CBaseAnimating::ExtractBbox( int sequence, float *mins, float *maxs )
int CBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs )
{ {
return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs ); return ::ExtractBbox( GET_MODEL_PTR( ENT( pev ) ), sequence, mins, maxs );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBaseAnimating :: SetSequenceBox( void ) void CBaseAnimating::SetSequenceBox( void )
{ {
Vector mins, maxs; Vector mins, maxs;
// Get sequence bbox // Get sequence bbox
if ( ExtractBbox( pev->sequence, mins, maxs ) ) if( ExtractBbox( pev->sequence, mins, maxs ) )
{ {
// expand box for rotation // expand box for rotation
// find min / max for rotations // find min / max for rotations
float yaw = pev->angles.y * (M_PI / 180.0); float yaw = pev->angles.y * ( M_PI / 180.0 );
Vector xvector, yvector; Vector xvector, yvector;
xvector.x = cos(yaw); xvector.x = cos( yaw );
xvector.y = sin(yaw); xvector.y = sin( yaw );
yvector.x = -sin(yaw); yvector.x = -sin( yaw );
yvector.y = cos(yaw); yvector.y = cos( yaw );
Vector bounds[2]; Vector bounds[2];
bounds[0] = mins; bounds[0] = mins;
@ -280,32 +274,32 @@ void CBaseAnimating :: SetSequenceBox( void )
Vector rmax( -9999, -9999, -9999 ); Vector rmax( -9999, -9999, -9999 );
Vector base, transformed; Vector base, transformed;
for (int i = 0; i <= 1; i++ ) for( int i = 0; i <= 1; i++ )
{ {
base.x = bounds[i].x; base.x = bounds[i].x;
for ( int j = 0; j <= 1; j++ ) for( int j = 0; j <= 1; j++ )
{ {
base.y = bounds[j].y; base.y = bounds[j].y;
for ( int k = 0; k <= 1; k++ ) for( int k = 0; k <= 1; k++ )
{ {
base.z = bounds[k].z; base.z = bounds[k].z;
// transform the point // transform the point
transformed.x = xvector.x*base.x + yvector.x*base.y; transformed.x = xvector.x * base.x + yvector.x * base.y;
transformed.y = xvector.y*base.x + yvector.y*base.y; transformed.y = xvector.y * base.x + yvector.y * base.y;
transformed.z = base.z; transformed.z = base.z;
if (transformed.x < rmin.x) if( transformed.x < rmin.x )
rmin.x = transformed.x; rmin.x = transformed.x;
if (transformed.x > rmax.x) if( transformed.x > rmax.x )
rmax.x = transformed.x; rmax.x = transformed.x;
if (transformed.y < rmin.y) if( transformed.y < rmin.y )
rmin.y = transformed.y; rmin.y = transformed.y;
if (transformed.y > rmax.y) if( transformed.y > rmax.y )
rmax.y = transformed.y; rmax.y = transformed.y;
if (transformed.z < rmin.z) if( transformed.z < rmin.z )
rmin.z = transformed.z; rmin.z = transformed.z;
if (transformed.z > rmax.z) if( transformed.z > rmax.z )
rmax.z = transformed.z; rmax.z = transformed.z;
} }
} }
@ -315,4 +309,3 @@ void CBaseAnimating :: SetSequenceBox( void )
UTIL_SetSize( pev, rmin, rmax ); UTIL_SetSize( pev, rmin, rmax );
} }
} }

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -53,52 +54,49 @@ extern globalvars_t *gpGlobals;
#pragma warning( disable : 4244 ) #pragma warning( disable : 4244 )
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ) int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return 0; return 0;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex );
mins[0] = pseqdesc[ sequence ].bbmin[0]; mins[0] = pseqdesc[sequence].bbmin[0];
mins[1] = pseqdesc[ sequence ].bbmin[1]; mins[1] = pseqdesc[sequence].bbmin[1];
mins[2] = pseqdesc[ sequence ].bbmin[2]; mins[2] = pseqdesc[sequence].bbmin[2];
maxs[0] = pseqdesc[ sequence ].bbmax[0]; maxs[0] = pseqdesc[sequence].bbmax[0];
maxs[1] = pseqdesc[ sequence ].bbmax[1]; maxs[1] = pseqdesc[sequence].bbmax[1];
maxs[2] = pseqdesc[ sequence ].bbmax[2]; maxs[2] = pseqdesc[sequence].bbmax[2];
return 1; return 1;
} }
int LookupActivity( void *pmodel, entvars_t *pev, int activity ) int LookupActivity( void *pmodel, entvars_t *pev, int activity )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return 0; return 0;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex );
int weighttotal = 0; int weighttotal = 0;
int seq = ACTIVITY_NOT_AVAILABLE; int seq = ACTIVITY_NOT_AVAILABLE;
for (int i = 0; i < pstudiohdr->numseq; i++) for( int i = 0; i < pstudiohdr->numseq; i++ )
{ {
if (pseqdesc[i].activity == activity) if( pseqdesc[i].activity == activity )
{ {
weighttotal += pseqdesc[i].actweight; weighttotal += pseqdesc[i].actweight;
if (!weighttotal || RANDOM_LONG(0,weighttotal-1) < pseqdesc[i].actweight) if( !weighttotal || RANDOM_LONG( 0, weighttotal - 1 ) < pseqdesc[i].actweight )
seq = i; seq = i;
} }
} }
@ -106,26 +104,25 @@ int LookupActivity( void *pmodel, entvars_t *pev, int activity )
return seq; return seq;
} }
int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ) int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if ( !pstudiohdr ) if( !pstudiohdr )
return 0; return 0;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex );
int weight = 0; int weight = 0;
int seq = ACTIVITY_NOT_AVAILABLE; int seq = ACTIVITY_NOT_AVAILABLE;
for (int i = 0; i < pstudiohdr->numseq; i++) for( int i = 0; i < pstudiohdr->numseq; i++ )
{ {
if (pseqdesc[i].activity == activity) if( pseqdesc[i].activity == activity )
{ {
if ( pseqdesc[i].actweight > weight ) if( pseqdesc[i].actweight > weight )
{ {
weight = pseqdesc[i].actweight; weight = pseqdesc[i].actweight;
seq = i; seq = i;
@ -136,19 +133,19 @@ int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity )
return seq; return seq;
} }
void GetEyePosition ( void *pmodel, float *vecEyePosition ) void GetEyePosition( void *pmodel, float *vecEyePosition )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if ( !pstudiohdr ) if( !pstudiohdr )
{ {
ALERT ( at_console, "GetEyePosition() Can't get pstudiohdr ptr!\n" ); ALERT( at_console, "GetEyePosition() Can't get pstudiohdr ptr!\n" );
return; return;
} }
VectorCopy ( pstudiohdr->eyeposition, vecEyePosition ); VectorCopy( pstudiohdr->eyeposition, vecEyePosition );
} }
int LookupSequence( void *pmodel, const char *label ) int LookupSequence( void *pmodel, const char *label )
@ -156,95 +153,91 @@ int LookupSequence( void *pmodel, const char *label )
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return 0; return 0;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex );
for (int i = 0; i < pstudiohdr->numseq; i++) for( int i = 0; i < pstudiohdr->numseq; i++ )
{ {
if (stricmp( pseqdesc[i].label, label ) == 0) if( stricmp( pseqdesc[i].label, label ) == 0 )
return i; return i;
} }
return -1; return -1;
} }
int IsSoundEvent( int eventNumber ) int IsSoundEvent( int eventNumber )
{ {
if ( eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE ) if( eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE )
return 1; return 1;
return 0; return 0;
} }
void SequencePrecache( void *pmodel, const char *pSequenceName ) void SequencePrecache( void *pmodel, const char *pSequenceName )
{ {
int index = LookupSequence( pmodel, pSequenceName ); int index = LookupSequence( pmodel, pSequenceName );
if ( index >= 0 ) if( index >= 0 )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if ( !pstudiohdr || index >= pstudiohdr->numseq ) if( !pstudiohdr || index >= pstudiohdr->numseq )
return; return;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
mstudioevent_t *pevent; mstudioevent_t *pevent;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index; pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + index;
pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); pevent = (mstudioevent_t *)( (byte *)pstudiohdr + pseqdesc->eventindex );
for (int i = 0; i < pseqdesc->numevents; i++) for( int i = 0; i < pseqdesc->numevents; i++ )
{ {
// Don't send client-side events to the server AI // Don't send client-side events to the server AI
if ( pevent[i].event >= EVENT_CLIENT ) if( pevent[i].event >= EVENT_CLIENT )
continue; continue;
// UNDONE: Add a callback to check to see if a sound is precached yet and don't allocate a copy // UNDONE: Add a callback to check to see if a sound is precached yet and don't allocate a copy
// of it's name if it is. // of it's name if it is.
if ( IsSoundEvent( pevent[i].event ) ) if( IsSoundEvent( pevent[i].event ) )
{ {
if ( !strlen(pevent[i].options) ) if( !strlen( pevent[i].options ) )
{ {
ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options );
} }
PRECACHE_SOUND( (char *)(gpGlobals->pStringBase + ALLOC_STRING(pevent[i].options) ) ); PRECACHE_SOUND( (char *)( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ) );
} }
} }
} }
} }
void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed ) void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return; return;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
if (pev->sequence >= pstudiohdr->numseq) if( pev->sequence >= pstudiohdr->numseq )
{ {
*pflFrameRate = 0.0; *pflFrameRate = 0.0;
*pflGroundSpeed = 0.0; *pflGroundSpeed = 0.0;
return; return;
} }
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence;
if (pseqdesc->numframes > 1) if( pseqdesc->numframes > 1 )
{ {
*pflFrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1); *pflFrameRate = 256 * pseqdesc->fps / ( pseqdesc->numframes - 1 );
*pflGroundSpeed = sqrt( pseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] ); *pflGroundSpeed = sqrt( pseqdesc->linearmovement[0] * pseqdesc->linearmovement[0] + pseqdesc->linearmovement[1] * pseqdesc->linearmovement[1] + pseqdesc->linearmovement[2] * pseqdesc->linearmovement[2] );
*pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1); *pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / ( pseqdesc->numframes - 1 );
} }
else else
{ {
@ -253,28 +246,26 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *
} }
} }
int GetSequenceFlags( void *pmodel, entvars_t *pev ) int GetSequenceFlags( void *pmodel, entvars_t *pev )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq ) if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq )
return 0; return 0;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence;
return pseqdesc->flags; return pseqdesc->flags;
} }
int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index ) int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent )
return 0; return 0;
int events = 0; int events = 0;
@ -282,15 +273,15 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
mstudioevent_t *pevent; mstudioevent_t *pevent;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence;
pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); pevent = (mstudioevent_t *)( (byte *)pstudiohdr + pseqdesc->eventindex );
if (pseqdesc->numevents == 0 || index > pseqdesc->numevents ) if( pseqdesc->numevents == 0 || index > pseqdesc->numevents )
return 0; return 0;
if (pseqdesc->numframes > 1) if( pseqdesc->numframes > 1 )
{ {
flStart *= (pseqdesc->numframes - 1) / 256.0; flStart *= ( pseqdesc->numframes - 1 ) / 256.0;
flEnd *= (pseqdesc->numframes - 1) / 256.0; flEnd *= (pseqdesc->numframes - 1) / 256.0;
} }
else else
@ -299,14 +290,14 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve
flEnd = 1.0; flEnd = 1.0;
} }
for (; index < pseqdesc->numevents; index++) for( ; index < pseqdesc->numevents; index++ )
{ {
// Don't send client-side events to the server AI // Don't send client-side events to the server AI
if ( pevent[index].event >= EVENT_CLIENT ) if( pevent[index].event >= EVENT_CLIENT )
continue; continue;
if ( (pevent[index].frame >= flStart && pevent[index].frame < flEnd) || if( ( pevent[index].frame >= flStart && pevent[index].frame < flEnd ) ||
((pseqdesc->flags & STUDIO_LOOPING) && flEnd >= pseqdesc->numframes - 1 && pevent[index].frame < flEnd - pseqdesc->numframes + 1) ) ( ( pseqdesc->flags & STUDIO_LOOPING ) && flEnd >= pseqdesc->numframes - 1 && pevent[index].frame < flEnd - pseqdesc->numframes + 1 ) )
{ {
pMonsterEvent->event = pevent[index].event; pMonsterEvent->event = pevent[index].event;
pMonsterEvent->options = pevent[index].options; pMonsterEvent->options = pevent[index].options;
@ -322,112 +313,111 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu
int i; int i;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return flValue; return flValue;
mstudiobonecontroller_t *pbonecontroller = (mstudiobonecontroller_t *)((byte *)pstudiohdr + pstudiohdr->bonecontrollerindex); mstudiobonecontroller_t *pbonecontroller = (mstudiobonecontroller_t *)( (byte *)pstudiohdr + pstudiohdr->bonecontrollerindex );
// find first controller that matches the index // find first controller that matches the index
for (i = 0; i < pstudiohdr->numbonecontrollers; i++, pbonecontroller++) for( i = 0; i < pstudiohdr->numbonecontrollers; i++, pbonecontroller++ )
{ {
if (pbonecontroller->index == iController) if( pbonecontroller->index == iController )
break; break;
} }
if (i >= pstudiohdr->numbonecontrollers) if( i >= pstudiohdr->numbonecontrollers )
return flValue; return flValue;
// wrap 0..360 if it's a rotational controller // wrap 0..360 if it's a rotational controller
if( pbonecontroller->type & ( STUDIO_XR | STUDIO_YR | STUDIO_ZR ) )
if (pbonecontroller->type & (STUDIO_XR | STUDIO_YR | STUDIO_ZR))
{ {
// ugly hack, invert value if end < start // ugly hack, invert value if end < start
if (pbonecontroller->end < pbonecontroller->start) if( pbonecontroller->end < pbonecontroller->start )
flValue = -flValue; flValue = -flValue;
// does the controller not wrap? // does the controller not wrap?
if (pbonecontroller->start + 359.0 >= pbonecontroller->end) if( pbonecontroller->start + 359.0 >= pbonecontroller->end )
{ {
if (flValue > ((pbonecontroller->start + pbonecontroller->end) / 2.0) + 180) if( flValue > ( ( pbonecontroller->start + pbonecontroller->end ) / 2.0 ) + 180 )
flValue = flValue - 360; flValue = flValue - 360;
if (flValue < ((pbonecontroller->start + pbonecontroller->end) / 2.0) - 180) if( flValue < ( ( pbonecontroller->start + pbonecontroller->end) / 2.0 ) - 180 )
flValue = flValue + 360; flValue = flValue + 360;
} }
else else
{ {
if (flValue > 360) if( flValue > 360 )
flValue = flValue - (int)(flValue / 360.0) * 360.0; flValue = flValue - (int)( flValue / 360.0 ) * 360.0;
else if (flValue < 0) else if( flValue < 0 )
flValue = flValue + (int)((flValue / -360.0) + 1) * 360.0; flValue = flValue + (int)( ( flValue / -360.0 ) + 1 ) * 360.0;
} }
} }
int setting = 255 * (flValue - pbonecontroller->start) / (pbonecontroller->end - pbonecontroller->start); int setting = 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start );
if (setting < 0) setting = 0; if( setting < 0 )
if (setting > 255) setting = 255; setting = 0;
if( setting > 255 )
setting = 255;
pev->controller[iController] = setting; pev->controller[iController] = setting;
return setting * (1.0 / 255.0) * (pbonecontroller->end - pbonecontroller->start) + pbonecontroller->start; return setting * ( 1.0 / 255.0 ) * (pbonecontroller->end - pbonecontroller->start ) + pbonecontroller->start;
} }
float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return flValue; return flValue;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence;
if (pseqdesc->blendtype[iBlender] == 0) if( pseqdesc->blendtype[iBlender] == 0 )
return flValue; return flValue;
if (pseqdesc->blendtype[iBlender] & (STUDIO_XR | STUDIO_YR | STUDIO_ZR)) if( pseqdesc->blendtype[iBlender] & ( STUDIO_XR | STUDIO_YR | STUDIO_ZR ) )
{ {
// ugly hack, invert value if end < start // ugly hack, invert value if end < start
if (pseqdesc->blendend[iBlender] < pseqdesc->blendstart[iBlender]) if( pseqdesc->blendend[iBlender] < pseqdesc->blendstart[iBlender] )
flValue = -flValue; flValue = -flValue;
// does the controller not wrap? // does the controller not wrap?
if (pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender]) if( pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender] )
{ {
if (flValue > ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) + 180) if( flValue > ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) / 2.0 ) + 180 )
flValue = flValue - 360; flValue = flValue - 360;
if (flValue < ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) - 180) if( flValue < ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) / 2.0 ) - 180 )
flValue = flValue + 360; flValue = flValue + 360;
} }
} }
int setting = 255 * (flValue - pseqdesc->blendstart[iBlender]) / (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender]); int setting = 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] );
if (setting < 0) setting = 0; if( setting < 0 )
if (setting > 255) setting = 255; setting = 0;
if(setting > 255)
setting = 255;
pev->blending[iBlender] = setting; pev->blending[iBlender] = setting;
return setting * (1.0 / 255.0) * (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender]) + pseqdesc->blendstart[iBlender]; return setting * ( 1.0 / 255.0 ) * ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) + pseqdesc->blendstart[iBlender];
} }
int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ) int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return iGoalAnim; return iGoalAnim;
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex );
// bail if we're going to or from a node 0 // bail if we're going to or from a node 0
if (pseqdesc[iEndingAnim].entrynode == 0 || pseqdesc[iGoalAnim].entrynode == 0) if( pseqdesc[iEndingAnim].entrynode == 0 || pseqdesc[iGoalAnim].entrynode == 0 )
{ {
return iGoalAnim; return iGoalAnim;
} }
@ -436,7 +426,7 @@ int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir )
// ALERT( at_console, "from %d to %d: ", pEndNode->iEndNode, pGoalNode->iStartNode ); // ALERT( at_console, "from %d to %d: ", pEndNode->iEndNode, pGoalNode->iStartNode );
if (*piDir > 0) if( *piDir > 0 )
{ {
iEndNode = pseqdesc[iEndingAnim].exitnode; iEndNode = pseqdesc[iEndingAnim].exitnode;
} }
@ -445,32 +435,32 @@ int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir )
iEndNode = pseqdesc[iEndingAnim].entrynode; iEndNode = pseqdesc[iEndingAnim].entrynode;
} }
if (iEndNode == pseqdesc[iGoalAnim].entrynode) if( iEndNode == pseqdesc[iGoalAnim].entrynode )
{ {
*piDir = 1; *piDir = 1;
return iGoalAnim; return iGoalAnim;
} }
byte *pTransition = ((byte *)pstudiohdr + pstudiohdr->transitionindex); byte *pTransition = ( (byte *)pstudiohdr + pstudiohdr->transitionindex );
int iInternNode = pTransition[(iEndNode-1)*pstudiohdr->numtransitions + (pseqdesc[iGoalAnim].entrynode-1)]; int iInternNode = pTransition[( iEndNode - 1 ) * pstudiohdr->numtransitions + ( pseqdesc[iGoalAnim].entrynode - 1 )];
if (iInternNode == 0) if( iInternNode == 0 )
return iGoalAnim; return iGoalAnim;
int i; int i;
// look for someone going // look for someone going
for (i = 0; i < pstudiohdr->numseq; i++) for( i = 0; i < pstudiohdr->numseq; i++ )
{ {
if (pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode) if( pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode )
{ {
*piDir = 1; *piDir = 1;
return i; return i;
} }
if (pseqdesc[i].nodeflags) if( pseqdesc[i].nodeflags )
{ {
if (pseqdesc[i].exitnode == iEndNode && pseqdesc[i].entrynode == iInternNode) if( pseqdesc[i].exitnode == iEndNode && pseqdesc[i].entrynode == iInternNode )
{ {
*piDir = -1; *piDir = -1;
return i; return i;
@ -487,40 +477,39 @@ void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue )
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return; return;
if (iGroup > pstudiohdr->numbodyparts) if( iGroup > pstudiohdr->numbodyparts )
return; return;
mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup; mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)( (byte *)pstudiohdr + pstudiohdr->bodypartindex ) + iGroup;
if (iValue >= pbodypart->nummodels) if( iValue >= pbodypart->nummodels )
return; return;
int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; int iCurrent = ( pev->body / pbodypart->base ) % pbodypart->nummodels;
pev->body = (pev->body - (iCurrent * pbodypart->base) + (iValue * pbodypart->base)); pev->body = ( pev->body - ( iCurrent * pbodypart->base ) + ( iValue * pbodypart->base ) );
} }
int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ) int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup )
{ {
studiohdr_t *pstudiohdr; studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel; pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr) if( !pstudiohdr )
return 0; return 0;
if (iGroup > pstudiohdr->numbodyparts) if( iGroup > pstudiohdr->numbodyparts )
return 0; return 0;
mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup; mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)( (byte *)pstudiohdr + pstudiohdr->bodypartindex ) + iGroup;
if (pbodypart->nummodels <= 1) if( pbodypart->nummodels <= 1 )
return 0; return 0;
int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; int iCurrent = ( pev->body / pbodypart->base ) % pbodypart->nummodels;
return iCurrent; return iCurrent;
} }

View File

@ -42,6 +42,4 @@ int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs );
// From /engine/studio.h // From /engine/studio.h
#define STUDIO_LOOPING 0x0001 #define STUDIO_LOOPING 0x0001
#endif //ANIMATION_H #endif //ANIMATION_H

File diff suppressed because it is too large Load Diff

View File

@ -36,11 +36,11 @@ class CBarnacle : public CBaseMonster
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
CBaseEntity *TongueTouchEnt ( float *pflLength ); CBaseEntity *TongueTouchEnt( float *pflLength );
int Classify ( void ); int Classify( void );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );
void EXPORT BarnacleThink ( void ); void EXPORT BarnacleThink( void );
void EXPORT WaitTillDead ( void ); void EXPORT WaitTillDead( void );
void Killed( entvars_t *pevAttacker, int iGib ); void Killed( entvars_t *pevAttacker, int iGib );
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
virtual int Save( CSave &save ); virtual int Save( CSave &save );
@ -65,7 +65,8 @@ public:
} }
#endif #endif
}; };
LINK_ENTITY_TO_CLASS( monster_barnacle, CBarnacle );
LINK_ENTITY_TO_CLASS( monster_barnacle, CBarnacle )
TYPEDESCRIPTION CBarnacle::m_SaveData[] = TYPEDESCRIPTION CBarnacle::m_SaveData[] =
{ {
@ -78,14 +79,13 @@ TYPEDESCRIPTION CBarnacle::m_SaveData[] =
DEFINE_FIELD( CBarnacle, m_flCachedLength, FIELD_FLOAT ), DEFINE_FIELD( CBarnacle, m_flCachedLength, FIELD_FLOAT ),
}; };
IMPLEMENT_SAVERESTORE( CBarnacle, CBaseMonster ); IMPLEMENT_SAVERESTORE( CBarnacle, CBaseMonster )
//========================================================= //=========================================================
// Classify - indicates this monster's place in the // Classify - indicates this monster's place in the
// relationship table. // relationship table.
//========================================================= //=========================================================
int CBarnacle :: Classify ( void ) int CBarnacle::Classify( void )
{ {
return CLASS_ALIEN_MONSTER; return CLASS_ALIEN_MONSTER;
} }
@ -96,7 +96,7 @@ int CBarnacle :: Classify ( void )
// //
// Returns number of events handled, 0 if none. // Returns number of events handled, 0 if none.
//========================================================= //=========================================================
void CBarnacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CBarnacle::HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
switch( pEvent->event ) switch( pEvent->event )
{ {
@ -112,12 +112,12 @@ void CBarnacle :: HandleAnimEvent( MonsterEvent_t *pEvent )
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CBarnacle :: Spawn() void CBarnacle::Spawn()
{ {
Precache( ); Precache();
SET_MODEL(ENT(pev), "models/barnacle.mdl"); SET_MODEL( ENT( pev ), "models/barnacle.mdl" );
UTIL_SetSize( pev, Vector(-16, -16, -32), Vector(16, 16, 0) ); UTIL_SetSize( pev, Vector( -16, -16, -32 ), Vector( 16, 16, 0 ) );
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
@ -135,17 +135,17 @@ void CBarnacle :: Spawn()
InitBoneControllers(); InitBoneControllers();
SetActivity ( ACT_IDLE ); SetActivity( ACT_IDLE );
SetThink( &CBarnacle::BarnacleThink ); SetThink( &CBarnacle::BarnacleThink );
pev->nextthink = gpGlobals->time + 0.5; pev->nextthink = gpGlobals->time + 0.5;
UTIL_SetOrigin ( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
int CBarnacle::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) int CBarnacle::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
if ( bitsDamageType & DMG_CLUB ) if( bitsDamageType & DMG_CLUB )
{ {
flDamage = pev->health; flDamage = pev->health;
} }
@ -155,27 +155,25 @@ int CBarnacle::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, floa
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBarnacle :: BarnacleThink ( void ) void CBarnacle::BarnacleThink( void )
{ {
CBaseEntity *pTouchEnt; CBaseEntity *pTouchEnt;
CBaseMonster *pVictim; CBaseMonster *pVictim;
float flLength; float flLength;
#ifdef BARNACLE_FIX_VISIBILITY #ifdef BARNACLE_FIX_VISIBILITY
if( m_flCachedLength != ( m_flAltitude + m_flTongueAdj ) || ( pev->absmin.z != pev->origin.z + -m_flCachedLength )) if( m_flCachedLength != ( m_flAltitude + m_flTongueAdj ) || ( pev->absmin.z != pev->origin.z + -m_flCachedLength ) )
{ {
// recalc collision box here to avoid barnacle disappears bug // recalc collision box here to avoid barnacle disappears bug
m_flCachedLength = (m_flAltitude + m_flTongueAdj); m_flCachedLength = m_flAltitude + m_flTongueAdj;
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
#endif #endif
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
if ( m_hEnemy != NULL ) if( m_hEnemy != NULL )
{ {
// barnacle has prey. // barnacle has prey.
if( !m_hEnemy->IsAlive() )
if ( !m_hEnemy->IsAlive() )
{ {
// someone (maybe even the barnacle) killed the prey. Reset barnacle. // someone (maybe even the barnacle) killed the prey. Reset barnacle.
m_fLiftingPrey = FALSE;// indicate that we're not lifting prey. m_fLiftingPrey = FALSE;// indicate that we're not lifting prey.
@ -183,9 +181,9 @@ void CBarnacle :: BarnacleThink ( void )
return; return;
} }
if ( m_fLiftingPrey ) if( m_fLiftingPrey )
{ {
if ( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO ) if( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO )
{ {
// crap, someone killed the prey on the way up. // crap, someone killed the prey on the way up.
m_hEnemy = NULL; m_hEnemy = NULL;
@ -199,44 +197,43 @@ void CBarnacle :: BarnacleThink ( void )
vecNewEnemyOrigin.y = pev->origin.y; vecNewEnemyOrigin.y = pev->origin.y;
// guess as to where their neck is // guess as to where their neck is
vecNewEnemyOrigin.x -= 6 * cos(m_hEnemy->pev->angles.y * M_PI/180.0); vecNewEnemyOrigin.x -= 6 * cos( m_hEnemy->pev->angles.y * M_PI / 180.0 );
vecNewEnemyOrigin.y -= 6 * sin(m_hEnemy->pev->angles.y * M_PI/180.0); vecNewEnemyOrigin.y -= 6 * sin( m_hEnemy->pev->angles.y * M_PI / 180.0 );
m_flAltitude -= BARNACLE_PULL_SPEED; m_flAltitude -= BARNACLE_PULL_SPEED;
vecNewEnemyOrigin.z += BARNACLE_PULL_SPEED; vecNewEnemyOrigin.z += BARNACLE_PULL_SPEED;
if ( fabs( pev->origin.z - ( vecNewEnemyOrigin.z + m_hEnemy->pev->view_ofs.z - 8 ) ) < BARNACLE_BODY_HEIGHT ) if( fabs( pev->origin.z - ( vecNewEnemyOrigin.z + m_hEnemy->pev->view_ofs.z - 8 ) ) < BARNACLE_BODY_HEIGHT )
{ {
// prey has just been lifted into position ( if the victim origin + eye height + 8 is higher than the bottom of the barnacle, it is assumed that the head is within barnacle's body ) // prey has just been lifted into position ( if the victim origin + eye height + 8 is higher than the bottom of the barnacle, it is assumed that the head is within barnacle's body )
m_fLiftingPrey = FALSE; m_fLiftingPrey = FALSE;
EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_bite3.wav", 1, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_bite3.wav", 1, ATTN_NORM );
pVictim = m_hEnemy->MyMonsterPointer(); pVictim = m_hEnemy->MyMonsterPointer();
m_flKillVictimTime = gpGlobals->time + 10;// now that the victim is in place, the killing bite will be administered in 10 seconds. m_flKillVictimTime = gpGlobals->time + 10;// now that the victim is in place, the killing bite will be administered in 10 seconds.
if ( pVictim ) if( pVictim )
{ {
pVictim->BarnacleVictimBitten( pev ); pVictim->BarnacleVictimBitten( pev );
SetActivity ( ACT_EAT ); SetActivity( ACT_EAT );
} }
} }
UTIL_SetOrigin ( m_hEnemy->pev, vecNewEnemyOrigin ); UTIL_SetOrigin( m_hEnemy->pev, vecNewEnemyOrigin );
} }
else else
{ {
// prey is lifted fully into feeding position and is dangling there. // prey is lifted fully into feeding position and is dangling there.
pVictim = m_hEnemy->MyMonsterPointer(); pVictim = m_hEnemy->MyMonsterPointer();
if ( m_flKillVictimTime != -1 && gpGlobals->time > m_flKillVictimTime ) if( m_flKillVictimTime != -1 && gpGlobals->time > m_flKillVictimTime )
{ {
// kill! // kill!
if ( pVictim ) if( pVictim )
{ {
pVictim->TakeDamage ( pev, pev, pVictim->pev->health, DMG_SLASH | DMG_ALWAYSGIB ); pVictim->TakeDamage( pev, pev, pVictim->pev->health, DMG_SLASH | DMG_ALWAYSGIB );
m_cGibs = 3; m_cGibs = 3;
} }
@ -244,58 +241,69 @@ void CBarnacle :: BarnacleThink ( void )
} }
// bite prey every once in a while // bite prey every once in a while
if ( pVictim && ( RANDOM_LONG(0,49) == 0 ) ) if( pVictim && ( RANDOM_LONG( 0, 49 ) == 0 ) )
{ {
switch ( RANDOM_LONG(0,2) ) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM ); break; case 0:
case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM ); break; EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM );
case 2: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM ); break; break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM );
break;
} }
pVictim->BarnacleVictimBitten( pev ); pVictim->BarnacleVictimBitten( pev );
} }
} }
} }
else else
{ {
// barnacle has no prey right now, so just idle and check to see if anything is touching the tongue. // barnacle has no prey right now, so just idle and check to see if anything is touching the tongue.
// If idle and no nearby client, don't think so often // If idle and no nearby client, don't think so often
if ( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) )
pev->nextthink = gpGlobals->time + RANDOM_FLOAT(1,1.5); // Stagger a bit to keep barnacles from thinking on the same frame pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); // Stagger a bit to keep barnacles from thinking on the same frame
if ( m_fSequenceFinished ) if( m_fSequenceFinished )
{// this is done so barnacle will fidget. {
// this is done so barnacle will fidget.
SetActivity ( ACT_IDLE ); SetActivity ( ACT_IDLE );
m_flTongueAdj = -100; m_flTongueAdj = -100;
} }
if ( m_cGibs && RANDOM_LONG(0,99) == 1 ) if( m_cGibs && RANDOM_LONG( 0, 99 ) == 1 )
{ {
// cough up a gib. // cough up a gib.
CGib::SpawnRandomGibs( pev, 1, 1 ); CGib::SpawnRandomGibs( pev, 1, 1 );
m_cGibs--; m_cGibs--;
switch ( RANDOM_LONG(0,2) ) switch ( RANDOM_LONG( 0, 2 ) )
{ {
case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM ); break; case 0:
case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM ); break; EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM );
case 2: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM ); break; break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM );
break;
} }
} }
pTouchEnt = TongueTouchEnt( &flLength ); pTouchEnt = TongueTouchEnt( &flLength );
if ( pTouchEnt != NULL && m_fTongueExtended ) if( pTouchEnt != NULL && m_fTongueExtended )
{ {
// tongue is fully extended, and is touching someone. // tongue is fully extended, and is touching someone.
if ( pTouchEnt->FBecomeProne() ) if( pTouchEnt->FBecomeProne() )
{ {
EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_alert2.wav", 1, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_alert2.wav", 1, ATTN_NORM );
SetSequenceByName ( "attack1" ); SetSequenceByName( "attack1" );
m_flTongueAdj = -20; m_flTongueAdj = -20;
m_hEnemy = pTouchEnt; m_hEnemy = pTouchEnt;
@ -309,13 +317,13 @@ void CBarnacle :: BarnacleThink ( void )
m_fLiftingPrey = TRUE;// indicate that we should be lifting prey. m_fLiftingPrey = TRUE;// indicate that we should be lifting prey.
m_flKillVictimTime = -1;// set this to a bogus time while the victim is lifted. m_flKillVictimTime = -1;// set this to a bogus time while the victim is lifted.
m_flAltitude = (pev->origin.z - pTouchEnt->EyePosition().z); m_flAltitude = pev->origin.z - pTouchEnt->EyePosition().z;
} }
} }
else else
{ {
// calculate a new length for the tongue to be clear of anything else that moves under it. // calculate a new length for the tongue to be clear of anything else that moves under it.
if ( m_flAltitude < flLength ) if( m_flAltitude < flLength )
{ {
// if tongue is higher than is should be, lower it kind of slowly. // if tongue is higher than is should be, lower it kind of slowly.
m_flAltitude += BARNACLE_PULL_SPEED; m_flAltitude += BARNACLE_PULL_SPEED;
@ -326,45 +334,47 @@ void CBarnacle :: BarnacleThink ( void )
m_flAltitude = flLength; m_flAltitude = flLength;
m_fTongueExtended = TRUE; m_fTongueExtended = TRUE;
} }
} }
} }
// ALERT( at_console, "tounge %f\n", m_flAltitude + m_flTongueAdj ); // ALERT( at_console, "tounge %f\n", m_flAltitude + m_flTongueAdj );
SetBoneController( 0, -(m_flAltitude + m_flTongueAdj) ); SetBoneController( 0, -( m_flAltitude + m_flTongueAdj ) );
StudioFrameAdvance( 0.1 ); StudioFrameAdvance( 0.1 );
} }
//========================================================= //=========================================================
// Killed. // Killed.
//========================================================= //=========================================================
void CBarnacle :: Killed( entvars_t *pevAttacker, int iGib ) void CBarnacle::Killed( entvars_t *pevAttacker, int iGib )
{ {
CBaseMonster *pVictim; CBaseMonster *pVictim;
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
if ( m_hEnemy != NULL ) if( m_hEnemy != NULL )
{ {
pVictim = m_hEnemy->MyMonsterPointer(); pVictim = m_hEnemy->MyMonsterPointer();
if ( pVictim ) if( pVictim )
{ {
pVictim->BarnacleVictimReleased(); pVictim->BarnacleVictimReleased();
} }
} }
// CGib::SpawnRandomGibs( pev, 4, 1 ); //CGib::SpawnRandomGibs( pev, 4, 1 );
switch ( RANDOM_LONG ( 0, 1 ) ) switch( RANDOM_LONG ( 0, 1 ) )
{ {
case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_die1.wav", 1, ATTN_NORM ); break; case 0:
case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_die3.wav", 1, ATTN_NORM ); break; EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_die1.wav", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_die3.wav", 1, ATTN_NORM );
break;
} }
SetActivity ( ACT_DIESIMPLE ); SetActivity( ACT_DIESIMPLE );
SetBoneController( 0, 0 ); SetBoneController( 0, 0 );
StudioFrameAdvance( 0.1 ); StudioFrameAdvance( 0.1 );
@ -375,14 +385,14 @@ void CBarnacle :: Killed( entvars_t *pevAttacker, int iGib )
//========================================================= //=========================================================
//========================================================= //=========================================================
void CBarnacle :: WaitTillDead ( void ) void CBarnacle::WaitTillDead( void )
{ {
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
float flInterval = StudioFrameAdvance( 0.1 ); float flInterval = StudioFrameAdvance( 0.1 );
DispatchAnimEvents ( flInterval ); DispatchAnimEvents( flInterval );
if ( m_fSequenceFinished ) if( m_fSequenceFinished )
{ {
// death anim finished. // death anim finished.
StopAnimation(); StopAnimation();
@ -393,17 +403,17 @@ void CBarnacle :: WaitTillDead ( void )
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CBarnacle :: Precache() void CBarnacle::Precache()
{ {
PRECACHE_MODEL("models/barnacle.mdl"); PRECACHE_MODEL( "models/barnacle.mdl" );
PRECACHE_SOUND("barnacle/bcl_alert2.wav");//happy, lifting food up PRECACHE_SOUND( "barnacle/bcl_alert2.wav" );//happy, lifting food up
PRECACHE_SOUND("barnacle/bcl_bite3.wav");//just got food to mouth PRECACHE_SOUND( "barnacle/bcl_bite3.wav" );//just got food to mouth
PRECACHE_SOUND("barnacle/bcl_chew1.wav"); PRECACHE_SOUND( "barnacle/bcl_chew1.wav" );
PRECACHE_SOUND("barnacle/bcl_chew2.wav"); PRECACHE_SOUND( "barnacle/bcl_chew2.wav" );
PRECACHE_SOUND("barnacle/bcl_chew3.wav"); PRECACHE_SOUND( "barnacle/bcl_chew3.wav" );
PRECACHE_SOUND("barnacle/bcl_die1.wav" ); PRECACHE_SOUND( "barnacle/bcl_die1.wav" );
PRECACHE_SOUND("barnacle/bcl_die3.wav" ); PRECACHE_SOUND( "barnacle/bcl_die3.wav" );
} }
//========================================================= //=========================================================
@ -412,15 +422,15 @@ void CBarnacle :: Precache()
// of the trace in the int pointer provided. // of the trace in the int pointer provided.
//========================================================= //=========================================================
#define BARNACLE_CHECK_SPACING 8 #define BARNACLE_CHECK_SPACING 8
CBaseEntity *CBarnacle :: TongueTouchEnt ( float *pflLength ) CBaseEntity *CBarnacle::TongueTouchEnt( float *pflLength )
{ {
TraceResult tr; TraceResult tr;
float length; float length;
// trace once to hit architecture and see if the tongue needs to change position. // trace once to hit architecture and see if the tongue needs to change position.
UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0 , 0 , 2048 ), ignore_monsters, ENT(pev), &tr ); UTIL_TraceLine( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT( pev ), &tr );
length = fabs( pev->origin.z - tr.vecEndPos.z ); length = fabs( pev->origin.z - tr.vecEndPos.z );
if ( pflLength ) if( pflLength )
{ {
*pflLength = length; *pflLength = length;
} }
@ -432,13 +442,13 @@ CBaseEntity *CBarnacle :: TongueTouchEnt ( float *pflLength )
mins.z -= length; mins.z -= length;
CBaseEntity *pList[10]; CBaseEntity *pList[10];
int count = UTIL_EntitiesInBox( pList, 10, mins, maxs, (FL_CLIENT|FL_MONSTER) ); int count = UTIL_EntitiesInBox( pList, 10, mins, maxs, ( FL_CLIENT | FL_MONSTER ) );
if ( count ) if( count )
{ {
for ( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
// only clients and monsters // only clients and monsters
if ( pList[i] != this && IRelationship( pList[i] ) > R_NO && pList[ i ]->pev->deadflag == DEAD_NO ) // this ent is one of our enemies. Barnacle tries to eat it. if( pList[i] != this && IRelationship( pList[i] ) > R_NO && pList[ i ]->pev->deadflag == DEAD_NO ) // this ent is one of our enemies. Barnacle tries to eat it.
{ {
return pList[i]; return pList[i];
} }

View File

@ -49,21 +49,21 @@ public:
int ISoundMask( void ); int ISoundMask( void );
void BarneyFirePistol( void ); void BarneyFirePistol( void );
void AlertSound( void ); void AlertSound( void );
int Classify ( void ); int Classify( void );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );
void RunTask( Task_t *pTask ); void RunTask( Task_t *pTask );
void StartTask( Task_t *pTask ); void StartTask( Task_t *pTask );
virtual int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; } virtual int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; }
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType);
BOOL CheckRangeAttack1 ( float flDot, float flDist ); BOOL CheckRangeAttack1( float flDot, float flDist );
void DeclineFollowing( void ); void DeclineFollowing( void );
// Override these to set behavior // Override these to set behavior
Schedule_t *GetScheduleOfType ( int Type ); Schedule_t *GetScheduleOfType( int Type );
Schedule_t *GetSchedule ( void ); Schedule_t *GetSchedule( void );
MONSTERSTATE GetIdealState ( void ); MONSTERSTATE GetIdealState( void );
void DeathSound( void ); void DeathSound( void );
void PainSound( void ); void PainSound( void );
@ -85,10 +85,10 @@ public:
// UNDONE: What is this for? It isn't used? // UNDONE: What is this for? It isn't used?
float m_flPlayerDamage;// how much pain has the player inflicted on me? float m_flPlayerDamage;// how much pain has the player inflicted on me?
CUSTOM_SCHEDULES; CUSTOM_SCHEDULES
}; };
LINK_ENTITY_TO_CLASS( monster_barney, CBarney ); LINK_ENTITY_TO_CLASS( monster_barney, CBarney )
TYPEDESCRIPTION CBarney::m_SaveData[] = TYPEDESCRIPTION CBarney::m_SaveData[] =
{ {
@ -99,14 +99,14 @@ TYPEDESCRIPTION CBarney::m_SaveData[] =
DEFINE_FIELD( CBarney, m_flPlayerDamage, FIELD_FLOAT ), DEFINE_FIELD( CBarney, m_flPlayerDamage, FIELD_FLOAT ),
}; };
IMPLEMENT_SAVERESTORE( CBarney, CTalkMonster ); IMPLEMENT_SAVERESTORE( CBarney, CTalkMonster )
//========================================================= //=========================================================
// AI Schedules Specific to this monster // AI Schedules Specific to this monster
//========================================================= //=========================================================
Task_t tlBaFollow[] = Task_t tlBaFollow[] =
{ {
{ TASK_MOVE_TO_TARGET_RANGE,(float)128 }, // Move within 128 of target ent (client) { TASK_MOVE_TO_TARGET_RANGE, (float)128 }, // Move within 128 of target ent (client)
{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE },
}; };
@ -114,7 +114,7 @@ Schedule_t slBaFollow[] =
{ {
{ {
tlBaFollow, tlBaFollow,
ARRAYSIZE ( tlBaFollow ), ARRAYSIZE( tlBaFollow ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
@ -126,7 +126,7 @@ Schedule_t slBaFollow[] =
}; };
//========================================================= //=========================================================
// BarneyDraw- much better looking draw schedule for when // BarneyDraw - much better looking draw schedule for when
// barney knows who he's gonna attack. // barney knows who he's gonna attack.
//========================================================= //=========================================================
Task_t tlBarneyEnemyDraw[] = Task_t tlBarneyEnemyDraw[] =
@ -140,7 +140,7 @@ Schedule_t slBarneyEnemyDraw[] =
{ {
{ {
tlBarneyEnemyDraw, tlBarneyEnemyDraw,
ARRAYSIZE ( tlBarneyEnemyDraw ), ARRAYSIZE( tlBarneyEnemyDraw ),
0, 0,
0, 0,
"Barney Enemy Draw" "Barney Enemy Draw"
@ -159,7 +159,7 @@ Schedule_t slBaFaceTarget[] =
{ {
{ {
tlBaFaceTarget, tlBaFaceTarget,
ARRAYSIZE ( tlBaFaceTarget ), ARRAYSIZE( tlBaFaceTarget ),
bits_COND_CLIENT_PUSH | bits_COND_CLIENT_PUSH |
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -171,7 +171,6 @@ Schedule_t slBaFaceTarget[] =
}, },
}; };
Task_t tlIdleBaStand[] = Task_t tlIdleBaStand[] =
{ {
{ TASK_STOP_MOVING, 0 }, { TASK_STOP_MOVING, 0 },
@ -184,18 +183,16 @@ Schedule_t slIdleBaStand[] =
{ {
{ {
tlIdleBaStand, tlIdleBaStand,
ARRAYSIZE ( tlIdleBaStand ), ARRAYSIZE( tlIdleBaStand ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
bits_COND_HEAR_SOUND | bits_COND_HEAR_SOUND |
bits_COND_SMELL | bits_COND_SMELL |
bits_COND_PROVOKED, bits_COND_PROVOKED,
bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code.
//bits_SOUND_PLAYER | //bits_SOUND_PLAYER |
//bits_SOUND_WORLD | //bits_SOUND_WORLD |
bits_SOUND_DANGER | bits_SOUND_DANGER |
bits_SOUND_MEAT |// scents bits_SOUND_MEAT |// scents
bits_SOUND_CARCASS | bits_SOUND_CARCASS |
@ -212,20 +209,19 @@ DEFINE_CUSTOM_SCHEDULES( CBarney )
slIdleBaStand, slIdleBaStand,
}; };
IMPLEMENT_CUSTOM_SCHEDULES( CBarney, CTalkMonster )
IMPLEMENT_CUSTOM_SCHEDULES( CBarney, CTalkMonster ); void CBarney::StartTask( Task_t *pTask )
void CBarney :: StartTask( Task_t *pTask )
{ {
CTalkMonster::StartTask( pTask ); CTalkMonster::StartTask( pTask );
} }
void CBarney :: RunTask( Task_t *pTask ) void CBarney::RunTask( Task_t *pTask )
{ {
switch ( pTask->iTask ) switch( pTask->iTask )
{ {
case TASK_RANGE_ATTACK1: case TASK_RANGE_ATTACK1:
if (m_hEnemy != NULL && (m_hEnemy->IsPlayer())) if( m_hEnemy != NULL && ( m_hEnemy->IsPlayer() ) )
{ {
pev->framerate = 1.5; pev->framerate = 1.5;
} }
@ -237,14 +233,11 @@ void CBarney :: RunTask( Task_t *pTask )
} }
} }
//========================================================= //=========================================================
// ISoundMask - returns a bit mask indicating which types // ISoundMask - returns a bit mask indicating which types
// of sounds this monster regards. // of sounds this monster regards.
//========================================================= //=========================================================
int CBarney :: ISoundMask ( void) int CBarney::ISoundMask( void)
{ {
return bits_SOUND_WORLD | return bits_SOUND_WORLD |
bits_SOUND_COMBAT | bits_SOUND_COMBAT |
@ -259,7 +252,7 @@ int CBarney :: ISoundMask ( void)
// Classify - indicates this monster's place in the // Classify - indicates this monster's place in the
// relationship table. // relationship table.
//========================================================= //=========================================================
int CBarney :: Classify ( void ) int CBarney::Classify( void )
{ {
return CLASS_PLAYER_ALLY; return CLASS_PLAYER_ALLY;
} }
@ -267,22 +260,22 @@ int CBarney :: Classify ( void )
//========================================================= //=========================================================
// ALertSound - barney says "Freeze!" // ALertSound - barney says "Freeze!"
//========================================================= //=========================================================
void CBarney :: AlertSound( void ) void CBarney::AlertSound( void )
{ {
if ( m_hEnemy != NULL ) if( m_hEnemy != NULL )
{ {
if ( FOkToSpeak() ) if( FOkToSpeak() )
{ {
PlaySentence( "BA_ATTACK", RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); PlaySentence( "BA_ATTACK", RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE );
} }
} }
} }
//========================================================= //=========================================================
// SetYawSpeed - allows each sequence to have a different // SetYawSpeed - allows each sequence to have a different
// turn rate associated with it. // turn rate associated with it.
//========================================================= //=========================================================
void CBarney :: SetYawSpeed ( void ) void CBarney::SetYawSpeed( void )
{ {
int ys; int ys;
@ -307,24 +300,23 @@ void CBarney :: SetYawSpeed ( void )
pev->yaw_speed = ys; pev->yaw_speed = ys;
} }
//========================================================= //=========================================================
// CheckRangeAttack1 // CheckRangeAttack1
//========================================================= //=========================================================
BOOL CBarney :: CheckRangeAttack1 ( float flDot, float flDist ) BOOL CBarney::CheckRangeAttack1( float flDot, float flDist )
{ {
if ( flDist <= 1024 && flDot >= 0.5 ) if( flDist <= 1024 && flDot >= 0.5 )
{ {
if ( gpGlobals->time > m_checkAttackTime ) if( gpGlobals->time > m_checkAttackTime )
{ {
TraceResult tr; TraceResult tr;
Vector shootOrigin = pev->origin + Vector( 0, 0, 55 ); Vector shootOrigin = pev->origin + Vector( 0, 0, 55 );
CBaseEntity *pEnemy = m_hEnemy; CBaseEntity *pEnemy = m_hEnemy;
Vector shootTarget = ( (pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin) + m_vecEnemyLKP ); Vector shootTarget = ( ( pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin ) + m_vecEnemyLKP );
UTIL_TraceLine( shootOrigin, shootTarget, dont_ignore_monsters, ENT(pev), &tr ); UTIL_TraceLine( shootOrigin, shootTarget, dont_ignore_monsters, ENT( pev ), &tr );
m_checkAttackTime = gpGlobals->time + 1; m_checkAttackTime = gpGlobals->time + 1;
if ( tr.flFraction == 1.0 || (tr.pHit != NULL && CBaseEntity::Instance(tr.pHit) == pEnemy) ) if( tr.flFraction == 1.0 || ( tr.pHit != NULL && CBaseEntity::Instance( tr.pHit ) == pEnemy ) )
m_lastAttackCheck = TRUE; m_lastAttackCheck = TRUE;
else else
m_lastAttackCheck = FALSE; m_lastAttackCheck = FALSE;
@ -335,16 +327,15 @@ BOOL CBarney :: CheckRangeAttack1 ( float flDot, float flDist )
return FALSE; return FALSE;
} }
//========================================================= //=========================================================
// BarneyFirePistol - shoots one round from the pistol at // BarneyFirePistol - shoots one round from the pistol at
// the enemy barney is facing. // the enemy barney is facing.
//========================================================= //=========================================================
void CBarney :: BarneyFirePistol ( void ) void CBarney::BarneyFirePistol( void )
{ {
Vector vecShootOrigin; Vector vecShootOrigin;
UTIL_MakeVectors(pev->angles); UTIL_MakeVectors( pev->angles );
vecShootOrigin = pev->origin + Vector( 0, 0, 55 ); vecShootOrigin = pev->origin + Vector( 0, 0, 55 );
Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); Vector vecShootDir = ShootAtEnemy( vecShootOrigin );
@ -352,18 +343,18 @@ void CBarney :: BarneyFirePistol ( void )
SetBlending( 0, angDir.x ); SetBlending( 0, angDir.x );
pev->effects = EF_MUZZLEFLASH; pev->effects = EF_MUZZLEFLASH;
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM ); FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM );
int pitchShift = RANDOM_LONG( 0, 20 ); int pitchShift = RANDOM_LONG( 0, 20 );
// Only shift about half the time // Only shift about half the time
if ( pitchShift > 10 ) if( pitchShift > 10 )
pitchShift = 0; pitchShift = 0;
else else
pitchShift -= 5; pitchShift -= 5;
EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "barney/ba_attack2.wav", 1, ATTN_NORM, 0, 100 + pitchShift ); EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "barney/ba_attack2.wav", 1, ATTN_NORM, 0, 100 + pitchShift );
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 384, 0.3 );
// UNDONE: Reload? // UNDONE: Reload?
m_cAmmoLoaded--;// take away a bullet! m_cAmmoLoaded--;// take away a bullet!
@ -375,26 +366,23 @@ void CBarney :: BarneyFirePistol ( void )
// //
// Returns number of events handled, 0 if none. // Returns number of events handled, 0 if none.
//========================================================= //=========================================================
void CBarney :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CBarney::HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
switch( pEvent->event ) switch( pEvent->event )
{ {
case BARNEY_AE_SHOOT: case BARNEY_AE_SHOOT:
BarneyFirePistol(); BarneyFirePistol();
break; break;
case BARNEY_AE_DRAW: case BARNEY_AE_DRAW:
// barney's bodygroup switches here so he can pull gun from holster // barney's bodygroup switches here so he can pull gun from holster
pev->body = BARNEY_BODY_GUNDRAWN; pev->body = BARNEY_BODY_GUNDRAWN;
m_fGunDrawn = TRUE; m_fGunDrawn = TRUE;
break; break;
case BARNEY_AE_HOLSTER: case BARNEY_AE_HOLSTER:
// change bodygroup to replace gun in holster // change bodygroup to replace gun in holster
pev->body = BARNEY_BODY_GUNHOLSTERED; pev->body = BARNEY_BODY_GUNHOLSTERED;
m_fGunDrawn = FALSE; m_fGunDrawn = FALSE;
break; break;
default: default:
CTalkMonster::HandleAnimEvent( pEvent ); CTalkMonster::HandleAnimEvent( pEvent );
} }
@ -403,12 +391,12 @@ void CBarney :: HandleAnimEvent( MonsterEvent_t *pEvent )
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CBarney :: Spawn() void CBarney::Spawn()
{ {
Precache( ); Precache();
SET_MODEL(ENT(pev), "models/barney.mdl"); SET_MODEL( ENT( pev ), "models/barney.mdl" );
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
@ -430,20 +418,20 @@ void CBarney :: Spawn()
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CBarney :: Precache() void CBarney::Precache()
{ {
PRECACHE_MODEL("models/barney.mdl"); PRECACHE_MODEL( "models/barney.mdl" );
PRECACHE_SOUND("barney/ba_attack1.wav" ); PRECACHE_SOUND( "barney/ba_attack1.wav" );
PRECACHE_SOUND("barney/ba_attack2.wav" ); PRECACHE_SOUND( "barney/ba_attack2.wav" );
PRECACHE_SOUND("barney/ba_pain1.wav"); PRECACHE_SOUND( "barney/ba_pain1.wav" );
PRECACHE_SOUND("barney/ba_pain2.wav"); PRECACHE_SOUND( "barney/ba_pain2.wav" );
PRECACHE_SOUND("barney/ba_pain3.wav"); PRECACHE_SOUND( "barney/ba_pain3.wav" );
PRECACHE_SOUND("barney/ba_die1.wav"); PRECACHE_SOUND( "barney/ba_die1.wav" );
PRECACHE_SOUND("barney/ba_die2.wav"); PRECACHE_SOUND( "barney/ba_die2.wav" );
PRECACHE_SOUND("barney/ba_die3.wav"); PRECACHE_SOUND( "barney/ba_die3.wav" );
// every new barney must call this, otherwise // every new barney must call this, otherwise
// when a level is loaded, nobody will talk (time is reset to 0) // when a level is loaded, nobody will talk (time is reset to 0)
@ -452,13 +440,11 @@ void CBarney :: Precache()
} }
// Init talk data // Init talk data
void CBarney :: TalkInit() void CBarney::TalkInit()
{ {
CTalkMonster::TalkInit(); CTalkMonster::TalkInit();
// scientists speach group names (group names are in sentences.txt) // scientists speach group names (group names are in sentences.txt)
m_szGrp[TLK_ANSWER] = "BA_ANSWER"; m_szGrp[TLK_ANSWER] = "BA_ANSWER";
m_szGrp[TLK_QUESTION] = "BA_QUESTION"; m_szGrp[TLK_QUESTION] = "BA_QUESTION";
m_szGrp[TLK_IDLE] = "BA_IDLE"; m_szGrp[TLK_IDLE] = "BA_IDLE";
@ -487,42 +473,41 @@ void CBarney :: TalkInit()
m_voicePitch = 100; m_voicePitch = 100;
} }
static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) static BOOL IsFacing( entvars_t *pevTest, const Vector &reference )
{ {
Vector vecDir = (reference - pevTest->origin); Vector vecDir = reference - pevTest->origin;
vecDir.z = 0; vecDir.z = 0;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
Vector forward, angle; Vector forward, angle;
angle = pevTest->v_angle; angle = pevTest->v_angle;
angle.x = 0; angle.x = 0;
UTIL_MakeVectorsPrivate( angle, forward, NULL, NULL ); UTIL_MakeVectorsPrivate( angle, forward, NULL, NULL );
// He's facing me, he meant it // He's facing me, he meant it
if ( DotProduct( forward, vecDir ) > 0.96 ) // +/- 15 degrees or so if( DotProduct( forward, vecDir ) > 0.96 ) // +/- 15 degrees or so
{ {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType)
{ {
// make sure friends talk about it if player hurts talkmonsters... // make sure friends talk about it if player hurts talkmonsters...
int ret = CTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); int ret = CTalkMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
if ( !IsAlive() || pev->deadflag == DEAD_DYING ) if( !IsAlive() || pev->deadflag == DEAD_DYING )
return ret; return ret;
if ( m_MonsterState != MONSTERSTATE_PRONE && (pevAttacker->flags & FL_CLIENT) ) if( m_MonsterState != MONSTERSTATE_PRONE && ( pevAttacker->flags & FL_CLIENT ) )
{ {
m_flPlayerDamage += flDamage; m_flPlayerDamage += flDamage;
// This is a heurstic to determine if the player intended to harm me // This is a heurstic to determine if the player intended to harm me
// If I have an enemy, we can't establish intent (may just be crossfire) // If I have an enemy, we can't establish intent (may just be crossfire)
if ( m_hEnemy == NULL ) if( m_hEnemy == NULL )
{ {
// If the player was facing directly at me, or I'm already suspicious, get mad // If the player was facing directly at me, or I'm already suspicious, get mad
if ( (m_afMemory & bits_MEMORY_SUSPICIOUS) || IsFacing( pevAttacker, pev->origin ) ) if( ( m_afMemory & bits_MEMORY_SUSPICIOUS ) || IsFacing( pevAttacker, pev->origin ) )
{ {
// Alright, now I'm pissed! // Alright, now I'm pissed!
PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM ); PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM );
@ -537,7 +522,7 @@ int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa
Remember( bits_MEMORY_SUSPICIOUS ); Remember( bits_MEMORY_SUSPICIOUS );
} }
} }
else if ( !(m_hEnemy->IsPlayer()) && pev->deadflag == DEAD_NO ) else if( !( m_hEnemy->IsPlayer()) && pev->deadflag == DEAD_NO )
{ {
PlaySentence( "BA_SHOT", 4, VOL_NORM, ATTN_NORM ); PlaySentence( "BA_SHOT", 4, VOL_NORM, ATTN_NORM );
} }
@ -546,60 +531,71 @@ int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa
return ret; return ret;
} }
//========================================================= //=========================================================
// PainSound // PainSound
//========================================================= //=========================================================
void CBarney :: PainSound ( void ) void CBarney::PainSound( void )
{ {
if (gpGlobals->time < m_painTime) if( gpGlobals->time < m_painTime )
return; return;
m_painTime = gpGlobals->time + RANDOM_FLOAT(0.5, 0.75); m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 0.75 );
switch (RANDOM_LONG(0,2)) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; case 0:
case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
case 2: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
break;
case 2:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
break;
} }
} }
//========================================================= //=========================================================
// DeathSound // DeathSound
//========================================================= //=========================================================
void CBarney :: DeathSound ( void ) void CBarney::DeathSound( void )
{ {
switch (RANDOM_LONG(0,2)) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; case 0:
case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
case 2: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
break;
case 2:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
break;
} }
} }
void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType )
void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType)
{ {
switch( ptr->iHitgroup) switch( ptr->iHitgroup )
{ {
case HITGROUP_CHEST: case HITGROUP_CHEST:
case HITGROUP_STOMACH: case HITGROUP_STOMACH:
if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST)) if (bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_BLAST ) )
{ {
flDamage = flDamage / 2; flDamage = flDamage / 2;
} }
break; break;
case 10: case 10:
if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_CLUB)) if( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_CLUB ) )
{ {
flDamage -= 20; flDamage -= 20;
if (flDamage <= 0) if( flDamage <= 0 )
{ {
UTIL_Ricochet( ptr->vecEndPos, 1.0 ); UTIL_Ricochet( ptr->vecEndPos, 1.0 );
flDamage = 0.01; flDamage = 0.01;
} }
} }
// always a head shot // always a head shot
ptr->iHitgroup = HITGROUP_HEAD; ptr->iHitgroup = HITGROUP_HEAD;
break; break;
@ -608,11 +604,11 @@ void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir
CTalkMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); CTalkMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
} }
void CBarney::Killed( entvars_t *pevAttacker, int iGib ) void CBarney::Killed( entvars_t *pevAttacker, int iGib )
{ {
if ( pev->body < BARNEY_BODY_GUNGONE ) if( pev->body < BARNEY_BODY_GUNGONE )
{// drop the gun! {
// drop the gun!
Vector vecGunPos; Vector vecGunPos;
Vector vecGunAngles; Vector vecGunAngles;
@ -630,41 +626,37 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib )
//========================================================= //=========================================================
// AI Schedules Specific to this monster // AI Schedules Specific to this monster
//========================================================= //=========================================================
Schedule_t *CBarney::GetScheduleOfType( int Type )
Schedule_t* CBarney :: GetScheduleOfType ( int Type )
{ {
Schedule_t *psched; Schedule_t *psched;
switch( Type ) switch( Type )
{ {
case SCHED_ARM_WEAPON: case SCHED_ARM_WEAPON:
if ( m_hEnemy != NULL ) if( m_hEnemy != NULL )
{ {
// face enemy, then draw. // face enemy, then draw.
return slBarneyEnemyDraw; return slBarneyEnemyDraw;
} }
break; break;
// Hook these to make a looping schedule // Hook these to make a looping schedule
case SCHED_TARGET_FACE: case SCHED_TARGET_FACE:
// call base class default so that barney will talk // call base class default so that barney will talk
// when 'used' // when 'used'
psched = CTalkMonster::GetScheduleOfType(Type); psched = CTalkMonster::GetScheduleOfType( Type );
if (psched == slIdleStand) if( psched == slIdleStand )
return slBaFaceTarget; // override this for different target face behavior return slBaFaceTarget; // override this for different target face behavior
else else
return psched; return psched;
case SCHED_TARGET_CHASE: case SCHED_TARGET_CHASE:
return slBaFollow; return slBaFollow;
case SCHED_IDLE_STAND: case SCHED_IDLE_STAND:
// call base class default so that scientist will talk // call base class default so that scientist will talk
// when standing during idle // when standing during idle
psched = CTalkMonster::GetScheduleOfType(Type); psched = CTalkMonster::GetScheduleOfType( Type );
if (psched == slIdleStand) if( psched == slIdleStand )
{ {
// just look straight ahead. // just look straight ahead.
return slIdleBaStand; return slIdleBaStand;
@ -682,18 +674,18 @@ Schedule_t* CBarney :: GetScheduleOfType ( int Type )
// monster's member function to get a pointer to a schedule // monster's member function to get a pointer to a schedule
// of the proper type. // of the proper type.
//========================================================= //=========================================================
Schedule_t *CBarney :: GetSchedule ( void ) Schedule_t *CBarney::GetSchedule( void )
{ {
if ( HasConditions( bits_COND_HEAR_SOUND ) ) if( HasConditions( bits_COND_HEAR_SOUND ) )
{ {
CSound *pSound; CSound *pSound;
pSound = PBestSound(); pSound = PBestSound();
ASSERT( pSound != NULL ); ASSERT( pSound != NULL );
if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) if( pSound && (pSound->m_iType & bits_SOUND_DANGER) )
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND );
} }
if ( HasConditions( bits_COND_ENEMY_DEAD ) && FOkToSpeak() ) if( HasConditions( bits_COND_ENEMY_DEAD ) && FOkToSpeak() )
{ {
PlaySentence( "BA_KILL", 4, VOL_NORM, ATTN_NORM ); PlaySentence( "BA_KILL", 4, VOL_NORM, ATTN_NORM );
} }
@ -702,37 +694,36 @@ Schedule_t *CBarney :: GetSchedule ( void )
{ {
case MONSTERSTATE_COMBAT: case MONSTERSTATE_COMBAT:
{ {
// dead enemy // dead enemy
if ( HasConditions( bits_COND_ENEMY_DEAD ) ) if( HasConditions( bits_COND_ENEMY_DEAD ) )
{ {
// call base class, all code to handle dead enemies is centralized there. // call base class, all code to handle dead enemies is centralized there.
return CBaseMonster :: GetSchedule(); return CBaseMonster::GetSchedule();
} }
// always act surprized with a new enemy // always act surprized with a new enemy
if ( HasConditions( bits_COND_NEW_ENEMY ) && HasConditions( bits_COND_LIGHT_DAMAGE) ) if( HasConditions( bits_COND_NEW_ENEMY ) && HasConditions( bits_COND_LIGHT_DAMAGE ) )
return GetScheduleOfType( SCHED_SMALL_FLINCH ); return GetScheduleOfType( SCHED_SMALL_FLINCH );
// wait for one schedule to draw gun // wait for one schedule to draw gun
if (!m_fGunDrawn ) if( !m_fGunDrawn )
return GetScheduleOfType( SCHED_ARM_WEAPON ); return GetScheduleOfType( SCHED_ARM_WEAPON );
if ( HasConditions( bits_COND_HEAVY_DAMAGE ) ) if( HasConditions( bits_COND_HEAVY_DAMAGE ) )
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY );
} }
break; break;
case MONSTERSTATE_ALERT: case MONSTERSTATE_ALERT:
case MONSTERSTATE_IDLE: case MONSTERSTATE_IDLE:
if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE)) if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
{ {
// flinch if hurt // flinch if hurt
return GetScheduleOfType( SCHED_SMALL_FLINCH ); return GetScheduleOfType( SCHED_SMALL_FLINCH );
} }
if ( m_hEnemy == NULL && IsFollowing() ) if( m_hEnemy == NULL && IsFollowing() )
{ {
if ( !m_hTargetEnt->IsAlive() ) if( !m_hTargetEnt->IsAlive() )
{ {
// UNDONE: Comment about the recently dead player here? // UNDONE: Comment about the recently dead player here?
StopFollowing( FALSE ); StopFollowing( FALSE );
@ -740,7 +731,7 @@ Schedule_t *CBarney :: GetSchedule ( void )
} }
else else
{ {
if ( HasConditions( bits_COND_CLIENT_PUSH ) ) if( HasConditions( bits_COND_CLIENT_PUSH ) )
{ {
return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW ); return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW );
} }
@ -748,7 +739,7 @@ Schedule_t *CBarney :: GetSchedule ( void )
} }
} }
if ( HasConditions( bits_COND_CLIENT_PUSH ) ) if( HasConditions( bits_COND_CLIENT_PUSH ) )
{ {
return GetScheduleOfType( SCHED_MOVE_AWAY ); return GetScheduleOfType( SCHED_MOVE_AWAY );
} }
@ -756,27 +747,23 @@ Schedule_t *CBarney :: GetSchedule ( void )
// try to say something about smells // try to say something about smells
TrySmellTalk(); TrySmellTalk();
break; break;
default:
break;
} }
return CTalkMonster::GetSchedule(); return CTalkMonster::GetSchedule();
} }
MONSTERSTATE CBarney :: GetIdealState ( void ) MONSTERSTATE CBarney::GetIdealState( void )
{ {
return CTalkMonster::GetIdealState(); return CTalkMonster::GetIdealState();
} }
void CBarney::DeclineFollowing( void ) void CBarney::DeclineFollowing( void )
{ {
PlaySentence( "BA_POK", 2, VOL_NORM, ATTN_NORM ); PlaySentence( "BA_POK", 2, VOL_NORM, ATTN_NORM );
} }
//========================================================= //=========================================================
// DEAD BARNEY PROP // DEAD BARNEY PROP
// //
@ -791,7 +778,7 @@ class CDeadBarney : public CBaseMonster
{ {
public: public:
void Spawn( void ); void Spawn( void );
int Classify ( void ) { return CLASS_PLAYER_ALLY; } int Classify( void ) { return CLASS_PLAYER_ALLY; }
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
@ -803,24 +790,24 @@ char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_s
void CDeadBarney::KeyValue( KeyValueData *pkvd ) void CDeadBarney::KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "pose")) if( FStrEq( pkvd->szKeyName, "pose" ) )
{ {
m_iPose = atoi(pkvd->szValue); m_iPose = atoi( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
CBaseMonster::KeyValue( pkvd ); CBaseMonster::KeyValue( pkvd );
} }
LINK_ENTITY_TO_CLASS( monster_barney_dead, CDeadBarney ); LINK_ENTITY_TO_CLASS( monster_barney_dead, CDeadBarney )
//========================================================= //=========================================================
// ********** DeadBarney SPAWN ********** // ********** DeadBarney SPAWN **********
//========================================================= //=========================================================
void CDeadBarney :: Spawn( ) void CDeadBarney::Spawn()
{ {
PRECACHE_MODEL("models/barney.mdl"); PRECACHE_MODEL( "models/barney.mdl" );
SET_MODEL(ENT(pev), "models/barney.mdl"); SET_MODEL( ENT( pev ), "models/barney.mdl" );
pev->effects = 0; pev->effects = 0;
pev->yaw_speed = 8; pev->yaw_speed = 8;
@ -828,14 +815,12 @@ void CDeadBarney :: Spawn( )
m_bloodColor = BLOOD_COLOR_RED; m_bloodColor = BLOOD_COLOR_RED;
pev->sequence = LookupSequence( m_szPoses[m_iPose] ); pev->sequence = LookupSequence( m_szPoses[m_iPose] );
if (pev->sequence == -1) if( pev->sequence == -1 )
{ {
ALERT ( at_console, "Dead barney with bad pose\n" ); ALERT( at_console, "Dead barney with bad pose\n" );
} }
// Corpses have less health // Corpses have less health
pev->health = 8;//gSkillData.barneyHealth; pev->health = 8;//gSkillData.barneyHealth;
MonsterInitDead(); MonsterInitDead();
} }

View File

@ -31,16 +31,14 @@ public:
SCRIPT_WAIT, // Waiting on everyone in the script to be ready SCRIPT_WAIT, // Waiting on everyone in the script to be ready
SCRIPT_CLEANUP, // Cancelling the script / cleaning up SCRIPT_CLEANUP, // Cancelling the script / cleaning up
SCRIPT_WALK_TO_MARK, SCRIPT_WALK_TO_MARK,
SCRIPT_RUN_TO_MARK, SCRIPT_RUN_TO_MARK
} SCRIPTSTATE; } SCRIPTSTATE;
// these fields have been added in the process of reworking the state machine. (sjb) // these fields have been added in the process of reworking the state machine. (sjb)
EHANDLE m_hEnemy; // the entity that the monster is fighting. EHANDLE m_hEnemy; // the entity that the monster is fighting.
EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach
EHANDLE m_hOldEnemy[ MAX_OLD_ENEMIES ]; EHANDLE m_hOldEnemy[MAX_OLD_ENEMIES];
Vector m_vecOldEnemy[ MAX_OLD_ENEMIES ]; Vector m_vecOldEnemy[MAX_OLD_ENEMIES];
float m_flFieldOfView;// width of monster's field of view ( dot product ) float m_flFieldOfView;// width of monster's field of view ( dot product )
float m_flWaitFinished;// if we're told to wait, this is the time that the wait will be over. float m_flWaitFinished;// if we're told to wait, this is the time that the wait will be over.
@ -58,7 +56,7 @@ public:
Schedule_t *m_pSchedule; Schedule_t *m_pSchedule;
int m_iScheduleIndex; int m_iScheduleIndex;
WayPoint_t m_Route[ ROUTE_SIZE ]; // Positions of movement WayPoint_t m_Route[ROUTE_SIZE]; // Positions of movement
int m_movementGoal; // Goal that defines route int m_movementGoal; // Goal that defines route
int m_iRouteIndex; // index into m_Route[] int m_iRouteIndex; // index into m_Route[]
float m_moveWaitTime; // How long I should wait for something to move float m_moveWaitTime; // How long I should wait for something to move
@ -104,54 +102,52 @@ public:
Vector m_HackedGunPos; // HACK until we can query end of gun Vector m_HackedGunPos; // HACK until we can query end of gun
// Scripted sequence Info // Scripted sequence Info
SCRIPTSTATE m_scriptState; // internal cinematic state SCRIPTSTATE m_scriptState; // internal cinematic state
CCineMonster *m_pCine; CCineMonster *m_pCine;
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
// monster use function // monster use function
void EXPORT MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT CorpseUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT CorpseUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
// overrideable Monster member functions // overrideable Monster member functions
virtual int BloodColor( void ) { return m_bloodColor; } virtual int BloodColor( void ) { return m_bloodColor; }
virtual CBaseMonster *MyMonsterPointer( void ) { return this; } virtual CBaseMonster *MyMonsterPointer( void ) { return this; }
virtual void Look ( int iDistance );// basic sight function for monsters virtual void Look( int iDistance );// basic sight function for monsters
virtual void RunAI ( void );// core ai function! virtual void RunAI( void );// core ai function!
void Listen ( void ); void Listen( void );
virtual BOOL IsAlive( void ) { return (pev->deadflag != DEAD_DEAD); } virtual BOOL IsAlive( void ) { return ( pev->deadflag != DEAD_DEAD ); }
virtual BOOL ShouldFadeOnDeath( void ); virtual BOOL ShouldFadeOnDeath( void );
// Basic Monster AI functions // Basic Monster AI functions
virtual float ChangeYaw ( int speed ); virtual float ChangeYaw( int speed );
float VecToYaw( Vector vecDir ); float VecToYaw( Vector vecDir );
float FlYawDiff ( void ); float FlYawDiff( void );
float DamageForce( float damage ); float DamageForce( float damage );
// stuff written for new state machine // stuff written for new state machine
virtual void MonsterThink( void ); virtual void MonsterThink( void );
void EXPORT CallMonsterThink( void ) { this->MonsterThink(); } void EXPORT CallMonsterThink( void ) { this->MonsterThink(); }
virtual int IRelationship ( CBaseEntity *pTarget ); virtual int IRelationship( CBaseEntity *pTarget );
virtual void MonsterInit ( void ); virtual void MonsterInit( void );
virtual void MonsterInitDead( void ); // Call after animation/pose is set up virtual void MonsterInitDead( void ); // Call after animation/pose is set up
virtual void BecomeDead( void ); virtual void BecomeDead( void );
void EXPORT CorpseFallThink( void ); void EXPORT CorpseFallThink( void );
void EXPORT MonsterInitThink ( void ); void EXPORT MonsterInitThink( void );
virtual void StartMonster ( void ); virtual void StartMonster( void );
virtual CBaseEntity* BestVisibleEnemy ( void );// finds best visible enemy for attack virtual CBaseEntity *BestVisibleEnemy( void );// finds best visible enemy for attack
virtual BOOL FInViewCone ( CBaseEntity *pEntity );// see if pEntity is in monster's view cone virtual BOOL FInViewCone( CBaseEntity *pEntity );// see if pEntity is in monster's view cone
virtual BOOL FInViewCone ( Vector *pOrigin );// see if given location is in monster's view cone virtual BOOL FInViewCone( Vector *pOrigin );// see if given location is in monster's view cone
virtual void HandleAnimEvent( MonsterEvent_t *pEvent ); virtual void HandleAnimEvent( MonsterEvent_t *pEvent );
virtual int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );// check validity of a straight move through space virtual int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );// check validity of a straight move through space
@ -172,19 +168,19 @@ public:
virtual BOOL CheckMeleeAttack2( float flDot, float flDist ); virtual BOOL CheckMeleeAttack2( float flDot, float flDist );
BOOL FHaveSchedule( void ); BOOL FHaveSchedule( void );
BOOL FScheduleValid ( void ); BOOL FScheduleValid( void );
void ClearSchedule( void ); void ClearSchedule( void );
BOOL FScheduleDone ( void ); BOOL FScheduleDone( void );
void ChangeSchedule ( Schedule_t *pNewSchedule ); void ChangeSchedule( Schedule_t *pNewSchedule );
void NextScheduledTask ( void ); void NextScheduledTask( void );
Schedule_t *ScheduleInList( const char *pName, Schedule_t **pList, int listCount ); Schedule_t *ScheduleInList( const char *pName, Schedule_t **pList, int listCount );
virtual Schedule_t *ScheduleFromName( const char *pName ); virtual Schedule_t *ScheduleFromName( const char *pName );
static Schedule_t *m_scheduleList[]; static Schedule_t *m_scheduleList[];
void MaintainSchedule ( void ); void MaintainSchedule( void );
virtual void StartTask ( Task_t *pTask ); virtual void StartTask( Task_t *pTask );
virtual void RunTask ( Task_t *pTask ); virtual void RunTask( Task_t *pTask );
virtual Schedule_t *GetScheduleOfType( int Type ); virtual Schedule_t *GetScheduleOfType( int Type );
virtual Schedule_t *GetSchedule( void ); virtual Schedule_t *GetSchedule( void );
virtual void ScheduleChange( void ) {} virtual void ScheduleChange( void ) {}
@ -196,49 +192,49 @@ public:
virtual void SentenceStop( void ); virtual void SentenceStop( void );
Task_t *GetTask ( void ); Task_t *GetTask( void );
virtual MONSTERSTATE GetIdealState ( void ); virtual MONSTERSTATE GetIdealState( void );
virtual void SetActivity ( Activity NewActivity ); virtual void SetActivity( Activity NewActivity );
void SetSequenceByName ( char *szSequence ); void SetSequenceByName( char *szSequence );
void SetState ( MONSTERSTATE State ); void SetState( MONSTERSTATE State );
virtual void ReportAIState( void ); virtual void ReportAIState( void );
void CheckAttacks ( CBaseEntity *pTarget, float flDist ); void CheckAttacks( CBaseEntity *pTarget, float flDist );
virtual int CheckEnemy ( CBaseEntity *pEnemy ); virtual int CheckEnemy( CBaseEntity *pEnemy );
void PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ); void PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos );
BOOL PopEnemy( void ); BOOL PopEnemy( void );
BOOL FGetNodeRoute ( Vector vecDest ); BOOL FGetNodeRoute( Vector vecDest );
inline void TaskComplete( void ) { if ( !HasConditions(bits_COND_TASK_FAILED) ) m_iTaskStatus = TASKSTATUS_COMPLETE; } inline void TaskComplete( void ) { if ( !HasConditions( bits_COND_TASK_FAILED ) ) m_iTaskStatus = TASKSTATUS_COMPLETE; }
void MovementComplete( void ); void MovementComplete( void );
inline void TaskFail( void ) { SetConditions(bits_COND_TASK_FAILED); } inline void TaskFail( void ) { SetConditions( bits_COND_TASK_FAILED ); }
inline void TaskBegin( void ) { m_iTaskStatus = TASKSTATUS_RUNNING; } inline void TaskBegin( void ) { m_iTaskStatus = TASKSTATUS_RUNNING; }
int TaskIsRunning( void ); int TaskIsRunning( void );
inline int TaskIsComplete( void ) { return (m_iTaskStatus == TASKSTATUS_COMPLETE); } inline int TaskIsComplete( void ) { return ( m_iTaskStatus == TASKSTATUS_COMPLETE ); }
inline int MovementIsComplete( void ) { return (m_movementGoal == MOVEGOAL_NONE); } inline int MovementIsComplete( void ) { return ( m_movementGoal == MOVEGOAL_NONE ); }
int IScheduleFlags ( void ); int IScheduleFlags( void );
BOOL FRefreshRoute( void ); BOOL FRefreshRoute( void );
BOOL FRouteClear ( void ); BOOL FRouteClear( void );
void RouteSimplify( CBaseEntity *pTargetEnt ); void RouteSimplify( CBaseEntity *pTargetEnt );
void AdvanceRoute ( float distance ); void AdvanceRoute( float distance );
virtual BOOL FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ); virtual BOOL FTriangulate( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex );
void MakeIdealYaw( Vector vecTarget ); void MakeIdealYaw( Vector vecTarget );
virtual void SetYawSpeed ( void ) { return; };// allows different yaw_speeds for each activity virtual void SetYawSpeed( void ) { return; };// allows different yaw_speeds for each activity
BOOL BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ); BOOL BuildRoute( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget );
virtual BOOL BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ); virtual BOOL BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist );
int RouteClassify( int iMoveFlag ); int RouteClassify( int iMoveFlag );
void InsertWaypoint ( Vector vecLocation, int afMoveFlags ); void InsertWaypoint( Vector vecLocation, int afMoveFlags );
BOOL FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ); BOOL FindLateralCover( const Vector &vecThreat, const Vector &vecViewOffset );
virtual BOOL FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ); virtual BOOL FindCover( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist );
virtual BOOL FValidateCover ( const Vector &vecCoverLocation ) { return TRUE; }; virtual BOOL FValidateCover( const Vector &vecCoverLocation ) { return TRUE; };
virtual float CoverRadius( void ) { return 784; } // Default cover radius virtual float CoverRadius( void ) { return 784; } // Default cover radius
virtual BOOL FCanCheckAttacks ( void ); virtual BOOL FCanCheckAttacks( void );
virtual void CheckAmmo( void ) { return; }; virtual void CheckAmmo( void ) { return; };
virtual int IgnoreConditions ( void ); virtual int IgnoreConditions( void );
inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; } inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; }
inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; } inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; }
@ -246,10 +242,10 @@ public:
inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; } inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; }
virtual BOOL FValidateHintType( short sHint ); virtual BOOL FValidateHintType( short sHint );
int FindHintNode ( void ); int FindHintNode( void );
virtual BOOL FCanActiveIdle ( void ); virtual BOOL FCanActiveIdle( void );
void SetTurnActivity ( void ); void SetTurnActivity( void );
float FLSoundVolume ( CSound *pSound ); float FLSoundVolume( CSound *pSound );
BOOL MoveToNode( Activity movementAct, float waitTime, const Vector &goal ); BOOL MoveToNode( Activity movementAct, float waitTime, const Vector &goal );
BOOL MoveToTarget( Activity movementAct, float waitTime ); BOOL MoveToTarget( Activity movementAct, float waitTime );
@ -260,18 +256,18 @@ public:
float OpenDoorAndWait( entvars_t *pevDoor ); float OpenDoorAndWait( entvars_t *pevDoor );
virtual int ISoundMask( void ); virtual int ISoundMask( void );
virtual CSound* PBestSound ( void ); virtual CSound* PBestSound( void );
virtual CSound* PBestScent ( void ); virtual CSound* PBestScent( void );
virtual float HearingSensitivity( void ) { return 1.0; }; virtual float HearingSensitivity( void ) { return 1.0; };
BOOL FBecomeProne ( void ); BOOL FBecomeProne( void );
virtual void BarnacleVictimBitten( entvars_t *pevBarnacle ); virtual void BarnacleVictimBitten( entvars_t *pevBarnacle );
virtual void BarnacleVictimReleased( void ); virtual void BarnacleVictimReleased( void );
void SetEyePosition ( void ); void SetEyePosition( void );
BOOL FShouldEat( void );// see if a monster is 'hungry' BOOL FShouldEat( void );// see if a monster is 'hungry'
void Eat ( float flFullDuration );// make the monster 'full' for a while. void Eat( float flFullDuration );// make the monster 'full' for a while.
CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ); CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType );
BOOL FacingIdeal( void ); BOOL FacingIdeal( void );
@ -284,13 +280,13 @@ public:
// PrescheduleThink // PrescheduleThink
virtual void PrescheduleThink( void ) { return; }; virtual void PrescheduleThink( void ) { return; };
BOOL GetEnemy ( void ); BOOL GetEnemy( void );
void MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ); void MakeDamageBloodDecal( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir );
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
// combat functions // combat functions
float UpdateTarget ( entvars_t *pevTarget ); float UpdateTarget( entvars_t *pevTarget );
virtual Activity GetDeathActivity ( void ); virtual Activity GetDeathActivity( void );
Activity GetSmallFlinchActivity( void ); Activity GetSmallFlinchActivity( void );
virtual void Killed( entvars_t *pevAttacker, int iGib ); virtual void Killed( entvars_t *pevAttacker, int iGib );
virtual void GibMonster( void ); virtual void GibMonster( void );
@ -301,25 +297,25 @@ public:
virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled
Vector ShootAtEnemy( const Vector &shootOrigin ); Vector ShootAtEnemy( const Vector &shootOrigin );
virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ) * 0.75 + EyePosition() * 0.25; }; // position to shoot at virtual Vector BodyTarget( const Vector &posSrc ) { return Center() * 0.75 + EyePosition() * 0.25; }; // position to shoot at
virtual Vector GetGunPosition( void ); virtual Vector GetGunPosition( void );
virtual int TakeHealth( float flHealth, int bitsDamageType ); virtual int TakeHealth( float flHealth, int bitsDamageType );
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
void RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); void RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType );
void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType );
virtual int IsMoving( void ) { return m_movementGoal != MOVEGOAL_NONE; } virtual int IsMoving( void ) { return m_movementGoal != MOVEGOAL_NONE; }
void RouteClear( void ); void RouteClear( void );
void RouteNew( void ); void RouteNew( void );
virtual void DeathSound ( void ) { return; }; virtual void DeathSound( void ) { return; };
virtual void AlertSound ( void ) { return; }; virtual void AlertSound( void ) { return; };
virtual void IdleSound ( void ) { return; }; virtual void IdleSound( void ) { return; };
virtual void PainSound ( void ) { return; }; virtual void PainSound( void ) { return; };
virtual void StopFollowing( BOOL clearSchedule ) {} virtual void StopFollowing( BOOL clearSchedule ) {}
@ -328,12 +324,9 @@ public:
inline BOOL HasMemory( int iMemory ) { if ( m_afMemory & iMemory ) return TRUE; return FALSE; } inline BOOL HasMemory( int iMemory ) { if ( m_afMemory & iMemory ) return TRUE; return FALSE; }
inline BOOL HasAllMemories( int iMemory ) { if ( (m_afMemory & iMemory) == iMemory ) return TRUE; return FALSE; } inline BOOL HasAllMemories( int iMemory ) { if ( (m_afMemory & iMemory) == iMemory ) return TRUE; return FALSE; }
BOOL ExitScriptedSequence( ); BOOL ExitScriptedSequence();
BOOL CineCleanup( ); BOOL CineCleanup();
CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item.
}; };
#endif // BASEMONSTER_H #endif // BASEMONSTER_H

File diff suppressed because it is too large Load Diff

View File

@ -22,20 +22,18 @@
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
//========================================================= //=========================================================
// Monster's Anim Events Go Here // Monster's Anim Events Go Here
//========================================================= //=========================================================
#define BLOATER_AE_ATTACK_MELEE1 0x01 #define BLOATER_AE_ATTACK_MELEE1 0x01
class CBloater : public CBaseMonster class CBloater : public CBaseMonster
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void SetYawSpeed( void ); void SetYawSpeed( void );
int Classify ( void ); int Classify( void );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );
void PainSound( void ); void PainSound( void );
@ -44,18 +42,18 @@ public:
void AttackSnd( void ); void AttackSnd( void );
// No range attacks // No range attacks
BOOL CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; } BOOL CheckRangeAttack1( float flDot, float flDist ) { return FALSE; }
BOOL CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; } BOOL CheckRangeAttack2( float flDot, float flDist ) { return FALSE; }
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
}; };
LINK_ENTITY_TO_CLASS( monster_bloater, CBloater ); LINK_ENTITY_TO_CLASS( monster_bloater, CBloater )
//========================================================= //=========================================================
// Classify - indicates this monster's place in the // Classify - indicates this monster's place in the
// relationship table. // relationship table.
//========================================================= //=========================================================
int CBloater :: Classify ( void ) int CBloater::Classify( void )
{ {
return CLASS_ALIEN_MONSTER; return CLASS_ALIEN_MONSTER;
} }
@ -64,39 +62,37 @@ int CBloater :: Classify ( void )
// SetYawSpeed - allows each sequence to have a different // SetYawSpeed - allows each sequence to have a different
// turn rate associated with it. // turn rate associated with it.
//========================================================= //=========================================================
void CBloater :: SetYawSpeed ( void ) void CBloater::SetYawSpeed( void )
{ {
int ys; int ys;
ys = 120; ys = 120;
#if 0 #if 0
switch ( m_Activity ) switch( m_Activity )
{ {
} }
#endif #endif
pev->yaw_speed = ys; pev->yaw_speed = ys;
} }
int CBloater :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) int CBloater::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
PainSound(); PainSound();
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
} }
void CBloater :: PainSound( void ) void CBloater::PainSound( void )
{ {
#if 0 #if 0
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG( 0, 9 );
switch (RANDOM_LONG(0,5)) switch( RANDOM_LONG( 0, 5 ) )
{ {
case 0: case 0:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_pain1.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_pain1.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
case 1: case 1:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_pain2.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_pain2.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
default: default:
break; break;
@ -104,69 +100,68 @@ void CBloater :: PainSound( void )
#endif #endif
} }
void CBloater :: AlertSound( void ) void CBloater::AlertSound( void )
{ {
#if 0 #if 0
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG( 0, 9 );
switch (RANDOM_LONG(0,2)) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: case 0:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_alert10.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_alert10.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
case 1: case 1:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_alert20.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_alert20.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
case 2: case 2:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_alert30.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_alert30.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
} }
#endif #endif
} }
void CBloater :: IdleSound( void ) void CBloater::IdleSound( void )
{ {
#if 0 #if 0
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG( 0, 9 );
switch (RANDOM_LONG(0,2)) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: case 0:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_idle1.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_idle1.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
case 1: case 1:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_idle2.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_idle2.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
case 2: case 2:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_idle3.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_idle3.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
} }
#endif #endif
} }
void CBloater :: AttackSnd( void ) void CBloater::AttackSnd( void )
{ {
#if 0 #if 0
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG( 0, 9 );
switch (RANDOM_LONG(0,1)) switch( RANDOM_LONG( 0, 1 ) )
{ {
case 0: case 0:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_attack1.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_attack1.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
case 1: case 1:
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_attack2.wav", 1.0, ATTN_NORM, 0, pitch); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_attack2.wav", 1.0, ATTN_NORM, 0, pitch );
break; break;
} }
#endif #endif
} }
//========================================================= //=========================================================
// HandleAnimEvent - catches the monster-specific messages // HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played. // that occur when tagged animation frames are played.
//========================================================= //=========================================================
void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CBloater::HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
switch( pEvent->event ) switch( pEvent->event )
{ {
@ -176,7 +171,6 @@ void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent )
AttackSnd(); AttackSnd();
} }
break; break;
default: default:
CBaseMonster::HandleAnimEvent( pEvent ); CBaseMonster::HandleAnimEvent( pEvent );
break; break;
@ -186,11 +180,11 @@ void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent )
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CBloater :: Spawn() void CBloater::Spawn()
{ {
Precache( ); Precache();
SET_MODEL(ENT(pev), "models/floater.mdl"); SET_MODEL( ENT( pev ), "models/floater.mdl" );
UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
@ -208,12 +202,11 @@ void CBloater :: Spawn()
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CBloater :: Precache() void CBloater::Precache()
{ {
PRECACHE_MODEL("models/floater.mdl"); PRECACHE_MODEL( "models/floater.mdl" );
} }
//========================================================= //=========================================================
// AI Schedules Specific to this monster // AI Schedules Specific to this monster
//========================================================= //=========================================================

View File

@ -60,27 +60,25 @@ public:
virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
}; };
LINK_ENTITY_TO_CLASS( func_wall, CFuncWall ); LINK_ENTITY_TO_CLASS( func_wall, CFuncWall )
void CFuncWall :: Spawn( void ) void CFuncWall::Spawn( void )
{ {
pev->angles = g_vecZero; pev->angles = g_vecZero;
pev->movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything pev->movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything
pev->solid = SOLID_BSP; pev->solid = SOLID_BSP;
SET_MODEL( ENT(pev), STRING(pev->model) ); SET_MODEL( ENT( pev ), STRING( pev->model ) );
// If it can't move/go away, it's really part of the world // If it can't move/go away, it's really part of the world
pev->flags |= FL_WORLDBRUSH; pev->flags |= FL_WORLDBRUSH;
} }
void CFuncWall::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
void CFuncWall :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
if ( ShouldToggle( useType, (int)(pev->frame)) ) if( ShouldToggle( useType, (int)( pev->frame ) ) )
pev->frame = 1 - pev->frame; pev->frame = 1 - pev->frame;
} }
#define SF_WALL_START_OFF 0x0001 #define SF_WALL_START_OFF 0x0001
class CFuncWallToggle : public CFuncWall class CFuncWallToggle : public CFuncWall
@ -93,54 +91,49 @@ public:
BOOL IsOn( void ); BOOL IsOn( void );
}; };
LINK_ENTITY_TO_CLASS( func_wall_toggle, CFuncWallToggle ); LINK_ENTITY_TO_CLASS( func_wall_toggle, CFuncWallToggle )
void CFuncWallToggle :: Spawn( void ) void CFuncWallToggle::Spawn( void )
{ {
CFuncWall::Spawn(); CFuncWall::Spawn();
if ( pev->spawnflags & SF_WALL_START_OFF ) if( pev->spawnflags & SF_WALL_START_OFF )
TurnOff(); TurnOff();
} }
void CFuncWallToggle::TurnOff( void )
void CFuncWallToggle :: TurnOff( void )
{ {
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->effects |= EF_NODRAW; pev->effects |= EF_NODRAW;
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
void CFuncWallToggle::TurnOn( void )
void CFuncWallToggle :: TurnOn( void )
{ {
pev->solid = SOLID_BSP; pev->solid = SOLID_BSP;
pev->effects &= ~EF_NODRAW; pev->effects &= ~EF_NODRAW;
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
BOOL CFuncWallToggle::IsOn( void )
BOOL CFuncWallToggle :: IsOn( void )
{ {
if ( pev->solid == SOLID_NOT ) if( pev->solid == SOLID_NOT )
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
void CFuncWallToggle::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
void CFuncWallToggle :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
int status = IsOn(); int status = IsOn();
if ( ShouldToggle( useType, status ) ) if( ShouldToggle( useType, status ) )
{ {
if ( status ) if( status )
TurnOff(); TurnOff();
else else
TurnOn(); TurnOn();
} }
} }
#define SF_CONVEYOR_VISUAL 0x0001 #define SF_CONVEYOR_VISUAL 0x0001
#define SF_CONVEYOR_NOTSOLID 0x0002 #define SF_CONVEYOR_NOTSOLID 0x0002
@ -152,53 +145,50 @@ public:
void UpdateSpeed( float speed ); void UpdateSpeed( float speed );
}; };
LINK_ENTITY_TO_CLASS( func_conveyor, CFuncConveyor ); LINK_ENTITY_TO_CLASS( func_conveyor, CFuncConveyor )
void CFuncConveyor :: Spawn( void )
void CFuncConveyor::Spawn( void )
{ {
SetMovedir( pev ); SetMovedir( pev );
CFuncWall::Spawn(); CFuncWall::Spawn();
if ( !(pev->spawnflags & SF_CONVEYOR_VISUAL) ) if( !( pev->spawnflags & SF_CONVEYOR_VISUAL ) )
SetBits( pev->flags, FL_CONVEYOR ); SetBits( pev->flags, FL_CONVEYOR );
// HACKHACK - This is to allow for some special effects // HACKHACK - This is to allow for some special effects
if ( pev->spawnflags & SF_CONVEYOR_NOTSOLID ) if( pev->spawnflags & SF_CONVEYOR_NOTSOLID )
{ {
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->skin = 0; // Don't want the engine thinking we've got special contents on this brush pev->skin = 0; // Don't want the engine thinking we've got special contents on this brush
} }
if ( pev->speed == 0 ) if( pev->speed == 0 )
pev->speed = 100; pev->speed = 100;
UpdateSpeed( pev->speed ); UpdateSpeed( pev->speed );
} }
// HACKHACK -- This is ugly, but encode the speed in the rendercolor to avoid adding more data to the network stream // HACKHACK -- This is ugly, but encode the speed in the rendercolor to avoid adding more data to the network stream
void CFuncConveyor :: UpdateSpeed( float speed ) void CFuncConveyor::UpdateSpeed( float speed )
{ {
// Encode it as an integer with 4 fractional bits // Encode it as an integer with 4 fractional bits
int speedCode = (int)(fabs(speed) * 16.0); int speedCode = (int)( fabs( speed ) * 16.0 );
if ( speed < 0 ) if( speed < 0 )
pev->rendercolor.x = 1; pev->rendercolor.x = 1;
else else
pev->rendercolor.x = 0; pev->rendercolor.x = 0;
pev->rendercolor.y = (speedCode >> 8); pev->rendercolor.y = speedCode >> 8;
pev->rendercolor.z = (speedCode & 0xFF); pev->rendercolor.z = speedCode & 0xFF;
} }
void CFuncConveyor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
void CFuncConveyor :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
pev->speed = -pev->speed; pev->speed = -pev->speed;
UpdateSpeed( pev->speed ); UpdateSpeed( pev->speed );
} }
// =================== FUNC_ILLUSIONARY ============================================== // =================== FUNC_ILLUSIONARY ==============================================
@ -214,25 +204,25 @@ public:
virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
}; };
LINK_ENTITY_TO_CLASS( func_illusionary, CFuncIllusionary ); LINK_ENTITY_TO_CLASS( func_illusionary, CFuncIllusionary )
void CFuncIllusionary :: KeyValue( KeyValueData *pkvd ) void CFuncIllusionary::KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "skin"))//skin is used for content type if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type
{ {
pev->skin = atof(pkvd->szValue); pev->skin = atof( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
CBaseToggle::KeyValue( pkvd ); CBaseToggle::KeyValue( pkvd );
} }
void CFuncIllusionary :: Spawn( void ) void CFuncIllusionary::Spawn( void )
{ {
pev->angles = g_vecZero; pev->angles = g_vecZero;
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
pev->solid = SOLID_NOT;// always solid_not pev->solid = SOLID_NOT;// always solid_not
SET_MODEL( ENT(pev), STRING(pev->model) ); SET_MODEL( ENT( pev ), STRING( pev->model ) );
// I'd rather eat the network bandwidth of this than figure out how to save/restore // I'd rather eat the network bandwidth of this than figure out how to save/restore
// these entities after they have been moved to the client, or respawn them ala Quake // these entities after they have been moved to the client, or respawn them ala Quake
@ -240,7 +230,6 @@ void CFuncIllusionary :: Spawn( void )
// MAKE_STATIC(ENT(pev)); // MAKE_STATIC(ENT(pev));
} }
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
// //
// Monster only clip brush // Monster only clip brush
@ -259,17 +248,16 @@ public:
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {} // Clear out func_wall's use function void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {} // Clear out func_wall's use function
}; };
LINK_ENTITY_TO_CLASS( func_monsterclip, CFuncMonsterClip ); LINK_ENTITY_TO_CLASS( func_monsterclip, CFuncMonsterClip )
void CFuncMonsterClip::Spawn( void ) void CFuncMonsterClip::Spawn( void )
{ {
CFuncWall::Spawn(); CFuncWall::Spawn();
if ( CVAR_GET_FLOAT("showtriggers") == 0 ) if( CVAR_GET_FLOAT( "showtriggers" ) == 0 )
pev->effects = EF_NODRAW; pev->effects = EF_NODRAW;
pev->flags |= FL_MONSTERCLIP; pev->flags |= FL_MONSTERCLIP;
} }
// =================== FUNC_ROTATING ============================================== // =================== FUNC_ROTATING ==============================================
class CFuncRotating : public CBaseEntity class CFuncRotating : public CBaseEntity
{ {
@ -277,13 +265,13 @@ public:
// basic functions // basic functions
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void EXPORT SpinUp ( void ); void EXPORT SpinUp( void );
void EXPORT SpinDown ( void ); void EXPORT SpinDown( void );
void KeyValue( KeyValueData* pkvd); void KeyValue( KeyValueData* pkvd);
void EXPORT HurtTouch ( CBaseEntity *pOther ); void EXPORT HurtTouch( CBaseEntity *pOther );
void EXPORT RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT Rotate( void ); void EXPORT Rotate( void );
void RampPitchVol (int fUp ); void RampPitchVol(int fUp );
void Blocked( CBaseEntity *pOther ); void Blocked( CBaseEntity *pOther );
virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
virtual int Save( CSave &save ); virtual int Save( CSave &save );
@ -307,38 +295,37 @@ TYPEDESCRIPTION CFuncRotating::m_SaveData[] =
DEFINE_FIELD( CFuncRotating, m_sounds, FIELD_INTEGER ) DEFINE_FIELD( CFuncRotating, m_sounds, FIELD_INTEGER )
}; };
IMPLEMENT_SAVERESTORE( CFuncRotating, CBaseEntity ); IMPLEMENT_SAVERESTORE( CFuncRotating, CBaseEntity )
LINK_ENTITY_TO_CLASS( func_rotating, CFuncRotating )
LINK_ENTITY_TO_CLASS( func_rotating, CFuncRotating ); void CFuncRotating::KeyValue( KeyValueData* pkvd )
void CFuncRotating :: KeyValue( KeyValueData* pkvd)
{ {
if (FStrEq(pkvd->szKeyName, "fanfriction")) if( FStrEq( pkvd->szKeyName, "fanfriction" ) )
{ {
m_flFanFriction = atof(pkvd->szValue)/100; m_flFanFriction = atof( pkvd->szValue ) / 100;
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "Volume")) else if( FStrEq( pkvd->szKeyName, "Volume" ) )
{ {
m_flVolume = atof(pkvd->szValue)/10.0; m_flVolume = atof( pkvd->szValue ) / 10.0;
if (m_flVolume > 1.0) if( m_flVolume > 1.0 )
m_flVolume = 1.0; m_flVolume = 1.0;
if (m_flVolume < 0.0) if( m_flVolume < 0.0 )
m_flVolume = 0.0; m_flVolume = 0.0;
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "spawnorigin")) else if( FStrEq( pkvd->szKeyName, "spawnorigin" ) )
{ {
Vector tmp; Vector tmp;
UTIL_StringToVector( (float *)tmp, pkvd->szValue ); UTIL_StringToVector( (float *)tmp, pkvd->szValue );
if ( tmp != g_vecZero ) if( tmp != g_vecZero )
pev->origin = tmp; pev->origin = tmp;
} }
else if (FStrEq(pkvd->szKeyName, "sounds")) else if( FStrEq( pkvd->szKeyName, "sounds" ) )
{ {
m_sounds = atoi(pkvd->szValue); m_sounds = atoi( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
@ -358,53 +345,51 @@ check either the X_AXIS or Y_AXIS box to change that.
REVERSE will cause the it to rotate in the opposite direction. REVERSE will cause the it to rotate in the opposite direction.
*/ */
void CFuncRotating::Spawn()
void CFuncRotating :: Spawn( )
{ {
// set final pitch. Must not be PITCH_NORM, since we // set final pitch. Must not be PITCH_NORM, since we
// plan on pitch shifting later. // plan on pitch shifting later.
m_pitch = PITCH_NORM - 1; m_pitch = PITCH_NORM - 1;
// maintain compatibility with previous maps // maintain compatibility with previous maps
if (m_flVolume == 0.0) if( m_flVolume == 0.0 )
m_flVolume = 1.0; m_flVolume = 1.0;
// if the designer didn't set a sound attenuation, default to one. // if the designer didn't set a sound attenuation, default to one.
m_flAttenuation = ATTN_NORM; m_flAttenuation = ATTN_NORM;
if ( FBitSet ( pev->spawnflags, SF_BRUSH_ROTATE_SMALLRADIUS) ) if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_SMALLRADIUS) )
{ {
m_flAttenuation = ATTN_IDLE; m_flAttenuation = ATTN_IDLE;
} }
else if ( FBitSet ( pev->spawnflags, SF_BRUSH_ROTATE_MEDIUMRADIUS) ) else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_MEDIUMRADIUS ) )
{ {
m_flAttenuation = ATTN_STATIC; m_flAttenuation = ATTN_STATIC;
} }
else if ( FBitSet ( pev->spawnflags, SF_BRUSH_ROTATE_LARGERADIUS) ) else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_LARGERADIUS ) )
{ {
m_flAttenuation = ATTN_NORM; m_flAttenuation = ATTN_NORM;
} }
// prevent divide by zero if level designer forgets friction! // prevent divide by zero if level designer forgets friction!
if ( m_flFanFriction == 0 ) if( m_flFanFriction == 0 )
{ {
m_flFanFriction = 1; m_flFanFriction = 1;
} }
if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS) ) if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS ) )
pev->movedir = Vector(0,0,1); pev->movedir = Vector( 0, 0, 1 );
else if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS) ) else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS ) )
pev->movedir = Vector(1,0,0); pev->movedir = Vector( 1, 0, 0 );
else else
pev->movedir = Vector(0,1,0); // y-axis pev->movedir = Vector( 0, 1, 0 ); // y-axis
// check for reverse rotation // check for reverse rotation
if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_BACKWARDS) ) if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_BACKWARDS ) )
pev->movedir = pev->movedir * -1; pev->movedir = pev->movedir * -1;
// some rotating objects like fake volumetric lights will not be solid. // some rotating objects like fake volumetric lights will not be solid.
if ( FBitSet(pev->spawnflags, SF_ROTATING_NOT_SOLID) ) if( FBitSet( pev->spawnflags, SF_ROTATING_NOT_SOLID ) )
{ {
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->skin = CONTENTS_EMPTY; pev->skin = CONTENTS_EMPTY;
@ -416,90 +401,88 @@ void CFuncRotating :: Spawn( )
pev->movetype = MOVETYPE_PUSH; pev->movetype = MOVETYPE_PUSH;
} }
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin( pev, pev->origin );
SET_MODEL( ENT(pev), STRING(pev->model) ); SET_MODEL( ENT(pev), STRING(pev->model) );
SetUse( &CFuncRotating::RotatingUse ); SetUse( &CFuncRotating::RotatingUse );
// did level designer forget to assign speed? // did level designer forget to assign speed?
if (pev->speed <= 0) if( pev->speed <= 0 )
pev->speed = 0; pev->speed = 0;
// Removed this per level designers request. -- JAY // Removed this per level designers request. -- JAY
// if (pev->dmg == 0) // if( pev->dmg == 0 )
// pev->dmg = 2; // pev->dmg = 2;
// instant-use brush? // instant-use brush?
if ( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT) ) if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT ) )
{ {
SetThink( &CBaseEntity::SUB_CallUseToggle ); SetThink( &CBaseEntity::SUB_CallUseToggle );
pev->nextthink = pev->ltime + 1.5; // leave a magic delay for client to start up pev->nextthink = pev->ltime + 1.5; // leave a magic delay for client to start up
} }
// can this brush inflict pain? // can this brush inflict pain?
if ( FBitSet (pev->spawnflags, SF_BRUSH_HURT) ) if( FBitSet( pev->spawnflags, SF_BRUSH_HURT ) )
{ {
SetTouch( &CFuncRotating::HurtTouch ); SetTouch( &CFuncRotating::HurtTouch );
} }
Precache( ); Precache();
} }
void CFuncRotating::Precache( void )
void CFuncRotating :: Precache( void )
{ {
char* szSoundFile = (char*) STRING(pev->message); char* szSoundFile = (char*)STRING( pev->message );
// set up fan sounds // set up fan sounds
if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 )
if (!FStringNull( pev->message ) && strlen( szSoundFile ) > 0)
{ {
// if a path is set for a wave, use it // if a path is set for a wave, use it
PRECACHE_SOUND( szSoundFile );
PRECACHE_SOUND(szSoundFile); pev->noiseRunning = ALLOC_STRING( szSoundFile );
}
pev->noiseRunning = ALLOC_STRING(szSoundFile); else
} else
{ {
// otherwise use preset sound // otherwise use preset sound
switch (m_sounds) switch( m_sounds )
{ {
case 1: case 1:
PRECACHE_SOUND ("fans/fan1.wav"); PRECACHE_SOUND( "fans/fan1.wav" );
pev->noiseRunning = ALLOC_STRING("fans/fan1.wav"); pev->noiseRunning = ALLOC_STRING( "fans/fan1.wav" );
break; break;
case 2: case 2:
PRECACHE_SOUND ("fans/fan2.wav"); PRECACHE_SOUND( "fans/fan2.wav" );
pev->noiseRunning = ALLOC_STRING("fans/fan2.wav"); pev->noiseRunning = ALLOC_STRING( "fans/fan2.wav" );
break; break;
case 3: case 3:
PRECACHE_SOUND ("fans/fan3.wav"); PRECACHE_SOUND( "fans/fan3.wav" );
pev->noiseRunning = ALLOC_STRING("fans/fan3.wav"); pev->noiseRunning = ALLOC_STRING( "fans/fan3.wav" );
break; break;
case 4: case 4:
PRECACHE_SOUND ("fans/fan4.wav"); PRECACHE_SOUND( "fans/fan4.wav" );
pev->noiseRunning = ALLOC_STRING("fans/fan4.wav"); pev->noiseRunning = ALLOC_STRING( "fans/fan4.wav" );
break; break;
case 5: case 5:
PRECACHE_SOUND ("fans/fan5.wav"); PRECACHE_SOUND( "fans/fan5.wav" );
pev->noiseRunning = ALLOC_STRING("fans/fan5.wav"); pev->noiseRunning = ALLOC_STRING( "fans/fan5.wav" );
break; break;
case 0: case 0:
default: default:
if (!FStringNull( pev->message ) && strlen( szSoundFile ) > 0) if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 )
{ {
PRECACHE_SOUND(szSoundFile); PRECACHE_SOUND( szSoundFile );
pev->noiseRunning = ALLOC_STRING(szSoundFile); pev->noiseRunning = ALLOC_STRING( szSoundFile );
break; break;
} else }
else
{ {
pev->noiseRunning = ALLOC_STRING("common/null.wav"); pev->noiseRunning = ALLOC_STRING( "common/null.wav" );
break; break;
} }
} }
} }
if (pev->avelocity != g_vecZero ) if( pev->avelocity != g_vecZero )
{ {
// if fan was spinning, and we went through transition or save/restore, // if fan was spinning, and we went through transition or save/restore,
// make sure we restart the sound. 1.5 sec delay is magic number. KDB // make sure we restart the sound. 1.5 sec delay is magic number. KDB
@ -509,25 +492,23 @@ void CFuncRotating :: Precache( void )
} }
} }
// //
// Touch - will hurt others based on how fast the brush is spinning // Touch - will hurt others based on how fast the brush is spinning
// //
void CFuncRotating :: HurtTouch ( CBaseEntity *pOther ) void CFuncRotating::HurtTouch( CBaseEntity *pOther )
{ {
entvars_t *pevOther = pOther->pev; entvars_t *pevOther = pOther->pev;
// we can't hurt this thing, so we're not concerned with it // we can't hurt this thing, so we're not concerned with it
if ( !pevOther->takedamage ) if( !pevOther->takedamage )
return; return;
// calculate damage based on rotation speed // calculate damage based on rotation speed
pev->dmg = pev->avelocity.Length() / 10; pev->dmg = pev->avelocity.Length() / 10;
pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH); pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH );
pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev) ).Normalize() * pev->dmg; pevOther->velocity = ( pevOther->origin - VecBModelOrigin( pev ) ).Normalize() * pev->dmg;
} }
// //
@ -537,9 +518,8 @@ void CFuncRotating :: HurtTouch ( CBaseEntity *pOther )
#define FANPITCHMIN 30 #define FANPITCHMIN 30
#define FANPITCHMAX 100 #define FANPITCHMAX 100
void CFuncRotating :: RampPitchVol (int fUp) void CFuncRotating::RampPitchVol( int fUp )
{ {
Vector vecAVel = pev->avelocity; Vector vecAVel = pev->avelocity;
vec_t vecCur; vec_t vecCur;
vec_t vecFinal; vec_t vecFinal;
@ -549,40 +529,35 @@ void CFuncRotating :: RampPitchVol (int fUp)
int pitch; int pitch;
// get current angular velocity // get current angular velocity
vecCur = fabs( vecAVel.x != 0 ? vecAVel.x : ( vecAVel.y != 0 ? vecAVel.y : vecAVel.z ) );
vecCur = fabs(vecAVel.x != 0 ? vecAVel.x : (vecAVel.y != 0 ? vecAVel.y : vecAVel.z));
// get target angular velocity // get target angular velocity
vecFinal = ( pev->movedir.x != 0 ? pev->movedir.x : ( pev->movedir.y != 0 ? pev->movedir.y : pev->movedir.z ) );
vecFinal = (pev->movedir.x != 0 ? pev->movedir.x : (pev->movedir.y != 0 ? pev->movedir.y : pev->movedir.z));
vecFinal *= pev->speed; vecFinal *= pev->speed;
vecFinal = fabs(vecFinal); vecFinal = fabs( vecFinal );
// calc volume and pitch as % of final vol and pitch // calc volume and pitch as % of final vol and pitch
fpct = vecCur / vecFinal; fpct = vecCur / vecFinal;
// if (fUp) //if (fUp)
// fvol = m_flVolume * (0.5 + fpct/2.0); // spinup volume ramps up from 50% max vol // fvol = m_flVolume * (0.5 + fpct/2.0); // spinup volume ramps up from 50% max vol
// else //else
fvol = m_flVolume * fpct; // slowdown volume ramps down to 0 fvol = m_flVolume * fpct; // slowdown volume ramps down to 0
fpitch = FANPITCHMIN + (FANPITCHMAX - FANPITCHMIN) * fpct; fpitch = FANPITCHMIN + ( FANPITCHMAX - FANPITCHMIN ) * fpct;
pitch = (int) fpitch; pitch = (int)fpitch;
if (pitch == PITCH_NORM) if( pitch == PITCH_NORM )
pitch = PITCH_NORM-1; pitch = PITCH_NORM - 1;
// change the fan's vol and pitch // change the fan's vol and pitch
EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ),
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch );
fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch);
} }
// //
// SpinUp - accelerates a non-moving func_rotating up to it's speed // SpinUp - accelerates a non-moving func_rotating up to it's speed
// //
void CFuncRotating :: SpinUp( void ) void CFuncRotating::SpinUp( void )
{ {
Vector vecAVel;//rotational velocity Vector vecAVel;//rotational velocity
@ -592,27 +567,27 @@ void CFuncRotating :: SpinUp( void )
vecAVel = pev->avelocity;// cache entity's rotational velocity vecAVel = pev->avelocity;// cache entity's rotational velocity
// if we've met or exceeded target speed, set target speed and stop thinking // if we've met or exceeded target speed, set target speed and stop thinking
if ( fabs(vecAVel.x) >= fabs(pev->movedir.x * pev->speed) && if( fabs( vecAVel.x ) >= fabs( pev->movedir.x * pev->speed ) &&
fabs(vecAVel.y) >= fabs(pev->movedir.y * pev->speed) && fabs( vecAVel.y ) >= fabs( pev->movedir.y * pev->speed ) &&
fabs(vecAVel.z) >= fabs(pev->movedir.z * pev->speed) ) fabs( vecAVel.z ) >= fabs( pev->movedir.z * pev->speed ) )
{ {
pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ),
m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX); m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX );
SetThink( &CFuncRotating::Rotate ); SetThink( &CFuncRotating::Rotate );
Rotate(); Rotate();
} }
else else
{ {
RampPitchVol(TRUE); RampPitchVol( TRUE );
} }
} }
// //
// SpinDown - decelerates a moving func_rotating to a standstill. // SpinDown - decelerates a moving func_rotating to a standstill.
// //
void CFuncRotating :: SpinDown( void ) void CFuncRotating::SpinDown( void )
{ {
Vector vecAVel;//rotational velocity Vector vecAVel;//rotational velocity
vec_t vecdir; vec_t vecdir;
@ -623,34 +598,34 @@ void CFuncRotating :: SpinDown( void )
vecAVel = pev->avelocity;// cache entity's rotational velocity vecAVel = pev->avelocity;// cache entity's rotational velocity
if (pev->movedir.x != 0) if( pev->movedir.x != 0 )
vecdir = pev->movedir.x; vecdir = pev->movedir.x;
else if (pev->movedir.y != 0) else if( pev->movedir.y != 0 )
vecdir = pev->movedir.y; vecdir = pev->movedir.y;
else else
vecdir = pev->movedir.z; vecdir = pev->movedir.z;
// if we've met or exceeded target speed, set target speed and stop thinking // if we've met or exceeded target speed, set target speed and stop thinking
// (note: must check for movedir > 0 or < 0) // (note: must check for movedir > 0 or < 0)
if (((vecdir > 0) && (vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0)) || if( ( ( vecdir > 0 ) && ( vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0 ) ) ||
((vecdir < 0) && (vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0))) ( ( vecdir < 0 ) && ( vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0 ) ) )
{ {
pev->avelocity = g_vecZero;// set speed in case we overshot pev->avelocity = g_vecZero;// set speed in case we overshot
// stop sound, we're done // stop sound, we're done
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning /* Stop */), EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ),
0, 0, SND_STOP, m_pitch); 0, 0, SND_STOP, m_pitch );
SetThink( &CFuncRotating::Rotate ); SetThink( &CFuncRotating::Rotate );
Rotate(); Rotate();
} }
else else
{ {
RampPitchVol(FALSE); RampPitchVol( FALSE );
} }
} }
void CFuncRotating :: Rotate( void ) void CFuncRotating::Rotate( void )
{ {
pev->nextthink = pev->ltime + 10; pev->nextthink = pev->ltime + 10;
} }
@ -658,46 +633,46 @@ void CFuncRotating :: Rotate( void )
//========================================================= //=========================================================
// Rotating Use - when a rotating brush is triggered // Rotating Use - when a rotating brush is triggered
//========================================================= //=========================================================
void CFuncRotating :: RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
// is this a brush that should accelerate and decelerate when turned on/off (fan)? // is this a brush that should accelerate and decelerate when turned on/off (fan)?
if ( FBitSet ( pev->spawnflags, SF_BRUSH_ACCDCC ) ) if( FBitSet ( pev->spawnflags, SF_BRUSH_ACCDCC ) )
{ {
// fan is spinning, so stop it. // fan is spinning, so stop it.
if ( pev->avelocity != g_vecZero ) if( pev->avelocity != g_vecZero )
{ {
SetThink( &CFuncRotating::SpinDown ); SetThink( &CFuncRotating::SpinDown );
//EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ),
// m_flVolume, m_flAttenuation, 0, m_pitch); // m_flVolume, m_flAttenuation, 0, m_pitch );
pev->nextthink = pev->ltime + 0.1; pev->nextthink = pev->ltime + 0.1;
} }
else// fan is not moving, so start it else// fan is not moving, so start it
{ {
SetThink( &CFuncRotating::SpinUp ); SetThink( &CFuncRotating::SpinUp );
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ),
0.01, m_flAttenuation, 0, FANPITCHMIN); 0.01, m_flAttenuation, 0, FANPITCHMIN );
pev->nextthink = pev->ltime + 0.1; pev->nextthink = pev->ltime + 0.1;
} }
} }
else if ( !FBitSet ( pev->spawnflags, SF_BRUSH_ACCDCC ) )//this is a normal start/stop brush. else if( !FBitSet( pev->spawnflags, SF_BRUSH_ACCDCC ) )//this is a normal start/stop brush.
{ {
if ( pev->avelocity != g_vecZero ) if( pev->avelocity != g_vecZero )
{ {
// play stopping sound here // play stopping sound here
SetThink( &CFuncRotating::SpinDown ); SetThink( &CFuncRotating::SpinDown );
// EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ),
// m_flVolume, m_flAttenuation, 0, m_pitch); // m_flVolume, m_flAttenuation, 0, m_pitch );
pev->nextthink = pev->ltime + 0.1; pev->nextthink = pev->ltime + 0.1;
// pev->avelocity = g_vecZero; // pev->avelocity = g_vecZero;
} }
else else
{ {
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ),
m_flVolume, m_flAttenuation, 0, FANPITCHMAX); m_flVolume, m_flAttenuation, 0, FANPITCHMAX );
pev->avelocity = pev->movedir * pev->speed; pev->avelocity = pev->movedir * pev->speed;
SetThink( &CFuncRotating::Rotate ); SetThink( &CFuncRotating::Rotate );
@ -706,34 +681,24 @@ void CFuncRotating :: RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller
} }
} }
// //
// RotatingBlocked - An entity has blocked the brush // RotatingBlocked - An entity has blocked the brush
// //
void CFuncRotating :: Blocked( CBaseEntity *pOther ) void CFuncRotating::Blocked( CBaseEntity *pOther )
{ {
pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH); pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH );
} }
//#endif //#endif
class CPendulum : public CBaseEntity class CPendulum : public CBaseEntity
{ {
public: public:
void Spawn ( void ); void Spawn( void );
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
void EXPORT Swing( void ); void EXPORT Swing( void );
void EXPORT PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT Stop( void ); void EXPORT Stop( void );
void Touch( CBaseEntity *pOther ); void Touch( CBaseEntity *pOther );
void EXPORT RopeTouch ( CBaseEntity *pOther );// this touch func makes the pendulum a rope void EXPORT RopeTouch( CBaseEntity *pOther );// this touch func makes the pendulum a rope
virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
@ -742,7 +707,7 @@ public:
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
float m_accel; // Acceleration float m_accel; // Acceleration
float m_distance; // float m_distance;
float m_time; float m_time;
float m_damp; float m_damp;
float m_maxSpeed; float m_maxSpeed;
@ -751,7 +716,7 @@ public:
vec3_t m_start; vec3_t m_start;
}; };
LINK_ENTITY_TO_CLASS( func_pendulum, CPendulum ); LINK_ENTITY_TO_CLASS( func_pendulum, CPendulum )
TYPEDESCRIPTION CPendulum::m_SaveData[] = TYPEDESCRIPTION CPendulum::m_SaveData[] =
{ {
@ -765,52 +730,49 @@ TYPEDESCRIPTION CPendulum::m_SaveData[] =
DEFINE_FIELD( CPendulum, m_start, FIELD_VECTOR ), DEFINE_FIELD( CPendulum, m_start, FIELD_VECTOR ),
}; };
IMPLEMENT_SAVERESTORE( CPendulum, CBaseEntity ); IMPLEMENT_SAVERESTORE( CPendulum, CBaseEntity )
void CPendulum::KeyValue( KeyValueData *pkvd )
void CPendulum :: KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "distance")) if( FStrEq( pkvd->szKeyName, "distance" ) )
{ {
m_distance = atof(pkvd->szValue); m_distance = atof( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "damp")) else if( FStrEq( pkvd->szKeyName, "damp" ) )
{ {
m_damp = atof(pkvd->szValue) * 0.001; m_damp = atof( pkvd->szValue ) * 0.001;
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
CBaseEntity::KeyValue( pkvd ); CBaseEntity::KeyValue( pkvd );
} }
void CPendulum::Spawn( void )
void CPendulum :: Spawn( void )
{ {
// set the axis of rotation // set the axis of rotation
CBaseToggle :: AxisDir( pev ); CBaseToggle::AxisDir( pev );
if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) ) if( FBitSet( pev->spawnflags, SF_DOOR_PASSABLE ) )
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
else else
pev->solid = SOLID_BSP; pev->solid = SOLID_BSP;
pev->movetype = MOVETYPE_PUSH; pev->movetype = MOVETYPE_PUSH;
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin( pev, pev->origin );
SET_MODEL(ENT(pev), STRING(pev->model) ); SET_MODEL( ENT( pev ), STRING( pev->model ) );
if ( m_distance == 0 ) if( m_distance == 0 )
return; return;
if (pev->speed == 0) if( pev->speed == 0 )
pev->speed = 100; pev->speed = 100;
m_accel = (pev->speed * pev->speed) / (2 * fabs(m_distance)); // Calculate constant acceleration from speed and distance m_accel = ( pev->speed * pev->speed ) / ( 2 * fabs( m_distance ) ); // Calculate constant acceleration from speed and distance
m_maxSpeed = pev->speed; m_maxSpeed = pev->speed;
m_start = pev->angles; m_start = pev->angles;
m_center = pev->angles + (m_distance * 0.5) * pev->movedir; m_center = pev->angles + ( m_distance * 0.5 ) * pev->movedir;
if ( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT) ) if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT ) )
{ {
SetThink( &CBaseEntity::SUB_CallUseToggle ); SetThink( &CBaseEntity::SUB_CallUseToggle );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
@ -818,25 +780,24 @@ void CPendulum :: Spawn( void )
pev->speed = 0; pev->speed = 0;
SetUse( &CPendulum::PendulumUse ); SetUse( &CPendulum::PendulumUse );
if ( FBitSet( pev->spawnflags, SF_PENDULUM_SWING ) ) if( FBitSet( pev->spawnflags, SF_PENDULUM_SWING ) )
{ {
SetTouch( &CPendulum::RopeTouch ); SetTouch( &CPendulum::RopeTouch );
} }
} }
void CPendulum::PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
void CPendulum :: PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
if ( pev->speed ) // Pendulum is moving, stop it and auto-return if necessary if( pev->speed ) // Pendulum is moving, stop it and auto-return if necessary
{ {
if ( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) ) if( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) )
{ {
float delta; float delta;
delta = CBaseToggle :: AxisDelta( pev->spawnflags, pev->angles, m_start ); delta = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start );
pev->avelocity = m_maxSpeed * pev->movedir; pev->avelocity = m_maxSpeed * pev->movedir;
pev->nextthink = pev->ltime + (delta / m_maxSpeed); pev->nextthink = pev->ltime + ( delta / m_maxSpeed );
SetThink( &CPendulum::Stop ); SetThink( &CPendulum::Stop );
} }
else else
@ -855,8 +816,7 @@ void CPendulum :: PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US
} }
} }
void CPendulum::Stop( void )
void CPendulum :: Stop( void )
{ {
pev->angles = m_start; pev->angles = m_start;
pev->speed = 0; pev->speed = 0;
@ -864,29 +824,27 @@ void CPendulum :: Stop( void )
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
} }
void CPendulum::Blocked( CBaseEntity *pOther ) void CPendulum::Blocked( CBaseEntity *pOther )
{ {
m_time = gpGlobals->time; m_time = gpGlobals->time;
} }
void CPendulum::Swing( void )
void CPendulum :: Swing( void )
{ {
float delta, dt; float delta, dt;
delta = CBaseToggle :: AxisDelta( pev->spawnflags, pev->angles, m_center ); delta = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_center );
dt = gpGlobals->time - m_time; // How much time has passed? dt = gpGlobals->time - m_time; // How much time has passed?
m_time = gpGlobals->time; // Remember the last time called m_time = gpGlobals->time; // Remember the last time called
if ( delta > 0 && m_accel > 0 ) if( delta > 0 && m_accel > 0 )
pev->speed -= m_accel * dt; // Integrate velocity pev->speed -= m_accel * dt; // Integrate velocity
else else
pev->speed += m_accel * dt; pev->speed += m_accel * dt;
if ( pev->speed > m_maxSpeed ) if( pev->speed > m_maxSpeed )
pev->speed = m_maxSpeed; pev->speed = m_maxSpeed;
else if ( pev->speed < -m_maxSpeed ) else if( pev->speed < -m_maxSpeed )
pev->speed = -m_maxSpeed; pev->speed = -m_maxSpeed;
// scale the destdelta vector by the time spent traveling to get velocity // scale the destdelta vector by the time spent traveling to get velocity
pev->avelocity = pev->speed * pev->movedir; pev->avelocity = pev->speed * pev->movedir;
@ -894,59 +852,59 @@ void CPendulum :: Swing( void )
// Call this again // Call this again
pev->nextthink = pev->ltime + 0.1; pev->nextthink = pev->ltime + 0.1;
if ( m_damp ) if( m_damp )
{ {
m_dampSpeed -= m_damp * m_dampSpeed * dt; m_dampSpeed -= m_damp * m_dampSpeed * dt;
if ( m_dampSpeed < 30.0 ) if( m_dampSpeed < 30.0 )
{ {
pev->angles = m_center; pev->angles = m_center;
pev->speed = 0; pev->speed = 0;
SetThink( NULL ); SetThink( NULL );
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
} }
else if ( pev->speed > m_dampSpeed ) else if( pev->speed > m_dampSpeed )
pev->speed = m_dampSpeed; pev->speed = m_dampSpeed;
else if ( pev->speed < -m_dampSpeed ) else if( pev->speed < -m_dampSpeed )
pev->speed = -m_dampSpeed; pev->speed = -m_dampSpeed;
} }
} }
void CPendulum::Touch( CBaseEntity *pOther )
void CPendulum :: Touch ( CBaseEntity *pOther )
{ {
entvars_t *pevOther = pOther->pev; entvars_t *pevOther = pOther->pev;
if ( pev->dmg <= 0 ) if( pev->dmg <= 0 )
return; return;
// we can't hurt this thing, so we're not concerned with it // we can't hurt this thing, so we're not concerned with it
if ( !pevOther->takedamage ) if( !pevOther->takedamage )
return; return;
// calculate damage based on rotation speed // calculate damage based on rotation speed
float damage = pev->dmg * pev->speed * 0.01; float damage = pev->dmg * pev->speed * 0.01;
if ( damage < 0 ) if( damage < 0 )
damage = -damage; damage = -damage;
pOther->TakeDamage( pev, pev, damage, DMG_CRUSH ); pOther->TakeDamage( pev, pev, damage, DMG_CRUSH );
pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev) ).Normalize() * damage; pevOther->velocity = ( pevOther->origin - VecBModelOrigin( pev ) ).Normalize() * damage;
} }
void CPendulum :: RopeTouch ( CBaseEntity *pOther ) void CPendulum::RopeTouch( CBaseEntity *pOther )
{ {
entvars_t *pevOther = pOther->pev; entvars_t *pevOther = pOther->pev;
if ( !pOther->IsPlayer() ) if( !pOther->IsPlayer() )
{// not a player! {
ALERT ( at_console, "Not a client\n" ); // not a player!
ALERT( at_console, "Not a client\n" );
return; return;
} }
if ( ENT(pevOther) == pev->enemy ) if( ENT( pevOther ) == pev->enemy )
{// this player already on the rope. {
// this player already on the rope.
return; return;
} }
@ -954,5 +912,3 @@ void CPendulum :: RopeTouch ( CBaseEntity *pOther )
pevOther->velocity = g_vecZero; pevOther->velocity = g_vecZero;
pevOther->movetype = MOVETYPE_NONE; pevOther->movetype = MOVETYPE_NONE;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cbase.h" #include "cbase.h"
@ -102,25 +103,25 @@ extern "C" {
#endif #endif
int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ) int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion )
{ {
if ( !pFunctionTable || interfaceVersion != INTERFACE_VERSION ) if( !pFunctionTable || interfaceVersion != INTERFACE_VERSION )
{ {
return FALSE; return FALSE;
} }
memcpy( pFunctionTable, &gFunctionTable, sizeof( DLL_FUNCTIONS ) ); memcpy( pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS) );
return TRUE; return TRUE;
} }
int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion )
{ {
if ( !pFunctionTable || *interfaceVersion != INTERFACE_VERSION ) if( !pFunctionTable || *interfaceVersion != INTERFACE_VERSION )
{ {
// Tell engine what version we had, so it can figure out who is out of date. // Tell engine what version we had, so it can figure out who is out of date.
*interfaceVersion = INTERFACE_VERSION; *interfaceVersion = INTERFACE_VERSION;
return FALSE; return FALSE;
} }
memcpy( pFunctionTable, &gFunctionTable, sizeof( DLL_FUNCTIONS ) ); memcpy( pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS) );
return TRUE; return TRUE;
} }
@ -128,43 +129,41 @@ int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion )
} }
#endif #endif
int DispatchSpawn( edict_t *pent ) int DispatchSpawn( edict_t *pent )
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent );
if (pEntity) if( pEntity )
{ {
// Initialize these or entities who don't link to the world won't have anything in here // Initialize these or entities who don't link to the world won't have anything in here
pEntity->pev->absmin = pEntity->pev->origin - Vector(1,1,1); pEntity->pev->absmin = pEntity->pev->origin - Vector( 1, 1, 1 );
pEntity->pev->absmax = pEntity->pev->origin + Vector(1,1,1); pEntity->pev->absmax = pEntity->pev->origin + Vector( 1, 1, 1 );
pEntity->Spawn(); pEntity->Spawn();
// Try to get the pointer again, in case the spawn function deleted the entity. // Try to get the pointer again, in case the spawn function deleted the entity.
// UNDONE: Spawn() should really return a code to ask that the entity be deleted, but // UNDONE: Spawn() should really return a code to ask that the entity be deleted, but
// that would touch too much code for me to do that right now. // that would touch too much code for me to do that right now.
pEntity = (CBaseEntity *)GET_PRIVATE(pent); pEntity = (CBaseEntity *)GET_PRIVATE( pent );
if ( pEntity ) if( pEntity )
{ {
if ( g_pGameRules && !g_pGameRules->IsAllowedToSpawn( pEntity ) ) if( g_pGameRules && !g_pGameRules->IsAllowedToSpawn( pEntity ) )
return -1; // return that this entity should be deleted return -1; // return that this entity should be deleted
if ( pEntity->pev->flags & FL_KILLME ) if( pEntity->pev->flags & FL_KILLME )
return -1; return -1;
} }
// Handle global stuff here // Handle global stuff here
if ( pEntity && pEntity->pev->globalname ) if( pEntity && pEntity->pev->globalname )
{ {
const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname ); const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname );
if ( pGlobal ) if( pGlobal )
{ {
// Already dead? delete // Already dead? delete
if ( pGlobal->state == GLOBAL_DEAD ) if( pGlobal->state == GLOBAL_DEAD )
return -1; return -1;
else if ( !FStrEq( STRING(gpGlobals->mapname), pGlobal->levelName ) ) else if( !FStrEq( STRING( gpGlobals->mapname ), pGlobal->levelName ) )
pEntity->MakeDormant(); // Hasn't been moved to this level yet, wait but stay alive pEntity->MakeDormant(); // Hasn't been moved to this level yet, wait but stay alive
// In this level & not dead, continue on as normal // In this level & not dead, continue on as normal
} }
@ -172,7 +171,7 @@ int DispatchSpawn( edict_t *pent )
{ {
// Spawned entities default to 'On' // Spawned entities default to 'On'
gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON ); gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON );
// ALERT( at_console, "Added global entity %s (%s)\n", STRING(pEntity->pev->classname), STRING(pEntity->pev->globalname) ); //ALERT( at_console, "Added global entity %s (%s)\n", STRING( pEntity->pev->classname ), STRING( pEntity->pev->globalname ) );
} }
} }
@ -183,10 +182,10 @@ int DispatchSpawn( edict_t *pent )
void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ) void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd )
{ {
if ( !pkvd || !pentKeyvalue ) if( !pkvd || !pentKeyvalue )
return; return;
EntvarsKeyvalue( VARS(pentKeyvalue), pkvd ); EntvarsKeyvalue( VARS( pentKeyvalue ), pkvd );
// If the key was an entity variable, or there's no class set yet, don't look for the object, it may // If the key was an entity variable, or there's no class set yet, don't look for the object, it may
// not exist yet. // not exist yet.
@ -194,47 +193,46 @@ void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd )
return; return;
// Get the actualy entity object // Get the actualy entity object
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentKeyvalue );
if ( !pEntity ) if( !pEntity )
return; return;
pEntity->KeyValue( pkvd ); pEntity->KeyValue( pkvd );
} }
// HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers) // HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers)
// while it builds the graph // while it builds the graph
BOOL gTouchDisabled = FALSE; BOOL gTouchDisabled = FALSE;
void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ) void DispatchTouch( edict_t *pentTouched, edict_t *pentOther )
{ {
if ( gTouchDisabled ) if( gTouchDisabled )
return; return;
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentTouched );
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther ); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther );
if ( pEntity && pOther && ! ((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME) ) if( pEntity && pOther && ! ( ( pEntity->pev->flags | pOther->pev->flags ) & FL_KILLME ) )
pEntity->Touch( pOther ); pEntity->Touch( pOther );
} }
void DispatchUse( edict_t *pentUsed, edict_t *pentOther ) void DispatchUse( edict_t *pentUsed, edict_t *pentOther )
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentUsed );
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther );
if (pEntity && !(pEntity->pev->flags & FL_KILLME) ) if( pEntity && !( pEntity->pev->flags & FL_KILLME ) )
pEntity->Use( pOther, pOther, USE_TOGGLE, 0 ); pEntity->Use( pOther, pOther, USE_TOGGLE, 0 );
} }
void DispatchThink( edict_t *pent ) void DispatchThink( edict_t *pent )
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent );
if (pEntity) if( pEntity )
{ {
if ( FBitSet( pEntity->pev->flags, FL_DORMANT ) ) if( FBitSet( pEntity->pev->flags, FL_DORMANT ) )
ALERT( at_error, "Dormant entity %s is thinking!!\n", STRING(pEntity->pev->classname) ); ALERT( at_error, "Dormant entity %s is thinking!!\n", STRING( pEntity->pev->classname ) );
pEntity->Think(); pEntity->Think();
} }
@ -245,26 +243,26 @@ void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther )
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentBlocked ); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentBlocked );
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther ); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther );
if (pEntity) if( pEntity )
pEntity->Blocked( pOther ); pEntity->Blocked( pOther );
} }
void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData )
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent );
if ( pEntity && pSaveData ) if( pEntity && pSaveData )
{ {
ENTITYTABLE *pTable = &pSaveData->pTable[ pSaveData->currentIndex ]; ENTITYTABLE *pTable = &pSaveData->pTable[pSaveData->currentIndex];
if ( pTable->pent != pent ) if( pTable->pent != pent )
ALERT( at_error, "ENTITY TABLE OR INDEX IS WRONG!!!!\n" ); ALERT( at_error, "ENTITY TABLE OR INDEX IS WRONG!!!!\n" );
if ( pEntity->ObjectCaps() & FCAP_DONT_SAVE ) if( pEntity->ObjectCaps() & FCAP_DONT_SAVE )
return; return;
// These don't use ltime & nextthink as times really, but we'll fudge around it. // These don't use ltime & nextthink as times really, but we'll fudge around it.
if ( pEntity->pev->movetype == MOVETYPE_PUSH ) if( pEntity->pev->movetype == MOVETYPE_PUSH )
{ {
float delta = pEntity->pev->nextthink - pEntity->pev->ltime; float delta = pEntity->pev->nextthink - pEntity->pev->ltime;
pEntity->pev->ltime = gpGlobals->time; pEntity->pev->ltime = gpGlobals->time;
@ -281,18 +279,17 @@ void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData )
} }
} }
// Find the matching global entity. Spit out an error if the designer made entities of // Find the matching global entity. Spit out an error if the designer made entities of
// different classes with the same global name // different classes with the same global name
CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname ) CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname )
{ {
edict_t *pent = FIND_ENTITY_BY_STRING( NULL, "globalname", STRING(globalname) ); edict_t *pent = FIND_ENTITY_BY_STRING( NULL, "globalname", STRING( globalname ) );
CBaseEntity *pReturn = CBaseEntity::Instance( pent ); CBaseEntity *pReturn = CBaseEntity::Instance( pent );
if ( pReturn ) if( pReturn )
{ {
if ( !FClassnameIs( pReturn->pev, STRING(classname) ) ) if( !FClassnameIs( pReturn->pev, STRING( classname ) ) )
{ {
ALERT( at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname) ); ALERT( at_console, "Global entity found %s, wrong class %s\n", STRING( globalname ), STRING( pReturn->pev->classname ) );
pReturn = NULL; pReturn = NULL;
} }
} }
@ -300,18 +297,17 @@ CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname )
return pReturn; return pReturn;
} }
int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ) int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity )
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent );
if ( pEntity && pSaveData ) if( pEntity && pSaveData )
{ {
entvars_t tmpVars; entvars_t tmpVars;
Vector oldOffset; Vector oldOffset;
CRestore restoreHelper( pSaveData ); CRestore restoreHelper( pSaveData );
if ( globalEntity ) if( globalEntity )
{ {
CRestore tmpRestore( pSaveData ); CRestore tmpRestore( pSaveData );
tmpRestore.PrecacheMode( 0 ); tmpRestore.PrecacheMode( 0 );
@ -322,25 +318,24 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity
pSaveData->pCurrentData = pSaveData->pBaseData + pSaveData->size; pSaveData->pCurrentData = pSaveData->pBaseData + pSaveData->size;
// ------------------- // -------------------
const globalentity_t *pGlobal = gGlobalState.EntityFromTable( tmpVars.globalname ); const globalentity_t *pGlobal = gGlobalState.EntityFromTable( tmpVars.globalname );
// Don't overlay any instance of the global that isn't the latest // Don't overlay any instance of the global that isn't the latest
// pSaveData->szCurrentMapName is the level this entity is coming from // pSaveData->szCurrentMapName is the level this entity is coming from
// pGlobla->levelName is the last level the global entity was active in. // pGlobla->levelName is the last level the global entity was active in.
// If they aren't the same, then this global update is out of date. // If they aren't the same, then this global update is out of date.
if ( !FStrEq( pSaveData->szCurrentMapName, pGlobal->levelName ) ) if( !FStrEq( pSaveData->szCurrentMapName, pGlobal->levelName ) )
return 0; return 0;
// Compute the new global offset // Compute the new global offset
oldOffset = pSaveData->vecLandmarkOffset; oldOffset = pSaveData->vecLandmarkOffset;
CBaseEntity *pNewEntity = FindGlobalEntity( tmpVars.classname, tmpVars.globalname ); CBaseEntity *pNewEntity = FindGlobalEntity( tmpVars.classname, tmpVars.globalname );
if ( pNewEntity ) if( pNewEntity )
{ {
// ALERT( at_console, "Overlay %s with %s\n", STRING(pNewEntity->pev->classname), STRING(tmpVars.classname) ); //ALERT( at_console, "Overlay %s with %s\n", STRING( pNewEntity->pev->classname ), STRING( tmpVars.classname ) );
// Tell the restore code we're overlaying a global entity from another level // Tell the restore code we're overlaying a global entity from another level
restoreHelper.SetGlobalMode( 1 ); // Don't overwrite global fields restoreHelper.SetGlobalMode( 1 ); // Don't overwrite global fields
pSaveData->vecLandmarkOffset = (pSaveData->vecLandmarkOffset - pNewEntity->pev->mins) + tmpVars.mins; pSaveData->vecLandmarkOffset = ( pSaveData->vecLandmarkOffset - pNewEntity->pev->mins ) + tmpVars.mins;
pEntity = pNewEntity;// we're going to restore this data OVER the old entity pEntity = pNewEntity;// we're going to restore this data OVER the old entity
pent = ENT( pEntity->pev ); pent = ENT( pEntity->pev );
// Update the global table to say that the global definition of this entity should come from this level // Update the global table to say that the global definition of this entity should come from this level
@ -352,10 +347,9 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity
// or call EntityUpdate() to move it to this level, we haven't changed global state at all. // or call EntityUpdate() to move it to this level, we haven't changed global state at all.
return 0; return 0;
} }
} }
if ( pEntity->ObjectCaps() & FCAP_MUST_SPAWN ) if( pEntity->ObjectCaps() & FCAP_MUST_SPAWN )
{ {
pEntity->Restore( restoreHelper ); pEntity->Restore( restoreHelper );
pEntity->Spawn(); pEntity->Spawn();
@ -363,39 +357,37 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity
else else
{ {
pEntity->Restore( restoreHelper ); pEntity->Restore( restoreHelper );
pEntity->Precache( ); pEntity->Precache();
} }
// Again, could be deleted, get the pointer again. // Again, could be deleted, get the pointer again.
pEntity = (CBaseEntity *)GET_PRIVATE(pent); pEntity = (CBaseEntity *)GET_PRIVATE( pent );
#if 0 #if 0
if ( pEntity && pEntity->pev->globalname && globalEntity ) if( pEntity && pEntity->pev->globalname && globalEntity )
{ {
ALERT( at_console, "Global %s is %s\n", STRING(pEntity->pev->globalname), STRING(pEntity->pev->model) ); ALERT( at_console, "Global %s is %s\n", STRING( pEntity->pev->globalname ), STRING( pEntity->pev->model ) );
} }
#endif #endif
// Is this an overriding global entity (coming over the transition), or one restoring in a level // Is this an overriding global entity (coming over the transition), or one restoring in a level
if ( globalEntity ) if( globalEntity )
{ {
// ALERT( at_console, "After: %f %f %f %s\n", pEntity->pev->origin.x, pEntity->pev->origin.y, pEntity->pev->origin.z, STRING(pEntity->pev->model) ); //ALERT( at_console, "After: %f %f %f %s\n", pEntity->pev->origin.x, pEntity->pev->origin.y, pEntity->pev->origin.z, STRING( pEntity->pev->model ) );
pSaveData->vecLandmarkOffset = oldOffset; pSaveData->vecLandmarkOffset = oldOffset;
if ( pEntity ) if( pEntity )
{ {
UTIL_SetOrigin( pEntity->pev, pEntity->pev->origin ); UTIL_SetOrigin( pEntity->pev, pEntity->pev->origin );
pEntity->OverrideReset(); pEntity->OverrideReset();
} }
} }
else if ( pEntity && pEntity->pev->globalname ) else if( pEntity && pEntity->pev->globalname )
{ {
const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname ); const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname );
if ( pGlobal ) if( pGlobal )
{ {
// Already dead? delete // Already dead? delete
if ( pGlobal->state == GLOBAL_DEAD ) if( pGlobal->state == GLOBAL_DEAD )
return -1; return -1;
else if ( !FStrEq( STRING(gpGlobals->mapname), pGlobal->levelName ) ) else if( !FStrEq( STRING( gpGlobals->mapname ), pGlobal->levelName ) )
{ {
pEntity->MakeDormant(); // Hasn't been moved to this level yet, wait but stay alive pEntity->MakeDormant(); // Hasn't been moved to this level yet, wait but stay alive
} }
@ -403,7 +395,7 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity
} }
else else
{ {
ALERT( at_error, "Global Entity %s (%s) not in table!!!\n", STRING(pEntity->pev->globalname), STRING(pEntity->pev->classname) ); ALERT( at_error, "Global Entity %s (%s) not in table!!!\n", STRING( pEntity->pev->globalname ), STRING( pEntity->pev->classname ) );
// Spawned entities default to 'On' // Spawned entities default to 'On'
gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON ); gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON );
} }
@ -412,11 +404,10 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity
return 0; return 0;
} }
void DispatchObjectCollsionBox( edict_t *pent ) void DispatchObjectCollsionBox( edict_t *pent )
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent );
if (pEntity) if( pEntity )
{ {
pEntity->SetObjectCollisionBox(); pEntity->SetObjectCollisionBox();
} }
@ -424,54 +415,49 @@ void DispatchObjectCollsionBox( edict_t *pent )
SetObjectCollisionBox( &pent->v ); SetObjectCollisionBox( &pent->v );
} }
void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount )
{ {
CSave saveHelper( pSaveData ); CSave saveHelper( pSaveData );
saveHelper.WriteFields( pname, pBaseData, pFields, fieldCount ); saveHelper.WriteFields( pname, pBaseData, pFields, fieldCount );
} }
void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount )
{ {
CRestore restoreHelper( pSaveData ); CRestore restoreHelper( pSaveData );
restoreHelper.ReadFields( pname, pBaseData, pFields, fieldCount ); restoreHelper.ReadFields( pname, pBaseData, pFields, fieldCount );
} }
edict_t *EHANDLE::Get( void )
edict_t * EHANDLE::Get( void )
{ {
if (m_pent) if( m_pent )
{ {
if (m_pent->serialnumber == m_serialnumber) if( m_pent->serialnumber == m_serialnumber )
return m_pent; return m_pent;
else else
return NULL; return NULL;
} }
return NULL; return NULL;
}; }
edict_t * EHANDLE::Set( edict_t *pent ) edict_t *EHANDLE::Set( edict_t *pent )
{ {
m_pent = pent; m_pent = pent;
if (pent) if( pent )
m_serialnumber = m_pent->serialnumber; m_serialnumber = m_pent->serialnumber;
return pent; return pent;
}; }
EHANDLE::operator CBaseEntity *()
EHANDLE :: operator CBaseEntity *()
{ {
return (CBaseEntity *)GET_PRIVATE( Get( ) ); return (CBaseEntity *)GET_PRIVATE( Get() );
}; }
CBaseEntity *EHANDLE::operator = ( CBaseEntity *pEntity )
CBaseEntity * EHANDLE :: operator = (CBaseEntity *pEntity)
{ {
if (pEntity) if( pEntity )
{ {
m_pent = ENT( pEntity->pev ); m_pent = ENT( pEntity->pev );
if (m_pent) if( m_pent )
m_serialnumber = m_pent->serialnumber; m_serialnumber = m_pent->serialnumber;
} }
else else
@ -482,30 +468,29 @@ CBaseEntity * EHANDLE :: operator = (CBaseEntity *pEntity)
return pEntity; return pEntity;
} }
EHANDLE :: operator int () EHANDLE::operator int ()
{ {
return Get() != NULL; return Get() != NULL;
} }
CBaseEntity * EHANDLE :: operator -> () CBaseEntity * EHANDLE::operator -> ()
{ {
return (CBaseEntity *)GET_PRIVATE( Get( ) ); return (CBaseEntity *)GET_PRIVATE( Get() );
} }
// give health // give health
int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) int CBaseEntity::TakeHealth( float flHealth, int bitsDamageType )
{ {
if (!pev->takedamage) if( !pev->takedamage )
return 0; return 0;
// heal // heal
if ( pev->health >= pev->max_health ) if( pev->health >= pev->max_health )
return 0; return 0;
pev->health += flHealth; pev->health += flHealth;
if (pev->health > pev->max_health) if( pev->health > pev->max_health )
pev->health = pev->max_health; pev->health = pev->max_health;
return 1; return 1;
@ -513,48 +498,47 @@ int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType )
// inflict damage on this entity. bitsDamageType indicates type of damage inflicted, ie: DMG_CRUSH // inflict damage on this entity. bitsDamageType indicates type of damage inflicted, ie: DMG_CRUSH
int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
Vector vecTemp; Vector vecTemp;
if (!pev->takedamage) if( !pev->takedamage )
return 0; return 0;
// UNDONE: some entity types may be immune or resistant to some bitsDamageType // UNDONE: some entity types may be immune or resistant to some bitsDamageType
// if Attacker == Inflictor, the attack was a melee or other instant-hit attack. // if Attacker == Inflictor, the attack was a melee or other instant-hit attack.
// (that is, no actual entity projectile was involved in the attack so use the shooter's origin). // (that is, no actual entity projectile was involved in the attack so use the shooter's origin).
if ( pevAttacker == pevInflictor ) if( pevAttacker == pevInflictor )
{ {
vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); vecTemp = pevInflictor->origin - VecBModelOrigin( pev );
} }
else else
// an actual missile was involved. // an actual missile was involved.
{ {
vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); vecTemp = pevInflictor->origin - VecBModelOrigin( pev );
} }
// this global is still used for glass and other non-monster killables, along with decals. // this global is still used for glass and other non-monster killables, along with decals.
g_vecAttackDir = vecTemp.Normalize(); g_vecAttackDir = vecTemp.Normalize();
// save damage based on the target's armor level // save damage based on the target's armor level
// figure momentum add (don't let hurt brushes or other triggers move player)
// figure momentum add (don't let hurt brushes or other triggers move player) if( ( !FNullEnt( pevInflictor ) ) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP ) && ( pevAttacker->solid != SOLID_TRIGGER ) )
if ((!FNullEnt(pevInflictor)) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP) && (pevAttacker->solid != SOLID_TRIGGER) )
{ {
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; Vector vecDir = pev->origin - ( pevInflictor->absmin + pevInflictor->absmax ) * 0.5;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
float flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; float flForce = flDamage * ( ( 32 * 32 * 72.0 ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5;
if (flForce > 1000.0) if( flForce > 1000.0 )
flForce = 1000.0; flForce = 1000.0;
pev->velocity = pev->velocity + vecDir * flForce; pev->velocity = pev->velocity + vecDir * flForce;
} }
// do the damage // do the damage
pev->health -= flDamage; pev->health -= flDamage;
if (pev->health <= 0) if( pev->health <= 0 )
{ {
Killed( pevAttacker, GIB_NORMAL ); Killed( pevAttacker, GIB_NORMAL );
return 0; return 0;
@ -563,21 +547,19 @@ int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker,
return 1; return 1;
} }
void CBaseEntity::Killed( entvars_t *pevAttacker, int iGib )
void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib )
{ {
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
pev->deadflag = DEAD_DEAD; pev->deadflag = DEAD_DEAD;
UTIL_Remove( this ); UTIL_Remove( this );
} }
CBaseEntity *CBaseEntity::GetNextTarget( void ) CBaseEntity *CBaseEntity::GetNextTarget( void )
{ {
if ( FStringNull( pev->target ) ) if( FStringNull( pev->target ) )
return NULL; return NULL;
edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(pev->target) ); edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) );
if ( FNullEnt(pTarget) ) if( FNullEnt( pTarget ) )
return NULL; return NULL;
return Instance( pTarget ); return Instance( pTarget );
@ -594,11 +576,10 @@ TYPEDESCRIPTION CBaseEntity::m_SaveData[] =
DEFINE_FIELD( CBaseEntity, m_pfnBlocked, FIELD_FUNCTION ), DEFINE_FIELD( CBaseEntity, m_pfnBlocked, FIELD_FUNCTION ),
}; };
int CBaseEntity::Save( CSave &save ) int CBaseEntity::Save( CSave &save )
{ {
if ( save.WriteEntVars( "ENTVARS", pev ) ) if( save.WriteEntVars( "ENTVARS", pev ) )
return save.WriteFields( "BASE", this, m_SaveData, ARRAYSIZE(m_SaveData) ); return save.WriteFields( "BASE", this, m_SaveData, ARRAYSIZE( m_SaveData ) );
return 0; return 0;
} }
@ -608,48 +589,47 @@ int CBaseEntity::Restore( CRestore &restore )
int status; int status;
status = restore.ReadEntVars( "ENTVARS", pev ); status = restore.ReadEntVars( "ENTVARS", pev );
if ( status ) if( status )
status = restore.ReadFields( "BASE", this, m_SaveData, ARRAYSIZE(m_SaveData) ); status = restore.ReadFields( "BASE", this, m_SaveData, ARRAYSIZE( m_SaveData ) );
if ( pev->modelindex != 0 && !FStringNull(pev->model) ) if( pev->modelindex != 0 && !FStringNull( pev->model ) )
{ {
Vector mins, maxs; Vector mins, maxs;
mins = pev->mins; // Set model is about to destroy these mins = pev->mins; // Set model is about to destroy these
maxs = pev->maxs; maxs = pev->maxs;
PRECACHE_MODEL( (char *)STRING( pev->model ) );
PRECACHE_MODEL( (char *)STRING(pev->model) ); SET_MODEL( ENT( pev ), STRING( pev->model ) );
SET_MODEL(ENT(pev), STRING(pev->model)); UTIL_SetSize( pev, mins, maxs ); // Reset them
UTIL_SetSize(pev, mins, maxs); // Reset them
} }
return status; return status;
} }
// Initialize absmin & absmax to the appropriate box // Initialize absmin & absmax to the appropriate box
void SetObjectCollisionBox( entvars_t *pev ) void SetObjectCollisionBox( entvars_t *pev )
{ {
if ( (pev->solid == SOLID_BSP) && if( ( pev->solid == SOLID_BSP ) &&
(pev->angles.x || pev->angles.y|| pev->angles.z) ) ( pev->angles.x || pev->angles.y || pev->angles.z ) )
{ // expand for rotation {
// expand for rotation
float max, v; float max, v;
int i; int i;
max = 0; max = 0;
for (i=0 ; i<3 ; i++) for( i = 0; i < 3; i++ )
{ {
v = fabs( ((float *)pev->mins)[i]); v = fabs( ( (float *)pev->mins )[i] );
if (v > max) if( v > max )
max = v; max = v;
v = fabs( ((float *)pev->maxs)[i]); v = fabs( ( (float *)pev->maxs )[i] );
if (v > max) if( v > max )
max = v; max = v;
} }
for (i=0 ; i<3 ; i++) for( i = 0; i < 3; i++ )
{ {
((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max; ( (float *)pev->absmin )[i] = ( (float *)pev->origin )[i] - max;
((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max; ( (float *)pev->absmax )[i] = ( (float *)pev->origin )[i] + max;
} }
} }
else else
@ -666,16 +646,14 @@ void SetObjectCollisionBox( entvars_t *pev )
pev->absmax.z += 1; pev->absmax.z += 1;
} }
void CBaseEntity::SetObjectCollisionBox( void ) void CBaseEntity::SetObjectCollisionBox( void )
{ {
::SetObjectCollisionBox( pev ); ::SetObjectCollisionBox( pev );
} }
int CBaseEntity::Intersects( CBaseEntity *pOther )
int CBaseEntity :: Intersects( CBaseEntity *pOther )
{ {
if ( pOther->pev->absmin.x > pev->absmax.x || if( pOther->pev->absmin.x > pev->absmax.x ||
pOther->pev->absmin.y > pev->absmax.y || pOther->pev->absmin.y > pev->absmax.y ||
pOther->pev->absmin.z > pev->absmax.z || pOther->pev->absmin.z > pev->absmax.z ||
pOther->pev->absmax.x < pev->absmin.x || pOther->pev->absmax.x < pev->absmin.x ||
@ -685,7 +663,7 @@ int CBaseEntity :: Intersects( CBaseEntity *pOther )
return 1; return 1;
} }
void CBaseEntity :: MakeDormant( void ) void CBaseEntity::MakeDormant( void )
{ {
SetBits( pev->flags, FL_DORMANT ); SetBits( pev->flags, FL_DORMANT );
@ -701,64 +679,73 @@ void CBaseEntity :: MakeDormant( void )
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
int CBaseEntity :: IsDormant( void ) int CBaseEntity::IsDormant( void )
{ {
return FBitSet( pev->flags, FL_DORMANT ); return FBitSet( pev->flags, FL_DORMANT );
} }
BOOL CBaseEntity :: IsInWorld( void ) BOOL CBaseEntity::IsInWorld( void )
{ {
// position // position
if (pev->origin.x >= 4096) return FALSE; if( pev->origin.x >= 4096 )
if (pev->origin.y >= 4096) return FALSE; return FALSE;
if (pev->origin.z >= 4096) return FALSE; if( pev->origin.y >= 4096 )
if (pev->origin.x <= -4096) return FALSE; return FALSE;
if (pev->origin.y <= -4096) return FALSE; if( pev->origin.z >= 4096 )
if (pev->origin.z <= -4096) return FALSE; return FALSE;
if( pev->origin.x <= -4096 )
return FALSE;
if( pev->origin.y <= -4096 )
return FALSE;
if( pev->origin.z <= -4096 )
return FALSE;
// speed // speed
if (pev->velocity.x >= 2000) return FALSE; if( pev->velocity.x >= 2000 )
if (pev->velocity.y >= 2000) return FALSE; return FALSE;
if (pev->velocity.z >= 2000) return FALSE; if( pev->velocity.y >= 2000 )
if (pev->velocity.x <= -2000) return FALSE; return FALSE;
if (pev->velocity.y <= -2000) return FALSE; if( pev->velocity.z >= 2000 )
if (pev->velocity.z <= -2000) return FALSE; return FALSE;
if( pev->velocity.x <= -2000 )
return FALSE;
if( pev->velocity.y <= -2000 )
return FALSE;
if( pev->velocity.z <= -2000 )
return FALSE;
return TRUE; return TRUE;
} }
int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState )
{ {
if ( useType != USE_TOGGLE && useType != USE_SET ) if( useType != USE_TOGGLE && useType != USE_SET )
{ {
if ( (currentState && useType == USE_ON) || (!currentState && useType == USE_OFF) ) if( ( currentState && useType == USE_ON ) || ( !currentState && useType == USE_OFF ) )
return 0; return 0;
} }
return 1; return 1;
} }
int CBaseEntity::DamageDecal( int bitsDamageType )
int CBaseEntity :: DamageDecal( int bitsDamageType )
{ {
if ( pev->rendermode == kRenderTransAlpha ) if( pev->rendermode == kRenderTransAlpha )
return -1; return -1;
if ( pev->rendermode != kRenderNormal ) if( pev->rendermode != kRenderNormal )
return DECAL_BPROOF1; return DECAL_BPROOF1;
return DECAL_GUNSHOT1 + RANDOM_LONG(0,4); return DECAL_GUNSHOT1 + RANDOM_LONG( 0, 4 );
} }
// NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity
// will keep a pointer to it after this call. // will keep a pointer to it after this call.
CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner )
{ {
edict_t *pent; edict_t *pent;
CBaseEntity *pEntity; CBaseEntity *pEntity;
pent = CREATE_NAMED_ENTITY( MAKE_STRING( szName )); pent = CREATE_NAMED_ENTITY( MAKE_STRING( szName ) );
if ( FNullEnt( pent ) ) if( FNullEnt( pent ) )
{ {
ALERT ( at_console, "NULL Ent in Create!\n" ); ALERT ( at_console, "NULL Ent in Create!\n" );
return NULL; return NULL;
@ -770,5 +757,3 @@ CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const
DispatchSpawn( pEntity->edict() ); DispatchSpawn( pEntity->edict() );
return pEntity; return pEntity;
} }

View File

@ -72,13 +72,19 @@ extern void SaveGlobalState( SAVERESTOREDATA *pSaveData );
extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData ); extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData );
extern void ResetGlobalState( void ); extern void ResetGlobalState( void );
typedef enum { USE_OFF = 0, USE_ON = 1, USE_SET = 2, USE_TOGGLE = 3 } USE_TYPE; typedef enum
{
USE_OFF = 0,
USE_ON = 1,
USE_SET = 2,
USE_TOGGLE = 3
} USE_TYPE;
extern void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); extern void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
typedef void (CBaseEntity::*BASEPTR)(void); typedef void(CBaseEntity::*BASEPTR)( void );
typedef void (CBaseEntity::*ENTITYFUNCPTR)(CBaseEntity *pOther ); typedef void(CBaseEntity::*ENTITYFUNCPTR)( CBaseEntity *pOther );
typedef void (CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); typedef void(CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
// For CLASSIFY // For CLASSIFY
#define CLASS_NONE 0 #define CLASS_NONE 0
@ -102,7 +108,6 @@ class CBaseMonster;
class CBasePlayerItem; class CBasePlayerItem;
class CSquadMonster; class CSquadMonster;
#define SF_NORESPAWN ( 1 << 30 )// !!!set this bit on guns and stuff that should never respawn. #define SF_NORESPAWN ( 1 << 30 )// !!!set this bit on guns and stuff that should never respawn.
// //
@ -121,11 +126,10 @@ public:
operator CBaseEntity *(); operator CBaseEntity *();
CBaseEntity * operator = (CBaseEntity *pEntity); CBaseEntity *operator = ( CBaseEntity *pEntity );
CBaseEntity * operator ->(); CBaseEntity *operator ->();
}; };
// //
// Base Entity. All entity types derive from this // Base Entity. All entity types derive from this
// //
@ -143,7 +147,7 @@ public:
// initialization functions // initialization functions
virtual void Spawn( void ) { return; } virtual void Spawn( void ) { return; }
virtual void Precache( void ) { return; } virtual void Precache( void ) { return; }
virtual void KeyValue( KeyValueData* pkvd) { pkvd->fHandled = FALSE; } virtual void KeyValue( KeyValueData* pkvd ) { pkvd->fHandled = FALSE; }
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; }
@ -152,23 +156,22 @@ public:
// Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box) // Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box)
virtual void SetObjectCollisionBox( void ); virtual void SetObjectCollisionBox( void );
// Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames // Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames
// still realize that they are teammates. (overridden for monsters that form groups) // still realize that they are teammates. (overridden for monsters that form groups)
virtual int Classify ( void ) { return CLASS_NONE; }; virtual int Classify( void ) { return CLASS_NONE; };
virtual void DeathNotice ( entvars_t *pevChild ) {}// monster maker children use this to tell the monster maker that they have died. virtual void DeathNotice( entvars_t *pevChild ) {}// monster maker children use this to tell the monster maker that they have died.
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
virtual int TakeHealth( float flHealth, int bitsDamageType ); virtual int TakeHealth( float flHealth, int bitsDamageType );
virtual void Killed( entvars_t *pevAttacker, int iGib ); virtual void Killed( entvars_t *pevAttacker, int iGib );
virtual int BloodColor( void ) { return DONT_BLEED; } virtual int BloodColor( void ) { return DONT_BLEED; }
virtual void TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); virtual void TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
virtual BOOL IsTriggered( CBaseEntity *pActivator ) {return TRUE;} virtual BOOL IsTriggered( CBaseEntity *pActivator ) {return TRUE; }
virtual CBaseMonster *MyMonsterPointer( void ) { return NULL;} virtual CBaseMonster *MyMonsterPointer( void ) { return NULL; }
virtual CSquadMonster *MySquadMonsterPointer( void ) { return NULL;} virtual CSquadMonster *MySquadMonsterPointer( void ) { return NULL; }
virtual int GetToggleState( void ) { return TS_AT_TOP; } virtual int GetToggleState( void ) { return TS_AT_TOP; }
virtual void AddPoints( int score, BOOL bAllowNegativeScore ) {} virtual void AddPoints( int score, BOOL bAllowNegativeScore ) {}
virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {}
@ -194,34 +197,33 @@ public:
virtual BOOL IsNetClient( void ) { return FALSE; } virtual BOOL IsNetClient( void ) { return FALSE; }
virtual const char *TeamID( void ) { return ""; } virtual const char *TeamID( void ) { return ""; }
//virtual void SetActivator( CBaseEntity *pActivator ) {}
// virtual void SetActivator( CBaseEntity *pActivator ) {}
virtual CBaseEntity *GetNextTarget( void ); virtual CBaseEntity *GetNextTarget( void );
// fundamental callbacks // fundamental callbacks
void (CBaseEntity ::*m_pfnThink)(void); void ( CBaseEntity ::*m_pfnThink )( void);
void (CBaseEntity ::*m_pfnTouch)( CBaseEntity *pOther ); void ( CBaseEntity ::*m_pfnTouch )( CBaseEntity *pOther );
void (CBaseEntity ::*m_pfnUse)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void ( CBaseEntity ::*m_pfnUse )( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void (CBaseEntity ::*m_pfnBlocked)( CBaseEntity *pOther ); void ( CBaseEntity ::*m_pfnBlocked )( CBaseEntity *pOther );
virtual void Think( void ) { if (m_pfnThink) (this->*m_pfnThink)(); }; virtual void Think( void ) { if( m_pfnThink ) ( this->*m_pfnThink )(); }
virtual void Touch( CBaseEntity *pOther ) { if (m_pfnTouch) (this->*m_pfnTouch)( pOther ); }; virtual void Touch( CBaseEntity *pOther ) { if( m_pfnTouch ) (this->*m_pfnTouch)( pOther ); }
virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
if (m_pfnUse) if( m_pfnUse )
(this->*m_pfnUse)( pActivator, pCaller, useType, value ); ( this->*m_pfnUse )( pActivator, pCaller, useType, value );
} }
virtual void Blocked( CBaseEntity *pOther ) { if (m_pfnBlocked) (this->*m_pfnBlocked)( pOther ); }; virtual void Blocked( CBaseEntity *pOther ) { if( m_pfnBlocked ) ( this->*m_pfnBlocked )( pOther ); };
// allow engine to allocate instance data // allow engine to allocate instance data
void *operator new( size_t stAllocateBlock, entvars_t *pev ) void *operator new( size_t stAllocateBlock, entvars_t *pev )
{ {
return (void *)ALLOC_PRIVATE(ENT(pev), stAllocateBlock); return (void *)ALLOC_PRIVATE( ENT( pev ), stAllocateBlock );
}; };
// don't use this. // don't use this.
#if _MSC_VER >= 1200 // only build this code if MSVC++ 6.0 or higher #if _MSC_VER >= 1200 // only build this code if MSVC++ 6.0 or higher
void operator delete(void *pMem, entvars_t *pev) void operator delete( void *pMem, entvars_t *pev )
{ {
pev->flags |= FL_KILLME; pev->flags |= FL_KILLME;
}; };
@ -233,7 +235,7 @@ public:
void EXPORT SUB_Remove( void ); void EXPORT SUB_Remove( void );
void EXPORT SUB_DoNothing( void ); void EXPORT SUB_DoNothing( void );
void EXPORT SUB_StartFadeOut ( void ); void EXPORT SUB_StartFadeOut ( void );
void EXPORT SUB_FadeOut ( void ); void EXPORT SUB_FadeOut( void );
void EXPORT SUB_CallUseToggle( void ) { this->Use( this, this, USE_TOGGLE, 0 ); } void EXPORT SUB_CallUseToggle( void ) { this->Use( this, this, USE_TOGGLE, 0 ); }
int ShouldToggle( USE_TYPE useType, BOOL currentState ); int ShouldToggle( USE_TYPE useType, BOOL currentState );
void FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL ); void FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL );
@ -250,9 +252,9 @@ public:
static CBaseEntity *Instance( edict_t *pent ) static CBaseEntity *Instance( edict_t *pent )
{ {
if ( !pent ) if( !pent )
pent = ENT(0); pent = ENT( 0 );
CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE( pent );
return pEnt; return pEnt;
} }
@ -262,78 +264,72 @@ public:
CBaseMonster *GetMonsterPointer( entvars_t *pevMonster ) CBaseMonster *GetMonsterPointer( entvars_t *pevMonster )
{ {
CBaseEntity *pEntity = Instance( pevMonster ); CBaseEntity *pEntity = Instance( pevMonster );
if ( pEntity ) if( pEntity )
return pEntity->MyMonsterPointer(); return pEntity->MyMonsterPointer();
return NULL; return NULL;
} }
CBaseMonster *GetMonsterPointer( edict_t *pentMonster ) CBaseMonster *GetMonsterPointer( edict_t *pentMonster )
{ {
CBaseEntity *pEntity = Instance( pentMonster ); CBaseEntity *pEntity = Instance( pentMonster );
if ( pEntity ) if( pEntity )
return pEntity->MyMonsterPointer(); return pEntity->MyMonsterPointer();
return NULL; return NULL;
} }
// Ugly code to lookup all functions to make sure they are exported when set. // Ugly code to lookup all functions to make sure they are exported when set.
#ifdef _DEBUG #ifdef _DEBUG
void FunctionCheck( void *pFunction, char *name ) void FunctionCheck( void *pFunction, char *name )
{ {
if (pFunction && !NAME_FOR_FUNCTION((unsigned long)(pFunction)) ) if( pFunction && !NAME_FOR_FUNCTION( (unsigned long)( pFunction ) ) )
ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING(pev->classname), name, (unsigned long)pFunction ); ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (unsigned long)pFunction );
} }
BASEPTR ThinkSet( BASEPTR func, char *name ) BASEPTR ThinkSet( BASEPTR func, char *name )
{ {
m_pfnThink = func; m_pfnThink = func;
FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnThink)))), name ); FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnThink ) ) ) ), name );
return func; return func;
} }
ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name ) ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name )
{ {
m_pfnTouch = func; m_pfnTouch = func;
FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnTouch)))), name ); FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnTouch ) ) ) ), name );
return func; return func;
} }
USEPTR UseSet( USEPTR func, char *name ) USEPTR UseSet( USEPTR func, char *name )
{ {
m_pfnUse = func; m_pfnUse = func;
FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnUse)))), name ); FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnUse ) ) ) ), name );
return func; return func;
} }
ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name ) ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name )
{ {
m_pfnBlocked = func; m_pfnBlocked = func;
FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnBlocked)))), name ); FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnBlocked ) ) ) ), name );
return func; return func;
} }
#endif #endif
// virtual functions used by a few classes // virtual functions used by a few classes
// used by monsters that are created by the MonsterMaker // used by monsters that are created by the MonsterMaker
virtual void UpdateOwner( void ) { return; }; virtual void UpdateOwner( void ) { return; };
//
static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL );
virtual BOOL FBecomeProne( void ) {return FALSE;}; virtual BOOL FBecomeProne( void ) {return FALSE;};
edict_t *edict() { return ENT( pev ); }; edict_t *edict() { return ENT( pev ); };
EOFFSET eoffset( ) { return OFFSET( pev ); }; EOFFSET eoffset() { return OFFSET( pev ); };
int entindex( ) { return ENTINDEX( edict() ); }; int entindex() { return ENTINDEX( edict() ); };
virtual Vector Center( ) { return (pev->absmax + pev->absmin) * 0.5; }; // center point of entity virtual Vector Center() { return ( pev->absmax + pev->absmin ) * 0.5; }; // center point of entity
virtual Vector EyePosition( ) { return pev->origin + pev->view_ofs; }; // position of eyes virtual Vector EyePosition() { return pev->origin + pev->view_ofs; }; // position of eyes
virtual Vector EarPosition( ) { return pev->origin + pev->view_ofs; }; // position of ears virtual Vector EarPosition() { return pev->origin + pev->view_ofs; }; // position of ears
virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ); }; // position to shoot at virtual Vector BodyTarget( const Vector &posSrc ) { return Center(); }; // position to shoot at
virtual int Illumination( ) { return GETENTITYILLUM( ENT( pev ) ); }; virtual int Illumination() { return GETENTITYILLUM( ENT( pev ) ); };
virtual BOOL FVisible ( CBaseEntity *pEntity ); virtual BOOL FVisible( CBaseEntity *pEntity );
virtual BOOL FVisible ( const Vector &vecOrigin ); virtual BOOL FVisible( const Vector &vecOrigin );
//We use this variables to store each ammo count. //We use this variables to store each ammo count.
int ammo_9mm; int ammo_9mm;
@ -354,8 +350,6 @@ public:
int m_fireState; int m_fireState;
}; };
// Ugly technique to override base member functions // Ugly technique to override base member functions
// Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a // Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a
// member function of a base class. static_cast is a sleezy way around that problem. // member function of a base class. static_cast is a sleezy way around that problem.
@ -378,19 +372,16 @@ public:
#define ResetUse( ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (NULL) #define ResetUse( ) m_pfnUse = static_cast <void (CBaseEntity::*)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )> (NULL)
#define ResetBlocked( ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL) #define ResetBlocked( ) m_pfnBlocked = static_cast <void (CBaseEntity::*)(CBaseEntity *)> (NULL)
#endif #endif
class CPointEntity : public CBaseEntity class CPointEntity : public CBaseEntity
{ {
public: public:
void Spawn( void ); void Spawn( void );
virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
private: private:
}; };
typedef struct locksounds // sounds that doors and buttons make when locked/unlocked typedef struct locksounds // sounds that doors and buttons make when locked/unlocked
{ {
string_t sLockedSound; // sound a door makes when it's locked string_t sLockedSound; // sound a door makes when it's locked
@ -407,7 +398,7 @@ typedef struct locksounds // sounds that doors and buttons make when locked/un
BYTE bEOFUnlocked; // true if hit end of list of unlocked sentences BYTE bEOFUnlocked; // true if hit end of list of unlocked sentences
} locksound_t; } locksound_t;
void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton );
// //
// MultiSouce // MultiSouce
@ -419,15 +410,15 @@ void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton);
class CMultiSource : public CPointEntity class CMultiSource : public CPointEntity
{ {
public: public:
void Spawn( ); void Spawn();
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
int ObjectCaps( void ) { return (CPointEntity::ObjectCaps() | FCAP_MASTER); } int ObjectCaps( void ) { return ( CPointEntity::ObjectCaps() | FCAP_MASTER ); }
BOOL IsTriggered( CBaseEntity *pActivator ); BOOL IsTriggered( CBaseEntity *pActivator );
void EXPORT Register( void ); void EXPORT Register( void );
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
EHANDLE m_rgEntities[MS_MAX_TARGETS]; EHANDLE m_rgEntities[MS_MAX_TARGETS];
@ -447,41 +438,38 @@ public:
float m_flDelay; float m_flDelay;
int m_iszKillTarget; int m_iszKillTarget;
virtual void KeyValue( KeyValueData* pkvd); virtual void KeyValue( KeyValueData *pkvd );
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
// common member functions // common member functions
void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value );
void EXPORT DelayThink( void ); void EXPORT DelayThink( void );
}; };
class CBaseAnimating : public CBaseDelay class CBaseAnimating : public CBaseDelay
{ {
public: public:
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
// Basic Monster Animation functions // Basic Monster Animation functions
float StudioFrameAdvance( float flInterval = 0.0 ); // accumulate animation frame time from last time called until now float StudioFrameAdvance( float flInterval = 0.0 ); // accumulate animation frame time from last time called until now
int GetSequenceFlags( void ); int GetSequenceFlags( void );
int LookupActivity ( int activity ); int LookupActivity( int activity );
int LookupActivityHeaviest ( int activity ); int LookupActivityHeaviest( int activity );
int LookupSequence ( const char *label ); int LookupSequence( const char *label );
void ResetSequenceInfo ( ); void ResetSequenceInfo();
void DispatchAnimEvents ( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future void DispatchAnimEvents( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future
virtual void HandleAnimEvent( MonsterEvent_t *pEvent ) { return; }; virtual void HandleAnimEvent( MonsterEvent_t *pEvent ) { return; };
float SetBoneController ( int iController, float flValue ); float SetBoneController( int iController, float flValue );
void InitBoneControllers ( void ); void InitBoneControllers( void );
float SetBlending ( int iBlender, float flValue ); float SetBlending( int iBlender, float flValue );
void GetBonePosition ( int iBone, Vector &origin, Vector &angles ); void GetBonePosition( int iBone, Vector &origin, Vector &angles );
void GetAutomovement( Vector &origin, Vector &angles, float flInterval = 0.1 ); void GetAutomovement( Vector &origin, Vector &angles, float flInterval = 0.1 );
int FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ); int FindTransition( int iEndingSequence, int iGoalSequence, int *piDir );
void GetAttachment ( int iAttachment, Vector &origin, Vector &angles ); void GetAttachment( int iAttachment, Vector &origin, Vector &angles );
void SetBodygroup( int iGroup, int iValue ); void SetBodygroup( int iGroup, int iValue );
int GetBodygroup( int iGroup ); int GetBodygroup( int iGroup );
int ExtractBbox( int sequence, float *mins, float *maxs ); int ExtractBbox( int sequence, float *mins, float *maxs );
@ -495,7 +483,6 @@ public:
BOOL m_fSequenceLoops; // true if the sequence loops BOOL m_fSequenceLoops; // true if the sequence loops
}; };
// //
// generic Toggle entity. // generic Toggle entity.
// //
@ -671,7 +658,6 @@ class CSound;
char *ButtonSound( int sound ); // get string of button sound number char *ButtonSound( int sound ); // get string of button sound number
// //
// Generic Button // Generic Button
// //
@ -683,16 +669,16 @@ public:
void RotSpawn( void ); void RotSpawn( void );
virtual void KeyValue( KeyValueData* pkvd); virtual void KeyValue( KeyValueData* pkvd);
void ButtonActivate( ); void ButtonActivate();
void SparkSoundCache( void ); void SparkSoundCache( void );
void EXPORT ButtonShot( void ); void EXPORT ButtonShot( void );
void EXPORT ButtonTouch( CBaseEntity *pOther ); void EXPORT ButtonTouch( CBaseEntity *pOther );
void EXPORT ButtonSpark ( void ); void EXPORT ButtonSpark( void );
void EXPORT TriggerAndWait( void ); void EXPORT TriggerAndWait( void );
void EXPORT ButtonReturn( void ); void EXPORT ButtonReturn( void );
void EXPORT ButtonBackHome( void ); void EXPORT ButtonBackHome( void );
void EXPORT ButtonUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
virtual int Save( CSave &save ); virtual int Save( CSave &save );
virtual int Restore( CRestore &restore ); virtual int Restore( CRestore &restore );
@ -723,7 +709,6 @@ public:
// //
// Weapons // Weapons
// //
#define BAD_WEAPON 0x00007FFF #define BAD_WEAPON 0x00007FFF
// //
@ -735,22 +720,21 @@ template <class T> T * GetClassPtr( T *a )
entvars_t *pev = (entvars_t *)a; entvars_t *pev = (entvars_t *)a;
// allocate entity if necessary // allocate entity if necessary
if (pev == NULL) if( pev == NULL )
pev = VARS(CREATE_ENTITY()); pev = VARS( CREATE_ENTITY() );
// get the private data // get the private data
a = (T *)GET_PRIVATE(ENT(pev)); a = (T *)GET_PRIVATE( ENT( pev ) );
if (a == NULL) if( a == NULL )
{ {
// allocate private data // allocate private data
a = new(pev) T; a = new( pev ) T;
a->pev = pev; a->pev = pev;
} }
return a; return a;
} }
/* /*
bit_PUSHBRUSH_DATA | bit_TOGGLE_DATA bit_PUSHBRUSH_DATA | bit_TOGGLE_DATA
bit_MONSTER_DATA bit_MONSTER_DATA
@ -784,7 +768,6 @@ typedef struct _SelAmmo
BYTE Ammo2; BYTE Ammo2;
} SelAmmo; } SelAmmo;
// this moved here from world.cpp, to allow classes to be derived from it // this moved here from world.cpp, to allow classes to be derived from it
//======================= //=======================
// CWorld // CWorld

View File

@ -42,5 +42,4 @@
#define WEAPON_SUIT 31 #define WEAPON_SUIT 31
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
#ifndef CLIENT_H #ifndef CLIENT_H
#define CLIENT_H #define CLIENT_H
extern void respawn( entvars_t* pev, BOOL fCopyCorpse ); extern void respawn( entvars_t *pev, BOOL fCopyCorpse );
extern BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); extern BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] );
extern void ClientDisconnect( edict_t *pEntity ); extern void ClientDisconnect( edict_t *pEntity );
extern void ClientKill( edict_t *pEntity ); extern void ClientKill( edict_t *pEntity );
@ -35,14 +35,14 @@ extern void ClientPrecache( void );
extern const char *GetGameDescription( void ); extern const char *GetGameDescription( void );
extern void PlayerCustomization( edict_t *pEntity, customization_t *pCust ); extern void PlayerCustomization( edict_t *pEntity, customization_t *pCust );
extern void SpectatorConnect ( edict_t *pEntity ); extern void SpectatorConnect( edict_t *pEntity );
extern void SpectatorDisconnect ( edict_t *pEntity ); extern void SpectatorDisconnect( edict_t *pEntity );
extern void SpectatorThink ( edict_t *pEntity ); extern void SpectatorThink( edict_t *pEntity );
extern void Sys_Error( const char *error_string ); extern void Sys_Error( const char *error_string );
extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas );
extern void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); extern void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd );
extern int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); extern int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet );
extern void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); extern void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs );
extern void RegisterEncoders( void ); extern void RegisterEncoders( void );
@ -56,10 +56,9 @@ extern int ConnectionlessPacket( const struct netadr_s *net_from, const char *ar
extern int GetHullBounds( int hullnumber, float *mins, float *maxs ); extern int GetHullBounds( int hullnumber, float *mins, float *maxs );
extern void CreateInstancedBaselines ( void ); extern void CreateInstancedBaselines( void );
extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message );
extern int AllowLagCompensation( void ); extern int AllowLagCompensation( void );
#endif // CLIENT_H #endif // CLIENT_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ class CCrossbowBolt : public CBaseEntity
{ {
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
int Classify ( void ); int Classify( void );
void EXPORT BubbleThink( void ); void EXPORT BubbleThink( void );
void EXPORT BoltTouch( CBaseEntity *pOther ); void EXPORT BoltTouch( CBaseEntity *pOther );
void EXPORT ExplodeThink( void ); void EXPORT ExplodeThink( void );
@ -46,50 +46,49 @@ class CCrossbowBolt : public CBaseEntity
public: public:
static CCrossbowBolt *BoltCreate( void ); static CCrossbowBolt *BoltCreate( void );
}; };
LINK_ENTITY_TO_CLASS( crossbow_bolt, CCrossbowBolt );
LINK_ENTITY_TO_CLASS( crossbow_bolt, CCrossbowBolt )
CCrossbowBolt *CCrossbowBolt::BoltCreate( void ) CCrossbowBolt *CCrossbowBolt::BoltCreate( void )
{ {
// Create a new entity with CCrossbowBolt private data // Create a new entity with CCrossbowBolt private data
CCrossbowBolt *pBolt = GetClassPtr( (CCrossbowBolt *)NULL ); CCrossbowBolt *pBolt = GetClassPtr( (CCrossbowBolt *)NULL );
pBolt->pev->classname = MAKE_STRING("crossbow_bolt"); // g-cont. enable save\restore pBolt->pev->classname = MAKE_STRING( "crossbow_bolt" ); // g-cont. enable save\restore
pBolt->Spawn(); pBolt->Spawn();
return pBolt; return pBolt;
} }
void CCrossbowBolt::Spawn( ) void CCrossbowBolt::Spawn()
{ {
Precache( ); Precache();
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
pev->gravity = 0.5; pev->gravity = 0.5;
SET_MODEL(ENT(pev), "models/crossbow_bolt.mdl"); SET_MODEL( ENT( pev ), "models/crossbow_bolt.mdl" );
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
SetTouch( &CCrossbowBolt::BoltTouch ); SetTouch( &CCrossbowBolt::BoltTouch );
SetThink( &CCrossbowBolt::BubbleThink ); SetThink( &CCrossbowBolt::BubbleThink );
pev->nextthink = gpGlobals->time + 0.2; pev->nextthink = gpGlobals->time + 0.2;
} }
void CCrossbowBolt::Precache()
void CCrossbowBolt::Precache( )
{ {
PRECACHE_MODEL ("models/crossbow_bolt.mdl"); PRECACHE_MODEL( "models/crossbow_bolt.mdl" );
PRECACHE_SOUND("weapons/xbow_hitbod1.wav"); PRECACHE_SOUND( "weapons/xbow_hitbod1.wav" );
PRECACHE_SOUND("weapons/xbow_hitbod2.wav"); PRECACHE_SOUND( "weapons/xbow_hitbod2.wav" );
PRECACHE_SOUND("weapons/xbow_fly1.wav"); PRECACHE_SOUND( "weapons/xbow_fly1.wav" );
PRECACHE_SOUND("weapons/xbow_hit1.wav"); PRECACHE_SOUND( "weapons/xbow_hit1.wav" );
PRECACHE_SOUND("fvox/beep.wav"); PRECACHE_SOUND( "fvox/beep.wav" );
m_iTrail = PRECACHE_MODEL("sprites/streak.spr"); m_iTrail = PRECACHE_MODEL( "sprites/streak.spr" );
} }
int CCrossbowBolt::Classify( void )
int CCrossbowBolt :: Classify ( void )
{ {
return CLASS_NONE; return CLASS_NONE;
} }
@ -99,71 +98,73 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther )
SetTouch( NULL ); SetTouch( NULL );
SetThink( NULL ); SetThink( NULL );
if (pOther->pev->takedamage) if( pOther->pev->takedamage )
{ {
TraceResult tr = UTIL_GetGlobalTrace( ); TraceResult tr = UTIL_GetGlobalTrace();
entvars_t *pevOwner; entvars_t *pevOwner;
pevOwner = VARS( pev->owner ); pevOwner = VARS( pev->owner );
// UNDONE: this needs to call TraceAttack instead // UNDONE: this needs to call TraceAttack instead
ClearMultiDamage( ); ClearMultiDamage();
if ( pOther->IsPlayer() ) if( pOther->IsPlayer() )
{ {
pOther->TraceAttack(pevOwner, gSkillData.plrDmgCrossbowClient, pev->velocity.Normalize(), &tr, DMG_NEVERGIB ); pOther->TraceAttack( pevOwner, gSkillData.plrDmgCrossbowClient, pev->velocity.Normalize(), &tr, DMG_NEVERGIB );
} }
else else
{ {
pOther->TraceAttack(pevOwner, gSkillData.plrDmgCrossbowMonster, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_NEVERGIB ); pOther->TraceAttack( pevOwner, gSkillData.plrDmgCrossbowMonster, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_NEVERGIB );
} }
ApplyMultiDamage( pev, pevOwner ); ApplyMultiDamage( pev, pevOwner );
pev->velocity = Vector( 0, 0, 0 ); pev->velocity = Vector( 0, 0, 0 );
// play body "thwack" sound // play body "thwack" sound
switch( RANDOM_LONG(0,1) ) switch( RANDOM_LONG( 0, 1 ) )
{ {
case 0: case 0:
EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM); break; EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM );
break;
case 1: case 1:
EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM); break; EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM );
break;
} }
if ( !g_pGameRules->IsMultiplayer() ) if( !g_pGameRules->IsMultiplayer() )
{ {
Killed( pev, GIB_NEVER ); Killed( pev, GIB_NEVER );
} }
} }
else else
{ {
EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0,7)); EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 7 ) );
SetThink( &CBaseEntity::SUB_Remove ); SetThink( &CBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit. pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit.
if ( FClassnameIs( pOther->pev, "worldspawn" ) ) if( FClassnameIs( pOther->pev, "worldspawn" ) )
{ {
// if what we hit is static architecture, can stay around for a while. // if what we hit is static architecture, can stay around for a while.
Vector vecDir = pev->velocity.Normalize( ); Vector vecDir = pev->velocity.Normalize();
UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); UTIL_SetOrigin( pev, pev->origin - vecDir * 12 );
pev->angles = UTIL_VecToAngles( vecDir ); pev->angles = UTIL_VecToAngles( vecDir );
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
pev->velocity = Vector( 0, 0, 0 ); pev->velocity = Vector( 0, 0, 0 );
pev->avelocity.z = 0; pev->avelocity.z = 0;
pev->angles.z = RANDOM_LONG(0,360); pev->angles.z = RANDOM_LONG( 0, 360 );
pev->nextthink = gpGlobals->time + 10.0; pev->nextthink = gpGlobals->time + 10.0;
} }
else if ( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP ) else if( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP )
{ {
Vector vecDir = pev->velocity.Normalize( ); Vector vecDir = pev->velocity.Normalize();
UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); UTIL_SetOrigin( pev, pev->origin - vecDir * 12 );
pev->angles = UTIL_VecToAngles( vecDir ); pev->angles = UTIL_VecToAngles( vecDir );
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->velocity = Vector( 0, 0, 0 ); pev->velocity = Vector( 0, 0, 0 );
pev->avelocity.z = 0; pev->avelocity.z = 0;
pev->angles.z = RANDOM_LONG(0,360); pev->angles.z = RANDOM_LONG( 0, 360 );
pev->nextthink = gpGlobals->time + 10.0; pev->nextthink = gpGlobals->time + 10.0;
// g-cont. Setup movewith feature // g-cont. Setup movewith feature
@ -171,13 +172,13 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther )
pev->aiment = ENT( pOther->pev ); // set parent pev->aiment = ENT( pOther->pev ); // set parent
} }
if (UTIL_PointContents(pev->origin) != CONTENTS_WATER) if( UTIL_PointContents( pev->origin ) != CONTENTS_WATER )
{ {
UTIL_Sparks( pev->origin ); UTIL_Sparks( pev->origin );
} }
} }
if ( g_pGameRules->IsMultiplayer() ) if( g_pGameRules->IsMultiplayer() )
{ {
SetThink( &CCrossbowBolt::ExplodeThink ); SetThink( &CCrossbowBolt::ExplodeThink );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
@ -188,7 +189,7 @@ void CCrossbowBolt::BubbleThink( void )
{ {
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
if (pev->waterlevel == 0) if( pev->waterlevel == 0 )
return; return;
UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 ); UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 );
@ -196,18 +197,18 @@ void CCrossbowBolt::BubbleThink( void )
void CCrossbowBolt::ExplodeThink( void ) void CCrossbowBolt::ExplodeThink( void )
{ {
int iContents = UTIL_PointContents ( pev->origin ); int iContents = UTIL_PointContents( pev->origin );
int iScale; int iScale;
pev->dmg = 40; pev->dmg = 40;
iScale = 10; iScale = 10;
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_EXPLOSION); WRITE_BYTE( TE_EXPLOSION );
WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
if (iContents != CONTENTS_WATER) if( iContents != CONTENTS_WATER )
{ {
WRITE_SHORT( g_sModelIndexFireball ); WRITE_SHORT( g_sModelIndexFireball );
} }
@ -222,7 +223,7 @@ void CCrossbowBolt::ExplodeThink( void )
entvars_t *pevOwner; entvars_t *pevOwner;
if ( pev->owner ) if( pev->owner )
pevOwner = VARS( pev->owner ); pevOwner = VARS( pev->owner );
else else
pevOwner = NULL; pevOwner = NULL;
@ -231,11 +232,12 @@ void CCrossbowBolt::ExplodeThink( void )
::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, 128, CLASS_NONE, DMG_BLAST | DMG_ALWAYSGIB ); ::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, 128, CLASS_NONE, DMG_BLAST | DMG_ALWAYSGIB );
UTIL_Remove(this); UTIL_Remove( this );
} }
#endif #endif
enum crossbow_e { enum crossbow_e
{
CROSSBOW_IDLE1 = 0, // full CROSSBOW_IDLE1 = 0, // full
CROSSBOW_IDLE2, // empty CROSSBOW_IDLE2, // empty
CROSSBOW_FIDGET1, // full CROSSBOW_FIDGET1, // full
@ -247,16 +249,16 @@ enum crossbow_e {
CROSSBOW_DRAW1, // full CROSSBOW_DRAW1, // full
CROSSBOW_DRAW2, // empty CROSSBOW_DRAW2, // empty
CROSSBOW_HOLSTER1, // full CROSSBOW_HOLSTER1, // full
CROSSBOW_HOLSTER2, // empty CROSSBOW_HOLSTER2 // empty
}; };
LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow ); LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow )
void CCrossbow::Spawn( ) void CCrossbow::Spawn()
{ {
Precache( ); Precache();
m_iId = WEAPON_CROSSBOW; m_iId = WEAPON_CROSSBOW;
SET_MODEL(ENT(pev), "models/w_crossbow.mdl"); SET_MODEL( ENT( pev ), "models/w_crossbow.mdl" );
m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE; m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE;
@ -265,7 +267,7 @@ void CCrossbow::Spawn( )
int CCrossbow::AddToPlayer( CBasePlayer *pPlayer ) int CCrossbow::AddToPlayer( CBasePlayer *pPlayer )
{ {
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{ {
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId ); WRITE_BYTE( m_iId );
@ -277,12 +279,12 @@ int CCrossbow::AddToPlayer( CBasePlayer *pPlayer )
void CCrossbow::Precache( void ) void CCrossbow::Precache( void )
{ {
PRECACHE_MODEL("models/w_crossbow.mdl"); PRECACHE_MODEL( "models/w_crossbow.mdl" );
PRECACHE_MODEL("models/v_crossbow.mdl"); PRECACHE_MODEL( "models/v_crossbow.mdl" );
PRECACHE_MODEL("models/p_crossbow.mdl"); PRECACHE_MODEL( "models/p_crossbow.mdl" );
PRECACHE_SOUND("weapons/xbow_fire1.wav"); PRECACHE_SOUND( "weapons/xbow_fire1.wav" );
PRECACHE_SOUND("weapons/xbow_reload1.wav"); PRECACHE_SOUND( "weapons/xbow_reload1.wav" );
UTIL_PrecacheOther( "crossbow_bolt" ); UTIL_PrecacheOther( "crossbow_bolt" );
@ -290,10 +292,9 @@ void CCrossbow::Precache( void )
m_usCrossbow2 = PRECACHE_EVENT( 1, "events/crossbow2.sc" ); m_usCrossbow2 = PRECACHE_EVENT( 1, "events/crossbow2.sc" );
} }
int CCrossbow::GetItemInfo( ItemInfo *p )
int CCrossbow::GetItemInfo(ItemInfo *p)
{ {
p->pszName = STRING(pev->classname); p->pszName = STRING( pev->classname );
p->pszAmmo1 = "bolts"; p->pszAmmo1 = "bolts";
p->iMaxAmmo1 = BOLT_MAX_CARRY; p->iMaxAmmo1 = BOLT_MAX_CARRY;
p->pszAmmo2 = NULL; p->pszAmmo2 = NULL;
@ -307,10 +308,9 @@ int CCrossbow::GetItemInfo(ItemInfo *p)
return 1; return 1;
} }
BOOL CCrossbow::Deploy()
BOOL CCrossbow::Deploy( )
{ {
if (m_iClip) if( m_iClip )
return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW1, "bow" ); return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW1, "bow" );
return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW2, "bow" ); return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW2, "bow" );
} }
@ -319,13 +319,13 @@ void CCrossbow::Holster( int skiplocal /* = 0 */ )
{ {
m_fInReload = FALSE;// cancel any reload in progress. m_fInReload = FALSE;// cancel any reload in progress.
if ( m_fInZoom ) if( m_fInZoom )
{ {
SecondaryAttack( ); SecondaryAttack();
} }
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
if (m_iClip) if( m_iClip )
SendWeaponAnim( CROSSBOW_HOLSTER1 ); SendWeaponAnim( CROSSBOW_HOLSTER1 );
else else
SendWeaponAnim( CROSSBOW_HOLSTER2 ); SendWeaponAnim( CROSSBOW_HOLSTER2 );
@ -333,11 +333,10 @@ void CCrossbow::Holster( int skiplocal /* = 0 */ )
void CCrossbow::PrimaryAttack( void ) void CCrossbow::PrimaryAttack( void )
{ {
#ifdef CLIENT_DLL #ifdef CLIENT_DLL
if ( m_fInZoom && bIsMultiplayer() ) if( m_fInZoom && bIsMultiplayer() )
#else #else
if ( m_fInZoom && g_pGameRules->IsMultiplayer() ) if( m_fInZoom && g_pGameRules->IsMultiplayer() )
#endif #endif
{ {
FireSniperBolt(); FireSniperBolt();
@ -352,9 +351,9 @@ void CCrossbow::FireSniperBolt()
{ {
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
if (m_iClip == 0) if( m_iClip == 0 )
{ {
PlayEmptySound( ); PlayEmptySound();
return; return;
} }
@ -377,16 +376,16 @@ void CCrossbow::FireSniperBolt()
Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
UTIL_MakeVectors( anglesAim ); UTIL_MakeVectors( anglesAim );
Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2; Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2;
Vector vecDir = gpGlobals->v_forward; Vector vecDir = gpGlobals->v_forward;
UTIL_TraceLine(vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr); UTIL_TraceLine( vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr );
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
if ( tr.pHit->v.takedamage ) if( tr.pHit->v.takedamage )
{ {
ClearMultiDamage( ); ClearMultiDamage();
CBaseEntity::Instance(tr.pHit)->TraceAttack(m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB ); CBaseEntity::Instance( tr.pHit )->TraceAttack( m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB );
ApplyMultiDamage( pev, m_pPlayer->pev ); ApplyMultiDamage( pev, m_pPlayer->pev );
} }
#endif #endif
@ -396,9 +395,9 @@ void CCrossbow::FireBolt()
{ {
TraceResult tr; TraceResult tr;
if (m_iClip == 0) if( m_iClip == 0 )
{ {
PlayEmptySound( ); PlayEmptySound();
return; return;
} }
@ -422,7 +421,7 @@ void CCrossbow::FireBolt()
UTIL_MakeVectors( anglesAim ); UTIL_MakeVectors( anglesAim );
anglesAim.x = -anglesAim.x; anglesAim.x = -anglesAim.x;
Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2; Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2;
Vector vecDir = gpGlobals->v_forward; Vector vecDir = gpGlobals->v_forward;
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
@ -431,7 +430,7 @@ void CCrossbow::FireBolt()
pBolt->pev->angles = anglesAim; pBolt->pev->angles = anglesAim;
pBolt->pev->owner = m_pPlayer->edict(); pBolt->pev->owner = m_pPlayer->edict();
if (m_pPlayer->pev->waterlevel == 3) if( m_pPlayer->pev->waterlevel == 3 )
{ {
pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY; pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY;
pBolt->pev->speed = BOLT_WATER_VELOCITY; pBolt->pev->speed = BOLT_WATER_VELOCITY;
@ -444,29 +443,28 @@ void CCrossbow::FireBolt()
pBolt->pev->avelocity.z = 10; pBolt->pev->avelocity.z = 10;
#endif #endif
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition // HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75;
if (m_iClip != 0) if( m_iClip != 0 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
else else
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
} }
void CCrossbow::SecondaryAttack() void CCrossbow::SecondaryAttack()
{ {
if ( m_pPlayer->pev->fov != 0 ) if( m_pPlayer->pev->fov != 0 )
{ {
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
m_fInZoom = 0; m_fInZoom = 0;
} }
else if ( m_pPlayer->pev->fov != 20 ) else if( m_pPlayer->pev->fov != 20 )
{ {
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 20; m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 20;
m_fInZoom = 1; m_fInZoom = 1;
@ -476,36 +474,34 @@ void CCrossbow::SecondaryAttack()
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
} }
void CCrossbow::Reload( void ) void CCrossbow::Reload( void )
{ {
if ( m_pPlayer->ammo_bolts <= 0 ) if( m_pPlayer->ammo_bolts <= 0 )
return; return;
if ( m_pPlayer->pev->fov != 0 ) if( m_pPlayer->pev->fov != 0 )
{ {
SecondaryAttack(); SecondaryAttack();
} }
if ( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) ) if( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) )
{ {
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0,0xF)); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) );
} }
} }
void CCrossbow::WeaponIdle( void ) void CCrossbow::WeaponIdle( void )
{ {
m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM
ResetEmptySound( ); ResetEmptySound();
if ( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{ {
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if (flRand <= 0.75) if( flRand <= 0.75 )
{ {
if (m_iClip) if( m_iClip )
{ {
SendWeaponAnim( CROSSBOW_IDLE1 ); SendWeaponAnim( CROSSBOW_IDLE1 );
} }
@ -517,7 +513,7 @@ void CCrossbow::WeaponIdle( void )
} }
else else
{ {
if (m_iClip) if( m_iClip )
{ {
SendWeaponAnim( CROSSBOW_FIDGET1 ); SendWeaponAnim( CROSSBOW_FIDGET1 );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0;
@ -532,33 +528,29 @@ void CCrossbow::WeaponIdle( void )
} }
} }
class CCrossbowAmmo : public CBasePlayerAmmo class CCrossbowAmmo : public CBasePlayerAmmo
{ {
void Spawn( void ) void Spawn( void )
{ {
Precache( ); Precache();
SET_MODEL(ENT(pev), "models/w_crossbow_clip.mdl"); SET_MODEL( ENT( pev ), "models/w_crossbow_clip.mdl" );
CBasePlayerAmmo::Spawn( ); CBasePlayerAmmo::Spawn();
} }
void Precache( void ) void Precache( void )
{ {
PRECACHE_MODEL ("models/w_crossbow_clip.mdl"); PRECACHE_MODEL( "models/w_crossbow_clip.mdl" );
PRECACHE_SOUND("items/9mmclip1.wav"); PRECACHE_SOUND( "items/9mmclip1.wav" );
} }
BOOL AddAmmo( CBaseEntity *pOther ) BOOL AddAmmo( CBaseEntity *pOther )
{ {
if (pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1) if( pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1 )
{ {
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
}; };
LINK_ENTITY_TO_CLASS( ammo_crossbow, CCrossbowAmmo );
LINK_ENTITY_TO_CLASS( ammo_crossbow, CCrossbowAmmo )
#endif #endif

View File

@ -22,15 +22,13 @@
#include "player.h" #include "player.h"
#include "gamerules.h" #include "gamerules.h"
#define CROWBAR_BODYHIT_VOLUME 128 #define CROWBAR_BODYHIT_VOLUME 128
#define CROWBAR_WALLHIT_VOLUME 512 #define CROWBAR_WALLHIT_VOLUME 512
LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ); LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar )
enum gauss_e
{
enum gauss_e {
CROWBAR_IDLE = 0, CROWBAR_IDLE = 0,
CROWBAR_DRAW, CROWBAR_DRAW,
CROWBAR_HOLSTER, CROWBAR_HOLSTER,
@ -45,33 +43,32 @@ enum gauss_e {
void CCrowbar::Spawn( ) void CCrowbar::Spawn( )
{ {
Precache( ); Precache();
m_iId = WEAPON_CROWBAR; m_iId = WEAPON_CROWBAR;
SET_MODEL(ENT(pev), "models/w_crowbar.mdl"); SET_MODEL( ENT( pev ), "models/w_crowbar.mdl" );
m_iClip = -1; m_iClip = -1;
FallInit();// get ready to fall down. FallInit();// get ready to fall down.
} }
void CCrowbar::Precache( void ) void CCrowbar::Precache( void )
{ {
PRECACHE_MODEL("models/v_crowbar.mdl"); PRECACHE_MODEL( "models/v_crowbar.mdl ");
PRECACHE_MODEL("models/w_crowbar.mdl"); PRECACHE_MODEL( "models/w_crowbar.mdl ");
PRECACHE_MODEL("models/p_crowbar.mdl"); PRECACHE_MODEL( "models/p_crowbar.mdl ");
PRECACHE_SOUND("weapons/cbar_hit1.wav"); PRECACHE_SOUND( "weapons/cbar_hit1.wav ");
PRECACHE_SOUND("weapons/cbar_hit2.wav"); PRECACHE_SOUND( "weapons/cbar_hit2.wav ");
PRECACHE_SOUND("weapons/cbar_hitbod1.wav"); PRECACHE_SOUND( "weapons/cbar_hitbod1.wav ");
PRECACHE_SOUND("weapons/cbar_hitbod2.wav"); PRECACHE_SOUND( "weapons/cbar_hitbod2.wav ");
PRECACHE_SOUND("weapons/cbar_hitbod3.wav"); PRECACHE_SOUND( "weapons/cbar_hitbod3.wav ");
PRECACHE_SOUND("weapons/cbar_miss1.wav"); PRECACHE_SOUND( "weapons/cbar_miss1.wav ");
m_usCrowbar = PRECACHE_EVENT ( 1, "events/crowbar.sc" ); m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" );
} }
int CCrowbar::GetItemInfo(ItemInfo *p) int CCrowbar::GetItemInfo( ItemInfo *p )
{ {
p->pszName = STRING(pev->classname); p->pszName = STRING( pev->classname );
p->pszAmmo1 = NULL; p->pszAmmo1 = NULL;
p->iMaxAmmo1 = -1; p->iMaxAmmo1 = -1;
p->pszAmmo2 = NULL; p->pszAmmo2 = NULL;
@ -84,9 +81,7 @@ int CCrowbar::GetItemInfo(ItemInfo *p)
return 1; return 1;
} }
BOOL CCrowbar::Deploy()
BOOL CCrowbar::Deploy( )
{ {
return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" );
} }
@ -97,7 +92,6 @@ void CCrowbar::Holster( int skiplocal /* = 0 */ )
SendWeaponAnim( CROWBAR_HOLSTER ); SendWeaponAnim( CROWBAR_HOLSTER );
} }
void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity ) void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
{ {
int i, j, k; int i, j, k;
@ -109,29 +103,29 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f
distance = 1e6f; distance = 1e6f;
vecHullEnd = vecSrc + ((vecHullEnd - vecSrc)*2); vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 );
UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace ); UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace );
if ( tmpTrace.flFraction < 1.0 ) if( tmpTrace.flFraction < 1.0 )
{ {
tr = tmpTrace; tr = tmpTrace;
return; return;
} }
for ( i = 0; i < 2; i++ ) for( i = 0; i < 2; i++ )
{ {
for ( j = 0; j < 2; j++ ) for( j = 0; j < 2; j++ )
{ {
for ( k = 0; k < 2; k++ ) for( k = 0; k < 2; k++ )
{ {
vecEnd.x = vecHullEnd.x + minmaxs[i][0]; vecEnd.x = vecHullEnd.x + minmaxs[i][0];
vecEnd.y = vecHullEnd.y + minmaxs[j][1]; vecEnd.y = vecHullEnd.y + minmaxs[j][1];
vecEnd.z = vecHullEnd.z + minmaxs[k][2]; vecEnd.z = vecHullEnd.z + minmaxs[k][2];
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace ); UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace );
if ( tmpTrace.flFraction < 1.0 ) if( tmpTrace.flFraction < 1.0 )
{ {
float thisDistance = (tmpTrace.vecEndPos - vecSrc).Length(); float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length();
if ( thisDistance < distance ) if( thisDistance < distance )
{ {
tr = tmpTrace; tr = tmpTrace;
distance = thisDistance; distance = thisDistance;
@ -142,65 +136,59 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f
} }
} }
void CCrowbar::PrimaryAttack() void CCrowbar::PrimaryAttack()
{ {
if (! Swing( 1 )) if( !Swing( 1 ) )
{ {
SetThink( &CCrowbar::SwingAgain ); SetThink( &CCrowbar::SwingAgain );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
} }
} }
void CCrowbar::Smack()
void CCrowbar::Smack( )
{ {
DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR ); DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR );
} }
void CCrowbar::SwingAgain( void ) void CCrowbar::SwingAgain( void )
{ {
Swing( 0 ); Swing( 0 );
} }
int CCrowbar::Swing( int fFirst ) int CCrowbar::Swing( int fFirst )
{ {
int fDidHit = FALSE; int fDidHit = FALSE;
TraceResult tr; TraceResult tr;
UTIL_MakeVectors (m_pPlayer->pev->v_angle); UTIL_MakeVectors( m_pPlayer->pev->v_angle );
Vector vecSrc = m_pPlayer->GetGunPosition( ); Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
if ( tr.flFraction >= 1.0 ) if( tr.flFraction >= 1.0 )
{ {
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr ); UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if ( tr.flFraction < 1.0 ) if( tr.flFraction < 1.0 )
{ {
// Calculate the point of intersection of the line (or hull) and the object we hit // Calculate the point of intersection of the line (or hull) and the object we hit
// This is and approximation of the "best" intersection // This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit ); CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );
if ( !pHit || pHit->IsBSPModel() ) if( !pHit || pHit->IsBSPModel() )
FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() ); FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space) vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
} }
} }
#endif #endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar,
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
0.0, 0, 0.0 ); 0.0, 0, 0.0 );
if( tr.flFraction >= 1.0 )
if ( tr.flFraction >= 1.0 )
{ {
if (fFirst) if( fFirst )
{ {
// miss // miss
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
@ -211,36 +199,38 @@ int CCrowbar::Swing( int fFirst )
} }
else else
{ {
switch( ((m_iSwing++) % 2) + 1 ) switch( ( ( m_iSwing++ ) % 2 ) + 1 )
{ {
case 0: case 0:
SendWeaponAnim( CROWBAR_ATTACK1HIT ); break; SendWeaponAnim( CROWBAR_ATTACK1HIT );
break;
case 1: case 1:
SendWeaponAnim( CROWBAR_ATTACK2HIT ); break; SendWeaponAnim( CROWBAR_ATTACK2HIT );
break;
case 2: case 2:
SendWeaponAnim( CROWBAR_ATTACK3HIT ); break; SendWeaponAnim( CROWBAR_ATTACK3HIT );
break;
} }
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
// hit // hit
fDidHit = TRUE; fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
ClearMultiDamage( ); ClearMultiDamage();
if ( (m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
{ {
// first swing does full damage // first swing does full damage
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB );
} }
else else
{ {
// subsequent swings do half // subsequent swings do half
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB );
} }
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
@ -248,22 +238,25 @@ int CCrowbar::Swing( int fFirst )
float flVol = 1.0; float flVol = 1.0;
int fHitWorld = TRUE; int fHitWorld = TRUE;
if (pEntity) if( pEntity )
{ {
if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{ {
// play thwack or smack sound // play thwack or smack sound
switch( RANDOM_LONG(0,2) ) switch( RANDOM_LONG( 0, 2 ) )
{ {
case 0: case 0:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); break; EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM );
break;
case 1: case 1:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM); break; EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM );
break;
case 2: case 2:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM); break; EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM );
break;
} }
m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME; m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() ) if( !pEntity->IsAlive() )
return TRUE; return TRUE;
else else
flVol = 0.1; flVol = 0.1;
@ -275,11 +268,11 @@ int CCrowbar::Swing( int fFirst )
// play texture hit sound // play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line // UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if (fHitWorld) if( fHitWorld )
{ {
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR); float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR );
if ( g_pGameRules->IsMultiplayer() ) if( g_pGameRules->IsMultiplayer() )
{ {
// override the volume here, cause we don't play texture sounds in multiplayer, // override the volume here, cause we don't play texture sounds in multiplayer,
// and fvolbar is going to be 0 from the above call. // and fvolbar is going to be 0 from the above call.
@ -288,13 +281,13 @@ int CCrowbar::Swing( int fFirst )
} }
// also play crowbar strike // also play crowbar strike
switch( RANDOM_LONG(0,1) ) switch( RANDOM_LONG( 0, 1 ) )
{ {
case 0: case 0:
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3)); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
break; break;
case 1: case 1:
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3)); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
break; break;
} }
@ -308,11 +301,6 @@ int CCrowbar::Swing( int fFirst )
SetThink( &CCrowbar::Smack ); SetThink( &CCrowbar::Smack );
pev->nextthink = UTIL_WeaponTimeBase() + 0.2; pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
} }
return fDidHit; return fDidHit;
} }

View File

@ -61,7 +61,7 @@ enum decal_e
DECAL_SMALLSCORCH2, // Small scorch mark DECAL_SMALLSCORCH2, // Small scorch mark
DECAL_SMALLSCORCH3, // Small scorch mark DECAL_SMALLSCORCH3, // Small scorch mark
DECAL_MOMMABIRTH, // Big momma birth splatter DECAL_MOMMABIRTH, // Big momma birth splatter
DECAL_MOMMASPLAT, DECAL_MOMMASPLAT
}; };
typedef struct typedef struct
@ -71,5 +71,4 @@ typedef struct
} DLL_DECALLIST; } DLL_DECALLIST;
extern DLL_DECALLIST gDecals[]; extern DLL_DECALLIST gDecals[];
#endif //DECALS_H
#endif // DECALS_H

View File

@ -40,7 +40,7 @@ Schedule_t slFail[] =
{ {
{ {
tlFail, tlFail,
ARRAYSIZE ( tlFail ), ARRAYSIZE( tlFail ),
bits_COND_CAN_ATTACK, bits_COND_CAN_ATTACK,
0, 0,
"Fail" "Fail"
@ -54,14 +54,14 @@ Task_t tlIdleStand1[] =
{ {
{ TASK_STOP_MOVING, 0 }, { TASK_STOP_MOVING, 0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE }, { TASK_SET_ACTIVITY, (float)ACT_IDLE },
{ TASK_WAIT, (float)5 },// repick IDLESTAND every five seconds. gives us a chance to pick an active idle, fidget, etc. { TASK_WAIT, (float)5 }, // repick IDLESTAND every five seconds. gives us a chance to pick an active idle, fidget, etc.
}; };
Schedule_t slIdleStand[] = Schedule_t slIdleStand[] =
{ {
{ {
tlIdleStand1, tlIdleStand1,
ARRAYSIZE ( tlIdleStand1 ), ARRAYSIZE( tlIdleStand1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_SEE_FEAR | bits_COND_SEE_FEAR |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -87,7 +87,7 @@ Schedule_t slIdleTrigger[] =
{ {
{ {
tlIdleStand1, tlIdleStand1,
ARRAYSIZE ( tlIdleStand1 ), ARRAYSIZE( tlIdleStand1 ),
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE, bits_COND_HEAVY_DAMAGE,
0, 0,
@ -95,7 +95,6 @@ Schedule_t slIdleTrigger[] =
}, },
}; };
Task_t tlIdleWalk1[] = Task_t tlIdleWalk1[] =
{ {
{ TASK_WALK_PATH, (float)9999 }, { TASK_WALK_PATH, (float)9999 },
@ -106,7 +105,7 @@ Schedule_t slIdleWalk[] =
{ {
{ {
tlIdleWalk1, tlIdleWalk1,
ARRAYSIZE ( tlIdleWalk1 ), ARRAYSIZE( tlIdleWalk1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
@ -139,12 +138,11 @@ Schedule_t slAmbush[] =
{ {
{ {
tlAmbush, tlAmbush,
ARRAYSIZE ( tlAmbush ), ARRAYSIZE( tlAmbush ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
bits_COND_PROVOKED, bits_COND_PROVOKED,
0, 0,
"Ambush" "Ambush"
}, },
@ -167,7 +165,7 @@ Task_t tlActiveIdle[] =
{ TASK_WAIT_FOR_MOVEMENT, (float)0 }, { TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_FACE_HINTNODE, (float)0 }, { TASK_FACE_HINTNODE, (float)0 },
{ TASK_PLAY_ACTIVE_IDLE, (float)0 }, { TASK_PLAY_ACTIVE_IDLE, (float)0 },
{ TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, { TASK_GET_PATH_TO_LASTPOSITION, (float)0 },
{ TASK_WALK_PATH, (float)0 }, { TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 }, { TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_CLEAR_LASTPOSITION, (float)0 }, { TASK_CLEAR_LASTPOSITION, (float)0 },
@ -184,7 +182,6 @@ Schedule_t slActiveIdle[] =
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
bits_COND_PROVOKED | bits_COND_PROVOKED |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_COMBAT | bits_SOUND_COMBAT |
bits_SOUND_WORLD | bits_SOUND_WORLD |
bits_SOUND_PLAYER | bits_SOUND_PLAYER |
@ -208,7 +205,7 @@ Schedule_t slWakeAngry[] =
{ {
{ {
tlWakeAngry1, tlWakeAngry1,
ARRAYSIZE ( tlWakeAngry1 ), ARRAYSIZE( tlWakeAngry1 ),
0, 0,
0, 0,
"Wake Angry" "Wake Angry"
@ -229,7 +226,7 @@ Schedule_t slAlertFace[] =
{ {
{ {
tlAlertFace1, tlAlertFace1,
ARRAYSIZE ( tlAlertFace1 ), ARRAYSIZE( tlAlertFace1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_SEE_FEAR | bits_COND_SEE_FEAR |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -256,7 +253,7 @@ Schedule_t slAlertSmallFlinch[] =
{ {
{ {
tlAlertSmallFlinch, tlAlertSmallFlinch,
ARRAYSIZE ( tlAlertSmallFlinch ), ARRAYSIZE( tlAlertSmallFlinch ),
0, 0,
0, 0,
"Alert Small Flinch" "Alert Small Flinch"
@ -278,7 +275,7 @@ Schedule_t slAlertStand[] =
{ {
{ {
tlAlertStand1, tlAlertStand1,
ARRAYSIZE ( tlAlertStand1 ), ARRAYSIZE( tlAlertStand1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_SEE_ENEMY | bits_COND_SEE_ENEMY |
bits_COND_SEE_FEAR | bits_COND_SEE_FEAR |
@ -288,12 +285,10 @@ Schedule_t slAlertStand[] =
bits_COND_SMELL | bits_COND_SMELL |
bits_COND_SMELL_FOOD | bits_COND_SMELL_FOOD |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_COMBAT |// sound flags bits_SOUND_COMBAT |// sound flags
bits_SOUND_WORLD | bits_SOUND_WORLD |
bits_SOUND_PLAYER | bits_SOUND_PLAYER |
bits_SOUND_DANGER | bits_SOUND_DANGER |
bits_SOUND_MEAT |// scent flags bits_SOUND_MEAT |// scent flags
bits_SOUND_CARCASS | bits_SOUND_CARCASS |
bits_SOUND_GARBAGE, bits_SOUND_GARBAGE,
@ -325,13 +320,12 @@ Schedule_t slInvestigateSound[] =
{ {
{ {
tlInvestigateSound, tlInvestigateSound,
ARRAYSIZE ( tlInvestigateSound ), ARRAYSIZE( tlInvestigateSound ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_SEE_FEAR | bits_COND_SEE_FEAR |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"InvestigateSound" "InvestigateSound"
}, },
@ -351,7 +345,7 @@ Schedule_t slCombatStand[] =
{ {
{ {
tlCombatStand1, tlCombatStand1,
ARRAYSIZE ( tlCombatStand1 ), ARRAYSIZE( tlCombatStand1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -376,7 +370,7 @@ Schedule_t slCombatFace[] =
{ {
{ {
tlCombatFace1, tlCombatFace1,
ARRAYSIZE ( tlCombatFace1 ), ARRAYSIZE( tlCombatFace1 ),
bits_COND_CAN_ATTACK | bits_COND_CAN_ATTACK |
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD, bits_COND_ENEMY_DEAD,
@ -401,13 +395,12 @@ Schedule_t slStandoff[] =
{ {
{ {
tlStandoff, tlStandoff,
ARRAYSIZE ( tlStandoff ), ARRAYSIZE( tlStandoff ),
bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Standoff" "Standoff"
} }
@ -419,14 +412,14 @@ Schedule_t slStandoff[] =
Task_t tlArmWeapon[] = Task_t tlArmWeapon[] =
{ {
{ TASK_STOP_MOVING, 0 }, { TASK_STOP_MOVING, 0 },
{ TASK_PLAY_SEQUENCE, (float) ACT_ARM } { TASK_PLAY_SEQUENCE, (float)ACT_ARM }
}; };
Schedule_t slArmWeapon[] = Schedule_t slArmWeapon[] =
{ {
{ {
tlArmWeapon, tlArmWeapon,
ARRAYSIZE ( tlArmWeapon ), ARRAYSIZE( tlArmWeapon ),
0, 0,
0, 0,
"Arm Weapon" "Arm Weapon"
@ -446,7 +439,7 @@ Schedule_t slReload[] =
{ {
{ {
tlReload, tlReload,
ARRAYSIZE ( tlReload ), ARRAYSIZE( tlReload ),
bits_COND_HEAVY_DAMAGE, bits_COND_HEAVY_DAMAGE,
0, 0,
"Reload" "Reload"
@ -469,7 +462,7 @@ Schedule_t slRangeAttack1[] =
{ {
{ {
tlRangeAttack1, tlRangeAttack1,
ARRAYSIZE ( tlRangeAttack1 ), ARRAYSIZE( tlRangeAttack1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -477,7 +470,6 @@ Schedule_t slRangeAttack1[] =
bits_COND_ENEMY_OCCLUDED | bits_COND_ENEMY_OCCLUDED |
bits_COND_NO_AMMO_LOADED | bits_COND_NO_AMMO_LOADED |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Range Attack1" "Range Attack1"
}, },
@ -495,14 +487,13 @@ Schedule_t slRangeAttack2[] =
{ {
{ {
tlRangeAttack2, tlRangeAttack2,
ARRAYSIZE ( tlRangeAttack2 ), ARRAYSIZE( tlRangeAttack2 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE | bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED | bits_COND_ENEMY_OCCLUDED |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Range Attack2" "Range Attack2"
}, },
@ -520,7 +511,7 @@ Schedule_t slPrimaryMeleeAttack[] =
{ {
{ {
tlPrimaryMeleeAttack1, tlPrimaryMeleeAttack1,
ARRAYSIZE ( tlPrimaryMeleeAttack1 ), ARRAYSIZE( tlPrimaryMeleeAttack1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -536,14 +527,14 @@ Task_t tlSecondaryMeleeAttack1[] =
{ {
{ TASK_STOP_MOVING, 0 }, { TASK_STOP_MOVING, 0 },
{ TASK_FACE_ENEMY, (float)0 }, { TASK_FACE_ENEMY, (float)0 },
{ TASK_MELEE_ATTACK2, (float)0 }, { TASK_MELEE_ATTACK2, (float)0},
}; };
Schedule_t slSecondaryMeleeAttack[] = Schedule_t slSecondaryMeleeAttack[] =
{ {
{ {
tlSecondaryMeleeAttack1, tlSecondaryMeleeAttack1,
ARRAYSIZE ( tlSecondaryMeleeAttack1 ), ARRAYSIZE( tlSecondaryMeleeAttack1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -566,7 +557,7 @@ Schedule_t slSpecialAttack1[] =
{ {
{ {
tlSpecialAttack1, tlSpecialAttack1,
ARRAYSIZE ( tlSpecialAttack1 ), ARRAYSIZE( tlSpecialAttack1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -574,7 +565,6 @@ Schedule_t slSpecialAttack1[] =
bits_COND_ENEMY_OCCLUDED | bits_COND_ENEMY_OCCLUDED |
bits_COND_NO_AMMO_LOADED | bits_COND_NO_AMMO_LOADED |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Special Attack1" "Special Attack1"
}, },
@ -592,7 +582,7 @@ Schedule_t slSpecialAttack2[] =
{ {
{ {
tlSpecialAttack2, tlSpecialAttack2,
ARRAYSIZE ( tlSpecialAttack2 ), ARRAYSIZE( tlSpecialAttack2 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD | bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE | bits_COND_LIGHT_DAMAGE |
@ -600,7 +590,6 @@ Schedule_t slSpecialAttack2[] =
bits_COND_ENEMY_OCCLUDED | bits_COND_ENEMY_OCCLUDED |
bits_COND_NO_AMMO_LOADED | bits_COND_NO_AMMO_LOADED |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Special Attack2" "Special Attack2"
}, },
@ -619,7 +608,7 @@ Schedule_t slChaseEnemy[] =
{ {
{ {
tlChaseEnemy1, tlChaseEnemy1,
ARRAYSIZE ( tlChaseEnemy1 ), ARRAYSIZE( tlChaseEnemy1 ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 |
@ -627,7 +616,6 @@ Schedule_t slChaseEnemy[] =
bits_COND_CAN_MELEE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2 |
bits_COND_TASK_FAILED | bits_COND_TASK_FAILED |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"Chase Enemy" "Chase Enemy"
}, },
@ -643,7 +631,7 @@ Task_t tlChaseEnemyFailed[] =
{ TASK_RUN_PATH, (float)0 }, { TASK_RUN_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 }, { TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, { TASK_REMEMBER, (float)bits_MEMORY_INCOVER },
// { TASK_TURN_LEFT, (float)179 }, //{ TASK_TURN_LEFT, (float)179 },
{ TASK_FACE_ENEMY, (float)0 }, { TASK_FACE_ENEMY, (float)0 },
{ TASK_WAIT, (float)1 }, { TASK_WAIT, (float)1 },
}; };
@ -652,20 +640,18 @@ Schedule_t slChaseEnemyFailed[] =
{ {
{ {
tlChaseEnemyFailed, tlChaseEnemyFailed,
ARRAYSIZE ( tlChaseEnemyFailed ), ARRAYSIZE( tlChaseEnemyFailed ),
bits_COND_NEW_ENEMY | bits_COND_NEW_ENEMY |
bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_CAN_MELEE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2 |
bits_COND_HEAR_SOUND, bits_COND_HEAR_SOUND,
bits_SOUND_DANGER, bits_SOUND_DANGER,
"tlChaseEnemyFailed" "tlChaseEnemyFailed"
}, },
}; };
//========================================================= //=========================================================
// small flinch, played when minor damage is taken. // small flinch, played when minor damage is taken.
//========================================================= //=========================================================
@ -680,7 +666,7 @@ Schedule_t slSmallFlinch[] =
{ {
{ {
tlSmallFlinch, tlSmallFlinch,
ARRAYSIZE ( tlSmallFlinch ), ARRAYSIZE( tlSmallFlinch ),
0, 0,
0, 0,
"Small Flinch" "Small Flinch"
@ -746,7 +732,7 @@ Schedule_t slBarnacleVictimGrab[] =
{ {
{ {
tlBarnacleVictimGrab, tlBarnacleVictimGrab,
ARRAYSIZE ( tlBarnacleVictimGrab ), ARRAYSIZE( tlBarnacleVictimGrab ),
0, 0,
0, 0,
"Barnacle Victim" "Barnacle Victim"
@ -770,14 +756,13 @@ Schedule_t slBarnacleVictimChomp[] =
{ {
{ {
tlBarnacleVictimChomp, tlBarnacleVictimChomp,
ARRAYSIZE ( tlBarnacleVictimChomp ), ARRAYSIZE( tlBarnacleVictimChomp ),
0, 0,
0, 0,
"Barnacle Chomp" "Barnacle Chomp"
} }
}; };
// Universal Error Schedule // Universal Error Schedule
Task_t tlError[] = Task_t tlError[] =
{ {
@ -789,7 +774,7 @@ Schedule_t slError[] =
{ {
{ {
tlError, tlError,
ARRAYSIZE ( tlError ), ARRAYSIZE( tlError ),
0, 0,
0, 0,
"Error" "Error"
@ -812,18 +797,17 @@ Schedule_t slWalkToScript[] =
{ {
{ {
tlScriptedWalk, tlScriptedWalk,
ARRAYSIZE ( tlScriptedWalk ), ARRAYSIZE( tlScriptedWalk ),
SCRIPT_BREAK_CONDITIONS, SCRIPT_BREAK_CONDITIONS,
0, 0,
"WalkToScript" "WalkToScript"
}, },
}; };
Task_t tlScriptedRun[] = Task_t tlScriptedRun[] =
{ {
{ TASK_RUN_TO_TARGET, (float)TARGET_MOVE_SCRIPTED }, { TASK_RUN_TO_TARGET, (float)TARGET_MOVE_SCRIPTED },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 }, { TASK_WAIT_FOR_MOVEMENT,(float)0 },
{ TASK_PLANT_ON_SCRIPT, (float)0 }, { TASK_PLANT_ON_SCRIPT, (float)0 },
{ TASK_FACE_SCRIPT, (float)0 }, { TASK_FACE_SCRIPT, (float)0 },
{ TASK_FACE_IDEAL, (float)0 }, { TASK_FACE_IDEAL, (float)0 },
@ -836,7 +820,7 @@ Schedule_t slRunToScript[] =
{ {
{ {
tlScriptedRun, tlScriptedRun,
ARRAYSIZE ( tlScriptedRun ), ARRAYSIZE( tlScriptedRun ),
SCRIPT_BREAK_CONDITIONS, SCRIPT_BREAK_CONDITIONS,
0, 0,
"RunToScript" "RunToScript"
@ -854,7 +838,7 @@ Schedule_t slWaitScript[] =
{ {
{ {
tlScriptedWait, tlScriptedWait,
ARRAYSIZE ( tlScriptedWait ), ARRAYSIZE( tlScriptedWait ),
SCRIPT_BREAK_CONDITIONS, SCRIPT_BREAK_CONDITIONS,
0, 0,
"WaitForScript" "WaitForScript"
@ -874,7 +858,7 @@ Schedule_t slFaceScript[] =
{ {
{ {
tlScriptedFace, tlScriptedFace,
ARRAYSIZE ( tlScriptedFace ), ARRAYSIZE( tlScriptedFace ),
SCRIPT_BREAK_CONDITIONS, SCRIPT_BREAK_CONDITIONS,
0, 0,
"FaceScript" "FaceScript"
@ -895,7 +879,7 @@ Schedule_t slCower[] =
{ {
{ {
tlCower, tlCower,
ARRAYSIZE ( tlCower ), ARRAYSIZE( tlCower ),
0, 0,
0, 0,
"Cower" "Cower"
@ -919,7 +903,7 @@ Schedule_t slTakeCoverFromOrigin[] =
{ {
{ {
tlTakeCoverFromOrigin, tlTakeCoverFromOrigin,
ARRAYSIZE ( tlTakeCoverFromOrigin ), ARRAYSIZE( tlTakeCoverFromOrigin ),
bits_COND_NEW_ENEMY, bits_COND_NEW_ENEMY,
0, 0,
"TakeCoverFromOrigin" "TakeCoverFromOrigin"
@ -943,7 +927,7 @@ Schedule_t slTakeCoverFromBestSound[] =
{ {
{ {
tlTakeCoverFromBestSound, tlTakeCoverFromBestSound,
ARRAYSIZE ( tlTakeCoverFromBestSound ), ARRAYSIZE( tlTakeCoverFromBestSound ),
bits_COND_NEW_ENEMY, bits_COND_NEW_ENEMY,
0, 0,
"TakeCoverFromBestSound" "TakeCoverFromBestSound"
@ -962,7 +946,7 @@ Task_t tlTakeCoverFromEnemy[] =
{ TASK_RUN_PATH, (float)0 }, { TASK_RUN_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 }, { TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, { TASK_REMEMBER, (float)bits_MEMORY_INCOVER },
// { TASK_TURN_LEFT, (float)179 }, //{ TASK_TURN_LEFT, (float)179 },
{ TASK_FACE_ENEMY, (float)0 }, { TASK_FACE_ENEMY, (float)0 },
{ TASK_WAIT, (float)1 }, { TASK_WAIT, (float)1 },
}; };
@ -971,7 +955,7 @@ Schedule_t slTakeCoverFromEnemy[] =
{ {
{ {
tlTakeCoverFromEnemy, tlTakeCoverFromEnemy,
ARRAYSIZE ( tlTakeCoverFromEnemy ), ARRAYSIZE( tlTakeCoverFromEnemy ),
bits_COND_NEW_ENEMY, bits_COND_NEW_ENEMY,
0, 0,
"tlTakeCoverFromEnemy" "tlTakeCoverFromEnemy"
@ -1022,29 +1006,27 @@ Schedule_t *CBaseMonster::m_scheduleList[] =
Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) Schedule_t *CBaseMonster::ScheduleFromName( const char *pName )
{ {
return ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) ); return ScheduleInList( pName, m_scheduleList, ARRAYSIZE( m_scheduleList ) );
} }
Schedule_t *CBaseMonster::ScheduleInList( const char *pName, Schedule_t **pList, int listCount )
Schedule_t *CBaseMonster :: ScheduleInList( const char *pName, Schedule_t **pList, int listCount )
{ {
int i; int i;
if ( !pName ) if( !pName )
{ {
ALERT( at_console, "%s set to unnamed schedule!\n", STRING(pev->classname) ); ALERT( at_console, "%s set to unnamed schedule!\n", STRING( pev->classname ) );
return NULL; return NULL;
} }
for( i = 0; i < listCount; i++ )
for ( i = 0; i < listCount; i++ )
{ {
if ( !pList[i]->pName ) if( !pList[i]->pName )
{ {
ALERT( at_console, "Unnamed schedule!\n" ); ALERT( at_console, "Unnamed schedule!\n" );
continue; continue;
} }
if ( stricmp( pName, pList[i]->pName ) == 0 ) if( stricmp( pName, pList[i]->pName ) == 0 )
return pList[i]; return pList[i];
} }
return NULL; return NULL;
@ -1054,25 +1036,25 @@ Schedule_t *CBaseMonster :: ScheduleInList( const char *pName, Schedule_t **pLis
// GetScheduleOfType - returns a pointer to one of the // GetScheduleOfType - returns a pointer to one of the
// monster's available schedules of the indicated type. // monster's available schedules of the indicated type.
//========================================================= //=========================================================
Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) Schedule_t* CBaseMonster::GetScheduleOfType( int Type )
{ {
// ALERT ( at_console, "Sched Type:%d\n", Type ); //ALERT( at_console, "Sched Type:%d\n", Type );
switch ( Type ) switch( Type )
{ {
// This is the schedule for scripted sequences AND scripted AI // This is the schedule for scripted sequences AND scripted AI
case SCHED_AISCRIPT: case SCHED_AISCRIPT:
{ {
ASSERT( m_pCine != NULL ); ASSERT( m_pCine != NULL );
if ( !m_pCine ) if( !m_pCine )
{ {
ALERT( at_aiconsole, "Script failed for %s\n", STRING(pev->classname) ); ALERT( at_aiconsole, "Script failed for %s\n", STRING( pev->classname ) );
CineCleanup(); CineCleanup();
return GetScheduleOfType( SCHED_IDLE_STAND ); return GetScheduleOfType( SCHED_IDLE_STAND );
} }
// else //else
// ALERT( at_aiconsole, "Starting script %s for %s\n", STRING( m_pCine->m_iszPlay ), STRING(pev->classname) ); // ALERT( at_aiconsole, "Starting script %s for %s\n", STRING( m_pCine->m_iszPlay ), STRING( pev->classname ) );
switch ( m_pCine->m_fMoveTo ) switch( m_pCine->m_fMoveTo )
{ {
case 0: case 0:
case 4: case 4:
@ -1088,132 +1070,132 @@ Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type )
} }
case SCHED_IDLE_STAND: case SCHED_IDLE_STAND:
{ {
if ( RANDOM_LONG(0,14) == 0 && FCanActiveIdle() ) if( RANDOM_LONG( 0, 14 ) == 0 && FCanActiveIdle() )
{ {
return &slActiveIdle[ 0 ]; return &slActiveIdle[0];
} }
return &slIdleStand[ 0 ]; return &slIdleStand[0];
} }
case SCHED_IDLE_WALK: case SCHED_IDLE_WALK:
{ {
return &slIdleWalk[ 0 ]; return &slIdleWalk[0];
} }
case SCHED_WAIT_TRIGGER: case SCHED_WAIT_TRIGGER:
{ {
return &slIdleTrigger[ 0 ]; return &slIdleTrigger[0];
} }
case SCHED_WAKE_ANGRY: case SCHED_WAKE_ANGRY:
{ {
return &slWakeAngry[ 0 ]; return &slWakeAngry[0];
} }
case SCHED_ALERT_FACE: case SCHED_ALERT_FACE:
{ {
return &slAlertFace[ 0 ]; return &slAlertFace[0];
} }
case SCHED_ALERT_STAND: case SCHED_ALERT_STAND:
{ {
return &slAlertStand[ 0 ]; return &slAlertStand[0];
} }
case SCHED_COMBAT_STAND: case SCHED_COMBAT_STAND:
{ {
return &slCombatStand[ 0 ]; return &slCombatStand[0];
} }
case SCHED_COMBAT_FACE: case SCHED_COMBAT_FACE:
{ {
return &slCombatFace[ 0 ]; return &slCombatFace[0];
} }
case SCHED_CHASE_ENEMY: case SCHED_CHASE_ENEMY:
{ {
return &slChaseEnemy[ 0 ]; return &slChaseEnemy[0];
} }
case SCHED_CHASE_ENEMY_FAILED: case SCHED_CHASE_ENEMY_FAILED:
{ {
return &slFail[ 0 ]; return &slFail[0];
} }
case SCHED_SMALL_FLINCH: case SCHED_SMALL_FLINCH:
{ {
return &slSmallFlinch[ 0 ]; return &slSmallFlinch[0];
} }
case SCHED_ALERT_SMALL_FLINCH: case SCHED_ALERT_SMALL_FLINCH:
{ {
return &slAlertSmallFlinch[ 0 ]; return &slAlertSmallFlinch[0];
} }
case SCHED_RELOAD: case SCHED_RELOAD:
{ {
return &slReload[ 0 ]; return &slReload[0];
} }
case SCHED_ARM_WEAPON: case SCHED_ARM_WEAPON:
{ {
return &slArmWeapon[ 0 ]; return &slArmWeapon[0];
} }
case SCHED_STANDOFF: case SCHED_STANDOFF:
{ {
return &slStandoff[ 0 ]; return &slStandoff[0];
} }
case SCHED_RANGE_ATTACK1: case SCHED_RANGE_ATTACK1:
{ {
return &slRangeAttack1[ 0 ]; return &slRangeAttack1[0];
} }
case SCHED_RANGE_ATTACK2: case SCHED_RANGE_ATTACK2:
{ {
return &slRangeAttack2[ 0 ]; return &slRangeAttack2[0];
} }
case SCHED_MELEE_ATTACK1: case SCHED_MELEE_ATTACK1:
{ {
return &slPrimaryMeleeAttack[ 0 ]; return &slPrimaryMeleeAttack[0];
} }
case SCHED_MELEE_ATTACK2: case SCHED_MELEE_ATTACK2:
{ {
return &slSecondaryMeleeAttack[ 0 ]; return &slSecondaryMeleeAttack[0];
} }
case SCHED_SPECIAL_ATTACK1: case SCHED_SPECIAL_ATTACK1:
{ {
return &slSpecialAttack1[ 0 ]; return &slSpecialAttack1[0];
} }
case SCHED_SPECIAL_ATTACK2: case SCHED_SPECIAL_ATTACK2:
{ {
return &slSpecialAttack2[ 0 ]; return &slSpecialAttack2[0];
} }
case SCHED_TAKE_COVER_FROM_BEST_SOUND: case SCHED_TAKE_COVER_FROM_BEST_SOUND:
{ {
return &slTakeCoverFromBestSound[ 0 ]; return &slTakeCoverFromBestSound[0];
} }
case SCHED_TAKE_COVER_FROM_ENEMY: case SCHED_TAKE_COVER_FROM_ENEMY:
{ {
return &slTakeCoverFromEnemy[ 0 ]; return &slTakeCoverFromEnemy[0];
} }
case SCHED_COWER: case SCHED_COWER:
{ {
return &slCower[ 0 ]; return &slCower[0];
} }
case SCHED_AMBUSH: case SCHED_AMBUSH:
{ {
return &slAmbush[ 0 ]; return &slAmbush[0];
} }
case SCHED_BARNACLE_VICTIM_GRAB: case SCHED_BARNACLE_VICTIM_GRAB:
{ {
return &slBarnacleVictimGrab[ 0 ]; return &slBarnacleVictimGrab[0];
} }
case SCHED_BARNACLE_VICTIM_CHOMP: case SCHED_BARNACLE_VICTIM_CHOMP:
{ {
return &slBarnacleVictimChomp[ 0 ]; return &slBarnacleVictimChomp[0];
} }
case SCHED_INVESTIGATE_SOUND: case SCHED_INVESTIGATE_SOUND:
{ {
return &slInvestigateSound[ 0 ]; return &slInvestigateSound[0];
} }
case SCHED_DIE: case SCHED_DIE:
{ {
return &slDie[ 0 ]; return &slDie[0];
} }
case SCHED_TAKE_COVER_FROM_ORIGIN: case SCHED_TAKE_COVER_FROM_ORIGIN:
{ {
return &slTakeCoverFromOrigin[ 0 ]; return &slTakeCoverFromOrigin[0];
} }
case SCHED_VICTORY_DANCE: case SCHED_VICTORY_DANCE:
{ {
return &slVictoryDance[ 0 ]; return &slVictoryDance[0];
} }
case SCHED_FAIL: case SCHED_FAIL:
{ {
@ -1221,9 +1203,9 @@ Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type )
} }
default: default:
{ {
ALERT ( at_console, "GetScheduleOfType()\nNo CASE for Schedule Type %d!\n", Type ); ALERT( at_console, "GetScheduleOfType()\nNo CASE for Schedule Type %d!\n", Type );
return &slIdleStand[ 0 ]; return &slIdleStand[0];
break; break;
} }
} }

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More