]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
W_CheckProjectileDamage -- new global weapon function which check g_projectiles_damag...
authorSamual <samual@xonotic.org>
Fri, 30 Sep 2011 04:46:22 +0000 (00:46 -0400)
committerSamual <samual@xonotic.org>
Fri, 30 Sep 2011 04:46:22 +0000 (00:46 -0400)
// possible values:
// -2: absolutely no damage to projectiles (no exceptions)
// -1: no damage other than the exceptions (electro combo, hagar join explode, minelayer mines)
// 0: only damage from contents (lava/slime) or exceptions
// 1: only self damage or damage from contents or exceptions
// 2: allow all damage to projectiles normally

16 files changed:
balance25.cfg
balanceFruit.cfg
balanceLeeStricklin.cfg
balanceXonotic.cfg
balancetZork.cfg
qcsrc/server/autocvars.qh
qcsrc/server/g_hook.qc
qcsrc/server/w_common.qc
qcsrc/server/w_electro.qc
qcsrc/server/w_fireball.qc
qcsrc/server/w_grenadelauncher.qc
qcsrc/server/w_hagar.qc
qcsrc/server/w_hook.qc
qcsrc/server/w_minelayer.qc
qcsrc/server/w_rocketlauncher.qc
qcsrc/server/w_seeker.qc

index edaa785121be27831af16e695efb603384a0e6fc..12c56c9078b2a86c57417f161a4b94000406182e 100644 (file)
@@ -155,6 +155,13 @@ set g_balance_firetransfer_time 0.9
 set g_balance_firetransfer_damage 0.8
 set g_throughfloor_damage 1
 set g_throughfloor_force 1
+set g_projectiles_damage 1
+// possible values:
+// -2: absolutely no damage to projectiles (no exceptions)
+// -1: no damage other than the exceptions (electro combo, hagar join explode, minelayer mines)
+// 0: only damage from contents (lava/slime) or exceptions 
+// 1: only self damage or damage from contents or exceptions
+// 2: allow all damage to projectiles normally
 set g_projectiles_newton_style 2
 // possible values:
 // 0: absolute velocity projectiles (like Quake)
index 84bfea542b8448c9aaa7bc6f1dc1658ddc05d45c..2ec1c23bf1be6585b1b3b66f2936df26cb3e6e7c 100644 (file)
@@ -155,6 +155,13 @@ set g_balance_firetransfer_time 0.9
 set g_balance_firetransfer_damage 0.8
 set g_throughfloor_damage 0.7
 set g_throughfloor_force 0.8
+set g_projectiles_damage 1
+// possible values:
+// -2: absolutely no damage to projectiles (no exceptions)
+// -1: no damage other than the exceptions (electro combo, hagar join explode, minelayer mines)
+// 0: only damage from contents (lava/slime) or exceptions 
+// 1: only self damage or damage from contents or exceptions
+// 2: allow all damage to projectiles normally
 set g_projectiles_newton_style 2
 // possible values:
 // 0: absolute velocity projectiles (like Quake)
index 121853d25ddf45b91fb35bc1c4229ee9ada5cb3e..3c9749c36900519b6c39b286bfcdeee899e2b809 100644 (file)
@@ -155,6 +155,13 @@ set g_balance_firetransfer_time 0.9
 set g_balance_firetransfer_damage 0.8
 set g_throughfloor_damage 0.4
 set g_throughfloor_force 0.7
+set g_projectiles_damage 1
+// possible values:
+// -2: absolutely no damage to projectiles (no exceptions)
+// -1: no damage other than the exceptions (electro combo, hagar join explode, minelayer mines)
+// 0: only damage from contents (lava/slime) or exceptions 
+// 1: only self damage or damage from contents or exceptions
+// 2: allow all damage to projectiles normally
 set g_projectiles_newton_style 2
 // possible values:
 // 0: absolute velocity projectiles (like Quake)
index 603f158ec90b7d5d9cad057082d52d6b16a46f53..63f084317a083df87a9fd7a5ff90b9d56199868b 100644 (file)
@@ -155,6 +155,13 @@ set g_balance_firetransfer_time 0.9
 set g_balance_firetransfer_damage 0.8
 set g_throughfloor_damage 0.5
 set g_throughfloor_force 0.75
+set g_projectiles_damage 1
+// possible values:
+// -2: absolutely no damage to projectiles (no exceptions)
+// -1: no damage other than the exceptions (electro combo, hagar join explode, minelayer mines)
+// 0: only damage from contents (lava/slime) or exceptions 
+// 1: only self damage or damage from contents or exceptions
+// 2: allow all damage to projectiles normally
 set g_projectiles_newton_style 2
 // possible values:
 // 0: absolute velocity projectiles (like Quake)
index 4a8e32410b80ef3c2171d4ce6d4fa59ed7a1cd67..07b35e2ee198a3ae0ab0863db0ca5e97e2e9413e 100644 (file)
@@ -155,6 +155,13 @@ set g_balance_firetransfer_time 0.9
 set g_balance_firetransfer_damage 0.8
 set g_throughfloor_damage 0.5
 set g_throughfloor_force 0.7
+set g_projectiles_damage 1
+// possible values:
+// -2: absolutely no damage to projectiles (no exceptions)
+// -1: no damage other than the exceptions (electro combo, hagar join explode, minelayer mines)
+// 0: only damage from contents (lava/slime) or exceptions 
+// 1: only self damage or damage from contents or exceptions
+// 2: allow all damage to projectiles normally
 set g_projectiles_newton_style 2
 // possible values:
 // 0: absolute velocity projectiles (like Quake)
index 9be4bd39216215ce40d72c354ec7b9b60ef58966..894ccc23e32c2d8824b6d6f8998b8335b3c06208 100644 (file)
@@ -945,6 +945,7 @@ float autocvar_g_playerstats_debug;
 float autocvar_g_powerup_shield;
 float autocvar_g_powerup_strength;
 float autocvar_g_powerup_superhealth;
+float autocvar_g_projectiles_damage;
 float autocvar_g_projectiles_newton_style;
 float autocvar_g_projectiles_newton_style_2_maxfactor;
 float autocvar_g_projectiles_newton_style_2_minfactor;
index dfd68e2ecc4efc4ff92dc8b1ea2e9c2fef78e9b5..27a63c421034ff2c0fe20cb640bfa887304cb830 100644 (file)
@@ -271,21 +271,24 @@ void GrapplingHookTouch (void)
 
 void GrapplingHook_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
-       if(self.health > 0)
-       {
-               self.health = self.health - damage;
+       if(self.health <= 0)
+               return;
                
-               print(strcat("hook health ", ftos(self.health), " after ", ftos(damage), " damage... (at time: ", ftos(time), ")\n"));
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, 0)) // no exceptions
+               return; // g_balance_projectiledamage says to halt
+                       
+       self.health = self.health - damage;
                
-               if (self.health <= 0)
+       print(strcat("hook health ", ftos(self.health), " after ", ftos(damage), " damage... (at time: ", ftos(time), ")\n"));
+               
+       if (self.health <= 0)
+       {
+               if(attacker != self.realowner)
                {
-                       if(attacker != self.realowner)
-                       {
-                               self.realowner.pusher = attacker;
-                               self.realowner.pushltime = time + autocvar_g_maxpushtime;
-                       }
-                       RemoveGrapplingHook(self.realowner);
+                       self.realowner.pusher = attacker;
+                       self.realowner.pushltime = time + autocvar_g_maxpushtime;
                }
+               RemoveGrapplingHook(self.realowner);
        }
 }
 
index f1e33ec968aec26b989f22dd29c7c98786ac0242..dfd5c77b6975566a6e9a29fe0013af30d1466d7c 100644 (file)
@@ -541,6 +541,32 @@ void fireBullet (vector start, vector dir, float spread, float damage, float for
        trace_endpos = end;
 }
 
+float W_CheckProjectileDamage(entity inflictor, entity projowner, float deathtype, float exception)
+{
+       float is_from_contents = (deathtype == DEATH_SLIME || deathtype == DEATH_LAVA);
+       float is_from_owner = (inflictor == projowner);
+       
+       if(autocvar_g_projectiles_damage <= -2)
+                       return FALSE; // no damage to projectiles at all, not even with the exceptions
+                       
+       else if(autocvar_g_projectiles_damage == -1)
+               if not(exception)
+                       return FALSE; // no damage other than exceptions (electro combo, hagar join explode, minelayer mines)
+                       
+       else if(autocvar_g_projectiles_damage == 0)
+               if not(is_from_contents || exception)
+                       return FALSE; // only damage from contents or exceptions is allowed
+                       
+       else if(autocvar_g_projectiles_damage == 1)
+               if not(is_from_contents || is_from_owner || exception)
+                       return FALSE; // only self damage or damage from contents or exceptions is allowed 
+       
+       // -2 or lower disables all damage including exceptions
+       // 2 or higher automatically allows all damage normally 
+
+       return TRUE; // continue with the damage as planned
+}
+
 void W_PrepareExplosionByDamage(entity attacker, void() explode)
 {
        self.takedamage = DAMAGE_NO;
index 6253e50fc5c1ded299904b10eefebbfb42e79695..08b963431d7b5e1a8246caff05bdb4210f654c3f 100644 (file)
@@ -83,13 +83,19 @@ void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float dea
 {
        if(self.health <= 0)
                return;
+
        // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
+       float is_combo = (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim");
+       
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_combo))
+               return; // g_projectiles_damage says to halt    
+       
        self.health = self.health - damage;
        if (self.health <= 0)
        {
                self.takedamage = DAMAGE_NO;
                self.nextthink = time;
-               if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
+               if (is_combo)
                {
                        // change owner to whoever caused the combo explosion
                        self.realowner = inflictor.realowner;
index d916edd9f60e18005a6700223f5256f88cbc1d5d..dd85c5c855aed2351baf058a3d3d4bf8a78b6b17 100644 (file)
@@ -115,6 +115,10 @@ void W_Fireball_Damage (entity inflictor, entity attacker, float damage, float d
 {
        if(self.health <= 0)
                return;
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, 0)) // no exceptions
+               return; // g_projectiles_damage says to halt
+               
        self.health = self.health - damage;
        if (self.health <= 0)
        {
index 929b10528325160aa13c2b6500ac97b6cf20496f..7a405d30bc1d430742d85461f35f6590808755c1 100644 (file)
@@ -49,6 +49,10 @@ void W_Grenade_Damage (entity inflictor, entity attacker, float damage, float de
 {
        if (self.health <= 0)
                return;
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, 0)) // no exceptions
+               return; // g_projectiles_damage says to halt
+               
        self.health = self.health - damage;
        
        print(strcat("grenade health ", ftos(self.health), " after ", ftos(damage), " damage... (at time: ", ftos(time), ")\n"));
index 855a4a04cf66d48cee69663a5f919926dcf14514..2a3597eab8fe7035649cb0187e1e4a7e0826f80b 100644 (file)
@@ -25,8 +25,12 @@ void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deat
        if (self.health <= 0)
                return;
                
-       if ((inflictor.realowner == self.realowner) && !autocvar_g_balance_hagar_secondary_load_linkexplode)
-               return;
+       float is_linkexplode = ((inflictor.realowner == self.realowner) 
+               && ((inflictor.projectiledeathtype & HITTYPE_SECONDARY) && (self.projectiledeathtype & HITTYPE_SECONDARY))
+               && !autocvar_g_balance_hagar_secondary_load_linkexplode);
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
+               return; // g_projectiles_damage says to halt
 
        self.health = self.health - damage;
        self.angles = vectoangles(self.velocity);
@@ -186,7 +190,7 @@ void W_Hagar_Attack2_Load_Release (void)
                missile.think = adaptor_think2use_hittype_splash;
                missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
                PROJECTILE_MAKETRIGGER(missile);
-               missile.projectiledeathtype = WEP_HAGAR;
+               missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
                setorigin (missile, w_shotorg);
                setsize(missile, '0 0 0', '0 0 0');
                missile.movetype = MOVETYPE_FLY;
index d3c38fc0543717b331bc3c07ce790f12bf703691..85651882290df540571b5a8f55710240197154eb 100644 (file)
@@ -56,6 +56,10 @@ void W_Hook_Damage (entity inflictor, entity attacker, float damage, float death
 {
        if (self.health <= 0)
                return;
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, 0)) // no exceptions
+               return; // g_projectiles_damage says to halt    
+       
        self.health = self.health - damage;
        
        print(strcat("hookbomb health ", ftos(self.health), " after ", ftos(damage), " damage... (at time: ", ftos(time), ")\n"));
index af60af14e12fde2302e6e2ce96ad688ff95235f3..efb9f7dbe503cf316dc4247fd470744e143768dc 100644 (file)
@@ -242,6 +242,12 @@ void W_Mine_Damage (entity inflictor, entity attacker, float damage, float death
 {
        if (self.health <= 0)
                return;
+               
+       float is_from_enemy = (inflictor.realowner != self.realowner);
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_from_enemy))
+               return; // g_projectiles_damage says to halt
+               
        self.health = self.health - damage;
        self.angles = vectoangles(self.velocity);
        
index 1c0b5a8b5c103da5e93cbb92feeabae90a3811d7..3a1bc9699665f2ec871da2174f4c22a67aed2a98 100644 (file)
@@ -238,6 +238,10 @@ void W_Rocket_Damage (entity inflictor, entity attacker, float damage, float dea
 {
        if (self.health <= 0)
                return;
+       
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, 0)) // no exceptions
+               return; // g_projectiles_damage says to halt
+               
        self.health = self.health - damage;
        self.angles = vectoangles(self.velocity);
        
index 326680cbd8a8d2ff9629a73b91ee7c60b326ab29..72cd9085a0c39c3edb7f95b2f0237a09f539656b 100644 (file)
@@ -124,6 +124,9 @@ void Seeker_Missile_Damage (entity inflictor, entity attacker, float damage, flo
 {
        if (self.health <= 0)
                return;
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, 0)) // no exceptions
+               return; // g_projectiles_damage says to halt
 
        if (self.realowner == attacker)
                self.health = self.health - (damage * 0.25);