5 void() trigger_push_touch =
7 local float flighttime, dist, grav;
10 // FIXME: add a .float for whether an entity should be tossed by jumppads
11 if (other.classname != "player")
12 if (other.classname != "corpse")
13 if (other.classname != "body")
14 if (other.classname != "gib")
15 if (other.classname != "missile")
16 if (other.classname != "casing")
17 if (other.classname != "grenade")
18 if (other.classname != "plasma")
19 if (other.classname != "plasma_prim")
20 if (other.classname != "plasma_chain")
21 if (other.classname != "droppedweapon")
24 if (other.deadflag && other.classname == "player")
29 other.velocity = self.movedir;
30 other.flags = other.flags - (other.flags & FL_ONGROUND);
36 if (other.classname == "player")
40 sound (other, CHAN_ITEM, "misc/jumppad.ogg", 1, ATTN_NORM);
42 for(i = 0; i < other.jumppadcount && i < NUM_JUMPPADSUSED; ++i)
43 if(other.(jumppadsused[i]) == self)
47 other.(jumppadsused[math_mod(other.jumppadcount, NUM_JUMPPADSUSED)]) = self;
48 other.jumppadcount = other.jumppadcount + 1;
52 // figure out how long it will take to hit the point considering gravity
53 grav = cvar("sv_gravity");
54 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
58 // how far in X and Y to move
59 self.movedir = (self.enemy.origin - org);
61 dist = vlen(self.movedir);
63 // finally calculate the velocity
64 self.movedir = normalize(self.movedir) * (dist / flighttime);
65 self.movedir_z = flighttime * grav;
67 other.flags = other.flags - (other.flags & FL_ONGROUND);
68 // reset tracking of oldvelocity for impact damage (sudden velocity changes)
69 other.oldvelocity = other.velocity = self.movedir;
70 // reset tracking of who pushed you into a hazard (for kill credit)
73 if (other.classname == "missile")
74 other.angles = vectoangles (other.velocity);
76 if (self.spawnflags & PUSH_ONCE)
78 self.touch = SUB_Null;
79 self.think = SUB_Remove;
80 self.nextthink = time;
86 void() trigger_push_findtarget =
90 local float flighttime;
94 // first calculate a typical start point for the jump
95 org = (self.absmin + self.absmax) * 0.5;
96 org_z = self.absmax_z - PL_MIN_z;
101 self.enemy = find(world, targetname, self.target);
104 objerror("trigger_push: target not found\n");
109 // figure out how long it will take to hit the point considering gravity
110 grav = cvar("sv_gravity");
111 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
114 objerror("trigger_push: jump pad with bad destination\n");
119 // how far in X and Y to move
120 self.movedir = (self.enemy.origin - org);
122 dist = vlen(self.movedir);
124 // finally calculate the velocity
125 self.movedir = normalize(self.movedir) * (dist / flighttime);
126 self.movedir_z = flighttime * grav;
131 // calculate the destination and spawn a teleporter waypoint
134 setsize(e, PL_MIN, PL_MAX);
135 e.velocity = self.movedir;
137 self.dest = trace_endpos;
140 waypoint_spawnforteleporter(self, self.dest, flighttime);
143 void() trigger_push =
145 if (self.angles != '0 0 0')
148 self.solid = SOLID_TRIGGER;
149 setmodel (self, self.model);
150 self.movetype = MOVETYPE_NONE;
154 self.touch = trigger_push_touch;
159 self.movedir = self.movedir * self.speed * 10;
161 // this must be called to spawn the teleport waypoints for bots
162 self.think = trigger_push_findtarget;
163 self.nextthink = time + 0.2;
166 void() target_push = {};
167 void() info_notnull = {};
168 void() target_position = {};