]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use W_PrepareExplosionByDamage. Clean up turrets csqc a bit. Fix accidental use of...
authorJakob MG <jakob_mg@hotmail.com>
Tue, 11 Oct 2011 16:00:50 +0000 (18:00 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Tue, 11 Oct 2011 16:00:50 +0000 (18:00 +0200)
qcsrc/client/tturrets.qc
qcsrc/server/tturrets/system/system_damage.qc
qcsrc/server/tturrets/system/system_main.qc
qcsrc/server/tturrets/system/system_scoreprocs.qc
qcsrc/server/tturrets/units/unit_common.qc [deleted file]
qcsrc/server/tturrets/units/unit_flac.qc
qcsrc/server/tturrets/units/unit_mlrs.qc
qcsrc/server/tturrets/units/unit_walker.qc

index 95efb4cc61c730d822a75fcc50afed9e36bf3c1b..16d13cf2259e7f7c62ea9211858c68651ed41b78 100644 (file)
@@ -17,7 +17,6 @@ void turret_precache(float _tid)
 {    
     if (!turret_is_precache[TID_COMMON])
     {
-        dprint("turret_precache TID_COMMON\n");
         precache_sound ("weapons/rocket_impact.wav");
         precache_model ("models/turrets/base-gib1.md3");
         precache_model ("models/turrets/base-gib2.md3");
@@ -33,12 +32,7 @@ void turret_precache(float _tid)
     }
     turret_tid2info(_tid);
     if(turret_is_precache[_tid])
-    {
-        dprint("turret_precache: ", tid2info_name, " allready precachd, skipping.\n");
         return;
-    }
-    else
-        dprint("turret_precache: ", tid2info_name, " precaching.\n");
 
     switch(_tid)
     {
@@ -158,13 +152,11 @@ void turret_tid2info(float _tid)
 }
 
 void turret_remove()
-{
-    turret_tid2info(self.turret_type);
-    dprint("Removing ", tid2info_name, " turrret.\n");
-    
+{    
     remove(self.tur_head);
     self.tur_head = world;    
 }
+
 .vector glowmod;
 void turret_changeteam()
 {      
@@ -189,8 +181,6 @@ void turret_changeteam()
        
        if(self.team)
         self.colormap = 1024 + (self.team - 1) * 17;
-       else
-           self.colormap = 1024 + (1 + rint(random() * 3) - 1) * 17;           
        
        self.tur_head.colormap = self.colormap;
        self.tur_head.glowmod = self.glowmod;
@@ -217,19 +207,17 @@ void turret_draw()
     {
         dt = random();
         
-        if(dt < 0.25)
-            te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);    
-        
+        if(dt < 0.03)
+            te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);        
     }
     
-    if(self.health < 85)    
-    if(dt < 0.05)
-        pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);        
+    if(self.health < 85)
+    if(dt < 0.01)
+        pointparticles(particleeffectnum("smoke_large"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
     
     if(self.health < 32)
-    if(dt < 0.1)
-        pointparticles(particleeffectnum("smoke_large"), (self.origin + (randomvec() * 80)), '0 0 0', 1);        
-    
+    if(dt < 0.015)
+        pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);        
 }
 
 void turret_walker_draw()
@@ -290,14 +278,19 @@ void turret_construct()
         self.tur_head = spawn();
     
     turret_tid2info(self.turret_type);
-    dprint("Constructing ", tid2info_name , " turret (", ftos(self.turret_type), ")\n");
 
     setorigin(self, self.origin);
     setmodel(self, tid2info_base);
     setmodel(self.tur_head, tid2info_head);
     setsize(self, tid2info_min, tid2info_max);
     setsize(self.tur_head, '0 0 0', '0 0 0');
-    setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
+    
+    if(self.turret_type == TID_EWHEEL)
+       setorigin(self.tur_head, '0 0 0');
+    else if (self.turret_type == TID_WALKER)
+        setorigin(self.tur_head, '0 0 0');
+    else
+        setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
 
     self.tur_head.classname     = "turret_head";
     self.tur_head.owner         = self;
@@ -339,7 +332,7 @@ void turret_gib_draw()
     Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
     
     self.drawmask = MASK_NORMAL;
-       
+       
        if(self.cnt)
        {
            if(time >= self.nextthink)
@@ -364,13 +357,17 @@ void turret_gibboom()
     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
 
     for (i = 1; i < 5; i = i + 1)
-        turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin, self.velocity + randomvec() * 700, '0 0 0', FALSE);
+        turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', FALSE);
 }
 
 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
 {
     entity gib;
-
+    
+    traceline(_from, _to, MOVE_NOMONSTERS, world);
+    if(trace_startsolid)
+        return world;
+    
     gib = spawn();
     setorigin(gib, _from);
     setmodel(gib, _model);
@@ -378,7 +375,7 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
        gib.solid       = SOLID_CORPSE;
     gib.draw        = turret_gib_draw;    
     gib.cnt         = _explode;
-    
+    setsize(gib, '-1 -1 -1', '1 1 1');
     if(_explode)
     {
         gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
@@ -394,6 +391,7 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
        gib.move_avelocity  = prandomvec() * 32;
        gib.move_time       = time;
        gib.damageforcescale = 1;
+       gib.classname = "turret_gib";
        
        return gib;
 }
@@ -402,37 +400,40 @@ void turret_die()
 {    
     entity headgib;
     
-    setmodel(self, "");
-    setmodel(self.tur_head, "");
     sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
     turret_tid2info(self.turret_type);
-    dprint("Turret ", tid2info_name, " dies.\n");
     
     // Base
     if(self.turret_type == TID_EWHEEL)
-        turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
+        turret_gibtoss(tid2info_base, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', TRUE);
     else if (self.turret_type == TID_WALKER)
-        turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
+        turret_gibtoss(tid2info_base, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', TRUE);
     else if (self.turret_type == TID_TESLA)
-        turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
+        turret_gibtoss(tid2info_base, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', FALSE);
     else
     {        
         if (random() > 0.5)
-        {
-            turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
-            turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
-            turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
+        {            
+            turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
+            turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
+            turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
         }
         else
-            turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 4', '0 0 0', '0 0 0', TRUE);
+            turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 8', '0 0 0', '0 0 0', TRUE);
+
+        headgib = turret_gibtoss(tid2info_head, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', TRUE);
+        if(headgib)
+        {
+            headgib.angles = headgib.move_angles = self.tur_head.angles;
+            headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
+            headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
+            headgib.gravity = 0.5;        
+        }
     }
     
-    headgib = turret_gibtoss(tid2info_head, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', TRUE);
-    headgib.angles = headgib.move_angles = self.tur_head.angles;
-    headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
-    headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
-    headgib.gravity = 0.5;
+    setmodel(self, "null");
+    setmodel(self.tur_head, "null");
 }
 
 void ent_turret()
@@ -453,12 +454,10 @@ void ent_turret()
            
            turret_precache(self.turret_type);
            turret_construct();
-           self.colormap = 1024; // + (1 + rint(random() * 3) - 1) * 17;               
+           self.colormap = 1024;
            self.glowmod = '0 1 1'; 
            self.tur_head.colormap = self.colormap;
            self.tur_head.glowmod = self.glowmod;
-           
-           //turret_changeteam();
     }
     
     if(sf & TNSF_ANG)
@@ -500,18 +499,19 @@ void ent_turret()
 
     if(sf & TNSF_STATUS)
     {
-        float _team;
-        _team = ReadByte();
-        //_team -= 1; // /&)=(%&#)&%)/#&)=½!!!½!!". thanks.
-        self.health = ReadByte();
-        if(_team != self.team)
-        {
-            self.team = _team;
+        float _tmp;
+        _tmp = ReadByte();        
+        if(_tmp != self.team)
+        {            
+            self.team = _tmp;                
             turret_changeteam();
         }
         
-        if(self.health == 0)
+        _tmp = ReadByte();        
+        if(_tmp == 0 && self.health != 0)
             turret_die();
+
+        self.health = _tmp;
     } 
     
 }
index 8daad2734101a1e53f8ebe5f42bf599effa7e0eb..de8e5c8fa375f9725b7e00b43e366064249e8a41 100644 (file)
@@ -113,7 +113,6 @@ void turret_stdproc_damage (entity inflictor, entity attacker, float damage, flo
         self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
         
         self.SendFlags  |= TNSF_ANG;
-
     }
 
     if (self.turrcaps_flags & TFL_TURRCAPS_MOVE)
index b4ee78139c21c6e31538fa7b2ad781de13ef1725..91956fb45e28ef1649bcaddf8ecd295de90d67d9 100644 (file)
@@ -143,9 +143,9 @@ void load_unit_settings(entity ent, string unitname, float is_reload)
 
 void turret_projectile_explode()
 {
-    self.takedamage = DAMAGE_NO;
-    self.event_damage = SUB_Null;
     
+    self.takedamage = DAMAGE_NO;
+    self.event_damage = SUB_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);
@@ -169,7 +169,7 @@ void turret_projectile_damage(entity inflictor, entity attacker, float damage, f
     self.health    -= damage;
     //self.realowner  = attacker; // Dont change realowner, it does not make much sense for turrets
     if(self.health <= 0)
-        turret_projectile_explode();
+        W_PrepareExplosionByDamage(self.owner, turret_projectile_explode);
 }
 
 entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
index 316d45bbced89e0e467e7f8436bd5ecd7536a85e..05717bf184dab0401ec6bc21c1417772185a0827 100644 (file)
@@ -59,7 +59,7 @@ float turret_stdproc_targetscore_generic(entity _turret, entity _target)
 
     if(_turret.target_range < vlen(_turret.tur_shotorg - real_origin(_target)))
     {
-        dprint("Wtf?\n");
+        //dprint("Wtf?\n");
         score *= 0.001;
     }
 
diff --git a/qcsrc/server/tturrets/units/unit_common.qc b/qcsrc/server/tturrets/units/unit_common.qc
deleted file mode 100644 (file)
index 8b13789..0000000
+++ /dev/null
@@ -1 +0,0 @@
-
index 9033f5d83d2874181c7cd11d6b421db889398b62..975abbd4c928254ec566a3d8858df8ad67b3f28a 100644 (file)
@@ -7,10 +7,7 @@ void turret_flac_projectile_think_explode()
     if(self.enemy != world)
     if(vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3)
         setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
-        
-    self.takedamage = DAMAGE_NO;
-    self.event_damage = SUB_Null;
-    
+            
 #ifdef TURRET_DEBUG
     float d;
     d = RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg, self.owner.shot_radius, self, self.owner.shot_force, self.totalfrags, world);
index f17af05d9bfca624c4e5d492e74192340aa085df..57c08083861c2f916323b1411410dbdfec56670b 100644 (file)
@@ -11,7 +11,6 @@ void turret_mlrs_postthink()
        dprint("ammo:",ftos(self.ammo),"\n");
        dprint("shot_dmg:",ftos(self.shot_dmg),"\n");
     }
-    
 }
 
 void turret_mlrs_attack()
@@ -20,8 +19,8 @@ void turret_mlrs_attack()
     
     turret_tag_fire_update();    
     missile = turret_projectile("weapons/rocket_fire.wav", 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
-    te_explosion (missile.origin);
     missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
+    te_explosion (missile.origin);    
 }
 
 void turret_mlrs_dinit()
index feb4b1f67536bdf8ed3fc879d8db5a498a8809fa..9a9140b455a13c4593be2482cb91d3809cd4f067 100644 (file)
@@ -54,6 +54,7 @@ void walker_rocket_explode()
     if (self.event_damage != SUB_Null)
     {
         self.event_damage = SUB_Null;
+        self.takedamage = DAMAGE_NO;
         self.think = walker_rocket_explode;
         self.nextthink = time;
         return;
@@ -556,8 +557,14 @@ void walker_respawnhook()
             dprint("Warning: not a turrret path\n");
         else
         {
-            self.pathcurrent = WALKER_PATH(self.origin,e.origin);
+ #ifdef WALKER_FANCYPATHING
+            self.pathcurrent = WALKER_PATH(self.origin, e.origin);
             self.pathgoal = e;
+#else
+            self.pathcurrent = e;
+#endif
+           //self.pathcurrent = WALKER_PATH(self.origin,e.origin);
+            //self.pathgoal = e;
         }
     }
 }