(version 2)
(include "sci.sh")
(exports
    0 apemanMonster
)
(use "Main")
(use "CombatIcon")
(use "Cycle")
(use "Obj")
(script 575)



(instance public apemanMonster of Monster
    (properties
        x 165
        y 135
        view 571
        roar 905
        primDamage 12
        secDamage 6
        armorValue 4
        monHP 180
        spellHitX 155
        spellHitY 85
    )

    (method (init param1)
        (if ((== gGClientModNum 800) or (== gGClientModNum 810))
            = mustFight 1
        )
        (send global2:picture(555))
        (super:init(rest param1))
        (self:setScript(sFight))
        (send gLongSong:
            setLoop(-1)
            changeTo(151)
        )
    )


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


    (method (defenseLevel)
        return 200
    )


    (method (restart)
        (self:setScript(sFight))
    )

)
(instance sFight of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = ticks (/ Random(90 360) global209)
            )
            (case 1
                (apemanMonster:
                    setCel(0)
                    setLoop(Random(0 1))
                    setCycle(End self)
                )
            )
            (case 2
                (send gWarriorObj:autoDodge())
                (if (not 
                (if ((== (send gWarriorObj:view) 26) or (== (send gWarriorObj:view) 27))
                )(else
                    == (send gWarriorObj:view) 555
                )
)
                    (send gWarriorObj:getHurt(
                        (if ((send gWarriorObj:loop))
                            (send gMonster:secDamage)
                        )(else
                            (send gMonster:primDamage)
                        )
))
                )(else
                    (send gLongSong2:
                        number(940)
                        play()
                    )
                )
                (self:init())
            )
        )
    )

)
(instance sReact of Script
    (properties)

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

)
