boss /chest/door lock

say i want to have a boss/chest/door locked until all mobs on screen are dead. how would i go about doing this?
Have each mob's death increase a variable by 1. Then set the chest event's first page to just say "it's locked" or whatever, and the second event page to require the variable to be equal or greater than however many mobs you want killed, and make that the event page that actually opens the chest

Original thread: https://forums.rpgmakerweb.com/threads/boss-chest-door-lock.86243/