]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port kill command to QC so that we can use the health resource
authorMario <mario@smbclan.net>
Sun, 30 Sep 2018 17:58:53 +0000 (03:58 +1000)
committerMario <mario@smbclan.net>
Sun, 30 Sep 2018 17:58:53 +0000 (03:58 +1000)
qcsrc/server/clientkill.qc
qcsrc/server/command/cmd.qc

index 8d7293bb066214c1f5e47535be2ab93453f47c46..08758a06536f706bd722e6ed57549e0ae1b6d154 100644 (file)
@@ -195,8 +195,6 @@ void ClientKill_Silent(entity this, float _delay)
 // Called when a client types 'kill' in the console
 void ClientKill(entity this)
 {
-       // TODO: once .health is removed, will need to check it here for the "already dead" message!
-
        if (game_stopped || this.player_blocked || STAT(FROZEN, this))
                return;
 
index 915fea7ee0ca2ca02ffb14d9341d539b4b4a7d14..80716d811c8e1da75124b95edb4a23b2e2ea5150 100644 (file)
@@ -247,6 +247,36 @@ void ClientCommand_join(entity caller, int request)
        }
 }
 
+void ClientCommand_kill(entity caller, int request)
+{
+       switch (request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       if(IS_SPEC(caller) || IS_OBSERVER(caller))
+                               return; // no point warning about this, command does nothing
+
+                       if(GetResourceAmount(caller, RESOURCE_HEALTH) <= 0)
+                       {
+                               sprint(caller, "Can't die - you are already dead!\n");
+                               return;
+                       }
+
+                       ClientKill(caller);
+
+                       return;  // never fall through to usage
+               }
+
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       sprint(caller, "\nUsage:^3 cmd kill\n");
+                       sprint(caller, "  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
 void ClientCommand_physics(entity caller, int request, int argc)
 {
        switch (request)
@@ -730,6 +760,7 @@ void ClientCommand_(entity caller, int request)
        CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(ent, request, arguments), "Whether or not to switch automatically when getting a better weapon") \
        CLIENT_COMMAND("clientversion", ClientCommand_clientversion(ent, request, arguments), "Release version of the game") \
        CLIENT_COMMAND("join", ClientCommand_join(ent, request), "Become a player in the game") \
+       CLIENT_COMMAND("kill", ClientCommand_kill(ent, request), "Become a member of the dead") \
        CLIENT_COMMAND("minigame", ClientCommand_minigame(ent, request, arguments, command), "Start a minigame") \
        CLIENT_COMMAND("mv_getpicture", ClientCommand_mv_getpicture(ent, request, arguments), "Retrieve mapshot picture from the server") \
        CLIENT_COMMAND("physics", ClientCommand_physics(ent, request, arguments), "Change physics set") \