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