1 #include "round_handler.qh"
3 #include "bot/waypoints.qh"
5 #include "weapons/throwing.qh"
7 #include "../common/minigames/sv_minigames.qh"
9 #include "../common/weapons/weapons.qh"
14 * 0 reserved (no input)
15 * 1 to 9, 14: weapon shortcuts
16 * 10: next weapon according to linear list
17 * 11: most recently used weapon
18 * 12: previous weapon according to linear list
19 * 13: best weapon according to priority list
20 * 15: next weapon according to priority list
21 * 16: previous weapon according to priority list
23 * 18: next weapon according to sbar_hudselector 1 list
24 * 19: previous weapon according to sbar_hudselector 1 list
25 * 20: reload if needed
27 * 30 to 39: create waypoints
28 * 47: clear personal waypoints
29 * 48: clear team waypoints
36 * 143: emergency teleport
37 * 148: unfairly eliminate
40 * 200 to 209: prev weapon shortcuts
41 * 210 to 219: best weapon shortcuts
42 * 220 to 229: next weapon shortcuts
43 * 230 to 253: individual weapons (up to 24)
46 void ImpulseCommands (void)
59 if ( self.active_minigame )
60 if ( MinigameImpulse(imp) )
63 // allow only weapon change impulses when not in round time
64 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
65 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
68 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
72 if(self.vehicle.deadflag == DEAD_NO)
73 if(self.vehicle.vehicles_impulse)
74 if(self.vehicle.vehicles_impulse(imp))
80 else if (imp >= 1 && imp <= 9)
82 // weapon switching impulses
83 if(self.deadflag == DEAD_NO)
84 W_NextWeaponOnImpulse(imp);
86 // self.impulse = imp; // retry in next frame
88 else if(imp >= 10 && imp <= 20)
90 if(self.deadflag == DEAD_NO)
104 W_SwitchWeapon(w_getbestweapon(self));
107 W_NextWeaponOnImpulse(0);
116 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
125 if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); }
130 self.impulse = imp; // retry in next frame
136 else if(imp >= 200 && imp <= 229)
138 if(self.deadflag == DEAD_NO)
140 // custom order weapon cycling
142 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
143 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
146 self.impulse = imp; // retry in next frame
148 else if(imp >= 230 && imp <= 253)
150 if(self.deadflag == DEAD_NO)
151 W_SwitchWeapon (imp - 230 + WEP_FIRST);
153 self.impulse = imp; // retry in next frame
156 else if (imp >= 30 && imp <= 49)
162 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
164 WaypointSprite_Ping(wp);
165 sprint(self, "personal waypoint spawned at location\n");
168 WarpZone_crosshair_trace(self);
169 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
171 WaypointSprite_Ping(wp);
172 sprint(self, "personal waypoint spawned at crosshair\n");
175 if(vlen(self.death_origin))
177 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
179 WaypointSprite_Ping(wp);
180 sprint(self, "personal waypoint spawned at death location\n");
184 if(self.deadflag == DEAD_NO && teamplay)
186 if (!MUTATOR_CALLHOOK(HelpMePing))
188 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
190 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
192 WaypointSprite_Ping(wp);
194 sprint(self, "HELP ME attached\n");
198 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
200 WaypointSprite_Ping(wp);
201 sprint(self, "HERE spawned at location\n");
204 WarpZone_crosshair_trace(self);
205 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
207 WaypointSprite_Ping(wp);
208 sprint(self, "HERE spawned at crosshair\n");
211 if(vlen(self.death_origin))
213 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
215 WaypointSprite_Ping(wp);
216 sprint(self, "HERE spawned at death location\n");
220 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
222 WaypointSprite_Ping(wp);
223 sprint(self, "DANGER spawned at location\n");
226 WarpZone_crosshair_trace(self);
227 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
229 WaypointSprite_Ping(wp);
230 sprint(self, "DANGER spawned at crosshair\n");
233 if(vlen(self.death_origin))
235 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
237 WaypointSprite_Ping(wp);
238 sprint(self, "DANGER spawned at death location\n");
242 WaypointSprite_ClearPersonal();
245 remove(self.personal);
246 self.personal = world;
248 sprint(self, "personal waypoint cleared\n");
251 WaypointSprite_ClearOwned();
254 remove(self.personal);
255 self.personal = world;
257 sprint(self, "all waypoints cleared\n");
261 else if(imp >= 103 && imp <= 107)
263 if(autocvar_g_waypointeditor)
268 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
269 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
272 e = navigation_findnearestwaypoint(self, false);
274 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
276 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
281 waypoint_schedulerelinkall();
287 for(e = findchain(classname, "waypoint"); e; e = e.chain)
289 e.colormod = '0.5 0.5 0.5';
290 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
292 e2 = navigation_findnearestwaypoint(self, false);
293 navigation_markroutes(e2);
296 for(e = findchain(classname, "waypoint"); e; e = e.chain)
298 if(e.wpcost >= 10000000)
300 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
302 e.effects |= EF_NODEPTHTEST | EF_BLUE;
308 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
309 navigation_markroutes_inverted(e2);
311 for(e = findchain(classname, "waypoint"); e; e = e.chain)
313 if(e.wpcost >= 10000000)
315 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
317 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
319 e.effects |= EF_NODEPTHTEST | EF_RED;
324 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
326 print(ftos(m), " waypoints have been marked total\n");
328 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
331 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
332 setorigin(e, trace_endpos);
333 if(navigation_findnearestwaypoint(e, false))
336 e.effects &= ~EF_NODEPTHTEST;
342 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
343 e.effects |= EF_NODEPTHTEST;
344 setmodel(e, self.model);
345 e.frame = self.frame;
347 e.colormod = '8 0.5 8';
348 setsize(e, '0 0 0', '0 0 0');
353 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
356 start = findchainflags(flags, FL_ITEM);
357 for(e = start; e; e = e.chain)
359 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
360 e.colormod = '0.5 0.5 0.5';
362 for(e = start; e; e = e.chain)
364 if(navigation_findnearestwaypoint(e, false))
369 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
370 e.effects |= EF_NODEPTHTEST | EF_RED;
376 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
378 for(e = start; e; e = e.chain)
381 if(navigation_findnearestwaypoint(e, true))
386 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
387 e.effects |= EF_NODEPTHTEST | EF_BLUE;
393 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");