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")
29 sound (other, CHAN_ITEM, "misc/jumppad.ogg", 1, ATTN_NORM);
31 for(i = 0; i < other.jumppadcount && i < NUM_JUMPPADSUSED; ++i)
32 if(other.(jumppadsused[i]) == self)
36 other.(jumppadsused[math_mod(other.jumppadcount, NUM_JUMPPADSUSED)]) = self;
37 other.jumppadcount = other.jumppadcount + 1;
41 // figure out how long it will take to hit the point considering gravity
42 grav = cvar("sv_gravity");
43 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
47 // how far in X and Y to move
48 self.movedir = (self.enemy.origin - org);
50 dist = vlen(self.movedir);
52 // finally calculate the velocity
53 self.movedir = normalize(self.movedir) * (dist / flighttime);
54 self.movedir_z = flighttime * grav;
56 other.flags = other.flags - (other.flags & FL_ONGROUND);
57 // reset tracking of oldvelocity for impact damage (sudden velocity changes)
58 other.oldvelocity = other.velocity = self.movedir;
59 // reset tracking of who pushed you into a hazard (for kill credit)
62 if (other.classname == "missile")
63 other.angles = vectoangles (other.velocity);
65 if (self.spawnflags & PUSH_ONCE)
67 self.touch = SUB_Null;
68 self.think = SUB_Remove;
69 self.nextthink = time;
75 void() trigger_push_findtarget =
79 local float flighttime;
83 // first calculate a typical start point for the jump
84 org = (self.absmin + self.absmax) * 0.5;
85 org_z = self.absmax_z - PL_MIN_z;
90 self.enemy = find(world, targetname, self.target);
93 objerror("trigger_push: target not found\n");
98 // figure out how long it will take to hit the point considering gravity
99 grav = cvar("sv_gravity");
100 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
103 objerror("trigger_push: jump pad with bad destination\n");
108 // how far in X and Y to move
109 self.movedir = (self.enemy.origin - org);
111 dist = vlen(self.movedir);
113 // finally calculate the velocity
114 self.movedir = normalize(self.movedir) * (dist / flighttime);
115 self.movedir_z = flighttime * grav;
120 // calculate the destination and spawn a teleporter waypoint
123 setsize(e, PL_MIN, PL_MAX);
124 e.velocity = self.movedir;
126 self.dest = trace_endpos;
129 waypoint_spawnforteleporter(self, self.dest, flighttime);
132 void() trigger_push =
134 if (self.angles != '0 0 0')
137 self.solid = SOLID_TRIGGER;
138 setmodel (self, self.model);
139 self.movetype = MOVETYPE_NONE;
143 self.touch = trigger_push_touch;
148 self.movedir = self.movedir * self.speed * 10;
150 // this must be called to spawn the teleport waypoints for bots
151 self.think = trigger_push_findtarget;
152 self.nextthink = time + 0.2;
155 void() target_push = {};
156 void() info_notnull = {};
157 void() target_position = {};