]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/vehicle/bumblebee.qc
Merge branch 'master' into TimePath/csqc_viewmodels
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / bumblebee.qc
index b4fcd182df52f20a1296d13ff750aa497ae62cee..244b4e2f6126e7fbabf9ca5533b4e24405618332 100644 (file)
@@ -2,6 +2,8 @@
 #define VEHICLE_BUMBLEBEE
 #include "bumblebee.qh"
 
+#include "bumblebee_weapons.qc"
+
 CLASS(Bumblebee, Vehicle)
 /* spawnflags */ ATTRIB(Bumblebee, spawnflags, int, VHF_DMGSHAKE);
 /* mins       */ ATTRIB(Bumblebee, mins, vector, '-245 -130 -130');
@@ -12,13 +14,13 @@ CLASS(Bumblebee, Vehicle)
 /* hud_model  */ ATTRIB(Bumblebee, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
 /* tags       */ ATTRIB(Bumblebee, tag_head, string, "");
 /* tags       */ ATTRIB(Bumblebee, tag_hud, string, "");
-/* tags       */ ATTRIB(Bumblebee, tag_hview, string, "tag_viewport");
+/* tags       */ ATTRIB(Bumblebee, tag_view, string, "tag_viewport");
 /* netname    */ ATTRIB(Bumblebee, netname, string, "bumblebee");
 /* fullname   */ ATTRIB(Bumblebee, vehicle_name, string, _("Bumblebee"));
 /* icon       */ ATTRIB(Bumblebee, m_icon, string, "vehicle_bumble");
 ENDCLASS(Bumblebee)
-
 REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee));
+
 #endif
 
 #ifdef IMPLEMENTATION
@@ -27,6 +29,8 @@ const float BRG_SETUP = 2;
 const float BRG_START = 4;
 const float BRG_END = 8;
 
+#include "bumblebee_weapons.qc"
+
 #ifdef SVQC
 float autocvar_g_vehicle_bumblebee_speed_forward;
 float autocvar_g_vehicle_bumblebee_speed_strafe;
@@ -49,14 +53,6 @@ float autocvar_g_vehicle_bumblebee_shield;
 float autocvar_g_vehicle_bumblebee_shield_regen;
 float autocvar_g_vehicle_bumblebee_shield_regen_pause;
 
-float autocvar_g_vehicle_bumblebee_cannon_cost;
-float autocvar_g_vehicle_bumblebee_cannon_damage;
-float autocvar_g_vehicle_bumblebee_cannon_radius;
-float autocvar_g_vehicle_bumblebee_cannon_refire;
-float autocvar_g_vehicle_bumblebee_cannon_speed;
-float autocvar_g_vehicle_bumblebee_cannon_spread;
-float autocvar_g_vehicle_bumblebee_cannon_force;
-
 float autocvar_g_vehicle_bumblebee_cannon_ammo;
 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
@@ -98,17 +94,6 @@ vector autocvar_g_vehicle_bumblebee_bouncepain;
 
 bool autocvar_g_vehicle_bumblebee = 0;
 
-float bumble_raygun_send(entity to, int sf);
-
-void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
-{
-       vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
-       vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND(VEH_BUMBLEBEE_FIRE),
-                                               v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
-                                               autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force,  0,
-                                               DEATH_VH_BUMB_GUN, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
-}
-
 float bumblebee_gunner_frame()
 {SELFPARAM();
        entity vehic    = self.vehicle.owner;
@@ -189,13 +174,13 @@ float bumblebee_gunner_frame()
 
        if(!forbidWeaponUse(gunner))
        if(gunner.BUTTON_ATCK)
-               if(time > gun.attack_finished_single)
+               if(time > gun.attack_finished_single[0])
                        if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
                        {
                                gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
                                bumblebee_fire_cannon(gun, "fire", gunner);
                                gun.delay = time;
-                               gun.attack_finished_single = time + autocvar_g_vehicle_bumblebee_cannon_refire;
+                               gun.attack_finished_single[0] = time + autocvar_g_vehicle_bumblebee_cannon_refire;
                        }
 
        VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
@@ -572,7 +557,7 @@ float bumblebee_pilot_frame()
                {
                        if(autocvar_g_vehicle_bumblebee_raygun)
                        {
-                               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);
+                               Damage(trace_ent, vehic, pilot, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC.m_id, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
                                vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
                        }
                        else
@@ -713,7 +698,7 @@ void bumblebee_blowup()
                                 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
                                 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
                                 autocvar_g_vehicle_bumblebee_blowup_forceintensity,
-                                DEATH_VH_BUMB_DEATH, world);
+                                DEATH_VH_BUMB_DEATH.m_id, world);
 
        sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        Send_Effect(EFFECT_EXPLOSION_BIG, (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
@@ -738,57 +723,25 @@ void bumblebee_diethink()
        self.nextthink = time + 0.1;
 }
 
-float bumble_raygun_send(entity to, float sf)
-{SELFPARAM();
-       WriteByte(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
-
-       WriteByte(MSG_ENTITY, sf);
-       if(sf & BRG_SETUP)
-       {
-               WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
-               WriteByte(MSG_ENTITY, self.realowner.team);
-               WriteByte(MSG_ENTITY, self.cnt);
-       }
-
-       if(sf & BRG_START)
-       {
-               WriteCoord(MSG_ENTITY, self.hook_start_x);
-               WriteCoord(MSG_ENTITY, self.hook_start_y);
-               WriteCoord(MSG_ENTITY, self.hook_start_z);
-       }
-
-       if(sf & BRG_END)
-       {
-               WriteCoord(MSG_ENTITY, self.hook_end_x);
-               WriteCoord(MSG_ENTITY, self.hook_end_y);
-               WriteCoord(MSG_ENTITY, self.hook_end_z);
-       }
-
-       return true;
-}
-
-void spawnfunc_vehicle_bumblebee()
-{SELFPARAM();
+spawnfunc(vehicle_bumblebee)
+{
        if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
        if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
 }
 
-               METHOD(Bumblebee, vr_impact, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh))
                {
                        if(autocvar_g_vehicle_bumblebee_bouncepain)
                                vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
-
-                       return true;
                }
-               METHOD(Bumblebee, vr_enter, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh))
                {
                        SELFPARAM();
                        self.touch = bumblebee_touch;
                        self.nextthink = 0;
                        self.movetype = MOVETYPE_BOUNCEMISSILE;
-                       return true;
                }
-               METHOD(Bumblebee, vr_think, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_think, void(Bumblebee thisveh))
                {
                        SELFPARAM();
                        self.angles_z *= 0.8;
@@ -809,7 +762,7 @@ void spawnfunc_vehicle_bumblebee()
                                        self.phase = 0;
                                        self.touch();
                                        other = oldother;
-                                       return true;
+                                       return;
                                }
 
                                if(self.gunner2)
@@ -822,18 +775,16 @@ void spawnfunc_vehicle_bumblebee()
                                        self.phase = 0;
                                        self.touch();
                                        other = oldother;
-                                       return true;
+                                       return;
                                }
                        }
-
-                       return true;
                }
-               METHOD(Bumblebee, vr_death, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_death, void(Bumblebee thisveh))
                {
                        SELFPARAM();
                        entity oldself = self;
 
-                       CSQCModel_UnlinkEntity();
+                       CSQCModel_UnlinkEntity(self);
 
                        // Hide beam
                        if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
@@ -891,9 +842,8 @@ void spawnfunc_vehicle_bumblebee()
                        self.nextthink          = 0;
 
                        setorigin(self, self.pos1);
-                       return true;
                }
-               METHOD(Bumblebee, vr_spawn, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh))
                {
                        SELFPARAM();
                        if(!self.gun1)
@@ -909,9 +859,9 @@ void spawnfunc_vehicle_bumblebee()
                                self.vehicle_shieldent.alpha = -1;
                                self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
 
-                               self.gun1 = spawn();
-                               self.gun2 = spawn();
-                               self.gun3 = spawn();
+                               self.gun1 = new(vehicle_playerslot);
+                               self.gun2 = new(vehicle_playerslot);
+                               self.gun3 = new(bumblebee_raygun);
 
                                self.vehicle_flags |= VHF_MULTISLOT;
 
@@ -919,8 +869,6 @@ void spawnfunc_vehicle_bumblebee()
                                self.gun2.owner = self;
                                self.gun3.owner = self;
 
-                               self.gun1.classname = self.gun2.classname = "vehicle_playerslot";
-
                                setmodel(self.gun1, MDL_VEH_BUMBLEBEE_CANNON_RIGHT);
                                setmodel(self.gun2, MDL_VEH_BUMBLEBEE_CANNON_LEFT);
                                setmodel(self.gun3, MDL_VEH_BUMBLEBEE_CANNON_CENTER);
@@ -972,9 +920,8 @@ void spawnfunc_vehicle_bumblebee()
                        self.PlayerPhysplug = bumblebee_pilot_frame;
 
                        setorigin(self, self.origin + '0 0 25');
-                       return true;
                }
-               METHOD(Bumblebee, vr_setup, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh))
                {
                        SELFPARAM();
                        if(autocvar_g_vehicle_bumblebee_energy)
@@ -995,12 +942,6 @@ void spawnfunc_vehicle_bumblebee()
                        self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
                        self.max_health = self.vehicle_health;
                        self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
-
-                       return true;
-               }
-               METHOD(Bumblebee, vr_precache, bool(Bumblebee thisveh))
-               {
-                       return true;
                }
 
 #endif // SVQC
@@ -1010,105 +951,43 @@ void CSQC_BUMBLE_GUN_HUD()
 {
        Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null,
                                         "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
-                                        string_null, '0 0 0',
-                                        string_null);
-}
-
-void bumble_raygun_draw()
-{SELFPARAM();
-       float _len;
-       vector _dir;
-       vector _vtmp1, _vtmp2;
-
-       _len = vlen(self.origin - self.move_origin);
-       _dir = normalize(self.move_origin - self.origin);
-
-       if(self.total_damages < time)
-       {
-               boxparticles(self.traileffect, self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
-               boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
-               self.total_damages = time + 0.1;
-       }
-
-       float i, df, sz, al;
-       for(i = -0.1; i < 0.2; i += 0.1)
-       {
-               df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
-               sz = 5 + random() * 5;
-               al = 0.25 + random() * 0.5;
-               _vtmp1 = self.origin + _dir * _len * (0.25 + i);
-               _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2));       //self.raygun_l1;
-               Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
-
-               _vtmp2 = self.origin + _dir * _len * (0.5 + i);
-               _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5));       //self.raygun_l2;
-               Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
-
-               _vtmp1 = self.origin + _dir * _len * (0.75 + i);
-               _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10);     //self.raygun_l3;
-               Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
-
-               Draw_CylindricLine(_vtmp1, self.move_origin +  randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
-       }
+                                        string_null, '0 0 0');
 }
 
-void bumble_raygun_read(bool bIsNew)
-{SELFPARAM();
-       int sf = ReadByte();
-
-       if(sf & BRG_SETUP)
-       {
-               self.cnt  = ReadByte();
-               self.team = ReadByte();
-               self.cnt  = ReadByte();
-
-               if(self.cnt)
-                       self.colormod = '1 0 0';
-               else
-                       self.colormod = '0 1 0';
-
-               self.traileffect = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH);
-               self.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
-
-               self.draw = bumble_raygun_draw;
-       }
+               METHOD(Bumblebee, vr_hud, void(Bumblebee thisveh))
+               {
+                       Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
+                                                        "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
+                                                        "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color);
 
+                       float hudAlpha = autocvar_hud_panel_fg_alpha;
+                       float blinkValue = 0.55 + sin(time * 7) * 0.45;
+                       vector tmpPos  = '0 0 0';
+                       vector tmpSize = '1 1 1' * hud_fontsize;
+                       tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (520/768);
 
-       if(sf & BRG_START)
-       {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
-       }
-
-       if(sf & BRG_END)
-       {
-               self.move_origin_x = ReadCoord();
-               self.move_origin_y = ReadCoord();
-               self.move_origin_z = ReadCoord();
-       }
-}
+                       if(!AuxiliaryXhair[1].draw2d)
+                       {
+                               tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (96/256) - tmpSize.y;
+                               drawstring(tmpPos, _("No right gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
+                       }
 
-               METHOD(Bumblebee, vr_hud, bool(Bumblebee thisveh))
+                       if(!AuxiliaryXhair[2].draw2d)
+                       {
+                               tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (160/256);
+                               drawstring(tmpPos, _("No left gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
+                       }
+               }
+               METHOD(Bumblebee, vr_crosshair, void(Bumblebee thisveh))
                {
-                       Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
-                                                        "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
-                                                        "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
-                                                        vCROSS_HEAL);
-                       return true;
+                       Vehicles_drawCrosshair(vCROSS_HEAL);
                }
-               METHOD(Bumblebee, vr_setup, bool(Bumblebee thisveh))
+               METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh))
                {
                        AuxiliaryXhair[0].axh_image = vCROSS_LOCK;  // Raygun-locked
                        AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
                        AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2
-                       return true;
-               }
-               METHOD(Bumblebee, vr_precache, bool(Bumblebee thisveh))
-               {
-                       return true;
                }
 
-#endif // CSQC
-#endif // REGISTER_VEHICLE
+#endif
+#endif