📄 modnpc.vb.svn-base
字号:
Public Module modNpc
Public Class clsNpc
#Region "Variables"
Public Filename As String 'Filename of the Npc Script
Public Name As String 'Npcs ingame name
Public Dir As Byte 'Direction Npc is facing
Public Map As String 'Filename of the map the Npc is on
Public X As Short 'Co-ord X of Npc
Public Y As Short 'Co-ord Y of Npc
Public Light As Byte 'Candle of Npc
Public NpcLook As Integer 'The Npcs look image
Public Tax As Boolean 'Sabuk Wall Tax
Public NpcId As Short 'The unique Id of the Npc
Public NpcCode As New clsNpcCode 'All the Npcs code parsed
#Region "clsNpcCode"
Public Class clsNpcCode
Public SubCount As Integer = 0
Public NpcSub(100) As clsNpcSub
End Class
#End Region
#Region "clsNpcSub"
Public Class clsNpcSub
Public SubTitle As String
Public NpcSay As String
Public NPCElseSay As String
Public NpcAct As String
Public NpcElseAct As String
Public NpcIF As String
End Class
#End Region
#End Region
#Region "Npc Processing"
#Region "ProcessNpcMain [@Main]"
Public Sub ProccessNpcMain(ByVal Index As Integer)
Dim SubNum, MainSub As Integer
Dim MainMenu As String = "[@main]"
Dim Say As String
For SubNum = 1 To NpcCode.SubCount
Select Case True
Case NpcCode.NpcSub(SubNum).SubTitle.ToLower = MainMenu
MainSub = SubNum
Exit Select
End Select
Say = NpcCode.NpcSub(SubNum).NpcSay
Say = FormatSay(Say, Index)
NpcCode.NpcSub(SubNum).NpcSay = Say
Next SubNum
Packets.SendNpcData(Index, NpcId, NpcCode.NpcSub(MainSub).NpcSay)
End Sub
#End Region
#Region "ProcessNpc"
Public Sub ProccessNpc(ByVal Index As Integer, ByVal NpcMenu As String)
Dim Player As clsPlayer = ObjectList(Index)
Dim SubNum, SubAmount As Integer
Dim NpcTitle As String
Dim nIf, nAct, nElseAct As String
Dim nIfOk As Boolean = True
Dim DoAction As Boolean = False
Dim Line As Integer
SubAmount = NpcCode.SubCount
For SubNum = 1 To SubAmount
NpcTitle = NpcCode.NpcSub(SubNum).SubTitle
NpcTitle = Replace(NpcTitle, "]", "")
NpcTitle = Replace(NpcTitle, "[", "")
If NpcTitle.ToLower = NpcMenu.ToLower Then
If NpcCode.NpcSub(SubNum).NpcIF Is Nothing Then
If NpcCode.NpcSub(SubNum).NpcAct Is Nothing Then
GoTo IsTrue
Else
'Do the Act
DoAction = True
GoTo TryAct
End If
End If
Do Until nIf = "failure"
If nIfOk = False Then
GoTo NotTrue
End If
nIf = GetTok(NpcCode.NpcSub(SubNum).NpcIF, Line, vbCrLf)
Line = Line + 1
If nIf = "failure" Then
GoTo IsTrue
End If
If CheckIF(nIf, Player) = True And nIfOk = True Then
nIfOk = True
Else
nIfOk = False
GoTo NotTrue
End If
Loop
TryAct:
Line = 0
Do Until nAct = "failure"
If nIfOk = True Then
nAct = GetTok(NpcCode.NpcSub(SubNum).NpcAct, Line, vbCrLf)
Line = Line + 1
If nAct = "faliure" Then
GoTo IsTrue
End If
DoACT(nAct, Player)
End If
Loop
If DoAction = True Then
GoTo IsTrue
End If
Line = 0
Do Until nElseAct = "failure"
If nIfOk = True Then
nElseAct = GetTok(NpcCode.NpcSub(SubNum).NpcElseAct, Line, vbCrLf)
Line = Line + 1
If nAct = "faliure" Then
GoTo IsTrue
End If
DoACT(nAct, Player)
End If
Loop
Line = 0
Dim Say As String
IsTrue: '#### IS THIS RIGHT? ####'
If nIfOk = True Then
Say = FormatSay(NpcCode.NpcSub(SubNum).NpcSay, Index)
Packets.SendNpcData(Index, NpcId, Say)
Else
NotTrue: Say = FormatSay(NpcCode.NpcSub(SubNum).NPCElseSay, Index)
Packets.SendNpcData(Index, NpcId, Say)
End If
End If
Next SubNum
nIfOk = True
End Sub
#End Region
#Region "CheckIF (Checks the IF statements)"
Public Function CheckIF(ByVal Code As String, ByVal Player As clsPlayer)
Select Case True
'Checklevel
Case Code.ToLower.StartsWith("checklevel")
Dim Level As Integer
Level = GetTok(Code, 1, " ")
If Player.Level >= Level Then
Return True
Else
Return False
End If
'Random
Case Code.ToLower.StartsWith("random")
Dim Random As Integer
Random = GetTok(Code, 1, " ")
If Rand(0, Random) = 1 Then
Return True
Else
Return False
End If
'Checkjob
Case Code.ToLower.StartsWith("checkjob")
Dim Job As String
Dim JobNum As Integer
Job = GetTok(Code, 1, " ")
If Job.ToLower = "warr" Then
JobNum = 0
End If
If Job.ToLower = "wizard" Then
JobNum = 1
End If
If Job.ToLower = "taos" Then
JobNum = 2
End If
If Player.Job = JobNum Then
Return True
Else
Return False
End If
'Gender
Case Code.ToLower.StartsWith("gender")
Dim Gender As String
Dim GenderNum As Integer
Gender = GetTok(Code, 1, " ")
If Gender.ToLower = "man" Then
GenderNum = 0
End If
If Gender.ToLower = "women" Then
GenderNum = 1
End If
If Player.Gender = GenderNum Then
Return True
Else
Return False
End If
'Checkgold
Case Code.ToLower.StartsWith("checkgold")
Dim Gold As Integer
Gold = GetTok(Code, 1, " ")
If Player.Gold > Gold Then
Return True
Else
Return False
End If
'Checkpkpoint
Case Code.ToLower.StartsWith("checkpkpoint")
Dim PkPoint As Integer
PkPoint = GetTok(Code, 1, " ")
If Player.PKPoint > PkPoint Then
Return True
Else
Return False
End If
End Select
End Function
#End Region
#Region "DoACT (Does the Acts)"
Public Sub DoACT(ByVal Code As String, ByVal Player As clsPlayer)
Dim Param1, Param2, Param3 As String
Select Case True
'Close
Case Code.ToLower.StartsWith("close")
Packets.SendNpcCloseDlg(Player.StateId, NpcId)
'Map Move
Case Code.ToLower.StartsWith("mapmove")
Dim X, Y As Integer
Dim Map, Text, Params() As String
Text = GetBetween(Code, "(", ")")
If Text.Contains(", ") Then
Params = Split(Text, ", ")
Map = Params(0)
X = Params(1)
Y = Params(2)
Player.PositionMove(X, Y, Map)
Else
Map = Text
Player.RandomMove(Map)
End If
'Spawn Monster
Case Code.ToLower.StartsWith("spawnmonster")
Dim tMonster, tMap, Text, Params() As String
Dim tAmount, tRange, tX, tY As Integer
Text = GetBetween(Code, "(", ")")
Params = Split(Text, ", ")
If Params.Length = 6 Then
tMonster = Params(0)
tMonster = tMonster.TrimStart(Chr(34))
tMonster = tMonster.TrimEnd(Chr(34))
tAmount = Params(1)
tMap = Params(2)
tX = Params(3)
tY = Params(4)
tRange = Params(5)
If tRange > 0 Then
Dim p As Point = GetRandomSpot(tX, tY, tMap, tRange)
tX = p.X
tY = p.Y
End If
GMCommands.SpawnMob(tMonster, tAmount, tX, tY, tMap)
End If
'Give Item
Case Code.ToLower.StartsWith("give")
Dim Item, Text, Params() As String
Dim Amount As Integer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -