From: Lyberta Date: Tue, 27 Mar 2018 23:05:20 +0000 (+0300) Subject: Added ResourceAmountChanged hook. X-Git-Tag: xonotic-v0.8.5~2204^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8e89e7844b71e89d284e10082b012eeb4d86a196;p=xonotic%2Fxonotic-data.pk3dir.git Added ResourceAmountChanged hook. --- diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index f0112a519..165353fff 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -679,6 +679,15 @@ constants for resource types. Return true to forbid the change. */ /**/ MUTATOR_HOOKABLE(SetResourceAmount, EV_SetResourceAmount); +/** Called after the amount of resource of an entity has changed. See RESOURCE_* +constants for resource types. */ +#define EV_ResourceAmountChanged(i, o) \ + /** checked entity */ i(entity, MUTATOR_ARGV_0_entity) \ + /** resource type */ i(int, MUTATOR_ARGV_1_int) \ + /** amount */ i(float, MUTATOR_ARGV_2_float) \ + /**/ +MUTATOR_HOOKABLE(ResourceAmountChanged, EV_ResourceAmountChanged); + /** Called when entity is being given some resource. See RESOURCE_* constants for resource types. Return true to forbid giving. */ #define EV_GiveResource(i, o) \ diff --git a/qcsrc/server/resources.qc b/qcsrc/server/resources.qc index c53cf7ad8..23cdea096 100644 --- a/qcsrc/server/resources.qc +++ b/qcsrc/server/resources.qc @@ -94,6 +94,7 @@ void SetResourceAmount(entity e, int resource_type, float amount) amount = max_amount; } e.(resource_field) = amount; + MUTATOR_CALLHOOK(ResourceAmountChanged, e, resource_type, amount); } void GiveResource(entity receiver, int resource_type, float amount)