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", 22, 40, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("EqShopperEve", 22, 41, 10, [A_Null], EqShopperEve_Contact)

  ac = AddActor_MTStopped("MgShopper", 24, 40, 0, [A_OldMan], ActorMotion.Down, Nothing)
  ac = AddStaticActor("MgShopperEve", 24, 41, 10, [A_Null], MgShopperEve_Contact)

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

  ac = AddActor_MTStopped("InnFront", 15, 29, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("InnFrontEve", 15, 30, 10, [A_Null], InnFrontEve_Contact)
  
  ac = AddActor_MTZonedRandom("Jeremy", 25, 6, 0, _
    22, 4, 0, 28, 8, 0, [A_Man], Jeremy_Contact)
    
  ac = AddActor_MTZonedRandom("Towner1", 6, 17, 0, _
    3, 15, 0, 9, 19, 0, [A_Woman], Towner1_Contact)
    
  ac = AddActor_MTZonedRandom("Towner2", 33, 18, 0, _
    30, 16, 0, 36, 20, 0, [A_Soldier], Towner2_Contact)
  
  ac = AddActor_MTZonedRandom("Towner3", 6, 39, 0, _
    3, 37, 0, 9, 41, 0, [A_OldMan], Towner3_Contact)
    
  DoInsideWarp(startAt, SetEntranceEx({12, 1, 0}, {12, 46, 0}, {11, 24, 0}, {46, 24, 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({[Katana], [SonicBoom], [TitanArmor], [ZirconArmor], [TitanShield], [ZirconShield], [TitanHelmet], [ZirconHelmet]})
End Procedure

Procedure MgShopperEve_Contact()
  DoMagicShop({[HealAll1], [Revive1], [Elec2], [StrUp], [StrDown], [ColdDPUp], [Heal3], [Fire3], [IntUp], [IntDown], [Berserk], [FireDPUp]})
End Procedure

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

Procedure InnFrontEve_Contact()
  DoInn(220)
End Procedure

Procedure Jeremy_Contact()
  Dim p_name = [TheHero].Name + "："
  Dim q_name = "ジェレミー："
  If TestFlag("Menom_3") Then
    DoMsg(q_name, "本当にありがとう")
  ElseIf TestFlag("Pinema_2") Then
    DoMsg(q_name, "よろしく頼んだよ")
  ElseIf TestFlag("Pinema_1") AndAlso AnybodyHas([GoldenBarrette]) Then
    DoMsg(q_name, "これは！")
    Sleep(500)
    DoMsg(q_name, "見つけてきてくれたのか　ありがとう")
    DoMsg(p_name, "これを奥様に届ければいいのですね？")
    DoMsg(q_name, "本当にすまないな", _
      "スイレンの咲く頃に帰るって伝えてくれ")
    SetFlag("Pinema_2")
  ElseIf TestFlag("Menom_2") Then
    DoMsg(q_name, "伝えておいてくれたか", _
      "ありがとう")
  ElseIf TestFlag("Pinema_1") Then
    DoMsg(q_name, "よろしく伝えておいてくれ")
  ElseIf TakeOurTool([LoveLetter]) Then
    DoMsg(p_name, "すみません　ちょっとお尋ねしますが", _
      "ジェレミーさんのお宅はどちらでしょうか")
    DoMsg(q_name, "俺だけど何か")
    DoMsg(p_name, "あ　そうでしたか", _
      "実はメノームにいらっしゃる奥様から", _
      "お手紙を預かって来たのですが")
    DoMsg(q_name, "え？　どれどれ")
    Sleep(500)
    DoMsg(q_name, "そうか……セリーヌ……")
    DoMsg(p_name, "何か伝えておきましょうか？")
    DoMsg(q_name, "そうだなあ　今は戻れないし", _
      "土産まで買っておいたのになあ……", _
      "あんなことになっちまって")
    DoMsg(p_name, "あんなこと？")
    DoMsg(q_name, "実は出水事故があってな", _
      "もう少しで俺も死ぬところだったが", _
      "なんとか脱出できた", _
      "だが肌身はなさず持っていた髪飾りを", _
      "どこかで落としてしまったんだ", _
      "たぶん最下層だと思うが……")
    Sleep(500)
    DoMsg(q_name, "ま　あいつに伝えてくれ", _
      "元気にやってるって")
    SetFlag("Pinema_1")
  Else
    DoMsg(q_name, "こんにちは")
  End If
End Procedure

Procedure Towner1_Contact()
  DoMsg("この町の鉱山には　よそから出稼ぎに", _
    "来てる人も たくさんいるのよ")
End Procedure

Procedure Towner2_Contact()
  DoMsg("北にホロイラという村があるぞ")
End Procedure

Procedure Towner3_Contact()
  DoMsg("こう見えても若い頃は鉱山で", _
    "バリバリ働いて筋肉モリモリだったのじゃ")
End Procedure
