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)
85 if(self.deadflag == DEAD_NO)
99 W_SwitchWeapon(w_getbestweapon(self));
102 W_NextWeaponOnImpulse(0);
111 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
120 if(!forbidWeaponUse(self)) { WEP_ACTION(self.weapon, WR_RELOAD); }
125 self.impulse = imp; // retry in next frame
131 else if(imp >= 200 && imp <= 229)
134 if(self.deadflag == DEAD_NO)
136 // custom order weapon cycling
138 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
139 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
142 self.impulse = imp; // retry in next frame
144 else if(imp >= 230 && imp <= 253)
147 if(self.deadflag == DEAD_NO)
148 W_SwitchWeapon (imp - 230 + WEP_FIRST);
150 self.impulse = imp; // retry in next frame
153 else if (imp >= 30 && imp <= 49)
159 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
161 WaypointSprite_Ping(wp);
162 sprint(self, "personal waypoint spawned at location\n");
165 WarpZone_crosshair_trace(self);
166 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
168 WaypointSprite_Ping(wp);
169 sprint(self, "personal waypoint spawned at crosshair\n");
172 if(vlen(self.death_origin))
174 wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
176 WaypointSprite_Ping(wp);
177 sprint(self, "personal waypoint spawned at death location\n");
181 if(self.deadflag == DEAD_NO && teamplay)
183 if (!MUTATOR_CALLHOOK(HelpMePing))
185 wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0');
187 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
189 WaypointSprite_Ping(wp);
191 sprint(self, "HELP ME attached\n");
195 wp = WaypointSprite_DeployFixed("here", false, self.origin, RADARICON_HERE, '0 1 0');
197 WaypointSprite_Ping(wp);
198 sprint(self, "HERE spawned at location\n");
201 WarpZone_crosshair_trace(self);
202 wp = WaypointSprite_DeployFixed("here", false, trace_endpos, RADARICON_HERE, '0 1 0');
204 WaypointSprite_Ping(wp);
205 sprint(self, "HERE spawned at crosshair\n");
208 if(vlen(self.death_origin))
210 wp = WaypointSprite_DeployFixed("here", false, self.death_origin, RADARICON_HERE, '0 1 0');
212 WaypointSprite_Ping(wp);
213 sprint(self, "HERE spawned at death location\n");
217 wp = WaypointSprite_DeployFixed("danger", false, self.origin, RADARICON_DANGER, '1 0.5 0');
219 WaypointSprite_Ping(wp);
220 sprint(self, "DANGER spawned at location\n");
223 WarpZone_crosshair_trace(self);
224 wp = WaypointSprite_DeployFixed("danger", false, trace_endpos, RADARICON_DANGER, '1 0.5 0');
226 WaypointSprite_Ping(wp);
227 sprint(self, "DANGER spawned at crosshair\n");
230 if(vlen(self.death_origin))
232 wp = WaypointSprite_DeployFixed("danger", false, self.death_origin, RADARICON_DANGER, '1 0.5 0');
234 WaypointSprite_Ping(wp);
235 sprint(self, "DANGER spawned at death location\n");
239 WaypointSprite_ClearPersonal();
242 remove(self.personal);
243 self.personal = world;
245 sprint(self, "personal waypoint cleared\n");
248 WaypointSprite_ClearOwned();
251 remove(self.personal);
252 self.personal = world;
254 sprint(self, "all waypoints cleared\n");
258 else if(imp >= 103 && imp <= 107)
260 if(autocvar_g_waypointeditor)
265 waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
266 bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
269 e = navigation_findnearestwaypoint(self, false);
271 if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
273 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
278 waypoint_schedulerelinkall();
284 for(e = findchain(classname, "waypoint"); e; e = e.chain)
286 e.colormod = '0.5 0.5 0.5';
287 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
289 e2 = navigation_findnearestwaypoint(self, false);
290 navigation_markroutes(e2);
293 for(e = findchain(classname, "waypoint"); e; e = e.chain)
295 if(e.wpcost >= 10000000)
297 print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
299 e.effects |= EF_NODEPTHTEST | EF_BLUE;
305 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
306 navigation_markroutes_inverted(e2);
308 for(e = findchain(classname, "waypoint"); e; e = e.chain)
310 if(e.wpcost >= 10000000)
312 print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
314 if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
316 e.effects |= EF_NODEPTHTEST | EF_RED;
321 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
323 print(ftos(m), " waypoints have been marked total\n");
325 for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
328 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
329 setorigin(e, trace_endpos);
330 if(navigation_findnearestwaypoint(e, false))
333 e.effects &= ~EF_NODEPTHTEST;
339 print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
340 e.effects |= EF_NODEPTHTEST;
341 setmodel(e, self.model);
342 e.frame = self.frame;
344 e.colormod = '8 0.5 8';
345 setsize(e, '0 0 0', '0 0 0');
350 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
353 start = findchainflags(flags, FL_ITEM);
354 for(e = start; e; e = e.chain)
356 e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
357 e.colormod = '0.5 0.5 0.5';
359 for(e = start; e; e = e.chain)
361 if(navigation_findnearestwaypoint(e, false))
366 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
367 e.effects |= EF_NODEPTHTEST | EF_RED;
373 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
375 for(e = start; e; e = e.chain)
378 if(navigation_findnearestwaypoint(e, true))
383 print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
384 e.effects |= EF_NODEPTHTEST | EF_BLUE;
390 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");