Merge branch 'master' into Mario/vehicles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / unit / bumblebee.qc
1 #ifdef REGISTER_VEHICLE
2 REGISTER_VEHICLE(
3 /* VEH_##id   */ BUMBLEBEE,
4 /* function   */ v_bumblebee,
5 /* spawnflags */ VHF_DMGSHAKE,
6 /* mins,maxs  */ '-245 -130 -130', '230 130 130',
7 /* model          */ "models/vehicles/bumblebee_body.dpm",
8 /* head_model */ "",
9 /* hud_model  */ "models/vehicles/spiderbot_cockpit.dpm",
10 /* tags           */ "", "", "tag_viewport",
11 /* netname        */ "bumblebee",
12 /* fullname   */ _("Bumblebee")
13 );
14 #else
15
16 const float BRG_SETUP = 2;
17 const float BRG_START = 4;
18 const float BRG_END = 8;
19
20 #ifdef SVQC
21 float autocvar_g_vehicle_bumblebee_speed_forward;
22 float autocvar_g_vehicle_bumblebee_speed_strafe;
23 float autocvar_g_vehicle_bumblebee_speed_up;
24 float autocvar_g_vehicle_bumblebee_speed_down;
25 float autocvar_g_vehicle_bumblebee_turnspeed;
26 float autocvar_g_vehicle_bumblebee_pitchspeed;
27 float autocvar_g_vehicle_bumblebee_pitchlimit;
28 float autocvar_g_vehicle_bumblebee_friction;
29
30 float autocvar_g_vehicle_bumblebee_energy;
31 float autocvar_g_vehicle_bumblebee_energy_regen;
32 float autocvar_g_vehicle_bumblebee_energy_regen_pause;
33
34 float autocvar_g_vehicle_bumblebee_health;
35 float autocvar_g_vehicle_bumblebee_health_regen;
36 float autocvar_g_vehicle_bumblebee_health_regen_pause;
37
38 float autocvar_g_vehicle_bumblebee_shield;
39 float autocvar_g_vehicle_bumblebee_shield_regen;
40 float autocvar_g_vehicle_bumblebee_shield_regen_pause;
41
42 float autocvar_g_vehicle_bumblebee_cannon_cost;
43 float autocvar_g_vehicle_bumblebee_cannon_damage;
44 float autocvar_g_vehicle_bumblebee_cannon_radius;
45 float autocvar_g_vehicle_bumblebee_cannon_refire;
46 float autocvar_g_vehicle_bumblebee_cannon_speed;
47 float autocvar_g_vehicle_bumblebee_cannon_spread;
48 float autocvar_g_vehicle_bumblebee_cannon_force;
49
50 float autocvar_g_vehicle_bumblebee_cannon_ammo;
51 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
52 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
53
54 float autocvar_g_vehicle_bumblebee_cannon_lock = 0;
55
56 float autocvar_g_vehicle_bumblebee_cannon_turnspeed;
57 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down;
58 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up;
59 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
60 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
61
62
63 float autocvar_g_vehicle_bumblebee_raygun_turnspeed;
64 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down;
65 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up;
66 float autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides;
67
68 float autocvar_g_vehicle_bumblebee_raygun_range;
69 float autocvar_g_vehicle_bumblebee_raygun_dps;
70 float autocvar_g_vehicle_bumblebee_raygun_aps;
71 float autocvar_g_vehicle_bumblebee_raygun_fps;
72
73 float autocvar_g_vehicle_bumblebee_raygun;
74 float autocvar_g_vehicle_bumblebee_healgun_hps;
75 float autocvar_g_vehicle_bumblebee_healgun_hmax;
76 float autocvar_g_vehicle_bumblebee_healgun_aps;
77 float autocvar_g_vehicle_bumblebee_healgun_amax;
78 float autocvar_g_vehicle_bumblebee_healgun_sps;
79 float autocvar_g_vehicle_bumblebee_healgun_locktime;
80
81 float autocvar_g_vehicle_bumblebee_respawntime;
82
83 float autocvar_g_vehicle_bumblebee_blowup_radius;
84 float autocvar_g_vehicle_bumblebee_blowup_coredamage;
85 float autocvar_g_vehicle_bumblebee_blowup_edgedamage;
86 float autocvar_g_vehicle_bumblebee_blowup_forceintensity;
87 vector autocvar_g_vehicle_bumblebee_bouncepain;
88
89 bool autocvar_g_vehicle_bumblebee = 0;
90
91 float bumble_raygun_send(entity to, int sf);
92
93 void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
94 {
95         vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
96         vehicles_projectile("bigplasma_muzzleflash", "weapons/flacexp3.wav",
97                                                 v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
98                                                 autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force,  0,
99                                                 DEATH_VH_BUMB_GUN, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
100 }
101
102 float bumblebee_gunner_frame()
103 {
104         entity vehic    = self.vehicle.owner;
105         entity gun      = self.vehicle;
106         entity gunner   = self;
107         self = vehic;
108
109         vehic.solid = SOLID_NOT;
110         //setorigin(gunner, vehic.origin);
111         gunner.velocity = vehic.velocity;
112
113         float _in, _out;
114         vehic.angles_x *= -1;
115         makevectors(vehic.angles);
116         vehic.angles_x *= -1;
117         if(gun == vehic.gun1)
118         {
119                 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
120                 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
121                 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
122         }
123         else
124         {
125                 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
126                 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
127                 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
128         }
129
130         crosshair_trace(gunner);
131         vector _ct = trace_endpos;
132         vector ad;
133
134         if(autocvar_g_vehicle_bumblebee_cannon_lock)
135         {
136                 if(gun.lock_time < time)
137                         gun.enemy = world;
138
139                 if(trace_ent)
140                         if(trace_ent.movetype)
141                                 if(trace_ent.takedamage)
142                                         if(!trace_ent.deadflag)
143                                         {
144                                                 if(DIFF_TEAM(trace_ent, gunner))
145                                                 {
146                                                         gun.enemy = trace_ent;
147                                                         gun.lock_time = time + 5;
148                                                 }
149                                         }
150         }
151
152         if(gun.enemy)
153         {
154                 float distance, impact_time;
155
156                 vector vf = real_origin(gun.enemy);
157                 vector _vel = gun.enemy.velocity;
158                 if(gun.enemy.movetype == MOVETYPE_WALK)
159                         _vel.z *= 0.1;
160
161
162                 ad = vf;
163                 distance = vlen(ad - gunner.origin);
164                 impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
165                 ad = vf + _vel * impact_time;
166                 trace_endpos = ad;
167
168
169                 UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
170                 vehicle_aimturret(vehic, trace_endpos, gun, "fire",
171                                                   autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
172                                                   _out * -1,  _in,  autocvar_g_vehicle_bumblebee_cannon_turnspeed);
173
174         }
175         else
176                 vehicle_aimturret(vehic, _ct, gun, "fire",
177                                                   autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
178                                                   _out * -1,  _in,  autocvar_g_vehicle_bumblebee_cannon_turnspeed);
179
180         if(!forbidWeaponUse(gunner))
181         if(gunner.BUTTON_ATCK)
182                 if(time > gun.attack_finished_single)
183                         if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
184                         {
185                                 gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
186                                 bumblebee_fire_cannon(gun, "fire", gunner);
187                                 gun.delay = time;
188                                 gun.attack_finished_single = time + autocvar_g_vehicle_bumblebee_cannon_refire;
189                         }
190
191         VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
192
193         if(vehic.vehicle_flags & VHF_HASSHIELD)
194                 VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
195
196         ad = gettaginfo(gun, gettagindex(gun, "fire"));
197         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
198
199         UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
200
201         if(vehic.owner)
202                 UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
203
204         vehic.solid = SOLID_BBOX;
205         gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
206         gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
207
208         self = gunner;
209         return 1;
210 }
211
212 vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity player)
213 {
214         //vector exitspot;
215         float mysize;
216
217         tracebox(gunner.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, player);
218         if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
219                 return prefer_spot;
220
221         mysize = 1.5 * vlen(PL_MAX - PL_MIN); // can't use gunner's size, as they don't have a size
222         float i;
223         vector v, v2;
224         v2 = 0.5 * (gunner.absmin + gunner.absmax);
225         for(i = 0; i < 100; ++i)
226         {
227                 v = randomvec();
228                 v_z = 0;
229                 v = v2 + normalize(v) * mysize;
230                 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, player);
231                 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
232                         return v;
233         }
234
235         return prefer_spot; // this should be considered a fallback?!
236 }
237
238 void bumblebee_gunner_exit(int _exitflag)
239 {
240         entity player = self;
241         entity gunner = player.vehicle;
242         entity vehic = gunner.owner;
243
244         if(IS_REAL_CLIENT(player))
245         {
246                 msg_entity = player;
247                 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
248                 WriteEntity(MSG_ONE, player);
249
250                 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
251                 WriteAngle(MSG_ONE, 0);
252                 WriteAngle(MSG_ONE, vehic.angles.y);
253                 WriteAngle(MSG_ONE, 0);
254         }
255
256         CSQCVehicleSetup(player, HUD_NORMAL);
257         setsize(player, PL_MIN, PL_MAX);
258
259         player.takedamage     = DAMAGE_AIM;
260         player.solid          = SOLID_SLIDEBOX;
261         player.movetype       = MOVETYPE_WALK;
262         player.effects       &= ~EF_NODRAW;
263         player.alpha          = 1;
264         player.PlayerPhysplug = func_null;
265         player.view_ofs       = PL_VIEW_OFS;
266         player.event_damage   = PlayerDamage;
267         player.hud            = HUD_NORMAL;
268         player.teleportable       = TELEPORT_NORMAL;
269         player.switchweapon   = gunner.switchweapon;
270         player.vehicle_enter_delay = time + 2;
271
272         fixedmakevectors(vehic.angles);
273
274         if(player == vehic.gunner1) { vehic.gunner1 = world; }
275         if(player == vehic.gunner2) { vehic.gunner2 = world; v_right *= -1; }
276
277         vector spot = real_origin(gunner);
278         spot = spot + v_up * 128 + v_forward * 300 + v_right * 150;
279         spot = bumblebee_gunner_findgoodexit(spot, gunner, player);
280
281         // TODO: figure a way to move player out of the gunner
282
283         player.velocity = 0.75 * vehic.velocity + normalize(spot - vehic.origin) * 200;
284         player.velocity_z += 10;
285
286         gunner.phase = time + 5;
287         gunner.vehicle_hudmodel.viewmodelforclient = gunner;
288
289         MUTATOR_CALLHOOK(VehicleExit, player, gunner);
290
291         player.vehicle = world;
292 }
293
294 bool bumblebee_gunner_enter()
295 {
296         entity vehic = self;
297         entity player = other;
298         entity gunner = world;
299
300         if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
301         {
302                 // we can have some fun
303                 if(vlen(real_origin(vehic.gun2) - player.origin) < vlen(real_origin(vehic.gun1) - player.origin))
304                 {
305                         gunner = vehic.gun2;
306                         vehic.gunner2 = player;
307                 }
308                 else
309                 {
310                         gunner = vehic.gun1;
311                         vehic.gunner1 = player;
312                 }
313         }
314         else if(!vehic.gunner1 && time >= vehic.gun1.phase)     { gunner = vehic.gun1; vehic.gunner1 = player; }
315         else if(!vehic.gunner2 && time >= vehic.gun2.phase)             { gunner = vehic.gun2; vehic.gunner2 = player; }
316         else { dprint("Vehicle is full, fail\n"); return false; }
317
318         player.vehicle                  = gunner;
319         player.angles                   = vehic.angles;
320         player.takedamage               = DAMAGE_NO;
321         player.solid                    = SOLID_NOT;
322         player.alpha                    = -1;
323         player.movetype                 = MOVETYPE_NOCLIP;
324         player.event_damage     = func_null;
325         player.view_ofs                 = '0 0 0';
326         player.hud                              = gunner.hud;
327         player.teleportable     = false;
328         player.PlayerPhysplug   = gunner.PlayerPhysplug;
329         player.vehicle_ammo1    = vehic.vehicle_ammo1;
330         player.vehicle_ammo2    = vehic.vehicle_ammo2;
331         player.vehicle_reload1  = vehic.vehicle_reload1;
332         player.vehicle_reload2  = vehic.vehicle_reload2;
333         player.vehicle_energy   = vehic.vehicle_energy;
334         player.flags               &= ~FL_ONGROUND;
335
336         RemoveGrapplingHook(player);
337
338         gunner.switchweapon = player.switchweapon;
339         gunner.vehicle_exit = bumblebee_gunner_exit;
340         gunner.vehicle_hudmodel.viewmodelforclient = player;
341
342         if(IS_REAL_CLIENT(player))
343         {
344                 msg_entity = player;
345                 WriteByte(MSG_ONE,              SVC_SETVIEWPORT);
346                 WriteEntity(MSG_ONE,    gunner.vehicle_viewport);
347
348                 WriteByte(MSG_ONE,              SVC_SETVIEWANGLES);
349                 WriteAngle(MSG_ONE,     gunner.angles_x + vehic.angles_x); // tilt
350                 WriteAngle(MSG_ONE,     gunner.angles_y + vehic.angles_y); // yaw
351                 WriteAngle(MSG_ONE,     0); // roll
352         }
353
354         CSQCVehicleSetup(player, player.hud);
355
356         MUTATOR_CALLHOOK(VehicleEnter, player, gunner);
357
358         return true;
359 }
360
361 bool vehicles_valid_pilot()
362 {
363         if(IS_BOT_CLIENT(other) && !autocvar_g_vehicles_allow_bots)
364                 return false;
365
366         if((!IS_PLAYER(other))
367         || (other.deadflag != DEAD_NO)
368         || (other.vehicle)
369         || (DIFF_TEAM(other, self))
370         ) { return false; }
371
372         return true;
373 }
374
375 void bumblebee_touch()
376 {
377         if(autocvar_g_vehicles_enter) { return; }
378
379         if(self.gunner1 != world && self.gunner2 != world)
380         {
381                 vehicles_touch();
382                 return;
383         }
384
385         if(vehicles_valid_pilot())
386         {
387                 float phase_time = (time >= self.gun1.phase) + (time >= self.gun2.phase);
388
389                 if(time >= other.vehicle_enter_delay && phase_time)
390                 if(bumblebee_gunner_enter())
391                         return;
392         }
393
394         vehicles_touch();
395 }
396
397 void bumblebee_regen()
398 {
399         if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
400                 self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
401                                                                            self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
402
403         if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
404                 self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
405                                                                            self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
406
407         if(self.vehicle_flags  & VHF_SHIELDREGEN)
408                 vehicles_regen(self.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, frametime, true);
409
410         if(self.vehicle_flags  & VHF_HEALTHREGEN)
411                 vehicles_regen(self.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, frametime, false);
412
413         if(self.vehicle_flags  & VHF_ENERGYREGEN)
414                 vehicles_regen(self.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, frametime, false);
415
416 }
417
418 float bumblebee_pilot_frame()
419 {
420         entity pilot, vehic;
421         vector newvel;
422         
423         if(intermission_running)
424         {
425                 self.vehicle.velocity = '0 0 0';
426                 self.vehicle.avelocity = '0 0 0';
427                 return 1;
428         }
429
430         pilot = self;
431         vehic = self.vehicle;
432         self   = vehic;
433
434         if(vehic.deadflag != DEAD_NO)
435         {
436                 self = pilot;
437                 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
438                 return 1;
439         }
440
441         bumblebee_regen();
442
443         crosshair_trace(pilot);
444
445         vector vang;
446         float ftmp;
447
448         vang = vehic.angles;
449         newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
450         vang.x *= -1;
451         newvel.x *= -1;
452         if(newvel.x > 180)  newvel.x -= 360;
453         if(newvel.x < -180) newvel.x += 360;
454         if(newvel.y > 180)  newvel.y -= 360;
455         if(newvel.y < -180) newvel.y += 360;
456
457         ftmp = shortangle_f(pilot.v_angle.y - vang.y, vang.y);
458         if(ftmp > 180)  ftmp -= 360;
459         if(ftmp < -180) ftmp += 360;
460         vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
461
462         // Pitch
463         ftmp = 0;
464         if(pilot.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
465                 ftmp = 4;
466         else if(pilot.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
467                 ftmp = -8;
468
469         newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit);
470         ftmp = vang.x - bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x + ftmp, autocvar_g_vehicle_bumblebee_pitchlimit);
471         vehic.avelocity_x = bound(-autocvar_g_vehicle_bumblebee_pitchspeed, ftmp + vehic.avelocity.x * 0.9, autocvar_g_vehicle_bumblebee_pitchspeed);
472
473         vehic.angles_x = anglemods(vehic.angles.x);
474         vehic.angles_y = anglemods(vehic.angles.y);
475         vehic.angles_z = anglemods(vehic.angles.z);
476
477         makevectors('0 1 0' * vehic.angles.y);
478         newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
479
480         if(pilot.movement.x != 0)
481         {
482                 if(pilot.movement.x > 0)
483                         newvel += v_forward  * autocvar_g_vehicle_bumblebee_speed_forward;
484                 else if(pilot.movement.x < 0)
485                         newvel -= v_forward  * autocvar_g_vehicle_bumblebee_speed_forward;
486         }
487
488         if(pilot.movement.y != 0)
489         {
490                 if(pilot.movement.y < 0)
491                         newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
492                 else if(pilot.movement.y > 0)
493                         newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
494                 ftmp = newvel * v_right;
495                 ftmp *= frametime * 0.1;
496                 vehic.angles_z = bound(-15, vehic.angles.z + ftmp, 15);
497         }
498         else
499         {
500                 vehic.angles_z *= 0.95;
501                 if(vehic.angles.z >= -1 && vehic.angles.z <= -1)
502                         vehic.angles_z = 0;
503         }
504
505         if(pilot.BUTTON_CROUCH)
506                 newvel -=   v_up * autocvar_g_vehicle_bumblebee_speed_down;
507         else if(pilot.BUTTON_JUMP)
508                 newvel +=  v_up * autocvar_g_vehicle_bumblebee_speed_up;
509
510         vehic.velocity  += newvel * frametime;
511         pilot.velocity = pilot.movement  = vehic.velocity;
512
513
514         if(autocvar_g_vehicle_bumblebee_healgun_locktime)
515         {
516                 if(vehic.tur_head.lock_time < time || vehic.tur_head.enemy.deadflag)
517                         vehic.tur_head.enemy = world;
518
519                 if(trace_ent)
520                 if(trace_ent.movetype)
521                 if(trace_ent.takedamage)
522                 if(!trace_ent.deadflag)
523                 {
524                         if(teamplay)
525                         {
526                                 if(trace_ent.team == pilot.team)
527                                 {
528                                         vehic.tur_head.enemy = trace_ent;
529                                         vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
530                                 }
531                         }
532                         else
533                         {
534                                 vehic.tur_head.enemy = trace_ent;
535                                 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
536                         }
537                 }
538
539                 if(vehic.tur_head.enemy)
540                 {
541                         trace_endpos = real_origin(vehic.tur_head.enemy);
542                         UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
543                 }
544         }
545
546         vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
547                                           autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1,  autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
548                                           autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1,  autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides,  autocvar_g_vehicle_bumblebee_raygun_turnspeed);
549
550         if(!forbidWeaponUse(pilot))
551         if((pilot.BUTTON_ATCK || pilot.BUTTON_ATCK2) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
552         {
553                 vehic.gun3.enemy.realowner = pilot;
554                 vehic.gun3.enemy.effects &= ~EF_NODRAW;
555
556                 vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
557                 vehic.gun3.enemy.SendFlags |= BRG_START;
558
559                 traceline(vehic.gun3.enemy.hook_start, vehic.gun3.enemy.hook_start + v_forward * autocvar_g_vehicle_bumblebee_raygun_range, MOVE_NORMAL, vehic);
560
561                 if(trace_ent)
562                 {
563                         if(autocvar_g_vehicle_bumblebee_raygun)
564                         {
565                                 Damage(trace_ent, vehic, pilot, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
566                                 vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
567                         }
568                         else
569                         {
570                                 if(trace_ent.deadflag == DEAD_NO)
571                                         if((teamplay && trace_ent.team == pilot.team) || !teamplay)
572                                         {
573
574                                                 if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
575                                                 {
576                                                         if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
577                                                                 trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
578
579                                                         if(autocvar_g_vehicle_bumblebee_healgun_hps)
580                                                                 trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
581                                                 }
582                                                 else if(IS_CLIENT(trace_ent))
583                                                 {
584                                                         if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
585                                                                 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
586
587                                                         if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
588                                                                 trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
589
590                                                         trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
591                                                 }
592                                                 else if(IS_TURRET(trace_ent))
593                                                 {
594                                                         if(trace_ent.health  <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps)
595                                                                 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
596                                                         //else ..hmmm what? ammo?
597
598                                                         trace_ent.SendFlags |= TNSF_STATUS;
599                                                 }
600                                         }
601                         }
602                 }
603
604                 vehic.gun3.enemy.hook_end = trace_endpos;
605                 setorigin(vehic.gun3.enemy, trace_endpos);
606                 vehic.gun3.enemy.SendFlags |= BRG_END;
607
608                 vehic.wait = time + 1;
609         }
610         else
611                 vehic.gun3.enemy.effects |= EF_NODRAW;
612         /*{
613                 if(vehic.gun3.enemy)
614                         remove(vehic.gun3.enemy);
615
616                 vehic.gun3.enemy = world;
617         }
618         */
619
620         VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
621         VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
622
623         pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
624         pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
625
626         if(vehic.vehicle_flags & VHF_HASSHIELD)
627                 VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
628
629         vehic.angles_x *= -1;
630         makevectors(vehic.angles);
631         vehic.angles_x *= -1;
632         setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
633
634         pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
635         self = pilot;
636
637         return 1;
638 }
639
640 void bumblebee_land()
641 {
642         float hgt;
643
644         hgt = raptor_altitude(512);
645         self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
646         self.angles_x *= 0.95;
647         self.angles_z *= 0.95;
648
649         if(hgt < 16)
650                 self.think      = vehicles_think;
651
652         self.nextthink = time;
653         
654         CSQCMODEL_AUTOUPDATE();
655 }
656
657 void bumblebee_exit(float eject)
658 {
659         if(self.owner.vehicleid == VEH_BUMBLEBEE)
660         {
661                 bumblebee_gunner_exit(eject);
662                 return;
663         }
664
665         self.touch = vehicles_touch;
666
667         if(self.deadflag == DEAD_NO)
668         {
669                 self.think = bumblebee_land;
670                 self.nextthink  = time;
671         }
672         
673         self.movetype = MOVETYPE_TOSS;
674
675         if(!self.owner)
676                 return;
677
678         fixedmakevectors(self.angles);
679         vector spot;
680         if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)
681                 spot = self.origin + v_up * 128 + v_forward * 300;
682         else
683                 spot = self.origin + v_up * 128 - v_forward * 300;
684
685         spot = vehicles_findgoodexit(spot);
686
687         // Hide beam
688         if(self.gun3.enemy || !wasfreed(self.gun3.enemy)) {
689                 self.gun3.enemy.effects |= EF_NODRAW;
690         }
691
692         self.owner.velocity = 0.75 * self.vehicle.velocity + normalize(spot - self.vehicle.origin) * 200;
693         self.owner.velocity_z += 10;
694         setorigin(self.owner, spot);
695
696         antilag_clear(self.owner);
697         self.owner = world;
698 }
699
700 void bumblebee_blowup()
701 {
702         RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
703                                  autocvar_g_vehicle_bumblebee_blowup_edgedamage,
704                                  autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
705                                  autocvar_g_vehicle_bumblebee_blowup_forceintensity,
706                                  DEATH_VH_BUMB_DEATH, world);
707
708         sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
709         Send_Effect("explosion_big", (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
710
711         if(self.owner.deadflag == DEAD_DYING)
712                 self.owner.deadflag = DEAD_DEAD;
713
714         remove(self);
715 }
716
717 void bumblebee_diethink()
718 {
719         if(time >= self.wait)
720                 self.think = bumblebee_blowup;
721
722         if(random() < 0.1)
723         {
724                 sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
725                 Send_Effect("explosion_small", randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
726         }
727
728         self.nextthink = time + 0.1;
729 }
730
731 float bumble_raygun_send(entity to, float sf)
732 {
733         WriteByte(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
734
735         WriteByte(MSG_ENTITY, sf);
736         if(sf & BRG_SETUP)
737         {
738                 WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
739                 WriteByte(MSG_ENTITY, self.realowner.team);
740                 WriteByte(MSG_ENTITY, self.cnt);
741         }
742
743         if(sf & BRG_START)
744         {
745                 WriteCoord(MSG_ENTITY, self.hook_start_x);
746                 WriteCoord(MSG_ENTITY, self.hook_start_y);
747                 WriteCoord(MSG_ENTITY, self.hook_start_z);
748         }
749
750         if(sf & BRG_END)
751         {
752                 WriteCoord(MSG_ENTITY, self.hook_end_x);
753                 WriteCoord(MSG_ENTITY, self.hook_end_y);
754                 WriteCoord(MSG_ENTITY, self.hook_end_z);
755         }
756
757         return true;
758 }
759
760 void spawnfunc_vehicle_bumblebee()
761 {
762         if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
763         if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
764 }
765
766 float v_bumblebee(float req)
767 {
768         switch(req)
769         {
770                 case VR_IMPACT:
771                 {
772                         if(autocvar_g_vehicle_bumblebee_bouncepain)
773                                 vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
774                                 
775                         return true;
776                 }
777                 case VR_ENTER:
778                 {
779                         self.touch = bumblebee_touch;
780                         self.nextthink = 0;
781                         self.movetype = MOVETYPE_BOUNCEMISSILE;
782                         return true;
783                 }
784                 case VR_THINK:
785                 {
786                         self.angles_z *= 0.8;
787                         self.angles_x *= 0.8;
788                         
789                         self.nextthink = time;
790                         
791                         if(!self.owner)
792                         {
793                                 entity oldself = self;          
794                                 if(self.gunner1)
795                                 {
796                                         self = self.gunner1;
797                                         oldself.gun1.vehicle_exit(VHEF_EJECT);
798                                         entity oldother = other;
799                                         other = self;
800                                         self = oldself;
801                                         self.phase = 0;
802                                         self.touch();
803                                         other = oldother;
804                                         return true;
805                                 }
806                                 
807                                 if(self.gunner2)
808                                 {
809                                         self = self.gunner2;
810                                         oldself.gun2.vehicle_exit(VHEF_EJECT);
811                                         entity oldother = other;
812                                         other = self;
813                                         self = oldself;
814                                         self.phase = 0;
815                                         self.touch();
816                                         other = oldother;
817                                         return true;
818                                 }               
819                         }
820                         
821                         return true;
822                 }
823                 case VR_DEATH:
824                 {
825                         entity oldself = self;
826
827                         CSQCModel_UnlinkEntity();
828
829                         // Hide beam
830                         if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
831                                 self.gun3.enemy.effects |= EF_NODRAW;
832                         
833                         if(self.gunner1)
834                         {
835                                 self = self.gunner1;
836                                 oldself.gun1.vehicle_exit(VHEF_EJECT);
837                                 self = oldself;
838                         }
839
840                         if(self.gunner2)
841                         {
842                                 self = self.gunner2;
843                                 oldself.gun2.vehicle_exit(VHEF_EJECT);
844                                 self = oldself;
845                         }
846
847                         self.vehicle_exit(VHEF_EJECT);
848
849                         fixedmakevectors(self.angles);
850                         vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
851                         vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
852                         vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
853
854                         entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
855
856                         if(random() > 0.5)
857                                 _body.touch = bumblebee_blowup;
858                         else
859                                 _body.touch = func_null;
860                                 
861                         _body.think = bumblebee_diethink;
862                         _body.nextthink = time;
863                         _body.wait = time + 2 + (random() * 8);
864                         _body.owner = self;
865                         _body.enemy = self.enemy;
866                         _body.scale = 1.5;
867                         _body.angles = self.angles;
868
869                         Send_Effect("explosion_medium", findbetterlocation(self.origin, 16), '0 0 0', 1);
870                         
871                         self.health                     = 0;
872                         self.event_damage       = func_null;
873                         self.solid                      = SOLID_NOT;
874                         self.takedamage         = DAMAGE_NO;
875                         self.deadflag           = DEAD_DYING;
876                         self.movetype           = MOVETYPE_NONE;
877                         self.effects            = EF_NODRAW;
878                         self.colormod           = '0 0 0';
879                         self.avelocity          = '0 0 0';
880                         self.velocity           = '0 0 0';
881                         self.touch                      = func_null;
882                         self.nextthink          = 0;
883
884                         setorigin(self, self.pos1);
885                         return true;
886                 }
887                 case VR_SPAWN:
888                 {
889                         if(!self.gun1)
890                         {
891                                 // for some reason, autosizing of the shield entity refuses to work for this one so set it up in advance.
892                                 self.vehicle_shieldent = spawn();
893                                 self.vehicle_shieldent.effects = EF_LOWPRECISION;
894                                 setmodel(self.vehicle_shieldent, "models/vhshield.md3");
895                                 setattachment(self.vehicle_shieldent, self, "");
896                                 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
897                                 self.vehicle_shieldent.scale       = 512 / vlen(self.maxs - self.mins);
898                                 self.vehicle_shieldent.think       = shieldhit_think;
899                                 self.vehicle_shieldent.alpha = -1;
900                                 self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
901
902                                 self.gun1 = spawn();
903                                 self.gun2 = spawn();
904                                 self.gun3 = spawn();
905
906                                 self.vehicle_flags |= VHF_MULTISLOT;
907
908                                 self.gun1.owner = self;
909                                 self.gun2.owner = self;
910                                 self.gun3.owner = self;
911
912                                 self.gun1.classname = self.gun2.classname = "vehicle_playerslot";
913
914                                 setmodel(self.gun1, "models/vehicles/bumblebee_plasma_right.dpm");
915                                 setmodel(self.gun2, "models/vehicles/bumblebee_plasma_left.dpm");
916                                 setmodel(self.gun3, "models/vehicles/bumblebee_ray.dpm");
917
918                                 setattachment(self.gun1, self, "cannon_right");
919                                 setattachment(self.gun2, self, "cannon_left");
920
921                                 // Angled bones are no fun, messes up gun-aim; so work arround it.
922                                 self.gun3.pos1 = self.angles;
923                                 self.angles = '0 0 0';
924                                 vector ofs = gettaginfo(self, gettagindex(self, "raygun"));
925                                 ofs -= self.origin;
926                                 setattachment(self.gun3, self, "");
927                                 setorigin(self.gun3, ofs);
928                                 self.angles = self.gun3.pos1;
929
930                                 vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
931                                 vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
932
933                                 setorigin(self.vehicle_hudmodel, '50 0 -5');    // Move cockpit forward - down.
934                                 setorigin(self.vehicle_viewport, '5 0 2');    // Move camera forward up
935
936                                 //fixme-model-bones
937                                 setorigin(self.gun1.vehicle_hudmodel, '90 -27 -23');
938                                 setorigin(self.gun1.vehicle_viewport, '-85 0 50');
939                                 //fixme-model-bones
940                                 setorigin(self.gun2.vehicle_hudmodel, '90 27 -23');
941                                 setorigin(self.gun2.vehicle_viewport, '-85 0 50');
942
943                                 self.scale = 1.5;
944                                 
945                                 // Raygun beam
946                                 if(self.gun3.enemy == world)
947                                 {                       
948                                         self.gun3.enemy = spawn();
949                                         Net_LinkEntity(self.gun3.enemy, true, 0, bumble_raygun_send);
950                                         self.gun3.enemy.SendFlags = BRG_SETUP;                  
951                                         self.gun3.enemy.cnt = autocvar_g_vehicle_bumblebee_raygun;                      
952                                         self.gun3.enemy.effects = EF_NODRAW | EF_LOWPRECISION;
953                                 }
954                         }
955
956                         self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
957                         self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
958                         self.solid = SOLID_BBOX;
959                         self.movetype = MOVETYPE_TOSS;
960                         self.damageforcescale = 0.025;
961                         
962                         self.PlayerPhysplug = bumblebee_pilot_frame;
963                         
964                         setorigin(self, self.origin + '0 0 25');
965                         return true;
966                 }
967                 case VR_SETUP:
968                 {
969                         if(autocvar_g_vehicle_bumblebee_energy)
970                         if(autocvar_g_vehicle_bumblebee_energy_regen)
971                                 self.vehicle_flags |= VHF_ENERGYREGEN;
972
973                         if(autocvar_g_vehicle_bumblebee_shield)
974                                 self.vehicle_flags |= VHF_HASSHIELD;
975
976                         if(autocvar_g_vehicle_bumblebee_shield_regen)
977                                 self.vehicle_flags |= VHF_SHIELDREGEN;
978
979                         if(autocvar_g_vehicle_bumblebee_health_regen)
980                                 self.vehicle_flags |= VHF_HEALTHREGEN;
981                                 
982                         self.vehicle_exit = bumblebee_exit;
983                         self.respawntime = autocvar_g_vehicle_bumblebee_respawntime;
984                         self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
985                         self.max_health = self.vehicle_health;
986                         self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
987                                 
988                         return true;
989                 }
990                 case VR_PRECACHE:
991                 {
992                         precache_model("models/vehicles/bumblebee_body.dpm");
993                         precache_model("models/vehicles/bumblebee_plasma_left.dpm");
994                         precache_model("models/vehicles/bumblebee_plasma_right.dpm");
995                         precache_model("models/vehicles/bumblebee_ray.dpm");
996                         precache_model("models/vehicles/wakizashi_cockpit.dpm");
997                         precache_model("models/vehicles/spiderbot_cockpit.dpm");
998                         precache_model("models/vehicles/raptor_cockpit.dpm");
999                         return true;
1000                 }
1001         }
1002
1003         return true;
1004 }
1005
1006 #endif // SVQC
1007 #ifdef CSQC
1008
1009 void CSQC_BUMBLE_GUN_HUD()
1010 {
1011         Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null,
1012                                          "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1013                                          string_null, '0 0 0',
1014                                          string_null);
1015 }
1016
1017 void bumble_raygun_draw()
1018 {
1019         float _len;
1020         vector _dir;
1021         vector _vtmp1, _vtmp2;
1022
1023         _len = vlen(self.origin - self.move_origin);
1024         _dir = normalize(self.move_origin - self.origin);
1025
1026         if(self.total_damages < time)
1027         {
1028                 boxparticles(self.traileffect, self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
1029                 boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
1030                 self.total_damages = time + 0.1;
1031         }
1032
1033         float i, df, sz, al;
1034         for(i = -0.1; i < 0.2; i += 0.1)
1035         {
1036                 df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
1037                 sz = 5 + random() * 5;
1038                 al = 0.25 + random() * 0.5;
1039                 _vtmp1 = self.origin + _dir * _len * (0.25 + i);
1040                 _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2));       //self.raygun_l1;
1041                 Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1042
1043                 _vtmp2 = self.origin + _dir * _len * (0.5 + i);
1044                 _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5));       //self.raygun_l2;
1045                 Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1046
1047                 _vtmp1 = self.origin + _dir * _len * (0.75 + i);
1048                 _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10);     //self.raygun_l3;
1049                 Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1050
1051                 Draw_CylindricLine(_vtmp1, self.move_origin +  randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1052         }
1053 }
1054
1055 void bumble_raygun_read(bool bIsNew)
1056 {
1057         int sf = ReadByte();
1058
1059         if(sf & BRG_SETUP)
1060         {
1061                 self.cnt  = ReadByte();
1062                 self.team = ReadByte();
1063                 self.cnt  = ReadByte();
1064
1065                 if(self.cnt)
1066                         self.colormod = '1 0 0';
1067                 else
1068                         self.colormod = '0 1 0';
1069
1070                 self.traileffect = particleeffectnum("healray_muzzleflash");
1071                 self.lip = particleeffectnum("healray_impact");
1072
1073                 self.draw = bumble_raygun_draw;
1074         }
1075
1076
1077         if(sf & BRG_START)
1078         {
1079                 self.origin_x = ReadCoord();
1080                 self.origin_y = ReadCoord();
1081                 self.origin_z = ReadCoord();
1082                 setorigin(self, self.origin);
1083         }
1084
1085         if(sf & BRG_END)
1086         {
1087                 self.move_origin_x = ReadCoord();
1088                 self.move_origin_y = ReadCoord();
1089                 self.move_origin_z = ReadCoord();
1090         }
1091 }
1092
1093 float v_bumblebee(float req)
1094 {
1095         switch(req)
1096         {
1097                 case VR_HUD:
1098                 {
1099                         Vehicles_drawHUD("vehicle_bumble", "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
1100                                                          "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1101                                                          "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1102                                                          vCROSS_HEAL);
1103                         return true;
1104                 }
1105                 case VR_SETUP:
1106                 {
1107                         AuxiliaryXhair[0].axh_image = vCROSS_LOCK;  // Raygun-locked
1108                         AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
1109                         AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2
1110                         return true;
1111                 }
1112                 case VR_PRECACHE:
1113                 {
1114                         return true;
1115                 }
1116         }
1117
1118         return true;
1119 }
1120
1121 #endif // CSQC
1122 #endif // REGISTER_VEHICLE