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/weapons/all.qh"
20 * 0 reserved (no input)
21 * 1 to 9, 14: weapon shortcuts
22 * 10: next weapon according to linear list
23 * 11: most recently used weapon
24 * 12: previous weapon according to linear list
25 * 13: best weapon according to priority list
26 * 15: next weapon according to priority list
27 * 16: previous weapon according to priority list
29 * 18: next weapon according to sbar_hudselector 1 list
30 * 19: previous weapon according to sbar_hudselector 1 list
31 * 20: reload if needed
33 * 30 to 39: create waypoints
34 * 47: clear personal waypoints
35 * 48: clear team waypoints
42 * 143: emergency teleport
43 * 148: unfairly eliminate
46 * 200 to 209: prev weapon shortcuts
47 * 210 to 219: best weapon shortcuts
48 * 220 to 229: next weapon shortcuts
49 * 230 to 253: individual weapons (up to 24)
52 void ImpulseCommands (void)
65 // allow only weapon change impulses when not in round time
66 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
67 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
70 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
74 if(self.vehicle.deadflag == DEAD_NO)
76 if(self.vehicle.vehicles_impulse)
77 if(self.vehicle.vehicles_impulse(imp))
79 if(vehicle_impulse(imp))
86 else if (imp >= 1 && imp <= 9)
88 // weapon switching impulses
89 if(self.deadflag == DEAD_NO)
90 W_NextWeaponOnImpulse(imp);
92 // self.impulse = imp; // retry in next frame
94 else if(imp >= 10 && imp <= 20)
97 if(self.deadflag == DEAD_NO)
111 W_SwitchWeapon(w_getbestweapon(self));
114 W_NextWeaponOnImpulse(0);
123 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
132 if(!forbidWeaponUse(self)) { WEP_ACTION(self.weapon, WR_RELOAD); }
137 self.impulse = imp; // retry in next frame
143 else if(imp >= 200 && imp <= 229)
146 if(self.deadflag == DEAD_NO)
148 // custom order weapon cycling
150 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
151 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
154 self.impulse = imp; // retry in next frame
156 else if(imp >= 230 && imp <= 253)
159 if(self.deadflag == DEAD_NO)
160 W_SwitchWeapon (imp - 230 + WEP_FIRST);
162 self.impulse = imp; // retry in next frame
165 else if (imp >= 30 && imp <= 49)
171 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
173 WaypointSprite_Ping(wp);
174 sprint(self, "personal waypoint spawned at location\n");
177 WarpZone_crosshair_trace(self);
178 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
180 WaypointSprite_Ping(wp);
181 sprint(self, "personal waypoint spawned at crosshair\n");
184 if(vlen(self.death_origin))
186 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
188 WaypointSprite_Ping(wp);
189 sprint(self, "personal waypoint spawned at death location\n");
193 if(self.deadflag == DEAD_NO && teamplay)
195 if (!MUTATOR_CALLHOOK(HelpMePing, self))
197 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
199 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
201 WaypointSprite_Ping(wp);
203 sprint(self, "HELP ME attached\n");
207 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
209 WaypointSprite_Ping(wp);
210 sprint(self, "HERE spawned at location\n");
213 WarpZone_crosshair_trace(self);
214 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
216 WaypointSprite_Ping(wp);
217 sprint(self, "HERE spawned at crosshair\n");
220 if(vlen(self.death_origin))
222 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
224 WaypointSprite_Ping(wp);
225 sprint(self, "HERE spawned at death location\n");
229 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
231 WaypointSprite_Ping(wp);
232 sprint(self, "DANGER spawned at location\n");
235 WarpZone_crosshair_trace(self);
236 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
238 WaypointSprite_Ping(wp);
239 sprint(self, "DANGER spawned at crosshair\n");
242 if(vlen(self.death_origin))
244 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
246 WaypointSprite_Ping(wp);
247 sprint(self, "DANGER spawned at death location\n");
251 WaypointSprite_ClearPersonal();
254 remove(self.personal);
255 self.personal = world;
257 sprint(self, "personal waypoint cleared\n");
260 WaypointSprite_ClearOwned();
263 remove(self.personal);
264 self.personal = world;
266 sprint(self, "all waypoints cleared\n");
270 else if(imp >= 103 && imp <= 107)
272 if(autocvar_g_waypointeditor)
277 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
278 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
281 e = navigation_findnearestwaypoint(self, false);
283 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
285 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
290 waypoint_schedulerelinkall();
296 for(e = findchain(classname, "waypoint"); e; e = e.chain)
298 e.colormod = '0.5 0.5 0.5';
299 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
301 e2 = navigation_findnearestwaypoint(self, false);
302 navigation_markroutes(e2);
305 for(e = findchain(classname, "waypoint"); e; e = e.chain)
307 if(e.wpcost >= 10000000)
309 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
311 e.effects |= EF_NODEPTHTEST | EF_BLUE;
317 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
318 navigation_markroutes_inverted(e2);
320 for(e = findchain(classname, "waypoint"); e; e = e.chain)
322 if(e.wpcost >= 10000000)
324 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
326 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
328 e.effects |= EF_NODEPTHTEST | EF_RED;
333 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
335 print(ftos(m), " waypoints have been marked total\n");
337 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
340 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
341 setorigin(e, trace_endpos);
342 if(navigation_findnearestwaypoint(e, false))
345 e.effects &= ~EF_NODEPTHTEST;
351 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
352 e.effects |= EF_NODEPTHTEST;
353 setmodel(e, self.model);
354 e.frame = self.frame;
356 e.colormod = '8 0.5 8';
357 setsize(e, '0 0 0', '0 0 0');
362 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
365 start = findchainflags(flags, FL_ITEM);
366 for(e = start; e; e = e.chain)
368 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
369 e.colormod = '0.5 0.5 0.5';
371 for(e = start; e; e = e.chain)
373 if(navigation_findnearestwaypoint(e, false))
378 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
379 e.effects |= EF_NODEPTHTEST | EF_RED;
385 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
387 for(e = start; e; e = e.chain)
390 if(navigation_findnearestwaypoint(e, true))
395 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
396 e.effects |= EF_NODEPTHTEST | EF_BLUE;
402 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");