You don't have to blow up the gunpowder house in Neketaka to get the code - that is a much later quest. First, the queen will give you a quest to talk with the watershapers. Then, she will give you the quest to befriend this tribe. Then, after Magran's Teeth, when you have to choose whom to ally with, she will give you the quest to blow up the powder house.
BTW you can go to the tribe, and gain an audience with the tribe leader even without speaking with the queen, but it's glitched and can potentialy jam Aloth's quest for good. If you go to the tribe for the first time after killing all the slavers, BUT before speaking with the queen, the tribe leader will hate you no matter what (for some reason she will think that she has given you the quest to kill the slavers, and you betrayed her, even though you've literally just met....).
It happened with me, I had to reload, and get the "ally with the tribe" quest from the queen to bypass the bugged dialogue, and be able to befriend the tribe, and proceed Aloth's quest. (if the quest is really and I mean REALLY jammed, then you can still kill her and read her soul to finish Aloth's quest =/ )
BTW: I don't know if it was a glitch, or not, but I allied with the Vailians, blew up the powderhouse, and Maia did not leave. I had my friendship maxed with her, I did not complete her personal quest, and I did not have her with me when I got and did this quest. After blowing the powderhouse up, and allying myself with the Vailians, I went for the endgame immediately. I did not go to the deck of my ship, did not speak with Maia, and did not add her to the party for the end-game. I even got rather good ending tiles for her!
Post edited June 08, 2018 by MadyNora