5 void() trigger_push_touch =
7 local float flighttime, dist, grav;
10 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" && other.classname != "plasma_prim" && other.classname != "plasma_chain")
13 if (other.deadflag && other.classname == "player")
18 other.velocity = self.movedir;
19 other.flags = other.flags - (other.flags & FL_ONGROUND);
25 if (other.classname == "player")
26 sound (other, CHAN_ITEM, "misc/jumppad.ogg", 1, ATTN_NORM);
28 // figure out how long it will take to hit the point considering gravity
29 grav = cvar("sv_gravity");
30 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
34 // how far in X and Y to move
35 self.movedir = (self.enemy.origin - org);
37 dist = vlen(self.movedir);
39 // finally calculate the velocity
40 self.movedir = normalize(self.movedir) * (dist / flighttime);
41 self.movedir_z = flighttime * grav;
43 other.flags = other.flags - (other.flags & FL_ONGROUND);
44 // reset tracking of oldvelocity for impact damage (sudden velocity changes)
45 other.oldvelocity = other.velocity = self.movedir;
46 // reset tracking of who pushed you into a hazard (for kill credit)
49 if (other.classname == "missile")
50 other.angles = vectoangles (other.velocity);
52 if (self.spawnflags & PUSH_ONCE)
54 self.touch = SUB_Null;
55 self.think = SUB_Remove;
56 self.nextthink = time;
62 void() trigger_push_findtarget =
66 local float flighttime;
70 // first calculate a typical start point for the jump
71 org = (self.absmin + self.absmax) * 0.5;
72 org_z = self.absmax_z - PL_MIN_z;
77 self.enemy = find(world, targetname, self.target);
80 objerror("trigger_push: target not found\n");
85 // figure out how long it will take to hit the point considering gravity
86 grav = cvar("sv_gravity");
87 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
90 objerror("trigger_push: jump pad with bad destination\n");
95 // how far in X and Y to move
96 self.movedir = (self.enemy.origin - org);
98 dist = vlen(self.movedir);
100 // finally calculate the velocity
101 self.movedir = normalize(self.movedir) * (dist / flighttime);
102 self.movedir_z = flighttime * grav;
107 // calculate the destination and spawn a teleporter waypoint
110 setsize(e, PL_MIN, PL_MAX);
111 e.velocity = self.movedir;
113 self.dest = trace_endpos;
116 waypoint_spawnforteleporter(self, self.dest, flighttime);
119 void() trigger_push =
121 if (self.angles != '0 0 0')
124 self.solid = SOLID_TRIGGER;
125 setmodel (self, self.model);
126 self.movetype = MOVETYPE_NONE;
130 self.touch = trigger_push_touch;
135 self.movedir = self.movedir * self.speed * 10;
137 // this must be called to spawn the teleport waypoints for bots
138 self.think = trigger_push_findtarget;
139 self.nextthink = time + 0.2;
142 void() target_push = {};
143 void() info_notnull = {};
144 void() target_position = {};