]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow spawning monsters by ID & remove spawn list
authorMario <mario.mario@y7mail.com>
Sun, 2 Jun 2013 12:03:53 +0000 (22:03 +1000)
committerMario <mario.mario@y7mail.com>
Sun, 2 Jun 2013 12:03:53 +0000 (22:03 +1000)
monsters.cfg
qcsrc/server/autocvars.qh
qcsrc/server/command/cmd.qc
qcsrc/server/command/cmd.qh
qcsrc/server/monsters/lib/monsters_early.qh
qcsrc/server/monsters/lib/spawn.qc
qcsrc/server/mutators/gamemode_towerdefense.qc

index 7423a323ef78e1ccc6523d9e6f37686e4c572567..00c63645ca055f3a89c5f19737aa1d8047eda2e2 100644 (file)
@@ -25,7 +25,6 @@ set g_monsters_skill_normal 4 "Monster normal skill level (used for skill based
 set g_monsters_skill_hard 5 "Monster hard skill level (used for skill based functions)"
 set g_monsters_skill_insane 7 "Monster insane skill level (used for skill based functions)"
 set g_monsters_skill_nightmare 10 "Monster nightmare skill level (used for skill based functions)"
-set g_monsters_spawn_list "brute animus shambler bruiser wyvern cerberus slime knight stingray mage zombie spider" "monsters not listed here will spawn as bruisers"
 
 // Brute
 set g_monster_brute 1 "Enable Brutes"
index 4457c603aa7ce2a68b3d9e9751f39ad102ee7de4..7236c4e7fa6c807dea96a676e7e2169dcb492f06 100644 (file)
@@ -1254,7 +1254,6 @@ float autocvar_g_monsters_skill_normal;
 float autocvar_g_monsters_skill_hard;
 float autocvar_g_monsters_skill_insane;
 float autocvar_g_monsters_skill_nightmare;
-string autocvar_g_monsters_spawn_list;
 float autocvar_g_touchexplode_radius;
 float autocvar_g_touchexplode_damage;
 float autocvar_g_touchexplode_edgedamage;
index 7814abef236b24b2d49b79d55758f4fd95d89650..941e6b5e25bb1eb4d49ef05b63ec864a8f742a79 100644 (file)
@@ -265,8 +265,14 @@ void ClientCommand_mobspawn(float request, float argc)
                        
                        if(tospawn == "list")
                        {
-                               sprint(self, "Available monsters:\n");
-                               sprint(self, strcat(autocvar_g_monsters_spawn_list, "\n"));
+                               float i;
+                               string list = "Available monsters:";
+                               
+                               for(i = MONSTER_FIRST + 1; i < MONSTER_LAST; ++i)
+                                       list = strcat(list, " ", monster_id2string(i));
+                               
+                               sprint(self, strcat(list, "\n"));
+                               
                                return;
                        }
                        
@@ -287,7 +293,7 @@ void ClientCommand_mobspawn(float request, float argc)
                                makevectors(self.v_angle);
                                WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 150, MOVE_NORMAL, self);
                        
-                               e = spawnmonster(tospawn, self, self, trace_endpos, FALSE, moveflag);
+                               e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, moveflag);
                                if(mname) e.netname = strzone(mname);
                        
                                sprint(self, strcat("Spawned 1 ", tospawn, "\n"));
index b0118c5cf327503b77ee3245f3b9082cd4a37b72..45d1f7584cef1663b5d6909d67714092360eaea5 100644 (file)
@@ -13,7 +13,7 @@ float totalspawned;
 
 string MapVote_Suggest(string m);
 
-entity spawnmonster(string monster, entity spawnedby, entity own, vector orig, float respwn, float moveflag);
+entity spawnmonster(string monster, float mnster, entity spawnedby, entity own, vector orig, float respwn, float moveflag);
 
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 void ClientCommand_macro_write_aliases(float fh);
index 0bda379d2daa47380ae7708702b0c2a367cb6b98..717d14c8082a12b218df9a3105a34677c8ba5f6b 100644 (file)
@@ -36,6 +36,46 @@ float MONSTER_MAGE                   = 12;
 float MONSTER_SPIDER           = 13;
 float MONSTER_LAST                     = 14;
 
+// id-string converters (TODO: remove these!)
+string monster_id2string(float mnster)
+{
+       switch(mnster)
+       {
+               case MONSTER_ZOMBIE:    return "zombie";
+               case MONSTER_BRUTE:     return "brute";
+               case MONSTER_ANIMUS:    return "animus";
+               case MONSTER_SHAMBLER:  return "shambler";
+               case MONSTER_BRUISER:   return "bruiser";
+               case MONSTER_WYVERN:    return "wyvern";
+               case MONSTER_CERBERUS:  return "cerberus";
+               case MONSTER_SLIME:     return "slime";
+               case MONSTER_KNIGHT:    return "knight";
+               case MONSTER_STINGRAY:  return "stingray";
+               case MONSTER_MAGE:              return "mage";
+               case MONSTER_SPIDER:    return "spider";
+               default: return "";
+       }
+}
+float monster_string2id(string monster)
+{
+       switch(monster)
+       {
+               case "zombie":          return MONSTER_ZOMBIE;
+               case "brute":           return MONSTER_BRUTE;
+               case "animus":          return MONSTER_ANIMUS;
+               case "shambler":        return MONSTER_SHAMBLER;
+               case "bruiser":         return MONSTER_BRUISER;
+               case "wyvern":          return MONSTER_WYVERN;
+               case "cerberus":        return MONSTER_CERBERUS;
+               case "slime":           return MONSTER_SLIME;
+               case "knight":          return MONSTER_KNIGHT;
+               case "stingray":        return MONSTER_STINGRAY;
+               case "mage":            return MONSTER_MAGE;
+               case "spider":          return MONSTER_SPIDER;
+               default:                        return 0;
+       }
+}
+
 float MSF_UPDATE       = 2;
 float MSF_STATUS       = 4;
 float MSF_SETUP        = 8;
index a756fad11b134b7eb960c624668b239c08b3a764..b985c7f2ce5a2e1d0605c26c403249efd49a1354 100644 (file)
@@ -1,14 +1,4 @@
-float spawnmonster_checkinlist(string monster, string list)
-{
-       string l = strcat(" ", list, " ");
-       
-       if(strstrofs(l, strcat(" ", monster, " "), 0) >= 0)
-               return TRUE;
-       
-       return FALSE;
-}
-
-entity spawnmonster (string monster, entity spawnedby, entity own, vector orig, float respwn, float moveflag)
+entity spawnmonster (string monster, float mnster, entity spawnedby, entity own, vector orig, float respwn, float moveflag)
 {
        if(!spawncode_first_load)
        {
@@ -25,8 +15,13 @@ entity spawnmonster (string monster, entity spawnedby, entity own, vector orig,
        
        setorigin(e, orig);
        
-       if not(spawnmonster_checkinlist(monster, autocvar_g_monsters_spawn_list))
+       if(monster != "")
+       if not(monster_string2id(monster))
                monster = "bruiser";
+               
+       if(monster == "")
+       if(mnster)
+               monster = monster_id2string(mnster);
        
        e.realowner = spawnedby;
        
index f4519da4c2fc19b40f96308fb6fe2b94c0337f6c..a0a210ed803dd5c603aac33aa432352295fa3db4 100644 (file)
@@ -187,7 +187,7 @@ entity PickSpawn (float tm)
        return RandomSelection_chosen_ent;
 }
 
-void TD_SpawnMonster(float tm, string mnster)
+void TD_SpawnMonster(float tm, float monster)
 {
        entity e, mon;
        
@@ -199,7 +199,7 @@ void TD_SpawnMonster(float tm, string mnster)
                return;
        }
   
-       mon = spawnmonster(mnster, e, e, e.origin, FALSE, 2);
+       mon = spawnmonster("", monster, e, e, e.origin, FALSE, 2);
        if(e.target2)
        {
                if(random() <= 0.5 && e.target)
@@ -211,26 +211,6 @@ void TD_SpawnMonster(float tm, string mnster)
                mon.target2 = e.target;
 }
 
-string monster_type2string(float mnster)
-{
-       switch(mnster)
-       {
-               case MONSTER_ZOMBIE: return "zombie";
-               case MONSTER_BRUTE: return "brute";
-               case MONSTER_ANIMUS: return "animus";
-               case MONSTER_SHAMBLER: return "shambler";
-               case MONSTER_BRUISER: return "bruiser";
-               case MONSTER_WYVERN: return "wyvern";
-               case MONSTER_CERBERUS: return "cerberus";
-               case MONSTER_SLIME: return "slime";
-               case MONSTER_KNIGHT: return "knight";
-               case MONSTER_STINGRAY: return "stingray";
-               case MONSTER_MAGE: return "mage";
-               case MONSTER_SPIDER: return "spider";
-               default: return "";
-       }
-}
-
 float RandomMonster()
 {
        RandomSelection_Init();
@@ -254,7 +234,7 @@ void SpawnMonsters(float tm)
        
        whichmon = RandomMonster();
        
-       TD_SpawnMonster(tm, monster_type2string(whichmon));
+       TD_SpawnMonster(tm, whichmon);
 }
 
 entity PickGenerator(float tm)