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

[@GuildWarEventSystem]
{
#IF
Isadmin

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_0

#IF

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_1

[@StartTeamWarEventSystem]
#ACT
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_USER,FLD_FARE,FLD_STEP,FLD_MAXUSER1,FLD_MAXUSER2" @StartTeamWarEventSystem_Check

[@StartTeamWarEventSystem_Check()]
#ACT
Mov A0 %ARG(1)
Mov D0 %ARG(2)
Mov A1 %ARG(3)
Mov D2 %ARG(4)
Mov D3 %ARG(5)

#IF
Equal A1 "OpenGate"
#ELSEACT
break

#ELSESAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_2

#IF
CheckTeamCount [1] "E004" 0
#ACT
Mov D2 %P9

#IF
CheckTeamCount [2] "E004" 0
#ACT
Mov D3 %P9

#IF
ELarge D2 %D0
or ELarge D3 %D1

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_3

#ACT
break

#IF
Equal A1 "StartOpen"

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_4


#ELSESAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_5

[@JoinChallengeTestSurviveGame]
#ACT
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_STEP" @JoinChallengeTestSurviveGame_Next

[@JoinChallengeTestSurviveGame_Next()]
#IF
#ACT
Mov A1 %ARG(1)

#IF
Equal A1 "StartOpen"
Equal A0 %USERNAME
#ACT
Map E004
break

#IF
Equal A1 "StartOpen"
CheckGold %D0
#ELSEACT
break

#ELSESAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_6

#IF
ELarge D2 %D3
#ACT
Take 金币 %D0
TeamMakeTeam 2
Killslave
Map E004
break

#IF
Small D2 %D3
#ACT
Take 金币 %D0
TeamMakeTeam 1
Killslave
Map E004
break


[@JoinTeamWarEventSystem]
#ACT
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TotalControl'" "FLD_STEP" @JoinTeamWarEventSystem_Next

[@JoinTeamWarEventSystem_Next()]
#ACT
mov A9 %ARG(1)

#IF
Equal A9 "Ready"
#ACT
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_STEP" @JoinTeamWarEventSystem_Next1

#ELSESAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_7

[@JoinTeamWarEventSystem_Next1()]
#ACT
mov A9 %ARG(1)

#IF
!Checkitem 通用卷 1

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_8

#ACT
break

#IF
Equal A9 "Ready"
Checkitem 通用卷 1

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_9

#ACT
MapTing E004 5 240 129
ChangeMapAttr "E004" "TEAMFIGHT"
FormatStr "FLD_USER='%s',FLD_STEP='StartClose'" %USERNAME
UpdateValueSQL "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" %A9
UpdateValueSQL "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_POINT1=10000,FLD_POINT2=10000"
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg0]
LineMsg [Grobal] %A7
Delaygoto [Grobal] 300 @JoinTeamWarEventSystem_Next2
break

#IF

#SAY
#INCLUDE [..\Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] @Convert_TeamWarNPC_10

#ACT
break

[@JoinTeamWarEventSystem_Next2]
#ACT
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg1]
LineMsg [Grobal] %A7
UpdateValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_STEP='OpenGate'"
Delaygoto [Grobal] 1200 @JoinTeamWarEventSystem_Next3

[@JoinTeamWarEventSystem_Next3]
#ACT
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg2]
LineMsg [Grobal] %A7
UpdateValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_STEP='CloseGate'"
Delaygoto [Grobal] 600 @JoinTeamWarEventSystem_Next4

[@JoinTeamWarEventSystem_Next4]
#ACT
ReadValueSQL "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_POINT1,FLD_POINT2" @JoinTeamWarEventSystem_Next5

[@JoinTeamWarEventSystem_Next5()]
#ACT
Mov D0 %ARG(1)
Mov D1 %ARG(2)
UpdateValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_STEP='End'"

#IF
Equal D0 %D1
#ACT
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg3]
LineMsg [Grobal] %A7
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_REWORD1,FLD_REWORN1COUNT,FLD_MAPEXP" @JoinTeamWarEventSystem_Next6
break

#IF
Large D0 %D1
#ACT
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg4]
LineMsg [Grobal] %A7
TeamTing E401 2 "E401 40 40 40"
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_REWORD1,FLD_REWORN1COUNT,FLD_MAPEXP" @JoinTeamWarEventSystem_Next6
break

#IF
Large D1 %D0
#ACT
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg5]
LineMsg [Grobal] %A7
TeamTing E401 1 "E401 40 40 40"
ReadValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_REWORD1,FLD_REWORN1COUNT,FLD_MAPEXP" @JoinTeamWarEventSystem_Next6
break

[@JoinTeamWarEventSystem_Next6()]
#ACT
mov A9 %ARG(1)
mov D9 %ARG(2)
Mov D8 %ARG(3)
GiveExpMap E004 %D8
DropItemMap "E004,40,40,20" %A9 1 %D9
Delaygoto [Grobal] 300 @JoinTeamWarEventSystem_Next7

[@JoinTeamWarEventSystem_Next7]
#ACT
MapTing E002 5 240 129
Delaygoto [Grobal] 300 @JoinTeamWarEventSystem_Next8

[@JoinTeamWarEventSystem_Next8]
#ACT
LoadValue A7 [Convert_Def\QuestDiary\EventSystem\TeamWar\TeamWarNPC.txt] [Convert] [Msg6]
LineMsg [Grobal] %A7
UpdateValueSql "TBL_EventSystemTotal" "FLD_NAME='TeamWar'" "FLD_STEP='Ready'"
UpdateValueSql "TBL_EventSystemTotal" "FLD_NAME='TotalControl'" "FLD_STEP='Ready'"
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;