你看看画面,你当然会想得到这一定是一款RPG游戏,但是,你想得到么?这是一款完全由JS+ASP后台写的在线游戏。汉,那些家伙,实在是crazy...
JS-RPG <白之绊> 核心GameScript服务端代码:
DEMO地址: http://bzb.gbq.cn
战斗画面DEMO: http://bzb.gbq.cn/test/2.asp
游戏脚本范例1: http://bzb.gbq.cn/xml/scene/1000.xml
游戏脚本范例2: http://bzb.gbq.cn/xml/scene/1001.xml
游戏脚本范例3: http://bzb.gbq.cn/xml/scene/1002.xml
游戏脚本范例4: http://bzb.gbq.cn/xml/scene/1003.xml
引用内容
JS-RPG <白之绊> 核心GameScript服务端代码:
DEMO地址: http://bzb.gbq.cn
战斗画面DEMO: http://bzb.gbq.cn/test/2.asp
游戏脚本范例1: http://bzb.gbq.cn/xml/scene/1000.xml
游戏脚本范例2: http://bzb.gbq.cn/xml/scene/1001.xml
游戏脚本范例3: http://bzb.gbq.cn/xml/scene/1002.xml
游戏脚本范例4: http://bzb.gbq.cn/xml/scene/1003.xml

<%
Dim XML
Dim DOM
Dim JS
Dim Scene
Dim JsPatch '补充到JS脚本的部分
Scene = Request.QueryString("Scene")
If Scene="" Then Scene="1001"
XML = "/XML/Scene/" & Scene & ".xml"
Set DOM = Server.CreateObject("MSXML2.DOMDocument")
DOM.async = false
DOM.load(Server.MapPath ( XML))
'获取地图信息
Function MapInfo(DOM)
Dim MapXML
Dim MapDom
Dim MapHtml,MapX,MapY
Dim MapImg
Dim i,j
Dim MapWay
Dim JS
'得到MapXML
MapXML = DOM.selectSingleNode("/Scene").GetAttribute("Map")
Set MapDOM = Server.CreateObject("MSXML2.DOMDocument")
MapDom.async = false
MapDom.load(Server.MapPath(MapXML))
'得到MapHTML,MapX,MapY信息
MapHTML = MapDom.selectSingleNode("/Map/HTML").text
MapX = MapDom.selectSingleNode("/Map/X").text
MapY = MapDom.selectSingleNode("/Map/Y").text
MapHTML = Replace(MapHTML,Chr(13),"")
MapHTML = Replace(MapHTML,Chr(10),"")
JS = JS & "MAP.insertAdjacentHTML('beforeEnd','" & MapHTML & "')" & Vbcrlf
JS = JS & "MapX = " & MapX & Vbcrlf
JS = JS & "MapY = " & MapY & Vbcrlf
If MapDom.selectSingleNode("/Map").getElementsBytagname("Images").Length>0 Then
Set MapImg = MapDom.selectSingleNode("/Map/Images")
For Each i In MapImg.childNodes
JS = JS & "AddImg('" & i.text & "')" & Vbcrlf
Next
End If
JS = JS & "MAP.style.width = CeilSize*" & MapX & Vbcrlf
JS = JS & "MAP.style.height = CeilSize*" & MapY & Vbcrlf
JS = JS & "MAPBG.style.width = CeilSize*" & MapX & Vbcrlf
JS = JS & "MAPBG.style.height = CeilSize*" & MapY & Vbcrlf
MapWay = MapDOM.selectSingleNode("/Map/Way").text
MapWay = Split(MapWay,",")
Dim EachWay,X,Y
For X = 0 To MapX-1
EachWay = ""
For Y = 0 To MapY-1
EachWay = EachWay + MapWay(Y*MapX+X) + ","
Next
EachWay = Left(EachWay,Len(EachWay)-1)
JS = JS & "MapInfo[" & X & "] = new Array(" & EachWay & ")" & Vbcrlf
Next
MapInfo = Js
End Function
'获取声音信息
Function SoundInfo(DOM)
Dim Nodes
Dim Node
Dim NodeID
Dim NodeText
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("Sounds").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/Sounds")
For Each Node In Nodes.childNodes
NodeID = Node.GetAttribute("ID")
NodeText = Node.Text
Js = Js & "new Sound(" & NodeID & "," & Chr(34) & NodeText & Chr(34) & ")" & Vbcrlf
Next
End If
SoundInfo = Js
End Function
'获取文本信息
Function TextInfo(DOM)
Dim Nodes
Dim Node
Dim NodeID
Dim NodeName
Dim NodeIMG
Dim NodeText
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("Texts").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/Texts")
For Each Node In Nodes.childNodes
NodeID = Node.GetAttribute("ID")
NodeName = Node.GetAttribute("Name")
NodeIMG = Node.GetAttribute("IMG")
NodeText = Node.Text
NodeText = Replace(NodeText,"[BR]","<br>")
Js = Js & "new Text(" & NodeID & "," & Chr(34) & NodeName & Chr(34) & "," & Chr(34) & NodeIMG & Chr(34) & "," & Chr(34) & NodeText & Chr(34) & ")" & Vbcrlf
Next
End If
TextInfo = Js
End Function
'获取角色信息
Function RoleInfo(DOM)
Dim Nodes
Dim Node
Dim NodeName
Dim NodeW
Dim NodeH
Dim NodeF
Dim NodeIMG
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("RoleInfos").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/RoleInfos")
For Each Node In Nodes.childNodes
NodeName = Node.GetAttribute("Name")
NodeW = Node.GetAttribute("Width")
NodeH = Node.GetAttribute("Height")
NodeF = Node.GetAttribute("AllFrame")
NodeIMG = Node.GetAttribute("IMG")
Js = Js & "new RoleInfo("
Js = Js & Chr(34) & NodeName & Chr(34)
Js = Js & ","
Js = Js & Chr(34) & NodeIMG & Chr(34)
If NodeW<>"" Then
Js = Js & ","
Js = Js & NodeW
Js = Js & ","
Js = Js & NodeH
Js = Js & ","
Js = Js & NodeF
End If
Js = Js & ")"
Js = Js & Vbcrlf
Next
End If
RoleInfo = Js
End Function
'获取NPC信息
Function NPCInfo(DOM)
Dim Nodes
Dim Node
Dim NodeID
Dim NodeRoleInfo
Dim NodeX
Dim NodeY
Dim NodeF
Dim NodeMT
Dim NodeMS
Dim NodeMF
Dim NodeIsOverpass
Dim NodeFilter
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("NPCs").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/NPCs")
For Each Node In Nodes.childNodes
NodeID = Node.GetAttribute("ID")
NodeRoleInfo = Node.GetAttribute("RoleInfo")
If IsNull(NodeRoleInfo) Then NodeRoleInfo = "NULL"
NodeX = Node.GetAttribute("X")
NodeY = Node.GetAttribute("Y")
NodeF = Node.GetAttribute("F")
NodeMT = Node.GetAttribute("MoveType")
NodeMS = Node.GetAttribute("MoveSpeed")
NodeMF = Node.GetAttribute("MoveFrequency")
NodeMP = Node.GetAttribute("MovePath")
NodeMP = Node.GetAttribute("MovePath")
NodeMRD = Node.GetAttribute("MoveRedo")
NodeMOL = Node.GetAttribute("MoveOverLook")
NodeIsOverpass = Node.GetAttribute("IsOverpass")
NodeFilter = Node.GetAttribute("Filter")
If IsNull(NodeF) Then NodeF = "0"
Js = Js & "LoadNPC("
Js = Js & NodeID
Js = Js & ","
Js = Js & Chr(34) & NodeRoleInfo & Chr(34)
Js = Js & ","
Js = Js & NodeX
Js = Js & ","
Js = Js & NodeY
Js = Js & ","
Js = Js & NodeF
Js = Js & ")"
Js = Js & Vbcrlf
If Not IsNull(NodeIsOverpass) Then
If NodeIsOverpass = "1" Then Js = Js & "Roles[" & NodeID & "].IsOverpass=true" & Vbcrlf
End If
If Not IsNull(NodeFilter) Then
Js = Js & "Role" & NodeID & ".style.filter=" & Chr(34) & NodeFilter & Chr(34) & Vbcrlf
End If
If Not IsNull(NodeMT) Then '设定移动方式了
If NodeMT = "Random" Then
NodeMT = 2
ElseIf NodeMT = "Follow" Then
NodeMT = 3
ElseIf NodeMT = "Plan" Then
NodeMT = 4
Else
NodeMT = 0
End If
Js = Js & "Roles[" & NodeID & "].SetMoveType("
Js = Js & NodeMT
Js = Js & ","
Js = Js & NodeMS
Js = Js & ","
Js = Js & NodeMF
Js = Js & ","
Js = Js & Chr(34) & NodeMP & Chr(34)
Js = Js & ","
If NodeMRD = "0" Then
Js = Js & "false"
Else
Js = Js & "true"
End If
Js = Js & ","
If NodeMOL = "0" Then
Js = Js & "false"
Else
Js = Js & "true"
End If
Js = Js & ")"
Js = Js & Vbcrlf
JsPatch = JsPatch & "Roles[" & NodeID & "].Move()" & Chr(10)
End If
If NodeF<>"0" Then '转向了
JsPatch = JsPatch & "Roles[" & NodeID & "].TurnTo(" & NodeF & ")" & Chr(10)
End If
If Node.hasChildNodes Then
Dim EvType
EvType = Node.childNodes(0).GetAttribute("Type")
EvCloneID = Node.childNodes(0).GetAttribute("CloneID")
If IsNull(EvCloneID) Then
Js = JS & "with(Roles[" & NodeID & "]){" & Vbcrlf
Js = JS & "EventType=" & EvType & Vbcrlf
Js = JS & EventInfo(Node.childNodes(0).text)
Js = JS & "}" & Vbcrlf
Else
Js = JS & "with(Roles[" & NodeID & "]){" & Vbcrlf
Js = JS & "EventType=" & EvType & Vbcrlf
Js = JS & "CloneEvent(" & EvCloneID & ")" & Vbcrlf
Js = JS & "}" & Vbcrlf
End If
End If
Next
End If
NPCInfo = Js
'Response.Write JS
'Response.End
End Function
'获取主脚本信息
Function MainInfo(DOM)
Dim NodeText
Dim EventHead
NodeText = DOM.selectSingleNode("/Scene/MainScript").text
EventHead = "" '自动添加以下事件到主脚本
EventHead = EventHead & "IsKeyLocked=true" & Chr(10) '锁定键盘
'EventHead = EventHead & "MapHide()" & Chr(10) '隐藏屏幕
EventHead = EventHead & "DrawIMGObj()" & Chr(10) '隐藏屏幕
'EventHead = EventHead & "Sleep(100)" & Chr(10) '隐藏屏幕
EventHead = EventHead & "LoadAllImage()" & Chr(10) '载入图片
EventHead = EventHead & JsPatch '补丁部分
NodeText = EventHead & NodeText
NodeText = NodeText & "AllEnd()" & Chr(10) '全部结束
Js = JS & "with(Roles[" & 0 & "]){" & Vbcrlf
Js = JS & "EventType=2" & Vbcrlf
Js = JS & EventInfo(NodeText)
Js = JS & "}" & Vbcrlf
MainInfo = Js
End Function
'处理事件信息[将GameScript转化为Javascript]
Function EventInfo(Events)
Dim Info1
Dim Info2
Dim i
Dim JS
Dim AllDim(100)
Dim AllIf(100)
Dim DimCount
Dim IfCount
Dim NowIfID
Dim IsAdd
Dim sNO
DimCount = 0
IfCount = 0
sNO = 0
Info1 = Split(Events,Chr(10))
For i = LBound(Info1) To UBound(Info1)
iInfo = Info1(i)
IsAdd = True
'如果为空行则忽略
iInfo = Trim(iInfo)
iInfo = Replace(iInfo,Chr(9),"")
iSp = Split(iInfo,"//")
If Ubound(iSp)>0 Then iInfo = iSP(0)
If iInfo="" Then IsAdd = False
'如果为Dim则加入自定义变量列表
If UCase(Left(iInfo,5)) = "DIM $" Then
AllDim(DimCount) = Right(iInfo,Len(iInfo)-5)
DimCount = DimCount+1
IsAdd = False
End If
'处理If Then语句
If UCase(Left(iInfo,3)) = "IF " And UCase(Right(iInfo,5)) = " THEN" Then
'取出Bol表达市
'1 状态:0尚未处理,1已经处理完Else,2已经处理完End If
'2 表达式为False出口
'3 结束点出口
AllIf(IfCount) = "0,0,0"
NowIfID = IfCount
IfCount = IfCount+1
BolStr = Mid(iInfo,4,Len(iInfo)-8)
BolStr = Replace(BolStr,">=",">>")
BolStr = Replace(BolStr,"<=","<<")
BolStr = Replace(BolStr,"=","==")
BolStr = Replace(BolStr,">>",">=")
BolStr = Replace(BolStr,"<<","<=")
BolStr = Replace(BolStr,"<>","!=")
BolStr = Replace(BolStr,"And","&&")
BolStr = Replace(BolStr,"and","&&")
BolStr = Replace(BolStr,"AND","&&")
BolStr = Replace(BolStr,"Or","||")
BolStr = Replace(BolStr,"OR","||")
BolStr = Replace(BolStr,"or","||")
iInfo = "if(!(" & BolStr & "))this.EventGoto(#IFA" & NowIfID & ")"
End If
'处理Else语句
If UCase(iInfo) = "ELSE" Then
AllIf(NowIfID) = "1," & sNo+1 & ",0"
iInfo = "this.EventGoto(#IFB" & NowIfID & ")"
End If
'处理End If语句
If UCase(iInfo) = "END IF" Then
S = Split(AllIf(NowIfID),",")
S(0) = 2
S(2) = sNO
If S(1)="0" Then S(1) = S(2)
AllIf(NowIfID) = S(0) & "," & S(1) & "," & S(2)
IsAdd = False
NowIfID = NowIfID-1
End If
'处理Sleep语句
If UCase(Left(iInfo,5)) = "SLEEP" Then
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "SleepOn()" & Chr(34) & ")" & Vbcrlf
sNO = sNO+1
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & iInfo & Chr(34) & ")" & Vbcrlf
sNO = sNO+1
IsAdd = False
End If
If IsAdd Then
iInfo = Replace(iInfo,Chr(34),"/" & Chr(34))
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & iInfo & Chr(34) & ")" & Vbcrlf
sNO = sNO+1
End If
Next
' Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "SleepOn()" & Chr(34) & ")" & Vbcrlf
' sNO = sNO+1
' Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "Sleep(100)" & Chr(34) & ")" & Vbcrlf
' sNO = sNO+1
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "End()" & Chr(34) & ")" & Vbcrlf
'替换Dim标志
For i = 0 To DimCount-1
Info2 = Replace(Info2,"$" & AllDim(i),"this.Values[" & i & "]")
Next
'替换If标志
For i = 0 To IfCount-1
iIf = Split(AllIf(i),",")
Info2 = Replace(Info2,"#IFA" & i ,iIf(1))
Info2 = Replace(Info2,"#IFB" & i ,iIf(2))
Next
EventInfo = Info2
End Function
OutJS = ""
OutJS = OutJS & MapInfo(DOM)
OutJS = OutJS & SoundInfo(DOM)
OutJS = OutJS & TextInfo(DOM)
OutJS = OutJS & RoleInfo(DOM)
OutJS = OutJS & "LoadHero(-1,-1,0)" & Vbcrlf
OutJS = OutJS & NPCInfo(DOM)
OutJS = OutJS & MainInfo(DOM)
%>
Dim XML
Dim DOM
Dim JS
Dim Scene
Dim JsPatch '补充到JS脚本的部分
Scene = Request.QueryString("Scene")
If Scene="" Then Scene="1001"
XML = "/XML/Scene/" & Scene & ".xml"
Set DOM = Server.CreateObject("MSXML2.DOMDocument")
DOM.async = false
DOM.load(Server.MapPath ( XML))
'获取地图信息
Function MapInfo(DOM)
Dim MapXML
Dim MapDom
Dim MapHtml,MapX,MapY
Dim MapImg
Dim i,j
Dim MapWay
Dim JS
'得到MapXML
MapXML = DOM.selectSingleNode("/Scene").GetAttribute("Map")
Set MapDOM = Server.CreateObject("MSXML2.DOMDocument")
MapDom.async = false
MapDom.load(Server.MapPath(MapXML))
'得到MapHTML,MapX,MapY信息
MapHTML = MapDom.selectSingleNode("/Map/HTML").text
MapX = MapDom.selectSingleNode("/Map/X").text
MapY = MapDom.selectSingleNode("/Map/Y").text
MapHTML = Replace(MapHTML,Chr(13),"")
MapHTML = Replace(MapHTML,Chr(10),"")
JS = JS & "MAP.insertAdjacentHTML('beforeEnd','" & MapHTML & "')" & Vbcrlf
JS = JS & "MapX = " & MapX & Vbcrlf
JS = JS & "MapY = " & MapY & Vbcrlf
If MapDom.selectSingleNode("/Map").getElementsBytagname("Images").Length>0 Then
Set MapImg = MapDom.selectSingleNode("/Map/Images")
For Each i In MapImg.childNodes
JS = JS & "AddImg('" & i.text & "')" & Vbcrlf
Next
End If
JS = JS & "MAP.style.width = CeilSize*" & MapX & Vbcrlf
JS = JS & "MAP.style.height = CeilSize*" & MapY & Vbcrlf
JS = JS & "MAPBG.style.width = CeilSize*" & MapX & Vbcrlf
JS = JS & "MAPBG.style.height = CeilSize*" & MapY & Vbcrlf
MapWay = MapDOM.selectSingleNode("/Map/Way").text
MapWay = Split(MapWay,",")
Dim EachWay,X,Y
For X = 0 To MapX-1
EachWay = ""
For Y = 0 To MapY-1
EachWay = EachWay + MapWay(Y*MapX+X) + ","
Next
EachWay = Left(EachWay,Len(EachWay)-1)
JS = JS & "MapInfo[" & X & "] = new Array(" & EachWay & ")" & Vbcrlf
Next
MapInfo = Js
End Function
'获取声音信息
Function SoundInfo(DOM)
Dim Nodes
Dim Node
Dim NodeID
Dim NodeText
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("Sounds").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/Sounds")
For Each Node In Nodes.childNodes
NodeID = Node.GetAttribute("ID")
NodeText = Node.Text
Js = Js & "new Sound(" & NodeID & "," & Chr(34) & NodeText & Chr(34) & ")" & Vbcrlf
Next
End If
SoundInfo = Js
End Function
'获取文本信息
Function TextInfo(DOM)
Dim Nodes
Dim Node
Dim NodeID
Dim NodeName
Dim NodeIMG
Dim NodeText
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("Texts").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/Texts")
For Each Node In Nodes.childNodes
NodeID = Node.GetAttribute("ID")
NodeName = Node.GetAttribute("Name")
NodeIMG = Node.GetAttribute("IMG")
NodeText = Node.Text
NodeText = Replace(NodeText,"[BR]","<br>")
Js = Js & "new Text(" & NodeID & "," & Chr(34) & NodeName & Chr(34) & "," & Chr(34) & NodeIMG & Chr(34) & "," & Chr(34) & NodeText & Chr(34) & ")" & Vbcrlf
Next
End If
TextInfo = Js
End Function
'获取角色信息
Function RoleInfo(DOM)
Dim Nodes
Dim Node
Dim NodeName
Dim NodeW
Dim NodeH
Dim NodeF
Dim NodeIMG
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("RoleInfos").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/RoleInfos")
For Each Node In Nodes.childNodes
NodeName = Node.GetAttribute("Name")
NodeW = Node.GetAttribute("Width")
NodeH = Node.GetAttribute("Height")
NodeF = Node.GetAttribute("AllFrame")
NodeIMG = Node.GetAttribute("IMG")
Js = Js & "new RoleInfo("
Js = Js & Chr(34) & NodeName & Chr(34)
Js = Js & ","
Js = Js & Chr(34) & NodeIMG & Chr(34)
If NodeW<>"" Then
Js = Js & ","
Js = Js & NodeW
Js = Js & ","
Js = Js & NodeH
Js = Js & ","
Js = Js & NodeF
End If
Js = Js & ")"
Js = Js & Vbcrlf
Next
End If
RoleInfo = Js
End Function
'获取NPC信息
Function NPCInfo(DOM)
Dim Nodes
Dim Node
Dim NodeID
Dim NodeRoleInfo
Dim NodeX
Dim NodeY
Dim NodeF
Dim NodeMT
Dim NodeMS
Dim NodeMF
Dim NodeIsOverpass
Dim NodeFilter
Dim Js
If DOM.selectSingleNode("/Scene").getElementsBytagname("NPCs").Length>0 Then
Set Nodes = DOM.selectSingleNode("/Scene/NPCs")
For Each Node In Nodes.childNodes
NodeID = Node.GetAttribute("ID")
NodeRoleInfo = Node.GetAttribute("RoleInfo")
If IsNull(NodeRoleInfo) Then NodeRoleInfo = "NULL"
NodeX = Node.GetAttribute("X")
NodeY = Node.GetAttribute("Y")
NodeF = Node.GetAttribute("F")
NodeMT = Node.GetAttribute("MoveType")
NodeMS = Node.GetAttribute("MoveSpeed")
NodeMF = Node.GetAttribute("MoveFrequency")
NodeMP = Node.GetAttribute("MovePath")
NodeMP = Node.GetAttribute("MovePath")
NodeMRD = Node.GetAttribute("MoveRedo")
NodeMOL = Node.GetAttribute("MoveOverLook")
NodeIsOverpass = Node.GetAttribute("IsOverpass")
NodeFilter = Node.GetAttribute("Filter")
If IsNull(NodeF) Then NodeF = "0"
Js = Js & "LoadNPC("
Js = Js & NodeID
Js = Js & ","
Js = Js & Chr(34) & NodeRoleInfo & Chr(34)
Js = Js & ","
Js = Js & NodeX
Js = Js & ","
Js = Js & NodeY
Js = Js & ","
Js = Js & NodeF
Js = Js & ")"
Js = Js & Vbcrlf
If Not IsNull(NodeIsOverpass) Then
If NodeIsOverpass = "1" Then Js = Js & "Roles[" & NodeID & "].IsOverpass=true" & Vbcrlf
End If
If Not IsNull(NodeFilter) Then
Js = Js & "Role" & NodeID & ".style.filter=" & Chr(34) & NodeFilter & Chr(34) & Vbcrlf
End If
If Not IsNull(NodeMT) Then '设定移动方式了
If NodeMT = "Random" Then
NodeMT = 2
ElseIf NodeMT = "Follow" Then
NodeMT = 3
ElseIf NodeMT = "Plan" Then
NodeMT = 4
Else
NodeMT = 0
End If
Js = Js & "Roles[" & NodeID & "].SetMoveType("
Js = Js & NodeMT
Js = Js & ","
Js = Js & NodeMS
Js = Js & ","
Js = Js & NodeMF
Js = Js & ","
Js = Js & Chr(34) & NodeMP & Chr(34)
Js = Js & ","
If NodeMRD = "0" Then
Js = Js & "false"
Else
Js = Js & "true"
End If
Js = Js & ","
If NodeMOL = "0" Then
Js = Js & "false"
Else
Js = Js & "true"
End If
Js = Js & ")"
Js = Js & Vbcrlf
JsPatch = JsPatch & "Roles[" & NodeID & "].Move()" & Chr(10)
End If
If NodeF<>"0" Then '转向了
JsPatch = JsPatch & "Roles[" & NodeID & "].TurnTo(" & NodeF & ")" & Chr(10)
End If
If Node.hasChildNodes Then
Dim EvType
EvType = Node.childNodes(0).GetAttribute("Type")
EvCloneID = Node.childNodes(0).GetAttribute("CloneID")
If IsNull(EvCloneID) Then
Js = JS & "with(Roles[" & NodeID & "]){" & Vbcrlf
Js = JS & "EventType=" & EvType & Vbcrlf
Js = JS & EventInfo(Node.childNodes(0).text)
Js = JS & "}" & Vbcrlf
Else
Js = JS & "with(Roles[" & NodeID & "]){" & Vbcrlf
Js = JS & "EventType=" & EvType & Vbcrlf
Js = JS & "CloneEvent(" & EvCloneID & ")" & Vbcrlf
Js = JS & "}" & Vbcrlf
End If
End If
Next
End If
NPCInfo = Js
'Response.Write JS
'Response.End
End Function
'获取主脚本信息
Function MainInfo(DOM)
Dim NodeText
Dim EventHead
NodeText = DOM.selectSingleNode("/Scene/MainScript").text
EventHead = "" '自动添加以下事件到主脚本
EventHead = EventHead & "IsKeyLocked=true" & Chr(10) '锁定键盘
'EventHead = EventHead & "MapHide()" & Chr(10) '隐藏屏幕
EventHead = EventHead & "DrawIMGObj()" & Chr(10) '隐藏屏幕
'EventHead = EventHead & "Sleep(100)" & Chr(10) '隐藏屏幕
EventHead = EventHead & "LoadAllImage()" & Chr(10) '载入图片
EventHead = EventHead & JsPatch '补丁部分
NodeText = EventHead & NodeText
NodeText = NodeText & "AllEnd()" & Chr(10) '全部结束
Js = JS & "with(Roles[" & 0 & "]){" & Vbcrlf
Js = JS & "EventType=2" & Vbcrlf
Js = JS & EventInfo(NodeText)
Js = JS & "}" & Vbcrlf
MainInfo = Js
End Function
'处理事件信息[将GameScript转化为Javascript]
Function EventInfo(Events)
Dim Info1
Dim Info2
Dim i
Dim JS
Dim AllDim(100)
Dim AllIf(100)
Dim DimCount
Dim IfCount
Dim NowIfID
Dim IsAdd
Dim sNO
DimCount = 0
IfCount = 0
sNO = 0
Info1 = Split(Events,Chr(10))
For i = LBound(Info1) To UBound(Info1)
iInfo = Info1(i)
IsAdd = True
'如果为空行则忽略
iInfo = Trim(iInfo)
iInfo = Replace(iInfo,Chr(9),"")
iSp = Split(iInfo,"//")
If Ubound(iSp)>0 Then iInfo = iSP(0)
If iInfo="" Then IsAdd = False
'如果为Dim则加入自定义变量列表
If UCase(Left(iInfo,5)) = "DIM $" Then
AllDim(DimCount) = Right(iInfo,Len(iInfo)-5)
DimCount = DimCount+1
IsAdd = False
End If
'处理If Then语句
If UCase(Left(iInfo,3)) = "IF " And UCase(Right(iInfo,5)) = " THEN" Then
'取出Bol表达市
'1 状态:0尚未处理,1已经处理完Else,2已经处理完End If
'2 表达式为False出口
'3 结束点出口
AllIf(IfCount) = "0,0,0"
NowIfID = IfCount
IfCount = IfCount+1
BolStr = Mid(iInfo,4,Len(iInfo)-8)
BolStr = Replace(BolStr,">=",">>")
BolStr = Replace(BolStr,"<=","<<")
BolStr = Replace(BolStr,"=","==")
BolStr = Replace(BolStr,">>",">=")
BolStr = Replace(BolStr,"<<","<=")
BolStr = Replace(BolStr,"<>","!=")
BolStr = Replace(BolStr,"And","&&")
BolStr = Replace(BolStr,"and","&&")
BolStr = Replace(BolStr,"AND","&&")
BolStr = Replace(BolStr,"Or","||")
BolStr = Replace(BolStr,"OR","||")
BolStr = Replace(BolStr,"or","||")
iInfo = "if(!(" & BolStr & "))this.EventGoto(#IFA" & NowIfID & ")"
End If
'处理Else语句
If UCase(iInfo) = "ELSE" Then
AllIf(NowIfID) = "1," & sNo+1 & ",0"
iInfo = "this.EventGoto(#IFB" & NowIfID & ")"
End If
'处理End If语句
If UCase(iInfo) = "END IF" Then
S = Split(AllIf(NowIfID),",")
S(0) = 2
S(2) = sNO
If S(1)="0" Then S(1) = S(2)
AllIf(NowIfID) = S(0) & "," & S(1) & "," & S(2)
IsAdd = False
NowIfID = NowIfID-1
End If
'处理Sleep语句
If UCase(Left(iInfo,5)) = "SLEEP" Then
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "SleepOn()" & Chr(34) & ")" & Vbcrlf
sNO = sNO+1
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & iInfo & Chr(34) & ")" & Vbcrlf
sNO = sNO+1
IsAdd = False
End If
If IsAdd Then
iInfo = Replace(iInfo,Chr(34),"/" & Chr(34))
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & iInfo & Chr(34) & ")" & Vbcrlf
sNO = sNO+1
End If
Next
' Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "SleepOn()" & Chr(34) & ")" & Vbcrlf
' sNO = sNO+1
' Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "Sleep(100)" & Chr(34) & ")" & Vbcrlf
' sNO = sNO+1
Info2 = Info2 & "AddEvent(" & sNO & "," & Chr(34) & "End()" & Chr(34) & ")" & Vbcrlf
'替换Dim标志
For i = 0 To DimCount-1
Info2 = Replace(Info2,"$" & AllDim(i),"this.Values[" & i & "]")
Next
'替换If标志
For i = 0 To IfCount-1
iIf = Split(AllIf(i),",")
Info2 = Replace(Info2,"#IFA" & i ,iIf(1))
Info2 = Replace(Info2,"#IFB" & i ,iIf(2))
Next
EventInfo = Info2
End Function
OutJS = ""
OutJS = OutJS & MapInfo(DOM)
OutJS = OutJS & SoundInfo(DOM)
OutJS = OutJS & TextInfo(DOM)
OutJS = OutJS & RoleInfo(DOM)
OutJS = OutJS & "LoadHero(-1,-1,0)" & Vbcrlf
OutJS = OutJS & NPCInfo(DOM)
OutJS = OutJS & MainInfo(DOM)
%>