]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Vampire mutator: fix console tracebacks when damage is done by non-players. Add two...
authorMorosophos <morosophos@teichisma.info>
Wed, 10 Jul 2019 17:58:34 +0000 (20:58 +0300)
committerMorosophos <morosophos@teichisma.info>
Wed, 10 Jul 2019 17:58:34 +0000 (20:58 +0300)
mutators.cfg
qcsrc/common/mutators/mutator/vampire/sv_vampire.qc

index 7e1c0358330e3c9c7abb5b02fb29dcc3c693eb0a..01e3a120a4285698382d3c408ef220b927bf87c8 100644 (file)
@@ -69,6 +69,8 @@ set g_overkill_filter_armormega 0
 //  vampire
 // =========
 set g_vampire 0 "set to 1 to enable the vampire mode, where the damage done to your opponent gets added to your own health"
+set g_vampire_factor 1.0 "Multiply damage done by this factor before adding it to the player's health"
+set g_vampire_use_total_damage 0 "If 1 then add combined damage (health + armor) to attackers health. If 0 add only health damage."
 
 
 // ========
index 57df1b02bf205ab9e8160c20c90998a77c393cc2..08ced807441710bead6aa80c690f1e9657af697f 100644 (file)
@@ -1,20 +1,25 @@
 #include "sv_vampire.qh"
 
 string autocvar_g_vampire;
+float autocvar_g_vampire_factor = 1.0;
+bool autocvar_g_vampire_use_total_damage = false;
+
 REGISTER_MUTATOR(vampire, expr_evaluate(autocvar_g_vampire) && !MUTATOR_IS_ENABLED(mutator_instagib));
 
 MUTATOR_HOOKFUNCTION(vampire, PlayerDamage_SplitHealthArmor)
 {
        entity frag_attacker = M_ARGV(1, entity);
        entity frag_target = M_ARGV(2, entity);
-       float damage_take = M_ARGV(4, float);
+       float health_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
+        float armor_take = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
+        float damage_take = (autocvar_g_vampire_use_total_damage) ? health_take + armor_take : health_take;
 
        if(time >= frag_target.spawnshieldtime)
        if(frag_target != frag_attacker)
+        if(IS_PLAYER(frag_attacker))
        if(!IS_DEAD(frag_target))
        {
-               GiveResource(frag_attacker, RES_HEALTH,
-                       bound(0, damage_take, GetResource(frag_target, RES_HEALTH)));
+               GiveResource(frag_attacker, RES_HEALTH, autocvar_g_vampire_factor * damage_take);
        }
 }