⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modmonster.vb.svn-base

📁 MirUnleashed vb.net Module modMainServer Public WithEvents Socket As New WinsockServer Pub
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
                                    WillHit = True
                                End If

                                'Monsters dead so we dont hit it
                                If tMonster.HP <= 0 Then
                                    Damage = 0
                                    WillHit = False
                                End If

                                'If were not going to hit it dont hurt it
                                If WillHit = False Then Damage = 0
                                If Damage = 0 Then WillHit = False

                                'Get the real damage including AC
                                If Damage > 0 Then
                                    Damage = Math.Max(0, Damage - GetAC(TargetId))
                                    'Dim WeapDuraLoss As Byte = Rand(0, 5) + 2
                                    'If Player.LooseDura(WeapDuraLoss, EquipId.weapon) Then
                                    '    'TellPlayer weapon broke
                                    'End If
                                End If

                                Dim HP As Integer
                                Dim MaxHP As Integer
                                Dim MP As Integer

                                '########################################'
                                '###DO THE ACTUAL DAMAGE TO THE TARGET###'
                                '########################################'

                                'Now do the damage
                                If Damage > 0 Then

                                    'Take away some of Monsters HP
                                    tMonster.HP = Math.Max(tMonster.HP - Damage, 0)
                                    If tMonster.HP <= 0 Then
                                        'Monster died
                                        tMonster.Died()
                                    End If
                                    HP = tMonster.HP
                                    MaxHP = tMonStats.MaxHP
                                    MP = tMonster.MP
                                End If

                                '######################################'
                                '###TELL EVERYONE YOU HIT THE TARGET###'
                                '######################################'

                                Dim i As Integer
                                Dim Locals As Hashtable = GetLocalPlayers(tMonster.X, tMonster.Y, tMonster.Map, 15, 15)
                                If WillHit And Damage > 0 Then
                                    'Attack has been Processed, Tell Players what got hit
                                    Dim lPlayer As clsPlayer
                                    For i = 0 To Locals.Count - 1
                                        If Not Locals(i) Is Nothing Then
                                            'Tell players
                                            lPlayer = ObjectList(Locals(i))


                                            If tMonster.IsDead Then
                                                'If monster died tell everyone
                                                Packets.SendDied(lPlayer.StateId, TargetId, Target)
                                                'Do Drops

                                                'Remove Monster
                                                'MonsterList.Remove(tMonster.MobId)
                                                ObjectList.Remove(tMonster.MobId)
                                            Else
                                                Packets.SendStruck(lPlayer.StateId, Target, GetSmallMonsterBuffer(tMonster))
                                            End If

                                        End If
                                    Next i
                                End If
                                '######################'
                                '######################'

                                Dim pID As Integer

                                For i = 0 To Locals.Count - 1
                                    pID = Locals(i)
                                    tMonster.Attacker = Races.Monster
                                    tMonster.AttackerId = MobId
                                    Packets.SendHit(pID, Me.MobId, Races.Monster, Me.Dir)
                                Next i
                                LastHit = Now.Ticks
                            End If
                        Else
                            'Move towards the target
                            'GMCommands.GMShout(Me.Name, "Moving towards: " & tMonster.X & ":" & tMonster.Y)
                            GotoTarget()
                        End If
                End Select
            End If
        End Sub

#End Region
#Region "GotoTarget"

        Private Sub GotoTarget()
            If Not Target = Races.None Then
                'We have a target
                Dim Stats As clsMobStats = MonsterStatsList(Me.Name)

                If LastWalk + (Stats.WalkSpeed * 10000) < Now.Ticks Then
                    LastWalk = Now.Ticks

                    Dim tX, tY, OldX, OldY As Integer
                    OldX = X
                    OldY = Y

                    Select Case Target
                        Case Races.Player
                            Dim tPlayer As clsPlayer = ObjectList(TargetId)

                            If tPlayer Is Nothing Then
                                TargetId = 0
                                Target = Races.None
                                Exit Sub
                            End If

                            tX = tPlayer.X
                            tY = tPlayer.Y
                        Case Races.Monster
                            Dim tMonster As clsMonster = ObjectList(TargetId)

                            If tMonster Is Nothing Then
                                TargetId = 0
                                Target = Races.None
                                Exit Sub
                            End If

                            tX = tMonster.X
                            tY = tMonster.Y
                    End Select

                    If tX = X And tY = Y Then
                        'Target is on the same spot as the monster
                        'Walk in the direction the monster is facing
                        Walk()
                        Exit Sub
                    End If

                    'Move the monster
                    Dir = Directions.Down
                    If tX > X Then
                        Dir = Directions.Right
                        If tY > Y Then Dir = Directions.DownRight
                        If tY < Y Then Dir = Directions.UpRight
                    ElseIf tX < X Then
                        Dir = Directions.Left
                        If tY > Y Then Dir = Directions.DownLeft
                        If tY < Y Then Dir = Directions.UpLeft
                    Else
                        If tY > Y Then Dir = Directions.Down
                        If tY < Y Then Dir = Directions.Up
                    End If

                    Select Case Dir
                        Case Directions.Up
                            Y = Y - 1
                        Case Directions.UpRight
                            X = X + 1
                            Y = Y - 1
                        Case Directions.Right
                            X = X + 1
                        Case Directions.DownRight
                            X = X + 1
                            Y = Y + 1
                        Case Directions.Down
                            Y = Y + 1
                        Case Directions.DownLeft
                            X = X - 1
                            Y = Y + 1
                        Case Directions.Left
                            X = X - 1
                        Case Directions.UpLeft
                            X = X - 1
                            Y = Y - 1
                    End Select

                    If CanWalk(New Point(X, Y), Map) = False Then
                        'Cant walk there
                        X = OldX
                        Y = OldY
                        Stuck()
                        Exit Sub
                    End If

                    'Can walk there so move the monster
                    LastX = OldX
                    LastY = OldY
                    'Dir = GetNewDir()

                    Dim j As Integer
                    Dim OnMap As Boolean = False
                    Dim tMap As Map = Maps(Map)

                    'Update the Maps Objectlist
                    While j < 10 And OnMap = False
                        If tMap.ObjectList.Contains(X & "/" & Y & "/" & j) = False Then
                            Dim sKey As String = GetKeyFromValue(tMap.ObjectList, MobId)
                            tMap.ObjectList.Remove(sKey)
                            tMap.ObjectList.Add(X & "/" & Y & "/" & j, MobId)
                            OnMap = True
                        End If
                        j += 1
                    End While

                    'Tell everyone around the monster that it moved
                    Dim Locals As Hashtable = GetLocalPlayers(X, Y, Map, 15, 15)
                    Dim i, pID As Integer
                    Dim Added As New Hashtable
                    Dim lPlayer As clsPlayer

                    For i = 0 To Locals.Count - 1
                        pID = Locals(i)
                        If Added.ContainsKey(pID) = False Then
                            lPlayer = ObjectList(pID)
                            Packets.SendMove(lPlayer.StateId, MobId, Races.Monster, X, Y, Dir, 1)
                            Added.Add(pID, "")
                        End If
                    Next i

                End If

            End If
        End Sub

#End Region
#Region "FollowPetOwner"

        Private Sub FollowPetOwner()
            Dim PetOwnerId As Integer = PlayerList(PetOwner)
            Dim Stats As clsMobStats = MonsterStatsList(Me.Name)

            If LastWalk + (Stats.WalkSpeed * 10000) < Now.Ticks Then
                LastWalk = Now.Ticks

                Dim tX, tY, OldX, OldY As Integer
                OldX = X
                OldY = Y

                Dim tPlayer As clsPlayer = ObjectList(PetOwnerId)

                If tPlayer Is Nothing Then
                    Died() 'Kill the pet
                    Exit Sub
                End If

                tX = tPlayer.X
                tY = tPlayer.Y

                If tX = X And tY = Y Then
                    'Pet Owner is on the same spot as the monster
                    'Walk in the direction the monster is facing
                    Walk()
                    Exit Sub
                End If

                'Move the monster
                Dir = Directions.Down
                If tX > X Then
                    Dir = Directions.Right
                    If tY > Y Then Dir = Directions.DownRight
                    If tY < Y Then Dir = Directions.UpRight
                ElseIf tX < X Then
                    Dir = Directions.Left
                    If tY > Y Then Dir = Directions.DownLeft
                    If tY < Y Then Dir = Directions.UpLeft
                Else
                    If tY > Y Then Dir = Directions.Down
                    If tY < Y Then Dir = Directions.Up
                End If

                Select Case Dir
                    Case Directions.Up
                        Y = Y - 1
                    Case Directions.UpRight
                        X = X + 1
                        Y = Y - 1
                    Case Directions.Right
                        X = X + 1
                    Case Directions.DownRight
                        X = X + 1
                        Y = Y + 1
                    Case Directions.Down
                        Y = Y + 1
                    Case Directions.DownLeft
                        X = X - 1
                        Y = Y + 1
                    Case Directions.Left
                        X = X - 1
                    Case Directions.UpLeft
                        X = X - 1
                        Y = Y - 1
                End Select

                If CanWalk(New Point(X, Y), Map) = False Then
                    'Cant walk there
                    X = OldX
                    Y = OldY
                    Stuck()
                    Exit Sub
                End If

                'Can walk there so move the monster
                LastX = OldX
                LastY = OldY
                'Dir = GetNewDir()

                Dim j As Integer
                Dim OnMap As Boolean = False
                Dim tMap As Map = Maps(Map)

                'Update the Maps Objectlist
                While j < 10 And OnMap = False
                    If tMap.ObjectList.Contains(X & "/" & Y & "/" & j) = False Then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -