]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/t_jumppads.c
target_jumppad no longer acts as a trigger_push (this was so wrong...)
[divverent/nexuiz.git] / qcsrc / gamec / t_jumppads.c
1 float PUSH_ONCE                 = 1;
2 float PUSH_SILENT               = 2;
3
4 void() trigger_push_touch =
5 {
6         local float flighttime, dist, grav;
7         local vector org;
8
9         if (other.classname != "player")
10                 return;
11
12         if (!self.target)
13         {
14                 other.velocity = self.movedir;
15                 other.flags = other.flags - (other.flags & FL_ONGROUND);
16                 return;
17         }
18
19         org = other.origin;
20
21         sound (other, CHAN_ITEM, "misc/jumppad.wav", 1, ATTN_NORM);
22
23         // figure out how long it will take to hit the point considering gravity
24         grav = cvar("sv_gravity");
25         flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
26         if (!flighttime)
27                 return;
28
29         // how far in X and Y to move
30         self.movedir = (self.enemy.origin - org);
31         self.movedir_z = 0;
32         dist = vlen(self.movedir);
33
34         // finally calculate the velocity
35         self.movedir = normalize(self.movedir) * (dist / flighttime);
36         self.movedir_z = flighttime * grav;
37
38         other.velocity = self.movedir;
39         other.flags = other.flags - (other.flags & FL_ONGROUND);
40
41         if (other.classname == "missile")
42                 other.angles = vectoangles (other.velocity);
43
44         if (self.spawnflags & PUSH_ONCE)
45         {
46                 self.touch = nullfunction;
47                 self.think = SUB_Remove;
48                 self.nextthink = time;
49         }
50 };
51
52 void() trigger_push_findtarget =
53 {
54         // find the target
55         self.enemy = find(world, targetname, self.target);
56         if (!self.enemy)
57         {
58                 objerror("trigger_push: target not found\n");
59                 remove(self);
60         }
61 };
62
63 void() trigger_push =
64 {
65         if (self.angles != '0 0 0')
66                 SetMovedir ();
67
68         self.solid = SOLID_TRIGGER;
69         setmodel (self, self.model);
70         self.movetype = MOVETYPE_NONE;
71         self.modelindex = 0;
72         self.model = "";
73
74         self.touch = trigger_push_touch;
75
76         // check if this is a jump pad
77         if (self.target)
78         {
79                 self.think = trigger_push_findtarget;
80                 self.nextthink = time + 0.2;
81         }
82         else
83         {
84                 // normal push setup
85                 if (!self.speed)
86                         self.speed = 1000;
87                 self.movedir = self.movedir * self.speed * 10;
88         }
89 };
90
91 void() target_push = {};
92 void() info_notnull = {};
93 void() target_position = {};