]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_impulse.qc
Get rid of TNSF_FAR, short is good enougth. Hide server based turret head from client.
[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);
139                                 if(wp)
140                                 {
141                                         WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
142                                         WaypointSprite_Ping(wp);
143                                 }
144                                 sprint(self, "personal waypoint spawned at location\n");
145                                 break;
146                         case 31:
147                                 WarpZone_crosshair_trace(self);
148                                 wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos);
149                                 if(wp)
150                                 {
151                                         WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
152                                         WaypointSprite_Ping(wp);
153                                 }
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);
160                                         if(wp)
161                                         {
162                                                 WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
163                                                 WaypointSprite_Ping(wp);
164                                         }
165                                         sprint(self, "personal waypoint spawned at death location\n");
166                                 }
167                                 break;
168                         case 33:
169                                 if(self.deadflag == DEAD_NO && teamplay)
170                                 {
171                                         wp = WaypointSprite_Attach("helpme", TRUE);
172                                         if(wp)
173                                                 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HELPME, '1 0.5 0'); // TODO choose better color
174                                         if(!wp)
175                                                 wp = self.waypointsprite_attachedforcarrier; // flag sprite?
176                                         if(wp)
177                                                 WaypointSprite_Ping(wp);
178                                         sprint(self, "HELP ME attached\n");
179                                 }
180                                 break;
181                         case 34:
182                                 wp = WaypointSprite_DeployFixed("here", FALSE, self.origin);
183                                 if(wp)
184                                 {
185                                         WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
186                                         WaypointSprite_Ping(wp);
187                                 }
188                                 sprint(self, "HERE spawned at location\n");
189                                 break;
190                         case 35:
191                                 WarpZone_crosshair_trace(self);
192                                 wp = WaypointSprite_DeployFixed("here", FALSE, trace_endpos);
193                                 if(wp)
194                                 {
195                                         WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
196                                         WaypointSprite_Ping(wp);
197                                 }
198                                 sprint(self, "HERE spawned at crosshair\n");
199                                 break;
200                         case 36:
201                                 if(vlen(self.death_origin))
202                                 {
203                                         wp = WaypointSprite_DeployFixed("here", FALSE, self.death_origin);
204                                         if(wp)
205                                         {
206                                                 WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
207                                                 WaypointSprite_Ping(wp);
208                                         }
209                                         sprint(self, "HERE spawned at death location\n");
210                                 }
211                                 break;
212                         case 37:
213                                 wp = WaypointSprite_DeployFixed("danger", FALSE, self.origin);
214                                 if(wp)
215                                 {
216                                         WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
217                                         WaypointSprite_Ping(wp);
218                                 }
219                                 sprint(self, "DANGER spawned at location\n");
220                                 break;
221                         case 38:
222                                 WarpZone_crosshair_trace(self);
223                                 wp = WaypointSprite_DeployFixed("danger", FALSE, trace_endpos);
224                                 if(wp)
225                                 {
226                                         WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
227                                         WaypointSprite_Ping(wp);
228                                 }
229                                 sprint(self, "DANGER spawned at crosshair\n");
230                                 break;
231                         case 39:
232                                 if(vlen(self.death_origin))
233                                 {
234                                         wp = WaypointSprite_DeployFixed("danger", FALSE, self.death_origin);
235                                         if(wp)
236                                         {
237                                                 WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
238                                                 WaypointSprite_Ping(wp);
239                                         }
240                                         sprint(self, "DANGER spawned at death location\n");
241                                 }
242                                 break;
243                         case 47:
244                                 WaypointSprite_ClearPersonal();
245                                 if(self.personal)
246                                 {
247                                         remove(self.personal);
248                                         self.personal = world;
249                                 }
250                                 sprint(self, "personal waypoint cleared\n");
251                                 break;
252                         case 48:
253                                 WaypointSprite_ClearOwned();
254                                 if(self.personal)
255                                 {
256                                         remove(self.personal);
257                                         self.personal = world;
258                                 }
259                                 sprint(self, "all waypoints cleared\n");
260                                 break;
261                 }
262         }
263         else if(imp >= 103 && imp <= 107)
264         {
265                 if(autocvar_g_waypointeditor)
266                 {
267                         switch(imp)
268                         {
269                                 case 103:
270                                         waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
271                                         bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
272                                         break;
273                                 case 104:
274                                         e = navigation_findnearestwaypoint(self, FALSE);
275                                         if (e)
276                                         if not(e.wpflags & WAYPOINTFLAG_GENERATED)
277                                         {
278                                                 bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
279                                                 waypoint_remove(e);
280                                         }
281                                         break;
282                                 case 105:
283                                         waypoint_schedulerelinkall();
284                                         break;
285                                 case 106:
286                                         waypoint_saveall();
287                                         break;
288                                 case 107:
289                                         for(e = findchain(classname, "waypoint"); e; e = e.chain)
290                                         {
291                                                 e.colormod_x = 1;
292                                                 e.effects &~= EF_NODEPTHTEST | EF_RED | EF_BLUE;
293                                         }
294                                         e2 = navigation_findnearestwaypoint(self, FALSE);
295                                         navigation_markroutes(e2);
296                                         i = 0;
297                                         m = 0;
298                                         for(e = findchain(classname, "waypoint"); e; e = e.chain)
299                                         {
300                                                 if(e.wpcost >= 10000000)
301                                                 {
302                                                         print("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
303                                                         e.colormod_x = 0.1;
304                                                         e.effects |= EF_NODEPTHTEST | EF_BLUE;
305                                                         ++i;
306                                                         ++m;
307                                                 }
308                                         }
309                                         if(i)
310                                                 print(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
311                                         navigation_markroutes_inverted(e2);
312                                         i = 0;
313                                         for(e = findchain(classname, "waypoint"); e; e = e.chain)
314                                         {
315                                                 if(e.wpcost >= 10000000)
316                                                 {
317                                                         print("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
318                                                         e.colormod_x = 0.1;
319                                                         if not(e.effects & EF_NODEPTHTEST) // not already reported before
320                                                                 ++m;
321                                                         e.effects |= EF_NODEPTHTEST | EF_RED;
322                                                         ++i;
323                                                 }
324                                         }
325                                         if(i)
326                                                 print(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
327                                         if(m)
328                                                 print(ftos(m), " waypoints have been marked total\n");
329                                         i = 0;
330                                         for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
331                                         {
332                                                 org = e.origin;
333                                                 tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
334                                                 setorigin(e, trace_endpos);
335                                                 if(navigation_findnearestwaypoint(e, FALSE))
336                                                 {
337                                                         setorigin(e, org);
338                                                         e.effects &~= EF_NODEPTHTEST;
339                                                         e.model = "";
340                                                 }
341                                                 else
342                                                 {
343                                                         setorigin(e, org);
344                                                         print("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
345                                                         e.effects |= EF_NODEPTHTEST;
346                                                         setmodel(e, self.model);
347                                                         e.frame = self.frame;
348                                                         e.skin = self.skin;
349                                                         setsize(e, '0 0 0', '0 0 0');
350                                                         ++i;
351                                                 }
352                                         }
353                                         if(i)
354                                                 print(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
355                                         break;
356                         }
357                 }
358         }
359 #ifdef TETRIS
360         else if(imp == 100)
361                 TetrisImpulse();
362 #endif
363 }