Reference
  Area\Util.txt
  Util\Audio.txt
  Util\Party.txt
  Area\Service.txt
  Util\CommonDialog.txt
End Reference

Procedure Main(startAt)

  Dim ac = Nothing

  RegisterCommonEventHandlers()

  SetZoneOfTown(48, 48, 1, 1, 46, 46, ExitArea_Enter)

  ac = AddActor_MTStopped("EqShopper", 11, 16, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("EqShopperEve", 11, 17, 10, [A_Null], EqShopperEve_Contact)

  ac = AddActor_MTStopped("MgShopper", 13, 16, 0, [A_OldMan], ActorMotion.Down, Nothing)
  ac = AddStaticActor("MgShopperEve", 13, 17, 10, [A_Null], MgShopperEve_Contact)

  ac = AddActor_MTStopped("GdShopper", 6, 5, 0, [A_Woman], ActorMotion.Down, Nothing)
  ac = AddStaticActor("GdShopperEve", 6, 6, 10, [A_Null], GdShopperEve_Contact)

  ac = AddActor_MTStopped("InnFront", 4, 5, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("InnFrontEve", 4, 6, 10, [A_Null], InnFrontEve_Contact)

  ac = AddActor_MTZonedRandom("Friend", 17, 29, 0, _
    14, 27, 0, 20, 31, 0, [A_Man], Friend_Contact)
  
  ac = AddActor_MTZonedRandom("Towner1", 41, 29, 0, _
    38, 27, 0, 44, 31, 0, [A_Soldier], Towner1_Contact)
  
  ac = AddActor_MTZonedRandom("Towner2", 17, 40, 0, _
    14, 38, 0, 20, 42, 0, [A_Woman], Towner2_Contact)
  
  ac = AddActor_MTZonedRandom("Towner3", 41, 40, 0, _
    38, 38, 0, 44, 42, 0, [A_OldMan], Towner3_Contact)

  DoInsideWarp(startAt, SetEntranceEx({35, 1, 0}, {23, 46, 0}, {1, 12, 0}, {46, 12, 0}), False)
  
  ChangeBGM(Music.Town)
  PutAreaNameLabel()

  NotifyEntered()
  Idle(ProcessInput)
  NotifyExiting()

End Procedure

Procedure ExitArea_Enter()
  BeginOutsideWarp([Field], GetAreaObject().Tag)
End Procedure

Procedure EqShopperEve_Contact()
  DoShop({[IronSword], [SteelSword], [BronzeArmor], [IronArmor], [BronzeShield], [IronShield], [BronzeHelmet], [IronHelmet]})
End Procedure

Procedure MgShopperEve_Contact()
  DoMagicShop({[CureAll], [Elec1], [AgiUp], [AgiDown], [Paralyze], [Blink], [Heal2], [Fire2], [Cold2], [Confuse], [PhysDPUp], [PhysDPDown]})
End Procedure

Procedure GdShopperEve_Contact()
  DoShop({[Heal_T1], [Heal_T2], [CureAll_T], [Revive_T]})
End Procedure

Procedure InnFrontEve_Contact()
  DoInn(20)
End Procedure

Procedure Towner1_Contact()
  DoMsg("北にソンテムという村があるぞ", _
    "海を左手に見ながら行けばいい")
End Procedure

Procedure Towner2_Contact()
  DoMsg("南のほうへ行く道が", _
    "さっき開通したそうよ")
  Sleep(500)
  DoMsg("え？洞窟を抜けてきたの？", _
    "あなた強いのね……")
End Procedure

Procedure Towner3_Contact()
  DoMsg("ずいぶん　しゃきっとした爺さんだと", _
    "思っておるじゃろ")
  Sleep(500)
  DoMsg("この世界には　腰の曲がったやつなど", _
    "存在せんのだ　なぜなら　ごふっ")
End Procedure

Procedure Friend_Contact()
  Dim p_name = [TheHero].Name + "："
  Dim q_name = "ニコラス："
  If TestFlag("Bamcake_2") Then
    DoMsg(q_name, "ありがとう　お袋に渡しておくよ")
  ElseIf TestFlag("Bamcake_1") AndAlso TakeOurTool([Movsin]) Then
    DoMsg(q_name, "おお　これが例の薬か　ありがとう", _
      "うちのお袋も　きっと喜ぶだろう")
    SetFlag("Bamcake_2")
  ElseIf TestFlag("Bamcake_1") Then
    DoMsg(q_name, "急ぐわけじゃないが　頼んだよ")
  Else
    DoMsg(q_name, "お！", _
      [TheHero].Name + "じゃないか")
    DoMsg(p_name, "ニック　久しぶりだね")
    DoMsg(q_name, "いやー　何年ぶりだろう", _
      "旅行か何か？")
    Sleep(500)
    DoMsg(q_name, "え？　何だって？", _
      "邪神の復活を阻止する旅？")
    Sleep(500)
    DoMsg(q_name, "あはははははは……")
    DoMsg(p_name, "そんなに笑わなくてもいいじゃないか", _
      "僕は本気だよ")
    DoMsg(q_name, "わかったわかった", _
      "で　その邪神ってのはどちらにお住まいで？")
    DoMsg(p_name, "それが　分からないんだ")
    DoMsg(q_name, "世界中歩き回るつもりなのか")
    DoMsg(p_name, "そうなるね")
    Sleep(500)
    DoMsg(q_name, "じゃあ　ひとつお願いがあるんだが")
    DoMsg(p_name, "なんだい？")
    DoMsg(q_name, "サマオリアのエンケラという町で", _
      [Movsin].Name + "って薬が売られているらしいんだけど", _
      "買って来てくれないかな")
    DoMsg(p_name, "海の向こうじゃないか")
    DoMsg(q_name, "大陸には行かないのかい？")
    DoMsg(p_name, "いや　行くかも知れないけど……")
    DoMsg(q_name, "行ってくれよ　礼は弾むからさ", _
      "な？")
    DoMsg(p_name, "わかったよ")
    DoMsg(q_name, "ありがとう　それじゃこれ代金", _
      "確か" + MoneyStr([Movsin].Price) + "だから")
    Sleep(500)
    ReceiveMoney([Movsin].Price)
    DoMsg(p_name, "ところで" + [Movsin].Name + "って何の薬なんだい？")
    DoMsg(q_name, "冷え性の薬なんだけどさ", _
      "うちのお袋がひどい冷え性でね", _
      "よろしくたのむよ")
    DoMsg(p_name, "はいはい")
    SetFlag("Bamcake_1")
  End If
End Procedure
