📄 modmonster.vb.svn-base
字号:
Module modMonster
#Region "clsSpawnInfo"
Public Class clsSpawnInfo
Public MapFilename As String 'Map filename to spawn on
Public X As Short 'Spawn X
Public Y As Short 'Spawn Y
Public Range As Short 'Range the monster should spawn from X/Y
Public RespawnTime As Short 'Respawn time
End Class
#End Region
#Region "clsMonsterDrops"
Public Class clsMonsterDrops
Public DropItems() As clsDropItems 'Items monster drops
Public DropItemCount As Integer 'Amount of items monster drops
End Class
#End Region
#Region "clsDropItems"
Public Class clsDropItems
Public ItemName As String 'Drop item name
Public ItemIndex As Integer = -1 'Item Index in DB
Public Chance1 As Integer 'Chance 1
Public Chance2 As Integer 'Chance 2
End Class
#End Region
#Region "clsMobStats"
Public Class clsMobStats
Public Name As String 'Monster name
Public AttackType As MonAttackType 'Attack type
Public AttackStyle As MonAttackStyle 'Attack style
Public AttackStyle2 As MonAttackStyle 'Second attack Style
Public AttackImg As MonAttackImage 'Attack image
Public MobImg As Integer 'Monsters image
Public Level As Short 'Level
Public Tamable As Boolean 'Can it be tamed?
Public Undead As Boolean 'Is it undead?
Public Visibility As Short 'Percentage of chance it will see through clearRing
Public Exp As Long 'Exp
Public MaxHP As Short 'MaxHP
Public MaxMP As Short 'MaxMP
Public AC As Short 'AC
Public AMC As Short 'AMC
Public DC As Short 'DC
Public MaxDC As Short 'MaxDC
Public MC As Short 'MC
Public MaxMC As Short 'MaxMC
Public SC As Short 'SC
Public MaxSC As Short 'MaxSC
Public Agility As Short 'Agility
Public Accuracy As Short 'Accuracy
Public WalkSpeed As Short 'Walk Speed
Public WalkSteps As Byte 'Amount of Steps
Public WalkWait As Integer 'Walk Wait
Public AttackSpeed As Integer 'Attack Speed
Public ViewRange As Short 'The area range the monster can see
End Class
#End Region
#Region "clsMonster"
Public Class clsMonster
#Region "Monsters Variables"
Public MobId As Long = -1 'Monsters unique Id
Public Name As String 'Monsters Name
Public Dir As Directions 'Direction
Public Map As String
Public X As Short 'X
Public Y As Short 'Y
Public LastX As Short 'LastX
Public LastY As Short 'LastY
Public Light As Byte 'Light
Public NameColour As NameColours 'Monsters name colour
Public HP As Short 'Current HP
Public MP As Short 'Current MP
Public SpawnInfo As clsSpawnInfo 'Spawn info for this monster
Public Exp As Long 'Exp monster gives
Public Reved As Boolean 'Is monster revelationed?
Public Poison As Integer 'Poisoned? What Poison
Public IsDead As Boolean 'Dead or Alive
'Public Chasing As Boolean 'Chasing a player?
Public IsPet As Boolean 'Is this monster someones pet?
Public PetOwner As String 'Who is the owner of this pet
Public PetStatus As PetStatuses 'Status of the pet
Public WalkWait As Integer 'Walk wait
Public LastWalk As Long 'Last walk time
Public LastHit As Long 'Last hit time
Public TargetId As Object 'Targets Id
Public Target As Races 'Targets race
Public AttackerId As Object 'Attackers Id
Public Attacker As Races 'Attackers Race
#End Region
#Region "New"
Public Sub New()
'MobProcess = New clsMobProcess
SpawnInfo = New clsSpawnInfo
'DropItems(100) = New DropItems1
End Sub
#End Region
#Region "Monster AI"
#Region "Process"
Public Sub Process()
If IsDead = False Then
'If the monster is alive
If IsPet Then
'Monster is a players pet
If PlayerList.Contains(PetOwner) Then
'The owner of the pet is online
Dim Player As clsPlayer = ObjectList(PlayerList(PetOwner))
If Player.IsDead Then
'Player is dead
Died() 'Kill the pet
End If
If PetStatus = PetStatuses.Rest Then
'Pet in rest mode
Target = Races.None
TargetId = -1
Else
'Pet in attack mode
If Player.Attacker <> Races.None Then
Dim TargetDead As Boolean
Select Case Player.Attacker
Case Races.Player
Dim tPlayer As clsPlayer = ObjectList(Player.AttackerId)
If tPlayer Is Nothing Then TargetDead = True
If Not tPlayer Is Nothing Then
If tPlayer.IsDead Then TargetDead = True
End If
Case Races.Monster
Dim tMonster As clsMonster = ObjectList(Player.AttackerId)
If tMonster Is Nothing Then TargetDead = True
If Not tMonster Is Nothing Then
If tMonster.IsDead Then TargetDead = True
End If
End Select
If TargetDead Then
Player.Attacker = Races.None
Player.AttackerId = -1
Target = Races.None
TargetId = -1
Else
Target = Player.Attacker
TargetId = Player.AttackerId
End If
End If
If Player.Target <> Races.None Then
Dim TargetDead As Boolean
Select Case Player.Target
Case Races.Player
Dim tPlayer As clsPlayer = ObjectList(Player.TargetId)
If tPlayer Is Nothing Then TargetDead = True
If Not tPlayer Is Nothing Then
If tPlayer.IsDead Then TargetDead = True
End If
Case Races.Monster
Dim tMonster As clsMonster = ObjectList(Player.TargetId)
If tMonster Is Nothing Then TargetDead = True
If Not tMonster Is Nothing Then
If tMonster.IsDead Then TargetDead = True
End If
End Select
If TargetDead Then
Player.Target = Races.None
Player.TargetId = -1
Target = Races.None
TargetId = -1
Else
Target = Player.Target
TargetId = Player.TargetId
End If
End If
If Attacker <> Races.None Then
Dim TargetDead As Boolean
Select Case Attacker
Case Races.Player
Dim tPlayer As clsPlayer = ObjectList(AttackerId)
If tPlayer Is Nothing Then TargetDead = True
If Not tPlayer Is Nothing Then
If tPlayer.IsDead Then TargetDead = True
End If
Case Races.Monster
Dim tMonster As clsMonster = ObjectList(AttackerId)
If tMonster Is Nothing Then TargetDead = True
If Not tMonster Is Nothing Then
If tMonster.IsDead Then TargetDead = True
End If
End Select
If TargetDead Then
Attacker = Races.None
AttackerId = -1
Target = Races.None
TargetId = -1
Else
Target = Attacker
TargetId = AttackerId
End If
End If
If Target = Races.Monster And TargetId = MobId Then
'Stop monster trying to attack its self
Target = Races.None
TargetId = -1
End If
If Target = Races.None And Player.Attacker = Races.None And Player.Target = Races.None And Attacker = Races.None Then
TargetId = -1
FollowPetOwner()
End If
End If
Else
'The owner of the pet is offline
Died() 'Kill the pet
End If
End If
If Not Target = Races.None Then
'Monster has a target check the target exists on the map
Dim CheckMap As Map = Maps(Me.Map)
If Not CheckMap.ObjectList.ContainsValue(TargetId) Then
Target = Races.None
TargetId = -1
Else
'Target still exists check that its still in view
'Get all the local objects around the monsters area
Dim mStats As clsMobStats = MonsterStatsList(Name)
Dim LocalPlayers As Hashtable = GetLocalPlayers(X, Y, Map, mStats.ViewRange, mStats.ViewRange)
Dim LocalPets As Hashtable = GetLocalPets(X, Y, Map, mStats.ViewRange, mStats.ViewRange)
Dim LocalMonsters As Hashtable = GetLocalMonsters(X, Y, Map, mStats.ViewRange, mStats.ViewRange)
'If there is no ememies around the monster then there is no targets to find
Select Case Target
Case Races.Player
If LocalPlayers.ContainsValue(TargetId) Then
'Target exists and will continue to either move towards
'it or to hit it
AttackTarget()
Else
'Target is out of range
Target = Races.None
TargetId = -1
End If
Case Races.Monster
If IsPet = False Then
'Monster is not a pet
If LocalPets.ContainsValue(TargetId) Then
'Target exists and will continue to either move towards
'it or to hit it
AttackTarget()
Else
'Target is out of range
Target = Races.None
TargetId = -1
End If
Else
'Monster is a pet
If LocalMonsters.ContainsValue(TargetId) Then
'Target exists and will continue to either move towards
'it or to hit it
AttackTarget()
Else
'Target is out of range
Target = Races.None
TargetId = -1
End If
End If
End Select
End If
End If
If Target = Races.None Then
'Monster has nothing to do so it searches the area for targets
'It will either find no targets in its area or will find a
'target and begin attacking it or moving towards it
SearchView()
End If
If Target = Races.None Then
'Monster has nothing to do so it just wonders about
Wonder()
End If
End If
End Sub
#End Region
#Region "SearchView"
Private Sub SearchView()
If Target = Races.None Then
'We have no target
Dim mStats As clsMobStats = MonsterStatsList(Name)
If mStats.AttackStyle = MonAttackStyle.None And Target = Races.None Then
'Monster only attacks when attacked so it doesn't search for targets
Exit Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -