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
83 * 143: emergency teleport
84 * 144: printsurfaceinfo
88 * 200 to 209: prev weapon shortcuts
89 * 210 to 219: best weapon shortcuts
90 * 220 to 229: next weapon shortcuts
91 * 230 to 253: individual weapons (up to 24)
94 void ImpulseCommands (void)
97 vector start, end, enddown;
100 float good, evil, evilsurf;
107 if (!imp || gameover)
111 if (timeoutStatus == 2) //don't allow any impulses while the game is paused
114 if (imp >= 1 && imp <= 9)
116 // weapon switching impulses
117 if(self.deadflag == DEAD_NO)
118 W_NextWeaponOnImpulse(imp);
120 self.impulse = imp; // retry in next frame
122 else if(imp >= 10 && imp <= 19)
124 if(self.deadflag == DEAD_NO)
132 W_SwitchWeapon (self.cnt); // previously used
135 W_PreviousWeapon (0);
138 W_SwitchWeapon (w_getbestweapon(self));
141 W_NextWeaponOnImpulse(0);
147 W_PreviousWeapon (2);
151 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750), '0 0 0', TRUE);
157 W_PreviousWeapon (1);
162 self.impulse = imp; // retry in next frame
164 else if(imp >= 200 && imp <= 229)
166 if(self.deadflag == DEAD_NO)
168 // custom order weapon cycling
170 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
171 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
174 self.impulse = imp; // retry in next frame
176 else if(imp >= 230 && imp <= 253)
178 if(self.deadflag == DEAD_NO)
179 W_SwitchWeapon (imp - 230 + WEP_FIRST);
181 self.impulse = imp; // retry in next frame
184 else if (imp >= 30 && imp <= 49)
190 wp = WaypointSprite_DeployPersonal("waypoint", self.origin);
193 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
194 WaypointSprite_Ping(wp);
196 self.personal_v_angle = self.v_angle;
197 self.personal_velocity = self.velocity;
198 sprint(self, "personal waypoint spawned at location\n");
201 wp = WaypointSprite_DeployPersonal("waypoint", self.cursor_trace_endpos);
204 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
205 WaypointSprite_Ping(wp);
207 self.personal_v_angle = self.v_angle;
208 self.personal_velocity = '0 0 0';
209 sprint(self, "personal waypoint spawned at crosshair\n");
212 if(vlen(self.death_origin))
214 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin);
217 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
218 WaypointSprite_Ping(wp);
220 self.personal_v_angle = self.v_angle;
221 self.personal_velocity = '0 0 0';
222 sprint(self, "personal waypoint spawned at death location\n");
226 if(self.deadflag == DEAD_NO && teams_matter)
228 wp = WaypointSprite_Attach("helpme", TRUE);
230 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HELPME, '1 0.5 0'); // TODO choose better color
232 wp = self.waypointsprite_attachedforcarrier; // flag sprite?
234 WaypointSprite_Ping(wp);
235 sprint(self, "HELP ME attached\n");
239 wp = WaypointSprite_DeployFixed("here", FALSE, self.origin);
242 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
243 WaypointSprite_Ping(wp);
245 sprint(self, "HERE spawned at location\n");
248 wp = WaypointSprite_DeployFixed("here", FALSE, self.cursor_trace_endpos);
251 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
252 WaypointSprite_Ping(wp);
254 sprint(self, "HERE spawned at crosshair\n");
257 if(vlen(self.death_origin))
259 wp = WaypointSprite_DeployFixed("here", FALSE, self.death_origin);
262 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
263 WaypointSprite_Ping(wp);
265 sprint(self, "HERE spawned at death location\n");
269 wp = WaypointSprite_DeployFixed("danger", FALSE, self.origin);
272 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
273 WaypointSprite_Ping(wp);
275 sprint(self, "DANGER spawned at location\n");
278 wp = WaypointSprite_DeployFixed("danger", FALSE, self.cursor_trace_endpos);
281 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
282 WaypointSprite_Ping(wp);
284 sprint(self, "DANGER spawned at crosshair\n");
287 if(vlen(self.death_origin))
289 wp = WaypointSprite_DeployFixed("danger", FALSE, self.death_origin);
292 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
293 WaypointSprite_Ping(wp);
295 sprint(self, "DANGER spawned at death location\n");
299 WaypointSprite_ClearPersonal();
300 sprint(self, "personal waypoint cleared\n");
303 WaypointSprite_ClearOwned();
304 sprint(self, "all waypoints cleared\n");
308 else if(imp >= 140 && imp <= 149 || imp == 99) // 10 cheats ought to be enough for anyone
310 if(self.deadflag == DEAD_NO)
312 if(sv_cheats || (self.lip < sv_clones))
317 makevectors (self.v_angle);
318 self.velocity = self.velocity + v_forward * 300;
321 self.velocity = self.velocity - v_forward * 300;
335 self.weapons |= WEPBIT_ALL;
336 self.items |= IT_UNLIMITED_AMMO;
337 self.ammo_shells = g_pickup_shells_max;
338 self.ammo_nails = g_pickup_nails_max;
339 self.ammo_rockets = g_pickup_rockets_max;
340 self.ammo_cells = g_pickup_cells_max;
341 self.health = g_pickup_healthsmall_max;
342 self.armorvalue = g_pickup_armorsmall_max;
343 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
344 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
345 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
346 // precache weapon models/sounds
348 while (wep <= WEP_LAST)
350 weapon_action(wep, WR_PRECACHE);
355 if(self.waypointsprite_deployed_personal)
357 self.speedrunning = TRUE;
358 tracebox(self.waypointsprite_deployed_personal.origin, self.mins, self.maxs, self.waypointsprite_deployed_personal.origin, MOVE_WORLDONLY, self);
361 sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
365 // Abort speedrun, teleport back
366 setorigin(self, self.waypointsprite_deployed_personal.origin);
367 self.oldvelocity = self.velocity = self.personal_velocity;
368 self.angles = self.personal_v_angle;
369 self.fixangle = TRUE;
372 bprint("The ", self.flagcarried.netname, " was returned to base by its carrier\n");
373 ReturnFlag(self.flagcarried);
376 self.ammo_rockets = 999;
377 self.ammo_nails = 999;
378 self.ammo_cells = 999;
379 self.ammo_shells = 999;
380 self.health = start_health;
381 self.armorvalue = start_armorvalue;
382 self.weapons |= weaponsInMap;
383 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
384 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
385 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
387 else if(self.deadflag != DEAD_NO)
388 sprint(self, "UR DEAD AHAHAH))\n");
390 sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
393 good = DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP;
394 evil = DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER;
395 evilsurf = Q3SURFACEFLAG_SKY;
397 m = self.dphitcontentsmask;
398 self.dphitcontentsmask = good | evil;
401 delta = world.maxs - world.mins;
403 maxattempts = ((sv_cheats >= 2) ? 100000 : 100);
405 for(i = 0; i < maxattempts; ++i)
407 start_x = org_x + random() * delta_x;
408 start_y = org_y + random() * delta_y;
409 start_z = org_z + random() * delta_z;
411 // rule 1: start inside world bounds, and outside
412 // solid, and don't start from somewhere where you can
414 tracebox(start, self.mins, self.maxs, start - '0 0 1' * delta_z, MOVE_NORMAL, self);
415 if(trace_fraction >= 1)
419 dprint("hit contents ", ftos(trace_dphitcontents), "\n");
420 if(trace_dphitcontents & evil)
422 if(trace_dphitq3surfaceflags & evilsurf)
425 // rule 2: if we are too high, lower the point
426 if(trace_fraction * delta_z > 1024)
427 start = trace_endpos + '0 0 1024';
428 enddown = trace_endpos;
430 // these can be traceLINES as we already verified the starting box
431 traceline(start, start + '1 0 0' * delta_x, MOVE_NORMAL, self);
432 if(trace_fraction >= 1)
434 traceline(start, start - '1 0 0' * delta_x, MOVE_NORMAL, self);
435 if(trace_fraction >= 1)
437 traceline(start, start + '0 1 0' * delta_y, MOVE_NORMAL, self);
438 if(trace_fraction >= 1)
440 traceline(start, start - '0 1 0' * delta_y, MOVE_NORMAL, self);
441 if(trace_fraction >= 1)
443 traceline(start, start + '0 0 1' * delta_z, MOVE_NORMAL, self);
444 if(trace_fraction >= 1)
447 end_x = org_x + random() * delta_x;
448 end_y = org_y + random() * delta_y;
449 end_z = org_z + random() * delta_z;
450 end = start + normalize(end - start) * vlen(delta);
452 // rule 3: start TO end must not be too short
453 tracebox(start, self.mins, self.maxs, end, MOVE_NORMAL, self);
456 if(trace_fraction < 256 / vlen(delta))
459 // rule 4: don't want to look at sky
460 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
463 // rule 5: we must not end up in trigger_hurt
464 if(tracebox_hits_trigger_hurt(start, self.mins, self.maxs, enddown))
466 dprint("trigger_hurt! ouch! and nothing else could find it!\n");
476 self.angles = vectoangles(end - start);
477 self.angles_x = -self.angles_x;
478 self.fixangle = TRUE;
479 self.velocity = '0 0 0';
480 dprint("Needed ", ftos(i + 1), " attempts\n");
483 sprint(self, "Emergency teleport could not find a good location, forget it!\n");
485 self.dphitcontentsmask = m;
488 makevectors(self.v_angle);
489 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, FALSE, self);
490 if (trace_fraction < 1)
491 printsurfaceinfo(trace_ent, trace_endpos);
494 makevectors(self.v_angle);
495 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 65536, FALSE, self);
496 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);