From 63277346599b6b32088864d51bce4f8ee2fac032 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sun, 3 Mar 2019 13:26:00 -0600 Subject: [PATCH] Added CanTouchItem virtual. - Allows an actor with +PICKUP flag to determine if it can pick up specific items or not. --- wadsrc/static/zscript/actors/actor.zs | 9 +++++++++ wadsrc/static/zscript/actors/inventory/inventory.zs | 3 +++ 2 files changed, 12 insertions(+) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 7e10aaf23..4fd3d46e3 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -460,6 +460,15 @@ class Actor : Thinker native native void Substitute(Actor replacement); native ui void DisplayNameTag(); + // Called by inventory items to see if this actor is capable of touching them. + // If true, the item will attempt to be picked up. Useful for things like + // allowing morphs to pick up limited items such as keys while preventing + // them from picking other items up. + virtual bool CanTouchItem(Inventory item) + { + return true; + } + // Called by PIT_CheckThing to check if two actors actually can collide. virtual bool CanCollideWith(Actor other, bool passive) { diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index b6dcea9a6..e8b984d02 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -768,6 +768,9 @@ class Inventory : Actor bool localview = toucher.CheckLocalView(); + if (!toucher.CanTouchItem(self)) + return; + bool res; [res, toucher] = CallTryPickup(toucher); if (!res) return;