From 030cfa4632dd76fcb72a3b12552f79f11201f94b Mon Sep 17 00:00:00 2001
From: Tim Angus <tim@ngus.net>
Date: Sat, 30 Aug 2003 01:47:31 +0000
Subject: * Integrated the overmind sounds * Sounds for repairing stuff * Fixed
 a buildable animation bug * Added G_BroadcastEvent

---
 src/game/bg_public.h   |  9 +++++++--
 src/game/g_buildable.c | 29 ++++++++++++++++++++++++++++-
 src/game/g_local.h     |  5 +++++
 src/game/g_utils.c     | 17 +++++++++++++++++
 src/game/g_weapon.c    |  5 +++++
 5 files changed, 62 insertions(+), 3 deletions(-)

(limited to 'src/game')

diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index f2b63342..ff96700d 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -532,9 +532,14 @@ typedef enum
   EV_TAUNT,
 
   EV_BUILD_DELAY,     //TA: can't build yet
+  EV_BUILD_REPAIR,    //TA: repairing buildable
+  EV_BUILD_REPAIRED,  //TA: buildable has full health
+  
+  EV_OVERMIND_ATTACK, //TA: overmind under attack
+  EV_OVERMIND_DYING,  //TA: overmind close to death
+  EV_OVERMIND_SPAWNS, //TA: overmind needs spawns
+  
   EV_POISONCLOUD,     //TA: client poisoned
-  EV_KNOCKOVER,       //TA: client knocked over
-  EV_GETUP,           //TA: client getting up
   EV_RPTUSE_SOUND     //TA: trigger a sound
 } entity_event_t;
 
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index cb48dc21..7ebd97d0 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -527,6 +527,10 @@ void ASpawn_Pain( gentity_t *self, gentity_t *attacker, int damage )
 
 
 
+#define OVERMIND_ATTACK_PERIOD 10000
+#define OVERMIND_DYING_PERIOD  5000
+#define OVERMIND_SPAWNS_PERIOD 30000
+
 /*
 ================
 AOvermind_Think
@@ -561,6 +565,29 @@ void AOvermind_Think( gentity_t *self )
         G_setBuildableAnim( self, BANIM_ATTACK1, qfalse );
       }
     }
+
+    //low on spawns
+    if( level.numAlienSpawns <= 1 && level.time > self->overmindSpawnsTimer )
+    {
+      self->overmindSpawnsTimer = level.time + OVERMIND_SPAWNS_PERIOD;
+      G_BroadcastEvent( EV_OVERMIND_SPAWNS, 0 );
+    }
+    
+    //overmind dying
+    if( self->health < ( OVERMIND_HEALTH / 10.0f ) && level.time > self->overmindDyingTimer )
+    {
+      self->overmindDyingTimer = level.time + OVERMIND_DYING_PERIOD;
+      G_BroadcastEvent( EV_OVERMIND_DYING, 0 );
+    }
+
+    //overmind under attack
+    if( self->health < self->lastHealth && level.time > self->overmindAttackTimer )
+    {
+      self->overmindAttackTimer = level.time + OVERMIND_ATTACK_PERIOD;
+      G_BroadcastEvent( EV_OVERMIND_ATTACK, 0 );
+    }
+    
+    self->lastHealth = self->health;
   }
 
   creepSlow( self->s.modelindex, self->s.origin );
@@ -2186,7 +2213,7 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin
   G_AddEvent( built, EV_BUILD_CONSTRUCT, 0 );
 
   if( built->builtBy >= 0 )
-    G_setBuildableAnim( built, BANIM_CONSTRUCT1, qfalse );
+    G_setBuildableAnim( built, BANIM_CONSTRUCT1, qtrue );
 
   trap_LinkEntity( built );
 
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 165b9c90..411bdde1 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -143,6 +143,7 @@ struct gentity_s
   int               last_move_time;
 
   int               health;
+  int               lastHealth; //TA: currently only used for overmind
 
   qboolean          takedamage;
 
@@ -182,6 +183,9 @@ struct gentity_s
   qboolean          spawned;      //TA: whether or not this buildable has finished spawning
   int               buildTime;    //TA: when this buildable was built
   int               time1000;     //TA: timer evaluated every second
+  int               overmindAttackTimer;
+  int               overmindDyingTimer;
+  int               overmindSpawnsTimer;
 
   int               credits[ MAX_CLIENTS ]; //TA: human credits for each client
   qboolean          creditsHash[ MAX_CLIENTS ]; //TA: track who has claimed credit
@@ -590,6 +594,7 @@ float       vectoyaw( const vec3_t vec );
 
 void        G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
 void        G_AddEvent( gentity_t *ent, int event, int eventParm );
+void        G_BroadcastEvent( int event, int eventParm );
 void        G_SetOrigin( gentity_t *ent, vec3_t origin );
 void        AddRemap(const char *oldShader, const char *newShader, float timeOffset);
 const char  *BuildShaderStateConfig();
diff --git a/src/game/g_utils.c b/src/game/g_utils.c
index 3c5ef2e2..7d9b362e 100644
--- a/src/game/g_utils.c
+++ b/src/game/g_utils.c
@@ -646,6 +646,23 @@ void G_AddEvent( gentity_t *ent, int event, int eventParm )
 }
 
 
+/*
+===============
+G_BroadcastEvent
+
+Sends an event to every client
+===============
+*/
+void G_BroadcastEvent( int event, int eventParm )
+{
+  gentity_t *ent;
+
+  ent = G_TempEntity( vec3_origin, event );
+  ent->s.eventParm = eventParm;
+  ent->r.svFlags = SVF_BROADCAST; // send to everyone
+}
+
+
 /*
 =============
 G_Sound
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 79bd1cb7..3c10db5e 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -478,6 +478,11 @@ void cancelBuildFire( gentity_t *ent )
 
       if( traceEnt->health > bHealth )
         traceEnt->health = bHealth;
+
+      if( traceEnt->health == bHealth )
+        G_AddEvent( ent, EV_BUILD_REPAIRED, 0 );
+      else
+        G_AddEvent( ent, EV_BUILD_REPAIR, 0 );
     }
   }
   else if( ent->client->ps.weapon == WP_ABUILD2 )
-- 
cgit