Attribute VB_Name = "EnemyAI"
'//Programmed by: Ervin Louie B. Pe Benito
'//EnemyAI.bas
'//This module is responsible for decision making of an enemy during the fight
Option Explicit
Public EnemyTurn As Boolean
Public ItemDesc As String
Public ItemName As String
Public tempstats As StatsOfEnemy
Public EnemyMove As Integer
'If enemymove = 1 then he will attack
'if enemymove = 2 then he will block
'if enemymove = 3 then he will use an item
Private HealAmount As Long
'AI code
Public Sub ImplementAI()
Dim bTemp1, btemp2 As Boolean
        bTemp1 = CheckLifeIfOnDanger
        If bTemp1 = True Then
            btemp2 = EnemyHeal
            If btemp2 = False Then
                EnemyMove = Attack
            End If
        Else
            'if enemy is not on danger, He will attack
            EnemyMove = Attack
        End If
End Sub
'Life checking
Private Function CheckLifeIfOnDanger() As Boolean
    If tempstats.Life <= (tempstats.MaxLife * 0.4) Then
        CheckLifeIfOnDanger = True
    Else
        CheckLifeIfOnDanger = False
    End If
End Function
'Heal
Private Function EnemyHeal() As Boolean
    'EnemyChar.Status = 3
    If tempstats.ItemCount > 0 Then
        If tempstats.Belt = 3 Then
            ItemDesc = GameItem(3).ItemDesc
            ItemName = GameItem(3).ItemName
            HealAmount = 8
        ElseIf tempstats.Belt = 4 Then
            ItemDesc = GameItem(4).ItemDesc
            ItemName = GameItem(4).ItemName
            HealAmount = 16
        ElseIf tempstats.Belt = 5 Then
            ItemDesc = GameItem(5).ItemDesc
            ItemName = GameItem(5).ItemName
            HealAmount = 32
        ElseIf tempstats.Belt = 6 Then
            ItemDesc = GameItem(6).ItemDesc
            ItemName = GameItem(6).ItemName
            HealAmount = 65
        End If
        EnemyHeal = True
        EnemyMove = Useitem
    Else
        EnemyHeal = False
    End If
End Function
Public Sub HealEffect()
    If (HealAmount + tempstats.Life) > tempstats.MaxLife Then
            tempstats.Life = tempstats.MaxLife
            tempstats.ItemCount = tempstats.ItemCount - 1
        Else
            tempstats.Life = HealAmount
            tempstats.ItemCount = tempstats.ItemCount - 1
    End If
End Sub
