]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cache monster list reply like map list & allow spawning mutator-blocked monsters...
authorMario <mario.mario@y7mail.com>
Sat, 12 Oct 2013 16:33:23 +0000 (03:33 +1100)
committerMario <mario.mario@y7mail.com>
Sat, 12 Oct 2013 16:33:23 +0000 (03:33 +1100)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/util.qh
qcsrc/server/command/cmd.qc
qcsrc/server/command/getreplies.qc
qcsrc/server/command/getreplies.qh
qcsrc/server/g_world.qc
qcsrc/server/mutators/gamemode_invasion.qc

index bf56a6245db58b405eebea1c40fba63c068826cb..1ca5eca61f6b418a9abd48ec53fbe86ec6bd346b 100644 (file)
@@ -980,7 +980,7 @@ float monster_initialize(float mon_id, float nodrop)
 
        entity mon = get_monsterinfo(mon_id);
        
-       if(mon.spawnflags & MON_FLAG_MUTATORBLOCKED)
+       if(mon.spawnflags & MON_FLAG_MUTATORBLOCKED && !(self.spawnflags & MONSTERFLAG_SPAWNED))
        {
                dprint("Attempted to spawn a mutator-blocked monster rejected");
                return FALSE;
index d575bbfddbd3c32c3c70c9b210ebe6c76117b10c..6a16886df4b8add4075068db0f62fa270976e5a2 100644 (file)
@@ -208,7 +208,7 @@ float compressShotOrigin(vector v);
 vector decompressShotOrigin(float f);
 
 #ifdef SVQC
-string rankings_reply, ladder_reply, lsmaps_reply, maplist_reply; // cached replies
+string rankings_reply, ladder_reply, lsmaps_reply, maplist_reply, monsterlist_reply; // cached replies
 string records_reply[10];
 #endif
 
index 86cc80866c7beab98ebbcae32d56ae5b3b0b9854..3d1015dfcd7d5ffd33d0045f3f7ce0d137d2e383 100644 (file)
@@ -263,21 +263,14 @@ void ClientCommand_mobspawn(float request, float argc)
                        
                        if(tospawn == "list")
                        {
-                               float i;
-                               string list = "Available monsters:";
-                               
-                               for(i = MON_FIRST; i <= MON_LAST; ++i)
-                                       list = strcat(list, " ", (get_monsterinfo(i)).netname);
-                               
-                               sprint(self, strcat(list, "\n"));
-                               
+                               sprint(self, monsterlist_reply);
                                return;
                        }
                        
                        if(autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { sprint(self, "Monster spawning is disabled.\n"); }
                        else if(!IS_PLAYER(self)) { sprint(self, "You can't spawn monsters while spectating.\n"); }
                        else if(g_invasion) { sprint(self, "You can't spawn monsters during an invasion!\n"); }
-                       else if not(autocvar_g_monsters) { Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_MONSTERS_DISABLED); }
+                       else if(!autocvar_g_monsters) { Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_MONSTERS_DISABLED); }
                        else if(self.vehicle) { sprint(self, "You can't spawn monsters while driving a vehicle.\n"); }
                        else if(autocvar_g_campaign) { sprint(self, "You can't spawn monsters in campaign mode.\n"); }
                        else if(self.deadflag != DEAD_NO) { sprint(self, "You can't spawn monsters while dead.\n"); }
index 415d20f9cf34b3a14d3a4a615d8cb37d11d6498e..ed6f69ad1fb24d478c39e699fda63d1bbc024e4d 100644 (file)
@@ -340,3 +340,18 @@ string getlsmaps()
        MapInfo_ClearTemps();
        return sprintf("^7Maps available%s: %s\n", (newmaps ? " (New maps have asterisks marked in blue)" : ""), lsmaps);
 }
+
+string getmonsterlist()
+{
+       string monsterlist = "", col;
+       float i;
+       
+       for(i = MON_FIRST; i <= MON_LAST; ++i)
+       {
+               if(mod(i, 2)) { col = "^2"; }
+               else { col = "^3"; }
+               monsterlist = sprintf("%s%s%s ", monsterlist, col, (get_monsterinfo(i)).netname);
+       }
+       
+       return sprintf("^7Monsters available: %s\n", monsterlist);
+}
index 77da27219241db4d587b9304d9fc605aece1ca8e..583961d2246db10ce3907b411672100a92589b93 100644 (file)
@@ -17,3 +17,4 @@ string getrankings(void);
 string getladder(void);
 string getmaplist(void);
 string getlsmaps(void);
+string getmonsterlist(void);
index 3b83d6e1ef4da7ce8e18dc5119fba1ddb3a5c1ae..a32cdaa0ffcefc5b290e26d46b870ae28bb69b63 100644 (file)
@@ -824,6 +824,7 @@ void spawnfunc_worldspawn (void)
        // set up information replies for clients and server to use
        maplist_reply = strzone(getmaplist());
        lsmaps_reply = strzone(getlsmaps());
+       monsterlist_reply = strzone(getmonsterlist());
        for(i = 0; i < 10; ++i)
        {
                s = getrecords(i);
index 1f55f776ad43c3010cb424dda0fe9f87b897a29e..b93b4401271d7ce8849537628db00cfb64b02377 100644 (file)
@@ -305,11 +305,16 @@ MUTATOR_DEFINITION(gamemode_invasion)
        
        MUTATOR_ONADD
        {
+               float i;
+               
                if(time > 1) // game loads at time 1
                        error("This is a game type and it cannot be added at runtime.");
                invasion_Initialize();
                
                cvar_settemp("g_monsters", "1");
+               
+               for(i = MON_FIRST; i <= MON_LAST; ++i)
+                       get_monsterinfo(i).spawnflags &= ~MON_FLAG_MUTATORBLOCKED;
        }
 
        MUTATOR_ONROLLBACK_OR_REMOVE