📄 modmagic.vb.svn-base
字号:
Module modMagic
#Region "clsMagic"
Public Class clsMagic
#Region "Magic Variables"
Public MagicId As Integer 'Magic ID
Public Name As String 'Magic Name
Public Looks As Byte 'Animation Looks
Public EffectType As MagEffectTypes 'What the magic does
Public ManaCost As Byte 'Mana Cost
Public HealthCost As Byte 'Health Cost
Public RequireItem As String 'Requires item to cast spell ("ItemId,ItemId,ItemId")
Public ItemCost As Byte 'Item Cost
Public Monster As String 'Monster to summon if summoning spell ("MonsterName,MonsterName,MonsterName")
Public Power As Byte 'Minimum power the magic does
Public MaxPower As Byte 'Maximum power the magic does
Public AttackRange As Byte 'How far you can cast the spell
Public Job As Byte 'Class (Warrior/Wizard/Taoist/All)
Public NeedLevel1 As Byte 'Required level to begin training
Public Level1Exp As Integer 'Exp required to gain level 1
Public NeedLevel2 As Byte 'Required level to begin training level 2
Public Level2Exp As Integer 'Exp required to gain level 2
Public NeedLevel3 As Byte 'Required level to begin training level 3
Public Level3Exp As Integer 'Exp required to gain level 3
Public RechargeTime As Integer 'Time until you can re-cast the spell
#End Region
#Region "UseMagic"
Public Function UseMagic(ByVal Player As clsPlayer, ByVal TargetX As Short, ByVal TargetY As Short) As clsMagicAttack
Dim PlayerMagic As clsPlayerMagic = Player.PlayerMagics(MagicId)
If Not PlayerMagic Is Nothing Then
UseMagic = New clsMagicAttack
UseMagic.Owner = Races.Player
UseMagic.OwnerId = Player.StateId
UseMagic.EffectType = EffectType
UseMagic.ManaCost = ManaCost
UseMagic.HealthCost = HealthCost
UseMagic.RequireItem = RequireItem
UseMagic.ItemCost = ItemCost
Select Case EffectType
Case MagEffectTypes.Accuracy1, MagEffectTypes.Accuracy2, MagEffectTypes.HitBoost
'In CalcMagicStats within clsPlayer
Case MagEffectTypes.ShootDamage
UseMagic = ProcessShootDamage(Player, UseMagic, PlayerMagic.Level, TargetX, TargetY)
Case MagEffectTypes.Heal
UseMagic = ProcessHeal(Player, UseMagic, PlayerMagic.Level, TargetX, TargetY)
Case MagEffectTypes.Poison
UseMagic = ProcessPoison(Player, UseMagic, PlayerMagic.Level, TargetX, TargetY)
Case MagEffectTypes.NearShootSquare2x2
UseMagic = ProcessShootSquare(Player, UseMagic, PlayerMagic.Level, Player.X, Player.Y, MagSizes.m2x2)
Case MagEffectTypes.NearShootSquare4x4
UseMagic = ProcessShootSquare(Player, UseMagic, PlayerMagic.Level, Player.X, Player.Y, MagSizes.m4x4)
Case MagEffectTypes.NearShootSquare6x6
UseMagic = ProcessShootSquare(Player, UseMagic, PlayerMagic.Level, Player.X, Player.Y, MagSizes.m6x6)
Case MagEffectTypes.NearShootSquare8x8
UseMagic = ProcessShootSquare(Player, UseMagic, PlayerMagic.Level, Player.X, Player.Y, MagSizes.m8x8)
End Select
End If
End Function
#End Region
#Region "Magics Effects"
#Region "ProcessShootDamage"
Private Function ProcessShootDamage(ByVal Player As clsPlayer, ByVal tMagicAttack As clsMagicAttack, ByVal Level As Byte, ByVal TargetX As Integer, ByVal TargetY As Integer) As clsMagicAttack
ProcessShootDamage = tMagicAttack
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
ProcessShootDamage.Power = Power + Player.MC + Level
ProcessShootDamage.MaxPower = MaxPower + Player.MaxMC + Level
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
ProcessShootDamage.Targets = GetLocalObjects(TargetX, TargetY, Player.Map, 0, 0, Player.StateId)
Dim TargetId As Object
Dim TargetRace As Races
Dim GotTarget As Boolean
Dim l As Long
For l = 0 To ProcessShootDamage.Targets.Count - 1
If Not ProcessShootDamage.Targets(l) Is Nothing Then
TargetId = ProcessShootDamage.Targets(l)
TargetRace = Races.Monster
GotTarget = True
End If
Next l
Dim i As Integer
For i = 0 To ProcessShootDamage.Targets.Count - 1
If Not ProcessShootDamage.Targets(i) Is Nothing Then
TargetId = ProcessShootDamage.Targets(i)
TargetRace = Races.Player
GotTarget = True
End If
Next i
If GotTarget Then
ProcessShootDamage.Targets.Add(TargetId, TargetRace)
End If
End Function
#End Region
#Region "ProcessHeal"
Private Function ProcessHeal(ByVal Player As clsPlayer, ByVal tMagicAttack As clsMagicAttack, ByVal Level As Byte, ByVal TargetX As Integer, ByVal TargetY As Integer) As clsMagicAttack
ProcessHeal = tMagicAttack
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
ProcessHeal.Power = Power + Player.SC + Level
ProcessHeal.MaxPower = MaxPower + Player.MaxSC + Level
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
Dim tempHashtable As Hashtable
tempHashtable = GetLocalObjects(TargetX, TargetY, Player.Map, 0, 0, Player.StateId)
Dim TargetId As Object
Dim TargetRace As Races
Dim GotTarget As Boolean
Dim l As Long
For l = 0 To tempHashtable.Count - 1
If Not tempHashtable(l) Is Nothing Then
TargetId = tempHashtable(l)
TargetRace = Races.Monster
GotTarget = True
End If
Next l
Dim i As Integer
For i = 0 To tempHashtable.Count - 1
If Not tempHashtable(i) Is Nothing Then
TargetId = tempHashtable(i)
TargetRace = Races.Player
GotTarget = True
End If
Next i
If GotTarget Then
ProcessHeal.Targets.Add(TargetId, TargetRace)
Else
'If theres no targets then heal self
ProcessHeal.Targets.Add(Player.StateId, Races.Player)
End If
End Function
#End Region
#Region "ProcessPoison"
Private Function ProcessPoison(ByVal Player As clsPlayer, ByVal tMagicAttack As clsMagicAttack, ByVal Level As Byte, ByVal TargetX As Integer, ByVal TargetY As Integer) As clsMagicAttack
ProcessPoison = tMagicAttack
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
ProcessPoison.Power = Power + Player.SC + Level
ProcessPoison.MaxPower = MaxPower + Player.MaxSC + Level
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
Dim TargetId As Object
Dim TargetRace As Races
Dim tempHashtable As Hashtable
Dim GotTarget As Boolean = False
tempHashtable = GetLocalObjects(TargetX, TargetY, Player.Map, 0, 0, Player.StateId)
Dim l As Long
For l = 0 To tempHashtable.Count - 1
If Not tempHashtable(l) Is Nothing Then
TargetId = tempHashtable(l)
TargetRace = Races.Monster
GotTarget = True
End If
Next l
Dim i As Integer
For i = 0 To tempHashtable.Count - 1
If Not tempHashtable(i) Is Nothing Then
TargetId = tempHashtable(i)
TargetRace = Races.Player
GotTarget = True
End If
Next i
If GotTarget Then
ProcessPoison.Targets.Add(TargetId, TargetRace)
End If
End Function
#End Region
#Region "ProcessShootSquare"
Private Function ProcessShootSquare(ByVal Player As clsPlayer, ByVal tMagicAttack As clsMagicAttack, ByVal Level As Byte, ByVal TargetX As Integer, ByVal TargetY As Integer, ByVal Size As MagSizes) As clsMagicAttack
ProcessShootSquare = tMagicAttack
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
ProcessShootSquare.Power = Power + Player.MC + Level
ProcessShootSquare.MaxPower = MaxPower + Player.MaxMC + Level
'#'#'#'#' Work Out Correct Power and Max Power '#'#'#'#'
Dim tempHashtable As Hashtable
Select Case Size
Case MagSizes.m2x2
tempHashtable = GetLocalObjects(TargetX, TargetY, Player.Map, 1, 1, Player.StateId)
Case MagSizes.m4x4
tempHashtable = GetLocalObjects(TargetX, TargetY, Player.Map, 3, 3, Player.StateId)
Case MagSizes.m6x6
tempHashtable = GetLocalObjects(TargetX, TargetY, Player.Map, 5, 5, Player.StateId)
Case MagSizes.m8x8
tempHashtable = GetLocalObjects(TargetX, TargetY, Player.Map, 7, 7, Player.StateId)
End Select
Dim TargetId As Object
Dim TargetRace As Races
Dim l As Long
For l = 0 To tempHashtable.Count - 1
If Not tempHashtable(l) Is Nothing Then
TargetId = tempHashtable(l)
TargetRace = Races.Monster
ProcessShootSquare.Targets.Add(TargetId, TargetRace)
End If
Next l
Dim i As Integer
For i = 0 To tempHashtable.Count - 1
If Not tempHashtable(i) Is Nothing Then
TargetId = tempHashtable(i)
TargetRace = Races.Player
ProcessShootSquare.Targets.Add(TargetId, TargetRace)
End If
Next i
End Function
#End Region
#End Region
#Region "ProcessMagicAttack"
Public Sub ProcessMagicAttack(ByVal MagicAttack As clsMagicAttack)
Select Case MagicAttack.Owner
Case Races.Player
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -