]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/tturrets/system/system_main.qc
Remove an old unused model
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / system / system_main.qc
index 17343f417b27ec9b35f9f9bfbd2da7c4220154af..70ae2ae09d55351daf20f2d4a80403f5cec6c64a 100644 (file)
@@ -1,79 +1,79 @@
 #define cvar_base "g_turrets_unit_"
 .float clientframe;
 void turrets_setframe(float _frame, float client_only)
-{        
+{
     if((client_only ? self.clientframe : self.frame ) != _frame)
     {
         self.SendFlags |= TNSF_ANIM;
         self.anim_start_time = time;
     }
-    
+
      if(client_only)
         self.clientframe = _frame;
     else
         self.frame = _frame;
-   
+
 }
 
 float turret_send(entity to, float sf)
 {
-       
-       WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);    
+
+       WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
        WriteByte(MSG_ENTITY, sf);
        if(sf & TNSF_SETUP)
        {
            WriteByte(MSG_ENTITY, self.turret_type);
-           
-           WriteCoord(MSG_ENTITY, self.origin_x);
-           WriteCoord(MSG_ENTITY, self.origin_y);
-           WriteCoord(MSG_ENTITY, self.origin_z);
-           
-           WriteAngle(MSG_ENTITY, self.angles_x);
-           WriteAngle(MSG_ENTITY, self.angles_y);
+
+           WriteCoord(MSG_ENTITY, self.origin.x);
+           WriteCoord(MSG_ENTITY, self.origin.y);
+           WriteCoord(MSG_ENTITY, self.origin.z);
+
+           WriteAngle(MSG_ENTITY, self.angles.x);
+           WriteAngle(MSG_ENTITY, self.angles.y);
     }
-    
+
     if(sf & TNSF_ANG)
     {
-        WriteShort(MSG_ENTITY, rint(self.tur_head.angles_x));
-        WriteShort(MSG_ENTITY, rint(self.tur_head.angles_y));
+        WriteShort(MSG_ENTITY, rint(self.tur_head.angles.x));
+        WriteShort(MSG_ENTITY, rint(self.tur_head.angles.y));
     }
-    
+
     if(sf & TNSF_AVEL)
-    {        
-        WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_x));
-        WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_y));
+    {
+        WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity.x));
+        WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity.y));
     }
-    
+
     if(sf & TNSF_MOVE)
     {
-        WriteShort(MSG_ENTITY, rint(self.origin_x));
-        WriteShort(MSG_ENTITY, rint(self.origin_y));
-        WriteShort(MSG_ENTITY, rint(self.origin_z));
-
-        WriteShort(MSG_ENTITY, rint(self.velocity_x));
-        WriteShort(MSG_ENTITY, rint(self.velocity_y));
-        WriteShort(MSG_ENTITY, rint(self.velocity_z));        
-        
-        WriteShort(MSG_ENTITY, rint(self.angles_y));        
+        WriteShort(MSG_ENTITY, rint(self.origin.x));
+        WriteShort(MSG_ENTITY, rint(self.origin.y));
+        WriteShort(MSG_ENTITY, rint(self.origin.z));
+
+        WriteShort(MSG_ENTITY, rint(self.velocity.x));
+        WriteShort(MSG_ENTITY, rint(self.velocity.y));
+        WriteShort(MSG_ENTITY, rint(self.velocity.z));
+
+        WriteShort(MSG_ENTITY, rint(self.angles.y));
     }
-    
+
     if(sf & TNSF_ANIM)
     {
         WriteCoord(MSG_ENTITY, self.anim_start_time);
         WriteByte(MSG_ENTITY, self.frame);
     }
-    
+
     if(sf & TNSF_STATUS)
     {
         WriteByte(MSG_ENTITY, self.team);
-        
+
         if(self.health <= 0)
             WriteByte(MSG_ENTITY, 0);
         else
             WriteByte(MSG_ENTITY, ceil((self.health / self.tur_health) * 255));
     }
-    
-       return TRUE;
+
+       return true;
 }
 
 void load_unit_settings(entity ent, string unitname, float is_reload)
@@ -143,16 +143,16 @@ void load_unit_settings(entity ent, string unitname, float is_reload)
 
 void turret_projectile_explode()
 {
-    
+
     self.takedamage = DAMAGE_NO;
-    self.event_damage = func_null;    
+    self.event_damage = func_null;
 #ifdef TURRET_DEBUG
     float d;
-    d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
+    d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
 #else
-    RadiusDamage (self, self.realowner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
+    RadiusDamage (self, self.realowner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
 #endif
     remove(self);
 }
@@ -182,13 +182,13 @@ entity turret_projectile(string _snd, float _size, float _health, float _death,
     setsize(proj, '-0.5 -0.5 -0.5' * _size, '0.5 0.5 0.5' * _size);
     proj.owner           = self;
     proj.realowner       = self;
-    proj.bot_dodge       = TRUE;
-    proj.bot_dodgerating = self.shot_dmg;    
+    proj.bot_dodge       = true;
+    proj.bot_dodgerating = self.shot_dmg;
     proj.think           = turret_projectile_explode;
     proj.touch           = turret_projectile_touch;
-    proj.nextthink       = time + 9;    
+    proj.nextthink       = time + 9;
     proj.movetype        = MOVETYPE_FLYMISSILE;
-    proj.velocity        = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;    
+    proj.velocity        = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
     proj.flags           = FL_PROJECTILE;
     proj.enemy           = self.enemy;
     proj.totalfrags      = _death;
@@ -203,7 +203,7 @@ entity turret_projectile(string _snd, float _size, float _health, float _death,
         proj.flags |= FL_NOTARGET;
 
     CSQCProjectile(proj, _cli_anim, _proj_type, _cull);
-    
+
     return proj;
 }
 
@@ -241,8 +241,8 @@ void turret_do_updates(entity t_turret)
     }
     else*/
         tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-       
-       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);                
+
+       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);
        self.tur_impactent             = trace_ent;
        self.tur_impacttime            = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
 
@@ -328,7 +328,7 @@ void turret_stdproc_track()
     vector v1, v2;
     v1 = self.tur_head.angles;
     v2 = self.tur_head.avelocity;
-    
+
     if (self.track_flags == TFL_TRACK_NO)
         return;
 
@@ -343,17 +343,17 @@ void turret_stdproc_track()
     }
     else
     {
-        target_angle = vectoangles(normalize(self.tur_aimpos - self.tur_shotorg)); 
+        target_angle = vectoangles(normalize(self.tur_aimpos - self.tur_shotorg));
     }
-    
-    self.tur_head.angles_x = anglemods(self.tur_head.angles_x);
-    self.tur_head.angles_y = anglemods(self.tur_head.angles_y);
+
+    self.tur_head.angles_x = anglemods(self.tur_head.angles.x);
+    self.tur_head.angles_y = anglemods(self.tur_head.angles.y);
 
     // Find the diffrence between where we currently aim and where we want to aim
     //move_angle = target_angle - (self.angles + self.tur_head.angles);
     //move_angle = shortangle_vxy(move_angle,(self.angles + self.tur_head.angles));
-    
-    move_angle = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(self.angles), AnglesTransform_FromAngles(target_angle))) - self.tur_head.angles; 
+
+    move_angle = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(self.angles), AnglesTransform_FromAngles(target_angle))) - self.tur_head.angles;
     move_angle = shortangle_vxy(move_angle, self.tur_head.angles);
 
     switch(self.track_type)
@@ -362,40 +362,40 @@ void turret_stdproc_track()
             f_tmp = self.aim_speed * self.ticrate; // dgr/sec -> dgr/tic
             if (self.track_flags & TFL_TRACK_PITCH)
             {
-                self.tur_head.angles_x += bound(-f_tmp,move_angle_x, f_tmp);
-                if(self.tur_head.angles_x > self.aim_maxpitch)
+                self.tur_head.angles_x += bound(-f_tmp,move_angle.x, f_tmp);
+                if(self.tur_head.angles.x > self.aim_maxpitch)
                     self.tur_head.angles_x = self.aim_maxpitch;
 
-                if(self.tur_head.angles_x  < -self.aim_maxpitch)
+                if(self.tur_head.angles.x  < -self.aim_maxpitch)
                     self.tur_head.angles_x = self.aim_maxpitch;
             }
 
             if (self.track_flags & TFL_TRACK_ROT)
             {
-                self.tur_head.angles_y += bound(-f_tmp, move_angle_y, f_tmp);
-                if(self.tur_head.angles_y > self.aim_maxrot)
+                self.tur_head.angles_y += bound(-f_tmp, move_angle.y, f_tmp);
+                if(self.tur_head.angles.y > self.aim_maxrot)
                     self.tur_head.angles_y = self.aim_maxrot;
 
-                if(self.tur_head.angles_y  < -self.aim_maxrot)
+                if(self.tur_head.angles.y  < -self.aim_maxrot)
                     self.tur_head.angles_y = self.aim_maxrot;
             }
-            
+
             // CSQC
             self.SendFlags  |= TNSF_ANG;
-            
+
             return;
 
         case TFL_TRACKTYPE_FLUIDINERTIA:
             f_tmp = self.aim_speed * self.ticrate; // dgr/sec -> dgr/tic
-            move_angle_x = bound(-self.aim_speed, move_angle_x * self.track_accel_pitch * f_tmp, self.aim_speed);
-            move_angle_y = bound(-self.aim_speed, move_angle_y * self.track_accel_rot * f_tmp, self.aim_speed);
+            move_angle.x = bound(-self.aim_speed, move_angle.x * self.track_accel_pitch * f_tmp, self.aim_speed);
+            move_angle.y = bound(-self.aim_speed, move_angle.y * self.track_accel_rot * f_tmp, self.aim_speed);
             move_angle = (self.tur_head.avelocity * self.track_blendrate) + (move_angle * (1 - self.track_blendrate));
             break;
 
         case TFL_TRACKTYPE_FLUIDPRECISE:
 
-            move_angle_y = bound(-self.aim_speed, move_angle_y, self.aim_speed);
-            move_angle_x = bound(-self.aim_speed, move_angle_x, self.aim_speed);
+            move_angle.y = bound(-self.aim_speed, move_angle.y, self.aim_speed);
+            move_angle.x = bound(-self.aim_speed, move_angle.x, self.aim_speed);
 
             break;
     }
@@ -403,20 +403,20 @@ void turret_stdproc_track()
     //  pitch
     if (self.track_flags & TFL_TRACK_PITCH)
     {
-        self.tur_head.avelocity_x = move_angle_x;
-        if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) > self.aim_maxpitch)
+        self.tur_head.avelocity_x = move_angle.x;
+        if((self.tur_head.angles.x + self.tur_head.avelocity.x * self.ticrate) > self.aim_maxpitch)
         {
             self.tur_head.avelocity_x = 0;
             self.tur_head.angles_x = self.aim_maxpitch;
-            
+
             self.SendFlags  |= TNSF_ANG;
         }
-        
-        if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) < -self.aim_maxpitch)
+
+        if((self.tur_head.angles.x + self.tur_head.avelocity.x * self.ticrate) < -self.aim_maxpitch)
         {
             self.tur_head.avelocity_x = 0;
             self.tur_head.angles_x = -self.aim_maxpitch;
-                        
+
             self.SendFlags  |= TNSF_ANG;
         }
     }
@@ -424,34 +424,34 @@ void turret_stdproc_track()
     //  rot
     if (self.track_flags & TFL_TRACK_ROT)
     {
-        self.tur_head.avelocity_y = move_angle_y;
+        self.tur_head.avelocity_y = move_angle.y;
 
-        if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) > self.aim_maxrot)
+        if((self.tur_head.angles.y + self.tur_head.avelocity.y * self.ticrate) > self.aim_maxrot)
         {
             self.tur_head.avelocity_y = 0;
             self.tur_head.angles_y = self.aim_maxrot;
-            
+
             self.SendFlags  |= TNSF_ANG;
         }
 
-        if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) < -self.aim_maxrot)
+        if((self.tur_head.angles.y + self.tur_head.avelocity.y * self.ticrate) < -self.aim_maxrot)
         {
             self.tur_head.avelocity_y = 0;
             self.tur_head.angles_y = -self.aim_maxrot;
-            
+
             self.SendFlags  |= TNSF_ANG;
         }
     }
-        
+
     self.SendFlags  |= TNSF_AVEL;
-    
+
     // Force a angle update every 10'th frame
     self.turret_framecounter += 1;
     if(self.turret_framecounter >= 10)
-    {        
+    {
         self.SendFlags |= TNSF_ANG;
         self.turret_framecounter = 0;
-    }            
+    }
 }
 
 
@@ -480,7 +480,7 @@ void turret_stdproc_track()
 float turret_stdproc_firecheck()
 {
     // This one just dont care =)
-    if (self.firecheck_flags & TFL_FIRECHECK_NO) 
+    if (self.firecheck_flags & TFL_FIRECHECK_NO)
         return 1;
 
     if (self.enemy == world)
@@ -494,7 +494,7 @@ float turret_stdproc_firecheck()
     if (self.shoot_flags & TFL_SHOOT_VOLLYALWAYS)
         if (self.volly_counter != self.shot_volly)
                        if(self.ammo >= self.shot_dmg)
-                               return 1;               
+                               return 1;
 
     // Lack of zombies makes shooting dead things unnecessary :P
     if (self.firecheck_flags & TFL_FIRECHECK_DEAD)
@@ -510,22 +510,22 @@ float turret_stdproc_firecheck()
     if (self.firecheck_flags & TFL_FIRECHECK_OTHER_AMMO)
         if (self.enemy.ammo >= self.enemy.ammo_max)
             return 0;
-       
+
        // Target of opertunity?
        if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0)
        {
                self.enemy = self.tur_impactent;
                return 1;
-       }                               
+       }
 
     if (self.firecheck_flags & TFL_FIRECHECK_DISTANCES)
     {
         // To close?
         if (self.tur_dist_aimpos < self.target_range_min)
-                       if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0)                    
+                       if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0)
                                return 1; // Target of opertunity?
-                       else 
-                               return 0;                               
+                       else
+                               return 0;
     }
 
     // Try to avoid FF?
@@ -571,7 +571,7 @@ float turret_stdproc_firecheck()
 float turret_validate_target(entity e_turret, entity e_target, float validate_flags)
 {
     vector v_tmp;
-        
+
     //if(!validate_flags & TFL_TARGETSELECT_NOBUILTIN)
     //    return -0.5;
 
@@ -579,7 +579,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
         return -0.5;
 
     if (!checkpvs(e_target.origin, e_turret))
-        return -1;        
+        return -1;
 
     if (!e_target)
         return -2;
@@ -596,7 +596,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
         return -5;
 
     // Cant touch this
-    if(e_target.vehicle_flags & VHF_ISVEHICLE)    
+    if(e_target.vehicle_flags & VHF_ISVEHICLE)
     {
         if (e_target.vehicle_health <= 0)
             return -6;
@@ -677,10 +677,10 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
 
     if (validate_flags & TFL_TARGETSELECT_ANGLELIMITS)
     {
-        if (fabs(tvt_tadv_x) > e_turret.aim_maxpitch)
+        if (fabs(tvt_tadv.x) > e_turret.aim_maxpitch)
             return -17;
 
-        if (fabs(tvt_tadv_y) > e_turret.aim_maxrot)
+        if (fabs(tvt_tadv.y) > e_turret.aim_maxrot)
             return -18;
     }
 
@@ -729,7 +729,7 @@ entity turret_select_target()
     e = findradius(self.origin, self.target_range);
 
     // Nothing to aim at?
-    if (!e) 
+    if (!e)
                return world;
 
     while (e)
@@ -759,7 +759,7 @@ void turret_think()
     entity e;
 
     self.nextthink = time + self.ticrate;
-    
+
     // ONS uses somewhat backwards linking.
     if (teamplay)
     {
@@ -788,7 +788,7 @@ void turret_think()
     if (!(self.spawnflags & TSF_NO_AMMO_REGEN))
     if (self.ammo < self.ammo_max)
         self.ammo = min(self.ammo + self.ammo_recharge, self.ammo_max);
-                       
+
     // Inactive turrets needs to run the think loop,
     // So they can handle animation and wake up if need be.
     if (!self.active)
@@ -980,7 +980,7 @@ void turret_stdproc_use()
 
 void turret_link()
 {
-    Net_LinkEntity(self, TRUE, 0, turret_send);
+    Net_LinkEntity(self, true, 0, turret_send);
     self.think      = turret_think;
     self.nextthink  = time;
     self.tur_head.effects = EF_NODRAW;
@@ -1021,14 +1021,14 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
     // Are turrets allowed?
     if (autocvar_g_turrets == 0)
         return 0;
-    
+
     if(_turret_type < 1 || _turret_type > TID_LAST)
     {
         dprint("Invalid / Unkown turret type\"", ftos(_turret_type), "\", aborting!\n");
         return 0;
-    }    
+    }
     self.turret_type = _turret_type;
-    
+
     e = find(world, classname, "turret_manager");
     if (!e)
     {
@@ -1037,28 +1037,15 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
         e.think = turrets_manager_think;
         e.nextthink = time + 2;
     }
-    
+
     if (!(self.spawnflags & TSF_SUSPENDED))
         builtin_droptofloor(); // why can't we use regular droptofloor here?
 
-    // Terrainbase spawnflag. This puts a enlongated model
-    // under the turret, so it looks ok on uneaven surfaces.
-    /*  TODO: Handle this with CSQC
-    if (self.spawnflags & TSF_TERRAINBASE)
-    {
-        entity tb;
-        tb = spawn();
-        setmodel(tb,"models/turrets/terrainbase.md3");
-        setorigin(tb,self.origin);
-        tb.solid = SOLID_BBOX;
-    }
-    */
-
     self.cvar_basename = cvar_base_name;
     load_unit_settings(self, self.cvar_basename, 0);
 
     self.effects = EF_NODRAW;
-    
+
     // Handle turret teams.
     if (!teamplay)
                self.team = MAX_SHOT_DISTANCE; // Group all turrets into the same team, so they dont kill eachother.
@@ -1082,13 +1069,13 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
     * as possible beforehand.
     */
     if (!self.ticrate)
-    {        
+    {
         if (self.turrcaps_flags & TFL_TURRCAPS_SUPPORT)
             self.ticrate = 0.2;     // Support units generaly dont need to have a high speed ai-loop
         else
             self.ticrate = 0.1;     // 10 fps for normal turrets
     }
-    
+
     self.ticrate = bound(sys_frametime, self.ticrate, 60);  // keep it sane
 
 // General stuff
@@ -1102,6 +1089,8 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
     if (!self.health)
         self.health = 1000;
     self.tur_health = max(1, self.health);
+    self.bot_attack = true;
+    self.monster_attack = true;
 
     if (!self.turrcaps_flags)
         self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
@@ -1272,7 +1261,7 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
 
 // Offsets & origins
     if (!self.tur_shotorg)   self.tur_shotorg = '50 0 50';
-    
+
     if (!self.health)
         self.health = 150;
 
@@ -1327,14 +1316,13 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
     self.turret_firecheckfunc   = turret_stdproc_firecheck;
     self.turret_firefunc        = turret_stdproc_fire;
     self.event_damage           = turret_stdproc_damage;
-    
+
     if (self.turrcaps_flags & TFL_TURRCAPS_SUPPORT)
         self.turret_score_target    = turret_stdproc_targetscore_support;
     else
         self.turret_score_target    = turret_stdproc_targetscore_generic;
 
     self.use = turret_stdproc_use;
-    self.bot_attack = TRUE;
 
     ++turret_count;
     self.nextthink = time + 1;
@@ -1348,9 +1336,9 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
     while (vlen(self.tur_dbg_rvec) < 2)
         self.tur_dbg_rvec  = randomvec() * 4;
 
-    self.tur_dbg_rvec_x = fabs(self.tur_dbg_rvec_x);
-    self.tur_dbg_rvec_y = fabs(self.tur_dbg_rvec_y);
-    self.tur_dbg_rvec_z = fabs(self.tur_dbg_rvec_z);
+    self.tur_dbg_rvec_x = fabs(self.tur_dbg_rvec.x);
+    self.tur_dbg_rvec_y = fabs(self.tur_dbg_rvec.y);
+    self.tur_dbg_rvec_z = fabs(self.tur_dbg_rvec.z);
 #endif
 
     // Its all good.
@@ -1366,11 +1354,11 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa
         activator = ee;
         self.use();
     }
-    
+
        turret_link();
-       turret_stdproc_respawn();           
+       turret_stdproc_respawn();
     turret_tag_fire_update();
-    
+
     return 1;
 }