summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2001-03-24 05:25:35 +0000
committerTim Angus <tim@ngus.net>2001-03-24 05:25:35 +0000
commit451524a98b307c472e7910a0f9941743bf36ee8c (patch)
treede3bb87aeb567927a9a0e4757775103995156231 /src
parent023bde0d5ba726016507ce9e63e475a4e2e88a30 (diff)
Beginnings of a power system for the humans
Diffstat (limited to 'src')
-rw-r--r--src/game/bg_public.h4
-rw-r--r--src/game/g_buildable.c79
-rw-r--r--src/game/g_local.h2
3 files changed, 78 insertions, 7 deletions
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 32a2b14d..63de6673 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -879,7 +879,9 @@ qboolean BG_infiniteAmmo( int weapon );
void BG_packWeapon( int weapon, int stats[ ] );
qboolean BG_gotWeapon( int weapon, int stats[ ] );*/
-#define CREEP_BASESIZE 120
+#define CREEP_BASESIZE 120
+#define REACTOR_BASESIZE 1000
+#define REPEATER_BASESIZE 500
#define ARENAS_PER_TIER 4
#define MAX_ARENAS 1024
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 388e8edc..1dba9b8d 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -154,12 +154,6 @@ think function for Droid Spawn
*/
void DSpawn_Think( gentity_t *self )
{
- /*if( self->parentNode == NULL )
- self->parentNode = createCreepNode( self );
-
- VectorCopy( self->s.origin, self->parentNode->s.origin );*/
-
- self->nextthink = level.time + 100;
}
@@ -384,6 +378,13 @@ void HDef1_Think( gentity_t *self )
{
self->nextthink = level.time + 50;
+ if( ( self->parentNode == NULL ) || !self->parentNode->inuse )
+ {
+ if( !findPower( self ) )
+ self->nextthink = level.time + 10000;
+ return;
+ }
+
if( !hdef1_checktarget( self, self->enemy) )
hdef1_findenemy( self );
if( !self->enemy )
@@ -440,6 +441,71 @@ void HSpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
trap_LinkEntity( self );
}
+qboolean findPower( gentity_t *self )
+{
+ int i;
+ gentity_t *ent;
+ gentity_t *closestPower;
+ int distance = 0;
+ int minDistance = 10000;
+ vec3_t temp_v;
+
+ for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ )
+ {
+ if( !Q_stricmp( ent->classname, "team_human_reactor" ) ||
+ !Q_stricmp( ent->classname, "team_human_repeater" ) )
+ {
+ VectorSubtract( self->s.origin, ent->s.origin, temp_v );
+ distance = VectorLength( temp_v );
+ if( distance < minDistance )
+ {
+ closestPower = ent;
+ minDistance = distance;
+ }
+ }
+ }
+
+ if( ( !Q_stricmp( closestPower->classname, "team_human_reactor" ) &&
+ ( minDistance <= REACTOR_BASESIZE ) ) ||
+ ( !Q_stricmp( closestPower->classname, "team_human_repeater" ) &&
+ ( minDistance <= REPEATER_BASESIZE ) ) )
+ {
+ self->powered = qtrue;
+ self->parentNode = closestPower;
+ return qtrue;
+ }
+ else
+ {
+ self->powered = qfalse;
+ return qfalse;
+ }
+}
+
+/*
+================
+HSpawn_Think
+
+Think for human spawn
+================
+*/
+void HSpawn_Think( gentity_t *self )
+{
+ int i;
+ gentity_t *ent;
+ gentity_t *closestPower;
+ int distance = 0;
+ int minDistance = 10000;
+ vec3_t temp_v;
+
+ self->nextthink = level.time + 100;
+
+ if( ( self->parentNode == NULL ) || !self->parentNode->inuse )
+ {
+ if( !findPower( self ) )
+ self->nextthink = level.time + 10000;
+ }
+}
+
/*
================
@@ -563,6 +629,7 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) {
else if( buildable == BA_H_SPAWN )
{
built->die = HSpawn_Die;
+ built->think = HSpawn_Think;
}
else if( buildable == BA_H_DEF1 )
{
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 1ce85c83..dfe70341 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -177,6 +177,8 @@ struct gentity_s {
int biteam; //TA: buildable item team
gentity_t *parentNode; //TA: for creep and defence/spawn dependencies
vec3_t turloc; //TA: direction human defense turrets are pointing
+ qboolean active; //TA: for power repeater, but could be useful elsewhere
+ qboolean powered; //TA: for human buildables
};
typedef enum {