X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fcmd.qc;h=edc2420f6acf2cbecf4423dcaca6b966185eb918;hb=e8403b890ebeeb78eee50b449260a5b10aad2725;hp=c8c87e09687f49a6df6e356acd6e58eaf9cd2255;hpb=b7d32c1f333da63877913b30c861230243ce1213;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index c8c87e096..edc2420f6 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -150,8 +150,10 @@ void ClientCommand_join(float request) { if(IS_CLIENT(self)) { - if(!IS_PLAYER(self) && !lockteams) + if(!IS_PLAYER(self) && !lockteams && !gameover) { + if(self.caplayer) + return; if(nJoinAllowed(self)) { if(autocvar_g_campaign) { campaign_bots_may_start = 1; } @@ -267,7 +269,7 @@ void ClientCommand_mobspawn(float request, float argc) { entity e; string tospawn; - float moveflag; + float moveflag, monstercount = 0; moveflag = (argv(2) ? stof(argv(2)) : 1); // follow owner if not defined tospawn = strtolower(argv(1)); @@ -278,14 +280,21 @@ void ClientCommand_mobspawn(float request, float argc) return; } + FOR_EACH_MONSTER(e) + { + if(e.realowner == self) + ++monstercount; + } + if(autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { sprint(self, "Monster spawning is disabled.\n"); return; } else if(!IS_PLAYER(self)) { sprint(self, "You can't spawn monsters while spectating.\n"); return; } else if(MUTATOR_CALLHOOK(AllowMobSpawning)) { sprint(self, "Monster spawning is currently disabled by a mutator.\n"); return; } else if(!autocvar_g_monsters) { Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_MONSTERS_DISABLED); return; } else if(self.vehicle) { sprint(self, "You can't spawn monsters while driving a vehicle.\n"); return; } + else if(self.frozen) { sprint(self, "You can't spawn monsters while frozen.\n"); return; } else if(autocvar_g_campaign) { sprint(self, "You can't spawn monsters in campaign mode.\n"); return; } else if(self.deadflag != DEAD_NO) { sprint(self, "You can't spawn monsters while dead.\n"); return; } - 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"); return; } + else if(monstercount >= autocvar_g_monsters_max_perplayer) { sprint(self, "You have spawned too many monsters, kill some before trying to spawn any more.\n"); return; } 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"); return; } else if(tospawn != "") { @@ -302,16 +311,15 @@ void ClientCommand_mobspawn(float request, float argc) } } - if(found) + if(found || tospawn == "random") { - self.monstercount += 1; totalspawned += 1; makevectors(self.v_angle); 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); - e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, moveflag); + e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, FALSE, moveflag); sprint(self, strcat("Spawned ", e.monster_name, "\n")); @@ -333,6 +341,46 @@ void ClientCommand_mobspawn(float request, float argc) } } +void ClientCommand_physics(float request, float argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + string command = strtolower(argv(1)); + + if(!autocvar_g_physics_clientselect) + { + sprint(self, "Client physics selection is currently disabled.\n"); + return; + } + + if(command == "list" || command == "help") + { + sprint(self, strcat("Available physics sets: \n\n", autocvar_g_physics_clientselect_options, " default\n")); + return; + } + + if(Physics_Valid(command) || command == "default") + { + stuffcmd(self, strcat("\nseta cl_physics ", command, "\nsendcvar cl_physics\n")); + sprint(self, strcat("^2Physics set successfully changed to ^3", command, "\n")); + return; + } + } + + default: + sprint(self, strcat("Current physics set: ^3", self.cvar_cl_physics, "\n")); + case CMD_REQUEST_USAGE: + { + sprint(self, "\nUsage:^3 cmd physics \n"); + sprint(self, " See 'cmd physics list' for available physics sets.\n"); + sprint(self, " Argument 'default' resets to standard physics.\n"); + return; + } + } +} + void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness { switch(request) @@ -456,10 +504,11 @@ void ClientCommand_selectteam(float request, float argc) { if(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance) { + CheckAllowedTeams(self); GetTeamCounts(self); - if(!TeamSmallerEqThanTeam(selection, self.team, self)) + if(!TeamSmallerEqThanTeam(Team_TeamToNumber(selection), Team_TeamToNumber(self.team), self)) { - sprint(self, "Cannot change to a larger/better/shinier team\n"); + Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM); return; } } @@ -573,15 +622,11 @@ void ClientCommand_spectate(float request) } } - 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(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self))) + if((IS_PLAYER(self) || self.caplayer) && autocvar_sv_spectate == 1) { - sprint(self, "WARNING: you will spectate in the next round.\n"); - self.caplayer = 0; + if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self))) + Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_LEAVE); + ClientKill_TeamChange(-2); // observe } } return; // never fall through to usage @@ -728,6 +773,7 @@ void ClientCommand_(float request) CLIENT_COMMAND("mobedit", ClientCommand_mobedit(request, arguments), "Edit your monster's properties") \ CLIENT_COMMAND("mobkill", ClientCommand_mobkill(request), "Kills your monster") \ CLIENT_COMMAND("mobspawn", ClientCommand_mobspawn(request, arguments), "Spawn monsters infront of yourself") \ + CLIENT_COMMAND("physics", ClientCommand_physics(request, arguments), "Change physics set") \ CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \ CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \ CLIENT_COMMAND("say_team", ClientCommand_say_team(request, arguments, command), "Print a message to chat to all team mates") \