Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Item Type Issue
#19
[code]Function CanAttackPlayer(ByVal Attacker As Long, ByVal Victim As Long) As Boolean

CanAttackPlayer = False

' Check attack timer
If GetTickCount < TempPlayer(Attacker).AttackTimer + 1000 Then Exit Function

' Check for subscript out of range
If Not IsPlaying(Victim) Then Exit Function

' Make sure they are on the same map
If Not GetPlayerMap(Attacker) = GetPlayerMap(Victim) Then Exit Function

' Make sure we dont attack the player if they are switching maps
If TempPlayer(Victim).GettingMap = YES Then Exit Function

' Check if at same coordinates
Select Case GetPlayerDir(Attacker)
Case DIR_UP
If Not ((GetPlayerY(Victim) + 1 = GetPlayerY(Attacker)) And (GetPlayerX(Victim) = GetPlayerX(Attacker))) Then Exit Function
Case DIR_DOWN
If Not ((GetPlayerY(Victim) - 1 = GetPlayerY(Attacker)) And (GetPlayerX(Victim) = GetPlayerX(Attacker))) Then Exit Function
Case DIR_LEFT
If Not ((GetPlayerY(Victim) = GetPlayerY(Attacker)) And (GetPlayerX(Victim) + 1 = GetPlayerX(Attacker))) Then Exit Function
Case DIR_RIGHT
If Not ((GetPlayerY(Victim) = GetPlayerY(Attacker)) And (GetPlayerX(Victim) - 1 = GetPlayerX(Attacker))) Then Exit Function
Case Else
Exit Function
End Select

' Check if map is attackable
If Not Map(GetPlayerMap(Attacker)).Moral = MAP_MORAL_NONE Then
If GetPlayerPK(Victim) = NO Then
Call PlayerMsg(Attacker, "This is a safe zone!", BrightRed)
Exit Function
End If
End If

' Make sure they have more then 0 hp
If GetPlayerVital(Victim, Vitals.HP)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)