]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_impulse.qc
Merge remote branch 'origin/master' into terencehill/infinite_ammo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_impulse.qc
1 /*
2  * Impulse map:
3  *
4  * 0 reserved (no input)
5  * 1 to 9, 14: weapon shortcuts
6  * 10: next weapon according to linear list
7  * 11: most recently used weapon
8  * 12: previous weapon according to linear list
9  * 13: best weapon according to priority list
10  * 15: next weapon according to priority list
11  * 16: previous weapon according to priority list
12  * 17: throw weapon
13  * 18: next weapon according to sbar_hudselector 1 list
14  * 19: previous weapon according to sbar_hudselector 1 list
15  * 20: reload if needed
16  *
17  * 30 to 39: create waypoints
18  * 47: clear personal waypoints
19  * 48: clear team waypoints
20  *
21  * 99: loaded
22  *
23  * 140: moving clone
24  * 141: ctf speedrun
25  * 142: fixed clone
26  * 143: emergency teleport
27  * 148: unfairly eliminate
28  *
29  * TODO:
30  * 200 to 209: prev weapon shortcuts
31  * 210 to 219: best weapon shortcuts
32  * 220 to 229: next weapon shortcuts
33  * 230 to 253: individual weapons (up to 24)
34  */
35
36 void ImpulseCommands (void)
37 {
38         local float imp;
39         vector org;
40         float i;
41         float m;
42         entity e, e2;
43
44         imp = self.impulse;
45         if (!imp || gameover)
46                 return;
47         self.impulse = 0;
48
49         if (timeoutStatus == 2) //don't allow any impulses while the game is paused
50                 return;
51
52         if(CheatImpulse(imp))
53         {
54         }
55         else if (imp >= 1 && imp <= 9)
56         {
57                 // weapon switching impulses
58                 if(self.deadflag == DEAD_NO)
59                         W_NextWeaponOnImpulse(imp);
60                 else
61                         self.impulse = imp; // retry in next frame
62         }
63         else if(imp >= 10 && imp <= 20)
64         {
65                 if(self.deadflag == DEAD_NO)
66                 {
67                         switch(imp)
68                         {
69                                 case 10:
70                                         W_NextWeapon (0);
71                                         break;
72                                 case 11:
73                                         W_SwitchWeapon (self.cnt); // previously used
74                                         break;
75                                 case 12:
76                                         W_PreviousWeapon (0);
77                                         break;
78                                 case 13:
79                                         W_SwitchWeapon (w_getbestweapon(self));
80                                         break;
81                                 case 14:
82                                         W_NextWeaponOnImpulse(0);
83                                         break;
84                                 case 15:
85                                         W_NextWeapon (2);
86                                         break;
87                                 case 16:
88                                         W_PreviousWeapon (2);
89                                         break;
90                                 case 17:
91                                         if (!g_minstagib)
92                                                 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, FALSE), '0 0 0', TRUE);
93                                         break;
94                                 case 18:
95                                         W_NextWeapon (1);
96                                         break;
97                                 case 19:
98                                         W_PreviousWeapon (1);
99                                         break;
100                                 case 20:
101                                         W_TriggerReload ();
102                                         break;
103                         }
104                 }
105                 else
106                         self.impulse = imp; // retry in next frame
107         }
108         else if(imp == 21)
109         {
110                 PlayerUseKey ();
111         }
112         else if(imp >= 200 && imp <= 229)
113         {
114                 if(self.deadflag == DEAD_NO)
115                 {
116                         // custom order weapon cycling
117                         i = mod(imp, 10);
118                         m = (imp - (210 + i)); // <0 for prev, =0 for best, >0 for next
119                         W_CycleWeapon(self.(cvar_cl_weaponpriorities[i]), m);
120                 }
121                 else
122                         self.impulse = imp; // retry in next frame
123         }
124         else if(imp >= 230 && imp <= 253)
125         {
126                 if(self.deadflag == DEAD_NO)
127                         W_SwitchWeapon (imp - 230 + WEP_FIRST);
128                 else
129                         self.impulse = imp; // retry in next frame
130         }
131         // deploy waypoints
132         else if (imp >= 30 && imp <= 49)
133         {
134                 entity wp;
135                 switch(imp)
136                 {
137                         case 30:
138                                 wp = WaypointSprite_DeployPersonal("waypoint", self.origin, RADARICON_WAYPOINT, '0 1 1');
139                                 if(wp)
140                                         WaypointSprite_Ping(wp);
141                                 sprint(self, "personal waypoint spawned at location\n");
142                                 break;
143                         case 31:
144                                 WarpZone_crosshair_trace(self);
145                                 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos, RADARICON_WAYPOINT, '0 1 1');
146                                 if(wp)
147                                         WaypointSprite_Ping(wp);
148                                 sprint(self, "personal waypoint spawned at crosshair\n");
149                                 break;
150                         case 32:
151                                 if(vlen(self.death_origin))
152                                 {
153                                         wp = WaypointSprite_DeployPersonal("waypoint", self.death_origin, RADARICON_WAYPOINT, '0 1 1');
154                                         if(wp)
155                                                 WaypointSprite_Ping(wp);
156                                         sprint(self, "personal waypoint spawned at death location\n");
157                                 }
158                                 break;
159                         case 33:
160                                 if(self.deadflag == DEAD_NO && teamplay)
161                                 {
162                                         wp = WaypointSprite_Attach("helpme", TRUE, RADARICON_HELPME, '1 0.5 0');
163                                         if(!wp)
164                                                 WaypointSprite_HelpMePing(self.waypointsprite_attachedforcarrier);
165                                         else
166                                                 WaypointSprite_Ping(wp);
167                                         sprint(self, "HELP ME attached\n");
168                                 }
169                                 break;
170                         case 34:
171                                 wp = WaypointSprite_DeployFixed("here", FALSE, self.origin, RADARICON_HERE, '0 1 0');
172                                 if(wp)
173                                         WaypointSprite_Ping(wp);
174                                 sprint(self, "HERE spawned at location\n");
175                                 break;
176                         case 35:
177                                 WarpZone_crosshair_trace(self);
178                                 wp = WaypointSprite_DeployFixed("here", FALSE, trace_endpos, RADARICON_HERE, '0 1 0');
179                                 if(wp)
180                                         WaypointSprite_Ping(wp);
181                                 sprint(self, "HERE spawned at crosshair\n");
182                                 break;
183                         case 36:
184                                 if(vlen(self.death_origin))
185                                 {
186                                         wp = WaypointSprite_DeployFixed("here", FALSE, self.death_origin, RADARICON_HERE, '0 1 0');
187                                         if(wp)
188                                                 WaypointSprite_Ping(wp);
189                                         sprint(self, "HERE spawned at death location\n");
190                                 }
191                                 break;
192                         case 37:
193                                 wp = WaypointSprite_DeployFixed("danger", FALSE, self.origin, RADARICON_DANGER, '1 0.5 0');
194                                 if(wp)
195                                         WaypointSprite_Ping(wp);
196                                 sprint(self, "DANGER spawned at location\n");
197                                 break;
198                         case 38:
199                                 WarpZone_crosshair_trace(self);
200                                 wp = WaypointSprite_DeployFixed("danger", FALSE, trace_endpos, RADARICON_DANGER, '1 0.5 0');
201                                 if(wp)
202                                         WaypointSprite_Ping(wp);
203                                 sprint(self, "DANGER spawned at crosshair\n");
204                                 break;
205                         case 39:
206                                 if(vlen(self.death_origin))
207                                 {
208                                         wp = WaypointSprite_DeployFixed("danger", FALSE, self.death_origin, RADARICON_DANGER, '1 0.5 0');
209                                         if(wp)
210                                                 WaypointSprite_Ping(wp);
211                                         sprint(self, "DANGER spawned at death location\n");
212                                 }
213                                 break;
214                         case 47:
215                                 WaypointSprite_ClearPersonal();
216                                 if(self.personal)
217                                 {
218                                         remove(self.personal);
219                                         self.personal = world;
220                                 }
221                                 sprint(self, "personal waypoint cleared\n");
222                                 break;
223                         case 48:
224                                 WaypointSprite_ClearOwned();
225                                 if(self.personal)
226                                 {
227                                         remove(self.personal);
228                                         self.personal = world;
229                                 }
230                                 sprint(self, "all waypoints cleared\n");
231                                 break;
232                 }
233         }
234         else if(imp >= 103 && imp <= 107)
235         {
236                 if(autocvar_g_waypointeditor)
237                 {
238                         switch(imp)
239                         {
240                                 case 103:
241                                         waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
242                                         bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
243                                         break;
244                                 case 104:
245                                         e = navigation_findnearestwaypoint(self, FALSE);
246                                         if (e)
247                                         if not(e.wpflags & WAYPOINTFLAG_GENERATED)
248                                         {
249                                                 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
250                                                 waypoint_remove(e);
251                                         }
252                                         break;
253                                 case 105:
254                                         waypoint_schedulerelinkall();
255                                         break;
256                                 case 106:
257                                         waypoint_saveall();
258                                         break;
259                                 case 107:
260                                         for(e = findchain(classname, "waypoint"); e; e = e.chain)
261                                         {
262                                                 e.colormod = '0.5 0.5 0.5';
263                                                 e.effects &~= EF_NODEPTHTEST | EF_RED | EF_BLUE;
264                                         }
265                                         e2 = navigation_findnearestwaypoint(self, FALSE);
266                                         navigation_markroutes(e2);
267                                         i = 0;
268                                         m = 0;
269                                         for(e = findchain(classname, "waypoint"); e; e = e.chain)
270                                         {
271                                                 if(e.wpcost >= 10000000)
272                                                 {
273                                                         print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
274                                                         e.colormod_z = 8;
275                                                         e.effects |= EF_NODEPTHTEST | EF_BLUE;
276                                                         ++i;
277                                                         ++m;
278                                                 }
279                                         }
280                                         if(i)
281                                                 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
282                                         navigation_markroutes_inverted(e2);
283                                         i = 0;
284                                         for(e = findchain(classname, "waypoint"); e; e = e.chain)
285                                         {
286                                                 if(e.wpcost >= 10000000)
287                                                 {
288                                                         print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
289                                                         e.colormod_x = 8;
290                                                         if not(e.effects & EF_NODEPTHTEST) // not already reported before
291                                                                 ++m;
292                                                         e.effects |= EF_NODEPTHTEST | EF_RED;
293                                                         ++i;
294                                                 }
295                                         }
296                                         if(i)
297                                                 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
298                                         if(m)
299                                                 print(ftos(m), " waypoints have been marked total\n");
300                                         i = 0;
301                                         for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
302                                         {
303                                                 org = e.origin;
304                                                 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
305                                                 setorigin(e, trace_endpos);
306                                                 if(navigation_findnearestwaypoint(e, FALSE))
307                                                 {
308                                                         setorigin(e, org);
309                                                         e.effects &~= EF_NODEPTHTEST;
310                                                         e.model = "";
311                                                 }
312                                                 else
313                                                 {
314                                                         setorigin(e, org);
315                                                         print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
316                                                         e.effects |= EF_NODEPTHTEST;
317                                                         setmodel(e, self.model);
318                                                         e.frame = self.frame;
319                                                         e.skin = self.skin;
320                                                         e.colormod = '8 0.5 8';
321                                                         setsize(e, '0 0 0', '0 0 0');
322                                                         ++i;
323                                                 }
324                                         }
325                                         if(i)
326                                                 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
327                                         i = 0;
328                                         entity start;
329                                         start = findchainflags(flags, FL_ITEM);
330                                         for(e = start; e; e = e.chain)
331                                         {
332                                                 e.effects &~= EF_NODEPTHTEST | EF_RED | EF_BLUE;
333                                                 e.colormod = '0.5 0.5 0.5';
334                                         }
335                                         for(e = start; e; e = e.chain)
336                                         {
337                                                 if(navigation_findnearestwaypoint(e, FALSE))
338                                                 {
339                                                 }
340                                                 else
341                                                 {
342                                                         print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
343                                                         e.effects |= EF_NODEPTHTEST | EF_RED;
344                                                         e.colormod_x = 8;
345                                                         ++i;
346                                                 }
347                                         }
348                                         if(i)
349                                                 print(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
350                                         i = 0;
351                                         for(e = start; e; e = e.chain)
352                                         {
353                                                 org = e.origin;
354                                                 if(navigation_findnearestwaypoint(e, TRUE))
355                                                 {
356                                                 }
357                                                 else
358                                                 {
359                                                         print("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
360                                                         e.effects |= EF_NODEPTHTEST | EF_BLUE;
361                                                         e.colormod_z = 8;
362                                                         ++i;
363                                                 }
364                                         }
365                                         if(i)
366                                                 print(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");
367                                         break;
368                         }
369                 }
370         }
371 #ifdef TETRIS
372         else if(imp == 100)
373                 TetrisImpulse();
374 #endif
375 }