]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_damage.qc
Merge branch 'master' into martin-t/okc3
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
index e9ab3d79ac945a2fa9cec1cf2a392b16aa72fbe0..644b2ea15e5b657e753da6a302630a0102d07d27 100644 (file)
@@ -566,6 +566,12 @@ void Unfreeze(entity targ, bool reset_health)
        MUTATOR_CALLHOOK(Unfreeze, targ);
 }
 
+float autocvar_g_balance_damagepush_scaling_speed_min;
+float autocvar_g_balance_damagepush_scaling_speed_max;
+float autocvar_g_balance_damagepush_scaling_reduction_slowest;
+float autocvar_g_balance_damagepush_scaling_reduction_fastest;
+float autocvar_g_balance_damagepush_scaling_sideways;
+float autocvar_g_balance_damagepush_scaling_vertical;
 void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
        float complainteamdamage = 0;
@@ -833,6 +839,33 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
        if (!IS_PLAYER(targ) || time >= targ.spawnshieldtime || targ == attacker)
        {
                vector farce = damage_explosion_calcpush(targ.damageforcescale * force, targ.velocity, autocvar_g_balance_damagepush_speedfactor);
+
+               if (targ == attacker && DEATH_ISWEAPON(deathtype, WEP_BLASTER)) {
+                       if (vec2(targ.velocity) == '0 0 0') {
+                               // using vectoangles here would give weird results (v_forward would point up)
+                               makevectors(targ.angles);
+                       } else {
+                               vector horiz_vel = vec2(targ.velocity);
+                               makevectors(vectoangles(horiz_vel));
+                       }
+
+                       // split farce into 3 perpendicular vectors
+                       v_forward *= v_forward * farce;
+                       v_right *= v_right * farce;
+                       v_up *= v_up * farce;
+                       //LOG_INFOF("farce vlen %f - sizes: %f %f %f", vlen(farce), vlen(v_forward), vlen(v_right), vlen(v_up));
+
+                       float reduction = map_bound_ranges(vlen(targ.velocity),
+                               autocvar_g_balance_damagepush_scaling_speed_min, autocvar_g_balance_damagepush_scaling_speed_max,
+                               autocvar_g_balance_damagepush_scaling_reduction_slowest, autocvar_g_balance_damagepush_scaling_reduction_fastest);
+                       //LOG_INFOF("reduction %f", reduction);
+                       v_forward -= reduction * v_forward;
+                       v_right -= (reduction * autocvar_g_balance_damagepush_scaling_sideways) * v_right;
+                       v_up -= (reduction * autocvar_g_balance_damagepush_scaling_vertical) * v_up;
+                       farce = v_forward + v_right + v_up;
+                       //LOG_INFOF("farce vlen %f - sizes: %f %f %f", vlen(farce), vlen(v_forward), vlen(v_right), vlen(v_up));
+               }
+
                if(targ.move_movetype == MOVETYPE_PHYSICS)
                {
                        entity farcent = new(farce);