]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_ctf.qc
Cleanse more of the mutator hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ctf.qc
index 702ff45743214da4efcfc61623802c22a9a1f611..ab664794ad9b51ad55cca63cec0e56a11b904a82 100644 (file)
@@ -278,16 +278,16 @@ void ctf_CaptureShield_Update(entity player, bool wanted_status)
        }
 }
 
-bool ctf_CaptureShield_Customize()
-{SELFPARAM();
+bool ctf_CaptureShield_Customize(entity this)
+{
        if(!other.ctf_captureshielded) { return false; }
        if(CTF_SAMETEAM(self, other)) { return false; }
 
        return true;
 }
 
-void ctf_CaptureShield_Touch()
-{SELFPARAM();
+void ctf_CaptureShield_Touch(entity this)
+{
        if(!other.ctf_captureshielded) { return; }
        if(CTF_SAMETEAM(self, other)) { return; }
 
@@ -304,8 +304,8 @@ void ctf_CaptureShield_Spawn(entity flag)
 
        shield.enemy = self;
        shield.team = self.team;
-       shield.touch = ctf_CaptureShield_Touch;
-       shield.customizeentityforclient = ctf_CaptureShield_Customize;
+       settouch(shield, ctf_CaptureShield_Touch);
+       setcefc(shield, ctf_CaptureShield_Customize);
        shield.effects = EF_ADDITIVE;
        shield.movetype = MOVETYPE_NOCLIP;
        shield.solid = SOLID_TRIGGER;
@@ -471,7 +471,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype)
                        makevectors((player.v_angle.y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle.x, autocvar_g_ctf_throw_angle_max) * '1 0 0'));
 
                        flag_velocity = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & ITEM_Strength.m_itemid) ? autocvar_g_ctf_throw_strengthmultiplier : 1)));
-                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false);
+                       flag.velocity = W_CalculateProjectileVelocity(player, player.velocity, flag_velocity, false);
                        ctf_Handle_Drop(flag, player, droptype);
                        break;
                }
@@ -485,7 +485,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype)
                default:
                case DROP_NORMAL:
                {
-                       flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false);
+                       flag.velocity = W_CalculateProjectileVelocity(player, player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false);
                        ctf_Handle_Drop(flag, player, droptype);
                        break;
                }
@@ -747,8 +747,8 @@ void ctf_CheckFlagReturn(entity flag, int returntype)
        }
 }
 
-bool ctf_Stalemate_Customize()
-{SELFPARAM();
+bool ctf_Stalemate_Customize(entity this)
+{
        // make spectators see what the player would see
        entity e, wp_owner;
        e = WaypointSprite_getviewentity(other);
@@ -814,7 +814,7 @@ void ctf_CheckStalemate()
                        {
                                entity wp = WaypointSprite_Spawn(((ctf_oneflag) ? WP_FlagCarrier : WP_FlagCarrierEnemy), 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, 0, tmp_entity.owner, wps_enemyflagcarrier, true, RADARICON_FLAG);
                                wp.colormod = WPCOLOR_ENEMYFC(tmp_entity.owner.team);
-                               tmp_entity.owner.wps_enemyflagcarrier.customizeentityforclient = ctf_Stalemate_Customize;
+                               setcefc(tmp_entity.owner.wps_enemyflagcarrier, ctf_Stalemate_Customize);
                        }
                }
 
@@ -851,8 +851,8 @@ void ctf_FlagDamage(entity this, entity inflictor, entity attacker, float damage
        }
 }
 
-void ctf_FlagThink()
-{SELFPARAM();
+void ctf_FlagThink(entity this)
+{
        // declarations
        entity tmp_entity;
 
@@ -943,10 +943,8 @@ void ctf_FlagThink()
                                self.health = 0;
                                ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
 
-                               setself(self.owner);
-                               self.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
-                               ImpulseCommands(self);
-                               setself(this);
+                               self.owner.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
+                               ImpulseCommands(self.owner);
                        }
                        if(autocvar_g_ctf_stalemate)
                        {
@@ -1188,9 +1186,6 @@ void ctf_DelayedFlagSetup(entity this) // called after a flag is placed on a map
 
 void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
 {
-       // declarations
-       setself(flag); // for later usage with droptofloor()
-
        // main setup
        flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
        ctf_worldflaglist = flag;
@@ -1216,8 +1211,8 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        flag.velocity = '0 0 0';
        flag.mangle = flag.angles;
        flag.reset = ctf_Reset;
-       flag.touch = ctf_FlagTouch;
-       flag.think = ctf_FlagThink;
+       settouch(flag, ctf_FlagTouch);
+       setthink(flag, ctf_FlagThink);
        flag.nextthink = time + FLAG_THINKRATE;
        flag.ctf_status = FLAG_BASE;
 
@@ -1290,8 +1285,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        else // drop to floor, automatically find a platform and set that as spawn origin
        {
                flag.noalign = false;
-               setself(flag);
-               droptofloor();
+               droptofloor(flag);
                flag.movetype = MOVETYPE_TOSS;
        }
 
@@ -2035,6 +2029,11 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerPreThink)
 
 MUTATOR_HOOKFUNCTION(ctf, PlayerDamage_Calculate) // for changing damage and force values that are applied to players in g_damage.qc
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(frag_attacker.flagcarried) // if the attacker is a flagcarrier
        {
                if(frag_target == frag_attacker) // damage done to yourself
@@ -2047,6 +2046,9 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerDamage_Calculate) // for changing damage and for
                        frag_damage *= autocvar_g_ctf_flagcarrier_damagefactor;
                        frag_force *= autocvar_g_ctf_flagcarrier_forcefactor;
                }
+
+               M_ARGV(4, float) = frag_damage;
+               M_ARGV(6, vector) = frag_force;
        }
        else if(frag_target.flagcarried && !IS_DEAD(frag_target) && CTF_DIFFTEAM(frag_target, frag_attacker)) // if the target is a flagcarrier
        {
@@ -2063,6 +2065,9 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerDamage_Calculate) // for changing damage and for
 
 MUTATOR_HOOKFUNCTION(ctf, PlayerDies)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+
        if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)) && (frag_target.flagcarried))
        {
                PlayerTeamScore_AddScore(frag_attacker, ((SAME_TEAM(frag_attacker, frag_target)) ? -autocvar_g_ctf_score_kill : autocvar_g_ctf_score_kill));
@@ -2081,7 +2086,7 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerDies)
 
 MUTATOR_HOOKFUNCTION(ctf, GiveFragsForKill)
 {
-       frag_score = 0;
+       M_ARGV(2, float) = 0; // frag score
        return (autocvar_g_ctf_ignore_frags); // no frags counted in ctf if this is true
 }
 
@@ -2099,15 +2104,18 @@ void ctf_RemovePlayer(entity player)
 }
 
 MUTATOR_HOOKFUNCTION(ctf, MakePlayerObserver)
-{SELFPARAM();
-       ctf_RemovePlayer(self);
+{
+       entity player = M_ARGV(0, entity);
+
+       ctf_RemovePlayer(player);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ctf, ClientDisconnect)
-{SELFPARAM();
-       ctf_RemovePlayer(self);
-       return false;
+{
+       entity player = M_ARGV(0, entity);
+
+       ctf_RemovePlayer(player);
 }
 
 MUTATOR_HOOKFUNCTION(ctf, PortalTeleport)
@@ -2320,15 +2328,17 @@ MUTATOR_HOOKFUNCTION(ctf, HavocBot_ChooseRole)
 
 MUTATOR_HOOKFUNCTION(ctf, GetTeamCount)
 {
-       //ret_float = ctf_teams;
-       ret_string = "ctf_team";
+       //M_ARGV(0, float) = ctf_teams;
+       M_ARGV(1, string) = "ctf_team";
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(ctf, SpectateCopy)
-{SELFPARAM();
-       self.ctf_flagstatus = other.ctf_flagstatus;
-       return false;
+{
+       entity spectatee = M_ARGV(0, entity);
+       entity client = M_ARGV(1, entity);
+
+       client.ctf_flagstatus = spectatee.ctf_flagstatus;
 }
 
 MUTATOR_HOOKFUNCTION(ctf, GetRecords)
@@ -2355,8 +2365,11 @@ bool superspec_Spectate(entity _player); // TODO
 void superspec_msg(string _center_title, string _con_title, entity _to, string _msg, float _spamlevel); // TODO
 MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand)
 {
-    SELFPARAM();
-       if(IS_PLAYER(self) || MUTATOR_RETURNVALUE || !cvar("g_superspectate")) { return false; }
+       entity player = M_ARGV(0, entity);
+       string cmd_name = M_ARGV(1, string);
+       int cmd_argc = M_ARGV(2, int);
+
+       if(IS_PLAYER(player) || MUTATOR_RETURNVALUE || !cvar("g_superspectate")) { return false; }
 
        if(cmd_name == "followfc")
        {
@@ -2381,14 +2394,14 @@ MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand)
                        if(it.flagcarried && (it.team == _team || _team == 0))
                        {
                                found = true;
-                               if(_team == 0 && IS_SPEC(self) && self.enemy == it)
+                               if(_team == 0 && IS_SPEC(player) && player.enemy == it)
                                        continue; // already spectating this fc, try another
                                return superspec_Spectate(it);
                        }
                ));
 
                if(!found)
-                       superspec_msg("", "", self, "No active flag carrier\n", 1);
+                       superspec_msg("", "", player, "No active flag carrier\n", 1);
                return true;
        }
 
@@ -2397,6 +2410,8 @@ MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand)
 
 MUTATOR_HOOKFUNCTION(ctf, DropSpecialItems)
 {
+       entity frag_target = M_ARGV(0, entity);
+       
        if(frag_target.flagcarried)
                ctf_Handle_Throw(frag_target, world, DROP_THROW);
 
@@ -2421,9 +2436,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team1)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_1, self);
+       ctf_FlagSetup(NUM_TEAM_1, this);
 }
 
 /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2439,9 +2454,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team2)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_2, self);
+       ctf_FlagSetup(NUM_TEAM_2, this);
 }
 
 /*QUAKED spawnfunc_item_flag_team3 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2457,9 +2472,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team3)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_3, self);
+       ctf_FlagSetup(NUM_TEAM_3, this);
 }
 
 /*QUAKED spawnfunc_item_flag_team4 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2475,9 +2490,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team4)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_4, self);
+       ctf_FlagSetup(NUM_TEAM_4, this);
 }
 
 /*QUAKED spawnfunc_item_flag_neutral (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2493,10 +2508,10 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_neutral)
 {
-       if(!g_ctf) { remove(self); return; }
-       if(!cvar("g_ctf_oneflag")) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
+       if(!cvar("g_ctf_oneflag")) { remove(this); return; }
 
-       ctf_FlagSetup(0, self);
+       ctf_FlagSetup(0, this);
 }
 
 /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
@@ -2507,10 +2522,10 @@ Keys:
 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
 spawnfunc(ctf_team)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       self.classname = "ctf_team";
-       self.team = self.cnt + 1;
+       this.classname = "ctf_team";
+       this.team = this.cnt + 1;
 }
 
 // compatibility for quake maps