?? modmainserver.vb.svn-base
字號(hào):
'#########################################'
'###CHECK TARGET EXISTS + FIND ITS RACE###'
'#########################################'
If ObjectList(TargetId) Is Nothing Then
'No object so we hit nothing
Exit Sub
Else
Dim gPlayer As New clsPlayer
Dim gMonster As New clsMonster
Dim gNpc As New clsNpc
'Get the Race of our target and put it in the TargetRace variable
If ObjectList(TargetId).GetType Is gPlayer.GetType Then
TargetRace = Races.Player
End If
If ObjectList(TargetId).GetType Is gMonster.GetType Then
TargetRace = Races.Monster
End If
If ObjectList(TargetId).GetType Is gNpc.GetType Then
TargetRace = Races.Npc
End If
End If
If CheckMap.MapMode = modMap.MapModes.Safezone And TargetRace = Races.Player Then
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
'!!!!CHECK IF TARGET IS IN A SAFEZONE RANGE!!!!'
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
'Target is a Player and the map mode is safe so hit nothing
Exit Sub
End If
Dim tPlayer As clsPlayer
Dim tMonster As clsMonster
Dim tMonStats As clsMobStats
'#######################################'
'###GET THE DAMAGE + IF WE HIT OR NOT###'
'#######################################'
Select Case TargetRace
Case Races.None
'Dont attack Nothing
Exit Sub
Case Races.Player
'Attack Player
tPlayer = ObjectList(TargetId)
'Get the damage we do
Damage = GetDamage(Player.DC, Player.MaxDC, Player.Luck - Player.Curse)
Player.Target = Races.Player
Player.TargetId = TargetId
tPlayer.Attacker = Races.Player
tPlayer.AttackerId = Player.StateId
'Do we hit or miss?
If Player.Accuracy > Rand(0, tPlayer.Agility) Then
WillHit = True
End If
'Check Players attack mode to see if we do hit or not
Select Case Player.AttackMode
Case clsPlayer.AttackModes.Peaceful
'Peace Attack
Damage = 0
WillHit = False
Case clsPlayer.AttackModes.GroupAttack
'Group Attack
If Player.GroupMembers.Contains(TargetId) Then
Damage = 0
WillHit = False
End If
Case clsPlayer.AttackModes.GuildAttack
'Guild Attack
Damage = 0
WillHit = False
Case clsPlayer.AttackModes.RedBrownAttack
If tPlayer.PKPoint < 199 Then
Damage = 0
WillHit = False
End If
Case clsPlayer.AttackModes.AttackAll
'Attack All
Case clsPlayer.AttackModes.MarriageAttack
'Marriage
Damage = 0
WillHit = False
End Select
'If the target player is dead then we cant hit him
If tPlayer.IsDead Or tPlayer.HP <= 0 Then
Damage = 0
WillHit = False
End If
Case Races.Monster
'Attack Monster
tMonster = ObjectList(TargetId)
tMonStats = MonsterStatsList(tMonster.Name)
'Do we get a holy bonus or not
If tMonStats.Undead Then
Damage = GetDamage(Player.DC, Player.MaxDC, Player.Luck - Player.Curse + Player.Holy)
Else
Damage = GetDamage(Player.DC, Player.MaxDC, Player.Luck - Player.Curse)
End If
tMonster.Target = Races.Player
tMonster.TargetId = State.Index
'Do we hit or miss?
If Player.Accuracy > Rand(0, tMonStats.Agility) Then
WillHit = True
End If
'Monsters dead so we dont hit it
If tMonster.HP <= 0 Then
Damage = 0
WillHit = False
End If
Case Races.Npc
'Dont attack Npcs
Exit Sub
End Select
'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
Select Case TargetRace
Case Races.Player
'Take away some of taget players HP
tPlayer.HP = Math.Max(tPlayer.HP - Damage, 0)
If tPlayer.HP <= 0 Then
'Player died, has he got a revival ring?
tPlayer.Died()
End If
HP = tPlayer.HP
MaxHP = tPlayer.MaxHP
MP = tPlayer.MP
'Process any loss on dura
'Dim Break As Boolean = False
'Dim DuraLoss As Byte = Rand(0, 10) + 5
'For i = 0 To 10
' If i = equipid.weapon Or i = equipid.candle Or equipid.shoes Then
' ElseIf tPlayer.losedur(durloss, i) = True Then
' If i = equipid.armour Or i = equipid.helmet Then
' break = True
' 'tell others we broke something later :p
' End If
' If i = equipid.candle Then
' sendchangelight(State.Index, PlayerList(Player.Name), Player.Light)
' 'technicaly we should tell others our light ended aswell
' End If
' End If
'Next i
'If break = True Then
' tPlayer.recalcstats()
' 'send the packet informing targetplayer about his new stats
' sendlookchanges(tPlayer)
'End If
Case Races.Monster
'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 Select
End If
'######################################'
'###TELL EVERYONE YOU HIT THE TARGET###'
'######################################'
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))
Select Case TargetRace
Case Races.Monster
If tMonster.IsDead Then
'If monster died tell everyone
Packets.SendDied(lPlayer.StateId, TargetId, TargetRace)
'Do Drops
tMonster.DoDrops()
'Add Exp
Player.AddExp(tMonster.Exp, tMonster.MobId)
'Remove Monster
'MonsterList.Remove(tMonster.MobId)
ObjectList.Remove(tMonster.MobId)
Else
Packets.SendStruck(lPlayer.StateId, TargetRace, GetSmallMonsterBuffer(tMonster))
End If
Case Races.Player
If tPlayer.IsDead Then
'If player died tell everyone
Packets.SendDied(lPlayer.StateId, tPlayer.StateId, TargetRace)
'Do Drops
Else
Packets.SendStruck(lPlayer.StateId, TargetRace, GetSmallPlayerBuffer(tPlayer))
End If
End Select
End If
Next i
End If
End Sub
#End Region
#Region "ProcessMagicAttack"
Public Sub ProcessMagicAttack(ByVal Header As Header, ByVal State As State)
Dim TargetX As Short = Header.wParam
Dim TargetY As Short = Header.wTag
Dim MagicId As Integer = Header.nRecog
'Player that is doing the action
Dim Player As clsPlayer = ObjectList(State.Index)
'#########################'
'###CHECK THEY CAN CAST###'
'#########################'
'Check they can perform the action and that server and client are in sync
If Player.IsDead Or Player.Poison = clsPlayer.Poisons.Paralysis Or Not Player.PlayerMagics.Contains(MagicId) Or Not MagicList.Contains(MagicKeyList(MagicId)) Then
Packets.SendCastFail(State.Index)
Exit Sub
End If
Dim Magic As clsMagic = MagicList(MagicKeyList(MagicId))
'Check target is in the range of the caster
If Not CheckInRangeXY(Player.X, Player.Y, TargetX, TargetY, Magic.AttackRange, Magic.AttackRange) Then Exit Sub
'######################'
'###IF THEY CAN CAST###'
'######################'
'Tell them they can cast
Packets.SendCastOk(State.Index)
Player.Dir = Header.wSeries
'########################'
'### USE MAGIC ###'
'########################'
Dim MagicAttack As clsMagicAttack
MagicAttack = Magic.UseMagic(Player, TargetX, TargetY)
Magic.ProcessMagicAttack(MagicAttack)
'###########################'
'###TELL EVERYONE WE CAST###'
'### AND WHERE ###'
'###########################'
Dim i As Integer
Dim Locals As Hashtable = GetLocalObjects(Player.X, Player.Y, Player.Map, 15, 15, -1)
Dim Added As New Hashtable
Dim lPlayerId As Integer
For i = 0 To Locals.Count - 1
If Not Locals(i) Is Nothing Then
'Its a player
lPlayerId = Locals(i)
If Not Added.Contains(lPlayerId) And Not lPlayerId = Player.StateId Then
Packets.SendCast(lPlayerId, Player.StateId, Races.Player, Player.Dir, Magic.Looks, TargetX, TargetY)
Added.Add(lPlayerId, "")
End If
End If
Next i
Added.Clear()
'######################################'
'###TELL EVERYONE WE STRUCK AND WHAT###'
'######################################'
Dim TargetRace As Races
Dim TargetId As Object
Dim m As Long
Dim en As IDictionaryEnumerator = MagicAttack.Targets.GetEnumerator
While en.MoveNext
Dim tMonster As clsMonster
Dim tPlayer As clsPlayer
TargetRace = en.Value
TargetId = en.Key
Dim lPlayer As clsPlayer
For i = 0 To Locals.Count - 1
If Not Locals(i) Is Nothing Then
'Tell players
lPlayer = ObjectList(Locals(i))
Select Case TargetRace
Case Races.Monster
tMonster = ObjectList(TargetId)
If tMonster.IsDead Then
'If monster died tell everyone
Packets.SendDied(lPlayer.StateId, TargetId, TargetRace)
'Do Drops
tMonster.DoDrops()
'Add Exp
Player.AddExp(tMonster.Exp, tMonster.MobId)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -