diff options
-rw-r--r-- | src/cgame/cg_consolecmds.c | 2 | ||||
-rw-r--r-- | src/game/bg_misc.c | 42 | ||||
-rw-r--r-- | src/game/bg_public.h | 1 | ||||
-rw-r--r-- | src/game/g_buildable.c | 125 | ||||
-rw-r--r-- | src/game/g_cmds.c | 197 |
5 files changed, 309 insertions, 58 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 316baef8..4e7bfd15 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -386,6 +386,8 @@ void CG_InitConsoleCommands( void ) { trap_AddCommand ("build"); trap_AddCommand ("buy"); trap_AddCommand ("sell"); + trap_AddCommand ("deposit"); + trap_AddCommand ("withdraw"); trap_AddCommand ("itemact"); trap_AddCommand ("itemdeact"); trap_AddCommand ("itemtoggle"); diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index af7328c7..0d5c5c7e 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -994,6 +994,22 @@ TA: human defense item "" //sounds }, +/*QUAKED team_human_bank (0 0 1) (-16 -16 -16) (16 16 16) +TA: human defense item +*/ + { + "team_human_bank", + "sound/items/holdable.wav", + { "models/buildables/bank/bank.md3", 0, 0, 0 }, + "icons/teleporter", //icon + "Human Bank", //pickup + 0, + IT_BUILDABLE, + BA_H_BANK, + "", //precache + "" //sounds + }, + /*QUAKED team_human_reactor (0 0 1) (-16 -16 -16) (16 16 16) TA: human power item */ @@ -1437,6 +1453,32 @@ buildableAttributes_t bg_buildableList[ ] = qfalse //qboolean reactorTest; }, { + BA_H_BANK, //int buildNum; + "bank", //char *buildName; + "team_human_bank", //char *entityName; + { -15, -15, -15 }, //vec3_t mins; + { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; + 200, //int buildPoints; + 1000, //int health; + 50, //int damage; + 50, //int splashDamage; + 150, //int splashRadius; + MOD_HSPAWN, //int meansOfDeath; + BIT_HUMANS, //int team; + ( 1 << WP_HBUILD )|( 1 << WP_HBUILD2 ), //weapon_t buildWeapon; + BANIM_IDLE1, //int idleAnim; + 100, //int nextthink; + 0, //int turretFireSpeed; + 0, //int turretRange; + WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; + qfalse, //qboolean creepTest; + qfalse //qboolean reactorTest; + }, + { BA_H_MCU, //int buildNum; "mcu", //char *buildName; "team_human_mcu", //char *entityName; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index a93b234b..845993d5 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -404,6 +404,7 @@ typedef enum { BA_H_MCU, BA_H_DCC, BA_H_MEDISTAT, + BA_H_BANK, BA_H_REACTOR, BA_H_REPEATER, diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 2cc58041..808666b5 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -82,7 +82,7 @@ qboolean findPower( gentity_t *self ) //iterate through entities for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { - if( !ent->classname ) + if( !ent->classname || ent->s.eType != ET_BUILDABLE ) continue; //if entity is a power item calculate the distance to it @@ -146,7 +146,7 @@ qboolean findDCC( gentity_t *self ) //iterate through entities for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { - if( !ent->classname ) + if( !ent->classname || ent->s.eType != ET_BUILDABLE ) continue; //if entity is a power item calculate the distance to it @@ -193,6 +193,9 @@ qboolean findCreep( gentity_t *self ) { for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { + if( !ent->classname || ent->s.eType != ET_BUILDABLE ) + continue; + if( ent->s.clientNum == BA_D_SPAWN || ent->s.clientNum == BA_D_HIVEMIND ) { VectorSubtract( self->s.origin, ent->s.origin, temp_v ); @@ -704,6 +707,9 @@ void HRpt_Think( gentity_t *self ) //iterate through entities for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { + if( !ent->classname || ent->s.eType != ET_BUILDABLE ) + continue; + if( ent->s.clientNum == BA_H_SPAWN && ent->parentNode == self ) count++; @@ -770,6 +776,47 @@ void HMCU_Think( gentity_t *self ) +/* +================ +HBank_Activate + +Called when a human activates a Bank +================ +*/ +void HBank_Activate( gentity_t *self, gentity_t *other, gentity_t *activator ) +{ + //only humans can activate this + if( activator->client->ps.stats[ STAT_PTEAM ] != PTE_HUMANS ) return; + + //if this is powered then call the mcu menu + if( self->powered ) + G_AddPredictableEvent( activator, EV_MENU, MN_H_MCU ); + else + G_AddPredictableEvent( activator, EV_MENU, MN_H_MCUPOWER ); +} + +/* +================ +HBank_Think + +Think for bank +================ +*/ +void HBank_Think( gentity_t *self ) +{ + //make sure we have power + self->nextthink = level.time + REFRESH_TIME; + + self->powered = findPower( self ); +} + + + + +//================================================================================== + + + /* ================ @@ -793,6 +840,55 @@ void HDCC_Think( gentity_t *self ) + +/* +================ +HMedistat_Think + +think function for Droid Acid Tube +================ +*/ +void HMedistat_Think( gentity_t *self ) +{ + int entityList[ MAX_GENTITIES ]; + vec3_t mins, maxs; + int i, num; + gentity_t *player; + + VectorAdd( self->s.origin, self->r.maxs, maxs ); + VectorAdd( self->s.origin, self->r.mins, mins ); + + mins[ 2 ] += fabs( self->r.mins[ 2 ] ) + self->r.maxs[ 2 ]; + maxs[ 2 ] += 60; //player height + + //make sure we have power + self->nextthink = level.time + REFRESH_TIME; + + self->powered = findPower( self ); + + //do some damage + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + for( i = 0; i < num; i++ ) + { + player = &g_entities[ entityList[ i ] ]; + + if( player->client && player->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) + { + if( player->health < player->client->ps.stats[ STAT_MAX_HEALTH ] ) + player->health++; + } + } + + self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +} + + + + +//================================================================================== + + + /* ================ HFM_Touch @@ -1367,6 +1463,9 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance { for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { + if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) + continue; + if( tempent->s.clientNum == BA_D_SPAWN || tempent->s.clientNum == BA_D_HIVEMIND ) { VectorSubtract( entity_origin, tempent->s.origin, temp_v ); @@ -1382,6 +1481,8 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //look for a hivemind for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { + if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) + continue; if( tempent->s.clientNum == BA_D_HIVEMIND ) break; } @@ -1400,6 +1501,9 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance { for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { + if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) + continue; + if( tempent->s.clientNum == BA_D_HIVEMIND ) { reason = IBE_HIVEMIND; @@ -1420,6 +1524,9 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //find the nearest power entity for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { + if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) + continue; + if( tempent->s.clientNum == BA_H_REACTOR || tempent->s.clientNum == BA_H_REPEATER ) { VectorSubtract( entity_origin, tempent->s.origin, temp_v ); @@ -1459,6 +1566,9 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance { for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { + if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) + continue; + if( tempent->s.clientNum == BA_H_REACTOR ) break; } @@ -1472,6 +1582,9 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance { for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { + if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) + continue; + if( tempent->s.clientNum == BA_H_REACTOR ) { reason = IBE_REACTOR; @@ -1587,13 +1700,19 @@ gentity_t *G_buildItem( gentity_t *ent, buildable_t buildable, int distance, flo built->use = HMCU_Activate; break; + case BA_H_BANK: + built->think = HBank_Think; + built->die = HSpawn_Die; + built->use = HBank_Activate; + break; + case BA_H_DCC: built->think = HDCC_Think; built->die = HSpawn_Die; break; case BA_H_MEDISTAT: - built->think = HDCC_Think; + built->think = HMedistat_Think; built->die = HSpawn_Die; break; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 35a453a4..1d977b86 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1722,26 +1722,18 @@ Activate an item void Cmd_ActivateItem_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; + int upgrade; trap_Argv( 1, s, sizeof( s ) ); + upgrade = BG_FindUpgradeNumForName( s ); if( ent->client->pers.pteam != PTE_HUMANS ) return; - if( !Q_stricmp( s, "nvg" ) ) - { - if( BG_gotItem( UP_NVG, ent->client->ps.stats ) ) - BG_activateItem( UP_NVG, ent->client->ps.stats ); - else - trap_SendServerCommand( ent-g_entities, va("print \"You don't have the NVG\n\"" ) ); - } - else if( !Q_stricmp( s, "torch" ) ) - { - if( BG_gotItem( UP_TORCH, ent->client->ps.stats ) ) - BG_activateItem( UP_TORCH, ent->client->ps.stats ); - else - trap_SendServerCommand( ent-g_entities, va("print \"You don't have the torch\n\"" ) ); - } + if( BG_gotItem( upgrade, ent->client->ps.stats ) ) + BG_activateItem( upgrade, ent->client->ps.stats ); + else + trap_SendServerCommand( ent-g_entities, va( "print \"You don't have the %s\n\"", s ) ); } @@ -1755,26 +1747,18 @@ Deactivate an item void Cmd_DeActivateItem_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; + int upgrade; trap_Argv( 1, s, sizeof( s ) ); + upgrade = BG_FindUpgradeNumForName( s ); if( ent->client->pers.pteam != PTE_HUMANS ) return; - if( !Q_stricmp( s, "nvg" ) ) - { - if( BG_gotItem( UP_NVG, ent->client->ps.stats ) ) - BG_deactivateItem( UP_NVG, ent->client->ps.stats ); - else - trap_SendServerCommand( ent-g_entities, va("print \"You don't have the NVG\n\"" ) ); - } - else if( !Q_stricmp( s, "torch" ) ) - { - if( BG_gotItem( UP_TORCH, ent->client->ps.stats ) ) - BG_deactivateItem( UP_TORCH, ent->client->ps.stats ); - else - trap_SendServerCommand( ent-g_entities, va("print \"You don't have the torch\n\"" ) ); - } + if( BG_gotItem( upgrade, ent->client->ps.stats ) ) + BG_deactivateItem( upgrade, ent->client->ps.stats ); + else + trap_SendServerCommand( ent-g_entities, va( "print \"You don't have the %s\n\"", s ) ); } @@ -1786,36 +1770,23 @@ Cmd_ToggleItem_f void Cmd_ToggleItem_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; + int upgrade; trap_Argv( 1, s, sizeof( s ) ); + upgrade = BG_FindUpgradeNumForName( s ); if( ent->client->pers.pteam != PTE_HUMANS ) return; - if( !Q_stricmp( s, "nvg" ) ) + if( BG_gotItem( upgrade, ent->client->ps.stats ) ) { - if( BG_gotItem( UP_NVG, ent->client->ps.stats ) ) - { - if( BG_activated( UP_NVG, ent->client->ps.stats ) ) - BG_deactivateItem( UP_NVG, ent->client->ps.stats ); - else - BG_activateItem( UP_NVG, ent->client->ps.stats ); - } - else - trap_SendServerCommand( ent-g_entities, va("print \"You don't have the NVG\n\"" ) ); - } - else if( !Q_stricmp( s, "torch" ) ) - { - if( BG_gotItem( UP_TORCH, ent->client->ps.stats ) ) - { - if( BG_activated( UP_TORCH, ent->client->ps.stats ) ) - BG_deactivateItem( UP_TORCH, ent->client->ps.stats ); - else - BG_activateItem( UP_TORCH, ent->client->ps.stats ); - } + if( BG_activated( upgrade, ent->client->ps.stats ) ) + BG_deactivateItem( upgrade, ent->client->ps.stats ); else - trap_SendServerCommand( ent-g_entities, va("print \"You don't have the torch\n\"" ) ); + BG_activateItem( upgrade, ent->client->ps.stats ); } + else + trap_SendServerCommand( ent-g_entities, va( "print \"You don't have the %s\n\"", s ) ); } @@ -1842,7 +1813,10 @@ void Cmd_Buy_f( gentity_t *ent ) for ( i = 1, mcuEntity = g_entities + i; i < level.num_entities; i++, mcuEntity++ ) { - if( !Q_stricmp( mcuEntity->classname, "team_human_mcu" ) ) + if( mcuEntity->s.eType != ET_BUILDABLE ) + continue; + + if( mcuEntity->s.clientNum == BA_H_MCU ) { VectorSubtract( ent->s.pos.trBase, mcuEntity->s.origin, distance ); if( VectorLength( distance ) <= 100 ) @@ -1953,7 +1927,10 @@ void Cmd_Sell_f( gentity_t *ent ) for ( i = 1, mcuEntity = g_entities + i; i < level.num_entities; i++, mcuEntity++ ) { - if( !Q_stricmp( mcuEntity->classname, "team_human_mcu" ) ) + if( mcuEntity->s.eType != ET_BUILDABLE ) + continue; + + if( mcuEntity->s.clientNum == BA_H_MCU ) { VectorSubtract( ent->s.pos.trBase, mcuEntity->s.origin, distance ); if( VectorLength( distance ) <= 100 ) @@ -1975,19 +1952,23 @@ void Cmd_Sell_f( gentity_t *ent ) { //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 ); + //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 ); + //add to funds + ent->client->ps.stats[ STAT_CREDIT ] += BG_FindPriceForUpgrade( upgrade ); + } } else { @@ -1998,6 +1979,108 @@ void Cmd_Sell_f( gentity_t *ent ) /* ================= +Cmd_Deposit_f +================= +*/ +void Cmd_Deposit_f( gentity_t *ent ) +{ + char s[ MAX_TOKEN_CHARS ]; + int amount; + vec3_t distance; + int i; + gentity_t *bankEntity; + qboolean nearBank = qfalse; + + trap_Argv( 1, s, sizeof( s ) ); + amount = atoi( s ); + + //droids don't sell stuff + if( ent->client->pers.pteam != PTE_HUMANS ) + return; + + for ( i = 1, bankEntity = g_entities + i; i < level.num_entities; i++, bankEntity++ ) + { + if( bankEntity->s.eType != ET_BUILDABLE ) + continue; + + if( bankEntity->s.clientNum == BA_H_BANK ) + { + VectorSubtract( ent->s.pos.trBase, bankEntity->s.origin, distance ); + if( VectorLength( distance ) <= 100 ) + nearBank = qtrue; + } + } + + //no Bank nearby + if( !nearBank ) + { + trap_SendServerCommand( ent-g_entities, va("print \"You must be near an Bank\n\"" ) ); + return; + } + + if( amount <= ent->client->ps.stats[ STAT_CREDIT ] ) + { + ent->client->ps.stats[ STAT_CREDIT ] -= amount; + bankEntity->credits[ ent->client->ps.clientNum ] += amount; + } + else + trap_SendServerCommand( ent-g_entities, va("print \"You do not have that amount\n\"" ) ); +} + + +/* +================= +Cmd_Withdraw_f +================= +*/ +void Cmd_Withdraw_f( gentity_t *ent ) +{ + char s[ MAX_TOKEN_CHARS ]; + int amount; + vec3_t distance; + int i; + gentity_t *bankEntity; + qboolean nearBank = qfalse; + + trap_Argv( 1, s, sizeof( s ) ); + amount = atoi( s ); + + //droids don't sell stuff + if( ent->client->pers.pteam != PTE_HUMANS ) + return; + + for ( i = 1, bankEntity = g_entities + i; i < level.num_entities; i++, bankEntity++ ) + { + if( bankEntity->s.eType != ET_BUILDABLE ) + continue; + + if( bankEntity->s.clientNum == BA_H_BANK ) + { + VectorSubtract( ent->s.pos.trBase, bankEntity->s.origin, distance ); + if( VectorLength( distance ) <= 100 ) + nearBank = qtrue; + } + } + + //no Bank nearby + if( !nearBank ) + { + trap_SendServerCommand( ent-g_entities, va("print \"You must be near an Bank\n\"" ) ); + return; + } + + if( amount <= bankEntity->credits[ ent->client->ps.clientNum ] ) + { + ent->client->ps.stats[ STAT_CREDIT ] += amount; + bankEntity->credits[ ent->client->ps.clientNum ] -= amount; + } + else + trap_SendServerCommand( ent-g_entities, va("print \"You do not have that amount\n\"" ) ); +} + + +/* +================= Cmd_Build_f ================= */ @@ -2211,6 +2294,10 @@ void ClientCommand( int clientNum ) { Cmd_Buy_f( ent ); else if (Q_stricmp (cmd, "sell") == 0) Cmd_Sell_f( ent ); + else if (Q_stricmp (cmd, "deposit") == 0) + Cmd_Deposit_f( ent ); + else if (Q_stricmp (cmd, "withdraw") == 0) + Cmd_Withdraw_f( ent ); else if (Q_stricmp (cmd, "itemact") == 0) Cmd_ActivateItem_f( ent ); else if (Q_stricmp (cmd, "itemdeact") == 0) |