diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index afbc036a6..04ed1c22c 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5635,16 +5635,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) PARAM_FLOAT (distance); PARAM_INT (flags); PARAM_INT_OPT (amount) { amount = 0; } - PARAM_CLASS_OPT (filter, AActor) { filter = NULL; } + PARAM_CLASS_OPT (filter, AActor) { filter = nullptr; } PARAM_NAME_OPT (species) { species = NAME_None; } PARAM_FLOAT_OPT (mindist) { mindist = 0; } + PARAM_INT_OPT (limit) { limit = 0; } // We need a valid item, valid targets, and a valid range - if (item == NULL || (flags & RGF_MASK) == 0 || !flags || distance <= 0 || mindist >= distance) + if (item == nullptr || (flags & RGF_MASK) == 0 || !flags || distance <= 0 || mindist >= distance) { ACTION_RETURN_INT(0); } - + bool unlimited = (limit <= 0); if (amount == 0) { amount = 1; @@ -5654,7 +5655,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) if (flags & RGF_MISSILES) { TThinkerIterator it; - while ((thing = it.Next())) + while ((thing = it.Next()) && ((unlimited) || (given < limit))) { given += DoRadiusGive(self, thing, item, amount, distance, flags, filter, species, mindist); } @@ -5666,7 +5667,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive) FMultiBlockThingsIterator it(check, self->X(), self->Y(), mid-distance, mid+distance, distance, false, self->Sector); FMultiBlockThingsIterator::CheckResult cres; - while ((it.Next(&cres))) + while ((it.Next(&cres)) && ((unlimited) || (given < limit))) { given += DoRadiusGive(self, cres.thing, item, amount, distance, flags, filter, species, mindist); } diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 44ebb1dc3..fbb16dc80 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -237,7 +237,7 @@ ACTOR Actor native //: Thinker native state A_JumpIfInTargetInventory(class itemtype, int amount, state label, int forward_ptr = AAPTR_DEFAULT); native bool A_GiveToTarget(class itemtype, int amount = 0, int forward_ptr = AAPTR_DEFAULT); native bool A_TakeFromTarget(class itemtype, int amount = 0, int flags = 0, int forward_ptr = AAPTR_DEFAULT); - native int A_RadiusGive(class itemtype, float distance, int flags, int amount = 0, class filter = "None", name species = "None", int mindist = 0); + native int A_RadiusGive(class itemtype, float distance, int flags, int amount = 0, class filter = "None", name species = "None", int mindist = 0, int limit = 0); native state A_CheckSpecies(state jump, name species = "", int ptr = AAPTR_DEFAULT); native void A_CountdownArg(int argnum, state targstate = ""); action native A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true);