]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_ca.qc
Cleanse more of the mutator hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ca.qc
index c49bfa2188ec68b545a86d74d11c334dfc103dda..ff011b59deac11355d160bb3f10f6260c6f28ab3 100644 (file)
@@ -35,7 +35,6 @@ REGISTER_MUTATOR(ca, false)
                ca_teams = autocvar_g_ca_teams_override;
                if (ca_teams < 2) ca_teams = autocvar_g_ca_teams;
                ca_teams = bound(2, ca_teams, 4);
-               ret_float = ca_teams;
 
         ScoreRules_basics(ca_teams, SFL_SORT_PRIO_PRIMARY, 0, true);
         ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
@@ -220,22 +219,24 @@ entity CA_SpectateNext(entity player, entity start)
 
 MUTATOR_HOOKFUNCTION(ca, PlayerSpawn)
 {
-    SELFPARAM();
-       this.caplayer = 1;
+    entity player = M_ARGV(0, entity);
+
+       player.caplayer = 1;
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
 {
-    SELFPARAM();
-       if (!allowed_to_spawn && IS_PLAYER(this)) // this is true even when player is trying to join
+       entity player = M_ARGV(0, entity);
+
+       if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join
        {
-               TRANSMUTE(Observer, this);
-               if (this.jointime != time && !this.caplayer) // not when connecting
+               TRANSMUTE(Observer, player);
+               if (player.jointime != time && !player.caplayer) // not when connecting
                {
-                       this.caplayer = 0.5;
-                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_JOIN_LATE);
+                       player.caplayer = 0.5;
+                       Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
                }
        }
 }
@@ -274,8 +275,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_global)
 
 MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE)
 {
-       ret_float = ca_teams;
-       return false;
+       M_ARGV(0, float) = ca_teams;
 }
 
 entity ca_LastPlayerForTeam()
@@ -306,6 +306,8 @@ void ca_LastPlayerForTeam_Notify()
 
 MUTATOR_HOOKFUNCTION(ca, PlayerDies)
 {
+       entity frag_target = M_ARGV(2, entity);
+       
        ca_LastPlayerForTeam_Notify();
        if (!allowed_to_spawn)
                frag_target.respawn_flags =  RESPAWN_SILENT;
@@ -316,10 +318,11 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies)
 
 MUTATOR_HOOKFUNCTION(ca, ClientDisconnect)
 {
-    SELFPARAM();
-       if (this.caplayer == 1)
+    entity player = M_ARGV(0, entity);
+
+       if (player.caplayer == 1)
                ca_LastPlayerForTeam_Notify();
-       return 1;
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, ForbidPlayerScore_Clear)
@@ -329,13 +332,14 @@ MUTATOR_HOOKFUNCTION(ca, ForbidPlayerScore_Clear)
 
 MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
 {
-    SELFPARAM();
-       if (!IS_DEAD(this))
+    entity player = M_ARGV(0, entity);
+
+       if (!IS_DEAD(player))
                ca_LastPlayerForTeam_Notify();
-       if (this.killindicator_teamchange == -2)
-               this.caplayer = 0;
-       if (this.caplayer)
-               this.frags = FRAGS_LMS_LOSER;
+       if (player.killindicator_teamchange == -2)
+               player.caplayer = 0;
+       if (player.caplayer)
+               player.frags = FRAGS_LMS_LOSER;
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
        return true;  // prevent team reset
@@ -348,8 +352,8 @@ MUTATOR_HOOKFUNCTION(ca, ForbidThrowCurrentWeapon)
 
 MUTATOR_HOOKFUNCTION(ca, GiveFragsForKill, CBC_ORDER_FIRST)
 {
-       frag_score = 0; // score will be given to the winner team when the round ends
-       return 1;
+       M_ARGV(2, float) = 0; // score will be given to the winner team when the round ends
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, SetStartItems)
@@ -403,12 +407,16 @@ MUTATOR_HOOKFUNCTION(ca, FilterItem)
 
 MUTATOR_HOOKFUNCTION(ca, PlayerDamage_SplitHealthArmor)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_damage = M_ARGV(7, float);
+       float damage_take = M_ARGV(4, float);
+       float damage_save = M_ARGV(5, float);
+
        float excess = max(0, frag_damage - damage_take - damage_save);
 
        if (frag_target != frag_attacker && IS_PLAYER(frag_attacker))
                PlayerTeamScore_Add(frag_attacker, SP_SCORE, ST_SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ca, PlayerRegen)
@@ -489,8 +497,7 @@ MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
 
 MUTATOR_HOOKFUNCTION(ca, WantWeapon)
 {
-       want_allguns = true;
-       return false;
+       M_ARGV(2, bool) = true; // all weapons
 }
 
 MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus)