]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_onslaught.qc
Merge branch 'master' into Mario/notifications
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_onslaught.qc
index 80489160696a42a45421d50f6a4e4c0c509982ad..74cba2897387862d8893b708cd263c1c8b8c8c69 100644 (file)
@@ -391,8 +391,7 @@ void onslaught_generator_think()
                {
                        if (!overtime_msg_time)
                        {
-                               FOR_EACH_PLAYER(e)
-                                       centerprint(e, "^3Now playing ^1OVERTIME^3!\n^3Generators start now to decay.\n^3The more control points your team holds,\n^3the faster the enemy generator decays.");
+                               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT);
                                overtime_msg_time = time;
                        }
                        // self.max_health / 300 gives 5 minutes of overtime.
@@ -407,12 +406,12 @@ void onslaught_generator_think()
                                                d = d + 1;
                                e = e.chain;
                        }
-                       
+
                        if(autocvar_g_campaign && autocvar__campaign_testrun)
                                d = d * self.max_health;
                        else
                                d = d * self.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
-                       
+
                        Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
                }
                else if (overtime_msg_time)
@@ -423,9 +422,9 @@ void onslaught_generator_think()
             self.wait = time + 5;
             FOR_EACH_REALPLAYER(e)
             {
-                if(e.team == self.team)
+                               if(SAME_TEAM(e, self))
                 {
-                    centerprint(e, "^1Your generator is NOT shielded!\n^7Re-capture controlpoints to shield it!");
+                                       Send_Notification(NOTIF_ONE, e, MSG_CENTER, CENTER_ONS_NOTSHIELDED);
                     soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTEN_NONE);    // FIXME: Uniqe sound?
                 }
             }
@@ -510,7 +509,7 @@ void onslaught_generator_deaththink()
        vector org;
        float i;
 
-       if not (self.count)
+       if (!self.count)
                self.count = 40;
 
        // White shockwave
@@ -614,7 +613,7 @@ void onslaught_generator_damage(entity inflictor, entity attacker, float damage,
 #endif
                self.lasthealth = self.health;
        }
-       else if not(warmup_stage)
+       else if (!warmup_stage)
        {
                if (attacker == self)
                        bprint(Team_ColoredFullName(self.team), " generator spontaneously exploded due to overtime!\n");
@@ -910,13 +909,13 @@ void spawnfunc_onslaught_generator()
        precache_sound("onslaught/electricity_explode.wav");
        if (!self.team)
                objerror("team must be set");
-       
+
        if(self.team == NUM_TEAM_1)
         ons_red_generator = self;
 
        if(self.team == NUM_TEAM_2)
         ons_blue_generator = self;
-        
+
        self.team_saved = self.team;
        self.colormap = 1024 + (self.team - 1) * 17;
        self.solid = SOLID_BBOX;
@@ -956,7 +955,7 @@ void spawnfunc_onslaught_generator()
        waypoint_spawnforitem(self);
 
        onslaught_updatelinks();
-       
+
        self.reset = onslaught_generator_reset;
 }
 
@@ -1084,7 +1083,7 @@ void onslaught_controlpoint_icon_think()
         float _friendly_count = 0;
         float _dist;
         entity _player;
-        
+
         FOR_EACH_PLAYER(_player)
         {
             if(!_player.deadflag)
@@ -1226,7 +1225,7 @@ void onslaught_controlpoint_icon_buildthink()
        a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
        if(!a)
                return;
-    
+
        self.health = self.health + self.count;
 
        if (self.health >= self.max_health)
@@ -1271,7 +1270,7 @@ void onslaught_controlpoint_touch()
 {
        entity e;
        float a;
-       if not(IS_PLAYER(other))
+       if (!IS_PLAYER(other))
                return;
        a = onslaught_controlpoint_attackable(self, other.team);
        if(a != 2 && a != 4)
@@ -1304,6 +1303,12 @@ void onslaught_controlpoint_touch()
        onslaught_updatelinks();
 }
 
+void onslaught_controlpoint_think()
+{
+       self.nextthink = time;
+       CSQCMODEL_AUTOUPDATE();
+}
+
 void onslaught_controlpoint_reset()
 {
        if(self.goalentity && self.goalentity != world)
@@ -1316,8 +1321,9 @@ void onslaught_controlpoint_reset()
        self.isshielded = TRUE;
        self.enemy.solid = SOLID_NOT;
        self.enemy.colormap = self.colormap;
-       self.think = self.enemy.think = func_null;
-       self.nextthink = 0; // don't like func_null :P
+       self.think = onslaught_controlpoint_think;
+       self.enemy.think = func_null;
+       self.nextthink = time; // don't like func_null :P
        setmodel(self, "models/onslaught/controlpoint_pad.md3");
        //setsize(self, '-32 -32 0', '32 32 8');
 
@@ -1327,6 +1333,8 @@ void onslaught_controlpoint_reset()
 
        activator = self;
        SUB_UseTargets(); // to reset the structures, playerspawns etc.
+       
+       CSQCMODEL_AUTOUPDATE();
 }
 
 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
@@ -1397,6 +1405,9 @@ void spawnfunc_onslaught_controlpoint()
        self.enemy.colormap = self.colormap;
 
        waypoint_spawnforitem(self);
+       
+       self.think = onslaught_controlpoint_think;
+       self.nextthink = time;
 
        WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
        WaypointSprite_UpdateRule(self.sprite, NUM_TEAM_2, SPRITERULE_TEAMPLAY);
@@ -1404,6 +1415,8 @@ void spawnfunc_onslaught_controlpoint()
        onslaught_updatelinks();
 
        self.reset = onslaught_controlpoint_reset;
+       
+       CSQCMODEL_AUTOINIT();
 }
 
 float onslaught_link_send(entity to, float sendflags)
@@ -1524,24 +1537,24 @@ MUTATOR_HOOKFUNCTION(ons_BuildMutatorsPrettyString)
 
 MUTATOR_HOOKFUNCTION(ons_Spawn_Score)
 {
-    
+
     /*
     float _neer_home = (random() > 0.5 ? TRUE : FALSE);
-    
+
        RandomSelection_Init();
-       
+
        if(self.team == NUM_TEAM_1)
         RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1);
-       
+
        if(self.team == NUM_TEAM_2)
         RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1);
-       
+
        entity _cp = findchain(classname, "onslaught_controlpoint"):
        while _cp;
        {
-           if(_cp.team == self.team)            
+           if(_cp.team == self.team)
             RandomSelection_Add(_cp, 0, string_null, 1, 1);
-               
+
                _cp = _cp.chain;
        }
 
@@ -1552,9 +1565,9 @@ MUTATOR_HOOKFUNCTION(ons_Spawn_Score)
        }
        else if(self.team == spawn_spot.team)
                spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate
-    
+
     */
-    
+
        return 0;
 }
 
@@ -1562,55 +1575,55 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
 {
     if(!autocvar_g_onslaught_spawn_at_controlpoints)
         return 0;
-        
+
     if(random() < 0.5)  // 50/50 chane to use default spawnsystem.
         return 0;
-    
+
     float _close_to_home = ((random() > 0.5) ? TRUE : FALSE);
     entity _best = world, _trg_gen = world;
     float _score, _best_score = MAX_SHOT_DISTANCE;
-    
+
        RandomSelection_Init();
-    
+
        if(self.team == NUM_TEAM_1)
        {
            if(!_close_to_home)
             _trg_gen = ons_blue_generator;
-        else    
-            _trg_gen  = ons_red_generator;        
+        else
+            _trg_gen  = ons_red_generator;
        }
-       
+
        if(self.team == NUM_TEAM_2)
        {
            if(_close_to_home)
             _trg_gen = ons_blue_generator;
-        else    
-            _trg_gen  = ons_red_generator;        
+        else
+            _trg_gen  = ons_red_generator;
        }
-       
+
        entity _cp = findchain(classname, "onslaught_controlpoint");
        while(_cp)
        {
-           if(_cp.team == self.team)            
-        {            
+           if(_cp.team == self.team)
+        {
             _score = vlen(_trg_gen.origin - _cp.origin);
             if(_score < _best_score)
             {
                 _best = _cp;
-                _best_score = _score;            
+                _best_score = _score;
             }
-        }              
+        }
                _cp = _cp.chain;
        }
-       
-    vector _loc;        
-    float i;    
+
+    vector _loc;
+    float i;
     if(_best)
     {
         for(i = 0; i < 10; ++i)
         {
             _loc = _best.origin + '0 0 96';
-            _loc += ('0 1 0' * random()) * 128; 
+            _loc += ('0 1 0' * random()) * 128;
             tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
             if(trace_fraction == 1.0 && !trace_startsolid)
             {
@@ -1624,13 +1637,13 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
     {
         if(!autocvar_g_onslaught_spawn_at_generator)
             return 0;
-        
+
         _trg_gen = ((self.team == NUM_TEAM_1) ? ons_red_generator : ons_blue_generator);
-        
+
         for(i = 0; i < 10; ++i)
         {
             _loc = _trg_gen.origin + '0 0 96';
-            _loc += ('0 1 0' * random()) * 128; 
+            _loc += ('0 1 0' * random()) * 128;
             tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
             if(trace_fraction == 1.0 && !trace_startsolid)
             {
@@ -1640,7 +1653,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
             }
         }
     }
-    
+
     return 0;
 }
 
@@ -1649,8 +1662,6 @@ MUTATOR_HOOKFUNCTION(ons_MonsterThink)
        entity e = find(world, targetname, self.target);
        if (e != world)
                self.team = e.team;
-               
-       self.SendFlags |= MSF_STATUS; // update team
 
        return FALSE;
 }
@@ -1665,7 +1676,6 @@ MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
                if(e != world)
                {
                        self.team = e.team;
-                       self.SendFlags |= MSF_STATUS;
                        ee = e;
                }
        }