]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_impulse.qc
log carried keys as K in sv_eventlog frag output; update makebuild
[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         // throw weapon
81         else if (imp == 17)
82         {
83                 if(self.deadflag == DEAD_NO)
84                 {
85                         if (self.weapon != WEP_LASER
86                                 && !cvar("g_minstagib") && !cvar("g_instagib")
87                                 && !cvar("g_rocketarena") && !cvar("g_lms") && cvar("g_pickup_items") && !cvar("g_nixnex"))
88                                 W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750), '0 0 0', TRUE);
89                 }
90         }
91         // deploy waypoints
92         else if (imp >= 30 && imp <= 49)
93         {
94                 if(imp == 30)
95                 {
96                         WaypointSprite_DeployPersonal("waypoint", self.origin);
97                         sprint(self, "personal waypoint spawned at location\n");
98                 }
99                 else if(imp == 31)
100                 {
101                         WaypointSprite_DeployPersonal("waypoint", self.cursor_trace_endpos);
102                         sprint(self, "personal waypoint spawned at crosshair\n");
103                 }
104                 else if(imp == 32 && vlen(self.death_origin))
105                 {
106                         WaypointSprite_DeployPersonal("waypoint", self.death_origin);
107                         sprint(self, "personal waypoint spawned at death location\n");
108                 }
109                 else if(imp == 33 && self.deadflag == DEAD_NO && teams_matter)
110                 {
111                         WaypointSprite_Attach("helpme", TRUE);
112                         sprint(self, "HELP ME attached\n");
113                 }
114                 else if(imp == 34)
115                 {
116                         WaypointSprite_DeployFixed("here", FALSE, self.origin);
117                         sprint(self, "HERE spawned at location\n");
118                 }
119                 else if(imp == 35)
120                 {
121                         WaypointSprite_DeployFixed("here", FALSE, self.cursor_trace_endpos);
122                         sprint(self, "HERE spawned at crosshair\n");
123                 }
124                 else if(imp == 36 && vlen(self.death_origin))
125                 {
126                         WaypointSprite_DeployFixed("here", FALSE, self.death_origin);
127                         sprint(self, "HERE spawned at death location\n");
128                 }
129                 else if(imp == 37)
130                 {
131                         WaypointSprite_DeployFixed("danger", FALSE, self.origin);
132                         sprint(self, "DANGER spawned at location\n");
133                 }
134                 else if(imp == 38)
135                 {
136                         WaypointSprite_DeployFixed("danger", FALSE, self.cursor_trace_endpos);
137                         sprint(self, "DANGER spawned at crosshair\n");
138                 }
139                 else if(imp == 39 && vlen(self.death_origin))
140                 {
141                         WaypointSprite_DeployFixed("danger", FALSE, self.death_origin);
142                         sprint(self, "DANGER spawned at death location\n");
143                 }
144                 else if(imp == 47)
145                 {
146                         WaypointSprite_ClearPersonal();
147                         sprint(self, "personal waypoint cleared\n");
148                 }
149                 else if(imp == 48)
150                 {
151                         WaypointSprite_ClearOwned();
152                         sprint(self, "all waypoints cleared\n");
153                 }
154                 else if(imp == 49)
155                 {
156                         self.cvar_cl_hidewaypoints = !(self.cvar_cl_hidewaypoints);
157                         sprint(self, "fixed waypoints now ");
158                         if(self.cvar_cl_hidewaypoints)
159                                 sprint(self, "OFF\n");
160                         else
161                                 sprint(self, "ON\n");
162                 }
163         }
164         else
165         {
166                 if (sv_cheats)
167                 {
168                         if(imp == 19)
169                         {
170                                 makevectors(self.v_angle);
171                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, FALSE, self);
172                                 if (trace_fraction < 1)
173                                         printsurfaceinfo(trace_ent, trace_endpos);
174                         }
175                         else if(imp == 20)
176                         {
177                                 makevectors(self.v_angle);
178                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 65536, FALSE, self);
179                                 sprint(self, strcat("distance: ", ftos(fabs(vlen(trace_endpos - (self.origin + self.view_ofs)))), "\n"));
180                         }
181                         else if(self.deadflag == DEAD_NO)
182                         {
183                                 if(imp == 99)
184                                 {
185                                         self.items |= (IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER);
186                                         self.ammo_shells = cvar("g_pickup_shells_max");
187                                         self.ammo_nails = cvar("g_pickup_nails_max");
188                                         self.ammo_rockets = cvar("g_pickup_rockets_max");
189                                         self.ammo_cells = cvar("g_pickup_cells_max");
190                                         self.health = cvar("g_pickup_healthshard_max");
191                                         self.armorvalue = cvar("g_pickup_armorshard_max");
192                                         self.pauserotarmor_finished = time + cvar("g_balance_pause_armor_rot_spawn");
193                                         self.pauserothealth_finished = time + cvar("g_balance_pause_health_rot_spawn");
194                                         self.pauseregen_finished = time + cvar("g_balance_pause_health_regen_spawn");
195                                         // precache weapon models/sounds
196                                         local float wep;
197                                         wep = WEP_FIRST;
198                                         while (wep <= WEP_LAST)
199                                         {
200                                                 weapon_action(wep, WR_PRECACHE);
201                                                 wep = wep + 1;
202                                         }
203                                 }
204                                 else if (imp == 13)
205                                 {
206                                         makevectors (self.v_angle);
207                                         self.velocity = self.velocity + v_forward * 300;
208                                         CopyBody(1);
209                                         self.velocity = self.velocity - v_forward * 300;
210                                 }
211                                 else if (imp == 14)
212                                         CopyBody(0);
213                         }
214                 }
215         }
216
217         if (cvar("g_waypointeditor"))
218         {
219                 local entity e;
220                 if (imp == 103) waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
221                 else if (imp == 104) {e = navigation_findnearestwaypoint(self, FALSE);if (e) waypoint_remove(e);}
222                 else if (imp == 105) waypoint_schedulerelinkall();
223                 else if (imp == 106) waypoint_saveall();
224         }
225
226         //TetrisImpulses();
227 }