]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_impulse.qc
waypoint sprites system mainly for CTF; currently with placeholder sprite TGAs with...
[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)
143                 {
144                         if(teams_matter)
145                                 WaypointSprite_Attach("helpme", TRUE);
146                         sprint(self, "HELP ME attached\n");
147                 }
148                 else if(imp == 34)
149                 {
150                         WaypointSprite_DeployFixed("here", FALSE, self.origin);
151                         sprint(self, "HERE spawned at location\n");
152                 }
153                 else if(imp == 35)
154                 {
155                         WaypointSprite_DeployFixed("here", FALSE, self.cursor_trace_endpos);
156                         sprint(self, "HERE spawned at crosshair\n");
157                 }
158                 else if(imp == 36 && vlen(self.death_origin))
159                 {
160                         WaypointSprite_DeployFixed("here", FALSE, self.death_origin);
161                         sprint(self, "HERE spawned at death location\n");
162                 }
163                 else if(imp == 37)
164                 {
165                         WaypointSprite_DeployFixed("danger", FALSE, self.origin);
166                         sprint(self, "DANGER spawned at location\n");
167                 }
168                 else if(imp == 38)
169                 {
170                         WaypointSprite_DeployFixed("danger", FALSE, self.cursor_trace_endpos);
171                         sprint(self, "DANGER spawned at crosshair\n");
172                 }
173                 else if(imp == 39 && vlen(self.death_origin))
174                 {
175                         WaypointSprite_DeployFixed("danger", FALSE, self.death_origin);
176                         sprint(self, "DANGER spawned at death location\n");
177                 }
178                 else if(imp == 47)
179                 {
180                         WaypointSprite_ClearPersonal();
181                         sprint(self, "personal waypoint cleared\n");
182                 }
183                 else if(imp == 48)
184                 {
185                         WaypointSprite_ClearOwned();
186                         sprint(self, "all waypoints cleared\n");
187                 }
188                 else if(imp == 49)
189                 {
190                         self.cvar_cl_hidewaypoints = !(self.cvar_cl_hidewaypoints);
191                         sprint(self, "fixed waypoints now ");
192                         if(self.cvar_cl_hidewaypoints)
193                                 sprint(self, "OFF\n");
194                         else
195                                 sprint(self, "ON\n");
196                 }
197         }
198         else
199         {
200                 if (cvar("sv_cheats"))
201                 {
202                         if(imp == 19)
203                         {
204                                 makevectors(self.v_angle);
205                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, FALSE, self);
206                                 if (trace_fraction < 1)
207                                         printsurfaceinfo(trace_ent, trace_endpos);
208                         }
209                         else if(imp == 20)
210                         {
211                                 makevectors(self.v_angle);
212                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 65536, FALSE, self);
213                                 sprint(self, strcat("distance: ", ftos(fabs(vlen(trace_endpos - (self.origin + self.view_ofs)))), "\n"));
214                         }
215                         else if(imp == 6*9)
216                         {
217                                 CampaignLevelWarp(cvar("_warplevel"));
218                         }
219                         else if (imp == 99 && self.deadflag == DEAD_NO)
220                         {
221                                 self.items = IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER;
222                                 self.ammo_shells = 999;
223                                 self.ammo_nails = 999;
224                                 self.ammo_rockets = 999;
225                                 self.ammo_cells = 999;
226                         }
227                 }
228         }
229
230         if (cvar("g_waypointeditor"))
231         {
232                 local entity e;
233                 if (imp == 103) waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
234                 else if (imp == 104) {e = navigation_findnearestwaypoint(self, FALSE);if (e) waypoint_remove(e);}
235                 else if (imp == 105) waypoint_schedulerelinkall();
236                 else if (imp == 106) waypoint_saveall();
237         }
238
239         //TetrisImpulses();
240 }