]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added ResourceAmountChanged hook.
authorLyberta <lyberta@lyberta.net>
Tue, 27 Mar 2018 23:05:20 +0000 (02:05 +0300)
committerLyberta <lyberta@lyberta.net>
Tue, 27 Mar 2018 23:05:20 +0000 (02:05 +0300)
qcsrc/server/mutators/events.qh
qcsrc/server/resources.qc

index f0112a51971c9f8157d71412ca78470972f041dd..165353fffefc5377a71456f4aa88b4126059c82e 100644 (file)
@@ -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) \
index c53cf7ad8c7f62993e89b0636568d799a795e860..23cdea096a111a85c1934932bfeab30009aac038 100644 (file)
@@ -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)