diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_public.h | 4 | ||||
-rw-r--r-- | src/game/g_client.c | 33 | ||||
-rw-r--r-- | src/game/g_cmds.c | 80 | ||||
-rw-r--r-- | src/game/g_combat.c | 6 |
4 files changed, 100 insertions, 23 deletions
diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 74767474..f0d7398c 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -548,7 +548,9 @@ typedef enum MN_H_RPLWARN, MN_H_RPTWARN, MN_H_MCUPOWER, - MN_H_NOSLOTS + MN_H_NOSLOTS, + MN_H_NOFUNDS, + MN_H_ITEMHELD } dynMenu_t; // animations diff --git a/src/game/g_client.c b/src/game/g_client.c index 96fb3651..33f644d3 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -540,9 +540,11 @@ Called when a body is used */ void useBody( gentity_t *self, gentity_t *other, gentity_t *activator ) { - int i, class; - int total = 0; - float numerator, denominator; + int i, class, clientNum; + int total = 0; + float numerator, denominator; + vec3_t up = { 0.0, 0.0, 1.0 }; + if( activator->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS ) { @@ -550,10 +552,12 @@ void useBody( gentity_t *self, gentity_t *other, gentity_t *activator ) } else { + clientNum = activator->client->ps.clientNum; + //client has already raided this corpse - if( self->creditsHash[ activator->client->ps.clientNum ] ) return; + if( self->creditsHash[ clientNum ] ) return; - numerator = self->credits[ activator->client->ps.clientNum ]; + numerator = self->credits[ clientNum ]; class = self->s.clientNum; //total up all the damage done by every client @@ -571,7 +575,18 @@ void useBody( gentity_t *self, gentity_t *other, gentity_t *activator ) ( numerator / denominator ) ); //prevent clients claiming credit twice - self->creditsHash[ activator->client->ps.clientNum ] = qtrue; + self->creditsHash[ clientNum ] = qtrue; + + //if this corpse has been 100% claimed destroy it + for( i = 0; i < MAX_CLIENTS; i++ ) + { + if( ( self->credits[ clientNum ] == 0 || !self->creditsHash[ clientNum ] ) && total != 0 ) + continue; + + G_AddEvent( self, EV_GIB_DROID, DirToByte( up ) ); + self->freeAfterEvent = qtrue; + break; + } } } @@ -588,6 +603,7 @@ void SpawnCorpse( gentity_t *ent ) { int contents; vec3_t origin, dest; trace_t tr; + int i; VectorCopy( ent->r.currentOrigin, origin ); @@ -602,9 +618,14 @@ void SpawnCorpse( gentity_t *ent ) { body = G_Spawn( ); if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) + { body->classname = "humanCorpse"; + } else + { body->classname = "droidCorpse"; + for( i = 0; i < MAX_CLIENTS; body->credits[ i ] = ent->credits[ i++ ] ); + } body->s = ent->s; body->r.s = body->s; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 2c42896c..5f05e554 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -268,6 +268,14 @@ void Cmd_Give_f (gentity_t *ent) return; } + if( give_all || Q_stricmp( name, "funds" ) == 0 ) + { + ent->client->ps.stats[ STAT_CREDIT ] += 100; + + if( !give_all ) + return; + } + // spawn a specific item right on the player if ( !give_all ) { it = BG_FindItem (name); @@ -1824,6 +1832,10 @@ void Cmd_Buy_f( gentity_t *ent ) int quan, clips, maxClips; trap_Argv( 1, s, sizeof( s ) ); + + //droids don't buy stuff + if( ent->client->pers.pteam != PTE_HUMANS ) + return; for ( i = 1, mcuEntity = g_entities + i; i < level.num_entities; i++, mcuEntity++ ) { @@ -1835,48 +1847,83 @@ void Cmd_Buy_f( gentity_t *ent ) } } + //no MCU nearby if( !nearMCU ) { trap_SendServerCommand( ent-g_entities, va("print \"You must be near an MCU\n\"" ) ); return; } - if( ent->client->pers.pteam != PTE_HUMANS ) - return; - weapon = BG_FindWeaponNumForName( s ); upgrade = BG_FindUpgradeNumForName( s ); if( weapon != WP_NONE ) { + //already got this? + if( BG_gotWeapon( weapon, ent->client->ps.stats ) ) + { + G_AddPredictableEvent( ent, EV_MENU, MN_H_ITEMHELD ); + return; + } + + //can afford this? + if( BG_FindPriceForWeapon( weapon ) > ent->client->ps.stats[ STAT_CREDIT ] ) + { + G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS ); + return; + } + + //have space to carry this? if( BG_FindSlotsForWeapon( weapon ) & ent->client->ps.stats[ STAT_SLOTS ] ) { G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS ); return; } + //add to inventory BG_packWeapon( weapon, ent->client->ps.stats ); BG_FindAmmoForWeapon( weapon, &quan, &clips, &maxClips ); BG_packAmmoArray( weapon, ent->client->ps.ammo, ent->client->ps.powerups, quan, clips, maxClips ); ent->client->ps.weapon = weapon; + + //subtract from funds + ent->client->ps.stats[ STAT_CREDIT ] -= BG_FindPriceForWeapon( weapon ); } else if( upgrade != UP_NONE ) { + //already got this? + if( BG_gotItem( upgrade, ent->client->ps.stats ) ) + { + G_AddPredictableEvent( ent, EV_MENU, MN_H_ITEMHELD ); + return; + } + + //can afford this? + if( BG_FindPriceForUpgrade( upgrade ) > ent->client->ps.stats[ STAT_CREDIT ] ) + { + G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS ); + return; + } + + //have space to carry this? if( BG_FindSlotsForUpgrade( upgrade ) & ent->client->ps.stats[ STAT_SLOTS ] ) { G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS ); return; } + //add to inventory BG_packItem( upgrade, ent->client->ps.stats ); + + //subtract from funds + ent->client->ps.stats[ STAT_CREDIT ] -= BG_FindPriceForUpgrade( upgrade ); } else { trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) ); } - //subtract from funds } @@ -1897,6 +1944,10 @@ void Cmd_Sell_f( gentity_t *ent ) trap_Argv( 1, s, sizeof( s ) ); + //droids don't sell stuff + if( ent->client->pers.pteam != PTE_HUMANS ) + return; + for ( i = 1, mcuEntity = g_entities + i; i < level.num_entities; i++, mcuEntity++ ) { if( !Q_stricmp( mcuEntity->classname, "team_human_mcu" ) ) @@ -1907,34 +1958,38 @@ void Cmd_Sell_f( gentity_t *ent ) } } + //no MCU nearby if( !nearMCU ) { trap_SendServerCommand( ent-g_entities, va("print \"You must be near an MCU\n\"" ) ); return; } - if( ent->client->pers.pteam != PTE_HUMANS ) - return; - weapon = BG_FindWeaponNumForName( s ); upgrade = BG_FindUpgradeNumForName( s ); if( weapon != WP_NONE ) { + //remove weapon if carried if( BG_gotWeapon( weapon, ent->client->ps.stats ) ) BG_removeWeapon( weapon, ent->client->ps.stats ); + + //add to funds + ent->client->ps.stats[ STAT_CREDIT ] += BG_FindPriceForWeapon( weapon ); } else if( upgrade != UP_NONE ) { + //remove upgrade if carried if( BG_gotItem( upgrade, ent->client->ps.stats ) ) BG_removeItem( upgrade, ent->client->ps.stats ); + + //add to funds + ent->client->ps.stats[ STAT_CREDIT ] += BG_FindPriceForUpgrade( upgrade ); } else { trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) ); } - - //add to funds } @@ -2072,11 +2127,6 @@ void Cmd_Boost_f( gentity_t *ent ) ent->client->ps.stats[ STAT_STATE ] |= SS_SPEEDBOOST; } -void Cmd_Credit_f( gentity_t *ent ) -{ - trap_SendServerCommand( ent-g_entities, va("print \"%d\n\"", ent->client->ps.stats[ STAT_CREDIT ] ) ); -} - /* ================= ClientCommand @@ -2202,8 +2252,6 @@ void ClientCommand( int clientNum ) { Cmd_SetViewpos_f( ent ); else if (Q_stricmp (cmd, "stats") == 0) Cmd_Stats_f( ent ); - else if (Q_stricmp (cmd, "credit") == 0) - Cmd_Credit_f( ent ); else trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) ); } diff --git a/src/game/g_combat.c b/src/game/g_combat.c index a5fd8a44..12953de0 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1065,6 +1065,12 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, targ->client->ps.stats[STAT_HEALTH] = targ->health; } + //TA: add to the attackers "account" on the target + if( targ->client && attacker->client && + targ->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS && + attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) + targ->credits[ attacker->client->ps.clientNum ] += take; + if ( targ->health <= 0 ) { if ( client ) targ->flags |= FL_NO_KNOCKBACK; |