Merge branch 'master' into terencehill/vehicles_fixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / spiderbot.qc
index 3d1aa3d833de56183726b8051a044cd9268e281a..1085a904e2143f7e1abec373b6f4d80aa496cad7 100644 (file)
@@ -43,8 +43,7 @@ float autocvar_g_vehicle_spiderbot_minigun_ammo_max;
 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen;
 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause;
 float autocvar_g_vehicle_spiderbot_minigun_force;
-float autocvar_g_vehicle_spiderbot_minigun_speed;
-float autocvar_g_vehicle_spiderbot_minigun_bulletconstant;
+float autocvar_g_vehicle_spiderbot_minigun_solidpenetration;
 
 float autocvar_g_vehicle_spiderbot_rocket_damage;
 float autocvar_g_vehicle_spiderbot_rocket_force;
@@ -104,7 +103,7 @@ void spiderbot_rocket_guided()
 
     self.nextthink  = time;
 
-    if not (self.realowner.vehicle)
+    if (!self.realowner.vehicle)
         self.think = spiderbot_rocket_unguided;
 
     crosshair_trace(self.realowner);
@@ -122,7 +121,7 @@ void spiderbot_guide_release()
 {
     entity rkt;
     rkt = findchainentity(realowner, self.owner);
-    if not (rkt)
+    if (!rkt)
         return;
 
     crosshair_trace(self.owner);
@@ -137,12 +136,12 @@ void spiderbot_guide_release()
     }
 }
 
-float spiberbot_calcartillery_flighttime;  
+float spiberbot_calcartillery_flighttime;
 vector spiberbot_calcartillery(vector org, vector tgt, float ht)
 {
        float grav, sdist, zdist, vs, vz, jumpheight;
        vector sdir;
-       
+
        grav  = autocvar_sv_gravity;
        zdist = tgt_z - org_z;
        sdist = vlen(tgt - org - zdist * '0 0 1');
@@ -218,7 +217,7 @@ void spiderbot_rocket_do()
     entity rocket = world;
 
     if (self.wait != -10)
-    {        
+    {
         if (self.owner.BUTTON_ATCK2 && self.vehicle_weapon2mode == SBRM_GUIDE)
         {
             if (self.wait == 1)
@@ -239,7 +238,7 @@ void spiderbot_rocket_do()
             self.wait = 0;
         }
     }
-    
+
     if(self.gun2.cnt > time)
         return;
 
@@ -248,14 +247,14 @@ void spiderbot_rocket_do()
         self.tur_head.frame = 1;
         self.wait = 0;
     }
-        
+
     if (self.wait != -10)
-        if not (self.owner.BUTTON_ATCK2)
+        if (!self.owner.BUTTON_ATCK2)
             return;
 
 
     v = gettaginfo(self.tur_head,gettagindex(self.tur_head,"tag_fire"));
-    
+
     switch(self.vehicle_weapon2mode)
     {
         case SBRM_VOLLY:
@@ -282,36 +281,36 @@ void spiderbot_rocket_do()
             rocket.nextthink  = time;
             rocket.think      = spiderbot_rocket_guided;
 
-                
+
         break;
         case SBRM_ARTILLERY:
             rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
                                    v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                    DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
-            
+
             crosshair_trace(self.owner);
-            
+
             rocket.pos1       = trace_endpos + randomvec() * (0.75 * autocvar_g_vehicle_spiderbot_rocket_radius);
             rocket.pos1_z       = trace_endpos_z;
-            
-            traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);             
+
+            traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
             float h1 = 0.75 * vlen(v - trace_endpos);
-            
+
             //v = trace_endpos;
-            traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self); 
+            traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
             float h2 = 0.75 * vlen(rocket.pos1 - v);
-            
+
             rocket.velocity  = spiberbot_calcartillery(v, rocket.pos1, ((h1 < h2) ? h1 : h2));
-            rocket.movetype  = MOVETYPE_TOSS;            
+            rocket.movetype  = MOVETYPE_TOSS;
             rocket.gravity   = 1;
-            //rocket.think     = spiderbot_rocket_artillery;   
+            //rocket.think     = spiderbot_rocket_artillery;
         break;
     }
     rocket.classname  = "spiderbot_rocket";
-    
+
     rocket.cnt = time + autocvar_g_vehicle_spiderbot_rocket_lifetime;
-    
+
     self.tur_head.frame += 1;
     if (self.tur_head.frame == 9)
         self.attack_finished_single = autocvar_g_vehicle_spiderbot_rocket_reload;
@@ -334,17 +333,17 @@ float spiderbot_frame()
 
        if(intermission_running)
                return 1;
-               
+
     player = self;
     spider = self.vehicle;
     self   = spider;
 
     vehicles_painframe();
-    
+
     player.BUTTON_ZOOM      = 0;
     player.BUTTON_CROUCH    = 0;
     player.switchweapon     = 0;
-    
+
 
 #if 1 // 0 to enable per-gun impact aux crosshairs
     // Avarage gun impact point's -> aux cross
@@ -372,9 +371,9 @@ float spiderbot_frame()
     ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
     ad = AnglesTransform_Normalize(ad, TRUE);
     //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
-    
+
     // Rotate head
-    ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;    
+    ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
     ad_y = bound(-ftmp, ad_y, ftmp);
     spider.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, spider.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
 
@@ -385,7 +384,7 @@ float spiderbot_frame()
 
     //fixedmakevectors(spider.angles);
     makevectors(spider.angles + '-2 0 0' * spider.angles_x);
-    
+
     movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
 
     if(spider.flags & FL_ONGROUND)
@@ -393,11 +392,11 @@ float spiderbot_frame()
         if(spider.frame == 4 && self.tur_head.wait != 0)
         {
             sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
-            spider.frame = 5;            
+            spider.frame = 5;
         }
-        
+
         if(player.BUTTON_JUMP && self.tur_head.wait < time)
-        {        
+        {
             sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
             //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
             self.delay = 0;
@@ -412,12 +411,12 @@ float spiderbot_frame()
             if(vlen(player.movement) == 0)
             {
                 if(self.sound_nexttime < time || self.delay != 3)
-                {                        
+                {
                     self.delay = 3;
                     self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
                     //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
                     sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
-                }                
+                }
                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
                 spider.frame = 5;
             }
@@ -428,8 +427,8 @@ float spiderbot_frame()
                     ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
                 else
                     ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
-                
-                ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);                
+
+                ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
                 spider.angles_y = anglemods(spider.angles_y + ftmp);
                 spider.tur_head.angles_y -= ftmp;
 
@@ -449,7 +448,7 @@ float spiderbot_frame()
                     movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
 
                     if(self.sound_nexttime < time || self.delay != 1)
-                    {                        
+                    {
                         self.delay = 1;
                         self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
@@ -470,7 +469,7 @@ float spiderbot_frame()
                     }
                     movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
                     if(self.sound_nexttime < time || self.delay != 2)
-                    {                        
+                    {
                         self.delay = 2;
                         self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
@@ -500,12 +499,8 @@ float spiderbot_frame()
             v_forward = normalize(v_forward);
             v += v_forward * 50;
 
-//void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, float lifetime, float damage, float force, float dtype, float tracereffects, float gravityfactor, float bulletconstant)
-
-            fireBallisticBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_speed,
-                                5, autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0, 1, autocvar_g_vehicle_spiderbot_minigun_bulletconstant);
-
-            endFireBallisticBullet();
+            fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
+                                autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
 
 //            fireBullet (v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_damage,
 //                autocvar_g_vehicle_spiderbot_minigun_spread, DEATH_VH_SPID_MINIGUN, 0);
@@ -532,7 +527,7 @@ float spiderbot_frame()
         vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
                                            autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
                                            autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, FALSE);
-        
+
 
     spiderbot_rocket_do();
 
@@ -559,7 +554,7 @@ float spiderbot_frame()
         VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
 
     self = player;
-    return 1;    
+    return 1;
 }
 void spiderbot_think()
 {
@@ -579,8 +574,8 @@ void spiderbot_enter()
 
     if(self.owner.flagcarried)
     {
-        setattachment(self.owner.flagcarried, self.tur_head, ""); 
-        setorigin(self.owner.flagcarried, '-20 0 120'); 
+        setattachment(self.owner.flagcarried, self.tur_head, "");
+        setorigin(self.owner.flagcarried, '-20 0 120');
     }
 }
 
@@ -588,7 +583,7 @@ void spiderbot_exit(float eject)
 {
     entity e;
     vector spot;
-    
+
     e = findchain(classname,"spiderbot_rocket");
     while(e)
     {
@@ -605,8 +600,8 @@ void spiderbot_exit(float eject)
     self.nextthink  = time;
     self.frame      = 5;
     self.movetype   = MOVETYPE_WALK;
-    
-    if not (self.owner)
+
+    if (!self.owner)
         return;
 
        makevectors(self.angles);
@@ -637,7 +632,7 @@ void spiderbot_exit(float eject)
            self.owner.oldvelocity = self.owner.velocity;
            setorigin(self.owner , spot);
        }
-       
+
        antilag_clear(self.owner);
     self.owner = world;
 }
@@ -677,7 +672,7 @@ void spiderbot_blowup()
         self.nextthink = time + 0.1;
         return;
     }
-    
+
     entity h, g1, g2, b;
     b = spawn();
     h = spawn();
@@ -764,12 +759,12 @@ float spiderbot_impulse(float _imp)
     switch(_imp)
     {
         case 10:
-        case 15:        
+        case 15:
         case 18:
             self.vehicle.vehicle_weapon2mode += 1;
             if(self.vehicle.vehicle_weapon2mode > SBRM_LAST)
                 self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
-            
+
             //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
             CSQCVehicleSetup(self, 0);
             return TRUE;
@@ -779,28 +774,28 @@ float spiderbot_impulse(float _imp)
             self.vehicle.vehicle_weapon2mode -= 1;
             if(self.vehicle.vehicle_weapon2mode < SBRM_FIRST)
                 self.vehicle.vehicle_weapon2mode = SBRM_LAST;
-            
+
             //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
             CSQCVehicleSetup(self, 0);
             return TRUE;
 
-        /*                     
+        /*
         case 17: // toss gun, could be used to exit?
             break;
         case 20: // Manual minigun reload?
             break;
         */
-    }    
+    }
     return FALSE;
 }
 
 void spiderbot_spawn(float _f)
 {
     if(!self.gun1)
-    {        
+    {
         self.vehicles_impulse   = spiderbot_impulse;
         self.gun1               = spawn();
-        self.gun2               = spawn();    
+        self.gun2               = spawn();
         setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
         setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
         setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
@@ -818,7 +813,7 @@ void spiderbot_spawn(float _f)
     self.movetype           = MOVETYPE_WALK;
     self.solid              = SOLID_SLIDEBOX;
     self.alpha              = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
-    self.tur_head.angles    = '0 0 0';    
+    self.tur_head.angles    = '0 0 0';
 
     setorigin(self, self.pos1 + '0 0 128');
     self.angles = self.pos2;
@@ -832,12 +827,12 @@ void spawnfunc_vehicle_spiderbot()
     {
         remove(self);
         return;
-    }        
+    }
 
     self.vehicle_flags |= VHF_DMGSHAKE;
     //self.vehicle_flags |= VHF_DMGROLL;
     //self.vehicle_flags |= VHF_DMGHEADROLL;
-    
+
     precache_model ( "models/vhshield.md3");
     precache_model ( "models/vehicles/spiderbot.dpm");
     precache_model ( "models/vehicles/spiderbot_top.dpm");
@@ -847,7 +842,7 @@ void spawnfunc_vehicle_spiderbot()
 
     precache_sound ( "weapons/uzi_fire.wav" );
     precache_sound ( "weapons/rocket_impact.wav");
-    
+
     precache_sound ( "vehicles/spiderbot_die.wav");
     precache_sound ( "vehicles/spiderbot_idle.wav");
     precache_sound ( "vehicles/spiderbot_jump.wav");
@@ -863,8 +858,8 @@ void spawnfunc_vehicle_spiderbot()
 
     if(autocvar_g_vehicle_spiderbot_health_regen)
         self.vehicle_flags |= VHF_HEALTHREGEN;
-        
-    if not (vehicle_initialize(
+
+    if(!vehicle_initialize(
              "Spiderbot",
              "models/vehicles/spiderbot.dpm",
              "models/vehicles/spiderbot_top.dpm",
@@ -877,7 +872,7 @@ void spawnfunc_vehicle_spiderbot()
              spiderbot_frame,
              spiderbot_enter, spiderbot_exit,
              spiderbot_die,   spiderbot_think,
-             FALSE, 
+             FALSE,
              autocvar_g_vehicle_spiderbot_health,
              autocvar_g_vehicle_spiderbot_shield))
     {