The gate is locked until a particular nearby quest is completed.
A few systems coming together here. NPCs get generated and given names. Quests get generated and assigned to NPCs. Each quest has the kind of item to get and the number to collect. The NPC’s dialogue tree adds dialogue options based on the current state of the NPC’s associated quests and other state such as whether the player has enough items in their inventory to complete the quest. Selecting the dialogue options progresses the state of the quest and removes the items from the player’s inventory.
I want people to like this game that I’m making. So I put together a survey so people can tell me what they like about video games.