(version 2)
(include "sci.sh")
(exports
    0 cobraMonster
)
(use "Main")
(use "CombatIcon")
(use "Cycle")
(use "View")
(use "Obj")
(script 580)



(instance public cobraMonster of Monster
    (properties
        x 185
        y 125
        view 576
        roar 906
        primDamage 8
        secDamage 15
        armorValue 3
        monHP 150
        spellHitX 185
        spellHitY 97
    )

    (method (init param1)
        (send global2:picture(560))
        (super:init(rest param1))
        (self:setScript(sFight))
        (spit:
            init()
            hide()
        )
        (send gLongSong:
            setLoop(-1)
            changeTo(151)
        )
    )


    (method (cue)
        (send gWarriorObj:autoDodge())
        (if (not 
        (if ((== (send gWarriorObj:view) 26) or (== (send gWarriorObj:view) 27))
        )(else
            == (send gWarriorObj:view) 555
        )
)
            (send gWarriorObj:getHurt((send gMonster:secDamage)))
            (spit:setCycle(End spit))
            proc0_4(115)
        )(else
            (spit:setMotion(MoveTo -58 119 spit))
        )
    )


    (method (getHurt)
        (self:setScript(sReact))
        (super:getHurt())
    )


    (method (defenseLevel)
        return 220
    )

)
(instance spit of Actor
    (properties
        x 162
        y 119
        yStep 15
        view 576
        loop 4
        priority 11
        signal $4810
        cycleSpeed 5
        xStep 15
        moveSpeed 0
    )

    (method (cue)
        (self:hide())
    )

)
(instance sFight of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = ticks (/ Random(90 360) global209)
            )
            (case 1
                (send gMonster:
                    setCel(0)
                    setLoop(
                        (if (Random(0 1))
                            1
                        )(else
                            2
                        )
)
                    setCycle(End self)
                )
            )
            (case 2
                (if (== (send gMonster:loop) 1)
                    (send gMonster:setCycle(Beg self))
                )(else
                    = ticks (/ 180 global209)
                )
            )
            (case 3
                (send gMonster:
                    setLoop(3)
                    setCel(0)
                    setCycle(CT 1 1 self)
                )
            )
            (case 4
                (if (Random(0 1))
                    (spit:
                        show()
                        x(162)
                        y(119)
                        setCel(0)
                        setMotion(MoveTo 102 119 gMonster)
                    )
                )(else
                    (send gMonster:x(150))
                    (send gWarriorObj:autoDodge())
                    (if (not 
                    (if ((== (send gWarriorObj:view) 26) or (== (send gWarriorObj:view) 27))
                    )(else
                        == (send gWarriorObj:view) 555
                    )
)
                        (send gWarriorObj:getHurt((send gMonster:primDamage)))
                    )
                )
                (send gMonster:setCycle(End self))
            )
            (case 5
                (send gMonster:
                    x(185)
                    y(125)
                )
                (self:init())
            )
        )
    )

)
(instance sReact of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gMonster:
                    setLoop(0)
                    setCel(0)
                    setCycle(End self)
                )
                = ticks 60
            )
            (case 1
                (send gMonster:whimper())
                = ticks (- (/ Random(45 180) global209) 14)
            )
            (case 2
                (send gMonster:setScript(sFight))
            )
        )
    )

)
