2 #include "round_handler.qh"
4 #include "bot/waypoints.qh"
6 #include "weapons/throwing.qh"
7 #include "command/common.qh"
9 #include "bot/navigation.qh"
10 #include "weapons/selection.qh"
11 #include "weapons/tracing.qh"
12 #include "weapons/weaponsystem.qh"
13 #include "../common/vehicles/sv_vehicles.qh"
14 #include "waypointsprites.qh"
16 #include "../common/weapons/all.qh"
21 * 0 reserved (no input)
22 * 1 to 9, 14: weapon shortcuts
23 * 10: next weapon according to linear list
24 * 11: most recently used weapon
25 * 12: previous weapon according to linear list
26 * 13: best weapon according to priority list
27 * 15: next weapon according to priority list
28 * 16: previous weapon according to priority list
30 * 18: next weapon according to sbar_hudselector 1 list
31 * 19: previous weapon according to sbar_hudselector 1 list
32 * 20: reload if needed
34 * 30 to 39: create waypoints
35 * 47: clear personal waypoints
36 * 48: clear team waypoints
43 * 143: emergency teleport
44 * 148: unfairly eliminate
47 * 200 to 209: prev weapon shortcuts
48 * 210 to 219: best weapon shortcuts
49 * 220 to 229: next weapon shortcuts
50 * 230 to 253: individual weapons (up to 24)
53 void ImpulseCommands (void)
66 // allow only weapon change impulses when not in round time
67 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
68 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
71 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
75 if(self.vehicle.deadflag == DEAD_NO)
76 if(self.vehicle.vehicles_impulse)
77 if(self.vehicle.vehicles_impulse(imp))
83 else if (imp >= 1 && imp <= 9)
85 // weapon switching impulses
86 if(self.deadflag == DEAD_NO)
87 W_NextWeaponOnImpulse(imp);
89 // self.impulse = imp; // retry in next frame
91 else if(imp >= 10 && imp <= 20)
94 if(self.deadflag == DEAD_NO)
108 W_SwitchWeapon(w_getbestweapon(self));
111 W_NextWeaponOnImpulse(0);
120 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
129 if(!forbidWeaponUse(self)) { WEP_ACTION(self.weapon, WR_RELOAD); }
134 self.impulse = imp; // retry in next frame
140 else if(imp >= 200 && imp <= 229)
143 if(self.deadflag == DEAD_NO)
145 // custom order weapon cycling
147 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
148 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
151 self.impulse = imp; // retry in next frame
153 else if(imp >= 230 && imp <= 253)
156 if(self.deadflag == DEAD_NO)
157 W_SwitchWeapon (imp - 230 + WEP_FIRST);
159 self.impulse = imp; // retry in next frame
162 else if (imp >= 30 && imp <= 49)
168 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
170 WaypointSprite_Ping(wp);
171 sprint(self, "personal waypoint spawned at location\n");
174 WarpZone_crosshair_trace(self);
175 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
177 WaypointSprite_Ping(wp);
178 sprint(self, "personal waypoint spawned at crosshair\n");
181 if(vlen(self.death_origin))
183 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
185 WaypointSprite_Ping(wp);
186 sprint(self, "personal waypoint spawned at death location\n");
190 if(self.deadflag == DEAD_NO && teamplay)
192 if (!MUTATOR_CALLHOOK(HelpMePing))
194 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
196 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
198 WaypointSprite_Ping(wp);
200 sprint(self, "HELP ME attached\n");
204 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
206 WaypointSprite_Ping(wp);
207 sprint(self, "HERE spawned at location\n");
210 WarpZone_crosshair_trace(self);
211 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
213 WaypointSprite_Ping(wp);
214 sprint(self, "HERE spawned at crosshair\n");
217 if(vlen(self.death_origin))
219 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
221 WaypointSprite_Ping(wp);
222 sprint(self, "HERE spawned at death location\n");
226 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
228 WaypointSprite_Ping(wp);
229 sprint(self, "DANGER spawned at location\n");
232 WarpZone_crosshair_trace(self);
233 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
235 WaypointSprite_Ping(wp);
236 sprint(self, "DANGER spawned at crosshair\n");
239 if(vlen(self.death_origin))
241 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
243 WaypointSprite_Ping(wp);
244 sprint(self, "DANGER spawned at death location\n");
248 WaypointSprite_ClearPersonal();
251 remove(self.personal);
252 self.personal = world;
254 sprint(self, "personal waypoint cleared\n");
257 WaypointSprite_ClearOwned();
260 remove(self.personal);
261 self.personal = world;
263 sprint(self, "all waypoints cleared\n");
267 else if(imp >= 103 && imp <= 107)
269 if(autocvar_g_waypointeditor)
274 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
275 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
278 e = navigation_findnearestwaypoint(self, false);
280 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
282 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
287 waypoint_schedulerelinkall();
293 for(e = findchain(classname, "waypoint"); e; e = e.chain)
295 e.colormod = '0.5 0.5 0.5';
296 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
298 e2 = navigation_findnearestwaypoint(self, false);
299 navigation_markroutes(e2);
302 for(e = findchain(classname, "waypoint"); e; e = e.chain)
304 if(e.wpcost >= 10000000)
306 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
308 e.effects |= EF_NODEPTHTEST | EF_BLUE;
314 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
315 navigation_markroutes_inverted(e2);
317 for(e = findchain(classname, "waypoint"); e; e = e.chain)
319 if(e.wpcost >= 10000000)
321 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
323 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
325 e.effects |= EF_NODEPTHTEST | EF_RED;
330 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
332 print(ftos(m), " waypoints have been marked total\n");
334 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
337 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
338 setorigin(e, trace_endpos);
339 if(navigation_findnearestwaypoint(e, false))
342 e.effects &= ~EF_NODEPTHTEST;
348 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
349 e.effects |= EF_NODEPTHTEST;
350 setmodel(e, self.model);
351 e.frame = self.frame;
353 e.colormod = '8 0.5 8';
354 setsize(e, '0 0 0', '0 0 0');
359 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
362 start = findchainflags(flags, FL_ITEM);
363 for(e = start; e; e = e.chain)
365 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
366 e.colormod = '0.5 0.5 0.5';
368 for(e = start; e; e = e.chain)
370 if(navigation_findnearestwaypoint(e, false))
375 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
376 e.effects |= EF_NODEPTHTEST | EF_RED;
382 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
384 for(e = start; e; e = e.chain)
387 if(navigation_findnearestwaypoint(e, true))
392 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
393 e.effects |= EF_NODEPTHTEST | EF_BLUE;
399 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");