]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_impulse.qc
small changes to make tetris work again by just uncommenting some lines :-)
[divverent/nexuiz.git] / data / qcsrc / server / cl_impulse.qc
1 .vector personal_v_angle; // view angles to restore on impulse 77
2 .vector personal_velocity; // velocity to restore on impulse 77
3
4 void CopyBody(float keepvelocity);
5
6 // changes by LordHavoc on 03/30/04
7 // cleaned up dummy code
8 // dummies are now removed eventually after being gibbed (norespawn = TRUE)
9 // dummy impulse now checks sv_cheats to prevent players from overwhelming server with dummies
10 // dummies now use player code where possible
11
12 void player_anim (void);
13 void DummyThink(void)
14 {
15         self.think = DummyThink;
16         self.nextthink = time;
17         SV_PlayerPhysics();
18         PlayerPreThink();
19         //player_anim();
20         PlayerPostThink();
21 }
22
23 // from dpmod
24 void(entity e, vector v) printsurfaceinfo =
25 {
26         local float surfnum, numpoints, vnum;
27         local string s;
28         local vector n;
29         surfnum = getsurfacenearpoint(e, v);
30         if (surfnum >= 0)
31         {
32                 sprint(self, "texture: ");
33                 s = getsurfacetexture(e, surfnum);
34                 sprint(self, s);
35                 sprint(self, " normal: ");
36                 n = getsurfacenormal(e, surfnum);
37                 sprint(self, vtos(n));
38                 sprint(self, " ");
39                 numpoints = getsurfacenumpoints(e, surfnum);
40                 sprint(self, ftos(numpoints));
41                 sprint(self, " verts:");
42                 vnum = 0;
43                 while (vnum < numpoints)
44                 {
45                         sprint(self, " ");
46                         n = getsurfacepoint(e, surfnum, vnum);
47                         sprint(self, vtos(n));
48                         vnum = vnum + 1;
49                 }
50                 sprint(self, " point tested: ");
51                 sprint(self, vtos(v));
52                 sprint(self, " nearest point on surface: ");
53                 n = getsurfaceclippedpoint(e, surfnum, v);
54                 sprint(self, vtos(n));
55                 sprint(self, "\n");
56         }
57 };
58
59 void ImpulseCommands (void)
60 {
61         local float imp;
62         imp = self.impulse;
63         if (!imp || gameover)
64                 return;
65         self.impulse = 0;
66         if (imp >= 1 && imp <= 12)
67         {
68                 // weapon switching impulses
69                 if(self.deadflag == DEAD_NO)
70                 {
71                         if (imp <= 9)
72                                 W_SwitchWeapon (imp);
73                         else if (imp == 10)
74                                 W_NextWeapon ();
75                         else if (imp == 12)
76                                 W_PreviousWeapon ();
77                         else if (imp == 11) // last weapon
78                                 W_SwitchWeapon (self.cnt);
79                 }
80                 else
81                         self.impulse = imp; // retry in next frame
82         }
83         // throw weapon
84         else if (imp == 17)
85         {
86                 if(self.deadflag == DEAD_NO)
87                 if (!g_minstagib)
88                         W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750), '0 0 0', TRUE);
89         }
90         // deploy waypoints
91         else if (imp >= 30 && imp <= 49)
92         {
93                 if(imp == 30)
94                 {
95                         WaypointSprite_DeployPersonal("waypoint", self.origin);
96                         self.personal_v_angle = self.v_angle;
97                         self.personal_velocity = self.velocity;
98                         sprint(self, "personal waypoint spawned at location\n");
99                 }
100                 else if(imp == 31)
101                 {
102                         WaypointSprite_DeployPersonal("waypoint", self.cursor_trace_endpos);
103                         self.personal_v_angle = self.v_angle;
104                         self.personal_velocity = '0 0 0';
105                         sprint(self, "personal waypoint spawned at crosshair\n");
106                 }
107                 else if(imp == 32 && vlen(self.death_origin))
108                 {
109                         WaypointSprite_DeployPersonal("waypoint", self.death_origin);
110                         self.personal_v_angle = self.v_angle;
111                         self.personal_velocity = '0 0 0';
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                                                 self.speedrunning = TRUE;
193                                                 tracebox(self.waypointsprite_deployed_personal.origin, self.mins, self.maxs, self.waypointsprite_deployed_personal.origin, MOVE_WORLDONLY, self);
194                                                 if(trace_startsolid)
195                                                 {
196                                                         sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
197                                                 }
198                                                 else
199                                                 {
200                                                         // Abort speedrun, teleport back
201                                                         setorigin(self, self.waypointsprite_deployed_personal.origin);
202                                                         self.oldvelocity = self.velocity = self.personal_velocity;
203                                                         self.angles = self.personal_v_angle;
204                                                         self.fixangle = TRUE;
205                                                         if(self.flagcarried)
206                                                         {
207                                                                 bprint("The ", self.flagcarried.netname, " was returned to base by its carrier\n");
208                                                                 ReturnFlag(self.flagcarried);
209                                                         }
210                                                 }
211                                                 self.ammo_rockets = 999;
212                                                 self.ammo_nails = 999;
213                                                 self.ammo_cells = 999;
214                                                 self.ammo_shells = 999;
215                                                 self.health = start_health;
216                                                 self.armorvalue = start_armorvalue;
217                                                 self.items |= itemsInMap & (IT_LASER | IT_SHOTGUN | IT_UZI | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER);
218                                                 self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
219                                                 self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
220                                                 self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
221                                         }
222                                         else
223                                                 sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
224                                 }
225                                 else if(imp == 99)
226                                 {
227                                         self.items |= (IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER);
228                                         self.ammo_shells = g_pickup_shells_max;
229                                         self.ammo_nails = g_pickup_nails_max;
230                                         self.ammo_rockets = g_pickup_rockets_max;
231                                         self.ammo_cells = g_pickup_cells_max;
232                                         self.health = g_pickup_healthsmall_max;
233                                         self.armorvalue = g_pickup_armorsmall_max;
234                                         self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
235                                         self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
236                                         self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
237                                         // precache weapon models/sounds
238                                         local float wep;
239                                         wep = WEP_FIRST;
240                                         while (wep <= WEP_LAST)
241                                         {
242                                                 weapon_action(wep, WR_PRECACHE);
243                                                 wep = wep + 1;
244                                         }
245                                 }
246                                 else if (imp == 13)
247                                 {
248                                         makevectors (self.v_angle);
249                                         self.velocity = self.velocity + v_forward * 300;
250                                         CopyBody(1);
251                                         self.velocity = self.velocity - v_forward * 300;
252                                 }
253                                 else if (imp == 14)
254                                         CopyBody(0);
255                         }
256                 }
257         }
258
259         if (cvar("g_waypointeditor"))
260         {
261                 local entity e;
262                 if (imp == 103) waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
263                 else if (imp == 104) {e = navigation_findnearestwaypoint(self, FALSE);if (e) waypoint_remove(e);}
264                 else if (imp == 105) waypoint_schedulerelinkall();
265                 else if (imp == 106) waypoint_saveall();
266         }
267
268         //TetrisImpulses(imp);
269 }