TeamREPENTOGON / REPENTOGON

Script extender for The Binding of Isaac: Repentance
https://repentogon.com/
GNU General Public License v2.0
106 stars 11 forks source link

MC_PRE_CHEST_OPEN (and MC_POST_CHEST_OPEN) #463

Open pedroff1 opened 1 month ago

pedroff1 commented 1 month ago

I suggest a pair of callbacks triggered whenever a chest is open. They'd use the following params (EntityPickup chest, RNG rng,table SpawnedEntities). The AddCallback function would take PickupVariant as an additional parameter for only triggering on a specific kind of chest.

Returning any value doesn't affect the MC_POST_CHEST_OPEN callback, but the MC_PRE_CHEST_OPEN callback accepts the following table, with any combination of its values: {boolean CanOpen whether or not a chest will actually open. If returned false, will prevent future instances of the callback from running. table SpawnedEntities table with Type, Variant and SubType of entities spawned by it, with the following structure: {Type,(default = 0) Variant,(default = 0) SubType, (default = RandomVector()) Velocity} boolean OpenCost whether or not opening the chest will consume any cost it usually has, such as dealing damage, or taking keys. Obviously doesn't work for regular, stone and red chests. boolean Remain whether or not the chest will disappear on opening or keep a version of it with subtype of 1. By default is true but by default also becomes false if a collectible is present in the SpawnedEntities table }.

Additionally, returning false is equivalent to returning {CanOpen = false, OpenCost = false}. Returning true or nil makes it behave as normal.