diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 28 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 27 | ||||
-rw-r--r-- | src/game/bg_public.h | 34 | ||||
-rw-r--r-- | src/game/g_active.c | 45 | ||||
-rw-r--r-- | src/game/g_client.c | 22 | ||||
-rw-r--r-- | src/game/g_combat.c | 2 | ||||
-rw-r--r-- | src/game/g_main.c | 9 |
7 files changed, 108 insertions, 59 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index b4ca57c8..25ade6fd 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -889,6 +889,34 @@ Only in CTF games int bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1; +classModelName_t bg_pModelList[ ] = +{ + { PCL_D_O_BASE, "klesk" }, + { PCL_D_D_BASE, "orbb" }, + { PCL_D_B_BASE, "lucy" }, + { PCL_H_BASE, "sarge" }, +}; + +int bg_numPModels = sizeof( bg_pModelList ) / sizeof( bg_pModelList[ 0 ] ); + +/* +============== +BG_FindModelNameForClass +============== +*/ +char *BG_FindModelNameForClass( int pclass ) +{ + int i; + + for( i = 0; i < bg_numPModels; i++ ) + { + if( bg_pModelList[ i ].classNum == pclass ) + return bg_pModelList[ i ].className; + } + + //wimp out + return bg_pModelList[ 0 ].className; +} /* ============== diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 4c8fe6dc..767395f8 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -398,7 +398,7 @@ static float PM_CmdScale( usercmd_t *cmd ) { int max; float total; float scale; - float modifier = 1.0; + float modifier = 1.0f; static int time; int dTime; int aForward, aRight; @@ -406,32 +406,13 @@ static float PM_CmdScale( usercmd_t *cmd ) { dTime = pm->cmd.serverTime - time; time = pm->cmd.serverTime; - if( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS ) + if( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS && pm->ps->pm_type == PM_NORMAL ) { if( !( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST ) ) { //if not sprinting modifier *= 0.8; } - else if( cmd->upmove >= 0 ) - { - //subtract stamina - pm->ps->stats[ STAT_STAMINA ] -= (dTime/8); - } - - aForward = abs( cmd->forwardmove ); - aRight = abs( cmd->rightmove ); - - if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) - { - //restore stamina - pm->ps->stats[ STAT_STAMINA ] += (dTime/10); - } - else if( aForward <= 5 && aRight <= 5 ) - { - //restore stamina faster - pm->ps->stats[ STAT_STAMINA ] += (dTime/8); - } if( cmd->forwardmove < 0 ) { @@ -450,10 +431,6 @@ static float PM_CmdScale( usercmd_t *cmd ) { if( pm->ps->stats[ STAT_STAMINA ] < -1000 ) pm->ps->stats[ STAT_STAMINA ] = -1000; - //if not trying to run then not trying to sprint - if( abs( cmd->forwardmove ) <= 64 ) - pm->ps->stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; - //must have +ve stamina to jump if( pm->ps->stats[ STAT_STAMINA ] < 0 ) cmd->upmove = 0; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index e096b33d..feee73b8 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -603,16 +603,25 @@ typedef enum { //FIXME: switch to enums at some point //TA: player classes -#define PCL_D_B_BASE 1 -#define PCL_D_O_BASE 2 -#define PCL_D_D_BASE 3 +typedef enum { + PCL_NONE, + PCL_D_B_BASE, + PCL_D_O_BASE, + PCL_D_D_BASE, + PCL_H_BASE, + + PCL_NUM_CLASSES +} pClass_t; -#define PCL_H_BASE 11 //TA: player teams -#define PTE_NONE 0 -#define PTE_DROIDS 1 -#define PTE_HUMANS 2 +typedef enum { + PTE_NONE, + PTE_DROIDS, + PTE_HUMANS, + + PTE_NUM_TEAMS +} pTeam_t; // means of death @@ -685,6 +694,14 @@ typedef struct gitem_s { char *sounds; // string of all sounds this item will use } gitem_t; +//TA: player model precaching +typedef struct +{ + int classNum; + char *className; +} classModelName_t; + + // included in both the game dll and the client extern gitem_t bg_itemlist[]; extern int bg_numItems; @@ -695,6 +712,9 @@ gitem_t *BG_FindItemForBuildable( buildable_t buildable ); gitem_t *BG_FindItemForUpgrade( upgrade_t upgrade ); gitem_t *BG_FindItemForPowerup( powerup_t pw ); gitem_t *BG_FindItemForHoldable( holdable_t pw ); + +//TA: +char *BG_FindModelNameForClass( int pclass ); #define ITEM_INDEX(x) ((x)-bg_itemlist) qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ); diff --git a/src/game/g_active.c b/src/game/g_active.c index c9e024c8..3e2d704c 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -374,10 +374,10 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) { // attack button cycles through spectators //TA: messes with the menus - if ( ( client->buttons & BUTTON_ATTACK ) && + /*if ( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) && ( client->sess.spectatorState == SPECTATOR_FREE ) ) - Cmd_FollowCycle_f( ent, 1 ); + Cmd_FollowCycle_f( ent, 1 );*/ } @@ -641,6 +641,7 @@ void ClientThink_real( gentity_t *ent ) { int msec; usercmd_t *ucmd; float speed; + int aForward, aRight; //TA: torch gentity_t *light; @@ -770,8 +771,13 @@ void ClientThink_real( gentity_t *ent ) { } //TA: torch stuff - if( client->torch == NULL && BG_activated( UP_TORCH, client->ps.stats ) ) + if( client->torch == NULL && + BG_activated( UP_TORCH, client->ps.stats ) && + BG_gotItem( UP_TORCH, client->ps.stats ) && + !( client->ps.pm_type == PM_DEAD ) + ) { + Com_Printf( "spawn torch\n" ); light = G_Spawn( ); light->s.eType = ET_TORCH; light->r.ownerNum = ent->s.number; @@ -779,9 +785,14 @@ void ClientThink_real( gentity_t *ent ) { client->torch = light; } - if( ( client->torch != NULL && !BG_activated( UP_TORCH, client->ps.stats ) ) || - ( client->torch != NULL && BG_activated( UP_TORCH, client->ps.stats ) && pm.ps->pm_type == PM_DEAD ) ) + if( client->torch != NULL && + ( !BG_activated( UP_TORCH, client->ps.stats ) || + client->ps.pm_type == PM_DEAD || + !BG_gotItem( UP_TORCH, client->ps.stats ) + ) + ) { + Com_Printf( "destroy torch\n" ); G_FreeEntity( client->torch ); trap_LinkEntity( client->torch ); client->torch = NULL; @@ -791,6 +802,30 @@ void ClientThink_real( gentity_t *ent ) { if( client->torch != NULL ) ShineTorch( client->torch ); + aForward = abs( ucmd->forwardmove ); + aRight = abs( ucmd->rightmove ); + + //if not trying to run then not trying to sprint + if( aForward <= 64 ) + client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; + + if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && ucmd->upmove >= 0 ) + { + //subtract stamina + client->ps.stats[ STAT_STAMINA ] -= 2; + } + + if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) + { + //restore stamina + client->ps.stats[ STAT_STAMINA ] += 3; + } + else if( aForward <= 5 && aRight <= 5 ) + { + //restore stamina faster + client->ps.stats[ STAT_STAMINA ] += 2; + } + // set up for pmove oldEventSequence = client->ps.eventSequence; diff --git a/src/game/g_client.c b/src/game/g_client.c index 90fabc38..87d5fc8d 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -582,6 +582,7 @@ void CopyToBodyQue( gentity_t *ent ) { body->s.event = 0; body->r.contents = CONTENTS_BODY; body->clipmask = MASK_PLAYERSOLID; + body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ]; switch ( body->s.legsAnim & ~ANIM_TOGGLEBIT ) { case BOTH_DEATH1: @@ -928,23 +929,10 @@ void ClientUserinfoChanged( int clientNum ) { // set model //Q_strncpyz( model, Info_ValueForKey (userinfo, "model"), sizeof( model ) ); - switch( client->pers.pclass ) - { - case PCL_D_O_BASE: - Q_strncpyz( model, "klesk", sizeof( model ) ); - break; - case PCL_D_D_BASE: - Q_strncpyz( model, "orbb", sizeof( model ) ); - break; - case PCL_D_B_BASE: - Q_strncpyz( model, "lucy", sizeof( model ) ); - break; - case PCL_H_BASE: - Q_strncpyz( model, "sarge", sizeof( model ) ); - break; - default: - Q_strncpyz( model, "grunt", sizeof( model ) ); - } + s = BG_FindModelNameForClass( client->pers.pclass ); + + //if( client->pers.pclass > PCL_NONE && client->pers.pclass < PCL_NUM_CLASSES ) + Q_strncpyz( model, s, sizeof( model ) ); // team switch( client->sess.sessionTeam ) { diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 5394314f..fbefaf26 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -454,7 +454,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int } // Add team bonuses - Team_FragBonuses(self, inflictor, attacker); + //Team_FragBonuses(self, inflictor, attacker); // if client is in a nodrop area, don't drop anything (but return CTF flags!) contents = trap_PointContents( self->r.currentOrigin, -1 ); diff --git a/src/game/g_main.c b/src/game/g_main.c index d5b6479f..cf82e34d 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -298,13 +298,14 @@ G_RegisterPlayerModels */ void G_RegisterPlayerModels( void ) { - char *precacheModels[ MAX_CLIENTS ] = { "klesk", "orbb", "lucy", "sarge", NULL }; - char *s; + char *s, *class; int i; - for( i = 0; i < 4; i++ ) + for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { - s = va("n\\%s%d\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d", "precache", i, 0, precacheModels[ i ], precacheModels[ i ], 0, 0, "7", 100, 0, 0, 0, 0); + class = BG_FindModelNameForClass( i ); + Com_Printf( ":%s: ", class ); + s = va("n\\%s%d\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d", "precache", i, 0, class, class, 0, 0, "7", 100, 0, 0, 0, 0); trap_SetConfigstring( CS_PLAYERS + MAX_CLIENTS + i, s ); } |