]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_plats.qc
Attempt to get overriding working, needs to be tested. Note that in order to avoid...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_plats.qc
index 805f690eccb807c5bd0dcbf6781d2cbca9a0e6ab..558786fbdfbddce08d1c80020680a89004c78aa6 100644 (file)
@@ -182,7 +182,26 @@ void plat_reset()
        }
 }
 
-void spawnfunc_path_corner() { }
+void set_platmovetype(entity e, string s)
+{
+       // sets platmovetype_start and platmovetype_end based on a string consisting of two values
+       if(s == "")
+               return;
+
+       float n;
+       n = tokenize_console(s);
+       e.platmovetype_start = stof(argv(0));
+       e.platmovetype_end = stof(argv(0));
+       if(n > 1)
+               e.platmovetype_end = stof(argv(1));
+}
+
+void spawnfunc_path_corner()
+{
+       // setup values for overriding train movement
+       // if a second value does not exist, both start and end speeds are the single value specified
+       set_platmovetype(self, self.platmovetype);
+}
 void spawnfunc_func_plat()
 {
        if (self.sounds == 0)
@@ -269,7 +288,7 @@ void train_wait()
                entity targ;
                vector org;
                targ = find(world, targetname, self.target);
-               org = normalize(targ.origin - (self.origin - self.mins));
+               org = normalize(targ.origin);
                SUB_CalcAngleMove(org, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
                self.train_wait_turning = TRUE;
                return;
@@ -312,6 +331,12 @@ void train_next()
        if (!self.wait)
                self.wait = 0.1;
 
+       // override train movement type if necessary
+       if(targ.platmovetype_start || targ.platmovetype_end)
+               set_platmovetype(self, targ.platmovetype);
+       else
+               set_platmovetype(self, self.platmovetype);
+
        if (targ.speed)
        {
                if (self.spawnflags & 1)
@@ -376,6 +401,8 @@ void spawnfunc_func_train()
                self.dmgtime = 0.25;
        self.dmgtime2 = time;
 
+       set_platmovetype(self, self.platmovetype);
+
        // TODO make a reset function for this one
 }