;;-*-Lisp-*-
(in-package goal)

(import "goal_src/jak1/import/periscope-ag.gc")
(import "goal_src/jak1/import/reflector-mirror-ag.gc")

;; failed to figure out what this is:
(defpartgroup group-jungle-binoculars
  :id 176
  :flags (screen-space)
  :bounds (static-bspherem 0 0 0 1)
  :parts ((sp-item 803)
    (sp-item 804)
    (sp-item 805)
    (sp-item 806)
    (sp-item 807)
    (sp-item 808)
    (sp-item 809)
    (sp-item 810)
    (sp-item 811)
    (sp-item 812)
    (sp-item 813)
    (sp-item 814)
    (sp-item 815)
    (sp-item 816)
    (sp-item 817)
    (sp-item 818)
    (sp-item 819)
    (sp-item 820)
    (sp-item 821)
    (sp-item 822)
    (sp-item 823)
    )
  )

;; failed to figure out what this is:
(defpart 823
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x28 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 1))
    (sp-flt spt-rot-z (degrees -45.0))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 0.0))
    (sp-flt spt-conerot-radius (meters 1.45))
    )
  )

;; failed to figure out what this is:
(defpart 815
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees -15.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 30.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 816
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 15.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 60.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 817
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 75.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 120.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 818
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 105.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 150.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 819
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 165.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 210.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 820
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 195.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 240.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 821
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 255.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 300.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 822
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x26 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-flt spt-rot-z (degrees 285.0))
    (sp-flt spt-scale-y (meters 0.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 330.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 811
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x27 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.75))
    (sp-flt spt-rot-z (degrees 0.0))
    (sp-flt spt-scale-y (meters 0.75))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 0.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 812
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x27 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.75))
    (sp-flt spt-rot-z (degrees 90.0))
    (sp-flt spt-scale-y (meters 0.75))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 90.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 813
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x27 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.75))
    (sp-flt spt-rot-z (degrees 180.0))
    (sp-flt spt-scale-y (meters 0.75))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 180.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 814
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x27 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.75))
    (sp-flt spt-rot-z (degrees 270.0))
    (sp-flt spt-scale-y (meters 0.75))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    (sp-flt spt-conerot-z (degrees 270.0))
    (sp-flt spt-conerot-radius (meters 1))
    )
  )

;; failed to figure out what this is:
(defpart 803
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters -2.9))
    (sp-flt spt-y (meters 2.1))
    (sp-flt spt-scale-x (meters 4.5))
    (sp-flt spt-scale-y (meters 3))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 804
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters 1.11))
    (sp-flt spt-y (meters 2.1))
    (sp-flt spt-scale-x (meters 4.5))
    (sp-flt spt-scale-y (meters 3))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 805
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters -1.11))
    (sp-flt spt-y (meters 2.1))
    (sp-flt spt-scale-x (meters 3))
    (sp-flt spt-rot-z (degrees -90.0))
    (sp-flt spt-scale-y (meters 4.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 806
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters 2.9))
    (sp-flt spt-y (meters 2.1))
    (sp-flt spt-scale-x (meters 3))
    (sp-flt spt-rot-z (degrees -90.0))
    (sp-flt spt-scale-y (meters 4.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 807
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters -2.9))
    (sp-flt spt-y (meters -2.1))
    (sp-flt spt-scale-x (meters 3))
    (sp-flt spt-rot-z (degrees 90.0))
    (sp-flt spt-scale-y (meters 4.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 808
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters 1.11))
    (sp-flt spt-y (meters -2.1))
    (sp-flt spt-scale-x (meters 3))
    (sp-flt spt-rot-z (degrees 90.0))
    (sp-flt spt-scale-y (meters 4.5))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 809
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters -1.11))
    (sp-flt spt-y (meters -2.1))
    (sp-flt spt-scale-x (meters 4.5))
    (sp-flt spt-rot-z (degrees 180.0))
    (sp-flt spt-scale-y (meters 3))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpart 810
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x25 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-x (meters 2.9))
    (sp-flt spt-y (meters -2.1))
    (sp-flt spt-scale-x (meters 4.5))
    (sp-flt spt-rot-z (degrees 180.0))
    (sp-flt spt-scale-y (meters 3))
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit9)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-jungle-binoculars-aligned
  :id 689
  :bounds (static-bspherem 0 0 0 10)
  :parts ((sp-item 2840) (sp-item 2863) (sp-item 2864) (sp-item 2865))
  )

;; failed to figure out what this is:
(defpart 2865
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 1.0 5.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.1) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 32.0 1.0)
    (sp-rnd-flt spt-g 0.0 96.0 1.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-y (meters 0.006666667) (meters 0.006666667) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -0.2) (degrees 0.4) 1.0)
    (sp-flt spt-fade-a 0.85333335)
    (sp-rnd-flt spt-accel-y -0.68266666 -0.68266666 1.0)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int-plain-rnd spt-next-time 75 74 1)
    (sp-launcher-by-id spt-next-launcher 2866)
    (sp-rnd-flt spt-conerot-x (degrees -360.0) (degrees 720.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees -1440.0) (degrees 2880.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 0) (meters 0.5) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2866
  :init-specs ((sp-flt spt-fade-a -0.85333335))
  )

;; failed to figure out what this is:
(defpart 2864
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-rnd-flt spt-num 1.0 1.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 1) (meters 2) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 32.0 1.0)
    (sp-rnd-flt spt-g 0.0 96.0 1.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-y (meters -0.0033333334) (meters 0.006666667) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -0.2) (degrees 0.4) 1.0)
    (sp-flt spt-fade-a 4.266667)
    (sp-int spt-timer 60)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int-plain-rnd spt-next-time 15 14 1)
    (sp-launcher-by-id spt-next-launcher 2867)
    (sp-rnd-flt spt-conerot-x (degrees -360.0) (degrees 720.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees -360.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters -2) (meters 4) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2867
  :init-specs ((sp-flt spt-fade-a -4.266667))
  )

;; failed to figure out what this is:
(defpart 2863
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 0.15)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 0.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 128.0 32.0 1.0)
    (sp-rnd-flt spt-g 128.0 96.0 1.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-scalevel-x (meters -0.0125))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.8)
    (sp-int spt-timer 120)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2840
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 13) (meters 5) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 32.0 1.0)
    (sp-rnd-flt spt-g 0.0 96.0 1.0)
    (sp-rnd-flt spt-b 128.0 128.0 1.0)
    (sp-rnd-flt spt-a 64.0 32.0 1.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; definition of type periscope
(deftype periscope (process-drawable)
  ((root-override          collide-shape                    :offset        112)
   (y-offset               meters                           :offset-assert 176)
   (y-offset-grips         meters                           :offset-assert 180)
   (height                 meters                           :offset-assert 184)
   (turn                   degrees                          :offset-assert 188)
   (tilt                   degrees                          :offset-assert 192)
   (target-turn            degrees                          :offset-assert 196)
   (target-tilt            degrees                          :offset-assert 200)
   (base                   vector                   :inline :offset-assert 208)
   (reflector-trans        vector                   :inline :offset-assert 224)
   (next-reflector-trans   vector                   :inline :offset-assert 240)
   (prev-reflector-trans   vector                   :inline :offset-assert 256)
   (old-camera-matrix      matrix                   :inline :offset-assert 272)
   (reflector              (pointer reflector)              :offset-assert 336)
   (gauge-rot              degrees                          :offset-assert 340)
   (lock-time              time-frame                       :offset-assert 344)
   (aligned?               symbol                           :offset-assert 352)
   (raised?                symbol                           :offset-assert 356)
   (player-touching-grips? symbol                           :offset-assert 360)
   (grips-moving?          symbol                           :offset-assert 364)
   (sound-id               sound-id                         :offset-assert 368)
   (rise-sound-id          sound-id                         :offset-assert 372)
   (grips-sound-id         sound-id                         :offset-assert 376)
   (grips                  joint-mod-set-world              :offset-assert 380)
   (part-aligned           sparticle-launch-control         :offset-assert 384)
   )
  :heap-base #x120
  :method-count-assert 20
  :size-assert         #x184
  :flag-assert         #x1401200184
  (:states
    periscope-activate
    periscope-idle
    periscope-player-control
    periscope-power-on
    periscope-wait-for-player
    periscope-wait-for-power-input
    )
  )

;; definition for method 3 of type periscope
(defmethod inspect periscope ((obj periscope))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Ty-offset: (meters ~m)~%" (-> obj y-offset))
  (format #t "~T~Ty-offset-grips: (meters ~m)~%" (-> obj y-offset-grips))
  (format #t "~T~Theight: (meters ~m)~%" (-> obj height))
  (format #t "~T~Tturn: (deg ~r)~%" (-> obj turn))
  (format #t "~T~Ttilt: (deg ~r)~%" (-> obj tilt))
  (format #t "~T~Ttarget-turn: (deg ~r)~%" (-> obj target-turn))
  (format #t "~T~Ttarget-tilt: (deg ~r)~%" (-> obj target-tilt))
  (format #t "~T~Tbase: ~`vector`P~%" (-> obj base))
  (format #t "~T~Treflector-trans: ~`vector`P~%" (-> obj reflector-trans))
  (format #t "~T~Tnext-reflector-trans: ~`vector`P~%" (-> obj next-reflector-trans))
  (format #t "~T~Tprev-reflector-trans: ~`vector`P~%" (-> obj prev-reflector-trans))
  (format #t "~T~Told-camera-matrix: ~`matrix`P~%" (-> obj old-camera-matrix))
  (format #t "~T~Treflector: #x~X~%" (-> obj reflector))
  (format #t "~T~Tgauge-rot: (deg ~r)~%" (-> obj gauge-rot))
  (format #t "~T~Tlock-time: ~D~%" (-> obj lock-time))
  (format #t "~T~Taligned?: ~A~%" (-> obj aligned?))
  (format #t "~T~Traised?: ~A~%" (-> obj raised?))
  (format #t "~T~Tplayer-touching-grips?: ~A~%" (-> obj player-touching-grips?))
  (format #t "~T~Tgrips-moving?: ~A~%" (-> obj grips-moving?))
  (format #t "~T~Tsound-id: ~D~%" (-> obj sound-id))
  (format #t "~T~Trise-sound-id: ~D~%" (-> obj rise-sound-id))
  (format #t "~T~Tgrips-sound-id: ~D~%" (-> obj grips-sound-id))
  (format #t "~T~Tgrips: ~A~%" (-> obj grips))
  (format #t "~T~Tpart-aligned: ~A~%" (-> obj part-aligned))
  obj
  )

;; definition for method 7 of type periscope
;; INFO: Return type mismatch process-drawable vs periscope.
(defmethod relocate periscope ((obj periscope) (arg0 int))
  (if (nonzero? (-> obj grips))
      (&+! (-> obj grips) arg0)
      )
  (if (nonzero? (-> obj part-aligned))
      (&+! (-> obj part-aligned) arg0)
      )
  (the-as periscope ((method-of-type process-drawable relocate) obj arg0))
  )

;; definition for method 10 of type periscope
(defmethod deactivate periscope ((obj periscope))
  (if (nonzero? (-> obj part-aligned))
      (kill-and-free-particles (-> obj part-aligned))
      )
  ((method-of-type process-drawable deactivate) obj)
  (none)
  )

;; definition of type reflector
(deftype reflector (process-drawable)
  ((parent-override (pointer periscope)  :offset  12)
   (root-override   collide-shape        :offset 112)
   )
  :heap-base #x40
  :method-count-assert 20
  :size-assert         #xb0
  :flag-assert         #x14004000b0
  (:states
    reflector-idle
    )
  )

;; definition for method 3 of type reflector
(defmethod inspect reflector ((obj reflector))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  obj
  )

;; definition of type reflector-origin
(deftype reflector-origin (process-drawable)
  ((reflector-trans      vector       :inline :offset-assert 176)
   (next-reflector-trans vector       :inline :offset-assert 192)
   (reflector            uint32               :offset-assert 208)
   (next                 basic                :offset-assert 212)
   (blocker              entity-actor         :offset-assert 216)
   )
  :heap-base #x70
  :method-count-assert 20
  :size-assert         #xdc
  :flag-assert         #x14007000dc
  (:states
    reflector-origin-idle
    )
  )

;; definition for method 3 of type reflector-origin
(defmethod inspect reflector-origin ((obj reflector-origin))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Treflector-trans: ~`vector`P~%" (-> obj reflector-trans))
  (format #t "~T~Tnext-reflector-trans: ~`vector`P~%" (-> obj next-reflector-trans))
  (format #t "~T~Treflector: #x~X~%" (-> obj reflector))
  (format #t "~T~Tnext: ~A~%" (-> obj next))
  (format #t "~T~Tblocker: ~A~%" (-> obj blocker))
  obj
  )

;; definition of type reflector-mirror
(deftype reflector-mirror (process-drawable)
  ((root-override collide-shape         :offset        112)
   (beam-end      vector        :inline :offset-assert 176)
   )
  :heap-base #x50
  :method-count-assert 20
  :size-assert         #xc0
  :flag-assert         #x14005000c0
  (:states
    (reflector-mirror-broken symbol)
    reflector-mirror-idle
    )
  )

;; definition for method 3 of type reflector-mirror
(defmethod inspect reflector-mirror ((obj reflector-mirror))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tbeam-end: #<vector @ #x~X>~%" (-> obj beam-end))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *periscope-base-sg* periscope periscope-base-lod0-jg periscope-base-idle-ja
              ((periscope-base-lod0-mg (meters 20)) (periscope-base-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 23.5 0 24)
              :longest-edge (meters 4.5)
              )

;; failed to figure out what this is:
(defskelgroup *periscope-mirror-sg* periscope periscope-mirror-lod0-jg periscope-mirror-idle-ja
              ((periscope-mirror-lod0-mg (meters 20)) (periscope-mirror-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 5)
              )

;; failed to figure out what this is:
(defskelgroup *reflector-mirror-sg* reflector-mirror reflector-mirror-lod0-jg reflector-mirror-idle-ja
              ((reflector-mirror-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 9 0 9)
              :longest-edge (meters 3)
              )

;; failed to figure out what this is:
(defskelgroup *reflector-mirror-break-sg* reflector-mirror reflector-mirror-break-lod0-jg reflector-mirror-break-break-ja
              ((reflector-mirror-break-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 9 0 9)
              )

;; failed to figure out what this is:
(defstate cam-periscope (camera-slave)
  :event cam-standard-event-handler
  :enter (behavior ()
    (when (not (-> self enter-has-run))
      (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0))
      (let ((v1-2 (-> self change-event-from)))
        (set! (-> self trans quad) (-> (the-as periscope (-> v1-2 0)) reflector-trans quad))
        (matrix-rotate-yx!
          (the-as matrix (-> self tracking))
          (-> (the-as periscope (-> v1-2 0)) turn)
          (-> (the-as periscope (-> v1-2 0)) tilt)
          )
        )
      (set! (-> self blend-from-type) (the-as uint 0))
      (set! (-> self blend-to-type) (the-as uint 0))
      0
      )
    (none)
    )
  :trans (behavior ()
    (if (zero? (logand (-> *camera* master-options) 2))
        (cam-slave-go cam-free-floating)
        )
    (none)
    )
  :code (behavior ()
    (local-vars (sv-32 int) (sv-48 int))
    (let* ((gp-0 (-> self change-event-from))
           (f28-0 (the-as float (-> (the-as periscope (-> gp-0 0)) tilt)))
           (f30-0 (the-as float (-> (the-as periscope (-> gp-0 0)) turn)))
           (s5-0 (new 'stack-no-clear 'vector))
           )
      (loop
        (when (not (or (paused?) (-> (the-as periscope (-> self change-event-from 0)) aligned?)))
          (vector-reset! s5-0)
          (when *camera-read-analog*
            (let ((f26-0 (analog-input
                           (the-as int (+ (-> *cpad-list* cpads 0 rightx) -256 (-> *cpad-list* cpads 0 leftx)))
                           0.0
                           48.0
                           110.0
                           -1.0
                           )
                         )
                  (f0-0 (analog-input
                          (the-as int (+ (-> *cpad-list* cpads 0 righty) -256 (-> *cpad-list* cpads 0 lefty)))
                          0.0
                          48.0
                          110.0
                          -1.0
                          )
                        )
                  )
              (set! (-> s5-0 y) (- (-> s5-0 y) (* 136.53334 (- f26-0))))
              (set! (-> s5-0 x) (- (-> s5-0 x) (* 136.53334 (- f0-0))))
              (cond
                ((and (= f26-0 0.0) (= f0-0 0.0))
                 (sound-stop (-> (the-as periscope (-> gp-0 0)) sound-id))
                 )
                (else
                  (let ((s4-0 sound-play-by-name)
                        (s3-0 (make-u128 101 (the-as uint #x706f6373656c6574)))
                        (s2-0 (-> (the-as periscope (-> gp-0 0)) sound-id))
                        (s1-0 1024)
                        (s0-0 0)
                        )
                    (set! sv-32 0)
                    (set! sv-48 1)
                    (let ((t2-0 (target-pos 0)))
                      (the-as
                        int
                        (s4-0 (the-as sound-name s3-0) s2-0 s1-0 s0-0 sv-32 (the-as sound-group sv-48) (the-as symbol t2-0))
                        )
                      )
                    )
                  )
                )
              )
            )
          (cond
            ((< 136.53334 (-> s5-0 x))
             (set! (-> s5-0 x) 136.53334)
             )
            ((< (-> s5-0 x) -136.53334)
             (set! (-> s5-0 x) -136.53334)
             )
            )
          (cond
            ((< 136.53334 (-> s5-0 y))
             (set! (-> s5-0 y) 136.53334)
             )
            ((< (-> s5-0 y) -136.53334)
             (set! (-> s5-0 y) -136.53334)
             )
            )
          (+! f30-0 (* (-> s5-0 y) (-> *display* time-adjust-ratio)))
          (set! f28-0 (fmax -12743.111 (fmin 12743.111 (+ f28-0 (* (-> s5-0 x) (-> *display* time-adjust-ratio))))))
          (matrix-rotate-yx! (the-as matrix (-> self tracking)) f30-0 f28-0)
          )
        (suspend)
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate reflector-idle (reflector)
  :code (behavior ()
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (loop
        (set! (-> gp-0 x) (-> self parent-override 0 tilt))
        (set! (-> gp-0 y) (-> self parent-override 0 turn))
        (set! (-> gp-0 z) 0.0)
        (set! (-> gp-0 w) 1.0)
        (quaternion-zxy! (-> self root-override quat) gp-0)
        (set! (-> self root-override trans quad)
              (-> self parent-override 0 node-list data 6 bone transform vector 3 quad)
              )
        (ja-post)
        (update-transforms! (-> self root-override))
        (suspend)
        )
      )
    (none)
    )
  )

;; definition for function reflector-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior reflector-init-by-other reflector ((arg0 vector))
  (set! (-> self entity) (-> self parent-override 0 entity))
  (let ((s5-0 (new 'process 'collide-shape self (collide-list-enum hit-by-player))))
    (let ((s4-0 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind wall-object))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s4-0 transform-index) 0)
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 16384.0)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> self root-override) s5-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 quad))
  (initialize-skeleton self *periscope-mirror-sg* '())
  (logclear! (-> self mask) (process-mask actor-pause))
  (go reflector-idle)
  (none)
  )

;; definition for function periscope-crosshair
;; INFO: Used lq/sq
(defbehavior periscope-crosshair periscope ()
  (let ((s3-0 (matrix-local->world #f #f))
        (s5-0 (new 'static 'vector4w-4))
        (s4-0 (new 'static 'vector))
        (gp-0 #f)
        )
    (set! (-> self turn) (vector-y-angle (-> s3-0 vector 2)))
    (set! (-> self tilt) (- (vector-x-angle (-> s3-0 vector 2))))
    (set! (-> s4-0 quad) (-> self next-reflector-trans quad))
    (set! (-> s4-0 w) 1.0)
    (init-for-transform *identity-matrix*)
    (transform-float-point s4-0 (the-as vector4w (-> s5-0 quad)))
    (let* ((v1-1 (-> self link))
           (s4-1 (and (-> v1-1 next) (-> v1-1 next extra process)))
           (v1-5 (if (and (nonzero? s4-1) (type-type? (-> s4-1 type) periscope))
                     s4-1
                     )
                 )
           )
      (when (or (not v1-5) (-> (the-as periscope v1-5) raised?))
        (cond
          ((>= (-> s5-0 vector 0 z) 0)
           (set! (-> s5-0 vector 0 x) (+ (/ (-> s5-0 vector 0 x) 16) -2048))
           (set! (-> s5-0 vector 0 y) (- (- 2048 (/ (-> s5-0 vector 0 y) 16))))
           (let ((v1-15 (abs (-> s5-0 vector 0 x))))
             (cond
               ((and (< v1-15 20) (let ((v1-17 (abs (-> s5-0 vector 0 y))))
                                    (< v1-17 10)
                                    )
                     )
                (when (not (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))))
                  (sound-stop (-> self sound-id))
                  (sound-play "beam-connect" :position (the-as symbol (target-pos 0)))
                  )
                (process-entity-status! self (entity-perm-status complete) #t)
                (set! gp-0 #t)
                )
               (else
                 (process-entity-status! self (entity-perm-status complete) #f)
                 )
               )
             )
           )
          (else
            (process-entity-status! self (entity-perm-status complete) #f)
            )
          )
        )
      )
    (let* ((s5-2 (position-in-front-of-camera! (new 'stack-no-clear 'vector) 40960.0 0.0))
           (v1-28
             (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> self next-reflector-trans) s5-2) 20480.0)
             )
           (s4-4 (vector+! (new 'stack-no-clear 'vector) s5-2 v1-28))
           )
      (init-for-transform *identity-matrix*)
      (let ((v1-30 (transform-float-point s4-4 (new 'stack 'vector4w))))
        (when (>= (-> v1-30 z) 0)
          (set! (-> v1-30 x) (+ (/ (-> v1-30 x) 16) -2048))
          (set! (-> v1-30 y) (- (- 2048 (/ (-> v1-30 y) 16))))
          )
        (let ((f0-9 (- (atan (the float (-> v1-30 x)) (the float (- (-> v1-30 y)))))))
          (set! (-> self gauge-rot) (deg-seek (-> self gauge-rot) f0-9 (* 131072.0 (-> *display* seconds-per-frame))))
          )
        )
      )
    (let ((f0-13 (-> self gauge-rot)))
      (set! (-> *part-id-table* 823 init-specs 3 initial-valuef) (+ -8192.0 f0-13))
      (set! (-> *part-id-table* 823 init-specs 11 initial-valuef) f0-13)
      (if gp-0
          (set! (-> *part-id-table* 823 init-specs 1 initial-valuef) 0.0)
          (set! (-> *part-id-table* 823 init-specs 1 initial-valuef) 1.0)
          )
      (set! (-> *part-id-table* 815 init-specs 3 initial-valuef) (- -2730.6667 f0-13))
      (set! (-> *part-id-table* 815 init-specs 11 initial-valuef) (- 5461.3335 f0-13))
      (set! (-> *part-id-table* 816 init-specs 3 initial-valuef) (- 2730.6667 f0-13))
      (set! (-> *part-id-table* 816 init-specs 11 initial-valuef) (- 10922.667 f0-13))
      (set! (-> *part-id-table* 817 init-specs 3 initial-valuef) (- 13653.333 f0-13))
      (set! (-> *part-id-table* 817 init-specs 11 initial-valuef) (- 21845.334 f0-13))
      (set! (-> *part-id-table* 818 init-specs 3 initial-valuef) (- 19114.666 f0-13))
      (set! (-> *part-id-table* 818 init-specs 11 initial-valuef) (- 27306.666 f0-13))
      (set! (-> *part-id-table* 819 init-specs 3 initial-valuef) (- 30037.334 f0-13))
      (set! (-> *part-id-table* 819 init-specs 11 initial-valuef) (- 38229.332 f0-13))
      (set! (-> *part-id-table* 820 init-specs 3 initial-valuef) (- 35498.668 f0-13))
      (set! (-> *part-id-table* 820 init-specs 11 initial-valuef) (- 43690.668 f0-13))
      (set! (-> *part-id-table* 821 init-specs 3 initial-valuef) (- 46421.332 f0-13))
      (set! (-> *part-id-table* 821 init-specs 11 initial-valuef) (- 54613.332 f0-13))
      (set! (-> *part-id-table* 822 init-specs 3 initial-valuef) (- 51882.668 f0-13))
      (set! (-> *part-id-table* 822 init-specs 11 initial-valuef) (- 60074.668 f0-13))
      (set! (-> *part-id-table* 811 init-specs 3 initial-valuef) (- f0-13))
      (set! (-> *part-id-table* 811 init-specs 11 initial-valuef) (- f0-13))
      (set! (-> *part-id-table* 812 init-specs 3 initial-valuef) (- 16384.0 f0-13))
      (set! (-> *part-id-table* 812 init-specs 11 initial-valuef) (- 16384.0 f0-13))
      (set! (-> *part-id-table* 813 init-specs 3 initial-valuef) (- 32768.0 f0-13))
      (set! (-> *part-id-table* 813 init-specs 11 initial-valuef) (- 32768.0 f0-13))
      (set! (-> *part-id-table* 814 init-specs 3 initial-valuef) (- 49152.0 f0-13))
      (set! (-> *part-id-table* 814 init-specs 11 initial-valuef) (- 49152.0 f0-13))
      )
    (spawn (-> self part) *zero-vector*)
    (let ((s4-5 (new 'stack-no-clear 'vector))
          (s3-2 (new 'stack-no-clear 'vector))
          (s5-4 (new 'stack-no-clear 'vector))
          )
      (set! (-> s4-5 quad) (-> (camera-pos) quad))
      (vector-! s3-2 (-> self prev-reflector-trans) s4-5)
      (vector-normalize! s3-2 1.0)
      (vector+*! s5-4 s4-5 s3-2 20480.0)
      (spawn (-> self part-aligned) s5-4)
      (when gp-0
        (vector-! s3-2 (-> self next-reflector-trans) s4-5)
        (vector-normalize! s3-2 1.0)
        (vector+*! s5-4 s4-5 s3-2 20480.0)
        (spawn (-> self part-aligned) s5-4)
        )
      )
    (set! (-> self aligned?) gp-0)
    gp-0
    )
  )

;; failed to figure out what this is:
(defpart 825
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 4.5)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 32.0)
    (sp-rnd-flt spt-g 0.0 64.0 1.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 96.0)
    (sp-flt spt-vel-y (meters 0.010666667))
    (sp-flt spt-scalevel-x (meters -0.008333334))
    (sp-rnd-flt spt-rotvel-z (degrees -0.99999994) (degrees 1.9999999) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-r -0.17777778)
    (sp-flt spt-fade-a -0.53333336)
    (sp-flt spt-accel-y 0.68266666)
    (sp-int spt-timer 165)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-conerot-z (degrees 90.0))
    (sp-rnd-flt spt-conerot-radius (meters 0) (meters 2.3) 1.0)
    )
  )

;; definition for function periscope-find-next
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior periscope-find-next periscope ()
  (let ((gp-0 (-> self link next)))
    (let ((a0-0 (-> self link prev)))
      (when a0-0
        (set! (-> self prev-reflector-trans quad) (-> a0-0 extra trans quad))
        (+! (-> self prev-reflector-trans y) (res-lump-float a0-0 'height-info))
        )
      )
    (cond
      (gp-0
        (set! (-> self next-reflector-trans quad) (-> gp-0 extra trans quad))
        (+! (-> self next-reflector-trans y) (res-lump-float gp-0 'height-info))
        )
      (else
        (let ((v1-9 (res-lump-struct (-> self entity) 'alt-vector structure)))
          (set! (-> self next-reflector-trans quad) (-> (the-as vector v1-9) quad))
          )
        )
      )
    )
  (none)
  )

;; definition for function periscope-set-target-direction
;; INFO: Return type mismatch float vs none.
(defbehavior periscope-set-target-direction periscope ((arg0 vector))
  (let ((f30-0 (vector-xz-length arg0)))
    (set! (-> self target-turn) (atan (-> arg0 x) (-> arg0 z)))
    (set! (-> self target-tilt) (atan (- (-> arg0 y)) f30-0))
    )
  (none)
  )

;; definition for function periscope-find-aim-at-angles
;; INFO: Used lq/sq
(defbehavior periscope-find-aim-at-angles periscope ()
  (let ((a0-0 (-> self link next))
        (gp-0 (new 'stack-no-clear 'vector))
        (s5-0 (new 'stack-no-clear 'vector))
        )
    (when a0-0
      (set! (-> gp-0 quad) (-> a0-0 extra trans quad))
      (+! (-> gp-0 y) (res-lump-float a0-0 'height-info))
      (vector-! s5-0 gp-0 (-> self reflector-trans))
      (vector-normalize! s5-0 1.0)
      (periscope-set-target-direction s5-0)
      )
    )
  (none)
  )

;; definition for function periscope-find-reflection-angles
;; INFO: Used lq/sq
(defbehavior periscope-find-reflection-angles periscope ()
  (let ((a0-0 (-> self link next))
        (s2-0 (-> self link prev))
        (s3-0 (new 'stack-no-clear 'vector))
        (s5-0 (new 'stack-no-clear 'vector))
        (gp-0 (new 'stack-no-clear 'vector))
        (s4-0 (new 'stack-no-clear 'vector))
        )
    (when (and s2-0 a0-0)
      (set! (-> s3-0 quad) (-> a0-0 extra trans quad))
      (+! (-> s3-0 y) (res-lump-float a0-0 'height-info))
      (vector-! s5-0 s3-0 (-> self reflector-trans))
      (vector-normalize! s5-0 1.0)
      (set! (-> s3-0 quad) (-> s2-0 extra trans quad))
      (+! (-> s3-0 y) (res-lump-float s2-0 'height-info))
      (vector-! gp-0 s3-0 (-> self reflector-trans))
      (vector-normalize! gp-0 1.0)
      (vector+! s4-0 gp-0 s5-0)
      (vector-normalize! s4-0 1.0)
      (periscope-set-target-direction s4-0)
      )
    )
  (none)
  )

;; definition for function periscope-has-power-input?
(defbehavior periscope-has-power-input? periscope ()
  (let ((v1-1 (-> self link prev)))
    (if v1-1
        (logtest? (-> v1-1 extra perm status) (entity-perm-status complete))
        )
    )
  )

;; definition for function periscope-draw-beam-impact
;; INFO: Return type mismatch int vs none.
(defbehavior periscope-draw-beam-impact periscope ()
  (when (periscope-has-power-input?)
    (update! (-> self sound))
    (if (logtest? (-> self draw status) (draw-status was-drawn))
        (sp-launch-particles-var
          *sp-particle-system-2d*
          (-> *part-id-table* 825)
          (-> self reflector-trans)
          (the-as sparticle-launch-state #f)
          (the-as sparticle-launch-control #f)
          1.0
          )
        )
    )
  0
  (none)
  )

;; definition for function periscope-draw-beam
;; INFO: Return type mismatch int vs none.
(defbehavior periscope-draw-beam periscope ()
  (if (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete)))
      (draw-power-beam (-> self reflector-trans) (-> self next-reflector-trans))
      )
  0
  (none)
  )

;; definition for function periscope-update-joints
;; INFO: Return type mismatch float vs none.
(defbehavior periscope-update-joints periscope ()
  (let ((a1-0 (new 'stack-no-clear 'event-message-block)))
    (set! (-> a1-0 to) (the-as process 0.0))
    (set! (-> a1-0 from) (the-as process (-> self turn)))
    (set! (-> a1-0 num-params) (the-as int 0.0))
    (set! (-> a1-0 message) (the-as symbol 1.0))
    (quaternion-zxy! (-> self root-override quat) (the-as vector a1-0))
    )
  (set! (-> self root-override trans y) (+ -184320.0 (-> self y-offset) (-> self base y)))
  (set! (-> self grips transform trans y)
        (+ (- (+ (-> self base y) (-> self y-offset)) (-> self height)) (-> self y-offset-grips))
        )
  (none)
  )

;; definition for function periscope-post
;; INFO: Return type mismatch int vs none.
(defbehavior periscope-post periscope ()
  (periscope-draw-beam)
  (periscope-draw-beam-impact)
  (periscope-update-joints)
  (ja-post)
  (update-transforms! (-> self root-override))
  0
  (none)
  )

;; definition for function periscope-test-task-complete?
(defbehavior periscope-test-task-complete? periscope ()
  (local-vars (sv-16 symbol))
  (set! sv-16 #t)
  (apply-all
    (-> self link)
    (lambda ((arg0 entity-actor) (arg1 (pointer symbol)))
      (the-as
        object
        (when (and (= (-> arg0 etype) periscope) (zero? (logand (-> arg0 extra perm status) (entity-perm-status complete))))
          (set! (-> arg1 0) #f)
          #t
          )
        )
      )
    (& sv-16)
    )
  sv-16
  )

;; definition for function peri-beamcam-init-by-other
;; INFO: Return type mismatch object vs (pointer pov-camera).
(defbehavior peri-beamcam-init-by-other process ((arg0 string))
  (let ((gp-0 (entity-by-name "junglecam-1")))
    (the-as
      (pointer pov-camera)
      (cond
        (gp-0
          (cond
            ((name= arg0 "reflector-mirror-2")
             (process-spawn
               pov-camera
               (-> gp-0 extra trans)
               *junglecam-sg*
               "tower1"
               0
               #f
               '((0 ambient camera "gamcam14"))
               :to self
               )
             )
            ((name= arg0 "periscope-11")
             (process-spawn
               pov-camera
               (-> gp-0 extra trans)
               *junglecam-sg*
               "tower2"
               0
               #f
               '((0 ambient camera "gamcam15") (0 want-force-vis jungle #t) (0 want-force-vis village1 #t))
               :to self
               )
             )
            ((name= arg0 "periscope-12")
             (process-spawn
               pov-camera
               (-> gp-0 extra trans)
               *junglecam-sg*
               "tower3"
               0
               #f
               '((0 ambient camera "gamcam16"))
               :to self
               )
             )
            ((name= arg0 "periscope-13")
             (process-spawn
               pov-camera
               (-> gp-0 extra trans)
               *junglecam-sg*
               "tower4"
               0
               #f
               '((0 ambient camera "gamcam17"))
               :to self
               )
             )
            ((name= arg0 "periscope-14")
             (process-spawn
               pov-camera
               (-> gp-0 extra trans)
               *junglecam-sg*
               "tower5"
               0
               #f
               '((0 ambient camera "gamcam18") (0 want-force-vis jungle #t) (0 want-force-vis village1 #t))
               :to self
               )
             )
            ((name= arg0 "periscope-15")
             (process-spawn
               pov-camera
               (-> gp-0 extra trans)
               *junglecam-sg*
               "beamcam"
               0
               #f
               '((0 ambient camera "gamcam19")
                 (0 want-force-vis jungle #t)
                 (0 want-force-vis village1 #t)
                 (0 display-level village1 movie)
                 )
               :to self
               )
             )
            (else
              (format #t "ERROR<GMJ>: don't know which peri-beamcam to play for ~S~%" arg0)
              )
            )
          )
        (else
          (format #t "ERROR<GMJ>: couldn't find junglecam-1 to initialize peri-beamcam~%")
          )
        )
      )
    )
  )

;; definition for function periscope-debug-trans
;; INFO: Return type mismatch int vs none.
(defbehavior periscope-debug-trans periscope ()
  0
  (none)
  )

;; failed to figure out what this is:
(defstate periscope-idle (periscope)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('activate)
       (logclear! (-> self mask) (process-mask actor-pause))
       (go periscope-activate)
       )
      )
    )
  :enter (behavior ()
    (clear-collide-with-as (-> self root-override))
    (none)
    )
  :exit (behavior ()
    (restore-collide-with-as (-> self root-override))
    (logclear! (-> self draw status) (draw-status hidden))
    (none)
    )
  :trans periscope-debug-trans
  :code (behavior ()
    (logior! (-> self mask) (process-mask actor-pause))
    (set! (-> self raised?) #f)
    (set! (-> self y-offset) 0.0)
    (set! (-> self y-offset-grips) (+ -20480.0 (-> self height)))
    (set! (-> self tilt) 16384.0)
    (set! (-> self turn) (+ 18204.445 (-> self target-turn)))
    (periscope-update-joints)
    (ja-post)
    (suspend)
    (update-transforms! (-> self root-override))
    (logior! (-> self draw status) (draw-status hidden))
    (loop
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate periscope-activate (periscope)
  :exit (behavior ()
    (sound-stop (-> self rise-sound-id))
    (sound-play "eco-tower-stop" :position (the-as symbol (-> self base)))
    (none)
    )
  :trans periscope-debug-trans
  :code (behavior ()
    (local-vars (v1-13 symbol))
    (logclear! (-> self mask) (process-mask actor-pause))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (link-to-next-and-prev-actor (-> self link))
    (periscope-find-next)
    (periscope-find-reflection-angles)
    (when (< 61440.0 (-> self height))
      (set! (-> self y-offset) (+ -61440.0 (-> self height)))
      (set! (-> self turn) (+ 18204.445 (-> self target-turn)))
      )
    (until (and v1-13 (= (-> self turn) (-> self target-turn)) (= (-> self tilt) (-> self target-tilt)))
      (sound-play "eco-tower-rise" :id (-> self rise-sound-id) :position (the-as symbol (-> self base)))
      (seek! (-> self y-offset) (-> self height) (* 16384.0 (-> *display* seconds-per-frame)))
      (seek! (-> self turn) (-> self target-turn) (* 7281.778 (-> *display* seconds-per-frame)))
      (seek! (-> self tilt) (-> self target-tilt) (* 7281.778 (-> *display* seconds-per-frame)))
      (set! (-> self raised?) (< (+ -12288.0 (-> self height)) (-> self y-offset)))
      (periscope-update-joints)
      (suspend)
      (set! v1-13 (= (-> self y-offset) (-> self height)))
      )
    (set! (-> self raised?) #t)
    (go periscope-wait-for-power-input)
    (none)
    )
  :post periscope-post
  )

;; failed to figure out what this is:
(defstate periscope-wait-for-power-input (periscope)
  :code (behavior ()
    (logclear! (-> self mask) (process-mask actor-pause))
    (set! (-> self raised?) #t)
    (let ((f30-0 (+ -20480.0 (-> self height))))
      (until (= (-> self y-offset-grips) f30-0)
        (seek! (-> self y-offset-grips) f30-0 (* 16384.0 (-> *display* seconds-per-frame)))
        (periscope-update-joints)
        (suspend)
        )
      )
    (update-transforms! (-> self root-override))
    (set! (-> self y-offset) (-> self height))
    (loop
      (if (periscope-has-power-input?)
          (go periscope-wait-for-player)
          )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior periscope) ja-post)
  )

;; definition for function target-close-to-point?
;; INFO: Return type mismatch basic vs symbol.
(defun target-close-to-point? ((arg0 vector) (arg1 float))
  (the-as symbol (and *target* (>= arg1 (vector-vector-distance arg0 (-> *target* control trans)))))
  )

;; failed to figure out what this is:
(defstate periscope-wait-for-player (periscope)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touch)
       (when (and *target* (not (and (logtest? (-> *target* control unknown-surface00 flags) (surface-flags jump))
                                     (zero? (logand (-> *target* control status) (cshape-moving-flags onsurf)))
                                     )
                                )
                  )
         (when ((method-of-type touching-shapes-entry prims-touching?)
                (the-as touching-shapes-entry (-> arg3 param 0))
                (the-as collide-shape-moving (-> self root-override))
                (the-as uint 1)
                )
           (let ((v0-0 (the-as object #t)))
             (set! (-> self player-touching-grips?) (the-as symbol v0-0))
             v0-0
             )
           )
         )
       )
      (('change-mode)
       (level-hint-spawn
         (game-text-id sidekick-hint-periscope)
         "sksp0049"
         (the-as entity #f)
         *entity-pool*
         (game-task none)
         )
       (go periscope-player-control)
       )
      )
    )
  :exit (behavior ()
    (sound-stop (-> self grips-sound-id))
    (none)
    )
  :code (behavior ()
    (hide-hud)
    (logclear! (-> self mask) (process-mask actor-pause))
    (set! (-> self raised?) #t)
    (set! (-> self grips-moving?) #t)
    (let ((f30-0 8192.0)
          (gp-0 (res-lump-value (-> self entity) 'text-id uint128))
          )
      (until (= (-> self y-offset-grips) f30-0)
        (if (nonzero? gp-0)
            (level-hint-spawn (game-text-id zero) (the-as string #f) (-> self entity) *entity-pool* (game-task none))
            )
        (sound-play "site-moves" :id (-> self grips-sound-id) :position (the-as symbol (-> self grips transform)))
        (seek! (-> self y-offset-grips) f30-0 (* 16384.0 (-> *display* seconds-per-frame)))
        (periscope-update-joints)
        (suspend)
        )
      )
    (set! (-> self grips-moving?) #f)
    (set! (-> self player-touching-grips?) #f)
    (let ((gp-1 (new 'stack-no-clear 'vector))
          (s5-0 (new 'stack-no-clear 'vector))
          (s4-0 (new 'stack-no-clear 'vector))
          (s3-0 (new 'stack-no-clear 'vector))
          )
      (loop
        (set! (-> s5-0 quad) (-> self node-list data 4 bone transform vector 3 quad))
        (let ((a0-10 s5-0)
              (f30-1 81920.0)
              )
          (when (and *target* (>= f30-1 (vector-vector-distance a0-10 (-> *target* control trans))))
            (when (logtest? (-> *target* control status) (cshape-moving-flags onsurf))
              (let ((f0-7 (fmax 4096.0 (fmin 12288.0 (+ (- 5120.0 (-> self base y)) (-> *target* control trans y))))))
                (seek! (-> self y-offset-grips) f0-7 (* 16384.0 (-> *display* seconds-per-frame)))
                )
              )
            (vector-! gp-1 (target-pos 0) (-> self base))
            (vector-z-quaternion! s4-0 (-> self grips transform quat))
            (quaternion-rotate-y-to-vector!
              (-> self grips transform quat)
              (-> self grips transform quat)
              (the-as quaternion gp-1)
              (* 27306.666 (-> *display* seconds-per-frame))
              )
            (vector-z-quaternion! s3-0 (-> self grips transform quat))
            (set! (-> self grips-moving?) (< (vector-dot s4-0 s3-0) (cos 182.04445)))
            (periscope-update-joints)
            (update-transforms! (-> self root-override))
            (when (and (-> self player-touching-grips?) (not (level-hint-displayed?)))
              (set! (-> self player-touching-grips?) #f)
              (hide-hud)
              (level-hint-surpress!)
              (kill-current-level-hint '() '(sidekick voicebox) 'exit)
              (when (and (hud-hidden?) (can-grab-display? self))
                (let ((s2-2
                        (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning))
                        )
                      )
                  (let ((v1-43 s2-2))
                    (set! (-> v1-43 width) (the float 440))
                    )
                  (let ((v1-44 s2-2))
                    (set! (-> v1-44 height) (the float 80))
                    )
                  (set! (-> s2-2 flags) (font-flags shadow kerning large))
                  (print-game-text (lookup-text! *common-text* (game-text-id press-to-use) #f) s2-2 #f 128 22)
                  )
                (when (cpad-pressed? 0 circle)
                  (set! (-> self grips-moving?) #f)
                  (loop
                    (send-event *target* 'change-mode 'periscope self)
                    (hide-hud)
                    (suspend)
                    (hide-hud)
                    (suspend)
                    )
                  )
                )
              )
            )
          )
        (if (not (periscope-has-power-input?))
            (go periscope-wait-for-power-input)
            )
        (suspend)
        )
      )
    (none)
    )
  :post (behavior ()
    (if (-> self grips-moving?)
        (sound-play "site-moves" :id (-> self grips-sound-id) :position (the-as symbol (-> self grips transform)))
        (sound-stop (-> self grips-sound-id))
        )
    (periscope-draw-beam-impact)
    (ja-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate periscope-player-control (periscope)
  :exit (behavior ()
    (logclear! (-> self reflector 0 draw status) (draw-status hidden))
    (periscope-find-reflection-angles)
    (set! (-> self turn) (-> self target-turn))
    (set! (-> self tilt) (-> self target-tilt))
    (none)
    )
  :trans (behavior ()
    (hide-hud)
    (none)
    )
  :code (behavior ()
    (set! (-> self lock-time) (-> *display* base-frame-counter))
    (link-to-next-and-prev-actor (-> self link))
    (periscope-find-next)
    (let ((a1-0 (new 'stack-no-clear 'event-message-block)))
      (set! (-> a1-0 from) self)
      (set! (-> a1-0 num-params) 0)
      (set! (-> a1-0 message) 'activate)
      (let ((t9-2 send-event-function)
            (v1-5 (-> self link))
            )
        (t9-2 (the-as process-tree (and (-> v1-5 next) (-> v1-5 next extra process))) a1-0)
        )
      )
    (periscope-find-aim-at-angles)
    (set! (-> self turn) (-> self target-turn))
    (set! (-> self tilt) (-> self target-tilt))
    (let ((v1-10 (res-lump-data (-> self entity) 'rotoffset (pointer float))))
      (cond
        (v1-10
          (+! (-> self turn) (-> v1-10 0))
          (+! (-> self tilt) (-> v1-10 1))
          )
        (else
          (set! (-> self turn) (+ 910.2222 (-> self turn)))
          )
        )
      )
    (case (get-aspect-ratio)
      (('aspect16x9)
       (set! (-> *part-id-table* 823 init-specs 12 initial-valuef) 5120.0)
       (set! (-> *part-id-table* 815 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 816 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 817 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 818 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 819 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 820 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 821 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 822 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 811 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 812 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 813 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 814 init-specs 12 initial-valuef) 3276.8)
       (set! (-> *part-id-table* 803 init-specs 2 initial-valuef) -10854.4)
       (set! (-> *part-id-table* 803 init-specs 3 initial-valuef) 6553.6)
       (set! (-> *part-id-table* 804 init-specs 2 initial-valuef) 4546.56)
       (set! (-> *part-id-table* 804 init-specs 3 initial-valuef) 6553.6)
       (set! (-> *part-id-table* 805 init-specs 2 initial-valuef) -4546.56)
       (set! (-> *part-id-table* 805 init-specs 3 initial-valuef) 6553.6)
       (set! (-> *part-id-table* 806 init-specs 2 initial-valuef) 10854.4)
       (set! (-> *part-id-table* 806 init-specs 3 initial-valuef) 6553.6)
       (set! (-> *part-id-table* 807 init-specs 2 initial-valuef) -10854.4)
       (set! (-> *part-id-table* 807 init-specs 3 initial-valuef) -6553.6)
       (set! (-> *part-id-table* 808 init-specs 2 initial-valuef) 4546.56)
       (set! (-> *part-id-table* 808 init-specs 3 initial-valuef) -6553.6)
       (set! (-> *part-id-table* 809 init-specs 2 initial-valuef) -4546.56)
       (set! (-> *part-id-table* 809 init-specs 3 initial-valuef) -6553.6)
       (set! (-> *part-id-table* 810 init-specs 2 initial-valuef) 10854.4)
       (set! (-> *part-id-table* 810 init-specs 3 initial-valuef) -6553.6)
       )
      (('aspect4x3)
       (set! (-> *part-id-table* 823 init-specs 12 initial-valuef) 5939.2)
       (set! (-> *part-id-table* 815 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 816 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 817 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 818 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 819 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 820 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 821 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 822 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 811 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 812 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 813 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 814 init-specs 12 initial-valuef) 4096.0)
       (set! (-> *part-id-table* 803 init-specs 2 initial-valuef) -11878.4)
       (set! (-> *part-id-table* 803 init-specs 3 initial-valuef) 8601.6)
       (set! (-> *part-id-table* 804 init-specs 2 initial-valuef) 4546.56)
       (set! (-> *part-id-table* 804 init-specs 3 initial-valuef) 8601.6)
       (set! (-> *part-id-table* 805 init-specs 2 initial-valuef) -4546.56)
       (set! (-> *part-id-table* 805 init-specs 3 initial-valuef) 8601.6)
       (set! (-> *part-id-table* 806 init-specs 2 initial-valuef) 11878.4)
       (set! (-> *part-id-table* 806 init-specs 3 initial-valuef) 8601.6)
       (set! (-> *part-id-table* 807 init-specs 2 initial-valuef) -11878.4)
       (set! (-> *part-id-table* 807 init-specs 3 initial-valuef) -8601.6)
       (set! (-> *part-id-table* 808 init-specs 2 initial-valuef) 4546.56)
       (set! (-> *part-id-table* 808 init-specs 3 initial-valuef) -8601.6)
       (set! (-> *part-id-table* 809 init-specs 2 initial-valuef) -4546.56)
       (set! (-> *part-id-table* 809 init-specs 3 initial-valuef) -8601.6)
       (set! (-> *part-id-table* 810 init-specs 2 initial-valuef) 11878.4)
       (set! (-> *part-id-table* 810 init-specs 3 initial-valuef) -8601.6)
       )
      )
    (let* ((gp-0 (-> self old-camera-matrix))
           (a2-1 (matrix-local->world #f #f))
           (v1-191 (-> a2-1 vector 0 quad))
           (a0-8 (-> a2-1 vector 1 quad))
           (a1-3 (-> a2-1 vector 2 quad))
           (a2-2 (-> a2-1 vector 3 quad))
           )
      (set! (-> gp-0 vector 0 quad) v1-191)
      (set! (-> gp-0 vector 1 quad) a0-8)
      (set! (-> gp-0 vector 2 quad) a1-3)
      (set! (-> gp-0 vector 3 quad) a2-2)
      )
    (send-event *camera* 'change-state cam-periscope 0)
    (logior! (-> self reflector 0 draw status) (draw-status hidden))
    (suspend)
    (loop
      (if (not (-> self aligned?))
          (set! (-> self lock-time) (-> *display* base-frame-counter))
          )
      (periscope-crosshair)
      (when (or (cpad-pressed? 0 triangle x)
                (and (-> self aligned?) (>= (- (-> *display* base-frame-counter) (-> self lock-time)) (seconds 3)))
                )
        (sound-stop (-> self sound-id))
        (if (periscope-test-task-complete?)
            (close-specific-task! (game-task jungle-lurkerm) (task-status need-reminder))
            )
        (loop
          (when (send-event *target* 'end-mode)
            (cond
              ((and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete)))
               (let ((gp-1 (ppointer->handle (peri-beamcam-init-by-other (the-as string (-> self name))))))
                 (suspend)
                 (while (and *target* (= (-> *target* next-state name) 'target-periscope))
                   (periscope-crosshair)
                   (suspend)
                   )
                 (logclear! (-> self reflector 0 draw status) (draw-status hidden))
                 (periscope-find-reflection-angles)
                 (set! (-> self turn) (-> self target-turn))
                 (set! (-> self tilt) (-> self target-tilt))
                 (set! *camera-init-mat* (-> self old-camera-matrix))
                 (send-event *camera* 'change-state *camera-base-mode* 0)
                 (set! *camera-init-mat* #f)
                 (while (handle->process (the-as handle gp-1))
                   (suspend)
                   )
                 )
               (process-spawn-function
                 process
                 (lambda ((arg0 string))
                   (while (or (-> *setting-control* current ambient)
                              (-> *setting-control* current movie)
                              (-> *setting-control* current hint)
                              )
                     (suspend)
                     )
                   (cond
                     ((name= arg0 "periscope-11")
                      (level-hint-spawn
                        (game-text-id sidekick-hint-periscope3)
                        "sksp0053"
                        (the-as entity #f)
                        *entity-pool*
                        (game-task none)
                        )
                      )
                     ((name= arg0 "periscope-12")
                      (level-hint-spawn
                        (game-text-id sidekick-hint-periscope2)
                        "sksp0052"
                        (the-as entity #f)
                        *entity-pool*
                        (game-task none)
                        )
                      )
                     ((name= arg0 "periscope-15")
                      (level-hint-spawn
                        (game-text-id jungle-lurkerm-resolution)
                        "sksp0018"
                        (the-as entity #f)
                        *entity-pool*
                        (game-task none)
                        )
                      )
                     )
                   (none)
                   )
                 (-> self name)
                 :to self
                 )
               )
              (else
                (set! *camera-init-mat* (-> self old-camera-matrix))
                (send-event *camera* 'change-state *camera-base-mode* 0)
                (set! *camera-init-mat* #f)
                )
              )
            (if (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete)))
                (go periscope-power-on)
                (go periscope-wait-for-player)
                )
            )
          (suspend)
          )
        )
      (suspend)
      )
    (none)
    )
  :post (behavior ()
    (periscope-draw-beam)
    (periscope-update-joints)
    (ja-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate periscope-power-on (periscope)
  :trans periscope-debug-trans
  :code (behavior ()
    (logclear! (-> self mask) (process-mask actor-pause))
    (set! (-> self y-offset) (-> self height))
    (link-to-next-and-prev-actor (-> self link))
    (periscope-find-reflection-angles)
    (set! (-> self turn) (-> self target-turn))
    (set! (-> self tilt) (-> self target-tilt))
    (let ((f30-0 (+ -20480.0 (-> self height))))
      (until (= (-> self y-offset-grips) f30-0)
        (seek! (-> self y-offset-grips) f30-0 (* 16384.0 (-> *display* seconds-per-frame)))
        (periscope-update-joints)
        (sound-play "site-moves" :id (-> self grips-sound-id) :position (the-as symbol (-> self grips transform)))
        (suspend)
        )
      )
    (sound-stop (-> self grips-sound-id))
    (ja-post)
    (loop
      (suspend)
      )
    (none)
    )
  :post periscope-post
  )

;; definition for method 11 of type periscope
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! periscope ((obj periscope) (arg0 entity-actor))
  (stack-size-set! (-> obj main-thread) 512)
  (let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-others))))
    (let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 3) 0)))
      (set! (-> s3-0 prim-core collide-as) (collide-kind wall-object))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid))
      (set! (-> s3-0 transform-index) 0)
      (set-vector! (-> s3-0 local-sphere) 0.0 96256.0 0.0 98304.0)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 1) (the-as uint 0))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind wall-object))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core action) (collide-action solid))
        (set! (-> s2-0 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-0 transform-index) 3)
        (set-vector! (-> s2-0 local-sphere) 0.0 96256.0 0.0 98304.0)
        (append-prim s3-0 s2-0)
        )
      (let ((s2-1 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-1 prim-core collide-as) (collide-kind wall-object))
        (set! (-> s2-1 collide-with) (collide-kind target))
        (set! (-> s2-1 prim-core action) (collide-action solid))
        (set! (-> s2-1 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-1 transform-index) 4)
        (set-vector! (-> s2-1 local-sphere) 0.0 0.0 0.0 9216.0)
        (append-prim s3-0 s2-1)
        )
      (let ((s2-2 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-2 prim-core collide-as) (collide-kind wall-object))
        (set! (-> s2-2 collide-with) (collide-kind target))
        (set! (-> s2-2 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-2 transform-index) 4)
        (set-vector! (-> s2-2 local-sphere) 0.0 0.0 0.0 11264.0)
        (append-prim s3-0 s2-2)
        )
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (set! (-> obj height) (res-lump-float (-> obj entity) 'height-info))
  (set! (-> obj y-offset) (-> obj height))
  (set! (-> obj y-offset-grips) (+ -20480.0 (-> obj height)))
  (set! (-> obj base quad) (-> obj root-override trans quad))
  (set! (-> obj reflector-trans quad) (-> obj base quad))
  (+! (-> obj reflector-trans y) (-> obj height))
  (set! (-> obj reflector) (process-spawn reflector (-> obj reflector-trans) :to obj))
  (set! (-> obj link) (new 'process 'actor-link-info obj))
  (periscope-find-next)
  (initialize-skeleton obj *periscope-base-sg* '())
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 176) obj))
  (set! (-> obj part-aligned) (create-launch-control (-> *part-group-id-table* 689) obj))
  (set! (-> obj grips) (new 'process 'joint-mod-set-world obj 4 #t))
  (transformq-copy! (-> obj grips transform) (the-as transformq (-> obj root-override trans)))
  (periscope-find-reflection-angles)
  (set! (-> obj turn) (-> obj target-turn))
  (set! (-> obj tilt) (-> obj target-tilt))
  (periscope-update-joints)
  (set! (-> obj grips-moving?) #f)
  (set! (-> obj sound-id) (new-sound-id))
  (set! (-> obj sound)
        (new 'process 'ambient-sound (static-sound-spec "eco-beam" :fo-max 50) (-> obj reflector-trans))
        )
  (set! (-> obj rise-sound-id) (new-sound-id))
  (set! (-> obj grips-sound-id) (new-sound-id))
  (set! (-> obj root-override nav-radius) 8192.0)
  (nav-mesh-connect obj (-> obj root-override) (the-as nav-control #f))
  (cond
    ((and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete)))
     (go periscope-power-on)
     )
    ((periscope-has-power-input?)
     (set! (-> obj y-offset-grips) 8192.0)
     (go periscope-wait-for-player)
     )
    (else
      (go periscope-idle)
      )
    )
  (none)
  )

;; definition for function reflector-origin-update
;; INFO: Used lq/sq
;; INFO: Return type mismatch int vs none.
(defbehavior reflector-origin-update reflector-origin ((arg0 entity-actor))
  (when arg0
    (set! (-> self next-reflector-trans quad) (-> arg0 extra trans quad))
    (+! (-> self next-reflector-trans y) (res-lump-float arg0 'height-info))
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defstate reflector-origin-idle (reflector-origin)
  :code (behavior ()
    (reflector-origin-update (-> self blocker))
    (while (zero? (logand (-> self blocker extra perm status) (entity-perm-status complete)))
      (suspend)
      )
    (let ((a1-0 (new 'stack-no-clear 'event-message-block)))
      (set! (-> a1-0 from) self)
      (set! (-> a1-0 num-params) 0)
      (set! (-> a1-0 message) 'activate)
      (let ((t9-1 send-event-function)
            (v1-6 (-> self link))
            )
        (t9-1 (the-as process-tree (and (-> v1-6 next) (-> v1-6 next extra process))) a1-0)
        )
      )
    (reflector-origin-update (-> self link next))
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (vector-! gp-0 (-> self next-reflector-trans) (-> self reflector-trans))
      (vector-normalize! gp-0 819200.0)
      (vector+! (-> self next-reflector-trans) (-> self reflector-trans) gp-0)
      )
    (let ((gp-1 #f))
      (until gp-1
        (let* ((v1-13 (-> self link))
               (s5-0 (and (-> v1-13 next) (-> v1-13 next extra process)))
               (v1-17 (if (and (nonzero? s5-0) (type-type? (-> s5-0 type) periscope))
                          s5-0
                          )
                      )
               )
          (if v1-17
              (set! gp-1 (-> (the-as periscope v1-17) raised?))
              )
          )
        (suspend)
        )
      )
    (process-entity-status! self (entity-perm-status complete) #t)
    (reflector-origin-update (-> self link next))
    (loop
      (suspend)
      )
    (none)
    )
  :post (behavior ()
    (draw-power-beam (-> self reflector-trans) (-> self next-reflector-trans))
    (none)
    )
  )

;; definition for method 11 of type reflector-origin
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! reflector-origin ((obj reflector-origin) (arg0 entity-actor))
  (set! (-> obj root) (new 'process 'trsqv))
  (process-drawable-from-entity! obj arg0)
  (logclear! (-> obj mask) (process-mask actor-pause))
  (set! (-> obj link) (new 'process 'actor-link-info obj))
  (set! (-> obj blocker) (entity-actor-lookup arg0 'alt-actor 0))
  (set! (-> obj reflector-trans quad) (-> obj root trans quad))
  (go reflector-origin-idle)
  (none)
  )

;; failed to figure out what this is:
(defstate reflector-mirror-idle (reflector-mirror)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('attack)
       (sound-play "mirror-smash")
       (go reflector-mirror-broken #f)
       )
      )
    )
  :exit (behavior ()
    (stop! (-> self sound))
    (none)
    )
  :code (behavior ()
    (let ((gp-0 (new-stack-vector0)))
      (set! (-> gp-0 quad) (-> self root-override trans quad))
      (set! (-> gp-0 y) (+ 49152.0 (-> gp-0 y)))
      (loop
        (draw-power-beam gp-0 (-> self beam-end))
        (update! (-> self sound))
        (when (logtest? (-> self draw status) (draw-status was-drawn))
          (sp-launch-particles-var
            *sp-particle-system-2d*
            (-> *part-id-table* 825)
            (-> self beam-end)
            (the-as sparticle-launch-state #f)
            (the-as sparticle-launch-control #f)
            1.0
            )
          (when (and *target* (>= 24576.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))))
            (start-hint-timer (game-text-id sidekick-hint-reflector-mirror))
            (level-hint-spawn
              (game-text-id sidekick-hint-reflector-mirror)
              "sksp0050"
              (the-as entity #f)
              *entity-pool*
              (game-task none)
              )
            )
          )
        (suspend)
        )
      )
    (none)
    )
  :post (the-as (function none :behavior reflector-mirror) ja-post)
  )

;; failed to figure out what this is:
(defstate reflector-mirror-broken (reflector-mirror)
  :code (behavior ((arg0 symbol))
    (ja-channel-set! 0)
    (clear-collide-with-as (-> self root-override))
    (ja-post)
    (let ((s5-0 (entity-actor-count (-> self entity) 'alt-actor)))
      (dotimes (s4-0 s5-0)
        (while (let ((s3-0 (new 'stack-no-clear 'event-message-block)))
                 (set! (-> s3-0 from) self)
                 (set! (-> s3-0 num-params) 0)
                 (set! (-> s3-0 message) 'stop)
                 (let ((s2-0 send-event-function)
                       (v1-3 (entity-actor-lookup (-> self entity) 'alt-actor s4-0))
                       )
                   (not (s2-0
                          (if v1-3
                              (-> v1-3 extra process)
                              )
                          s3-0
                          )
                        )
                   )
                 )
          (suspend)
          )
        )
      )
    (when (not arg0)
      (ambient-hint-spawn "gamcam21" (the-as vector #f) *entity-pool* 'camera)
      (let ((v1-11 (manipy-spawn (-> self root-override trans) (-> self entity) *reflector-mirror-break-sg* #f :to self))
            )
        (send-event (ppointer->process v1-11) 'anim-mode 'play1)
        )
      (let ((gp-2 (-> *display* base-frame-counter)))
        (until (>= (- (-> *display* base-frame-counter) gp-2) (seconds 0.5))
          (suspend)
          )
        )
      (process-grab? *target*)
      (while (or (-> self child) (-> *setting-control* current ambient))
        (suspend)
        )
      (process-release? *target*)
      (peri-beamcam-init-by-other (the-as string (-> self name)))
      (process-entity-status! self (entity-perm-status complete) #t)
      (close-specific-task! (game-task jungle-lurkerm) (task-status need-reminder-a))
      (while (-> self child)
        (suspend)
        )
      )
    (logior! (-> self mask) (process-mask actor-pause))
    (loop
      (suspend)
      )
    (none)
    )
  )

;; definition for method 11 of type reflector-mirror
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! reflector-mirror ((obj reflector-mirror) (arg0 entity-actor))
  (let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player))))
    (let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 3) 0)))
      (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid))
      (set! (-> s3-0 prim-core offense) (collide-offense touch))
      (set-vector! (-> s3-0 local-sphere) 0.0 24576.0 0.0 49152.0)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core action) (collide-action solid))
        (set! (-> s2-0 prim-core offense) (collide-offense touch))
        (set-vector! (-> s2-0 local-sphere) 0.0 6144.0 0.0 6963.2)
        (append-prim s3-0 s2-0)
        )
      (let ((s2-1 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-1 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-1 collide-with) (collide-kind target))
        (set! (-> s2-1 prim-core action) (collide-action solid))
        (set! (-> s2-1 prim-core offense) (collide-offense touch))
        (set-vector! (-> s2-1 local-sphere) 0.0 18432.0 0.0 6963.2)
        (append-prim s3-0 s2-1)
        )
      (let ((s2-2 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-2 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-2 collide-with) (collide-kind target))
        (set! (-> s2-2 prim-core action) (collide-action solid))
        (set! (-> s2-2 prim-core offense) (collide-offense touch))
        (set-vector! (-> s2-2 local-sphere) 0.0 30720.0 0.0 8192.0)
        (append-prim s3-0 s2-2)
        )
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (logclear! (-> obj mask) (process-mask actor-pause))
  (set! (-> obj link) (new 'process 'actor-link-info obj))
  (initialize-skeleton obj *reflector-mirror-sg* '())
  (set-vector! (-> obj beam-end) 1805721.6 167936.0 -932659.2 1.0)
  (set! (-> obj sound)
        (new 'process 'ambient-sound (static-sound-spec "eco-beam" :fo-max 50) (-> obj beam-end))
        )
  (if (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete)))
      (go reflector-mirror-broken #t)
      (go reflector-mirror-idle)
      )
  (none)
  )

;; definition for function draw-power-beam
;; INFO: Return type mismatch int vs none.
(defun draw-power-beam ((arg0 vector) (arg1 vector))
  (when (line-in-view-frustum? arg0 arg1)
    (let ((s4-1 (vector-! (new 'stack-no-clear 'vector) arg1 arg0)))
      (vector-length s4-1)
      (let ((t2-0 (new 'stack-no-clear 'collide-tri-result)))
        0.0
        (if (>= (fill-and-probe-using-line-sphere
                  *collide-cache*
                  arg0
                  s4-1
                  6144.0
                  (collide-kind target)
                  (the-as process #f)
                  t2-0
                  (new 'static 'pat-surface :noentity #x1)
                  )
                0.0
                )
            (send-event *target* 'get-pickup 3 5.0)
            )
        )
      )
    (if (and (< 4096.0 (vector-vector-distance (camera-pos) arg0))
             (< 4096.0 (vector-vector-distance (camera-pos) arg1))
             )
        (draw-eco-beam arg0 arg1)
        )
    )
  0
  (none)
  )
