summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2001-03-22 01:57:00 +0000
committerTim Angus <tim@ngus.net>2001-03-22 01:57:00 +0000
commitfbe70db07dd5dc85a83d98d3ef789de41d22545b (patch)
tree8d211b0fb6d6fdcb5c5fb9c0c512ba377517055a /src/game
parent8a3452aa2a8fd7f82d267a1de0b05288b8d92dfe (diff)
Restructuring of the builables routines.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_misc.c185
-rw-r--r--src/game/bg_public.h56
-rw-r--r--src/game/g_buildable.c144
-rw-r--r--src/game/g_cmds.c47
-rw-r--r--src/game/g_local.h4
5 files changed, 170 insertions, 266 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 062eb3fc..1f9f5187 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -750,7 +750,7 @@ TA: droid spawn item
"Droid Spawn", //pickup
0,
IT_BUILDABLE,
- BA_A_SPAWN,
+ BA_D_SPAWN,
"", //precache
"" //sounds
},
@@ -766,7 +766,7 @@ TA: droid defense item
"Droid Defense", //pickup
0,
IT_BUILDABLE,
- BA_A_DEF1,
+ BA_D_DEF1,
"", //precache
"" //sounds
},
@@ -894,13 +894,9 @@ int bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1;
buildableAttributes_t bg_buildableList[ ] =
{
{
- BA_A_SPAWN,
- "spawn",
+ BA_D_SPAWN,
+ "bioegg",
"team_droid_spawn",
- "Droid Spawn",
- { "models/bitems/aspawn.md3", 0, 0, 0 },
- { "", 0, 0, 0 },
- "icons/teleporter",
{ -15, -15, -15 },
{ 15, 15, 15 },
1000,
@@ -910,7 +906,72 @@ buildableAttributes_t bg_buildableList[ ] =
MOD_ASPAWN,
BIT_DROIDS,
EV_ITEM_GROW,
- 100
+ 100,
+ qfalse
+ },
+ {
+ BA_D_DEF1,
+ "defense1",
+ "team_droid_def1",
+ { -15, -15, -15 },
+ { 15, 15, 15 },
+ 1000,
+ 50,
+ 20,
+ 50,
+ MOD_ASPAWN,
+ BIT_DROIDS,
+ EV_ITEM_GROW,
+ 100,
+ qtrue
+ },
+ {
+ BA_H_SPAWN,
+ "replicator",
+ "team_human_spawn",
+ { -40, -40, -4 },
+ { 40, 40, 4 },
+ 1000,
+ 50,
+ 50,
+ 150,
+ MOD_HSPAWN,
+ BIT_HUMANS,
+ EV_NONE,
+ -1,
+ qfalse
+ },
+ {
+ BA_H_DEF1,
+ "plasmaturret",
+ "team_human_def1",
+ { -24, -24, -11 },
+ { 24, 24, 11 },
+ 1000,
+ 50,
+ 20,
+ 50,
+ MOD_ASPAWN,
+ BIT_HUMANS,
+ EV_NONE,
+ 50,
+ qfalse
+ },
+ {
+ BA_H_MCU,
+ "mcu",
+ "team_human_mcu",
+ { -15, -15, -15 },
+ { 15, 15, 15 },
+ 1000,
+ 50,
+ 50,
+ 150,
+ MOD_HSPAWN,
+ BIT_HUMANS,
+ EV_NONE,
+ -1,
+ qfalse
}
};
@@ -940,7 +1001,7 @@ int BG_FindBuildNumForName( char *name )
BG_FindNameForBuildNum
==============
*/
-char *BG_FindNameForBuildNum( int bclass )
+char *BG_FindNameForBuildable( int bclass )
{
int i;
@@ -959,7 +1020,7 @@ char *BG_FindNameForBuildNum( int bclass )
BG_FindEntityNameForBuildNum
==============
*/
-char *BG_FindEntityNameForBuildNum( int bclass )
+char *BG_FindEntityNameForBuildable( int bclass )
{
int i;
@@ -975,86 +1036,6 @@ char *BG_FindEntityNameForBuildNum( int bclass )
/*
==============
-BG_FindPrecacheNameForBuildNum
-==============
-*/
-char *BG_FindPrecacheNameForBuildNum( int bclass )
-{
- int i;
-
- for( i = 0; i < bg_numBuildables; i++ )
- {
- if( bg_buildableList[ i ].buildNum == bclass )
- return bg_buildableList[ i ].precacheName;
- }
-
- //wimp out
- return "";
-}
-
-/*
-==============
-BG_FindModelsForBuildable
-==============
-*/
-char **BG_FindModelsForBuildable( int bclass )
-{
- int i;
- char **dummy;
-
- for( i = 0; i < bg_numBuildables; i++ )
- {
- if( bg_buildableList[ i ].buildNum == bclass )
- {
- return bg_buildableList[ i ].modelPrecache;
- }
- }
-
- return dummy;
-}
-
-/*
-==============
-BG_FindSoundsForBuildable
-==============
-*/
-char **BG_FindSoundsForBuildable( int bclass )
-{
- int i;
- char **dummy;
-
- for( i = 0; i < bg_numBuildables; i++ )
- {
- if( bg_buildableList[ i ].buildNum == bclass )
- {
- return bg_buildableList[ i ].soundPrecache;
- }
- }
-
- return dummy;
-}
-
-/*
-==============
-BG_FindIconForBuildNum
-==============
-*/
-char *BG_FindIconForBuildNum( int bclass )
-{
- int i;
-
- for( i = 0; i < bg_numBuildables; i++ )
- {
- if( bg_buildableList[ i ].buildNum == bclass )
- return bg_buildableList[ i ].icon;
- }
-
- //wimp out
- return "";
-}
-
-/*
-==============
BG_FindBBoxForBuildable
==============
*/
@@ -1168,7 +1149,7 @@ int BG_FindSplashRadiusForBuildable( int bclass )
BG_FindMODForBuildable
==============
*/
-int BG_FindMODBuildable( int bclass )
+int BG_FindMODForBuildable( int bclass )
{
int i;
@@ -1243,6 +1224,26 @@ int BG_FindNextThinkForBuildable( int bclass )
return 100;
}
+/*
+==============
+BG_FindCreepTestForBuildable
+==============
+*/
+int BG_FindCreepTestForBuildable( int bclass )
+{
+ int i;
+
+ for( i = 0; i < bg_numBuildables; i++ )
+ {
+ if( bg_buildableList[ i ].buildNum == bclass )
+ {
+ return bg_buildableList[ i ].creepTest;
+ }
+ }
+
+ return qfalse;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
classAttributes_t bg_classList[ ] =
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 34e822ed..3a701611 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -369,8 +369,8 @@ typedef enum {
typedef enum {
BA_NONE,
- BA_A_SPAWN,
- BA_A_DEF1,
+ BA_D_SPAWN,
+ BA_D_DEF1,
BA_H_SPAWN,
BA_H_DEF1,
BA_H_MCU,
@@ -381,8 +381,11 @@ typedef enum {
typedef enum
{
BIT_NONE,
+
BIT_DROIDS,
- BIT_HUMANS
+ BIT_HUMANS,
+
+ BIT_NUM_TEAMS
} buildableTeam_t;
// reward sounds (stored in ps->persistant[PERS_PLAYEREVENTS])
@@ -736,32 +739,29 @@ typedef struct
//TA: buildable item record
typedef struct
{
- int buildNum;
+ int buildNum;
- char *buildName;
- char *entityName;
- char *precacheName;
+ char *buildName;
+ char *entityName;
- char *modelPrecache[ 4 ];
- char *soundPrecache[ 4 ];
- char *icon;
+ vec3_t mins;
+ vec3_t maxs;
- vec3_t mins;
- vec3_t maxs;
-
- int health;
+ int health;
- int damage;
- int splashDamage;
- int splashRadius;
+ int damage;
+ int splashDamage;
+ int splashRadius;
- int meansOfDeath;
+ int meansOfDeath;
- int team;
+ int team;
- int spawnEvent;
+ int spawnEvent;
- int nextthink;
+ int nextthink;
+
+ qboolean creepTest;
} buildableAttributes_t;
// included in both the game dll and the client
@@ -776,6 +776,20 @@ gitem_t *BG_FindItemForPowerup( powerup_t pw );
gitem_t *BG_FindItemForHoldable( holdable_t pw );
//TA:
+int BG_FindBuildNumForName( char *name );
+char *BG_FindNameForBuildable( int bclass );
+char *BG_FindEntityNameForBuildable( int bclass );
+void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs );
+int BG_FindHealthForBuildable( int bclass );
+int BG_FindDamageForBuildable( int bclass );
+int BG_FindSplashDamageForBuildable( int bclass );
+int BG_FindSplashRadiusForBuildable( int bclass );
+int BG_FindMODForBuildable( int bclass );
+int BG_FindTeamForBuildable( int bclass );
+int BG_FindEventForBuildable( int bclass );
+int BG_FindNextThinkForBuildable( int bclass );
+int BG_FindCreepTestForBuildable( int bclass );
+
int BG_FindClassNumForName( char *name );
char *BG_FindNameForClassNum( int pclass );
char *BG_FindModelNameForClass( int pclass );
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 01fdcdb8..4294fb01 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -448,7 +448,7 @@ itemFits
Checks to see if an item fits in a specific area
================
*/
-qboolean itemFits( gentity_t *ent, gitem_t *item, int distance )
+qboolean itemFits( gentity_t *ent, buildable_t buildable, int distance )
{
vec3_t forward;
vec3_t angles;
@@ -468,41 +468,12 @@ qboolean itemFits( gentity_t *ent, gitem_t *item, int distance )
VectorCopy( ent->s.pos.trBase, player_origin );
VectorMA( player_origin, distance, forward, entity_origin );
- if( !Q_stricmp( item->classname, "team_droid_spawn" ) )
- {
- creeptest = qfalse;
- VectorSet( mins, -15, -15, -15 );
- VectorSet( maxs, 15, 15, 15 );
- }
- else if( !Q_stricmp( item->classname, "team_droid_def1" ) )
- {
- creeptest = qtrue;
- VectorSet( mins, -15, -15, -15 );
- VectorSet( maxs, 15, 15, 15 );
- }
- else if( !Q_stricmp( item->classname, "team_human_spawn" ) )
- {
- creeptest = qfalse;
- VectorSet( mins, -40, -40, -4 );
- VectorSet( maxs, 40, 40, 4 );
- }
- else if( !Q_stricmp( item->classname, "team_human_def1" ) )
- {
- creeptest = qfalse;
- VectorSet( mins, -24, -24, -11 );
- VectorSet( maxs, 24, 24, 11 );
- }
- else if( !Q_stricmp( item->classname, "team_human_mcu" ) )
- {
- creeptest = qfalse;
- VectorSet( mins, -15, -15, -15 );
- VectorSet( maxs, 15, 15, 15 );
- }
-
+ BG_FindBBoxForBuildable( buildable, mins, maxs );
+
trap_Trace( &tr1, entity_origin, mins, maxs, entity_origin, ent->s.number, MASK_PLAYERSOLID );
trap_Trace( &tr2, player_origin, NULL, NULL, entity_origin, ent->s.number, MASK_PLAYERSOLID );
- if( creeptest )
+ if( BG_FindCreepTestForBuildable( buildable ) )
{
for ( i = 1, creepent = g_entities + i; i < level.num_entities; i++, creepent++ )
{
@@ -534,7 +505,7 @@ Build_Item
Spawns an item and tosses it forward
================
*/
-gentity_t *Build_Item( gentity_t *ent, gitem_t *item, int distance ) {
+gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) {
vec3_t forward;
vec3_t angles;
vec3_t origin;
@@ -550,109 +521,50 @@ gentity_t *Build_Item( gentity_t *ent, gitem_t *item, int distance ) {
built = G_Spawn();
built->s.eType = ET_BUILDABLE;
- built->s.modelindex = item - bg_itemlist; // store item number in modelindex
- built->classname = item->classname;
- built->item = item;
+ built->classname = BG_FindEntityNameForBuildable( buildable );
+ built->item = BG_FindItemForBuildable( buildable );
+
+ built->s.modelindex = built->item - bg_itemlist; // store item number in modelindex
+
+ BG_FindBBoxForBuildable( buildable, built->r.mins, built->r.maxs );
+ built->biteam = built->s.modelindex2 = BG_FindTeamForBuildable( buildable );
+ built->health = BG_FindHealthForBuildable( buildable );
+
+ built->damage = BG_FindDamageForBuildable( buildable );
+ built->splashDamage = BG_FindSplashDamageForBuildable( buildable );
+ built->splashRadius = BG_FindSplashRadiusForBuildable( buildable );
+ built->splashMethodOfDeath = BG_FindMODForBuildable( buildable );
+
+ if( BG_FindEventForBuildable( buildable ) != EV_NONE )
+ G_AddEvent( built, BG_FindEventForBuildable( buildable ), 0 );
+
+ built->nextthink = BG_FindNextThinkForBuildable( buildable );
- if( !Q_stricmp( item->classname, "team_droid_spawn" ) )
+ if( buildable == BA_D_SPAWN )
{
- VectorSet( built->r.mins, -15, -15, -15 );
- VectorSet( built->r.maxs, 15, 15, 15 );
-
- built->biteam = BIT_DROIDS;
- built->takedamage = qtrue;
- built->health = 1000;
- built->damage = 50;
- built->splashDamage = 50;
- built->splashRadius = 200;
- built->splashMethodOfDeath = MOD_ASPAWN;
- built->s.modelindex2 = BIT_DROIDS;
- G_AddEvent( built, EV_ITEM_GROW, 0 );
- //built->touch = ASpawn_Touch;
built->die = DSpawn_Die;
- //built->pain = ASpawn_Pain;
built->think = DSpawn_Think;
- built->nextthink = level.time + 100;
}
- else if( !Q_stricmp( item->classname, "team_droid_def1" ) )
+ else if( buildable == BA_D_DEF1 )
{
- VectorSet( built->r.mins, -15, -15, -15 );
- VectorSet( built->r.maxs, 15, 15, 15 );
-
- built->biteam = BIT_DROIDS;
- built->takedamage = qtrue;
- built->health = 1000;
- built->damage = 50;
- built->splashDamage = 20;
- built->splashRadius = 50;
- built->splashMethodOfDeath = MOD_ASPAWN;
- built->s.modelindex2 = BIT_DROIDS;
- G_AddEvent( built, EV_ITEM_GROW, 0 );
- //built->touch = ASpawn_Touch;
built->die = DDef1_Die;
- //built->pain = ASpawn_Pain;
built->think = DDef1_Think;
- built->nextthink = level.time + 100;
}
- else if( !Q_stricmp( item->classname, "team_human_spawn" ) )
+ else if( buildable == BA_H_SPAWN )
{
- VectorSet( built->r.mins, -40, -40, -4 );
- VectorSet( built->r.maxs, 40, 40, 4 );
-
- built->biteam = BIT_HUMANS;
- built->takedamage = qtrue;
- built->health = 1000;
- built->damage = 50;
- built->splashDamage = 50;
- built->splashRadius = 150;
- built->splashMethodOfDeath = MOD_HSPAWN;
- built->s.modelindex2 = BIT_HUMANS;
- //built->touch = HSpawn_Touch;
- //built->think = HSpawn_Think;
- //built->nextthink = level.time + 1000;
built->die = HSpawn_Die;
- //built->pain = HSpawn_Pain;
}
- else if( !Q_stricmp( item->classname, "team_human_def1" ) )
+ else if( buildable == BA_H_DEF1 )
{
- VectorSet( built->r.mins, -24, -24, -11 );
- VectorSet( built->r.maxs, 24, 24, 11 );
-
- built->biteam = BIT_HUMANS;
- built->takedamage = qtrue;
- built->health = 1000;
- built->damage = 50;
- built->splashDamage = 20;
- built->splashRadius = 50;
- built->splashMethodOfDeath = MOD_HSPAWN;
- built->s.modelindex2 = BIT_HUMANS;
- //built->touch = ASpawn_Touch;
built->die = HSpawn_Die;
- //built->pain = ASpawn_Pain;
built->think = HDef1_Think;
built->enemy = NULL;
- built->nextthink = level.time + 50;
}
- else if( !Q_stricmp( item->classname, "team_human_mcu" ) )
+ else if( buildable == BA_H_MCU )
{
- VectorSet( built->r.mins, -15, -15, -15 );
- VectorSet( built->r.maxs, 15, 15, 15 );
-
- built->biteam = BIT_HUMANS;
- built->takedamage = qtrue;
- built->health = 1000;
- built->damage = 50;
- built->splashDamage = 50;
- built->splashRadius = 150;
- built->splashMethodOfDeath = MOD_HSPAWN;
- built->s.modelindex2 = BIT_HUMANS;
- //built->touch = HSpawn_Touch;
- //built->think = HSpawn_Think;
- //built->nextthink = level.time + 1000;
built->die = HSpawn_Die;
built->use = HMCU_Activate;
- //built->pain = HSpawn_Pain;
}
built->s.number = built - g_entities;
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index d6eb998b..1687504f 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1903,11 +1903,8 @@ Cmd_Build_f
*/
void Cmd_Build_f( gentity_t *ent )
{
- gitem_t *item;
char s[ MAX_TOKEN_CHARS ];
int buildable;
- qboolean dontBuild = qfalse;
-
trap_Argv( 1, s, sizeof( s ) );
@@ -1915,23 +1912,14 @@ void Cmd_Build_f( gentity_t *ent )
BG_gotWeapon( WP_ABUILD, ent->client->ps.stats ) &&
( ent->client->ps.weapon == WP_ABUILD ) )
{
- if( !Q_stricmp(s, "0") || !Q_stricmp(s, "spawn") )
- buildable = BA_A_SPAWN;
- else if( !Q_stricmp(s, "1") || !Q_stricmp(s, "defense1") )
- buildable = BA_A_DEF1;
- else
- {
- trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
- dontBuild = qtrue;
- }
+ buildable = BG_FindBuildNumForName( s );
- if( !dontBuild )
+ if( buildable == BA_NONE )
+ trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
+ else
{
- item = BG_FindItemForBuildable( buildable );
- if( itemFits( ent, item, -50 ) )
- {
- Build_Item( ent, item, -50 );
- }
+ if( itemFits( ent, buildable, -50 ) )
+ Build_Item( ent, buildable, -50 );
else
trap_SendServerCommand( ent-g_entities, va("print \"Location is not suitable\n\"" ) );
}
@@ -1940,25 +1928,14 @@ void Cmd_Build_f( gentity_t *ent )
BG_gotWeapon( WP_HBUILD, ent->client->ps.stats ) &&
( ent->client->ps.weapon == WP_HBUILD ) )
{
- if( !Q_stricmp(s, "0") || !Q_stricmp(s, "spawn") )
- buildable = BA_H_SPAWN;
- else if( !Q_stricmp(s, "1") || !Q_stricmp(s, "defense1") )
- buildable = BA_H_DEF1;
- else if( !Q_stricmp(s, "2") || !Q_stricmp(s, "mcu") )
- buildable = BA_H_MCU;
- else
- {
- trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
- dontBuild = qtrue;
- }
+ buildable = BG_FindBuildNumForName( s );
- if( !dontBuild )
+ if( buildable == BA_NONE )
+ trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
+ else
{
- item = BG_FindItemForBuildable( buildable );
- if( itemFits( ent, item, 80 ) )
- {
- Build_Item( ent, item, 80 );
- }
+ if( itemFits( ent, buildable, 80 ) )
+ Build_Item( ent, buildable, 80 );
else
trap_SendServerCommand( ent-g_entities, va("print \"Location is not suitable\n\"" ) );
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index b32f07ff..c4fb81a6 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -468,8 +468,8 @@ void SaveRegisteredItems( void );
//
// g_buildable.c
//
-qboolean itemFits( gentity_t *ent, gitem_t *item, int distance );
-gentity_t *Build_Item( gentity_t *ent, gitem_t *item, int distance );
+qboolean itemFits( gentity_t *ent, buildable_t buildable, int distance );
+gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance );
//
// g_utils.c