;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[@main]
#IF
#ACT
Mov   A1   %USERNAME
Mov   D4   0
#IF
#SAY
The New Group Cave System is now set up\
You must have a group of 3\
1 Warrior, 1 Taoist and 1 Wizard\\
Group up first and then Enter the Setup room\
by Clicking below.\\
<[ Do you want to Enter the Group Cave? ]/@MoveToNPCRoom>\\
You can Exchange FPScrolls Here...\
<[ Exchange FPScroll ]/@CALLFPSCroll>\\
<[ Collect Integral or ThanksLiquor Rewards ]/@CollectReward>\
<[ Exchange ThanksLiquors ]/@ExchangeLiq> For a Different Size Liquor\\
#IF
ISADMIN
#SAY
<[ Talk ]/@@TalktoTown>\
<[ Give Integral in OB ]/@GiveIntegralOB>\
<[ Give Item ]/@@EnterDescr>          \
#IF
#SAY
<[ Exit ]/@Exit>\\\

[@ExchangeLiq]
#IF
#SAY
ThanksLiquor(S) = 2 Hours\
ThanksLiquor(M) = 1 Hour\
ThanksLiquor(X) = 30 Minutes\\
<[ Exchange 1 (S) for 2 (M) ]/@ExLiq(ThanksLiquor(S),ThanksLiquor(M),1,2)>\
<[ Exchange 1 (M) for 2 (X) ]/@ExLiq(ThanksLiquor(M),ThanksLiquor(X),1,2)>\
<[ Exchange 2 (X) for 1 (M) ]/@ExLiq(ThanksLiquor(X),ThanksLiquor(M),2,1)>\
<[ Exchange 2 (M) for 1 (S) ]/@ExLiq(ThanksLiquor(M),ThanksLiquor(S),2,1)>\
<[ Exit ]/@Exit>\\\

[@ExLiq()]
#ACT
   Mov A1 %ARG(1)
   Mov A2 %ARG(2)
   Mov D1 %ARG(3)
   Mov D2 %ARG(4)
#IF
Checkitem %A1 %D1
#ACT
Give %A2 %D2
Take %A1 %D1
#SAY
There you go!\
<[ Exit ]/@Exit>\\\
#ELSESAY
You do not have <$OUTPUT(D1)> * <$OUTPUT(A1)>\
<[ Exit ]/@Exit>\\\

[@_Startup1]
#IF
Random 3
#ACT
Speak "I can deal with your FamePoint Scrolls"
DelayGoto [Grobal] 380 @_Startup
Break

#IF
Random 3
#ACT
Speak "Got any Integral or ThanksLiquors owed ?  Come see me!"
DelayGoto [Grobal] 380 @_Startup
Break

#IF
Random 3
#ACT
Speak "Want to enter the Group cave, I can help!"
DelayGoto [Grobal] 380 @_Startup
Break

#IF
#ACT
DelayGoto [Grobal] 1380 @_Startup
Break

[@CollectReward]
#ACT
   FormatStr FLD_CHARACTER='%s' %USERNAME
   ReadValueSql "TBL_CHARACTER" %A9 "FLD_USERID" @collectReward1

[@collectReward1()]
#ACT
   Mov A2 %ARG(1)
   LoadValue D1 "QuestDiary\EventSystem\RewardCollection\RewardList.txt" [%A2] Integral
   LoadValue D2 "QuestDiary\EventSystem\RewardCollection\RewardList.txt" [%A2] Thanks
#IF
   !ELarge D2 10
   ELarge D2 1
#ACT
   Give ThanksLiquor(M) %D2
   Mov D4 %D2
   SaveValue "QuestDiary\EventSystem\RewardCollection\RewardList.txt" [%A2] Thanks 0

#IF
   ELarge D2 10
#ACT
   Give ThanksLiquor(M) 10
   Mov D4 %D2
   Dec D2 10
   SaveValue "QuestDiary\EventSystem\RewardCollection\RewardList.txt" [%A2] Thanks %D2

#IF
   ELarge D1 1
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   ReadValueSql  "TBL_INTEGRAL"  %A9  "FLD_INTEGRAL"  [@CollectReward2]
#ELSEACT
   Goto @CollectReward3

[@CollectReward2()]
#ACT
   Mov D8 %ARG(1)
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   Mov   A8     %A9
   Inc   D8     %D1
   FormatStr "FLD_INTEGRAL='%s'" %D8
   UPDATEVALUESQL "TBL_INTEGRAL" %A8 %A9
   SaveValue "QuestDiary\EventSystem\RewardCollection\RewardList.txt" [%A2] Integral 0
   Mov     A7  ""
   AddStr  A7 %USERNAME
   AddStr  A7 ","
   AddStr  A7 %D1
   AddStr  A7 ",WithdrawIntegral,"
   AddStr  A7 %D8
   Savelog "QuestDiary\IntegralSystem\IntegralLog.txt" %A7
   Goto @CollectReward3

[@CollectReward3]
#IF
   ELarge D1 1
#SAY
You have received <$OUTPUT(D1)> Integral\
These have been put into your Integral Bank\
You now have <$OUTPUT(D8)> Integral\\
#ELSESAY
You did not get any Integral Reward\\

#IF
   !ELarge D4 10
   ELarge D4 1
#SAY
You have received <$OUTPUT(D4)> ThanksLiquor(M)'s\
These are now in your bag\\
<[ Exit ]/@exit>\\\
#ACT
Break

#IF
   ELarge D4 10
#SAY
You have received 10 ThanksLiquor(M)'s\
There are <$OUTPUT(D2)> more to be taken\
These are now in your bag\\
<[ Exit ]/@exit>\\\
#ACT
Break

#IF
#SAY
You did not get any ThanksLiquor Reward\\
<[ Exit ]/@exit>\\\

[@MoveToNPCRoom]
#IF
   CheckHum NPCRoom1 1
#SAY
Sorry, there is already someone in that room\
Please wait a short while\\
<[ Exit ]/@Exit>\\\\
#ACT
Break

#IF
   CheckGroupCount
#ACT
   Mov D1 %P9
   Mov A0 %USERNAME
#IF
   Equal D1 3
#ACT
   SaveValue "QuestDiary\EventSystem\GroupCave\Groups.txt" [%A0] Wizard ""
   SaveValue "QuestDiary\EventSystem\GroupCave\Groups.txt" [%A0] Taoist ""
   SaveValue "QuestDiary\EventSystem\GroupCave\Groups.txt" [%A0] Password ""
   Groupmove "NPCRoom1,10,12,2" %USERNAME
#ELSESAY
Sorry, you must have 3 in your group\
1 Warrior, 1 Wizard and 1 Taoist\\
<[ Exit ]/@Exit>\\\\

[@@EnterDescr]
#ACT
Mov A1 %INPUTSTR
#SAY
<[ Enter Qty ]/@@EnterDescrQty1>\


[@@EnterDescrQty1]
#ACT
   Mov D1 %INPUTNUM
#SAY
<[ Enter X ]/@@EnterDescrQty2>\

[@@EnterDescrQty2]
#ACT
   Mov D2 %INPUTNUM
#SAY
<[ Enter Y ]/@@EnterDescrQty3>\

[@@EnterDescrQty3]
#ACT
   Mov D3 %INPUTNUM
#SAY
<[ Enter Radius ]/@@EnterDescrQty4>\

[@@EnterDescrQty4]
#ACT
   Mov D4 %INPUTNUM
   FormatStr "%s,%s,%s" %USERMAP %D2 %D3
   Mov   A2     %A9
   FormatStr "%s,%s" %A2 %D4
   Mov   A2     %A9
   DropItemMap %A2 %A1 1 %D1
#SAY
<$OUTPUT(D1)> * <$OUTPUT(A1)> Dropped\
At Co-ordinates <$OUTPUT(D2)>,<$OUTPUT(D3)>,<$OUTPUT(D4)>\\
<$OUTPUT(A2)>\
<[ Main ]/@Main>\\


[@CALLFPSCroll]
#CALL [EventSystem\AddFP.txt] @FPScrollMain

[@GiveIntegralOB]
#IF
#SAY
<[ Please Enter the Password ]/@@PasswordInt>\
<[ Back ]/@Main>\\\

[@@PasswordInt]
#ACT
Mov  A0  %INPUTSTR
#IF
Equal A0  "biga"
#SAY
Are you Sure?\
<[ Yes 20 * 100 ]/@GiveIntegOB>\
<[ Yes 500 * 4 ]/@GiveIntegOB500>\\
<[ Back ]/@Main>\\\

[@GiveIntegOB]
#ACT
DropItemMap "10,250,250,250" Integral(20) 1 100
#sAY
Items Dropped!\
<[ Again? ]/@GiveIntegralOB>\

[@GiveIntegOB500]
#ACT
DropItemMap "10,250,250,250" Integral(500) 1 4
#sAY
Items Dropped!\
<[ Again? ]/@GiveIntegralOB>\

[@@TalktoTown]
#ACT
Mov  A1  %INPUTSTR
Speak "%A1"
Delaygoto [local] 2 @Main

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;