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/minigames/sv_minigames.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 if ( self.active_minigame )
67 if ( MinigameImpulse(imp) )
70 // allow only weapon change impulses when not in round time
71 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
72 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
75 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
79 if(self.vehicle.deadflag == DEAD_NO)
81 if(self.vehicle.vehicles_impulse)
82 if(self.vehicle.vehicles_impulse(imp))
84 if(vehicle_impulse(imp))
91 else if (imp >= 1 && imp <= 9)
93 // weapon switching impulses
94 if(self.deadflag == DEAD_NO)
95 W_NextWeaponOnImpulse(imp);
97 // self.impulse = imp; // retry in next frame
99 else if(imp >= 10 && imp <= 20)
102 if(self.deadflag == DEAD_NO)
116 W_SwitchWeapon(w_getbestweapon(self));
119 W_NextWeaponOnImpulse(0);
128 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
137 if(!forbidWeaponUse(self)) { WEP_ACTION(self.weapon, WR_RELOAD); }
142 self.impulse = imp; // retry in next frame
148 else if(imp >= 200 && imp <= 229)
151 if(self.deadflag == DEAD_NO)
153 // custom order weapon cycling
155 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
156 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
159 self.impulse = imp; // retry in next frame
161 else if(imp >= 230 && imp <= 253)
164 if(self.deadflag == DEAD_NO)
165 W_SwitchWeapon (imp - 230 + WEP_FIRST);
167 self.impulse = imp; // retry in next frame
170 else if (imp >= 30 && imp <= 49)
176 wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.origin, RADARICON_WAYPOINT);
178 WaypointSprite_Ping(wp);
179 sprint(self, "personal waypoint spawned at location\n");
182 WarpZone_crosshair_trace(self);
183 wp = WaypointSprite_DeployPersonal(WP_Waypoint, trace_endpos, RADARICON_WAYPOINT);
185 WaypointSprite_Ping(wp);
186 sprint(self, "personal waypoint spawned at crosshair\n");
189 if(vlen(self.death_origin))
191 wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.death_origin, RADARICON_WAYPOINT);
193 WaypointSprite_Ping(wp);
194 sprint(self, "personal waypoint spawned at death location\n");
198 if(self.deadflag == DEAD_NO && teamplay)
200 if (!MUTATOR_CALLHOOK(HelpMePing, self))
202 wp = WaypointSprite_Attach(WP_Helpme, true, RADARICON_HELPME);
204 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
206 WaypointSprite_Ping(wp);
208 sprint(self, "HELP ME attached\n");
212 wp = WaypointSprite_DeployFixed(WP_Here, false, self.origin, RADARICON_HERE);
214 WaypointSprite_Ping(wp);
215 sprint(self, "HERE spawned at location\n");
218 WarpZone_crosshair_trace(self);
219 wp = WaypointSprite_DeployFixed(WP_Here, false, trace_endpos, RADARICON_HERE);
221 WaypointSprite_Ping(wp);
222 sprint(self, "HERE spawned at crosshair\n");
225 if(vlen(self.death_origin))
227 wp = WaypointSprite_DeployFixed(WP_Here, false, self.death_origin, RADARICON_HERE);
229 WaypointSprite_Ping(wp);
230 sprint(self, "HERE spawned at death location\n");
234 wp = WaypointSprite_DeployFixed(WP_Danger, false, self.origin, RADARICON_DANGER);
236 WaypointSprite_Ping(wp);
237 sprint(self, "DANGER spawned at location\n");
240 WarpZone_crosshair_trace(self);
241 wp = WaypointSprite_DeployFixed(WP_Danger, false, trace_endpos, RADARICON_DANGER);
243 WaypointSprite_Ping(wp);
244 sprint(self, "DANGER spawned at crosshair\n");
247 if(vlen(self.death_origin))
249 wp = WaypointSprite_DeployFixed(WP_Danger, false, self.death_origin, RADARICON_DANGER);
251 WaypointSprite_Ping(wp);
252 sprint(self, "DANGER spawned at death location\n");
256 WaypointSprite_ClearPersonal();
259 remove(self.personal);
260 self.personal = world;
262 sprint(self, "personal waypoint cleared\n");
265 WaypointSprite_ClearOwned();
268 remove(self.personal);
269 self.personal = world;
271 sprint(self, "all waypoints cleared\n");
275 else if(imp >= 103 && imp <= 107)
277 if(autocvar_g_waypointeditor)
282 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
283 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
286 e = navigation_findnearestwaypoint(self, false);
288 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
290 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
295 waypoint_schedulerelinkall();
301 for(e = findchain(classname, "waypoint"); e; e = e.chain)
303 e.colormod = '0.5 0.5 0.5';
304 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
306 e2 = navigation_findnearestwaypoint(self, false);
307 navigation_markroutes(e2);
310 for(e = findchain(classname, "waypoint"); e; e = e.chain)
312 if(e.wpcost >= 10000000)
314 LOG_INFO("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
316 e.effects |= EF_NODEPTHTEST | EF_BLUE;
322 LOG_INFO(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
323 navigation_markroutes_inverted(e2);
325 for(e = findchain(classname, "waypoint"); e; e = e.chain)
327 if(e.wpcost >= 10000000)
329 LOG_INFO("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
331 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
333 e.effects |= EF_NODEPTHTEST | EF_RED;
338 LOG_INFO(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
340 LOG_INFO(ftos(m), " waypoints have been marked total\n");
342 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
345 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
346 setorigin(e, trace_endpos);
347 if(navigation_findnearestwaypoint(e, false))
350 e.effects &= ~EF_NODEPTHTEST;
356 LOG_INFO("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
357 e.effects |= EF_NODEPTHTEST;
358 _setmodel(e, self.model);
359 e.frame = self.frame;
361 e.colormod = '8 0.5 8';
362 setsize(e, '0 0 0', '0 0 0');
367 LOG_INFO(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
370 start = findchainflags(flags, FL_ITEM);
371 for(e = start; e; e = e.chain)
373 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
374 e.colormod = '0.5 0.5 0.5';
376 for(e = start; e; e = e.chain)
378 if(navigation_findnearestwaypoint(e, false))
383 LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
384 e.effects |= EF_NODEPTHTEST | EF_RED;
390 LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
392 for(e = start; e; e = e.chain)
395 if(navigation_findnearestwaypoint(e, true))
400 LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
401 e.effects |= EF_NODEPTHTEST | EF_BLUE;
407 LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");