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