]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/magicear.qc
Remove SELFPARAM() from .think and .touch
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / magicear.qc
index f14b75c3124b983856400b620faf2af7dbc517ce..3287210409c8cd65b73cbd378e02920f5c7a70e4 100644 (file)
@@ -2,15 +2,14 @@
 float magicear_matched;
 float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
 string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin)
-{
+{SELFPARAM();
        float domatch, dotrigger, matchstart, l;
        string s, msg;
-       entity oldself;
        string savemessage;
 
        magicear_matched = false;
 
-       dotrigger = ((IS_PLAYER(source)) && (source.deadflag == DEAD_NO) && ((ear.radius == 0) || (vlen(source.origin - ear.origin) <= ear.radius)));
+       dotrigger = ((IS_PLAYER(source)) && (!IS_DEAD(source)) && ((ear.radius == 0) || (vdist(source.origin - ear.origin, <=, ear.radius))));
        domatch = ((ear.spawnflags & 32) || dotrigger);
 
        if (!domatch)
@@ -29,14 +28,10 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
 
                if(dotrigger)
                {
-                       oldself = self;
-                       activator = source;
-                       self = ear;
                        savemessage = self.message;
                        self.message = string_null;
-                       SUB_UseTargets();
+                       SUB_UseTargets(ear, source, NULL);
                        self.message = savemessage;
-                       self = oldself;
                }
 
                if(ear.netname != "")
@@ -120,14 +115,10 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
 
        if(dotrigger)
        {
-               oldself = self;
-               activator = source;
-               self = ear;
                savemessage = self.message;
                self.message = string_null;
-               SUB_UseTargets();
+               SUB_UseTargets(ear, source, NULL);
                self.message = savemessage;
-               self = oldself;
        }
 
        if(ear.spawnflags & 16)
@@ -165,10 +156,10 @@ string trigger_magicear_processmessage_forallears(entity source, float teamsay,
        return msgin;
 }
 
-void spawnfunc_trigger_magicear()
+spawnfunc(trigger_magicear)
 {
-       self.enemy = magicears;
-       magicears = self;
+       this.enemy = magicears;
+       magicears = this;
 
        // actually handled in "say" processing
        // spawnflags:
@@ -199,6 +190,6 @@ void spawnfunc_trigger_magicear()
        // movedir:
        //   for spawnflags 256, defines 'instrument+1 mintempo maxtempo' (zero component doesn't matter)
 
-       self.movedir_x -= 1; // map to tuba instrument numbers
+       this.movedir_x -= 1; // map to tuba instrument numbers
 }
 #endif