]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_common.qc
Merge branch 'master' into fruitiex/gamemode_freezetag
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_common.qc
index ec307528a0984f4bfdf64ab47d7c05c3532407d3..0b405ba77e8043dc2d73e7edf7a1155aa8f7554a 100644 (file)
@@ -1,3 +1,4 @@
+
 void W_GiveWeapon (entity e, float wep, string name)
 {
        entity oldself;
@@ -269,7 +270,7 @@ float W_BallisticBullet_LeaveSolid(entity e, vector vel, float constant)
 
        self.W_BallisticBullet_LeaveSolid_origin = trace_endpos;
 
-       dst = vlen(trace_endpos - self.origin);
+       dst = max(cvar("g_ballistics_mindistance"), vlen(trace_endpos - self.origin));
        // E(s) = E0 - constant * s, constant = area of bullet circle * material constant / mass
        Es_m = E0_m - constant * dst;
        if(Es_m <= 0)
@@ -301,14 +302,20 @@ float W_BallisticBullet_LeaveSolid(entity e, vector vel, float constant)
 
 void W_BallisticBullet_Touch (void)
 {
+       float density;
+
        if(self.think == W_BallisticBullet_LeaveSolid_think) // skip this!
                return;
 
        PROJECTILE_TOUCH;
        W_BallisticBullet_Hit ();
 
+       density = other.ballistics_density;
+       if(density == 0)
+               density = 1;
+
        // go through solid!
-       if(!W_BallisticBullet_LeaveSolid(self, self.velocity, self.dmg_radius))
+       if(!W_BallisticBullet_LeaveSolid(self, self.velocity, self.dmg_radius * density))
        {
                remove(self);
                return;
@@ -332,7 +339,7 @@ void fireBallisticBullet_trace_callback(vector start, vector hit, vector end)
 
 void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, float lifetime, float damage, float headshotbonus, float force, float dtype, float tracereffects, float gravityfactor, float bulletconstant)
 {
-       float lag, dt, savetime;
+       float lag, dt, savetime, density;
        entity pl, oldself;
 
        entity proj;
@@ -364,6 +371,8 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
 
        proj.oldvelocity = proj.velocity;
 
+       other = proj; MUTATOR_CALLHOOK(EditProjectile);
+
        if(cvar("g_antilag_bullets"))
        if(pSpeed >= cvar("g_antilag_bullets"))
        {
@@ -438,8 +447,12 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
                                W_BallisticBullet_Hit();
                        }
 
+                       density = other.ballistics_density;
+                       if(density == 0)
+                               density = 1;
+
                        // go through solid!
-                       if(!W_BallisticBullet_LeaveSolid(self, self.velocity, self.dmg_radius))
+                       if(!W_BallisticBullet_LeaveSolid(self, self.velocity, self.dmg_radius * density))
                                break;
 
                        W_BallisticBullet_LeaveSolid_think();
@@ -500,6 +513,7 @@ void W_PrepareExplosionByDamage(entity attacker, void() explode)
        self.takedamage = DAMAGE_NO;
        self.event_damage = SUB_Null;
        self.owner = attacker;
+       self.realowner = attacker;
 
        // do not explode NOW but in the NEXT FRAME!
        // because recursive calls to RadiusDamage are not allowed