]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up tower defense monster counting a bit
authorMario <mario.mario@y7mail.com>
Sat, 11 May 2013 11:19:04 +0000 (21:19 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 11 May 2013 11:19:04 +0000 (21:19 +1000)
qcsrc/server/g_damage.qc
qcsrc/server/mutators/gamemode_towerdefense.qc
qcsrc/server/mutators/gamemode_towerdefense.qh

index 91b03454be1d3d162446274f58d350c57e07d80b..d4bb9a44982bdbe9bb87b12243cfb5da18e62eee 100644 (file)
@@ -595,6 +595,9 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
 
 void Unfreeze (entity targ)
 {
+       if not(targ.frozen)
+               return; // not even frozen?
+               
        targ.frozen = 0;
        targ.revive_progress = 0;
        targ.health = ((targ.classname == STR_PLAYER) ? autocvar_g_balance_health_start : targ.max_health);
index 7e02ac1716a1ddaea3d704abeff38d305b200586..fcd2618a69f9886b2f2de262265771468a9d53f4 100644 (file)
@@ -1,5 +1,7 @@
 // Tower Defense
 // Gamemode by Mario
+
+float td_moncount[MONSTER_LAST];
  
 void spawnfunc_td_controller()
 {
@@ -444,18 +446,14 @@ float RandomMonster()
 {
        RandomSelection_Init();
        
-       if(n_animuses) RandomSelection_Add(world, MONSTER_ANIMUS, "", 1, 1);
-       if(n_mages) RandomSelection_Add(world, MONSTER_MAGE, "", 1, 1);
-       if(n_knights) RandomSelection_Add(world, MONSTER_KNIGHT, "", 1, 1);
-       if(n_zombies) RandomSelection_Add(world, MONSTER_ZOMBIE, "", 1, 1);
-       if(n_spiders) RandomSelection_Add(world, MONSTER_SPIDER, "", 1, 1);
-       if(n_brutes) RandomSelection_Add(world, MONSTER_BRUTE, "", 1, 1);
-       if(n_cerberuses) RandomSelection_Add(world, MONSTER_CERBERUS, "", 1, 1);
-       if(n_bruisers) RandomSelection_Add(world, MONSTER_BRUISER, "", 1, 1);
-       if(n_shamblers) RandomSelection_Add(world, MONSTER_SHAMBLER, "", 0.2, 0.2);
-       if(n_slimes) RandomSelection_Add(world, MONSTER_SLIME, "", 0.2, 0.2);
-       if(n_wyverns && flyspawns_count) RandomSelection_Add(world, MONSTER_WYVERN, "", 1, 1);
-       if(n_stingrays && waterspawns_count) RandomSelection_Add(world, MONSTER_STINGRAY, "", 0.2, 0.2);
+       float i;
+       
+       for(i = 2; i < MONSTER_LAST; ++i)
+       if(td_moncount[i])
+       if(i == MONSTER_STINGRAY || i == MONSTER_SHAMBLER || i == MONSTER_SLIME)
+               RandomSelection_Add(world, i, "", 0.2, 0.2);
+       else
+               RandomSelection_Add(world, i, "", 1, 1);
        
        return RandomSelection_chosen_float;
 }
@@ -474,10 +472,9 @@ void combat_phase()
        
        self.think = combat_phase;
        
-       whichmon = RandomMonster();
-       
-       mstrength = Monster_GetStrength(whichmon);
-       montype = Monster_GetType(whichmon);
+       whichmon        = RandomMonster();
+       mstrength       = Monster_GetStrength(whichmon);
+       montype         = Monster_GetType(whichmon);
        
        if(current_monsters <= max_current && whichmon)
        {
@@ -498,20 +495,26 @@ void queue_monsters(float maxmonsters)
                mc += 1;
                
        DistributeEvenly_Init(maxmonsters, mc);
-       n_animuses              = DistributeEvenly_Get(1);
-       n_brutes                = DistributeEvenly_Get(1);
-       n_cerberuses    = DistributeEvenly_Get(1);
-       n_bruisers      = DistributeEvenly_Get(1);
-       n_mages                 = DistributeEvenly_Get(1);
-       n_knights       = DistributeEvenly_Get(1);
-       n_zombies       = DistributeEvenly_Get(1);
-       n_spiders       = DistributeEvenly_Get(1);
-       n_slimes                = DistributeEvenly_Get(0.7);
-       n_shamblers     = DistributeEvenly_Get(0.3);
-       if(flyspawns_count > 0)
-               n_wyverns = DistributeEvenly_Get(1);
-       if(waterspawns_count > 0)
-               n_stingrays = DistributeEvenly_Get(1);
+       
+       float i;
+       
+       for(i = 2; i < MONSTER_LAST; ++i)
+       {
+               if(i == MONSTER_WYVERN)
+               if(flyspawns_count < 1)
+                       continue;
+                       
+               if(i == MONSTER_STINGRAY)
+               if(waterspawns_count < 1)
+                       continue;
+       
+               if(i == MONSTER_SLIME)
+                       td_moncount[i] = DistributeEvenly_Get(0.7);
+               else if(i == MONSTER_SHAMBLER)
+                       td_moncount[i] = DistributeEvenly_Get(0.3);
+               else
+                       td_moncount[i] = DistributeEvenly_Get(1);
+       }
 }
 
 void combat_phase_begin()
@@ -836,21 +839,7 @@ MUTATOR_HOOKFUNCTION(td_MonsterSpawn)
        
        self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_CORPSE | DPCONTENTS_MONSTERCLIP;
        
-       switch(self.monsterid)
-       {
-               case MONSTER_ZOMBIE: n_zombies -= 1; break;
-               case MONSTER_BRUTE: n_brutes -= 1; break;
-               case MONSTER_ANIMUS: n_animuses -= 1; break;
-               case MONSTER_SHAMBLER: n_shamblers -= 1; break;
-               case MONSTER_BRUISER: n_bruisers -= 1; break;
-               case MONSTER_WYVERN: n_wyverns -= 1; break;
-               case MONSTER_CERBERUS: n_cerberuses -= 1; break;
-               case MONSTER_SLIME: n_slimes -= 1; break;
-               case MONSTER_KNIGHT: n_knights -= 1; break;
-               case MONSTER_STINGRAY: n_stingrays -= 1; break;
-               case MONSTER_MAGE: n_mages -= 1; break;
-               case MONSTER_SPIDER: n_spiders -= 1; break;
-       }
+       td_moncount[self.monsterid] -= 1;
        
        return TRUE;
 }
index 92b2be424a728942f96ac4deaca41c0c5fe463b2..8864ee75a2ccf08bca93a6f65373aed49cbab90f 100644 (file)
@@ -1,6 +1,5 @@
 // Counters
 float monster_count, totalmonsters;
-float n_bruisers, n_cerberuses, n_brutes, n_shamblers, n_wyverns, n_mages, n_knights, n_animuses, n_zombies, n_slimes, n_stingrays, n_spiders;
 float current_monsters;
 float waterspawns_count, flyspawns_count;
 float wave_count, max_waves;