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 "vehicles/vehicle.qh"
14 #include "waypointsprites.qh"
16 #include "../common/minigames/sv_minigames.qh"
18 #include "../common/weapons/all.qh"
23 * 0 reserved (no input)
24 * 1 to 9, 14: weapon shortcuts
25 * 10: next weapon according to linear list
26 * 11: most recently used weapon
27 * 12: previous weapon according to linear list
28 * 13: best weapon according to priority list
29 * 15: next weapon according to priority list
30 * 16: previous weapon according to priority list
32 * 18: next weapon according to sbar_hudselector 1 list
33 * 19: previous weapon according to sbar_hudselector 1 list
34 * 20: reload if needed
36 * 30 to 39: create waypoints
37 * 47: clear personal waypoints
38 * 48: clear team waypoints
45 * 143: emergency teleport
46 * 148: unfairly eliminate
49 * 200 to 209: prev weapon shortcuts
50 * 210 to 219: best weapon shortcuts
51 * 220 to 229: next weapon shortcuts
52 * 230 to 253: individual weapons (up to 24)
55 void ImpulseCommands (void)
68 if ( self.active_minigame )
69 if ( MinigameImpulse(imp) )
72 // allow only weapon change impulses when not in round time
73 if(round_handler_IsActive() && !round_handler_IsRoundStarted())
74 if(imp == 17 || (imp >= 20 && imp < 200) || imp > 253)
77 if (timeout_status == TIMEOUT_ACTIVE) //don't allow any impulses while the game is paused
81 if(self.vehicle.deadflag == DEAD_NO)
82 if(self.vehicle.vehicles_impulse)
83 if(self.vehicle.vehicles_impulse(imp))
89 else if (imp >= 1 && imp <= 9)
91 // weapon switching impulses
92 if(self.deadflag == DEAD_NO)
93 W_NextWeaponOnImpulse(imp);
95 // self.impulse = imp; // retry in next frame
97 else if(imp >= 10 && imp <= 20)
99 if(self.deadflag == DEAD_NO)
113 W_SwitchWeapon(w_getbestweapon(self));
116 W_NextWeaponOnImpulse(0);
125 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, false), '0 0 0', true);
134 if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); }
139 self.impulse = imp; // retry in next frame
145 else if(imp >= 200 && imp <= 229)
147 if(self.deadflag == DEAD_NO)
149 // custom order weapon cycling
151 m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
152 W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
155 self.impulse = imp; // retry in next frame
157 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))
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");