1 #include "round_handler.qh"
3 #include "bot/waypoints.qh"
5 #include "weapons/throwing.qh"
7 #include "../common/weapons/weapons.qh"
12 * 0 reserved (no input)
13 * 1 to 9, 14: weapon shortcuts
14 * 10: next weapon according to linear list
15 * 11: most recently used weapon
16 * 12: previous weapon according to linear list
17 * 13: best weapon according to priority list
18 * 15: next weapon according to priority list
19 * 16: previous weapon according to priority list
21 * 18: next weapon according to sbar_hudselector 1 list
22 * 19: previous weapon according to sbar_hudselector 1 list
23 * 20: reload if needed
25 * 30 to 39: create waypoints
26 * 47: clear personal waypoints
27 * 48: clear team waypoints
34 * 143: emergency teleport
35 * 148: unfairly eliminate
38 * 200 to 209: prev weapon shortcuts
39 * 210 to 219: best weapon shortcuts
40 * 220 to 229: next weapon shortcuts
41 * 230 to 253: individual weapons (up to 24)
44 void ImpulseCommands (void)
57 // allow only weapon change impulses when not in round time
58 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
59 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
62 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
66 if(self.vehicle.deadflag == DEAD_NO)
67 if(self.vehicle.vehicles_impulse)
68 if(self.vehicle.vehicles_impulse(imp))
74 else if (imp >= 1 && imp <= 9)
76 // weapon switching impulses
77 if(self.deadflag == DEAD_NO)
78 W_NextWeaponOnImpulse(imp);
80 // self.impulse = imp; // retry in next frame
82 else if(imp >= 10 && imp <= 20)
84 if(self.deadflag == DEAD_NO)
98 W_SwitchWeapon(w_getbestweapon(self));
101 W_NextWeaponOnImpulse(0);
110 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
119 if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); }
124 self.impulse = imp; // retry in next frame
130 else if(imp >= 200 && imp <= 229)
132 if(self.deadflag == DEAD_NO)
134 // custom order weapon cycling
136 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
137 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
140 self.impulse = imp; // retry in next frame
142 else if(imp >= 230 && imp <= 253)
144 if(self.deadflag == DEAD_NO)
145 W_SwitchWeapon (imp - 230 + WEP_FIRST);
147 self.impulse = imp; // retry in next frame
150 else if (imp >= 30 && imp <= 49)
156 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
158 WaypointSprite_Ping(wp);
159 sprint(self, "personal waypoint spawned at location\n");
162 WarpZone_crosshair_trace(self);
163 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
165 WaypointSprite_Ping(wp);
166 sprint(self, "personal waypoint spawned at crosshair\n");
169 if(vlen(self.death_origin))
171 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
173 WaypointSprite_Ping(wp);
174 sprint(self, "personal waypoint spawned at death location\n");
178 if(self.deadflag == DEAD_NO && teamplay)
180 if (!MUTATOR_CALLHOOK(HelpMePing))
182 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
184 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
186 WaypointSprite_Ping(wp);
188 sprint(self, "HELP ME attached\n");
192 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
194 WaypointSprite_Ping(wp);
195 sprint(self, "HERE spawned at location\n");
198 WarpZone_crosshair_trace(self);
199 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
201 WaypointSprite_Ping(wp);
202 sprint(self, "HERE spawned at crosshair\n");
205 if(vlen(self.death_origin))
207 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
209 WaypointSprite_Ping(wp);
210 sprint(self, "HERE spawned at death location\n");
214 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
216 WaypointSprite_Ping(wp);
217 sprint(self, "DANGER spawned at location\n");
220 WarpZone_crosshair_trace(self);
221 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
223 WaypointSprite_Ping(wp);
224 sprint(self, "DANGER spawned at crosshair\n");
227 if(vlen(self.death_origin))
229 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
231 WaypointSprite_Ping(wp);
232 sprint(self, "DANGER spawned at death location\n");
236 WaypointSprite_ClearPersonal();
239 remove(self.personal);
240 self.personal = world;
242 sprint(self, "personal waypoint cleared\n");
245 WaypointSprite_ClearOwned();
248 remove(self.personal);
249 self.personal = world;
251 sprint(self, "all waypoints cleared\n");
255 else if(imp >= 103 && imp <= 107)
257 if(autocvar_g_waypointeditor)
262 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
263 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
266 e = navigation_findnearestwaypoint(self, false);
268 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
270 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
275 waypoint_schedulerelinkall();
281 for(e = findchain(classname, "waypoint"); e; e = e.chain)
283 e.colormod = '0.5 0.5 0.5';
284 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
286 e2 = navigation_findnearestwaypoint(self, false);
287 navigation_markroutes(e2);
290 for(e = findchain(classname, "waypoint"); e; e = e.chain)
292 if(e.wpcost >= 10000000)
294 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
296 e.effects |= EF_NODEPTHTEST | EF_BLUE;
302 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
303 navigation_markroutes_inverted(e2);
305 for(e = findchain(classname, "waypoint"); e; e = e.chain)
307 if(e.wpcost >= 10000000)
309 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
311 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
313 e.effects |= EF_NODEPTHTEST | EF_RED;
318 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
320 print(ftos(m), " waypoints have been marked total\n");
322 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
325 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
326 setorigin(e, trace_endpos);
327 if(navigation_findnearestwaypoint(e, false))
330 e.effects &= ~EF_NODEPTHTEST;
336 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
337 e.effects |= EF_NODEPTHTEST;
338 setmodel(e, self.model);
339 e.frame = self.frame;
341 e.colormod = '8 0.5 8';
342 setsize(e, '0 0 0', '0 0 0');
347 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
350 start = findchainflags(flags, FL_ITEM);
351 for(e = start; e; e = e.chain)
353 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
354 e.colormod = '0.5 0.5 0.5';
356 for(e = start; e; e = e.chain)
358 if(navigation_findnearestwaypoint(e, false))
363 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
364 e.effects |= EF_NODEPTHTEST | EF_RED;
370 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
372 for(e = start; e; e = e.chain)
375 if(navigation_findnearestwaypoint(e, true))
380 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
381 e.effects |= EF_NODEPTHTEST | EF_BLUE;
387 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");