]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/client.qc
Fixed order of weapons
[divverent/nexuiz.git] / qcsrc / client.qc
1
2 void info_player_start (void)
3 {
4 }
5
6 void info_player_deathmatch (void)
7 {
8 }
9
10 /*
11 =============
12 SelectSpawnPoint
13
14 Finds a point to respawn
15 =============
16 */
17 entity SelectSpawnPoint (void)
18 {
19         entity  spot, thing;
20         float   pcount;
21
22         spot = findchain (classname, "info_player_deathmatch");
23         
24         while (spot)
25         {
26                 pcount = 0;
27                 thing = findradius (spot.origin, 100);
28                 while (thing)
29                 {
30                         if (thing.classname == "player")
31                                 pcount = pcount + 1;
32                         thing = thing.chain;
33                 }
34                 if (!pcount)
35                         return spot;
36                         
37                 spot = spot.chain;
38         }
39         
40         if (spot == world)
41         {
42                 spot = findchain (classname, "info_player_start");
43                 if (spot == world)
44                         error ("No startpoint found\n");
45                 return spot;
46         }
47         
48         return spot;
49 }
50
51
52 /*
53 =============
54 PutClientInServer
55
56 Called when a client spawns in the server
57 =============
58 */
59 void PutClientInServer (void)
60 {
61         entity  spot;
62         
63         spot = SelectSpawnPoint ();
64         
65         self.classname = "player";
66         self.movetype = MOVETYPE_WALK;
67         self.solid = SOLID_SLIDEBOX;
68         self.flags = FL_CLIENT;
69         self.takedamage = DAMAGE_YES;
70         self.health = 125;
71         
72         self.ammo_shells = 100;//
73         self.ammo_nails = 100;//
74         self.ammo_rockets = 100;
75         self.ammo_cells = 100;//
76         
77         self.deadflag = DEAD_NO;
78         
79         self.view_ofs = PL_VIEW_OFS;
80         self.angles = spot.angles;
81         setmodel (self, "models/player/player.zym");
82         setsize (self, PL_MIN, PL_MAX);
83         setorigin (self, spot.origin);
84         
85         self.items = IT_LASER | IT_UZI | IT_SHOTGUN | IT_GRENADE_LAUNCHER | IT_ELECTRO | IT_CRYLINK | IT_NEX | IT_HAGAR | IT_ROCKET_LAUNCHER;
86         self.weapon = IT_UZI;
87         
88         self.event_hurt = PlayerHurt;
89         self.event_die = PlayerDie;
90         
91         self.statdraintime = time + 5;
92         
93         W_UpdateWeapon ();
94         W_UpdateAmmo ();
95 }
96
97 /*
98 =============
99 SetNewParms
100 =============
101 */
102 void SetNewParms (void)
103 {
104         
105 }
106
107 /*
108 =============
109 SetChangeParms
110 =============
111 */
112 void SetChangeParms (void)
113 {
114         
115 }
116
117 /*
118 =============
119 ClientKill
120
121 Called when a client types 'kill' in the console
122 =============
123 */
124 void ClientKill (void)
125 {
126         
127 }
128
129 /*
130 =============
131 ClientConnect
132
133 Called when a client connects to the server
134 =============
135 */
136 void ClientConnect (void)
137 {
138         bprint (self.netname);
139         bprint (" connected\n");
140 }
141
142 /*
143 =============
144 ClientDisconnect
145
146 Called when a client disconnects from the server
147 =============
148 */
149 void ClientDisconnect (void)
150 {
151         bprint (self.netname);
152         bprint (" disconnected\n");
153 }
154
155 /*
156 =============
157 PlayerJump
158
159 When you press the jump key
160 =============
161 */
162 void PlayerJump (void)
163 {
164         if (!(self.flags & FL_ONGROUND))
165                 return;
166         if (!(self.flags & FL_JUMPRELEASED))
167                 return;
168         
169         self.velocity_z = self.velocity_z + 270;
170         
171         self.flags = self.flags - FL_ONGROUND;
172         self.flags = self.flags - FL_JUMPRELEASED;
173 }
174
175 /*
176 =============
177 PlayerPreThink
178
179 Called every frame for each client before the physics are run
180 =============
181 */
182 .float attack_finished;
183 void PlayerPreThink (void)
184 {
185         if (self.button0 && self.attack_finished < time)
186                 W_Attack ();
187         
188         if (self.button2)
189                 PlayerJump ();
190         else
191                 self.flags = self.flags | FL_JUMPRELEASED;
192                 
193         if (self.statdraintime < time)
194         {
195                 if (self.health > 100)
196                         self.health = self.health - 1;
197                 if (self.armorvalue > 100)
198                         self.armorvalue = self.armorvalue - 1;
199                         
200                 self.statdraintime = time + 1;
201         }
202 }
203
204 /*
205 =============
206 PlayerPostThink
207
208 Called every frame for each client after the physics are run
209 =============
210 */
211 void PlayerPostThink (void)
212 {
213         ImpulseCommands ();
214 }