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