Option Explicit

 

Private sCharName As String

Private sClass As String

Private iLevel As Integer

Private iAC As Integer

Private iCurHP As Integer

Private iBaseHP As Integer

'Skill Points

Private iSP As Integer

Private iCurSP As Integer

'Current and normal Mana

Private iCurMana As Integer

Private iBaseMana As Integer

 

Private iAction As CharacterAction

'Any misc offensive or defensive bonuses (ie. spells cast on character, items, etc. May be positive or negative)

Private objDefBonus() As udtBonus

Private objOffBonus() As udtBonus

 

'Optional members

Private sAlignment As String

Private sSex As String

Private iAge As Integer

Private iWeight As Integer

Private iHeight As Integer

Private sEyes As String

Private sHair As String

Private iDiseaseResistance As Integer

Private iPoisonResistance As Integer

Private iMagicResistance As Integer

'End optional members

 

Private Stats() As udtStat

Private objSkills As New Collection

Private objArmors As New Collection

Private objWeapons As New Collection

Private objSpells As New Collection

Private sRace As String

'Index into Characters collection

Private iTarget As Integer

Private sMapName As String

'Contains bitmap of all character frames for current armor/weapon combination

Private objCharSprite As New clsSprite

 

Public Property Let CharName(ByVal sData As String)

    sCharName = sData

End Property

 

Public Property Get CharName() As String

    CharName = sCharName

End Property

 

Public Property Let Class(ByVal sData As String)

    sClass = sData

End Property

 

Public Property Get Class() As String

    Class = sClass

End Property

 

Public Property Let Level(ByVal iData As Integer)

    iLevel = iData

End Property

 

Public Property Get Level() As Integer

    Level = iLevel

End Property

 

Public Property Let AC(iData As Integer)

    iAC = iData

End Property

 

Public Property Get AC() As Integer

    AC = iAC

End Property

 

Public Property Get HP() As Integer

    HP = iCurHP

End Property

 

Public Property Let HP(iData As Integer)

    iCurHP = iData

End Property

 

Public Property Get BaseHP() As Integer

    BaseHP = iBaseHP

End Property

 

Public Property Let BaseHP(iData As Integer)

    iBaseHP = iData

End Property

 

Public Property Let SP(ByVal iData As Integer)

    iSP = iData

End Property

 

Public Property Get SP() As Integer

    SP = iSP

End Property

 

Public Property Let CurSP(ByVal iData As Integer)

    iCurSP = iData

End Property

 

Public Property Get CurSP() As Integer

    SP = iCurSP

End Property

 

Public Property Let CurMana(ByVal iData As Integer)

    iCurMana = iData

End Property

 

Public Property Get CurMana() As Integer

    CurMana = iCurMana

End Property

 

Public Property Let Mana(ByVal iData As Integer)

    iBaseMana = iData

End Property

 

Public Property Get Mana() As Integer

    Mana = iBaseMana

End Property

 

Public Property Let Race(ByVal sData As String)

    sRace = sData

End Property

 

Public Property Get Race() As String

    Race = sRace

End Property

 

Public Property Let Alignment(ByVal sData As String)

    sAlignment = sData

End Property

 

Public Property Get Alignment() As String

    Alignment = sAlignment

End Property

 

Public Property Let Sex(ByVal sData As String)

    sSex = sData

End Property

 

Public Property Get Sex() As String

    Sex = sSex

End Property

 

Public Property Let Height(ByVal iData As Integer)

    iHeight = iData

End Property

 

Public Property Get Height() As Integer

    Height = iHeight

End Property

 

Public Property Let Weight(ByVal iData As Integer)

    iWeight = iData

End Property

 

Public Property Get Weight() As Integer

    Weight = iWeight

End Property

 

Public Property Let Hair(ByVal sData As String)

    sHair = sData

End Property

 

Public Property Get Hair() As String

    Hair = sHair

End Property

 

Public Property Let Eyes(ByVal sData As String)

    sEyes = sData

End Property

 

Public Property Get Eyes() As String

    Eyes = sEyes

End Property

 

Public Property Let Age(ByVal iData As Integer)

    iAge = iData

End Property

 

Public Property Get Age() As Integer

    Age = iAge

End Property

 

Public Property Get CharPicture() As DirectDrawSurface7

    Set CharPicture = picCharacter.objSurface

End Property

 

Public Property Set CharPicture(picData As DirectDrawSurface7)

    Set picCharacter.objSurface = picData

End Property

 

Public Property Let Action(ByVal iData As Integer)

    iAction = iData

End Property

 

Public Property Get Action() As Integer

    Action = iAction

End Property

 

Public Property Let Stat(ByVal iIndex As Integer, ByVal iData As Integer)

    Stats(iIndex) = iData

    If iIndex = STAT_STR Then

        iMaxWeight = Stats(STAT_STR) * 5

    End If

End Property

 

Public Property Get Stat(ByVal iIndex As Integer) As Integer

    'Assumes iIndex will be zero based per constants used

    Stat = Stats(iIndex + 1)

End Property

 

Public Property Let MapName(ByVal sData As String)

    sMapName = sData

End Property

 

Public Property Get MapName() As String

    MapName = sMapName

End Property

 

Public Property Let Target(ByVal iData As Integer)

    iTarget = iData

End Property

 

Public Property Get Target() As Integer

    Target = iTarget

End Property

 

Public Property Let Armors(ByVal objData As Collection)

    Set objArmors = objData

End Property

 

Public Property Get Armors() As Collection

    Set Armors = objArmors

End Property

 

Public Property Let Weapons(ByVal objData As Collection)

    Set objWeapons = objData

End Property

 

Public Property Get Weapons() As Collection

    Set Weapons = objWeapons

End Property

 

Public Property Let Skills(ByVal objData As Collection)

    Set objSkills = objData

End Property

 

Public Property Get Skills() As Collection

    Set Skills = objSkills

End Property

 

Public Property Let Spells(ByVal objData As Collection)

    Set objSpells = objData

End Property

 

Public Property Get Spells() As Collection

    Set Spells = objSpells

End Property

 

Private Sub Class_Initialize()

   

    'Initial direction is East

    iDirection = DIR_EAST

   

End Sub

 

Public Sub PerformAction()

 

    Select Case iAction

   

        Case ACTION_ATTACK

           

       

       

        Case ACTION_DEFEND

           

           

       

        Case ACTION_SEARCH

       

       

       

        Case ACTION_LOOK

       

       

       

        Case ACTION_DISARM

       

       

       

        Case ACTION_JUMP

       

       

       

        Case ACTION_CLIMB

       

       

       

        Case ACTION_IDLE

       

       

       

        Case ACTION_PREPARESPELL

       

       

       

        Case ACTION_CASTSPELL

       

        

       

        Case ACTION_DIE

       

       

       

        Case ACTION_WALK

       

       

       

    End Select

End Sub

 

Public Sub Damage(iDamage As Integer)

 

    Dim iHP As Integer

   

    iHP = iDamage - objArmors.Defense

   

    If iHP > 0 Then

        iCurHP = iCurHP - iHP

        If iCurHP < 1 Then

            iAction = ACTION_DIE

        End If

    End If

   

End Sub

 

Public Property Get Direction() As Integer

    Direction = iDirection

End Property

 

Public Property Let Direction(iData As Integer)

    iDirection = iData

End Property

 

Public Property Get X() As Integer

    X = iX

End Property

 

Public Property Let X(iData As Integer)

    iX = iData

End Property

 

Public Property Get Y() As Integer

    Y = iY

End Property

 

Public Property Let Y(iData As Integer)

    iY = iData

End Property

 

Public Function GetDefBonus() As Integer

   

    Dim iLp As Integer

    Dim iTotal As Integer

   

    iTotal = 0

   

    For iLp = 0 To UBound(objDefBonus)

        iTotal = iTotal + objDefBonus(iLp).iAmount

    Next iLp

   

    GetDefBonus = iTotal

   

End Function

 

Public Sub SetDefBonus(ByVal iAmount As Integer, ByVal iTimeStarted As Integer, ByVal iDuration As Integer)

 

    Dim iIndex As Integer

   

    On Error Resume Next

   

    iIndex = -1

   

    iIndex = UBound(objDefBonus)

   

    If iIndex = -1 Then

        iIndex = 0

        ReDim objDefBonus(iIndex)

    Else

        iIndex = iIndex + 1

        ReDim Preserve objDefBonus(iIndex)

    End If

   

    With objDefBonus(iIndex)

        .iAmount = iAmount

        .iDuration = iDuration

        .iTimeStarted = iTimeStarted

    End With

   

End Sub

 

Public Function GetOffBonus() As Integer

 

    Dim iLp As Integer

    Dim iTotal As Integer

   

    iTotal = 0

   

    For iLp = 0 To UBound(objOffBonus)

        iTotal = iTotal + objOffBonus(iLp).iAmount

    Next iLp

   

    GetOffBonus = iTotal

End Function

 

Public Sub SetOffBonus(ByVal iAmount As Integer, ByVal iTimeStarted As Integer, ByVal iDuration As Integer)

 

    Dim iIndex As Integer

   

    On Error Resume Next

   

    iIndex = -1

   

    iIndex = UBound(objOffBonus)

   

    If iIndex = -1 Then

        iIndex = 0

        ReDim objOffBonus(iIndex)

    Else

        iIndex = iIndex + 1

        ReDim Preserve objOffBonus(iIndex)

    End If

   

    With objOffBonus(iIndex)

        .iAmount = iAmount

        .iDuration = iDuration

        .iTimeStarted = iTimeStarted

    End With

 

End Sub

 

Public Property Let DiseaseResistance(ByVal iData As Integer)

    iDiseaseResistance = iData

End Property

 

Public Property Let PoisonResistance(ByVal iData As Integer)

    iPoisonResistance = iData

End Property

 

Public Property Let MagicResistance(ByVal iData As Integer)

    iMagicResistance = iData

End Property

 

Public Property Get DiseaseResistance() As Integer

    DiseaseResistance = iDiseaseResistance

End Property

 

Public Property Get PoisonResistance() As Integer

    PoisonResistance = iPoisonResistance

End Property

 

Public Property Get MagicResistance() As Integer

    MagicResistance = iMagicResistance

End Property

 

Public Function MaxWeight() As Integer

    MaxWeight = Stats(STAT_STR).iCurVal * 5

End Function