SHARE
TWEET

Untitled

a guest Dec 7th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void() teleporttrain_calcmove;
  2. void() teleporttrain_next =
  3. {
  4.     setorigin(self, self.enemy.origin);
  5.    
  6.     if (!self.target)
  7.     {
  8.         self.enemy = world;
  9.         return;
  10.     }
  11.     self.enemy = find(world, targetname, self.target);
  12.     if (self.enemy.classname == "path_corner")
  13.     {
  14.         vector dir = normalize(self.enemy.origin - self.origin);
  15.         self.velocity = dir * self.speed;
  16.         self.target = self.enemy.target;
  17.     }
  18.     else
  19.     {
  20.         objerror("unable to find target\n");
  21.         remove(self);
  22.     }
  23.     teleporttrain_calcmove();
  24. };
  25. /*void() teleporttrain_move =
  26. {  
  27.     if (!self.enemy)
  28.     {
  29.         self.velocity = '0 0 0';
  30.         self.think = SUB_Null;
  31.         return;
  32.     }
  33.    
  34.     if (vlen(self.origin - self.enemy.origin) < self.size_x)
  35.         teleporttrain_next();
  36.  
  37.     self.think = teleporttrain_move;
  38.     self.nextthink = time + 0.1;
  39. };*/
  40. void() teleporttrain_calcmove =
  41. {
  42.     local float len;
  43.     local vector delta;
  44.     local float spd;
  45.    
  46.     delta = self.enemy.origin - self.origin;
  47.     len = vlen(delta);
  48.     spd = vlen(self.velocity);
  49.     self.nextthink = time + (len / spd);
  50.     self.think = teleporttrain_next;
  51. };
  52. void() teleporttrain_use =
  53. {
  54.     if (self.velocity == '0 0 0')
  55.     {
  56.         teleporttrain_next();
  57.     }
  58.    
  59. };
  60. void() teleporttrain_find =
  61. {
  62.     // always start positioned on the first path_corner
  63.     self.enemy = find(world, targetname, self.target);
  64.     if (self.enemy.classname == "path_corner")
  65.     {
  66.         setorigin (self, self.enemy.origin);
  67.         self.target = self.enemy.target;
  68.     }
  69.     else
  70.     {
  71.         objerror("unable to find target\n");
  72.         remove(self);
  73.         return;
  74.     }
  75.    
  76.     // not triggered, so start immediately
  77.     if (!self.targetname)
  78.     {
  79.         teleporttrain_calcmove();
  80.         //self.think = teleporttrain_move;
  81.         //self.nextthink = time + 0.1;
  82.     }
  83.     else
  84.     {
  85.         self.use = teleporttrain_use;
  86.     }
  87. };
  88. /*QUAKED misc_teleporttrain (.5 .5 .5) (-16 -16 -16) (16 16 16) X X X X X X X X NOT_IN_EASY NOT_IN_NORMAL NOT_IN_HARD NOT_IN_DM
  89. {   model("progs/teleport.mdl");    }
  90.  
  91. Teleporter target for final boss level. Must target a series of 'path_corner' entities.
  92. It will position itself on its first target at map load.
  93. If a targetname is set, it must be triggered to start moving, otherwise it will start automatically.
  94. */
  95. void() misc_teleporttrain =
  96. {
  97.     if (!self.target)
  98.     {
  99.         objerror ("no target");
  100.         remove(self);
  101.         return;
  102.     }
  103.     if (self.speed <= 0)
  104.         self.speed = 100;
  105.  
  106.     self.solid = SOLID_NOT;
  107.     self.movetype = MOVETYPE_FLY;
  108.     precache_model ("progs/teleport.mdl");
  109.     setmodel (self, "progs/teleport.mdl");
  110.     setsize (self, '-16 -16 -16', '16 16 16');
  111.  
  112.     //Causes the ball to spin around like it was originally intended to.
  113.     self.avelocity = '40 80 120';
  114.     //self.avelocity = '100 200 300';
  115.    
  116.     self.think = teleporttrain_find;
  117.     self.nextthink = time + 0.1;
  118. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top