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 "vehicles/vehicle.qh"
14 #include "waypointsprites.qh"
16 #include "../common/weapons/weapons.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)
93 if(self.deadflag == DEAD_NO)
107 W_SwitchWeapon(w_getbestweapon(self));
110 W_NextWeaponOnImpulse(0);
119 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
128 if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); }
133 self.impulse = imp; // retry in next frame
139 else if(imp >= 200 && imp <= 229)
141 if(self.deadflag == DEAD_NO)
143 // custom order weapon cycling
145 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
146 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
149 self.impulse = imp; // retry in next frame
151 else if(imp >= 230 && imp <= 253)
153 if(self.deadflag == DEAD_NO)
154 W_SwitchWeapon (imp - 230 + WEP_FIRST);
156 self.impulse = imp; // retry in next frame
159 else if (imp >= 30 && imp <= 49)
165 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
167 WaypointSprite_Ping(wp);
168 sprint(self, "personal waypoint spawned at location\n");
171 WarpZone_crosshair_trace(self);
172 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
174 WaypointSprite_Ping(wp);
175 sprint(self, "personal waypoint spawned at crosshair\n");
178 if(vlen(self.death_origin))
180 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
182 WaypointSprite_Ping(wp);
183 sprint(self, "personal waypoint spawned at death location\n");
187 if(self.deadflag == DEAD_NO && teamplay)
189 if (!MUTATOR_CALLHOOK(HelpMePing))
191 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
193 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
195 WaypointSprite_Ping(wp);
197 sprint(self, "HELP ME attached\n");
201 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
203 WaypointSprite_Ping(wp);
204 sprint(self, "HERE spawned at location\n");
207 WarpZone_crosshair_trace(self);
208 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
210 WaypointSprite_Ping(wp);
211 sprint(self, "HERE spawned at crosshair\n");
214 if(vlen(self.death_origin))
216 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
218 WaypointSprite_Ping(wp);
219 sprint(self, "HERE spawned at death location\n");
223 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
225 WaypointSprite_Ping(wp);
226 sprint(self, "DANGER spawned at location\n");
229 WarpZone_crosshair_trace(self);
230 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
232 WaypointSprite_Ping(wp);
233 sprint(self, "DANGER spawned at crosshair\n");
236 if(vlen(self.death_origin))
238 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
240 WaypointSprite_Ping(wp);
241 sprint(self, "DANGER spawned at death location\n");
245 WaypointSprite_ClearPersonal();
248 remove(self.personal);
249 self.personal = world;
251 sprint(self, "personal waypoint cleared\n");
254 WaypointSprite_ClearOwned();
257 remove(self.personal);
258 self.personal = world;
260 sprint(self, "all waypoints cleared\n");
264 else if(imp >= 103 && imp <= 107)
266 if(autocvar_g_waypointeditor)
271 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
272 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
275 e = navigation_findnearestwaypoint(self, false);
277 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
279 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
284 waypoint_schedulerelinkall();
290 for(e = findchain(classname, "waypoint"); e; e = e.chain)
292 e.colormod = '0.5 0.5 0.5';
293 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
295 e2 = navigation_findnearestwaypoint(self, false);
296 navigation_markroutes(e2);
299 for(e = findchain(classname, "waypoint"); e; e = e.chain)
301 if(e.wpcost >= 10000000)
303 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
305 e.effects |= EF_NODEPTHTEST | EF_BLUE;
311 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
312 navigation_markroutes_inverted(e2);
314 for(e = findchain(classname, "waypoint"); e; e = e.chain)
316 if(e.wpcost >= 10000000)
318 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
320 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
322 e.effects |= EF_NODEPTHTEST | EF_RED;
327 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
329 print(ftos(m), " waypoints have been marked total\n");
331 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
334 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
335 setorigin(e, trace_endpos);
336 if(navigation_findnearestwaypoint(e, false))
339 e.effects &= ~EF_NODEPTHTEST;
345 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
346 e.effects |= EF_NODEPTHTEST;
347 setmodel(e, self.model);
348 e.frame = self.frame;
350 e.colormod = '8 0.5 8';
351 setsize(e, '0 0 0', '0 0 0');
356 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
359 start = findchainflags(flags, FL_ITEM);
360 for(e = start; e; e = e.chain)
362 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
363 e.colormod = '0.5 0.5 0.5';
365 for(e = start; e; e = e.chain)
367 if(navigation_findnearestwaypoint(e, false))
372 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
373 e.effects |= EF_NODEPTHTEST | EF_RED;
379 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
381 for(e = start; e; e = e.chain)
384 if(navigation_findnearestwaypoint(e, true))
389 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
390 e.effects |= EF_NODEPTHTEST | EF_BLUE;
396 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");