]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/cmd.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / cmd.qc
index 35bb12cbb7a086ecc255f0a9b8d0c1507d25ff4c..5baf7ded5e16c655ef6d3394215e7f018e01f01a 100644 (file)
@@ -81,7 +81,7 @@ void ClientCommand_clientversion(float request, float argc) // internal command,
                {
                        if(argv(1) != "")
                        {
-                               if(self.flags & FL_CLIENT)
+                               if(IS_CLIENT(self))
                                {
                                        self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1)));
                                        
@@ -148,18 +148,16 @@ void ClientCommand_join(float request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if(self.flags & FL_CLIENT)
+                       if(IS_CLIENT(self))
                        {
-                               if(self.classname != "player" && !lockteams && !g_arena)
+                               if(!IS_PLAYER(self) && !lockteams && !g_arena)
                                {
                                        if(nJoinAllowed(self)) 
                                        {
-                                               if(g_ca) { self.caplayer = 1; }
                                                if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
-                                               
+
                                                self.classname = "player";
                                                PlayerScore_Clear(self);
-                                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
                                                Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
                                                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname);
                                                PutClientInServer();
@@ -167,7 +165,7 @@ void ClientCommand_join(float request)
                                        else 
                                        {
                                                //player may not join because of g_maxplayers is set
-                                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
+                                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_PREVENT);
                                        }
                                }
                        }
@@ -198,20 +196,16 @@ void ClientCommand_mobedit(float request, float argc)
                        
                        switch(argv(1))
                        {
-                               case "name": trace_ent.netname = strzone(strdecolorize(argv(2))); if(trace_ent.sprite) WaypointSprite_UpdateSprites(trace_ent.sprite, trace_ent.netname, "", ""); break;
-                               case "skin": trace_ent.skin = stof(argv(2)); trace_ent.SendFlags |= MSF_STATUS; break;
-                               case "movetarget": trace_ent.monster_moveflags = stof(argv(2)); break;
-                               default: sprint(self, "Unknown parameter\n"); break;
+                               case "skin": if(trace_ent.monsterid != MON_MAGE) { trace_ent.skin = stof(argv(2)); trace_ent.SendFlags |= MSF_STATUS; } return;
+                               case "movetarget": trace_ent.monster_moveflags = stof(argv(2)); return;
                        }
-                       
-                       return; // never fall through to usage
                }
                default:
                        sprint(self, "Incorrect parameters for ^2mobedit^7\n");
                case CMD_REQUEST_USAGE:
                {
                        sprint(self, "\nUsage:^3 cmd mobedit [argument]\n");
-                       sprint(self, "  Where 'argument' can be name, skin, color or movetarget.\n");
+                       sprint(self, "  Where 'argument' can be skin or movetarget.\n");
                        return;
                }
        }
@@ -233,7 +227,7 @@ void ClientCommand_mobkill(float request)
                                        sprint(self, "That monster does not belong to you.\n");
                                        return;
                                }
-                               sprint(self, strcat("Your pet '", trace_ent.netname, "' has been brutally mutilated.\n"));
+                               sprint(self, strcat("Your pet '", trace_ent.monster_name, "' has been brutally mutilated.\n"));
                                Damage (trace_ent, world, world, trace_ent.health + trace_ent.max_health + 200, DEATH_KILL, trace_ent.origin, '0 0 0');
                                return;
                        }
@@ -261,27 +255,32 @@ void ClientCommand_mobspawn(float request, float argc)
                case CMD_REQUEST_COMMAND:
                {
                        entity e;
-                       string tospawn, mname;
+                       string tospawn;
                        float moveflag;
                        
                        moveflag = (argv(2) ? stof(argv(2)) : 1); // follow owner if not defined
-                       tospawn = argv(1);
-                       mname = argv(3);
+                       tospawn = strtolower(argv(1));
                        
                        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 = MON_FIRST; i <= MON_LAST; ++i)
+                                       list = strcat(list, " ", (get_monsterinfo(i)).netname);
+                               
+                               sprint(self, strcat(list, "\n"));
+                               
                                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(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(g_td) { sprint(self, "You can't spawn monsters in Tower Defense mode.\n"); }
-                       else if(self.deadflag) { sprint(self, "You can't spawn monsters while dead.\n"); }
+                       else if(self.deadflag != DEAD_NO) { sprint(self, "You can't spawn monsters while dead.\n"); }
                        else if(self.monstercount >= autocvar_g_monsters_max_perplayer) { sprint(self, "You have spawned too many monsters, kill some before trying to spawn any more.\n"); }
                        else if(totalspawned >= autocvar_g_monsters_max) { sprint(self, "The global maximum monster count has been reached, kill some before trying to spawn any more.\n"); }
                        else // all worked out, so continue
@@ -290,12 +289,12 @@ void ClientCommand_mobspawn(float request, float argc)
                                totalspawned += 1;
                        
                                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);
-                               if(mname) e.netname = strzone(mname);
+                               WarpZone_TraceBox (CENTER_OR_VIEWOFS(self), PL_MIN, PL_MAX, CENTER_OR_VIEWOFS(self) + v_forward * 150, TRUE, self);
+                               //WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 150, MOVE_NORMAL, self);
                        
-                               sprint(self, strcat("Spawned 1 ", tospawn, "\n"));
+                               e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, moveflag);
+                               
+                               sprint(self, strcat("Spawned ", e.monster_name, "\n"));
                        }
                        
                        return;
@@ -318,12 +317,14 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if(self.flags & FL_CLIENT)
+                       if(IS_CLIENT(self))
                        {
-                               if(inWarmupStage || autocvar_sv_ready_restart || g_race_qualifying == 2)
+                               if(warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2)
                                {
                                        if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
                                        {
+                                               if(time < game_starttime) // game is already restarting
+                                                       return;
                                                if (self.ready) // toggle
                                                {
                                                        self.ready = FALSE;
@@ -404,7 +405,7 @@ void ClientCommand_selectteam(float request, float argc)
                {
                        if(argv(1) != "")
                        {
-                               if(self.flags & FL_CLIENT)
+                               if(IS_CLIENT(self))
                                {
                                        if(teamplay)
                                                if not(self.team_forced > 0) 
@@ -520,7 +521,7 @@ void ClientCommand_spectate(float request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if(self.flags & FL_CLIENT)
+                       if(IS_CLIENT(self))
                        {
                                if(g_arena) { return; } 
                                if(g_lms)
@@ -540,12 +541,12 @@ void ClientCommand_spectate(float request)
                                        }
                                }
                                
-                               if(self.classname == "player" && autocvar_sv_spectate == 1) 
+                               if(IS_PLAYER(self) && autocvar_sv_spectate == 1) 
                                        ClientKill_TeamChange(-2); // observe
-                               
+
                                // in CA, allow a dead player to move to spectators (without that, caplayer!=0 will be moved back to the player list)
                                // note: if arena game mode is ever done properly, this needs to be removed.
-                               if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer"))
+                               if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self)))
                                {
                                        sprint(self, "WARNING: you will spectate in the next round.\n");
                                        self.caplayer = 0;