]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/superspec/superspec.qc
Cleanse more of the mutator hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / superspec / superspec.qc
index 142f9d9ba54dce3d379993b0cbfc794336435896..9913591af7cc70d2cfb89d6f8318071ae7fc4e61 100644 (file)
@@ -147,7 +147,7 @@ MUTATOR_HOOKFUNCTION(superspec, ItemTouch)
 }
 
 MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
-{SELFPARAM();
+{
 #define OPTIONINFO(flag,var,test,text,long,short) \
     var = strcat(var, ((flag & test) ? "^2[ON]  ^7" : "^1[OFF] ^7")); \
     var = strcat(var, text," ^7(^3 ", long, "^7 | ^3", short, " ^7)\n")
@@ -155,7 +155,11 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
        if(MUTATOR_RETURNVALUE) // command was already handled?
                return false;
 
-       if(IS_PLAYER(self))
+       entity player = M_ARGV(0, entity);
+       string cmd_name = M_ARGV(1, string);
+       int cmd_argc = M_ARGV(2, int);
+
+       if(IS_PLAYER(player))
                return false;
 
        if(cmd_name == "superspec_itemfilter")
@@ -166,24 +170,24 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                        _aspeco = "^7 superspec_itemfilter ^3\"item_classname1 item_classname2\"^7 only show thise items when ^2superspec ^3item_message^7 is on\n";
                        _aspeco = strcat(_aspeco, "^3 clear^7 Remove the filter (show all pickups)\n");
                        _aspeco = strcat(_aspeco, "^3 show ^7 Display current filter\n");
-                       superspec_msg("^3superspec_itemfilter help:\n\n\n", "\n^3superspec_itemfilter help:\n", self, _aspeco, 1);
+                       superspec_msg("^3superspec_itemfilter help:\n\n\n", "\n^3superspec_itemfilter help:\n", player, _aspeco, 1);
                }
                else if(argv(1) == "clear")
                {
-                       if(self.superspec_itemfilter != "")
-                               strunzone(self.superspec_itemfilter);
+                       if(player.superspec_itemfilter != "")
+                               strunzone(player.superspec_itemfilter);
 
-                       self.superspec_itemfilter = "";
+                       player.superspec_itemfilter = "";
                }
                else if(argv(1) == "show" || argv(1) == "")
                {
-                       if(self.superspec_itemfilter == "")
+                       if(player.superspec_itemfilter == "")
                        {
-                               superspec_msg("^3superspec_itemfilter^7 is ^1not^7 set", "\n^3superspec_itemfilter^7 is ^1not^7 set\n", self, "", 1);
+                               superspec_msg("^3superspec_itemfilter^7 is ^1not^7 set", "\n^3superspec_itemfilter^7 is ^1not^7 set\n", player, "", 1);
                                return true;
                        }
                        float i;
-                       float l = tokenize_console(self.superspec_itemfilter);
+                       float l = tokenize_console(player.superspec_itemfilter);
                        string _msg = "";
                        for(i = 0; i < l; ++i)
                                _msg = strcat(_msg, "^3#", ftos(i), " ^7", argv(i), "\n");
@@ -191,14 +195,14 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
 
                        _msg = strcat(_msg,"\n");
 
-                       superspec_msg("^3superspec_itemfilter is:\n\n\n", "\n^3superspec_itemfilter is:\n", self, _msg, 1);
+                       superspec_msg("^3superspec_itemfilter is:\n\n\n", "\n^3superspec_itemfilter is:\n", player, _msg, 1);
                }
                else
                {
-                       if(self.superspec_itemfilter != "")
-                               strunzone(self.superspec_itemfilter);
+                       if(player.superspec_itemfilter != "")
+                               strunzone(player.superspec_itemfilter);
 
-                       self.superspec_itemfilter = strzone(argv(1));
+                       player.superspec_itemfilter = strzone(argv(1));
                }
 
                return true;
@@ -218,13 +222,13 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                                _aspeco = strcat(_aspeco, "^3 verbose ^7(short^5 ve^7) makes superspectate print some additional information.\n");
                                _aspeco = strcat(_aspeco, "^3 item_message ^7(short^5 im^7) makes superspectate print items that were picked up.\n");
                                _aspeco = strcat(_aspeco, "^7    Use cmd superspec_itemfilter \"item_class1 item_class2\" to set up a filter of what to show with ^3item_message.\n");
-                               superspec_msg("^2Available Super Spectate ^3options:\n\n\n", "\n^2Available Super Spectate ^3options:\n", self, _aspeco, 1);
+                               superspec_msg("^2Available Super Spectate ^3options:\n\n\n", "\n^2Available Super Spectate ^3options:\n", player, _aspeco, 1);
                                return true;
                        }
 
                        if(argv(1) == "clear")
                        {
-                               self.superspec_flags = 0;
+                               player.superspec_flags = 0;
                                _start = 2;
                        }
 
@@ -232,13 +236,13 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                        {
                                if(argv(i) == "on" || argv(i) == "1")
                                {
-                                       self.superspec_flags |= _bits;
+                                       player.superspec_flags |= _bits;
                                        _bits = 0;
                                }
                                else if(argv(i) == "off" || argv(i) == "0")
                                {
                                        if(_start == 1)
-                                               self.superspec_flags &= ~_bits;
+                                               player.superspec_flags &= ~_bits;
 
                                        _bits = 0;
                                }
@@ -252,11 +256,11 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                }
 
                _aspeco = "";
-               OPTIONINFO(self.superspec_flags, _aspeco, SSF_SILENT, "Silent", "silent", "si");
-               OPTIONINFO(self.superspec_flags, _aspeco, SSF_VERBOSE, "Verbose", "verbose", "ve");
-               OPTIONINFO(self.superspec_flags, _aspeco, SSF_ITEMMSG, "Item pickup messages", "item_message", "im");
+               OPTIONINFO(player.superspec_flags, _aspeco, SSF_SILENT, "Silent", "silent", "si");
+               OPTIONINFO(player.superspec_flags, _aspeco, SSF_VERBOSE, "Verbose", "verbose", "ve");
+               OPTIONINFO(player.superspec_flags, _aspeco, SSF_ITEMMSG, "Item pickup messages", "item_message", "im");
 
-               superspec_msg("^3Current Super Spectate options are:\n\n\n\n\n", "\n^3Current Super Spectate options are:\n", self, _aspeco, 1);
+               superspec_msg("^3Current Super Spectate options are:\n\n\n\n\n", "\n^3Current Super Spectate options are:\n", player, _aspeco, 1);
 
                return true;
        }
@@ -281,14 +285,14 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                                _aspeco = strcat(_aspeco, "^3 item_msg ^7(short^5 im^7) to autospec when item_message in superspectate is triggered\n");
                                _aspeco = strcat(_aspeco, "^3 followkiller ^7(short ^5fk^7) to autospec the killer/off\n");
                                _aspeco = strcat(_aspeco, "^3 all ^7(short ^5aa^7) to turn everything on/off\n");
-                               superspec_msg("^2Available Auto Spectate ^3options:\n\n\n", "\n^2Available Auto Spectate ^3options:\n", self, _aspeco, 1);
+                               superspec_msg("^2Available Auto Spectate ^3options:\n\n\n", "\n^2Available Auto Spectate ^3options:\n", player, _aspeco, 1);
                                return true;
                        }
 
                        float i, _bits = 0, _start = 1;
                        if(argv(1) == "clear")
                        {
-                               self.autospec_flags = 0;
+                               player.autospec_flags = 0;
                                _start = 2;
                        }
 
@@ -296,13 +300,13 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                        {
                                if(argv(i) == "on" || argv(i) == "1")
                                {
-                                       self.autospec_flags |= _bits;
+                                       player.autospec_flags |= _bits;
                                        _bits = 0;
                                }
                                else if(argv(i) == "off" || argv(i) == "0")
                                {
                                        if(_start == 1)
-                                               self.autospec_flags &= ~_bits;
+                                               player.autospec_flags &= ~_bits;
 
                                        _bits = 0;
                                }
@@ -323,17 +327,17 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
                }
 
                _aspeco = "";
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_STRENGTH, "Strength", "strength", "st");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_SHIELD, "Shield", "shield", "sh");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_MEGA_HP, "Mega Health", "mega_health", "mh");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_MEGA_AR, "Mega Armor", "mega_armor", "ma");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_FLAG_GRAB, "Flag grab", "flag_grab","fg");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_OBSERVER_ONLY, "Only switch if observer", "observer_only", "oo");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_SHOWWHAT, "Show what item triggered spectate", "show_what", "sw");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_SSIM, "Switch on superspec item message", "item_msg", "im");
-               OPTIONINFO(self.autospec_flags, _aspeco, ASF_FOLLOWKILLER, "Followkiller", "followkiller", "fk");
-
-               superspec_msg("^3Current auto spectate options are:\n\n\n\n\n", "\n^3Current auto spectate options are:\n", self, _aspeco, 1);
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_STRENGTH, "Strength", "strength", "st");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_SHIELD, "Shield", "shield", "sh");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_MEGA_HP, "Mega Health", "mega_health", "mh");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_MEGA_AR, "Mega Armor", "mega_armor", "ma");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_FLAG_GRAB, "Flag grab", "flag_grab","fg");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_OBSERVER_ONLY, "Only switch if observer", "observer_only", "oo");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_SHOWWHAT, "Show what item triggered spectate", "show_what", "sw");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_SSIM, "Switch on superspec item message", "item_msg", "im");
+               OPTIONINFO(player.autospec_flags, _aspeco, ASF_FOLLOWKILLER, "Followkiller", "followkiller", "fk");
+
+               superspec_msg("^3Current auto spectate options are:\n\n\n\n\n", "\n^3Current auto spectate options are:\n", player, _aspeco, 1);
                return true;
        }
 
@@ -341,7 +345,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && (it.strength_finished > time || it.invincible_finished > time), LAMBDA(return superspec_Spectate(it)));
 
-               superspec_msg("", "", self, "No active powerup\n", 1);
+               superspec_msg("", "", player, "No active powerup\n", 1);
                return true;
        }
 
@@ -349,7 +353,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it.strength_finished > time, LAMBDA(return superspec_Spectate(it)));
 
-               superspec_msg("", "", self, "No active Strength\n", 1);
+               superspec_msg("", "", player, "No active Strength\n", 1);
                return true;
        }
 
@@ -357,7 +361,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, LAMBDA(return superspec_Spectate(it)));
 
-               superspec_msg("", "", self, "No active Shield\n", 1);
+               superspec_msg("", "", player, "No active Shield\n", 1);
                return true;
        }
 
@@ -435,6 +439,9 @@ MUTATOR_HOOKFUNCTION(superspec, ClientConnect)
 
 MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+
        FOREACH_CLIENT(IS_SPEC(it), LAMBDA(
                if(it.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && it.enemy == frag_target)
                {
@@ -450,7 +457,8 @@ MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
 
 MUTATOR_HOOKFUNCTION(superspec, ClientDisconnect)
 {
-       superspec_save_client_conf();
-       return false;
+       entity player = M_ARGV(0, entity);
+
+       WITHSELF(player, superspec_save_client_conf());
 }
 #endif