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