VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "file560"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public itemdata As String
Public itemloc As Long

Private Attacks(1 To 44) As New attack
Private Combos(1 To 44) As New Combo
Private Spells(1 To 25) As New Spell
Private rects(1 To 24) As Integer
Private Runes(1 To 24) As Byte
Private RuneMultipliers(1 To 6) As Byte
Private bytes20194(1 To 16) As Byte
Private byte19218 As Integer

Function read_byte() As Byte
    read_byte = AscB(MidB(itemdata, itemloc, 1))
    itemloc = itemloc + 1
End Function

Function read_int() As Long
    Dim b1, b2 As Byte
    Dim l1 As Long
    b2 = read_byte
    b1 = read_byte
    read_int = b2
    read_int = read_int * 256
    read_int = read_int + b1
End Function

Function write_byte(num As Byte)
    itemdata = itemdata + ChrB(num)
    itemloc = itemloc + 1
End Function
Function write_int(num As Long)
    Dim b1, b2 As Byte
    Dim l1 As Long
    l1 = num And &HFF00
    b1 = l1 / &H100
    b2 = num And &HFF
    write_byte (b1)
    write_byte (b2)
End Function

Public Function attack(ByVal num As Integer) As attack
    Set attack = Attacks(num)
End Function
Public Function Combo(ByVal num As Integer) As Combo
    Set Combo = Combos(num)
End Function
Public Function Spell(ByVal num As Integer) As Spell
    Set Spell = Spells(num)
End Function
Public Function rect(ByVal num As Integer) As Integer
    rect = rects(num)
End Function
Public Function rune(ByVal num As Integer) As Byte
    rune = Runes(num)
End Function
Public Function setrune(ByVal num As Integer, ByVal val As Byte)
    Runes(num) = val
End Function
Public Function runemultiplier(ByVal num As Integer) As Byte
    runemultiplier = RuneMultipliers(num)
End Function
Public Function setrunemultiplier(ByVal num As Integer, ByVal val As Byte)
    RuneMultipliers(num) = val
End Function
Public Function byte20194(ByVal num As Integer) As Byte
    byte20194 = bytes20194(num)
End Function

Public Sub update()
    Dim i As Integer
    Dim atknum As Integer
    Dim var As Integer
    
    itemdata = ""
    itemloc = 1
    var = 0
    For atknum = 1 To 44
        var = var + 1 + Len(Attacks(atknum).name)
    Next
    
    If var > 299 Then
        MsgBox ("Error: Attacks total name length too large!" + chr(13) + chr(13) + "Total characters: " + Str(var) + "/300")
        Exit Sub
    End If
    
    For i = 1 To 24
        write_int (rects(i))
    Next
    
    For i = 1 To 16
        write_byte (bytes20194(i))
    Next

    For i = 1 To 44
        write_byte (Attacks(i).Exp)
    Next
    For i = 1 To 44
        write_byte (Attacks(i).Skill)
    Next
    For i = 1 To 44
        If Attacks(i).Defense < 0 Then
            Attacks(i).Defense = Attacks(i).Defense + 256
        End If
        write_byte (Attacks(i).Defense)
    Next
    For i = 1 To 44
        write_byte (Attacks(i).Stamina)
    Next
    For i = 1 To 44
        write_byte (Attacks(i).HitProb)
    Next
    For i = 1 To 44
        write_byte (Attacks(i).Damage)
    Next
    For i = 1 To 44
        write_byte (Attacks(i).Fatigue)
    Next
    
    var = 0
    For atknum = 1 To 44
        For i = 1 To Len(Attacks(atknum).name)
            var = var + 1
            write_byte (Asc(Mid(Attacks(atknum).name, i, 1)))
        Next
        write_byte (0)
        var = var + 1
    Next
    For var = var To 299
        write_byte (0)
    Next


    For i = 1 To 44
        write_byte (Combos(i).attack1)
        write_byte (Combos(i).attack2)
        write_byte (Combos(i).attack3)
        write_byte (Combos(i).Byte4)
        write_byte (Combos(i).Byte5)
        write_byte (Combos(i).byte6)
        write_byte (Combos(i).Unused1)
        write_byte (Combos(i).Unused2)
    Next
    
    write_int (byte19218)
    
    For i = 1 To 25
        write_byte (Spells(i).Rune1)
        write_byte (Spells(i).Rune2)
        write_byte (Spells(i).Rune3)
        write_byte (Spells(i).Rune4)
        write_byte (Spells(i).Difficulty)
        write_byte (Spells(i).Skill)
        write_int (Spells(i).word6)
    Next
        
    For i = 1 To 6
        write_byte (RuneMultipliers(i))
    Next
    
    For i = 1 To 24
        write_byte (Runes(i))
    Next
    graphics.setgitemsize 560, LenB(itemdata)
    graphics.setgitemdata 560, itemdata
End Sub
Public Sub read()
    Dim i As Integer
    Dim atknum As Integer
    Dim var As Integer
    Dim l As Long
    
    itemloc = 1
    
    For i = 1 To 24
        l = read_int()
        rects(i) = l
    Next
    
    For i = 1 To 16
        bytes20194(i) = read_byte()
    Next

    For i = 1 To 44
        Attacks(i).Exp = read_byte()
    Next
    For i = 1 To 44
        Attacks(i).Skill = read_byte()
    Next
    For i = 1 To 44
        Attacks(i).Defense = read_byte()
        If Attacks(i).Defense > 128 Then
            Attacks(i).Defense = Attacks(i).Defense - 256
        End If
    Next
    For i = 1 To 44
        Attacks(i).Stamina = read_byte()
    Next
    For i = 1 To 44
        Attacks(i).HitProb = read_byte()
    Next
    For i = 1 To 44
        Attacks(i).Damage = read_byte()
    Next
    For i = 1 To 44
        Attacks(i).Fatigue = read_byte()
    Next
    
    For i = 1 To 44
        Attacks(i).name = ""
    Next
    atknum = 1
    For i = 1 To 300
        var = read_byte()
        If var = 0 Then
            atknum = atknum + 1
        Else
            If atknum <= 44 Then
                Attacks(atknum).name = Attacks(atknum).name & chr(var)
            End If
        End If
    Next

    For i = 1 To 44
        Combos(i).attack1 = read_byte()
        Combos(i).attack2 = read_byte()
        Combos(i).attack3 = read_byte()
        Combos(i).Byte4 = read_byte()
        Combos(i).Byte5 = read_byte()
        Combos(i).byte6 = read_byte()
        Combos(i).Unused1 = read_byte()
        Combos(i).Unused2 = read_byte()
    Next
        
    byte19218 = read_int()
    
    For i = 1 To 25
        Spells(i).Rune1 = read_byte()
        Spells(i).Rune2 = read_byte()
        Spells(i).Rune3 = read_byte()
        Spells(i).Rune4 = read_byte()
        Spells(i).Difficulty = read_byte()
        Spells(i).Skill = read_byte()
        Spells(i).word6 = read_int()
    Next
        
    For i = 1 To 6
        RuneMultipliers(i) = read_byte()
    Next
    
    For i = 1 To 24
        Runes(i) = read_byte()
    Next
    
End Sub

