1 .vector personal_v_angle; // view angles to restore on impulse 77
2 .vector personal_velocity; // velocity to restore on impulse 77
4 void CopyBody(float keepvelocity);
6 // changes by LordHavoc on 03/30/04
7 // cleaned up dummy code
8 // dummies are now removed eventually after being gibbed (norespawn = TRUE)
9 // dummy impulse now checks sv_cheats to prevent players from overwhelming server with dummies
10 // dummies now use player code where possible
12 void player_anim (void);
15 self.think = DummyThink;
16 self.nextthink = time;
24 void printsurfaceinfo(entity e, vector v)
26 local float surfnum, numpoints, vnum;
29 surfnum = getsurfacenearpoint(e, v);
32 sprint(self, "texture: ");
33 s = getsurfacetexture(e, surfnum);
35 sprint(self, " normal: ");
36 n = getsurfacenormal(e, surfnum);
37 sprint(self, vtos(n));
39 numpoints = getsurfacenumpoints(e, surfnum);
40 sprint(self, ftos(numpoints));
41 sprint(self, " verts:");
43 while (vnum < numpoints)
46 n = getsurfacepoint(e, surfnum, vnum);
47 sprint(self, vtos(n));
50 sprint(self, " point tested: ");
51 sprint(self, vtos(v));
52 sprint(self, " nearest point on surface: ");
53 n = getsurfaceclippedpoint(e, surfnum, v);
54 sprint(self, vtos(n));
62 * 0 reserved (no input)
63 * 1 to 9, 14: weapon shortcuts
64 * 10: next weapon according to linear list
65 * 11: most recently used weapon
66 * 12: previous weapon according to linear list
67 * 13: best weapon according to priority list
68 * 15: next weapon according to priority list
69 * 16: previous weapon according to priority list
71 * 18: next weapon according to sbar_hudselector 1 list
72 * 19: previous weapon according to sbar_hudselector 1 list
74 * 30 to 39: create waypoints
75 * 47: clear personal waypoints
76 * 48: clear team waypoints
77 * 49: turn base waypoints on/off
84 * 143: emergency teleport
85 * 144: printsurfaceinfo
89 * 200 to 209: prev weapon shortcuts
90 * 210 to 219: best weapon shortcuts
91 * 220 to 229: next weapon shortcuts
92 * 230 to 253: individual weapons (up to 24)
95 void ImpulseCommands (void)
98 vector start, end, enddown;
101 float good, evil, evilsurf;
108 if (!imp || gameover)
112 if (timeoutStatus == 2) //don't allow any impulses while the game is paused
115 if (imp >= 1 && imp <= 9)
117 // weapon switching impulses
118 if(self.deadflag == DEAD_NO)
119 W_NextWeaponOnImpulse(imp);
121 self.impulse = imp; // retry in next frame
123 else if(imp >= 10 && imp <= 19)
125 if(self.deadflag == DEAD_NO)
133 W_SwitchWeapon (self.cnt); // previously used
136 W_PreviousWeapon (0);
139 W_SwitchWeapon (w_getbestweapon(self));
142 W_NextWeaponOnImpulse(0);
148 W_PreviousWeapon (2);
152 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750), '0 0 0', TRUE);
158 W_PreviousWeapon (1);
163 self.impulse = imp; // retry in next frame
165 else if(imp >= 200 && imp <= 229)
167 if(self.deadflag == DEAD_NO)
169 // custom order weapon cycling
171 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
172 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
175 self.impulse = imp; // retry in next frame
177 else if(imp >= 230 && imp <= 253)
179 if(self.deadflag == DEAD_NO)
180 W_SwitchWeapon (imp - 230 + WEP_FIRST);
182 self.impulse = imp; // retry in next frame
185 else if (imp >= 30 && imp <= 49)
191 wp = WaypointSprite_DeployPersonal("waypoint", self.origin);
194 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
195 WaypointSprite_Ping(wp);
197 self.personal_v_angle = self.v_angle;
198 self.personal_velocity = self.velocity;
199 sprint(self, "personal waypoint spawned at location\n");
202 wp = WaypointSprite_DeployPersonal("waypoint", self.cursor_trace_endpos);
205 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
206 WaypointSprite_Ping(wp);
208 self.personal_v_angle = self.v_angle;
209 self.personal_velocity = '0 0 0';
210 sprint(self, "personal waypoint spawned at crosshair\n");
213 if(vlen(self.death_origin))
215 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin);
218 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
219 WaypointSprite_Ping(wp);
221 self.personal_v_angle = self.v_angle;
222 self.personal_velocity = '0 0 0';
223 sprint(self, "personal waypoint spawned at death location\n");
227 if(self.deadflag == DEAD_NO && teams_matter)
229 wp = WaypointSprite_Attach("helpme", TRUE);
231 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HELPME, '1 0.5 0'); // TODO choose better color
233 wp = self.waypointsprite_attachedforcarrier; // flag sprite?
235 WaypointSprite_Ping(wp);
236 sprint(self, "HELP ME attached\n");
240 wp = WaypointSprite_DeployFixed("here", FALSE, self.origin);
243 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
244 WaypointSprite_Ping(wp);
246 sprint(self, "HERE spawned at location\n");
249 wp = WaypointSprite_DeployFixed("here", FALSE, self.cursor_trace_endpos);
252 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
253 WaypointSprite_Ping(wp);
255 sprint(self, "HERE spawned at crosshair\n");
258 if(vlen(self.death_origin))
260 wp = WaypointSprite_DeployFixed("here", FALSE, self.death_origin);
263 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
264 WaypointSprite_Ping(wp);
266 sprint(self, "HERE spawned at death location\n");
270 wp = WaypointSprite_DeployFixed("danger", FALSE, self.origin);
273 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
274 WaypointSprite_Ping(wp);
276 sprint(self, "DANGER spawned at location\n");
279 wp = WaypointSprite_DeployFixed("danger", FALSE, self.cursor_trace_endpos);
282 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
283 WaypointSprite_Ping(wp);
285 sprint(self, "DANGER spawned at crosshair\n");
288 if(vlen(self.death_origin))
290 wp = WaypointSprite_DeployFixed("danger", FALSE, self.death_origin);
293 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
294 WaypointSprite_Ping(wp);
296 sprint(self, "DANGER spawned at death location\n");
300 WaypointSprite_ClearPersonal();
301 sprint(self, "personal waypoint cleared\n");
304 WaypointSprite_ClearOwned();
305 sprint(self, "all waypoints cleared\n");
308 self.cvar_cl_hidewaypoints = !(self.cvar_cl_hidewaypoints);
309 sprint(self, "fixed waypoints now ");
310 if(self.cvar_cl_hidewaypoints)
311 sprint(self, "OFF\n");
313 sprint(self, "ON\n");
317 else if(imp >= 140 && imp <= 149 || imp == 99) // 10 cheats ought to be enough for anyone
320 if(self.deadflag == DEAD_NO)
325 self.weapons |= WEPBIT_ALL;
326 self.items |= IT_UNLIMITED_AMMO;
327 self.ammo_shells = g_pickup_shells_max;
328 self.ammo_nails = g_pickup_nails_max;
329 self.ammo_rockets = g_pickup_rockets_max;
330 self.ammo_cells = g_pickup_cells_max;
331 self.health = g_pickup_healthsmall_max;
332 self.armorvalue = g_pickup_armorsmall_max;
333 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
334 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
335 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
336 // precache weapon models/sounds
338 while (wep <= WEP_LAST)
340 weapon_action(wep, WR_PRECACHE);
345 makevectors (self.v_angle);
346 self.velocity = self.velocity + v_forward * 300;
349 self.velocity = self.velocity - v_forward * 300;
352 if(self.waypointsprite_deployed_personal)
354 self.speedrunning = TRUE;
355 tracebox(self.waypointsprite_deployed_personal.origin, self.mins, self.maxs, self.waypointsprite_deployed_personal.origin, MOVE_WORLDONLY, self);
358 sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
362 // Abort speedrun, teleport back
363 setorigin(self, self.waypointsprite_deployed_personal.origin);
364 self.oldvelocity = self.velocity = self.personal_velocity;
365 self.angles = self.personal_v_angle;
366 self.fixangle = TRUE;
369 bprint("The ", self.flagcarried.netname, " was returned to base by its carrier\n");
370 ReturnFlag(self.flagcarried);
373 self.ammo_rockets = 999;
374 self.ammo_nails = 999;
375 self.ammo_cells = 999;
376 self.ammo_shells = 999;
377 self.health = start_health;
378 self.armorvalue = start_armorvalue;
379 self.weapons |= weaponsInMap;
380 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
381 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
382 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
384 else if(self.deadflag != DEAD_NO)
385 sprint(self, "UR DEAD AHAHAH))\n");
387 sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
394 good = DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP;
395 evil = DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER;
396 evilsurf = Q3SURFACEFLAG_SKY;
398 m = self.dphitcontentsmask;
399 self.dphitcontentsmask = good | evil;
402 delta = world.maxs - world.mins;
404 maxattempts = ((sv_cheats >= 2) ? 100000 : 100);
406 for(i = 0; i < maxattempts; ++i)
408 start_x = org_x + random() * delta_x;
409 start_y = org_y + random() * delta_y;
410 start_z = org_z + random() * delta_z;
412 // rule 1: start inside world bounds, and outside
413 // solid, and don't start from somewhere where you can
415 tracebox(start, self.mins, self.maxs, start - '0 0 1' * delta_z, MOVE_NORMAL, self);
416 if(trace_fraction >= 1)
420 dprint("hit contents ", ftos(trace_dphitcontents), "\n");
421 if(trace_dphitcontents & evil)
423 if(trace_dphitq3surfaceflags & evilsurf)
426 // rule 2: if we are too high, lower the point
427 if(trace_fraction * delta_z > 1024)
428 start = trace_endpos + '0 0 1024';
429 enddown = trace_endpos;
431 // these can be traceLINES as we already verified the starting box
432 traceline(start, start + '1 0 0' * delta_x, MOVE_NORMAL, self);
433 if(trace_fraction >= 1)
435 traceline(start, start - '1 0 0' * delta_x, MOVE_NORMAL, self);
436 if(trace_fraction >= 1)
438 traceline(start, start + '0 1 0' * delta_y, MOVE_NORMAL, self);
439 if(trace_fraction >= 1)
441 traceline(start, start - '0 1 0' * delta_y, MOVE_NORMAL, self);
442 if(trace_fraction >= 1)
444 traceline(start, start + '0 0 1' * delta_z, MOVE_NORMAL, self);
445 if(trace_fraction >= 1)
448 end_x = org_x + random() * delta_x;
449 end_y = org_y + random() * delta_y;
450 end_z = org_z + random() * delta_z;
451 end = start + normalize(end - start) * vlen(delta);
453 // rule 3: start TO end must not be too short
454 tracebox(start, self.mins, self.maxs, end, MOVE_NORMAL, self);
457 if(trace_fraction < 256 / vlen(delta))
460 // rule 4: don't want to look at sky
461 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
464 // rule 5: we must not end up in trigger_hurt
465 if(tracebox_hits_trigger_hurt(start, self.mins, self.maxs, enddown))
467 dprint("trigger_hurt! ouch! and nothing else could find it!\n");
477 self.angles = vectoangles(end - start);
478 self.angles_x = -self.angles_x;
479 self.fixangle = TRUE;
480 self.velocity = '0 0 0';
481 dprint("Needed ", ftos(i + 1), " attempts\n");
484 sprint(self, "Emergency teleport could not find a good location, forget it!\n");
486 self.dphitcontentsmask = m;
489 makevectors(self.v_angle);
490 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, FALSE, self);
491 if (trace_fraction < 1)
492 printsurfaceinfo(trace_ent, trace_endpos);
495 makevectors(self.v_angle);
496 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 65536, FALSE, self);
497 sprint(self, strcat("distance: ", ftos(fabs(vlen(trace_endpos - (self.origin + self.view_ofs)))), "\n"));
502 else if(imp >= 103 && imp <= 106)
504 if(cvar("g_waypointeditor"))
509 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
512 e = navigation_findnearestwaypoint(self, FALSE);
517 waypoint_schedulerelinkall();
526 //TetrisImpulses(imp);