VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "monster"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public IdNum As Byte
Public attacksound As Byte
Public Word2 As Long
Public Word4 As Long
Public Speed As Byte
Public MinSpeed As Byte
Public Armor As Byte
Public BaseHealth As Byte
Public quickness As Byte
Public Poison As Byte
Public power As Byte
Public Unused1 As Byte
Public word14 As Long
Public word16 As Long
Public word18 As Long
Public word20 As Long
Public byte22 As Byte
Public byte23 As Byte
Public damagetype As Byte
Public Unused2 As Byte


'byte1: 0x01 tested for itself?
'byte2: if non-zero, play sound number for attack
'word3:
'0x0003: 0 = 1/4 space, 1 = 1/2 space, 2 = 1 space (dragon)
'0x0004: attacks no matter if facing or not (always faces)
'0x0008: can go through walls
'0x0010: dumb (won't hit a live character sometimes)
'0x0020: levitates
'0x0040: if set, monster only affected by disrupt/vorpal blades
'        if 0, disrupting automisses
'        if 0, can hit with normal weapons
'0x0080: immune to missiles (except dispell)
'0x0100: short... doors close more on top of them
'0x0200: drop items when die
'0x0400: absorbs arrows, ninja stars, etc
'0x0800: can see invisible
'0x1000: can see in dark
'0x2000: invulnerable?

Public Function w2_space() As Byte
    w2_space = (Word2 And &H3)
End Function
Public Function w2_unknown1() As Byte
    w2_unknown1 = (Word2 And &H4) / &H4
End Function
Public Function w2_walkthroughwalls() As Byte
    w2_walkthroughwalls = (Word2 And &H8) / &H8
End Function
Public Function w2_dumb() As Byte
    w2_dumb = (Word2 And &H10) / &H10
End Function
Public Function w2_levitates() As Byte
    w2_levitates = (Word2 And &H20) / &H20
End Function
Public Function w2_nonmaterial() As Byte
    w2_nonmaterial = (Word2 And &H40) / &H40
End Function
Public Function w2_immunetomissiles() As Byte
    w2_immunetomissiles = (Word2 And &H80) / &H80
End Function
Public Function w2_short() As Byte
    w2_short = (Word2 And &H100) / &H100
End Function
Public Function w2_dropsitems() As Byte
    w2_dropsitems = (Word2 And &H200) / &H200
End Function
Public Function w2_absorbsmissiles() As Byte
    w2_absorbsmissiles = (Word2 And &H400) / &H400
End Function
Public Function w2_seeinvisible() As Byte
    w2_seeinvisible = (Word2 And &H800) / &H800
End Function
Public Function w2_seedarkness() As Byte
    w2_seedarkness = (Word2 And &H1000) / &H1000
End Function
Public Function w2_invulnerable() As Byte
    w2_invulnerable = (Word2 And &H2000) / &H2000
End Function

Public Function set_w2_space(num As Long)
    If num > 3 Then
        num = 3
    End If
    If num < 0 Then
        num = 0
    End If
    Word2 = (Word2 And &HFFFC) + num
End Function
Public Function set_w2_unknown1(num As Long)
    Word2 = (Word2 And (&HFFFF - &H4))
    If num = 1 Then
        Word2 = Word2 + &H4
    End If
End Function
Public Function set_w2_walkthroughwalls(num As Long)
    Word2 = (Word2 And (&HFFFF - &H8))
    If num = 1 Then
        Word2 = Word2 + &H8
    End If
End Function
Public Function set_w2_dumb(num As Long)
    Word2 = (Word2 And (&HFFFF - &H10))
    If num = 1 Then
        Word2 = Word2 + &H10
    End If
End Function
Public Function set_w2_levitates(num As Long)
    Word2 = (Word2 And (&HFFFF - &H20))
    If num = 1 Then
        Word2 = Word2 + &H20
    End If
End Function
Public Function set_w2_nonmaterial(num As Long)
    Word2 = (Word2 And (&HFFFF - &H40))
    If num = 1 Then
        Word2 = Word2 + &H40
    End If
End Function
Public Function set_w2_immunetomissiles(num As Long)
    Word2 = (Word2 And (&HFFFF - &H80))
    If num = 1 Then
        Word2 = Word2 + &H80
    End If
End Function
Public Function set_w2_short(num As Long)
    Word2 = (Word2 And (&HFFFF - &H100))
    If num = 1 Then
        Word2 = Word2 + &H100
    End If
End Function
Public Function set_w2_dropsitems(num As Long)
    Word2 = (Word2 And (&HFFFF - &H200))
    If num = 1 Then
        Word2 = Word2 + &H200
    End If
End Function
Public Function set_w2_absorbsmissiles(num As Long)
    Word2 = (Word2 And (&HFFFF - &H400))
    If num = 1 Then
        Word2 = Word2 + &H400
    End If
End Function
Public Function set_w2_seeinvisible(num As Long)
    Word2 = (Word2 And (&HFFFF - &H800))
    If num = 1 Then
        Word2 = Word2 + &H800
    End If
End Function
Public Function set_w2_seedarkness(num As Long)
    Word2 = (Word2 And (&HFFFF - &H1000))
    If num = 1 Then
        Word2 = Word2 + &H1000
    End If
End Function
Public Function set_w2_invulnerable(num As Long)
    Word2 = (Word2 And (&HFFFF - &H2000))
    If num = 1 Then
        Word2 = Word2 + &H2000
    End If
End Function

'word5: This has alot to do with a monsters graphics i think...
'0x0003: something to do with scaling?
'0x0004: making a mirror image for something?
'0x0008: side image exists
'0x0010: back image exists
'0x0020: attack graphic exists
'0x0040: 0
'0x0080: ??? __ these 2 come in pairs, both set or not.
'0x0100: ??? ^^
'0x0200: mirrored attack image
'0x0400: if 0, mirror attack image while mid-attack
'0x0800: 0
'0x3000: shiftgroup x
'0xC000: shiftgroup y

Public Function w4_frontgraphics() As Byte
    w4_frontgraphics = (Word4 And &H3)
End Function
Public Function w4_mirrorimage() As Byte
    w4_mirrorimage = (Word4 And &H4) / &H4
End Function
Public Function w4_sideimage() As Byte
    w4_sideimage = (Word4 And &H8) / &H8
End Function
Public Function w4_backimage() As Byte
    w4_backimage = (Word4 And &H10) / &H10
End Function
Public Function w4_attackimage() As Byte
    w4_attackimage = (Word4 And &H20) / &H20
End Function
Public Function w4_unknown1() As Byte
    w4_unknown1 = (Word4 And &H40) / &H40
End Function
Public Function w4_unknown2() As Byte
    w4_unknown2 = (Word4 And &H80) / &H80
End Function
Public Function w4_unknown3() As Byte
    w4_unknown3 = (Word4 And &H100) / &H100
End Function
Public Function w4_mirroredattack() As Byte
    w4_mirroredattack = (Word4 And &H200) / &H200
End Function
Public Function w4_dontmirrorwhileattacking() As Byte
    w4_dontmirrorwhileattacking = (Word4 And &H400) / &H400
End Function
Public Function w4_unknown4() As Byte
    w4_unknown4 = (Word4 And &H800) / &H800
End Function
Public Function w4_xshiftgroup() As Byte
    w4_xshiftgroup = (Word4 And &H3000) / &H1000
End Function
Public Function w4_yshiftgroup() As Byte
    w4_yshiftgroup = (Word4 And &HC000) / &H4000
End Function

Public Function set_w4_frontgraphics(num As Long)
    Word4 = (Word4 And (&HFFFF - &H3))
    Word4 = Word4 + (num And &H3)
End Function
Public Function set_w4_mirrorimage(num As Long)
    Word4 = (Word4 And (&HFFFF - &H4))
    If num = 1 Then
        Word4 = Word4 + &H4
    End If
End Function
Public Function set_w4_sideimage(num As Long)
    Word4 = (Word4 And (&HFFFF - &H8))
    If num = 1 Then
        Word4 = Word4 + &H8
    End If
End Function
Public Function set_w4_backimage(num As Long)
    Word4 = (Word4 And (&HFFFF - &H10))
    If num = 1 Then
        Word4 = Word4 + &H10
    End If
End Function
Public Function set_w4_attackimage(num As Long)
    Word4 = (Word4 And (&HFFFF - &H20))
    If num = 1 Then
        Word4 = Word4 + &H20
    End If
End Function
Public Function set_w4_unknown1(num As Long)
    Word4 = (Word4 And (&HFFFF - &H40))
    If num = 1 Then
        Word4 = Word4 + &H40
    End If
End Function
Public Function set_w4_unknown2(num As Long)
    Word4 = (Word4 And (&HFFFF - &H80))
    If num = 1 Then
        Word4 = Word4 + &H80
    End If
End Function
Public Function set_w4_unknown3(num As Long)
    Word4 = (Word4 And (&HFFFF - &H100))
    If num = 1 Then
        Word4 = Word4 + &H100
    End If
End Function
Public Function set_w4_mirroredattack(num As Long)
    Word4 = (Word4 And (&HFFFF - &H200))
    If num = 1 Then
        Word4 = Word4 + &H200
    End If
End Function
Public Function set_w4_dontmirrorwhileattacking(num As Long)
    Word4 = (Word4 And (&HFFFF - &H400))
    If num = 1 Then
        Word4 = Word4 + &H400
    End If
End Function
Public Function set_w4_unknown4(num As Long)
    Word4 = (Word4 And (&HFFFF - &H800))
    If num = 1 Then
        Word4 = Word4 + &H800
    End If
End Function
Public Function set_w4_xshiftgroup(num As Long)
    Word4 = (Word4 And (&HFFFF - &H3000))
        Word4 = Word4 + (num * &H1000)
End Function
Public Function set_w4_yshiftgroup(num As Long)
    Word4 = (Word4 And (&HFFFF - &HC000))
        Word4 = Word4 + (num * &H4000)
End Function

'byte7: 255 - self = ticks per move (lower the faster)
'byte8: minimum time to do something?
'byte9: resistance to projectiles?
'byte10: base HP
'byte11: quickness of monster (hit prob)
'byte12: poisonousness of attack
'byte13: power of spell casted and attack
'byte14: unused

'word14:
'0x000F: how far monster can see, reduced by 1/2 for each darkness level
'0x0F00: turn towards player if this close?
'0xF000: compared to distance of prey?
'0xE000: 2-15, casts spells... something to do w/ timing as well?
Public Function w14_sightrange() As Byte
    w14_sightrange = (word14 And &HF)
End Function
Public Function w14_unused1() As Byte
    w14_unused1 = (word14 And &HF0) / &H10
End Function
Public Function w14_awarenessrange() As Byte
    w14_awarenessrange = (word14 And &HF00) / &H100
End Function
Public Function w14_spellrange() As Byte
    w14_spellrange = (word14 And &HF000) / &H1000
End Function


Public Function set_w14_sightrange(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word14 = (word14 And &HFFF0) + (num * &H1)
End Function
Public Function set_w14_unused1(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word14 = (word14 And &HFF0F) + (num * &H10)
End Function
Public Function set_w14_awarenessrange(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word14 = (word14 And &HF0FF) + (num * &H100)
End Function
Public Function set_w14_spellrange(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    num = num * &H1000
    word14 = (word14 And &HFFF) + num
End Function

'word16:
'0x000F: unused
'0x00F0: bravery, how immune to warcry/calm etc
'0x0F00: amount of skill characters gain when damaged/damage monster
'0xF000: <10 ? then it gets teleported, otherwise not.

Public Function w16_unused1() As Byte
    w16_unused1 = (word16 And &HF) / &H1
End Function
Public Function w16_bravery() As Byte
    w16_bravery = (word16 And &HF0) / &H10
End Function
Public Function w16_skill() As Byte
    w16_skill = (word16 And &HF00) / &H100
End Function
Public Function w16_teleportation() As Byte
    w16_teleportation = (word16 And &HF000) / &H1000
End Function

Public Function set_w16_unused1(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word16 = (word16 And &HFFF0) + (num * &H1)
End Function
Public Function set_w16_bravery(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word16 = (word16 And &HFF0F) + (num * &H10)
End Function
Public Function set_w16_skill(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word16 = (word16 And &HF0FF) + (num * &H100)
End Function
Public Function set_w16_teleportation(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    num = num * &H1000
    word16 = (word16 And &HFFF) + num
End Function

'word18:
'0x000F: unused
'0x00F0: resistance to magic (15 = immune)
'0x0F00: resistance to poison (15 = immune)
'0xF000: unused

Public Function w18_unused1() As Byte
    w18_unused1 = (word18 And &HF) / &H1
End Function
Public Function w18_magicresistance() As Byte
    w18_magicresistance = (word18 And &HF0) / &H10
End Function
Public Function w18_poisonresistance() As Byte
    w18_poisonresistance = (word18 And &HF00) / &H100
End Function
Public Function w18_unused2() As Byte
    w18_unused2 = (word18 And &HF000) / &H1000
End Function

Public Function set_w18_unused1(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word18 = (word18 And &HFFF0) + (num * &H1)
End Function
Public Function set_w18_magicresistance(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word18 = (word18 And &HFF0F) + (num * &H10)
End Function
Public Function set_w18_poisonresistance(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word18 = (word18 And &HF0FF) + (num * &H100)
End Function
Public Function set_w18_unused2(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    num = num * &H1000
    word18 = (word18 And &HFFF) + num
End Function

'word20:
'0x000F: time to show attack graphic
'0x00F0: speed of movment when fleeing, time between status update
'0x0F00: time between status update while attacking

Public Function w20_attacklength() As Byte
    w20_attacklength = (word20 And &HF) / &H1
End Function
Public Function w20_statusupdate() As Byte
    w20_statusupdate = (word20 And &HF0) / &H10
End Function
Public Function w20_attackstatusupdate() As Byte
    w20_attackstatusupdate = (word20 And &HF00) / &H100
End Function
Public Function w20_unused1() As Byte
    w20_unused1 = (word20 And &HF000) / &H1000
End Function

Public Function set_w20_attacklength(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word20 = (word20 And &HFFF0) + (num * &H1)
End Function
Public Function set_w20_statusupdate(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word20 = (word20 And &HFF0F) + (num * &H10)
End Function
Public Function set_w20_attackstatusupdate(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    word20 = (word20 And &HF0FF) + (num * &H100)
End Function
Public Function set_w20_unused1(num As Long)
    If num > 15 Then
        num = 15
    End If
    If num < 0 Then
        num = 0
    End If
    num = num * &H1000
    word20 = (word20 And &HFFF) + num
End Function

'word22: Hit location mask #'s (4 of them)
'  Basically, its kind of random which NIBBLE it uses
'  It looks up the chart of "hit location masks" with a somewhat
'  random nibble.  That chart shows what items actually help when
'  it comes to armor....  I don't understand the use, its very
'  complicated...  I think it has something to do with certain monsters
'  having a better chance of "injuring" your arms, feet, chest, etc

'byte25: something to do with damage (0 = no damage)
'if 1, affectd by anti-fire
'if 2, halves the effects of armor
'if 4, has x8000 flag (deals piercing damage?),
'if 6, = (115-wisdom)/64 * the damage
'if 5, affected by anti-magic
'byte26: unused


'To sum it up, this is a complete pile of shit thrown together



