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 "waypointsprites.qh"
15 #include "../common/minigames/sv_minigames.qh"
17 #include "../common/weapons/all.qh"
22 * 0 reserved (no input)
23 * 1 to 9, 14: weapon shortcuts
24 * 10: next weapon according to linear list
25 * 11: most recently used weapon
26 * 12: previous weapon according to linear list
27 * 13: best weapon according to priority list
28 * 15: next weapon according to priority list
29 * 16: previous weapon according to priority list
31 * 18: next weapon according to sbar_hudselector 1 list
32 * 19: previous weapon according to sbar_hudselector 1 list
33 * 20: reload if needed
35 * 30 to 39: create waypoints
36 * 47: clear personal waypoints
37 * 48: clear team waypoints
44 * 143: emergency teleport
45 * 148: unfairly eliminate
48 * 200 to 209: prev weapon shortcuts
49 * 210 to 219: best weapon shortcuts
50 * 220 to 229: next weapon shortcuts
51 * 230 to 253: individual weapons (up to 24)
54 void ImpulseCommands (void)
67 if ( self.active_minigame )
68 if ( MinigameImpulse(imp) )
71 // allow only weapon change impulses when not in round time
72 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
73 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
76 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
80 if(self.vehicle.deadflag == DEAD_NO)
82 if(self.vehicle.vehicles_impulse)
83 if(self.vehicle.vehicles_impulse(imp))
85 if(vehicle_impulse(imp))
92 else if (imp >= 1 && imp <= 9)
94 // weapon switching impulses
95 if(self.deadflag == DEAD_NO)
96 W_NextWeaponOnImpulse(imp);
98 // self.impulse = imp; // retry in next frame
100 else if(imp >= 10 && imp <= 20)
103 if(self.deadflag == DEAD_NO)
117 W_SwitchWeapon(w_getbestweapon(self));
120 W_NextWeaponOnImpulse(0);
129 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
138 if(!forbidWeaponUse(self)) { WEP_ACTION(self.weapon, WR_RELOAD); }
143 self.impulse = imp; // retry in next frame
149 else if(imp >= 200 && imp <= 229)
152 if(self.deadflag == DEAD_NO)
154 // custom order weapon cycling
156 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
157 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
160 self.impulse = imp; // retry in next frame
162 else if(imp >= 230 && imp <= 253)
165 if(self.deadflag == DEAD_NO)
166 W_SwitchWeapon (imp - 230 + WEP_FIRST);
168 self.impulse = imp; // retry in next frame
171 else if (imp >= 30 && imp <= 49)
177 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
179 WaypointSprite_Ping(wp);
180 sprint(self, "personal waypoint spawned at location\n");
183 WarpZone_crosshair_trace(self);
184 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
186 WaypointSprite_Ping(wp);
187 sprint(self, "personal waypoint spawned at crosshair\n");
190 if(vlen(self.death_origin))
192 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
194 WaypointSprite_Ping(wp);
195 sprint(self, "personal waypoint spawned at death location\n");
199 if(self.deadflag == DEAD_NO && teamplay)
201 if (!MUTATOR_CALLHOOK(HelpMePing, self))
203 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
205 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
207 WaypointSprite_Ping(wp);
209 sprint(self, "HELP ME attached\n");
213 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
215 WaypointSprite_Ping(wp);
216 sprint(self, "HERE spawned at location\n");
219 WarpZone_crosshair_trace(self);
220 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
222 WaypointSprite_Ping(wp);
223 sprint(self, "HERE spawned at crosshair\n");
226 if(vlen(self.death_origin))
228 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
230 WaypointSprite_Ping(wp);
231 sprint(self, "HERE spawned at death location\n");
235 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
237 WaypointSprite_Ping(wp);
238 sprint(self, "DANGER spawned at location\n");
241 WarpZone_crosshair_trace(self);
242 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
244 WaypointSprite_Ping(wp);
245 sprint(self, "DANGER spawned at crosshair\n");
248 if(vlen(self.death_origin))
250 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
252 WaypointSprite_Ping(wp);
253 sprint(self, "DANGER spawned at death location\n");
257 WaypointSprite_ClearPersonal();
260 remove(self.personal);
261 self.personal = world;
263 sprint(self, "personal waypoint cleared\n");
266 WaypointSprite_ClearOwned();
269 remove(self.personal);
270 self.personal = world;
272 sprint(self, "all waypoints cleared\n");
276 else if(imp >= 103 && imp <= 107)
278 if(autocvar_g_waypointeditor)
283 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
284 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
287 e = navigation_findnearestwaypoint(self, false);
289 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
291 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
296 waypoint_schedulerelinkall();
302 for(e = findchain(classname, "waypoint"); e; e = e.chain)
304 e.colormod = '0.5 0.5 0.5';
305 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
307 e2 = navigation_findnearestwaypoint(self, false);
308 navigation_markroutes(e2);
311 for(e = findchain(classname, "waypoint"); e; e = e.chain)
313 if(e.wpcost >= 10000000)
315 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
317 e.effects |= EF_NODEPTHTEST | EF_BLUE;
323 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
324 navigation_markroutes_inverted(e2);
326 for(e = findchain(classname, "waypoint"); e; e = e.chain)
328 if(e.wpcost >= 10000000)
330 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
332 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
334 e.effects |= EF_NODEPTHTEST | EF_RED;
339 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
341 print(ftos(m), " waypoints have been marked total\n");
343 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
346 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
347 setorigin(e, trace_endpos);
348 if(navigation_findnearestwaypoint(e, false))
351 e.effects &= ~EF_NODEPTHTEST;
357 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
358 e.effects |= EF_NODEPTHTEST;
359 setmodel(e, self.model);
360 e.frame = self.frame;
362 e.colormod = '8 0.5 8';
363 setsize(e, '0 0 0', '0 0 0');
368 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
371 start = findchainflags(flags, FL_ITEM);
372 for(e = start; e; e = e.chain)
374 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
375 e.colormod = '0.5 0.5 0.5';
377 for(e = start; e; e = e.chain)
379 if(navigation_findnearestwaypoint(e, false))
384 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
385 e.effects |= EF_NODEPTHTEST | EF_RED;
391 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
393 for(e = start; e; e = e.chain)
396 if(navigation_findnearestwaypoint(e, true))
401 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
402 e.effects |= EF_NODEPTHTEST | EF_BLUE;
408 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");