;;-*-Lisp-*-
(in-package goal)
(bundles "SWA.DGO")
(require "levels/swamp/swamp-rat.gc")
(declare-type swamp-rat-nest-dummy process-drawable)

(declare-type swamp-rat-nest process-drawable)

;; DECOMP BEGINS

(defpartgroup group-swamp-rat-nest-a-explosion
  :id 292
  :duration (seconds 0.017)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1334) (sp-item 1335) (sp-item 1336) (sp-item 1337) (sp-item 1338) (sp-item 1339)))

(defpartgroup group-swamp-rat-nest-b-explosion
  :id 293
  :duration (seconds 0.017)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1342) (sp-item 1339) (sp-item 1337) (sp-item 1334)))

(defpartgroup group-swamp-rat-nest-c-explosion
  :id 294
  :duration (seconds 0.017)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1335) (sp-item 1339) (sp-item 1337) (sp-item 1334)))

(defpartgroup group-swamp-rat-nest-a-puff
  :id 295
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1346) (sp-item 1347) (sp-item 1348)))

(defpartgroup group-swamp-rat-nest-b-puff
  :id 296
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1350) (sp-item 1351)))

(defpartgroup group-swamp-rat-nest-c-puff
  :id 297
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1353) (sp-item 1354)))

(defpart 1353
  :init-specs
  ((:texture (bigpuff effects))
   (:num 1.0)
   (:y (meters 1.5) (meters 0.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 48.0)
   (:b 64.0 16.0)
   (:a 32.0 32.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.0016666667))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.14222223)
   (:accel-y (meters -0.00008333333) (meters -0.00016666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.5))))

(defpart 1354
  :init-specs
  ((:texture (rockbit effects))
   (:num 1.0)
   (:y (meters 1) (meters 0.5))
   (:scale-x (meters 0.1) (meters 0.05))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 32.0)
   (:b 32.0 16.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.006666667) (meters 0.01))
   (:rotvel-z (degrees -1.2) (degrees 2.4))
   (:fade-a -0.28444445)
   (:accel-y (meters -0.00033333333) (meters -0.00066666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 85) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 2))))

(defpart 1355
  :init-specs
  ((:texture (bigpuff effects))
   (:num 1.0)
   (:y (meters -4.5) (meters 0.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 64.0 48.0)
   (:g 64.0 48.0)
   (:b 64.0 16.0)
   (:a 16.0 16.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.0016666667))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.07111111)
   (:accel-y (meters 0.00008333333) (meters 0.00016666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 80) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.5))))

(defpart 1350
  :init-specs
  ((:texture (bigpuff effects))
   (:num 1.0)
   (:y (meters -0.5) (meters 0.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 48.0)
   (:b 64.0 16.0)
   (:a 32.0 32.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.0016666667))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.14222223)
   (:accel-y (meters -0.00008333333) (meters -0.00016666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.5))))

(defpart 1351
  :init-specs
  ((:texture (rockbit effects))
   (:num 1.0)
   (:y (meters -1) (meters 0.5))
   (:scale-x (meters 0.1) (meters 0.05))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 32.0)
   (:b 32.0 16.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.006666667) (meters 0.01))
   (:rotvel-z (degrees -1.2) (degrees 2.4))
   (:fade-a -0.28444445)
   (:accel-y (meters -0.00033333333) (meters -0.00066666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 85) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 3))))

(defpart 1352
  :init-specs
  ((:texture (bigpuff effects))
   (:num 1.0)
   (:y (meters -10.5) (meters 0.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 64.0 48.0)
   (:g 64.0 48.0)
   (:b 64.0 16.0)
   (:a 16.0 16.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.0016666667))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.07111111)
   (:accel-y (meters 0.00008333333) (meters 0.00016666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 80) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.5))))

(defpart 1334
  :init-specs
  ((:texture (starflash effects))
   (:num 1.0)
   (:y (meters 1))
   (:scale-x (meters 16))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 196.0)
   (:g 160.0)
   (:b 96.0)
   (:a 32.0)
   (:fade-a -1.0)
   (:timer (seconds 0.05))
   (:flags (bit2 bit3))))

(defpart 1341
  :init-specs
  ((:texture (starflash effects))
   (:num 1.0)
   (:y (meters -12))
   (:scale-x (meters 16))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:g 196.0)
   (:b 96.0)
   (:a 16.0)
   (:fade-a 0.0)
   (:timer (seconds 0.05))
   (:flags (bit2 bit3))))

(defpart 1339
  :init-specs
  ((:texture (bigpuff effects))
   (:num 8.0 8.0)
   (:y (meters -1) (meters 1.5))
   (:scale-x (meters 0.75) (meters 1))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 64.0 48.0)
   (:g 48.0 32.0)
   (:b 48.0 8.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.08) (meters 0.08))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -1.2) (degrees 2.4))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.85333335)
   (:accel-y (meters -0.00033333333) (meters -0.00066666666))
   (:friction 0.92)
   (:timer (seconds 0.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 70) (degrees 40))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 2.5) (meters 1))))

(defpart 1335
  :init-specs
  ((:texture (bigpuff effects))
   (:num 16.0 8.0)
   (:y (meters -2) (meters 1.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 64.0 48.0)
   (:g 48.0 32.0)
   (:b 48.0 8.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.21333334)
   (:accel-y (meters -0.000033333334) (meters -0.00006666667))
   (:timer (seconds 2))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 30) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.25))))

(defpart 1340
  :init-specs
  ((:texture (bigpuff effects))
   (:num 10.0 5.0)
   (:y (meters -12) (meters 1.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 48.0 32.0)
   (:g 48.0 32.0)
   (:b 48.0 8.0)
   (:a 32.0 32.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.10666667)
   (:accel-y (meters 0.000033333334) (meters 0.00006666667))
   (:timer (seconds 2))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.25))))

(defpart 1336
  :init-specs
  ((:texture (bigpuff effects))
   (:num 12.0 8.0)
   (:y (meters 0.5) (meters 0.25))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 48.0 32.0)
   (:g 64.0 48.0)
   (:b 48.0 8.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.21333334)
   (:accel-y (meters -0.000033333334) (meters -0.00006666667))
   (:timer (seconds 2))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 30) (degrees 50.000004))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 1) (meters 1.75))))

(defpart 1337
  :init-specs
  ((:texture (rockbit effects))
   (:num 8.0 16.0)
   (:y (meters -1) (meters 2))
   (:scale-x (meters 0.2) (meters 0.6))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 32.0)
   (:b 32.0 16.0)
   (:a 128.0)
   (:vel-y (meters 0.02) (meters 0.04))
   (:rotvel-z (degrees -1.2) (degrees 2.4))
   (:accel-y (meters -0.002) (meters -0.00066666666))
   (:timer (seconds 2.5))
   (:flags (bit2 bit12))
   (:userdata 0.0)
   (:func 'check-water-level-drop)
   (:conerot-x (degrees 15) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0) (meters 3.5))))

(defpart 1338
  :init-specs
  ((:texture (woodchip effects))
   (:num 32.0 32.0)
   (:y (meters 2) (meters 1))
   (:scale-x (meters 0.25) (meters 0.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y (meters 0.25) (meters 0.1))
   (:r 32.0 32.0)
   (:g 128.0 32.0)
   (:b 32.0 16.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.02) (meters 0.04))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:fade-a -0.28444445)
   (:accel-y (meters -0.00033333333) (meters -0.0016666667))
   (:friction 0.94)
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 45) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 3.5) (meters 1))))

(defpart 1346
  :init-specs
  ((:texture (bigpuff effects))
   (:num 1.0)
   (:y (meters 0.5) (meters 0.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 48.0)
   (:b 64.0 16.0)
   (:a 32.0 32.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.0016666667))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.14222223)
   (:accel-y (meters -0.00008333333) (meters -0.00016666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 2.5) (meters 1))))

(defpart 1349
  :init-specs
  ((:texture (bigpuff effects))
   (:num 1.0)
   (:y (meters -12) (meters 0.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 64.0 48.0)
   (:g 64.0 48.0)
   (:b 64.0 16.0)
   (:a 8.0 8.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.0016666667))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.035555556)
   (:accel-y (meters 0.00008333333) (meters 0.00016666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 80) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 2.5) (meters 1))))

(defpart 1347
  :init-specs
  ((:texture (rockbit effects))
   (:num 1.0)
   (:y (meters 1) (meters 0.5))
   (:scale-x (meters 0.1) (meters 0.05))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 96.0 64.0)
   (:g 64.0 32.0)
   (:b 32.0 16.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:rotvel-z (degrees -1.2) (degrees 2.4))
   (:fade-a -0.28444445)
   (:accel-y (meters -0.00033333333) (meters -0.00066666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 3) (meters 0.5))))

(defpart 1348
  :init-specs
  ((:texture (woodchip effects))
   (:num 0.5 0.5)
   (:y (meters 1) (meters 0.5))
   (:scale-x (meters 0.25) (meters 0.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y (meters 0.25) (meters 0.1))
   (:r 32.0 32.0)
   (:g 128.0 32.0)
   (:b 32.0 16.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:fade-a -0.28444445)
   (:accel-y (meters -0.00033333333) (meters -0.00066666666))
   (:timer (seconds 1.5))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 10))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 3) (meters 0.5))))

(defpart 1342
  :init-specs
  ((:texture (bigpuff effects))
   (:num 20.0 8.0)
   (:y (meters -3.5) (meters 2.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 64.0 48.0)
   (:g 48.0 32.0)
   (:b 48.0 8.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.21333334)
   (:accel-y (meters -0.000033333334) (meters -0.00006666667))
   (:timer (seconds 2))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 30) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.25))))

(defpart 1343
  :init-specs
  ((:texture (bigpuff effects))
   (:num 16.0 5.0)
   (:y (meters -10.5) (meters 2.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 48.0 32.0)
   (:g 48.0 32.0)
   (:b 48.0 8.0)
   (:a 32.0 32.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.10666667)
   (:accel-y (meters 0.000033333334) (meters 0.00006666667))
   (:timer (seconds 2))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.25))))

(defpart 1344
  :init-specs
  ((:texture (starflash effects))
   (:num -5.0)
   (:y (meters -12))
   (:scale-x (meters 16))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:g 196.0)
   (:b 96.0)
   (:a 16.0)
   (:fade-a 0.0)
   (:timer (seconds 0.05))
   (:flags (bit2 bit3))))

(defpart 1345
  :init-specs
  ((:texture (bigpuff effects))
   (:num 12.0 4.0)
   (:y (meters -4) (meters 1.5))
   (:scale-x (meters 1) (meters 2.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 48.0 32.0)
   (:g 48.0 32.0)
   (:b 48.0 8.0)
   (:a 48.0 48.0)
   (:vel-y (meters 0.0033333334) (meters 0.0033333334))
   (:scalevel-x (meters 0.005))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.16)
   (:accel-y (meters 0.000033333334) (meters 0.00006666667))
   (:timer (seconds 2))
   (:flags (bit2 bit12))
   (:conerot-x (degrees 90) (degrees 60))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 0.5) (meters 1.25))))

(deftype swamp-rat-nest (process-drawable)
  ((fact                fact-info-enemy :override)
   (child-process       (pointer swamp-rat-nest-dummy) :overlay-at child)
   (dummy               (pointer swamp-rat-nest-dummy))
   (damaged             symbol)
   (dummy-type          int8)
   (rat-count           int8)
   (hit-points          int8)
   (defensive-rat-count int8)
   (spawn-period        float)
   (spawn-period-scale  float)
   (test-interval       time-frame)
   (player-attack-id    int32))
  (:states
   swamp-rat-nest-active
   swamp-rat-nest-die
   swamp-rat-nest-gestate
   swamp-rat-nest-idle
   swamp-rat-nest-victory))


(deftype swamp-rat-nest-dummy (process-drawable)
  ((root                 collide-shape :override)
   (parent-process       (pointer swamp-rat-nest) :overlay-at parent)
   (top-sphere           sphere :inline)
   (death-part           sparticle-launch-group)
   (spawn-joint-array    int8 6)
   (spawn-joint-count    int8)
   (particle-spawn-joint int8))
  (:methods
   (swamp-rat-nest-dummy-method-20 (_type_) none)
   (swamp-rat-nest-dummy-method-21 (_type_) int))
  (:states
   swamp-rat-nest-dummy-die
   swamp-rat-nest-dummy-hit
   swamp-rat-nest-dummy-idle
   swamp-rat-nest-dummy-shake))


(deftype swamp-rat-nest-dummy-a (swamp-rat-nest-dummy) ())


(deftype swamp-rat-nest-dummy-b (swamp-rat-nest-dummy) ())


(deftype swamp-rat-nest-dummy-c (swamp-rat-nest-dummy) ())


(defbehavior swamp-rat-nest-dummy-draw-spawn-joints swamp-rat-nest-dummy ()
  (dotimes (gp-0 (-> self spawn-joint-count))
    (let* ((a0-0 (-> self spawn-joint-array gp-0))
           (a2-0 (-> self node-list data a0-0 bone transform)))
      (add-debug-matrix #t (bucket-id debug-no-zbuf) a2-0)))
  #f)

(defbehavior swamp-rat-nest-dummy-take-damage swamp-rat-nest-dummy ((arg0 int))
  (when (not (-> self parent-process 0 damaged))
    (set! (-> self parent-process 0 damaged) #t)
    (+! (-> self parent-process 0 rat-count) (-> self parent-process 0 defensive-rat-count))
    (set! (-> self parent-process 0 spawn-period) 600.0))
  (set! (-> self parent-process 0 hit-points) (- (-> self parent-process 0 hit-points) arg0))
  (none))

(defbehavior swamp-rat-nest-dummy-event-handler swamp-rat-nest-dummy ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('shake) (if (= (-> self next-state name) 'swamp-rat-nest-dummy-idle) (go swamp-rat-nest-dummy-shake)))
    (('attack)
     (send-event (ppointer->process (-> self parent-process)) 'hit)
     (let ((v1-7 (-> arg3 param 2)))
       (when (!= v1-7 (-> self parent-process 0 player-attack-id))
         (set! (-> self parent-process 0 player-attack-id) (the-as int v1-7))
         (cond
           ((and (>= arg1 2) (= (-> arg3 param 1) 'eco-yellow))
            (swamp-rat-nest-dummy-take-damage 3)
            (if (< (vector-vector-distance (target-pos 0) (-> self top-sphere)) (-> self top-sphere w))
              (send-event *target* 'no-look-around (seconds 0.25)))
            (go swamp-rat-nest-dummy-hit))
           (else
            (level-hint-spawn (text-id swamp-rat-nest-hint) "sksp0144" (the-as entity #f) *entity-pool* (game-task none))
            (swamp-rat-nest-dummy-take-damage 0)
            (go swamp-rat-nest-dummy-hit))))))))

(defstate swamp-rat-nest-dummy-idle (swamp-rat-nest-dummy)
  :event swamp-rat-nest-dummy-event-handler
  :code
    (behavior ()
      (loop
        (ja :num-func num-func-identity :frame-num max)
        (suspend)))
  :post transform-post)

(defstate swamp-rat-nest-dummy-hit (swamp-rat-nest-dummy)
  :event swamp-rat-nest-dummy-event-handler
  :enter
    (behavior ()
      (set-time! (-> self state-time))
      (if (<= (-> self parent-process 0 hit-points) 0) (go swamp-rat-nest-dummy-die)))
  :code
    (behavior ()
      (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (if (< (-> self parent-process 0 hit-points) 3)
          (spawn (-> self part) (-> self node-list data (-> self particle-spawn-joint) bone transform vector 3)))
        (suspend)
        (ja :num! (seek!)))
      (go swamp-rat-nest-dummy-idle))
  :post transform-post)

(defstate swamp-rat-nest-dummy-shake (swamp-rat-nest-dummy)
  :event swamp-rat-nest-dummy-event-handler
  :code
    (behavior ()
      (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!)))
      (go swamp-rat-nest-dummy-idle))
  :post transform-post)

(defstate swamp-rat-nest-dummy-die (swamp-rat-nest-dummy)
  :event #f
  :code
    (behavior ()
      (set-time! (-> self state-time))
      (set! (-> self parent-process 0 dummy) (the-as (pointer swamp-rat-nest-dummy) #f))
      (process-spawn part-tracker
                     :init
                     part-tracker-init
                     (-> self death-part)
                     -1
                     #f
                     #f
                     #f
                     (-> self node-list data (-> self particle-spawn-joint) bone transform vector 3)
                     :to
                     *entity-pool*)
      (until (time-elapsed? (-> self state-time) (seconds 0.1))
        (suspend))
      (ja-channel-set! 0)
      (while (-> self child)
        (suspend))
      (deactivate self)))

(defbehavior swamp-rat-nest-dummy-init-by-other swamp-rat-nest-dummy ((arg0 swamp-rat-nest-dummy))
  (let ((gp-0 (-> arg0 entity)))
    (logior! (-> self mask) (process-mask enemy))
    (swamp-rat-nest-dummy-method-20 self)
    (process-drawable-from-entity! self gp-0)
    (set! (-> self top-sphere quad) (-> self root trans quad))
    (+! (-> self top-sphere y) 24576.0)
    (set! (-> self top-sphere w) 18432.0)
    (set! (-> self entity) gp-0))
  (set! (-> self nav) (new 'process 'nav-control (-> self root) 16 40960.0))
  (logior! (-> self nav flags) (nav-control-flags display-marks navcf3 navcf5 navcf6 navcf7))
  (set-current-poly! (-> self nav) (find-poly (-> self nav) (-> self root trans)))
  (+! (-> self parent-process 0 hit-points) 3)
  (swamp-rat-nest-dummy-method-21 self)
  (when (zero? (-> self skel))
    (set! (-> self spawn-joint-count) 0)
    0)
  (if (zero? (-> self parent-process 0 dummy-type)) (go swamp-rat-nest-dummy-idle) (go swamp-rat-nest-dummy-hit))
  (none))

(defbehavior swamp-rat-nest-default-event-handler swamp-rat-nest ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('victory) (go swamp-rat-nest-victory))))

swamp-rat-nest-default-event-handler

(defbehavior swamp-rat-nest-pick-spawn-joint swamp-rat-nest ()
  (when (and *target* (>= 32768.0 (vector-vector-distance (-> self root trans) (-> *target* control trans))))
    (dotimes (gp-0 5)
      (let* ((s5-0 (-> self dummy 0 spawn-joint-array (rand-vu-int-count (-> self dummy 0 spawn-joint-count))))
             (v1-15 (-> self dummy 0 node-list data s5-0 bone))
             (s3-0 (new 'stack-no-clear 'vector)))
        (set! (-> s3-0 quad) (-> v1-15 transform vector 3 quad))
        (let ((s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> v1-15 transform vector 1) 1.0))
              (s4-1 (vector-! (new 'stack-no-clear 'vector) (target-pos 0) s3-0)))
          (set! (-> s4-1 y) 0.0)
          (vector-normalize! s4-1 1.0)
          (if (< (vector-dot s2-0 s4-1) (cos 8192.0)) (return s5-0))))))
  (-> self dummy 0 spawn-joint-array (rand-vu-int-count (-> self dummy 0 spawn-joint-count))))

;; ERROR: Function may read a register that is not set: t2
(defbehavior swamp-rat-nest-spawn-rat swamp-rat-nest ()
  (local-vars (t2-0 none))
  (the-as (pointer swamp-rat)
          (when (and (-> self dummy) (> (-> self dummy 0 spawn-joint-count) 0))
            (let* ((v1-5 (swamp-rat-nest-pick-spawn-joint))
                   (v1-8 (-> self dummy 0 node-list data v1-5 bone))
                   (gp-0 (new 'stack-no-clear 'vector)))
              (set! (-> gp-0 quad) (-> v1-8 transform vector 3 quad))
              (let ((s5-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> v1-8 transform vector 1) 1.0))
                    (s4-0 (if (= (-> self fact pickup-type) (pickup-type none)) 0 9)))
                (process-spawn swamp-rat self gp-0 s5-0 s4-0 t2-0 :to self))))))

(defbehavior swamp-rat-nest-check-dummy swamp-rat-nest ()
  (when (not (-> self dummy))
    (let ((v1-1 (-> self dummy-type)))
      (cond
        ((zero? v1-1)
         (set! (-> self dummy) (process-spawn swamp-rat-nest-dummy-a :init swamp-rat-nest-dummy-init-by-other self :to self)))
        ((= v1-1 1)
         (set! (-> self dummy) (process-spawn swamp-rat-nest-dummy-b :init swamp-rat-nest-dummy-init-by-other self :to self)))
        ((= v1-1 2)
         (set! (-> self dummy) (process-spawn swamp-rat-nest-dummy-c :init swamp-rat-nest-dummy-init-by-other self :to self)))
        (else (go swamp-rat-nest-die))))
    (+! (-> self dummy-type) 1)
    (set! (-> self spawn-period) (* 0.75 (-> self spawn-period))))
  (none))

(defstate swamp-rat-nest-idle (swamp-rat-nest)
  :event
    (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
      (case message
        (('hit) (go swamp-rat-nest-active))))
  :enter
    (behavior ()
      (set-time! (-> self state-time)))
  :trans
    (behavior ()
      (if (and *target*
               (>= (-> self fact idle-distance) (vector-vector-distance (-> self root trans) (-> *target* control trans))))
        (go swamp-rat-nest-active)))
  :code
    (behavior ()
      (swamp-rat-nest-check-dummy)
      (loop
        (suspend)))
  :post #f)

(defstate swamp-rat-nest-active (swamp-rat-nest)
  :event swamp-rat-nest-default-event-handler
  :enter
    (behavior ()
      (set-time! (-> self state-time)))
  :trans
    (behavior ()
      (swamp-rat-nest-check-dummy)
      (when (time-elapsed? (-> self state-time) (-> self test-interval))
        (set-time! (-> self state-time))
        (set! (-> self test-interval) (seconds 0.2))
        (let ((v1-6 0))
          (let ((a0-2 (the-as (pointer process-tree) (-> self child-process))))
            (while a0-2
              (if (= (-> (ppointer->process a0-2) type) swamp-rat) (+! v1-6 1))
              (set! a0-2 (-> a0-2 0 brother))))
          (if (< v1-6 (-> self rat-count)) (go swamp-rat-nest-gestate)))))
  :code
    (behavior ()
      (loop
        (suspend)))
  :post #f)

(defstate swamp-rat-nest-gestate (swamp-rat-nest)
  :event swamp-rat-nest-default-event-handler
  :enter
    (behavior ()
      (set-time! (-> self state-time)))
  :trans
    (behavior ()
      (swamp-rat-nest-check-dummy)
      (when (time-elapsed? (-> self state-time) (the int (* (-> self spawn-period-scale) (-> self spawn-period))))
        (send-event (ppointer->process (-> self dummy)) 'shake)
        (swamp-rat-nest-spawn-rat)
        (go swamp-rat-nest-active)))
  :code
    (behavior ()
      (loop
        (suspend)))
  :post #f)

(defstate swamp-rat-nest-victory (swamp-rat-nest)
  :event #f
  :code
    (behavior ()
      (let ((gp-0 (the-as (pointer process-tree) (-> self child-process))))
        (while gp-0
          (let* ((s5-0 (ppointer->process gp-0))
                 (a0-1 (if (and (nonzero? s5-0) (type-type? (-> s5-0 type) swamp-rat)) s5-0)))
            (if a0-1 (send-event a0-1 'victory)))
          (set! gp-0 (-> gp-0 0 brother))))
      (go swamp-rat-nest-active))
  :post #f)

(defstate swamp-rat-nest-die (swamp-rat-nest)
  :event swamp-rat-nest-default-event-handler
  :code
    (behavior ()
      (process-entity-status! self (entity-perm-status complete) #t)
      (process-entity-status! self (entity-perm-status dead) #t)
      (drop-pickup (-> self fact) #t *entity-pool* (-> self fact) 0)
      (while (-> self child-process)
        (suspend)))
  :post #f)

(defmethod init-from-entity! ((this swamp-rat-nest) (arg0 entity-actor))
  (logior! (-> this mask) (process-mask enemy))
  (set! (-> this root) (new 'process 'trsqv))
  (process-drawable-from-entity! this arg0)
  (set! (-> this fact) (new 'process 'fact-info-enemy this (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc)))
  (set! (-> this path) (new 'process 'path-control this 'path 0.0))
  (logior! (-> this path flags) (path-control-flag display draw-line draw-point draw-text))
  (let ((s5-1 (res-lump-value arg0 'num-lurkers uint128 :default (the-as uint128 3))))
    (if (>= (get-health-percent-lost *game-info* #f) 0.5) (+! s5-1 -1))
    (set! (-> this rat-count) (max 1 (min 4 (the-as int s5-1)))))
  (set! (-> this defensive-rat-count) 2)
  (if (>= (get-health-percent-lost *game-info* #f) 0.75) (+! (-> this defensive-rat-count) -1))
  (set! (-> this dummy) (the-as (pointer swamp-rat-nest-dummy) #f))
  (set! (-> this dummy-type) 0)
  (set! (-> this hit-points) 0)
  (set! (-> this damaged) #f)
  (set! (-> this spawn-period) (* 1200.0 (rand-vu-float-range 0.9 1.1)))
  (set! (-> this spawn-period-scale) (+ 1.0 (* 2.0 (get-health-percent-lost *game-info* #f))))
  (set! (-> this test-interval) (rand-vu-int-range (seconds 0.1) (seconds 0.2)))
  (go swamp-rat-nest-idle)
  (none))

(defskelgroup *swamp-rat-nest-dummy-a-sg*
  swamp-rat-nest
  swamp-rat-nest-a-lod0-jg
  swamp-rat-nest-a-idle-ja
  ((swamp-rat-nest-a-lod0-mg (meters 20)) (swamp-rat-nest-a-lod1-mg (meters 999999)))
  :bounds (static-spherem 0 0 0 8))

(defskelgroup *swamp-rat-nest-dummy-b-sg*
  swamp-rat-nest
  swamp-rat-nest-b-lod0-jg
  swamp-rat-nest-b-idle-ja
  ((swamp-rat-nest-b-lod0-mg (meters 20)) (swamp-rat-nest-b-lod1-mg (meters 999999)))
  :bounds (static-spherem 0 0 0 8))

(defskelgroup *swamp-rat-nest-dummy-c-sg*
  swamp-rat-nest
  swamp-rat-nest-c-lod0-jg
  swamp-rat-nest-c-idle-ja
  ((swamp-rat-nest-c-lod0-mg (meters 999999)))
  :bounds (static-spherem 0 0 0 5))

(defmethod swamp-rat-nest-dummy-method-20 ((this swamp-rat-nest-dummy-a))
  (let ((s5-0 (new 'process 'collide-shape this (collide-list-enum hit-by-others))))
    (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 12288.0 0.0 20480.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! (-> this root) s5-0))
  (initialize-skeleton this *swamp-rat-nest-dummy-a-sg* '())
  (none))

(defmethod swamp-rat-nest-dummy-method-20 ((this swamp-rat-nest-dummy-b))
  (let ((s5-0 (new 'process 'collide-shape this (collide-list-enum hit-by-others))))
    (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 12288.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! (-> this root) s5-0))
  (initialize-skeleton this *swamp-rat-nest-dummy-b-sg* '())
  (none))

(defmethod swamp-rat-nest-dummy-method-20 ((this swamp-rat-nest-dummy-c))
  (let ((s5-0 (new 'process 'collide-shape this (collide-list-enum hit-by-others))))
    (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 12288.0 0.0 12288.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! (-> this root) s5-0))
  (initialize-skeleton this *swamp-rat-nest-dummy-c-sg* '())
  (none))

(defmethod swamp-rat-nest-dummy-method-21 ((this swamp-rat-nest-dummy-a))
  (let ((v1-0 0))
    (let* ((a0-1 '(5 6 7 8 9 10))
           (a1-0 (car a0-1)))
      (while (not (null? a0-1))
        (when (< v1-0 6)
          (set! (-> this spawn-joint-array v1-0) (/ (the-as int a1-0) 8))
          (+! v1-0 1))
        (set! a0-1 (cdr a0-1))
        (set! a1-0 (car a0-1))))
    (set! (-> this spawn-joint-count) v1-0))
  (set! (-> this death-part) group-swamp-rat-nest-a-explosion)
  (set! (-> this part) (create-launch-control group-swamp-rat-nest-a-puff this))
  (let ((v0-1 6)) (set! (-> this particle-spawn-joint) v0-1) v0-1))

(defmethod swamp-rat-nest-dummy-method-21 ((this swamp-rat-nest-dummy-b))
  (let ((v1-0 0))
    (let* ((a0-1 '(5 9 10 6 7 8))
           (a1-0 (car a0-1)))
      (while (not (null? a0-1))
        (when (< v1-0 6)
          (set! (-> this spawn-joint-array v1-0) (/ (the-as int a1-0) 8))
          (+! v1-0 1))
        (set! a0-1 (cdr a0-1))
        (set! a1-0 (car a0-1))))
    (set! (-> this spawn-joint-count) v1-0))
  (set! (-> this death-part) group-swamp-rat-nest-b-explosion)
  (set! (-> this part) (create-launch-control group-swamp-rat-nest-b-puff this))
  (let ((v0-1 9)) (set! (-> this particle-spawn-joint) v0-1) v0-1))

(defmethod swamp-rat-nest-dummy-method-21 ((this swamp-rat-nest-dummy-c))
  (let ((v1-0 0))
    (let* ((a0-1 '(5 6))
           (a1-0 (car a0-1)))
      (while (not (null? a0-1))
        (when (< v1-0 6)
          (set! (-> this spawn-joint-array v1-0) (/ (the-as int a1-0) 8))
          (+! v1-0 1))
        (set! a0-1 (cdr a0-1))
        (set! a1-0 (car a0-1))))
    (set! (-> this spawn-joint-count) v1-0))
  (set! (-> this death-part) group-swamp-rat-nest-c-explosion)
  (set! (-> this part) (create-launch-control group-swamp-rat-nest-c-puff this))
  (let ((v0-1 5)) (set! (-> this particle-spawn-joint) v0-1) v0-1))
