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