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 if(self.pushltime < time) // prevent "snorring" sound when a player hits the jumppad more than once
42 sound (other, CHAN_ITEM, "misc/jumppad.ogg", 1, ATTN_NORM);
43 self.pushltime = time + 0.5;
46 for(i = 0; i < other.jumppadcount && i < NUM_JUMPPADSUSED; ++i)
47 if(other.(jumppadsused[i]) == self)
51 other.(jumppadsused[math_mod(other.jumppadcount, NUM_JUMPPADSUSED)]) = self;
52 other.jumppadcount = other.jumppadcount + 1;
56 // figure out how long it will take to hit the point considering gravity
57 grav = cvar("sv_gravity");
58 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
62 // how far in X and Y to move
63 self.movedir = (self.enemy.origin - org);
65 dist = vlen(self.movedir);
67 // finally calculate the velocity
68 self.movedir = normalize(self.movedir) * (dist / flighttime);
69 self.movedir_z = flighttime * grav;
71 other.flags = other.flags - (other.flags & FL_ONGROUND);
72 // reset tracking of oldvelocity for impact damage (sudden velocity changes)
73 other.oldvelocity = other.velocity = self.movedir;
74 // reset tracking of who pushed you into a hazard (for kill credit)
77 if (other.classname == "missile")
78 other.angles = vectoangles (other.velocity);
80 if (self.spawnflags & PUSH_ONCE)
82 self.touch = SUB_Null;
83 self.think = SUB_Remove;
84 self.nextthink = time;
90 void() trigger_push_findtarget =
94 local float flighttime;
98 // first calculate a typical start point for the jump
99 org = (self.absmin + self.absmax) * 0.5;
100 org_z = self.absmax_z - PL_MIN_z;
105 self.enemy = find(world, targetname, self.target);
108 objerror("trigger_push: target not found\n");
113 // figure out how long it will take to hit the point considering gravity
114 grav = cvar("sv_gravity");
115 flighttime = sqrt((self.enemy.origin_z - org_z) / (0.5 * grav));
118 objerror("trigger_push: jump pad with bad destination\n");
123 // how far in X and Y to move
124 self.movedir = (self.enemy.origin - org);
126 dist = vlen(self.movedir);
128 // finally calculate the velocity
129 self.movedir = normalize(self.movedir) * (dist / flighttime);
130 self.movedir_z = flighttime * grav;
135 // calculate the destination and spawn a teleporter waypoint
138 setsize(e, PL_MIN, PL_MAX);
139 e.velocity = self.movedir;
141 self.dest = trace_endpos;
144 waypoint_spawnforteleporter(self, self.dest, flighttime);
147 void() trigger_push =
149 if (self.angles != '0 0 0')
152 self.solid = SOLID_TRIGGER;
153 setmodel (self, self.model);
154 self.movetype = MOVETYPE_NONE;
158 self.touch = trigger_push_touch;
163 self.movedir = self.movedir * self.speed * 10;
165 // this must be called to spawn the teleport waypoints for bots
166 self.think = trigger_push_findtarget;
167 self.nextthink = time + 0.2;
170 void() target_push = {};
171 void() info_notnull = {};
172 void() target_position = {};