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