]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/resources.qc
Set consistent rating scales in havocbot_goalrating_enemyplayers calls (no actual...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / resources.qc
index 254db749fff871eb3331024e58e048d7afa704b9..4ad66bb98ed2169380e7074ea23147a503e652cf 100644 (file)
@@ -83,17 +83,24 @@ void SetResourceAmount(entity e, int resource_type, float amount)
        }
        resource_type = M_ARGV(1, int);
        amount = M_ARGV(2, float);
-       .float resource_field = GetResourceField(resource_type);
-       if (e.(resource_field) == amount)
-       {
-               return;
-       }
        float max_amount = GetResourceLimit(e, resource_type);
+       float amount_wasted = 0;
        if (amount > max_amount)
        {
+               amount_wasted = amount - max_amount;
                amount = max_amount;
        }
-       e.(resource_field) = amount;
+       .float resource_field = GetResourceField(resource_type);
+       if (e.(resource_field) != amount)
+       {
+               e.(resource_field) = amount;
+               MUTATOR_CALLHOOK(ResourceAmountChanged, e, resource_type, amount);
+       }
+       if (amount_wasted == 0)
+       {
+               return;
+       }
+       MUTATOR_CALLHOOK(ResourceWasted, e, resource_type, amount_wasted);
 }
 
 void GiveResource(entity receiver, int resource_type, float amount)
@@ -157,7 +164,7 @@ void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
        resource_type = M_ARGV(1, int);
        amount = M_ARGV(2, float);
        limit = M_ARGV(3, float);
-       if (amount <= 0)
+       if (amount == 0)
        {
                return;
        }