diff --git a/src/gamedata/a_keys.cpp b/src/gamedata/a_keys.cpp index 406b0fbb8..86b01306f 100644 --- a/src/gamedata/a_keys.cpp +++ b/src/gamedata/a_keys.cpp @@ -516,6 +516,12 @@ int P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet) return false; } +// [MK] for ZScript, simply returns if a lock is defined or not +int P_ValidLock(int keynum) +{ + return !!Locks.CheckKey(keynum); +} + //========================================================================== // // These functions can be used to get color information for diff --git a/src/gamedata/a_keys.h b/src/gamedata/a_keys.h index 15c19c017..40385a93f 100644 --- a/src/gamedata/a_keys.h +++ b/src/gamedata/a_keys.h @@ -5,6 +5,7 @@ class AActor; class PClassActor; int P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet = false); +int P_ValidLock (int lock); void P_InitKeyMessages (); int P_GetMapColorForLock (int lock); int P_GetMapColorForKey (AActor *key); diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 8b7edabc2..f91bb51b2 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -1749,6 +1749,27 @@ DEFINE_ACTION_FUNCTION_NATIVE(AInventory, PrintPickupMessage, PrintPickupMessage // //===================================================================================== +DEFINE_ACTION_FUNCTION_NATIVE(AKey, ValidLock, P_ValidLock) +{ + PARAM_PROLOGUE; + PARAM_INT(locknum); + ACTION_RETURN_BOOL(P_ValidLock(locknum)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetMapColorForLock, P_GetMapColorForLock) +{ + PARAM_PROLOGUE; + PARAM_INT(locknum); + ACTION_RETURN_INT(P_GetMapColorForLock(locknum)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetMapColorForKey, P_GetMapColorForKey) +{ + PARAM_PROLOGUE; + PARAM_OBJECT(key, AActor); + ACTION_RETURN_INT(P_GetMapColorForKey(key)); +} + DEFINE_ACTION_FUNCTION_NATIVE(AKey, GetKeyTypeCount, P_GetKeyTypeCount) { PARAM_PROLOGUE; diff --git a/wadsrc/static/zscript/actors/inventory/inv_misc.zs b/wadsrc/static/zscript/actors/inventory/inv_misc.zs index a31efc5b1..09ce6436f 100644 --- a/wadsrc/static/zscript/actors/inventory/inv_misc.zs +++ b/wadsrc/static/zscript/actors/inventory/inv_misc.zs @@ -37,6 +37,9 @@ class Key : Inventory Inventory.PickupSound "misc/k_pkup"; } + static native clearscope bool ValidLock(int locknum); + static native clearscope Color GetMapColorForLock(int locknum); + static native clearscope Color GetMapColorForKey(Key key); static native clearscope int GetKeyTypeCount(); static native clearscope class GetKeyType(int index);