]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/keylock.qc
Merge branch 'master' into Mario/use1
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / keylock.qc
index ec27d4b77fb9348363153f8ca81214e4867c695f..cc45e2490fd5e6641af04b86771bf91b0a97a01e 100644 (file)
@@ -1,25 +1,11 @@
 /**
  * trigger given targets
  */
-void trigger_keylock_trigger(string s)
+void trigger_keylock_trigger(entity this, entity actor, string s)
 {
-       entity stemp = self;
-       entity otemp = other;
-       entity atemp = activator;
-
-       entity t;
-       for(t = world; (t = find(t, targetname, s)); )
-               if(t.use)
-               {
-                       self = t;
-                       other = stemp;
-                       activator = atemp;
-                       self.use();
-               }
-
-       self = stemp;
-       other = otemp;
-       activator = atemp;
+       for(entity t = world; (t = find(t, targetname, s)); )
+               if(t.use1)
+                       t.use1(t, actor, this);
 }
 
 /**
@@ -33,7 +19,7 @@ void trigger_keylock_kill(string s)
 }
 
 void trigger_keylock_touch()
-{
+{SELFPARAM();
        bool key_used = false;
        bool started_delay = false;
 
@@ -45,8 +31,6 @@ void trigger_keylock_touch()
        if(self.itemkeys)
                key_used = item_keys_usekey(self, other);
 
-       activator = other;
-
        if(self.itemkeys)
        {
 #ifdef SVQC
@@ -71,7 +55,7 @@ void trigger_keylock_touch()
                if(self.delay <= time || started_delay == true)
                if(self.target2)
                {
-                       trigger_keylock_trigger(self.target2);
+                       trigger_keylock_trigger(this, other, self.target2);
                        started_delay = true;
                        self.delay = time + self.wait;
                }
@@ -85,7 +69,7 @@ void trigger_keylock_touch()
 #endif
 
                if(self.target)
-                       trigger_keylock_trigger(self.target);
+                       trigger_keylock_trigger(this, other, self.target);
 
                if(self.killtarget)
                        trigger_keylock_kill(self.killtarget);
@@ -95,15 +79,17 @@ void trigger_keylock_touch()
 
 }
 
+REGISTER_NET_LINKED(ENT_CLIENT_KEYLOCK)
+
 #ifdef SVQC
 bool trigger_keylock_send(entity to, int sf)
-{
-       WriteByte(MSG_ENTITY, ENT_CLIENT_KEYLOCK);
+{SELFPARAM();
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_KEYLOCK);
 
        WriteInt24_t(MSG_ENTITY, self.itemkeys);
        WriteByte(MSG_ENTITY, self.height);
 
-       trigger_common_write(true);
+       trigger_common_write(self, true);
 
        return true;
 }
@@ -133,7 +119,7 @@ wait: prevent triggering again for this amount of time (default: 5) - applies to
 If spawned without any key specified in itemkeys, this trigger will display an error and remove itself.
 message2 and noise2 will be resent to the player every 2 seconds while he is in the trigger zone.
 */
-void spawnfunc_trigger_keylock(void)
+spawnfunc(trigger_keylock)
 {
        if(!self.itemkeys) { remove(self); return; }
 
@@ -147,7 +133,7 @@ void spawnfunc_trigger_keylock(void)
                if(self.sounds == 1)
                        self.noise = "misc/secret.wav";
                else if(self.sounds == 2)
-                       self.noise = "misc/talk.wav";
+                       self.noise = strzone(SND(TALK));
                else //if (self.sounds == 3) {
                        self.noise = "misc/trigger1.wav";
        }
@@ -158,7 +144,7 @@ void spawnfunc_trigger_keylock(void)
 
        // set closed sourd
        if(self.noise2 == "")
-               self.noise2 = "misc/talk.wav";
+               self.noise2 = SND(TALK);
 
        // delay between triggering message2 and trigger2
        if(!self.wait) { self.wait = 5; }
@@ -175,34 +161,36 @@ void spawnfunc_trigger_keylock(void)
        trigger_keylock_link();
 }
 #elif defined(CSQC)
-void keylock_remove()
+void keylock_remove(entity this)
 {
-       if(self.target) { strunzone(self.target); }
-       self.target = string_null;
+       if(this.target) { strunzone(this.target); }
+       this.target = string_null;
 
-       if(self.target2) { strunzone(self.target2); }
-       self.target2 = string_null;
+       if(this.target2) { strunzone(this.target2); }
+       this.target2 = string_null;
 
-       if(self.target3) { strunzone(self.target3); }
-       self.target3 = string_null;
+       if(this.target3) { strunzone(this.target3); }
+       this.target3 = string_null;
 
-       if(self.target4) { strunzone(self.target4); }
-       self.target4 = string_null;
+       if(this.target4) { strunzone(this.target4); }
+       this.target4 = string_null;
 
-       if(self.killtarget) { strunzone(self.killtarget); }
-       self.killtarget = string_null;
+       if(this.killtarget) { strunzone(this.killtarget); }
+       this.killtarget = string_null;
 
-       if(self.targetname) { strunzone(self.targetname); }
-       self.targetname = string_null;
+       if(this.targetname) { strunzone(this.targetname); }
+       this.targetname = string_null;
 }
 
-void ent_keylock()
+NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew)
 {
        self.itemkeys = ReadInt24_t();
        self.height = ReadByte();
 
        trigger_common_read(true);
 
+       return = true;
+
        self.classname = "trigger_keylock";
        self.drawmask = MASK_NORMAL;
        self.draw = trigger_draw_generic;