X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fcmd.qc;h=898e7db18faf59a78afe5988320a8a21baa02ccb;hp=2974e1d538122e854c54962534003fb58496ee7d;hb=a6a3b0cebd6928e3678ee4e97de4093f1b61c58b;hpb=490131c400cb22079f9713ecb2d2830b84118987 diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 2974e1d538..898e7db18f 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; } @@ -193,28 +195,25 @@ void ClientCommand_mobedit(float request, float argc) makevectors(self.v_angle); WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self); - if(!autocvar_g_monsters_edit) { sprint(self, "Monster property editing is not enabled.\n"); } - if(!(trace_ent.flags & FL_MONSTER)) { sprint(self, "You need to aim at your monster to edit its properties.\n"); } - else if(trace_ent.realowner != self) { sprint(self, "That monster does not belong to you.\n"); } - else // all went well, continue + if(!autocvar_g_monsters_edit) { sprint(self, "Monster property editing is not enabled.\n"); return; } + if(trace_ent.flags & FL_MONSTER) { + if(trace_ent.realowner != self) { sprint(self, "That monster does not belong to you.\n"); return; } switch(argv(1)) { case "skin": { if(trace_ent.monsterid != MON_MAGE) trace_ent.skin = stof(argv(2)); - break; + return; } case "movetarget": { trace_ent.monster_moveflags = stof(argv(2)); - break; + return; } } } - - return; } } default: @@ -223,6 +222,7 @@ void ClientCommand_mobedit(float request, float argc) { sprint(self, "\nUsage:^3 cmd mobedit [argument]\n"); sprint(self, " Where 'argument' can be skin or movetarget.\n"); + sprint(self, " Aim at your monster to edit its properties.\n"); return; } } @@ -248,10 +248,6 @@ void ClientCommand_mobkill(float request) Damage (trace_ent, world, world, trace_ent.health + trace_ent.max_health + 200, DEATH_KILL, trace_ent.origin, '0 0 0'); return; } - else - sprint(self, "You need to aim at your monster to kill it.\n"); - - return; } default: @@ -273,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)); @@ -284,31 +280,52 @@ void ClientCommand_mobspawn(float request, float argc) 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(tospawn == "") { sprint(self, "No argument specified.\n"); } - else if(MUTATOR_CALLHOOK(AllowMobSpawning)) { sprint(self, "Monster spawning is currently disabled by a mutator.\n"); } - 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"); } - 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 + FOR_EACH_MONSTER(e) { - 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); + if(e.realowner == self) + ++monstercount; + } - e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, moveflag); + 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(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 != "") + { + float found = 0, i; + entity mon; - sprint(self, strcat("Spawned ", e.monster_name, "\n")); + for(i = MON_FIRST; i <= MON_LAST; ++i) + { + mon = get_monsterinfo(i); + if(mon.netname == tospawn) + { + found = TRUE; + break; + } + } + + if(found || tospawn == "random") + { + 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, FALSE, moveflag); + + sprint(self, strcat("Spawned ", e.monster_name, "\n")); + + return; + } } - - return; } default: @@ -316,7 +333,7 @@ void ClientCommand_mobspawn(float request, float argc) case CMD_REQUEST_USAGE: { sprint(self, "\nUsage:^3 cmd mobspawn [movetype]\n"); - sprint(self, " See 'cmd mobspawn list' for available arguments.\n"); + sprint(self, " See 'cmd mobspawn list' for available monsters.\n"); sprint(self, " Argument 'random' spawns a random monster.\n"); sprint(self, " Monster will follow the owner if second argument is not defined.\n"); return; @@ -444,7 +461,19 @@ void ClientCommand_selectteam(float request, float argc) else if(self.wasplayer && autocvar_g_changeteam_banned) sprint(self, "^1You cannot change team, forbidden by the server.\n"); else + { + if(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance) + { + CheckAllowedTeams(self); + GetTeamCounts(self); + if(!TeamSmallerEqThanTeam(Team_TeamToNumber(selection), Team_TeamToNumber(self.team), self)) + { + Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM); + return; + } + } ClientKill_TeamChange(selection); + } } } else @@ -553,15 +582,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