]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_impulse.qc
latch the mutator cvars too
[divverent/nexuiz.git] / data / qcsrc / server / cl_impulse.qc
1 .vector personal_v_angle; // view angles to restore on impulse 77
2
3 void CopyBody(float keepvelocity);
4
5 // changes by LordHavoc on 03/30/04
6 // cleaned up dummy code
7 // dummies are now removed eventually after being gibbed (norespawn = TRUE)
8 // dummy impulse now checks sv_cheats to prevent players from overwhelming server with dummies
9 // dummies now use player code where possible
10
11 void player_anim (void);
12 void DummyThink(void)
13 {
14         self.think = DummyThink;
15         self.nextthink = time;
16         SV_PlayerPhysics();
17         PlayerPreThink();
18         //player_anim();
19         PlayerPostThink();
20 }
21
22 // from dpmod
23 void(entity e, vector v) printsurfaceinfo =
24 {
25         local float surfnum, numpoints, vnum;
26         local string s;
27         local vector n;
28         surfnum = getsurfacenearpoint(e, v);
29         if (surfnum >= 0)
30         {
31                 sprint(self, "texture: ");
32                 s = getsurfacetexture(e, surfnum);
33                 sprint(self, s);
34                 sprint(self, " normal: ");
35                 n = getsurfacenormal(e, surfnum);
36                 sprint(self, vtos(n));
37                 sprint(self, " ");
38                 numpoints = getsurfacenumpoints(e, surfnum);
39                 sprint(self, ftos(numpoints));
40                 sprint(self, " verts:");
41                 vnum = 0;
42                 while (vnum < numpoints)
43                 {
44                         sprint(self, " ");
45                         n = getsurfacepoint(e, surfnum, vnum);
46                         sprint(self, vtos(n));
47                         vnum = vnum + 1;
48                 }
49                 sprint(self, " point tested: ");
50                 sprint(self, vtos(v));
51                 sprint(self, " nearest point on surface: ");
52                 n = getsurfaceclippedpoint(e, surfnum, v);
53                 sprint(self, vtos(n));
54                 sprint(self, "\n");
55         }
56 };
57
58 void ImpulseCommands (void)
59 {
60         local float imp;
61         imp = self.impulse;
62         if (!imp || gameover)
63                 return;
64         self.impulse = 0;
65         if (imp >= 1 && imp <= 12)
66         {
67                 // weapon switching impulses
68                 if(self.deadflag == DEAD_NO)
69                 {
70                         if (imp <= 9)
71                                 W_SwitchWeapon (imp);
72                         else if (imp == 10)
73                                 W_NextWeapon ();
74                         else if (imp == 12)
75                                 W_PreviousWeapon ();
76                         else if (imp == 11) // last weapon
77                                 W_SwitchWeapon (self.cnt);
78                 }
79                 else
80                         self.impulse = imp; // retry in next frame
81         }
82         // throw weapon
83         else if (imp == 17)
84         {
85                 if(self.deadflag == DEAD_NO)
86                 {
87                         if (self.weapon != WEP_LASER
88                                 && !g_minstagib && !g_instagib
89                                 && !g_rocketarena && !g_lms && cvar("g_pickup_items") && !g_nixnex)
90                                 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750), '0 0 0', TRUE);
91                 }
92         }
93         // deploy waypoints
94         else if (imp >= 30 && imp <= 49)
95         {
96                 if(imp == 30)
97                 {
98                         WaypointSprite_DeployPersonal("waypoint", self.origin);
99                         self.personal_v_angle = self.v_angle;
100                         sprint(self, "personal waypoint spawned at location\n");
101                 }
102                 else if(imp == 31)
103                 {
104                         WaypointSprite_DeployPersonal("waypoint", self.cursor_trace_endpos);
105                         self.personal_v_angle = self.v_angle;
106                         sprint(self, "personal waypoint spawned at crosshair\n");
107                 }
108                 else if(imp == 32 && vlen(self.death_origin))
109                 {
110                         WaypointSprite_DeployPersonal("waypoint", self.death_origin);
111                         self.personal_v_angle = self.v_angle;
112                         sprint(self, "personal waypoint spawned at death location\n");
113                 }
114                 else if(imp == 33 && self.deadflag == DEAD_NO && teams_matter)
115                 {
116                         WaypointSprite_Attach("helpme", TRUE);
117                         sprint(self, "HELP ME attached\n");
118                 }
119                 else if(imp == 34)
120                 {
121                         WaypointSprite_DeployFixed("here", FALSE, self.origin);
122                         sprint(self, "HERE spawned at location\n");
123                 }
124                 else if(imp == 35)
125                 {
126                         WaypointSprite_DeployFixed("here", FALSE, self.cursor_trace_endpos);
127                         sprint(self, "HERE spawned at crosshair\n");
128                 }
129                 else if(imp == 36 && vlen(self.death_origin))
130                 {
131                         WaypointSprite_DeployFixed("here", FALSE, self.death_origin);
132                         sprint(self, "HERE spawned at death location\n");
133                 }
134                 else if(imp == 37)
135                 {
136                         WaypointSprite_DeployFixed("danger", FALSE, self.origin);
137                         sprint(self, "DANGER spawned at location\n");
138                 }
139                 else if(imp == 38)
140                 {
141                         WaypointSprite_DeployFixed("danger", FALSE, self.cursor_trace_endpos);
142                         sprint(self, "DANGER spawned at crosshair\n");
143                 }
144                 else if(imp == 39 && vlen(self.death_origin))
145                 {
146                         WaypointSprite_DeployFixed("danger", FALSE, self.death_origin);
147                         sprint(self, "DANGER spawned at death location\n");
148                 }
149                 else if(imp == 47)
150                 {
151                         WaypointSprite_ClearPersonal();
152                         sprint(self, "personal waypoint cleared\n");
153                 }
154                 else if(imp == 48)
155                 {
156                         WaypointSprite_ClearOwned();
157                         sprint(self, "all waypoints cleared\n");
158                 }
159                 else if(imp == 49)
160                 {
161                         self.cvar_cl_hidewaypoints = !(self.cvar_cl_hidewaypoints);
162                         sprint(self, "fixed waypoints now ");
163                         if(self.cvar_cl_hidewaypoints)
164                                 sprint(self, "OFF\n");
165                         else
166                                 sprint(self, "ON\n");
167                 }
168         }
169         else
170         {
171                 if (sv_cheats)
172                 {
173                         if(imp == 19)
174                         {
175                                 makevectors(self.v_angle);
176                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, FALSE, self);
177                                 if (trace_fraction < 1)
178                                         printsurfaceinfo(trace_ent, trace_endpos);
179                         }
180                         else if(imp == 20)
181                         {
182                                 makevectors(self.v_angle);
183                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 65536, FALSE, self);
184                                 sprint(self, strcat("distance: ", ftos(fabs(vlen(trace_endpos - (self.origin + self.view_ofs)))), "\n"));
185                         }
186                         else if(self.deadflag == DEAD_NO)
187                         {
188                                 if(imp == 77)
189                                 {
190                                         if(self.waypointsprite_deployed_personal)
191                                         {
192                                                 tracebox(self.waypointsprite_deployed_personal.origin, self.mins, self.maxs, self.waypointsprite_deployed_personal.origin, MOVE_WORLDONLY, self);
193                                                 if(trace_startsolid)
194                                                 {
195                                                         sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
196                                                 }
197                                                 else
198                                                 {
199                                                         // Abort speedrun, teleport back
200                                                         setorigin(self, self.waypointsprite_deployed_personal.origin);
201                                                         self.velocity = '0 0 0';
202                                                         self.angles = self.personal_v_angle;
203                                                         self.fixangle = TRUE;
204                                                         if(self.flagcarried)
205                                                         {
206                                                                 bprint("The ", self.flagcarried.netname, " was returned to base by its carrier\n");
207                                                                 ReturnFlag(self.flagcarried);
208                                                         }
209                                                 }
210                                         }
211                                         else
212                                                 sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
213                                 }
214                                 else if(imp == 99)
215                                 {
216                                         self.items |= (IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER);
217                                         self.ammo_shells = cvar("g_pickup_shells_max");
218                                         self.ammo_nails = cvar("g_pickup_nails_max");
219                                         self.ammo_rockets = cvar("g_pickup_rockets_max");
220                                         self.ammo_cells = cvar("g_pickup_cells_max");
221                                         self.health = cvar("g_pickup_healthshard_max");
222                                         self.armorvalue = cvar("g_pickup_armorshard_max");
223                                         self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
224                                         self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
225                                         self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
226                                         // precache weapon models/sounds
227                                         local float wep;
228                                         wep = WEP_FIRST;
229                                         while (wep <= WEP_LAST)
230                                         {
231                                                 weapon_action(wep, WR_PRECACHE);
232                                                 wep = wep + 1;
233                                         }
234                                 }
235                                 else if (imp == 13)
236                                 {
237                                         makevectors (self.v_angle);
238                                         self.velocity = self.velocity + v_forward * 300;
239                                         CopyBody(1);
240                                         self.velocity = self.velocity - v_forward * 300;
241                                 }
242                                 else if (imp == 14)
243                                         CopyBody(0);
244                         }
245                 }
246         }
247
248         if (cvar("g_waypointeditor"))
249         {
250                 local entity e;
251                 if (imp == 103) waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
252                 else if (imp == 104) {e = navigation_findnearestwaypoint(self, FALSE);if (e) waypoint_remove(e);}
253                 else if (imp == 105) waypoint_schedulerelinkall();
254                 else if (imp == 106) waypoint_saveall();
255         }
256
257         //TetrisImpulses();
258 }