Option Strict Off
Option Explicit On
Friend Class monster
	Public IdNum As Byte
	Public attacksound As Byte
	Public Word2 As Integer
	Public Word4 As Integer
	Public Speed As Byte
	Public MinSpeed As Byte
	'UPGRADE_NOTE: Armor was upgraded to Armor_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Public Armor_Renamed 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 Integer
	Public word16 As Integer
	Public word18 As Integer
	Public word20 As Integer
	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 = CShort(Word2 And &H4) / &H4
	End Function
	Public Function w2_walkthroughwalls() As Byte
		w2_walkthroughwalls = CShort(Word2 And &H8) / &H8
	End Function
	Public Function w2_dumb() As Byte
		w2_dumb = CShort(Word2 And &H10) / &H10
	End Function
	Public Function w2_levitates() As Byte
		w2_levitates = CShort(Word2 And &H20) / &H20
	End Function
	Public Function w2_nonmaterial() As Byte
		w2_nonmaterial = CShort(Word2 And &H40) / &H40
	End Function
	Public Function w2_immunetomissiles() As Byte
		w2_immunetomissiles = CShort(Word2 And &H80) / &H80
	End Function
	Public Function w2_short() As Byte
		w2_short = CShort(Word2 And &H100) / &H100
	End Function
	Public Function w2_dropsitems() As Byte
		w2_dropsitems = CShort(Word2 And &H200) / &H200
	End Function
	Public Function w2_absorbsmissiles() As Byte
		w2_absorbsmissiles = CShort(Word2 And &H400) / &H400
	End Function
	Public Function w2_seeinvisible() As Byte
		w2_seeinvisible = CShort(Word2 And &H800) / &H800
	End Function
	Public Function w2_seedarkness() As Byte
		w2_seedarkness = CShort(Word2 And &H1000) / &H1000
	End Function
	Public Function w2_invulnerable() As Byte
		w2_invulnerable = CShort(Word2 And &H2000) / &H2000
	End Function
	
    Public Sub set_w2_space(ByRef num As Integer)
        If num > 3 Then
            num = 3
        End If
        If num < 0 Then
            num = 0
        End If
        Word2 = CShort(Word2 And &HFFFC) + num
    End Sub
    Public Sub set_w2_unknown1(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H4))
        If num = 1 Then
            Word2 = Word2 + &H4
        End If
    End Sub
    Public Sub set_w2_walkthroughwalls(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H8))
        If num = 1 Then
            Word2 = Word2 + &H8
        End If
    End Sub
    Public Sub set_w2_dumb(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H10))
        If num = 1 Then
            Word2 = Word2 + &H10
        End If
    End Sub
    Public Sub set_w2_levitates(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H20))
        If num = 1 Then
            Word2 = Word2 + &H20
        End If
    End Sub
    Public Sub set_w2_nonmaterial(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H40))
        If num = 1 Then
            Word2 = Word2 + &H40
        End If
    End Sub
    Public Sub set_w2_immunetomissiles(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H80))
        If num = 1 Then
            Word2 = Word2 + &H80
        End If
    End Sub
    Public Sub set_w2_short(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H100))
        If num = 1 Then
            Word2 = Word2 + &H100
        End If
    End Sub
    Public Sub set_w2_dropsitems(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H200))
        If num = 1 Then
            Word2 = Word2 + &H200
        End If
    End Sub
    Public Sub set_w2_absorbsmissiles(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H400))
        If num = 1 Then
            Word2 = Word2 + &H400
        End If
    End Sub
    Public Sub set_w2_seeinvisible(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H800))
        If num = 1 Then
            Word2 = Word2 + &H800
        End If
    End Sub
    Public Sub set_w2_seedarkness(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H1000))
        If num = 1 Then
            Word2 = Word2 + &H1000
        End If
    End Sub
    Public Sub set_w2_invulnerable(ByRef num As Integer)
        Word2 = (Word2 And (&HFFFF - &H2000))
        If num = 1 Then
            Word2 = Word2 + &H2000
        End If
    End Sub
	
	'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 = CByte(Word4 And &H3)
	End Function
	Public Function w4_mirrorimage() As Byte
        w4_mirrorimage = CByte((Word4 And &H4) / &H4)
	End Function
	Public Function w4_sideimage() As Byte
        w4_sideimage = CByte((Word4 And &H8) / &H8)
	End Function
	Public Function w4_backimage() As Byte
        w4_backimage = CByte((Word4 And &H10) / &H10)
	End Function
	Public Function w4_attackimage() As Byte
        w4_attackimage = CByte((Word4 And &H20) / &H20)
	End Function
	Public Function w4_unknown1() As Byte
        w4_unknown1 = CByte((Word4 And &H40) / &H40)
	End Function
	Public Function w4_unknown2() As Byte
        w4_unknown2 = CByte((Word4 And &H80) / &H80)
	End Function
	Public Function w4_unknown3() As Byte
        w4_unknown3 = CByte((Word4 And &H100) / &H100)
	End Function
	Public Function w4_mirroredattack() As Byte
        w4_mirroredattack = CByte((Word4 And &H200) / &H200)
	End Function
	Public Function w4_dontmirrorwhileattacking() As Byte
        w4_dontmirrorwhileattacking = CByte((Word4 And &H400) / &H400)
	End Function
	Public Function w4_unknown4() As Byte
        w4_unknown4 = CByte((Word4 And &H800) / &H800)
	End Function
	Public Function w4_xshiftgroup() As Byte
        w4_xshiftgroup = CByte((Word4 And &H3000) / &H1000)
	End Function
	Public Function w4_yshiftgroup() As Byte
        w4_yshiftgroup = CByte((Word4 And &HC000) / &H4000)
	End Function
	
    Public Sub set_w4_frontgraphics(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H3))
        Word4 = Word4 + CShort(num And &H3)
    End Sub
    Public Sub set_w4_mirrorimage(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H4))
        If num = 1 Then
            Word4 = Word4 + &H4
        End If
    End Sub
    Public Sub set_w4_sideimage(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H8))
        If num = 1 Then
            Word4 = Word4 + &H8
        End If
    End Sub
    Public Sub set_w4_backimage(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H10))
        If num = 1 Then
            Word4 = Word4 + &H10
        End If
    End Sub
    Public Sub set_w4_attackimage(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H20))
        If num = 1 Then
            Word4 = Word4 + &H20
        End If
    End Sub
    Public Sub set_w4_unknown1(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H40))
        If num = 1 Then
            Word4 = Word4 + &H40
        End If
    End Sub
    Public Sub set_w4_unknown2(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H80))
        If num = 1 Then
            Word4 = Word4 + &H80
        End If
    End Sub
    Public Sub set_w4_unknown3(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H100))
        If num = 1 Then
            Word4 = Word4 + &H100
        End If
    End Sub
    Public Sub set_w4_mirroredattack(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H200))
        If num = 1 Then
            Word4 = Word4 + &H200
        End If
    End Sub
    Public Sub set_w4_dontmirrorwhileattacking(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H400))
        If num = 1 Then
            Word4 = Word4 + &H400
        End If
    End Sub
    Public Sub set_w4_unknown4(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H800))
        If num = 1 Then
            Word4 = Word4 + &H800
        End If
    End Sub
    Public Sub set_w4_xshiftgroup(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &H3000))
        Word4 = Word4 + (num * &H1000)
    End Sub
    Public Sub set_w4_yshiftgroup(ByRef num As Integer)
        Word4 = (Word4 And (&HFFFF - &HC000))
        Word4 = Word4 + (num * &H4000)
    End Sub

    '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 = CByte(word14 And &HF)
    End Function
    Public Function w14_unused1() As Byte
        w14_unused1 = CByte((word14 And &HF0) / &H10)
    End Function
    Public Function w14_awarenessrange() As Byte
        w14_awarenessrange = CByte((word14 And &HF00) / &H100)
    End Function
    Public Function w14_spellrange() As Byte
        w14_spellrange = CByte((word14 And &HF000) / &H1000)
    End Function


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

    '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 = CByte((word16 And &HF) / &H1)
    End Function
    Public Function w16_bravery() As Byte
        w16_bravery = CByte((word16 And &HF0) / &H10)
    End Function
    Public Function w16_skill() As Byte
        w16_skill = CByte((word16 And &HF00) / &H100)
    End Function
    Public Function w16_teleportation() As Byte
        w16_teleportation = CByte((word16 And &HF000) / &H1000)
    End Function

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

    '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 = CByte((word18 And &HF) / &H1)
    End Function
    Public Function w18_magicresistance() As Byte
        w18_magicresistance = CByte((word18 And &HF0) / &H10)
    End Function
    Public Function w18_poisonresistance() As Byte
        w18_poisonresistance = CByte((word18 And &HF00) / &H100)
    End Function
    Public Function w18_unused2() As Byte
        w18_unused2 = CByte((word18 And &HF000) / &H1000)
    End Function

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

    '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 = CByte((word20 And &HF) / &H1)
    End Function
    Public Function w20_statusupdate() As Byte
        w20_statusupdate = CByte((word20 And &HF0) / &H10)
    End Function
    Public Function w20_attackstatusupdate() As Byte
        w20_attackstatusupdate = CByte((word20 And &HF00) / &H100)
    End Function
    Public Function w20_unused1() As Byte
        w20_unused1 = CByte((word20 And &HF000) / &H1000)
    End Function

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

    '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
End Class