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)) {
138 Weapon w = get_weaponinfo(self.weapon);
145 self.impulse = imp; // retry in next frame
151 else if(imp >= 200 && imp <= 229)
154 if(self.deadflag == DEAD_NO)
156 // custom order weapon cycling
158 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
159 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
162 self.impulse = imp; // retry in next frame
164 else if(imp >= WEP_IMPULSE_BEGIN && imp <= WEP_IMPULSE_END)
167 if(self.deadflag == DEAD_NO)
168 W_SwitchWeapon (imp - WEP_IMPULSE_BEGIN + WEP_FIRST);
170 self.impulse = imp; // retry in next frame
173 else if (imp >= 30 && imp <= 49)
179 wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.origin, RADARICON_WAYPOINT);
181 WaypointSprite_Ping(wp);
182 sprint(self, "personal waypoint spawned at location\n");
185 WarpZone_crosshair_trace(self);
186 wp = WaypointSprite_DeployPersonal(WP_Waypoint, trace_endpos, RADARICON_WAYPOINT);
188 WaypointSprite_Ping(wp);
189 sprint(self, "personal waypoint spawned at crosshair\n");
192 if(vlen(self.death_origin))
194 wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.death_origin, RADARICON_WAYPOINT);
196 WaypointSprite_Ping(wp);
197 sprint(self, "personal waypoint spawned at death location\n");
201 if(self.deadflag == DEAD_NO && teamplay)
203 if (!MUTATOR_CALLHOOK(HelpMePing, self))
205 wp = WaypointSprite_Attach(WP_Helpme, true, RADARICON_HELPME);
207 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
209 WaypointSprite_Ping(wp);
211 sprint(self, "HELP ME attached\n");
215 wp = WaypointSprite_DeployFixed(WP_Here, false, self.origin, RADARICON_HERE);
217 WaypointSprite_Ping(wp);
218 sprint(self, "HERE spawned at location\n");
221 WarpZone_crosshair_trace(self);
222 wp = WaypointSprite_DeployFixed(WP_Here, false, trace_endpos, RADARICON_HERE);
224 WaypointSprite_Ping(wp);
225 sprint(self, "HERE spawned at crosshair\n");
228 if(vlen(self.death_origin))
230 wp = WaypointSprite_DeployFixed(WP_Here, false, self.death_origin, RADARICON_HERE);
232 WaypointSprite_Ping(wp);
233 sprint(self, "HERE spawned at death location\n");
237 wp = WaypointSprite_DeployFixed(WP_Danger, false, self.origin, RADARICON_DANGER);
239 WaypointSprite_Ping(wp);
240 sprint(self, "DANGER spawned at location\n");
243 WarpZone_crosshair_trace(self);
244 wp = WaypointSprite_DeployFixed(WP_Danger, false, trace_endpos, RADARICON_DANGER);
246 WaypointSprite_Ping(wp);
247 sprint(self, "DANGER spawned at crosshair\n");
250 if(vlen(self.death_origin))
252 wp = WaypointSprite_DeployFixed(WP_Danger, false, self.death_origin, RADARICON_DANGER);
254 WaypointSprite_Ping(wp);
255 sprint(self, "DANGER spawned at death location\n");
259 WaypointSprite_ClearPersonal();
262 remove(self.personal);
263 self.personal = world;
265 sprint(self, "personal waypoint cleared\n");
268 WaypointSprite_ClearOwned();
271 remove(self.personal);
272 self.personal = world;
274 sprint(self, "all waypoints cleared\n");
278 else if(imp >= 103 && imp <= 107)
280 if(autocvar_g_waypointeditor)
285 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
286 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
289 e = navigation_findnearestwaypoint(self, false);
291 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
293 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
298 waypoint_schedulerelinkall();
304 for(e = findchain(classname, "waypoint"); e; e = e.chain)
306 e.colormod = '0.5 0.5 0.5';
307 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
309 e2 = navigation_findnearestwaypoint(self, false);
310 navigation_markroutes(e2);
313 for(e = findchain(classname, "waypoint"); e; e = e.chain)
315 if(e.wpcost >= 10000000)
317 LOG_INFO("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
319 e.effects |= EF_NODEPTHTEST | EF_BLUE;
325 LOG_INFO(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
326 navigation_markroutes_inverted(e2);
328 for(e = findchain(classname, "waypoint"); e; e = e.chain)
330 if(e.wpcost >= 10000000)
332 LOG_INFO("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
334 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
336 e.effects |= EF_NODEPTHTEST | EF_RED;
341 LOG_INFO(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
343 LOG_INFO(ftos(m), " waypoints have been marked total\n");
345 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
348 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
349 setorigin(e, trace_endpos);
350 if(navigation_findnearestwaypoint(e, false))
353 e.effects &= ~EF_NODEPTHTEST;
359 LOG_INFO("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
360 e.effects |= EF_NODEPTHTEST;
361 _setmodel(e, self.model);
362 e.frame = self.frame;
364 e.colormod = '8 0.5 8';
365 setsize(e, '0 0 0', '0 0 0');
370 LOG_INFO(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
373 start = findchainflags(flags, FL_ITEM);
374 for(e = start; e; e = e.chain)
376 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
377 e.colormod = '0.5 0.5 0.5';
379 for(e = start; e; e = e.chain)
381 if(navigation_findnearestwaypoint(e, false))
386 LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
387 e.effects |= EF_NODEPTHTEST | EF_RED;
393 LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
395 for(e = start; e; e = e.chain)
398 if(navigation_findnearestwaypoint(e, true))
403 LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
404 e.effects |= EF_NODEPTHTEST | EF_BLUE;
410 LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");