So, I've seen that there is a "Door Manager" script in a few of the Solarus Team's projects, which seems to help with this instance as well as a few other things you might want to do with doors- I've tried it and it works great once you figure out what you're supposed to do to use it! However, I don't 100% understand everything in that code, so I don't like using it. Maybe once I'm smart enough to re-code it myself to understand it I will, but until then I'm stubbornly doing things poorly so I can learn.
So, one way I've achieved this effect is by having an event for every enemy that, when they're killed, checking if there aren't any other enemies left and if so, opening the door (or whatever). I know for a fact that this is not very good code, and it's repetitive and hard-codes the number of enemies, but it might be a good starting point for you to try to understand some of the code that you'll need.
function mushroom_golem_1:on_dead()
if map:get_entities_count("mushroom_golem") == 0 then --)this line counts the number of entities that are named starting with "mushroom_golem...")
game:start_dialog("_yarrowmouth.observations.mushroom_spot.1")
map:open_doors("gate")
end
end
function mushroom_golem_2:on_dead()
if map:get_entities_count("mushroom_golem") == 0 then
game:start_dialog("_yarrowmouth.observations.mushroom_spot.1")
map:open_doors("gate")
end
end
--and so on, with function mushroom_golem_3:on_dead(), mushroom_golem_4, etc...