Magistrate Hat / Ayam starts with Han Garam in Inside Payon (139, 124). The steps below are read from the quest's script on this server, in the order the script's quest stage moves through them.
Walkthrough

1 Talk to Han Garam in Inside Payon (139, 124)
When Script check: not moza_korea == 2 && countitem(954) > 299 && countitem(733) > 4 && countitem(975) > 0 && countitem(7166) > 49; Script check: not moza_korea == 2 && countitem(954) > 299 && countitem(733) > 4 && countitem(983) > 0 && countitem(2221) > 0 Choose “Give him the items.” Have with you 7 ×
Blue Bijou, 7 ×
Yellow Bijou, 7 ×
Green Bijou, 7 ×
Red BijouIt takes 7 ×
Blue Bijou, 7 ×
Yellow Bijou, 7 ×
Green Bijou, 7 ×
Red BijouWow, wow, thank you so much!
As I promised, I will make you a hat in return.
But, can you wait for a while?
To make hat, I have to contact the Dragon God first.
Script:
npc/quests/newgears/2006_headgears.txt:1076· moza_korea = 1
2 Talk to Han Garam in Inside Payon (139, 124)
When After step 1; Script check: not moza_korea == 2 && countitem(954) > 299 && countitem(733) > 4 && countitem(975) > 0 && countitem(7166) > 49; Script check: not moza_korea == 2 && countitem(954) > 299 && countitem(733) > 4 && countitem(983) > 0 && countitem(2221) > 0 So, you don't have to worry about that.
You know...are they Ayam and Magistrate Hat?
You heard what materials I need, don't you?
Choose a hat, and bring me its materials without missing anything.
Script:
npc/quests/newgears/2006_headgears.txt:1028· moza_korea = 2
3 Talk to Han Garam in Inside Payon (139, 124)
When After step 2 Choose “Give him the items.” Have with you 300 ×
Shining Scale, 5 ×
Cracked Diamond, 1 ×
Scarlet Dyestuffs, 50 ×
Soft SilkIt takes 300 ×
Shining Scale, 5 ×
Cracked Diamond, 1 ×
Scarlet Dyestuffs, 50 ×
Soft SilkYou get 1 ×
Ayam [1]I still feel good that I had a chance
to exercise my skills, you know. It was fun, too.
Please take this Ayam.
As I promised, this is my gift for you.
Script:
npc/quests/newgears/2006_headgears.txt:855· moza_korea = 0
4 Talk to Han Garam in Inside Payon (139, 124)
When After step 2; Script check: not moza_korea == 2 && countitem(954) > 299 && countitem(733) > 4 && countitem(975) > 0 && countitem(7166) > 49 Choose “Give him the items.” Have with you 300 ×
Shining Scale, 5 ×
Cracked Diamond, 1 ×
Black Dyestuffs, 1 ×
Hat [1]It takes 300 ×
Shining Scale, 5 ×
Cracked Diamond, 1 ×
Black Dyestuffs, 1 ×
Hat [1]You get 1 ×
Magistrate Hat [1]I still feel good that I had a chance
to exercise my skills, you know. It was fun, too.
Please take this Magistrate Hat.
As I promised, this is my gift for you.
Script:
npc/quests/newgears/2006_headgears.txt:917· moza_korea = 0
Rewards over the whole quest
1 ×
Ayam [1]; 1 ×
Magistrate Hat [1]
How this page is made: every step comes from the NPC scripts the server loads for Episode 13.2 (the file and line are under each step). "When" lists the checks the script makes before that branch runs; "Have with you" are the items it counts; experience from getexp is multiplied by the server's 50x quest rate. NPC lines are the script's own text.