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"
14 #include "../common/weapons/all.qh"
19 * 0 reserved (no input)
20 * 1 to 9, 14: weapon shortcuts
21 * 10: next weapon according to linear list
22 * 11: most recently used weapon
23 * 12: previous weapon according to linear list
24 * 13: best weapon according to priority list
25 * 15: next weapon according to priority list
26 * 16: previous weapon according to priority list
28 * 18: next weapon according to sbar_hudselector 1 list
29 * 19: previous weapon according to sbar_hudselector 1 list
30 * 20: reload if needed
32 * 30 to 39: create waypoints
33 * 47: clear personal waypoints
34 * 48: clear team waypoints
41 * 143: emergency teleport
42 * 148: unfairly eliminate
45 * 200 to 209: prev weapon shortcuts
46 * 210 to 219: best weapon shortcuts
47 * 220 to 229: next weapon shortcuts
48 * 230 to 253: individual weapons (up to 24)
51 void ImpulseCommands (void)
64 // allow only weapon change impulses when not in round time
65 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
66 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
69 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
73 if(self.vehicle.deadflag == DEAD_NO)
75 if(self.vehicle.vehicles_impulse)
76 if(self.vehicle.vehicles_impulse(imp))
78 if(vehicle_impulse(imp))
85 else if (imp >= 1 && imp <= 9)
87 // weapon switching impulses
88 if(self.deadflag == DEAD_NO)
89 W_NextWeaponOnImpulse(imp);
91 // self.impulse = imp; // retry in next frame
93 else if(imp >= 10 && imp <= 20)
96 if(self.deadflag == DEAD_NO)
110 W_SwitchWeapon(w_getbestweapon(self));
113 W_NextWeaponOnImpulse(0);
122 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
131 if(!forbidWeaponUse(self)) { WEP_ACTION(self.weapon, WR_RELOAD); }
136 self.impulse = imp; // retry in next frame
142 else if(imp >= 200 && imp <= 229)
145 if(self.deadflag == DEAD_NO)
147 // custom order weapon cycling
149 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
150 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
153 self.impulse = imp; // retry in next frame
155 else if(imp >= 230 && imp <= 253)
158 if(self.deadflag == DEAD_NO)
159 W_SwitchWeapon (imp - 230 + WEP_FIRST);
161 self.impulse = imp; // retry in next frame
164 else if (imp >= 30 && imp <= 49)
170 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
172 WaypointSprite_Ping(wp);
173 sprint(self, "personal waypoint spawned at location\n");
176 WarpZone_crosshair_trace(self);
177 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
179 WaypointSprite_Ping(wp);
180 sprint(self, "personal waypoint spawned at crosshair\n");
183 if(vlen(self.death_origin))
185 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
187 WaypointSprite_Ping(wp);
188 sprint(self, "personal waypoint spawned at death location\n");
192 if(self.deadflag == DEAD_NO && teamplay)
194 if (!MUTATOR_CALLHOOK(HelpMePing, self))
196 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
198 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
200 WaypointSprite_Ping(wp);
202 sprint(self, "HELP ME attached\n");
206 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
208 WaypointSprite_Ping(wp);
209 sprint(self, "HERE spawned at location\n");
212 WarpZone_crosshair_trace(self);
213 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
215 WaypointSprite_Ping(wp);
216 sprint(self, "HERE spawned at crosshair\n");
219 if(vlen(self.death_origin))
221 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
223 WaypointSprite_Ping(wp);
224 sprint(self, "HERE spawned at death location\n");
228 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
230 WaypointSprite_Ping(wp);
231 sprint(self, "DANGER spawned at location\n");
234 WarpZone_crosshair_trace(self);
235 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
237 WaypointSprite_Ping(wp);
238 sprint(self, "DANGER spawned at crosshair\n");
241 if(vlen(self.death_origin))
243 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
245 WaypointSprite_Ping(wp);
246 sprint(self, "DANGER spawned at death location\n");
250 WaypointSprite_ClearPersonal();
253 remove(self.personal);
254 self.personal = world;
256 sprint(self, "personal waypoint cleared\n");
259 WaypointSprite_ClearOwned();
262 remove(self.personal);
263 self.personal = world;
265 sprint(self, "all waypoints cleared\n");
269 else if(imp >= 103 && imp <= 107)
271 if(autocvar_g_waypointeditor)
276 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
277 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
280 e = navigation_findnearestwaypoint(self, false);
282 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
284 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
289 waypoint_schedulerelinkall();
295 for(e = findchain(classname, "waypoint"); e; e = e.chain)
297 e.colormod = '0.5 0.5 0.5';
298 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
300 e2 = navigation_findnearestwaypoint(self, false);
301 navigation_markroutes(e2);
304 for(e = findchain(classname, "waypoint"); e; e = e.chain)
306 if(e.wpcost >= 10000000)
308 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
310 e.effects |= EF_NODEPTHTEST | EF_BLUE;
316 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
317 navigation_markroutes_inverted(e2);
319 for(e = findchain(classname, "waypoint"); e; e = e.chain)
321 if(e.wpcost >= 10000000)
323 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
325 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
327 e.effects |= EF_NODEPTHTEST | EF_RED;
332 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
334 print(ftos(m), " waypoints have been marked total\n");
336 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
339 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
340 setorigin(e, trace_endpos);
341 if(navigation_findnearestwaypoint(e, false))
344 e.effects &= ~EF_NODEPTHTEST;
350 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
351 e.effects |= EF_NODEPTHTEST;
352 setmodel(e, self.model);
353 e.frame = self.frame;
355 e.colormod = '8 0.5 8';
356 setsize(e, '0 0 0', '0 0 0');
361 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
364 start = findchainflags(flags, FL_ITEM);
365 for(e = start; e; e = e.chain)
367 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
368 e.colormod = '0.5 0.5 0.5';
370 for(e = start; e; e = e.chain)
372 if(navigation_findnearestwaypoint(e, false))
377 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
378 e.effects |= EF_NODEPTHTEST | EF_RED;
384 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
386 for(e = start; e; e = e.chain)
389 if(navigation_findnearestwaypoint(e, true))
394 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
395 e.effects |= EF_NODEPTHTEST | EF_BLUE;
401 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");