]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/jumppads.qc
check for players within radius 70 when choosing a spawn spot, not 32, this prevents...
[divverent/nexuiz.git] / qcsrc / jumppads.qc
1 float PUSH_ONCE                 = 1;
2 float PUSH_SILENT               = 2;
3
4 // TODO: add sounds
5 void() trigger_push_touch =
6 {
7         local float flighttime, dist, grav;
8         local vector org;
9
10         if (!other.health)
11                 return;
12
13         org = other.origin;
14
15         // figure out how long it will take to hit the point considering gravity
16         grav = cvar("sv_gravity");
17         flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
18         if (!flighttime)
19                 return;
20
21         // how far in X and Y to move
22         self.movedir = (self.enemy.origin - org);
23         self.movedir_z = 0;
24         dist = vlen(self.movedir);
25
26         // finally calculate the velocity
27         self.movedir = normalize(self.movedir) * (dist / flighttime);
28         self.movedir_z = flighttime * grav;
29
30         other.velocity = self.movedir;
31         other.flags = other.flags - (other.flags & FL_ONGROUND);
32
33         if (self.spawnflags & PUSH_ONCE)
34         {
35                 self.touch = SUB_Null;
36                 self.think = SUB_Remove;
37                 self.nextthink = time;
38         }
39 };
40
41 void() trigger_push_findtarget =
42 {
43         // find the target
44         self.enemy = find(world, targetname, self.target);
45         if (!self.enemy)
46                 objerror("trigger_push: target not found\n");
47 };
48
49 /*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE SILENT
50 Improved version of normal trigger_push.
51
52 Pushes anything that touches it,
53 or acts as a jump pad, hitting "target"
54 at the apogee (peak) of the jump.
55
56 Target should be an info_notnull.
57
58 Flags:
59 "PUSH_ONCE" - removes itself after push
60 "SILENT" - no 'windtunnel' noise
61 Keys:
62 "target" - acts as jump pad, hits this entity
63
64
65 void() SetMovedir =
66 {
67         if (self.angles == '0 -1 0')
68                 self.movedir = '0 0 1';
69         else if (self.angles == '0 -2 0')
70                 self.movedir = '0 0 -1';
71         else
72         {
73                 makevectors (self.angles);
74                 self.movedir = v_forward;
75         }
76         
77         self.angles = '0 0 0';
78 };
79 */
80 void() trigger_push =
81 {
82         if (self.angles != '0 0 0')
83                 SetMovedir ();
84
85         self.solid = SOLID_TRIGGER;
86         setmodel (self, self.model);
87         self.movetype = MOVETYPE_NONE;
88         self.modelindex = 0;
89         self.model = "";
90
91         self.touch = trigger_push_touch;
92
93         // check if this is a jump pad
94         if (self.target)
95         {
96                 self.think = trigger_push_findtarget;
97                 self.nextthink = time + 0.2;
98         }
99         else
100         {
101                 // normal push setup
102                 if (!self.speed)
103                         self.speed = 1000;
104                 self.movedir = self.movedir * self.speed * 10;
105         }
106 };
107
108 void() target_push = { trigger_push(); };
109 void() info_notnull = {};
110 void() target_position = {};