diff --git a/src/scripting/vmiterators.cpp b/src/scripting/vmiterators.cpp index f6a9c30b7..7762d176b 100644 --- a/src/scripting/vmiterators.cpp +++ b/src/scripting/vmiterators.cpp @@ -420,13 +420,16 @@ public: Reinit(); } - DBehaviorIterator(const FLevelLocals& level, PClass* type) + DBehaviorIterator(const FLevelLocals& level, PClass* type, PClass* ownerType) { for (auto& b : level.ActorBehaviors) { if (b == nullptr || (b->ObjectFlags & OF_EuthanizeMe)) continue; + if (ownerType != nullptr && !b->Owner->IsKindOf(ownerType)) + continue; + if (type == nullptr || b->IsKindOf(type)) _behaviors.Push(b); } @@ -466,16 +469,17 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBehaviorIterator, CreateFrom, CreateBehaviorItFro ACTION_RETURN_OBJECT(CreateBehaviorItFromActor(mobj, type)); } -static DBehaviorIterator* CreateBehaviorIt(PClass* type) +static DBehaviorIterator* CreateBehaviorIt(PClass* type, PClass* ownerType) { - return Create(*primaryLevel, type); + return Create(*primaryLevel, type, ownerType); } DEFINE_ACTION_FUNCTION_NATIVE(DBehaviorIterator, Create, CreateBehaviorIt) { PARAM_PROLOGUE; PARAM_CLASS(type, DBehavior); - ACTION_RETURN_OBJECT(CreateBehaviorIt(type)); + PARAM_CLASS(ownerType, AActor); + ACTION_RETURN_OBJECT(CreateBehaviorIt(type, ownerType)); } static DBehavior* NextBehavior(DBehaviorIterator* self) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 6f8577855..5d24f34b0 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -86,7 +86,7 @@ class Behavior native play abstract class BehaviorIterator native abstract final { native static BehaviorIterator CreateFrom(Actor mobj, class type = null); - native static BehaviorIterator Create(class type = null); + native static BehaviorIterator Create(class type = null, class ownerType = null); native Behavior Next(); native void Reinit();