1 #include "round_handler.qh"
3 #include "bot/waypoints.qh"
5 #include "weapons/throwing.qh"
6 #include "command/common.qh"
8 #include "bot/navigation.qh"
9 #include "weapons/selection.qh"
10 #include "weapons/tracing.qh"
11 #include "weapons/weaponsystem.qh"
13 #include "../common/minigames/sv_minigames.qh"
15 #include "../common/weapons/all.qh"
16 #include "../common/vehicles/sv_vehicles.qh"
18 #include "../common/mutators/mutator/waypoints/waypointsprites.qh"
25 * 0 reserved (no input)
26 * 1 to 9, 14: weapon shortcuts
27 * 10: next weapon according to linear list
28 * 11: most recently used weapon
29 * 12: previous weapon according to linear list
30 * 13: best weapon according to priority list
31 * 15: next weapon according to priority list
32 * 16: previous weapon according to priority list
34 * 18: next weapon according to sbar_hudselector 1 list
35 * 19: previous weapon according to sbar_hudselector 1 list
36 * 20: reload if needed
38 * 30 to 39: create waypoints
39 * 47: clear personal waypoints
40 * 48: clear team waypoints
47 * 143: emergency teleport
48 * 148: unfairly eliminate
51 * 200 to 209: prev weapon shortcuts
52 * 210 to 219: best weapon shortcuts
53 * 220 to 229: next weapon shortcuts
54 * 230 to 253: individual weapons (up to 24)
57 void ImpulseCommands (void)
70 if ( self.active_minigame )
71 if ( MinigameImpulse(imp) )
74 // allow only weapon change impulses when not in round time
75 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
76 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
79 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
83 if(self.vehicle.deadflag == DEAD_NO)
85 if(self.vehicle.vehicles_impulse)
86 if(self.vehicle.vehicles_impulse(imp))
88 if(vehicle_impulse(imp))
95 else if (imp >= 1 && imp <= 9)
97 // weapon switching impulses
98 if(self.deadflag == DEAD_NO)
99 W_NextWeaponOnImpulse(imp);
101 // self.impulse = imp; // retry in next frame
103 else if(imp >= 10 && imp <= 20)
106 if(self.deadflag == DEAD_NO)
120 W_SwitchWeapon(w_getbestweapon(self));
123 W_NextWeaponOnImpulse(0);
132 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
141 if(!forbidWeaponUse(self)) {
142 Weapon w = get_weaponinfo(self.weapon);
149 self.impulse = imp; // retry in next frame
155 else if(imp >= 200 && imp <= 229)
158 if(self.deadflag == DEAD_NO)
160 // custom order weapon cycling
162 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
163 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
166 self.impulse = imp; // retry in next frame
168 else if(imp >= WEP_IMPULSE_BEGIN && imp <= WEP_IMPULSE_END)
171 if(self.deadflag == DEAD_NO)
172 W_SwitchWeapon (imp - WEP_IMPULSE_BEGIN + WEP_FIRST);
174 self.impulse = imp; // retry in next frame
177 else if (imp >= 30 && imp <= 49)
183 wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.origin, RADARICON_WAYPOINT);
185 WaypointSprite_Ping(wp);
186 sprint(self, "personal waypoint spawned at location\n");
189 WarpZone_crosshair_trace(self);
190 wp = WaypointSprite_DeployPersonal(WP_Waypoint, trace_endpos, RADARICON_WAYPOINT);
192 WaypointSprite_Ping(wp);
193 sprint(self, "personal waypoint spawned at crosshair\n");
196 if(vlen(self.death_origin))
198 wp = WaypointSprite_DeployPersonal(WP_Waypoint, self.death_origin, RADARICON_WAYPOINT);
200 WaypointSprite_Ping(wp);
201 sprint(self, "personal waypoint spawned at death location\n");
205 if(self.deadflag == DEAD_NO && teamplay)
207 if (!MUTATOR_CALLHOOK(HelpMePing, self))
209 wp = WaypointSprite_Attach(WP_Helpme, true, RADARICON_HELPME);
211 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
213 WaypointSprite_Ping(wp);
215 sprint(self, "HELP ME attached\n");
219 wp = WaypointSprite_DeployFixed(WP_Here, false, self.origin, RADARICON_HERE);
221 WaypointSprite_Ping(wp);
222 sprint(self, "HERE spawned at location\n");
225 WarpZone_crosshair_trace(self);
226 wp = WaypointSprite_DeployFixed(WP_Here, false, trace_endpos, RADARICON_HERE);
228 WaypointSprite_Ping(wp);
229 sprint(self, "HERE spawned at crosshair\n");
232 if(vlen(self.death_origin))
234 wp = WaypointSprite_DeployFixed(WP_Here, false, self.death_origin, RADARICON_HERE);
236 WaypointSprite_Ping(wp);
237 sprint(self, "HERE spawned at death location\n");
241 wp = WaypointSprite_DeployFixed(WP_Danger, false, self.origin, RADARICON_DANGER);
243 WaypointSprite_Ping(wp);
244 sprint(self, "DANGER spawned at location\n");
247 WarpZone_crosshair_trace(self);
248 wp = WaypointSprite_DeployFixed(WP_Danger, false, trace_endpos, RADARICON_DANGER);
250 WaypointSprite_Ping(wp);
251 sprint(self, "DANGER spawned at crosshair\n");
254 if(vlen(self.death_origin))
256 wp = WaypointSprite_DeployFixed(WP_Danger, false, self.death_origin, RADARICON_DANGER);
258 WaypointSprite_Ping(wp);
259 sprint(self, "DANGER spawned at death location\n");
263 WaypointSprite_ClearPersonal();
266 remove(self.personal);
267 self.personal = world;
269 sprint(self, "personal waypoint cleared\n");
272 WaypointSprite_ClearOwned();
275 remove(self.personal);
276 self.personal = world;
278 sprint(self, "all waypoints cleared\n");
282 else if(imp >= 103 && imp <= 107)
284 if(autocvar_g_waypointeditor)
289 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
290 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
293 e = navigation_findnearestwaypoint(self, false);
295 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
297 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
302 waypoint_schedulerelinkall();
308 for(e = findchain(classname, "waypoint"); e; e = e.chain)
310 e.colormod = '0.5 0.5 0.5';
311 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
313 e2 = navigation_findnearestwaypoint(self, false);
314 navigation_markroutes(e2);
317 for(e = findchain(classname, "waypoint"); e; e = e.chain)
319 if(e.wpcost >= 10000000)
321 LOG_INFO("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
323 e.effects |= EF_NODEPTHTEST | EF_BLUE;
329 LOG_INFO(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
330 navigation_markroutes_inverted(e2);
332 for(e = findchain(classname, "waypoint"); e; e = e.chain)
334 if(e.wpcost >= 10000000)
336 LOG_INFO("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
338 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
340 e.effects |= EF_NODEPTHTEST | EF_RED;
345 LOG_INFO(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
347 LOG_INFO(ftos(m), " waypoints have been marked total\n");
349 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
352 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
353 setorigin(e, trace_endpos);
354 if(navigation_findnearestwaypoint(e, false))
357 e.effects &= ~EF_NODEPTHTEST;
363 LOG_INFO("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
364 e.effects |= EF_NODEPTHTEST;
365 _setmodel(e, self.model);
366 e.frame = self.frame;
368 e.colormod = '8 0.5 8';
369 setsize(e, '0 0 0', '0 0 0');
374 LOG_INFO(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
377 start = findchainflags(flags, FL_ITEM);
378 for(e = start; e; e = e.chain)
380 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
381 e.colormod = '0.5 0.5 0.5';
383 for(e = start; e; e = e.chain)
385 if(navigation_findnearestwaypoint(e, false))
390 LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
391 e.effects |= EF_NODEPTHTEST | EF_RED;
397 LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
399 for(e = start; e; e = e.chain)
402 if(navigation_findnearestwaypoint(e, true))
407 LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
408 e.effects |= EF_NODEPTHTEST | EF_BLUE;
414 LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");