]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/cl_impulse.qc
and now it shows the LAST player the crosshair pointed to
[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 (imp <= 9)
67                         W_SwitchWeapon (imp);
68                 else if (imp == 10)
69                         W_NextWeapon ();
70                 else if (imp == 12)
71                         W_PreviousWeapon ();
72                 else if (imp == 11) // last weapon
73                         W_SwitchWeapon (self.cnt);
74         }
75         else if (imp >= 13 && imp <= 16)
76         {
77                 if (cvar("sv_cheats"))
78                 {
79                         if (imp == 13)
80                         {
81                                 makevectors (self.v_angle);
82                                 self.velocity = self.velocity + v_forward * 300;
83                                 CopyBody(1);
84                                 self.velocity = self.velocity - v_forward * 300;
85                         }
86                         else if (imp == 14)
87                                 CopyBody(0);
88                         else if (imp == 15)
89                         {
90                                 sprint(self, strcat("origin = ", vtos(self.origin), "\n"));
91                                 sprint(self, strcat("angles = ", vtos(self.angles), "\n"));
92                         }
93                         else if (imp == 16)
94                         {
95                                 float i;
96                                 string s;
97                                 i=1;
98                                 while(i <= 10)
99                                 {
100                                         s = ftos(i);
101                                         sprint(self, strcat(s, ": ^", s, "color\n"));
102                                         i = i + 1;
103                                 }
104                                 sprint(self, strcat("origin = ", vtos(self.origin), "\n"));
105                         }
106                 }
107         }
108         // throw weapon
109         else if (imp == 17)
110         {
111                 if (self.weapon != WEP_LASER
112                         && !cvar("g_minstagib") && !cvar("g_instagib")
113                         && !cvar("g_rocketarena") && !cvar("g_lms") && cvar("g_pickup_items") && !cvar("g_nixnex"))
114                         W_ThrowWeapon(self.velocity * 0.5 + v_forward * 750, '0 0 0', TRUE);
115         }
116         else if (imp == 18)
117         {
118                 if(self.last_trace_player)
119                 {
120                         string t;
121                         string h;
122                         t = "^3";
123                         h = "";
124                         if(teams_matter)
125                         {
126                                 t = Team_ColorCode(self.last_trace_player.team);
127                                 if(self.team == self.last_trace_player.team)
128                                         h = strcat(" (", ftos(self.last_trace_player.health), "% health)");
129                         }
130                         centermsg_set(CENTERMSG_KILL, strcat(t, self.last_trace_player.netname, h));
131                 }
132         }
133         else
134         {
135                 if (cvar("sv_cheats"))
136                 {
137                         if(imp == 19)
138                         {
139                                 makevectors(self.v_angle);
140                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, FALSE, self);
141                                 if (trace_fraction < 1)
142                                         printsurfaceinfo(trace_ent, trace_endpos);
143                         }
144                         else if(imp == 20)
145                         {
146                                 makevectors(self.v_angle);
147                                 traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 65536, FALSE, self);
148                                 sprint(self, strcat("distance: ", ftos(fabs(vlen(trace_endpos - (self.origin + self.view_ofs)))), "\n"));
149                         }
150                         else if(imp == 42)
151                         {
152                                 CampaignLevelWarp(cvar("_warplevel"));
153                         }
154                         else if (imp == 99)
155                         {
156                                 self.items = IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER;
157                                 self.ammo_shells = 999;
158                                 self.ammo_nails = 999;
159                                 self.ammo_rockets = 999;
160                                 self.ammo_cells = 999;
161                         }
162                 }
163         }
164
165         if (cvar("g_waypointeditor"))
166         {
167                 local entity e;
168                 if (imp == 103) waypoint_spawn(self.origin, self.origin, 0);
169                 else if (imp == 104) {e = navigation_findnearestwaypoint(self, FALSE);if (e) waypoint_remove(e);}
170                 else if (imp == 105) waypoint_schedulerelinkall();
171                 else if (imp == 106) waypoint_saveall();
172         }
173
174         //TetrisImpulses();
175 }