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