]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/unit/raptor.qc
Merge new vehicle stuff from combined updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / unit / raptor.qc
index c9eefa6e00847eb222fabfd837a9c6752bc03212..b8cf0d2a558b1a6cde12ccce596a01487f536e9b 100644 (file)
@@ -13,13 +13,13 @@ REGISTER_VEHICLE(
 );
 #else
 
-const float RSM_FIRST = 0;
-const float RSM_BOMB = 0;
-const float RSM_FLARE = 1;
-const float RSM_LAST = 1;
+const int RSM_FIRST = 1;
+const int RSM_BOMB = 1;
+const int RSM_FLARE = 2;
+const int RSM_LAST = 2;
 
 #ifdef SVQC
-float autocvar_g_vehicle_raptor;
+bool autocvar_g_vehicle_raptor;
 
 float autocvar_g_vehicle_raptor_respawntime;
 float autocvar_g_vehicle_raptor_takeofftime;
@@ -99,7 +99,7 @@ void raptor_bomblet_boom()
 {
        RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_bomblet_damage,
                                                                        autocvar_g_vehicle_raptor_bomblet_edgedamage,
-                                                                       autocvar_g_vehicle_raptor_bomblet_radius, world,
+                                                                       autocvar_g_vehicle_raptor_bomblet_radius, world, world,
                                                                        autocvar_g_vehicle_raptor_bomblet_force, DEATH_VH_RAPT_BOMB, world);
        remove(self);
 }
@@ -147,7 +147,7 @@ void raptor_bomb_burst()
                bomblet.velocity        = normalize(normalize(self.velocity) + (randomvec() * autocvar_g_vehicle_raptor_bomblet_spread)) * vlen(self.velocity);
 
                PROJECTILE_MAKETRIGGER(bomblet);
-               CSQCProjectile(bomblet, TRUE, PROJECTILE_RAPTORBOMBLET, TRUE);
+               CSQCProjectile(bomblet, true, PROJECTILE_RAPTORBOMBLET, true);
        }
 
        remove(self);
@@ -182,8 +182,8 @@ void raptor_bombdrop()
        PROJECTILE_MAKETRIGGER(bomb_1);
        PROJECTILE_MAKETRIGGER(bomb_2);
 
-       CSQCProjectile(bomb_1, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
-       CSQCProjectile(bomb_2, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
+       CSQCProjectile(bomb_1, true, PROJECTILE_RAPTORBOMB, true);
+       CSQCProjectile(bomb_2, true, PROJECTILE_RAPTORBOMB, true);
 }
 
 
@@ -192,7 +192,7 @@ void raptor_fire_cannon(entity gun, string tagname)
        vehicles_projectile("raptor_cannon_muzzleflash", "weapons/lasergun_fire.wav",
                                                   gettaginfo(gun, gettagindex(gun, tagname)), normalize(v_forward + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
                                                   autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force,  0,
-                                                  DEATH_VH_RAPT_CANNON, PROJECTILE_RAPTORCANNON, 0, TRUE, TRUE, self.owner);
+                                                  DEATH_VH_RAPT_CANNON, PROJECTILE_RAPTORCANNON, 0, true, true, self.owner);
 }
 
 void raptor_land()
@@ -219,6 +219,8 @@ void raptor_land()
        }
 
        self.nextthink  = time;
+       
+       CSQCMODEL_AUTOUPDATE();
 }
 
 void raptor_exit(float eject)
@@ -232,7 +234,7 @@ void raptor_exit(float eject)
                self.nextthink  = time;
        }
 
-       if not (self.owner)
+       if(!self.owner)
                return;
 
        makevectors(self.angles);
@@ -304,11 +306,16 @@ float raptor_frame()
        vector df;
 
        if(intermission_running)
+       {
+               self.vehicle.velocity = '0 0 0';
+               self.vehicle.avelocity = '0 0 0';
                return 1;
+       }
 
        player = self;
        raptor = self.vehicle;
        self   = raptor;
+       
        vehicles_painframe();
        /*
        ftmp = vlen(self.velocity);
@@ -409,6 +416,8 @@ float raptor_frame()
        player.velocity = player.movement  = raptor.velocity;
        setorigin(player, raptor.origin + '0 0 32');
 
+       player.vehicle_weapon2mode = raptor.vehicle_weapon2mode;
+
        vector vf, ad;
        // Target lock & predict
        if(autocvar_g_vehicle_raptor_cannon_locktarget == 2)
@@ -438,7 +447,7 @@ float raptor_frame()
 
                if(raptor.gun1.enemy)
                {
-                       float i, distance, impact_time;
+                       float distance, impact_time;
 
                        vf = real_origin(raptor.gun1.enemy);
                        UpdateAuxiliaryXhair(player, vf, '1 0 0', 1);
@@ -449,12 +458,9 @@ float raptor_frame()
                        if(autocvar_g_vehicle_raptor_cannon_predicttarget)
                        {
                                ad = vf;
-                               for(i = 0; i < 4; ++i)
-                               {
-                                       distance = vlen(ad - player.origin);
-                                       impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
-                                       ad = vf + _vel * impact_time;
-                               }
+                               distance = vlen(ad - player.origin);
+                               impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
+                               ad = vf + _vel * impact_time;
                                trace_endpos = ad;
                        }
                        else
@@ -512,6 +518,7 @@ float raptor_frame()
        UpdateAuxiliaryXhair(player, trace_endpos, '0 1 0', 0);
        */
 
+       if(!forbidWeaponUse(player))
        if(player.BUTTON_ATCK)
        if(raptor.attack_finished_single <= time)
        if(raptor.vehicle_energy > autocvar_g_vehicle_raptor_cannon_cost)
@@ -533,14 +540,15 @@ float raptor_frame()
        }
 
        if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, TRUE);
+               vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true);
 
        if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, FALSE);
+               vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false);
 
        if(self.vehicle_flags  & VHF_ENERGYREGEN)
-               vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, FALSE);
+               vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false);
 
+       if(!forbidWeaponUse(player))
        if(raptor.vehicle_weapon2mode == RSM_BOMB)
        {
                if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
@@ -626,6 +634,11 @@ float raptor_takeoff()
        player = self;
        raptor = self.vehicle;
        self   = raptor;
+       
+       self.nextthink = time;
+       CSQCMODEL_AUTOUPDATE();
+       self.nextthink = 0; // will this work?
+       
        if(self.sound_nexttime < time)
        {
                self.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
@@ -647,13 +660,13 @@ float raptor_takeoff()
                player.PlayerPhysplug = raptor_frame;
 
        if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, TRUE);
+               vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true);
 
        if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, FALSE);
+               vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false);
 
        if(self.vehicle_flags  & VHF_ENERGYREGEN)
-               vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, FALSE);
+               vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false);
 
 
        raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
@@ -673,7 +686,7 @@ void raptor_blowup()
 {
        self.deadflag   = DEAD_DEAD;
        self.vehicle_exit(VHEF_NORMAL);
-       RadiusDamage (self, self.enemy, 250, 15, 250, world, 250, DEATH_VH_RAPT_DEATH, world);
+       RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_RAPT_DEATH, world);
 
        self.alpha                = -1;
        self.movetype      = MOVETYPE_NONE;
@@ -692,12 +705,14 @@ void raptor_diethink()
        if(time >= self.wait)
                self.think = raptor_blowup;
 
-       if(random() < 0.1)
+       if(random() < 0.05)
        {
                sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
                pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
        }
-       self.nextthink = time + 0.1;
+       self.nextthink = time;
+       
+       CSQCMODEL_AUTOUPDATE();
 }
 
 // If we dont do this ever now and then, the raptors rotors
@@ -713,6 +728,17 @@ float raptor_impulse(float _imp)
 {
        switch(_imp)
        {
+               case 1:
+               case 230:
+                       self.vehicle.vehicle_weapon2mode = RSM_BOMB;
+                       CSQCVehicleSetup(self, 0);
+                       return true;
+               case 2:
+               case 231:
+                       self.vehicle.vehicle_weapon2mode = RSM_FLARE;
+                       CSQCVehicleSetup(self, 0);
+                       return true;
+
                case 10:
                case 15:
                case 18:
@@ -721,7 +747,8 @@ float raptor_impulse(float _imp)
                                self.vehicle.vehicle_weapon2mode = RSM_FIRST;
 
                        CSQCVehicleSetup(self, 0);
-                       return TRUE;
+                       return true;
+               case 11:
                case 12:
                case 16:
                case 19:
@@ -730,7 +757,7 @@ float raptor_impulse(float _imp)
                                self.vehicle.vehicle_weapon2mode = RSM_LAST;
 
                        CSQCVehicleSetup(self, 0);
-                       return TRUE;
+                       return true;
 
                /*
                case 17: // toss gun, could be used to exit?
@@ -739,13 +766,13 @@ float raptor_impulse(float _imp)
                        break;
                */
        }
-       return FALSE;
+       return false;
 }
 
 void spawnfunc_vehicle_raptor()
 {
-       if not(autocvar_g_vehicle_raptor) { remove(self); return; }
-       if not(vehicle_initialize(VEH_RAPTOR, FALSE)) { remove(self); return; }
+       if(!autocvar_g_vehicle_raptor) { remove(self); return; }
+       if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
 }
 
 float v_raptor(float req)
@@ -757,7 +784,7 @@ float v_raptor(float req)
                        if(autocvar_g_vehicle_raptor_bouncepain)
                                vehicles_impact(autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
                                
-                       return TRUE;
+                       return true;
                }
                case VR_ENTER:
                {
@@ -777,11 +804,11 @@ float v_raptor(float req)
                           setorigin(self.owner.flagcarried, '-20 0 96');
 
                        CSQCVehicleSetup(self.owner, 0);
-                       return TRUE;
+                       return true;
                }
                case VR_THINK:
                {
-                       return TRUE;
+                       return true;
                }
                case VR_DEATH:
                {
@@ -804,11 +831,11 @@ float v_raptor(float req)
 
                        self.colormod = '-0.5 -0.5 -0.5';
                        self.touch = raptor_blowup;
-                       return TRUE;
+                       return true;
                }
                case VR_SPAWN:
                {
-                       if not(self.gun1)
+                       if(!self.gun1)
                        {
                                entity spinner;
                                vector ofs;
@@ -896,7 +923,7 @@ float v_raptor(float req)
                        self.damageforcescale = 0.25;
                        self.vehicle_health = autocvar_g_vehicle_raptor_health;
                        self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
-                       return TRUE;
+                       return true;
                }
                case VR_SETUP:
                {
@@ -918,7 +945,7 @@ float v_raptor(float req)
                        self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
                        self.max_health = self.vehicle_health;
                                
-                       return TRUE;
+                       return true;
                }
                case VR_PRECACHE:
                {
@@ -933,21 +960,63 @@ float v_raptor(float req)
                        precache_sound ("vehicles/raptor_speed.wav");
                        precache_sound ("vehicles/missile_alarm.wav");
                
-                       return TRUE;
+                       return true;
                }
        }
 
-       return TRUE;
+       return true;
 }
 
 #endif // SVQC
 #ifdef CSQC
-
 #define raptor_ico  "gfx/vehicles/raptor.tga"
 #define raptor_gun  "gfx/vehicles/raptor_guns.tga"
 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
-string raptor_xhair;
+
+void RaptorCBShellfragDraw()
+{
+       if(wasfreed(self))
+               return;
+
+       Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+       self.move_avelocity += randomvec() * 15;
+       self.renderflags = 0;
+
+       if(self.cnt < time)
+               self.alpha = bound(0, self.nextthink - time, 1);
+
+       if(self.alpha < ALPHA_MIN_VISIBLE)
+               remove(self);
+}
+
+void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
+{
+       entity sfrag;
+
+       sfrag = spawn();
+       setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
+       setorigin(sfrag, _org);
+
+       sfrag.move_movetype = MOVETYPE_BOUNCE;
+       sfrag.gravity = 0.15;
+       sfrag.solid = SOLID_CORPSE;
+
+       sfrag.draw = RaptorCBShellfragDraw;
+
+       sfrag.move_origin = sfrag.origin = _org;
+       sfrag.move_velocity = _vel;
+       sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
+       sfrag.angles = self.move_angles = _ang;
+
+       sfrag.move_time = time;
+       sfrag.damageforcescale = 4;
+
+       sfrag.nextthink = time + 3;
+       sfrag.cnt = time + 2;
+       sfrag.alpha = 1;
+       sfrag.drawmask = MASK_NORMAL;
+}
 
 float v_raptor(float req)
 {
@@ -956,9 +1025,10 @@ float v_raptor(float req)
                case VR_HUD:
                {
                        if(autocvar_r_letterbox)
-                               return TRUE;
+                               return true;
 
                        vector picsize, hudloc = '0 0 0', pic2size, picloc;
+                       string raptor_xhair;
 
                        // Fetch health & ammo stats
                        HUD_GETVEHICLESTATS
@@ -1072,7 +1142,7 @@ float v_raptor(float req)
                        else
                                drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
 
-                       if(weapon2mode == RSM_FLARE)
+                       if(getstati(STAT_VEHICLESTAT_W2MODE) == RSM_FLARE)
                        {
                                raptor_xhair =  "gfx/vehicles/axh-bracket.tga";
                        }
@@ -1101,7 +1171,7 @@ float v_raptor(float req)
                                        setorigin(dropmark, trace_endpos);
                                        picsize = draw_getimagesize(raptor_drop) * 0.2;
 
-                                       if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
+                                       if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
                                        {
                                                where_x -= picsize_x * 0.5;
                                                where_y -= picsize_y * 0.5;
@@ -1118,7 +1188,7 @@ float v_raptor(float req)
                                                where = project_3d_to_2d(dropmark.origin);
                                                picsize = draw_getimagesize(raptor_drop) * 0.25;
 
-                                               if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
+                                               if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
                                                {
                                                        where_x -= picsize_x * 0.5;
                                                        where_y -= picsize_y * 0.5;
@@ -1140,7 +1210,7 @@ float v_raptor(float req)
                                drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), raptor_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
                        }
                        
-                       return TRUE;
+                       return true;
                }
                case VR_SETUP:
                {
@@ -1149,22 +1219,15 @@ float v_raptor(float req)
                        
                        AuxiliaryXhair[1].axh_image = "gfx/vehicles/axh-bracket.tga";
                        AuxiliaryXhair[1].axh_scale = 0.25;
-                       return TRUE;
+                       return true;
                }
                case VR_PRECACHE:
                {
-                       precache_model ("models/vehicles/raptor.dpm");
-                       precache_model ("models/vehicles/raptor_gun.dpm");
-                       precache_model ("models/vehicles/spinner.dpm");
-                       precache_model ("models/vehicles/raptor_cockpit.dpm");
-                       precache_model ("models/vehicles/clusterbomb_folded.md3");
-                       precache_model ("models/vehicles/raptor_body.dpm");
-                       
-                       return TRUE;
+                       return true;
                }
        }
 
-       return TRUE;
+       return true;
 }
 
 #endif // CSQC