jak-project/goal_src/jak2/engine/ai/enemy.gc
Ziemas cca829aecd
j2: fix enemy-method-135 (#3206)
Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-11-15 22:29:51 +01:00

3608 lines
125 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: enemy.gc
;; name in dgo: enemy
;; dgos: GAME, COMMON
;; DECOMP BEGINS
(defmethod copy-enemy-info! ((this enemy-info) (obj-to-copy enemy-info))
"Copies the given [[enemy-info]] into the current [[enemy-info]]"
(mem-copy! (&-> this type) (&-> obj-to-copy type) 384)
0
(none)
)
(define *enemy-dummy-shadow-control*
(new 'static 'shadow-control :settings (new 'static 'shadow-settings
:flags (shadow-flags shdf03 disable-draw)
:shadow-dir (new 'static 'vector :y -1.0 :w 614400.0)
:bot-plane (new 'static 'plane :y 1.0 :w 4096.0)
:top-plane (new 'static 'plane :y 1.0 :w -4096.0)
)
)
)
(defmethod relocate ((this enemy) (arg0 int))
(if (nonzero? (-> this neck))
(&+! (-> this neck) arg0)
)
(call-parent-method this arg0)
)
(defmethod get-rand-float ((this enemy))
"@returns the result of calling [[rand-vu]]"
(rand-vu)
)
(defmethod get-rand-float-range ((this enemy) (low float) (high float))
"@param low The lower bound of the range (inclusive)
@param high The upper bound of the range (exclusive)
@returns A random float in the specified range"
(+ low (* (rand-vu) (- high low)))
)
(defmethod get-rand-int ((this enemy) (high int))
"@param high The upper bound of the range (exclusive)
@returns a random integer in the range 0 to `high`
@see [[rand-vu]]"
(the int (* (rand-vu) (the float high)))
)
(defmethod get-rand-int-range ((this enemy) (low int) (high int))
"@param low The lower bound of the range (inclusive)
@param high The upper bound of the range (exclusive)
@returns A random integer in the specified range"
(+ low (the int (* (rand-vu) (the float (+ (- 1 low) high)))))
)
(defmethod rng-hit? ((this enemy) (chance float))
"TODO - not the best name
@param chance The value to compare ([[>=]]) with the result from [[rand-vu]].
@returns If `chance` is greater than the random draw"
(>= chance (rand-vu))
)
;; WARN: new jak 2 until loop case, check carefully
(defmethod enemy-method-120 ((this enemy) (arg0 int) (arg1 int))
"TODO"
(let ((v1-0 0)
(s5-0 0)
)
(let ((a2-1 1))
(while (nonzero? arg0)
(+! arg0 -1)
(if (not (logtest? arg1 a2-1))
(+! v1-0 1)
)
(set! a2-1 (* a2-1 2))
)
)
(when (> v1-0 0)
(let ((v1-1 (get-rand-int this v1-0))
(a0-1 1)
)
(until #f
(while (logtest? arg1 a0-1)
(nop!)
(nop!)
(+! s5-0 1)
(set! a0-1 (* a0-1 2))
)
(if (zero? v1-1)
(goto cfg-14)
)
(+! v1-1 -1)
(+! s5-0 1)
(set! a0-1 (* a0-1 2))
)
)
#f
)
(label cfg-14)
s5-0
)
)
(defmethod enemy-method-123 ((this enemy) (arg0 float))
"TODO"
(let* ((v1-5 (-> *display* frames (-> *display* last-screen) run-time))
(f1-2 (fmax 0.0 (fmin 1.0 (* 0.001 (+ -7000.0 (the float v1-5))))))
)
(>= (+ arg0 (* f1-2 (- 1.0 arg0))) (rand-vu))
)
)
(defmethod coin-flip? ((this enemy))
"@returns The result of a 50/50 RNG roll"
(zero? (get-rand-int this 2))
)
;; WARN: disable def twice: 40. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
(defmethod run-logic? ((this enemy))
(cond
((logtest? (-> this mask) (process-mask actor-pause))
(let ((draw (-> this draw)))
(or (and (nonzero? draw)
(>= (+ (-> *ACTOR-bank* pause-dist) (-> this root pause-adjust-distance))
(vector-vector-distance (-> this root trans) (camera-pos))
)
(or (logtest? (-> draw status) (draw-control-status on-screen))
(not (and (-> this next-state) (= (-> this next-state name) 'idle)))
)
)
(and (nonzero? (-> this skel)) (!= (-> this skel root-channel 0) (-> this skel channel)))
(and (nonzero? draw) (logtest? (-> draw status) (draw-control-status uninited)))
)
)
)
(else
#t
)
)
)
;; WARN: Return type mismatch object vs symbol.
(defmethod enemy-method-53 ((this enemy) (proc-focus process-focusable))
"TODO"
(the-as symbol (and proc-focus (!= this proc-focus) (collide-check? (-> this focus) proc-focus)))
)
(defmethod get-trans ((this enemy) (arg0 int))
"@returns the `trans` [[vector]] from the process's `root` (typically either a [[trsqv]] or a [[collide-shape]])"
(let ((s4-0 (-> this root)))
(cond
((zero? arg0)
(-> s4-0 trans)
)
((and (= arg0 1) (type? s4-0 collide-shape-moving))
(-> s4-0 gspot-pos)
)
((= arg0 2)
(vector<-cspace! (new 'static 'vector) (-> this node-list data (-> this enemy-info look-at-joint)))
)
((= arg0 3)
(let ((v0-0 (vector<-cspace! (new 'static 'vector) (-> this node-list data (-> this enemy-info bullseye-joint)))))
(set! (-> v0-0 w) (-> this root root-prim prim-core world-sphere w))
v0-0
)
)
(else
(-> s4-0 trans)
)
)
)
)
(defmethod enemy-method-124 ((this enemy))
"TODO"
(let* ((v1-0 (-> this enemy-info))
(v0-0 (if (logtest? (enemy-flag use-trigger) (-> this enemy-flags))
(-> v1-0 recover-gnd-collide-with)
(-> v1-0 gnd-collide-with)
)
)
)
(set! (-> this gnd-collide) (the-as uint v0-0))
v0-0
)
)
(defmethod get-penetrate-info ((this enemy))
"@returns the allowed way(s) this enemy can take damage
@see [[penetrate]] and [[penetrated-by-all&hit-points->penetrated-by]]"
(penetrated-by-all&hit-points->penetrated-by (-> this penetrated-by-all) (-> this hit-points))
)
(defmethod get-water-height ((this enemy))
(-> this water-surface-height)
)
(defmethod enemy-method-54 ((this enemy))
(let ((s4-0 (-> this root)))
(when (>= (-> this water-max-height) (-> s4-0 trans y))
(let ((s5-0 (new 'stack-no-clear 'water-info)))
(water-info-init! s4-0 s5-0 (collide-action solid semi-solid))
(let ((s3-0 (-> s5-0 flags)))
(when (logtest? (water-flags touch-water) s3-0)
(logior! (-> this enemy-flags) (enemy-flag directed-ready))
(set! (-> this water-surface-height) (-> s5-0 trans y))
(when (not (focus-test? this touch-water under-water))
(let ((s2-0 (new 'stack-no-clear 'vector)))
(set! (-> s2-0 quad) (-> this root trans quad))
(set! (-> s2-0 y) (+ 409.6 (-> s5-0 trans y)))
(let ((s1-0 (get-process *default-dead-pool* part-tracker #x4000)))
(when s1-0
(let ((t9-2 (method-of-type part-tracker activate)))
(t9-2
(the-as part-tracker s1-0)
*entity-pool*
(symbol->string (-> part-tracker symbol))
(the-as pointer #x70004000)
)
)
(let ((t9-3 run-function-in-process)
(a0-8 s1-0)
(a1-3 part-tracker-init)
(a2-5 (-> *part-group-id-table* 121))
(a3-1 0)
(t0-0 #f)
(t1-0 #f)
(t2-0 #f)
(t3-0 *launch-matrix*)
)
(set! (-> t3-0 trans quad) (-> s2-0 quad))
((the-as (function object object object object object object object object none) t9-3)
a0-8
a1-3
a2-5
a3-1
t0-0
t1-0
t2-0
t3-0
)
)
(-> s1-0 ppointer)
)
)
)
(cond
((logtest? s3-0 (water-flags dark-eco))
(sound-play "eco-splash")
(send-event this 'instant-death)
)
(else
(sound-play "splash")
)
)
)
(logior! (-> this focus-status) (focus-status touch-water))
(let* ((v1-32 (-> s4-0 root-prim prim-core))
(f0-5 (+ (-> v1-32 world-sphere y) (-> v1-32 world-sphere w)))
)
(if (focus-test? this under-water)
(set! f0-5 (+ -819.2 f0-5))
)
(if (< f0-5 (-> s5-0 trans y))
(logior! (-> this focus-status) (focus-status under-water))
(logclear! (-> this focus-status) (focus-status under-water))
)
)
(return (the-as enemy-flag #f))
)
)
)
)
)
(logclear! (-> this focus-status) (focus-status touch-water under-water))
(when (not (logtest? (enemy-flag use-trigger) (-> this enemy-flags)))
(let ((v0-9 (logclear (-> this enemy-flags) (enemy-flag directed-ready))))
(set! (-> this enemy-flags) v0-9)
v0-9
)
)
)
(defmethod track-target! ((self enemy))
"Does a lot of various things relating to interacting with the target
- tracks when the enemy was last drawn
- looks at the target and handles attacking
@TODO Not extremely well understood yet"
(if (and (nonzero? (-> self draw)) (logtest? (-> self draw status) (draw-control-status on-screen)))
(set-time! (-> self last-draw-time))
)
(enemy-method-129 self)
(if (logtest? (enemy-flag use-trigger) (-> self enemy-flags))
(enemy-method-100 self)
)
(when *target*
;; og:preserve-this macro
(target-look-at-me! :trans (the-as vector (-> self root root-prim prim-core))
:message (if (logtest? (-> self enemy-flags) (enemy-flag use-notice-distance))
'attacking
))
)
(when (nonzero? (-> self neck))
(when (logtest? (-> self enemy-flags) (enemy-flag lock-focus))
(let ((a0-9 (handle->process (-> self focus handle))))
(if a0-9
(target-set! (-> self neck) (get-trans (the-as process-focusable a0-9) 2))
)
)
)
)
(when (and (logtest? (-> self enemy-flags) (enemy-flag attackable-backup))
(time-elapsed? (-> self auto-reset-penetrate-time) (seconds 0.1))
)
(logclear! (-> self enemy-flags) (enemy-flag attackable-backup))
(set! (-> self root penetrated-by) (get-penetrate-info self))
(let ((v1-48 0))
(if (logtest? (penetrate knocked) (-> self root penetrate-using))
(set! v1-48 (logior (shl 1 32) v1-48))
)
(set! (-> self root penetrate-using) (the-as penetrate v1-48))
)
)
(if (logtest? (-> self enemy-flags) (enemy-flag look-at-focus))
(enemy-method-136 self)
)
(if (logtest? (enemy-flag trackable-backup directed-ready) (-> self enemy-flags))
(enemy-method-54 self)
)
(if (and *debug-segment* (-> self enemy-info debug-draw-neck) (nonzero? (-> self neck)))
(joint-mod-debug-draw (-> self neck))
)
(ja-post)
0
(none)
)
(defmethod enemy-method-136 ((this enemy))
(when (or (time-elapsed? (-> this hit-focus-time) (seconds 2))
(and (handle->process (-> this focus handle))
(not (logtest? (-> (the-as process-focusable (handle->process (-> this focus handle))) focus-status)
(focus-status disable dead ignore grabbed)
)
)
)
)
(let ((v0-0 (logclear (-> this enemy-flags) (enemy-flag look-at-focus))))
(set! (-> this enemy-flags) v0-0)
v0-0
)
)
)
;; WARN: Return type mismatch int vs penetrate.
(defun get-penetrate-using-from-attack-event ((arg0 process-drawable) (arg1 event-message-block))
(let ((v1-0 (the-as attack-info (-> arg1 param 1))))
(if (logtest? (attack-mask penetrate-using) (-> v1-0 mask))
(return (the-as penetrate (-> v1-0 penetrate-using)))
)
)
(let* ((gp-0 arg0)
(v1-3 (if (type? gp-0 process-drawable)
gp-0
)
)
)
(when v1-3
(let* ((gp-1 (-> v1-3 root))
(v1-4 (if (type? gp-1 collide-shape)
(the-as collide-shape gp-1)
)
)
)
(if v1-4
(return (the-as penetrate (logior (-> v1-4 penetrate-using) (penetrate generic-attack))))
)
)
)
)
(the-as penetrate 2)
)
;; WARN: Return type mismatch process vs process-focusable.
(defmethod get-enemy-target ((this enemy))
"@returns the [[process-focusable]] that the enemy is currently focusing on, or [[#f]] otherwise"
(let ((v0-0 (handle->process (-> this focus handle))))
(if (and v0-0
(not (and v0-0
(not (logtest? (-> (the-as process-focusable v0-0) focus-status) (focus-status disable dead ignore grabbed)))
)
)
)
(set! v0-0 (the-as process #f))
)
(the-as process-focusable v0-0)
)
)
(defmethod enemy-method-63 ((this enemy) (arg0 process-focusable) (arg1 enemy-aware))
(if arg1
(enemy-focus-method-13 (-> this focus) arg0 arg1)
(try-update-focus (-> this focus) arg0 this)
)
)
(defmethod enemy-method-62 ((this enemy))
(when (not (logtest? (enemy-flag actor-pause-backup) (-> this enemy-flags)))
(let* ((s4-0 (handle->process (-> this incoming attacker-handle)))
(s5-0 (if (type? s4-0 process-focusable)
s4-0
)
)
)
(when (enemy-method-53 this (the-as process-focusable s5-0))
(enemy-method-63 this (the-as process-focusable s5-0) (the-as enemy-aware #f))
(logior! (-> this focus flags) (enemy-flag lock-focus))
)
)
)
0
(none)
)
(defmethod enemy-method-108 ((this enemy) (arg0 enemy) (arg1 event-message-block))
(let ((s4-0 (the-as touching-shapes-entry (-> arg1 param 0))))
(when (and s4-0
(and (logtest? (-> this incoming penetrate-using) 4096)
(not (logtest? (-> this incoming penetrate-using) 32))
)
(begin
(let ((s3-0 (-> s4-0 head)))
(while s3-0
(let ((s2-0 (get-touched-prim s3-0 (-> arg0 root) s4-0)))
(get-touched-prim s3-0 (-> this root) s4-0)
(when (logtest? (-> s2-0 prim-core action) (collide-action solid semi-solid deadly))
(let* ((a0-5 this)
(t9-2 (method-of-object a0-5 enemy-method-104))
(a1-3 arg0)
(a2-3 s4-0)
(v1-13 *game-info*)
(a3-1 (+ (-> v1-13 attack-id) 1))
)
(set! (-> v1-13 attack-id) a3-1)
(if (t9-2 a0-5 a1-3 a2-3 a3-1)
(return 0)
)
)
)
)
(set! s3-0 (-> s3-0 next))
)
)
#f
)
)
)
)
0
)
;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-64 ((this enemy))
(let ((v1-1 (-> this root root-prim)))
(set! (-> v1-1 prim-core collide-as) (collide-spec))
(set! (-> v1-1 prim-core collide-with) (collide-spec))
)
0
(logior! (-> this draw status) (draw-control-status no-draw))
(logior! (-> this focus-status) (focus-status disable))
(go (method-of-object this dormant))
(none)
)
;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-65 ((this enemy))
(let ((v1-1 (-> this root root-prim)))
(set! (-> v1-1 prim-core collide-as) (collide-spec))
(set! (-> v1-1 prim-core collide-with) (collide-spec))
)
0
(logior! (-> this draw status) (draw-control-status no-draw))
(logior! (-> this focus-status) (focus-status disable))
(go (method-of-object this dormant-aware))
(none)
)
(defmethod go-stare ((this enemy))
(go (method-of-object this stare))
)
(defmethod go-stare2 ((this enemy))
(go (method-of-object this stare))
)
(defmethod go-hostile ((this enemy))
(go (method-of-object this hostile))
)
(defmethod go-ambush ((this enemy))
(go (method-of-object this ambush))
)
(defmethod go-flee ((this enemy))
(go (method-of-object this flee))
)
(defmethod go-directed ((this enemy))
(go (method-of-object this directed))
)
(defmethod react-to-focus ((this enemy))
"@TODO - flesh out docs"
(let ((s5-0 (-> this focus aware)))
(cond
((and (= s5-0 (enemy-aware enemy-aware-3)) (get-enemy-target this))
(go-hostile this)
)
((<= (the-as int s5-0) 0)
(go (method-of-object this idle))
)
((>= 1 (the-as int s5-0))
(go (method-of-object this active))
)
((= s5-0 (enemy-aware unaware))
(go-flee this)
)
(else
(go-stare this)
)
)
)
)
;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-93 ((this enemy))
(if (logtest? (enemy-flag alert) (-> this enemy-flags))
(go-directed this)
(react-to-focus this)
)
(none)
)
(defmethod kill-prefer-falling ((this enemy))
"If available in `enemy-info`, [[go]] to the [[die-falling]] state, if not, [[die]]"
(if (-> this enemy-info use-die-falling)
(go (method-of-object this die-falling))
(go (method-of-object this die))
)
)
(defmethod enemy-method-135 ((this enemy) (sound int))
(let ((name (static-sound-name "")))
(let ((sound-type sound))
(cond
((zero? sound-type)
(set! name (-> this enemy-info sound-hit))
)
((= sound-type 1)
(set! name (-> this enemy-info sound-die))
)
)
)
(if (nonzero? (the-as uint name))
(sound-play-by-name (the-as sound-name name) (new-sound-id) 1024 0 0 (sound-group sfx) #t)
)
)
)
(defmethod enemy-method-94 ((this enemy) (arg0 vector) (arg1 float))
(let ((s4-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> this root quat)))
(s5-0 (new 'stack-no-clear 'vector))
)
(set! (-> s5-0 quad) (-> arg0 quad))
(set! (-> s4-0 y) 0.0)
(vector-normalize! s4-0 1.0)
(set! (-> s5-0 y) 0.0)
(vector-normalize! s5-0 1.0)
(>= (vector-dot s4-0 s5-0) (cos arg1))
)
)
(defmethod enemy-method-95 ((this enemy) (arg0 vector) (arg1 float))
(let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg0 (-> this root trans))))
(enemy-method-94 this v1-1 arg1)
)
)
(defmethod enemy-method-96 ((this enemy) (arg0 float) (arg1 symbol))
(let ((a0-2 (handle->process (-> this focus handle))))
(cond
(a0-2
(let ((s4-1
(vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable a0-2) 0) (-> this root trans))
)
)
(enemy-method-94 this s4-1 arg0)
)
)
(else
arg1
)
)
)
)
(defmethod enemy-method-104 ((this enemy) (arg0 process) (arg1 touching-shapes-entry) (arg2 uint))
(let ((v1-1 (-> this enemy-info attack-damage)))
(if (and (logtest? (-> *game-info* secrets) (game-secrets hero-mode)) (= v1-1 1))
(set! v1-1 2)
)
(when (send-event arg0 'attack arg1 (static-attack-info ((id arg2)
(shove-back (-> this enemy-info attack-shove-back))
(shove-up (-> this enemy-info attack-shove-up))
(mode (-> this enemy-info attack-mode))
(damage (the float v1-1))
(knock (the-as uint 8))
)
)
)
(enemy-method-105 this arg0)
#t
)
)
)
(defmethod enemy-method-105 ((this enemy) (arg0 process))
(when (logtest? (process-mask target bot) (-> arg0 mask))
(set! (-> this root penetrated-by) (the-as penetrate -1))
(enemy-method-49 this)
)
(let ((s5-0 (if (type? arg0 process-focusable)
arg0
)
)
)
(when (enemy-method-53 this (the-as process-focusable s5-0))
(let ((v1-10 (handle->process (-> this focus handle))))
(when (or (= s5-0 v1-10) (and (not (logtest? (enemy-flag actor-pause-backup) (-> this enemy-flags)))
(or (not v1-10) (not (logtest? (-> this focus flags) (enemy-flag lock-focus))))
)
)
(enemy-method-63 this (the-as process-focusable s5-0) (the-as enemy-aware #f))
(set-time! (-> this hit-focus-time))
(let ((v0-3 (logior (-> this enemy-flags) (enemy-flag look-at-focus))))
(set! (-> this enemy-flags) v0-3)
v0-3
)
)
)
)
)
)
(defmethod enemy-method-49 ((this enemy))
(logior! (-> this enemy-flags) (enemy-flag attackable-backup))
(let ((v0-0 (current-time)))
(set! (-> this auto-reset-penetrate-time) v0-0)
v0-0
)
)
(defmethod enemy-method-50 ((this enemy) (arg0 vector))
(set! (-> arg0 quad) (-> this incoming attack-direction quad))
(let ((v1-1 arg0))
(when (= (+ (* (-> v1-1 x) (-> v1-1 x)) (* (-> v1-1 z) (-> v1-1 z))) 0.0)
(vector-z-quaternion! arg0 (-> this root quat))
(vector-negate-in-place! arg0)
)
)
(set! (-> arg0 y) 0.0)
(vector-xz-normalize! arg0 1.0)
)
;; WARN: Return type mismatch int vs uint.
(defmethod enemy-method-131 ((this enemy) (arg0 int))
(the-as uint (cond
((logtest? arg0 1024)
7
)
((logtest? #x1000000 arg0)
6
)
((logtest? #x4400000 arg0)
4
)
((logtest? #x800000 arg0)
5
)
((logtest? #xc0000 arg0)
3
)
((logtest? #xa200000 arg0)
2
)
((logtest? arg0 #x4000)
1
)
(else
0
)
)
)
)
(defmethod enemy-method-106 ((this enemy) (arg0 process) (arg1 object) (arg2 int) (arg3 attack-info))
(set! (-> this incoming penetrate-using) (the-as uint arg2))
(set! (-> this incoming attack-id) (-> arg3 id))
(let ((v1-3 (if (logtest? (attack-mask knock) (-> arg3 mask))
(-> arg3 knock)
(enemy-method-131 this arg2)
)
)
)
(set! (-> this incoming knocked-type) (the-as knocked-type v1-3))
(let ((a0-4 (current-time)))
(cond
((!= v1-3 6)
(set! (-> this incoming blue-juggle-count) (the-as uint 0))
0
)
((time-elapsed? (-> this incoming attack-time) (seconds 1))
(set! (-> this incoming blue-juggle-count) (the-as uint 1))
)
(else
(+! (-> this incoming blue-juggle-count) 1)
)
)
(set! (-> this incoming attack-time) a0-4)
)
(cond
((= v1-3 7)
(set! (-> this incoming attack-direction quad) (-> arg3 vector quad))
)
(else
(let ((s3-0 (new 'stack-no-clear 'attack-info)))
(attack-info-method-9 arg3 s3-0 (the-as process-drawable arg0) this)
(set! (-> this incoming attacker-pos quad) (-> s3-0 intersection quad))
(set! (-> this incoming attack-direction quad) (-> s3-0 attacker-velocity quad))
)
)
)
)
(set! (-> this incoming attacker-handle) (process->handle (enemy-method-134 this arg0 arg3)))
0
(none)
)
(defmethod look-at-target! ((this enemy) (arg0 enemy-flag))
"Logic for looking at the target that is locked on, sets some flags and adjusts the neck to look at the target if available
@param flag Reacts to [[enemy-flag::death-start]] and [[enemy-flag::enable-on-active]], see implementation for details"
(case arg0
(((enemy-flag lock-focus))
(logclear! (-> this enemy-flags) (enemy-flag death-start))
(logior! (-> this enemy-flags) (enemy-flag lock-focus))
)
(((enemy-flag death-start))
(logclear! (-> this enemy-flags) (enemy-flag lock-focus))
(logior! (-> this enemy-flags) (enemy-flag death-start))
)
)
(if (nonzero? (-> this neck))
(mode-set! (-> this neck) (joint-mod-mode look-at))
)
0
(none)
)
(defmethod stop-looking-at-target! ((this enemy))
"Will unset [[enemy-flag::death-start]] and [[enemy-flag::lock-focus]] and call [[joint-mod::shut-down]] if applicable"
(when (nonzero? (-> this neck))
(logclear! (-> this enemy-flags) (enemy-flag lock-focus death-start))
(shut-down (-> this neck))
)
0
(none)
)
(defmethod enemy-method-125 ((this enemy) (arg0 collide-query) (arg1 collide-spec) (arg2 float) (arg3 float) (arg4 float))
(when (find-ground (-> this root) arg0 arg1 arg2 arg3 arg4)
(let ((v0-1 (-> arg0 best-other-tri pat)))
(set! (-> this root ground-pat) v0-1)
v0-1
)
)
)
(defmethod enemy-above-ground? ((this enemy) (arg0 collide-query) (arg1 vector) (arg2 collide-spec) (arg3 float) (arg4 float) (arg5 float))
"@returns if the enemy is above the ground or not
@see [[above-ground?]]"
(above-ground? (-> this root) arg0 arg1 arg2 arg3 arg4 arg5)
)
(defmethod enemy-method-127 ((this enemy) (arg0 float) (arg1 float) (arg2 symbol) (arg3 collide-spec))
(let ((s4-0 (new 'stack-no-clear 'collide-query)))
(cond
((enemy-method-125 this s4-0 arg3 arg0 arg1 1024.0)
(let ((s5-1 (-> this root)))
(let ((s3-0 (new 'stack-no-clear 'vector)))
(set! (-> s3-0 quad) (-> this root trans quad))
(set! (-> s3-0 y) (-> s4-0 best-other-tri intersect y))
(move-to-point! s5-1 s3-0)
(let ((a0-3 (-> s4-0 best-other-tri normal))
(v1-8 (-> s4-0 best-other-tri pat))
)
(set! (-> s5-1 grount-touch-point quad) (-> s3-0 quad))
(set! (-> s5-1 poly-normal quad) (-> a0-3 quad))
(set! (-> s5-1 surface-normal quad) (-> a0-3 quad))
(set! (-> s5-1 local-normal quad) (-> a0-3 quad))
(set! (-> s5-1 ground-poly-normal quad) (-> a0-3 quad))
(set! (-> s5-1 poly-pat) v1-8)
(set! (-> s5-1 cur-pat) v1-8)
(set! (-> s5-1 ground-pat) v1-8)
)
)
(logior! (-> s5-1 status) (collide-status on-surface on-ground touch-surface))
)
#t
)
(else
(let ((v1-11 (-> this root)))
(logclear! (-> v1-11 status) (collide-status
on-surface
on-ground
touch-surface
touch-wall
touch-ceiling
touch-actor
on-special-surface
touch-edge
blocked
on-water
impact-surface
touch-background
stuck
glance
)
)
(when (not (logtest? (-> v1-11 root-prim prim-core action) (collide-action no-normal-reset)))
(let ((a0-12 (-> v1-11 dynam gravity-normal)))
(set! (-> v1-11 local-normal quad) (-> a0-12 quad))
(set! (-> v1-11 surface-normal quad) (-> a0-12 quad))
(set! (-> v1-11 poly-normal quad) (-> a0-12 quad))
)
(set! (-> v1-11 coverage) 0.0)
(set! (-> v1-11 touch-angle) 0.0)
)
)
(if arg2
(format 0 "WARNING: enemy::move-to-ground: failed to locate ground for ~S!~%" (-> this name))
)
#f
)
)
)
)
(defmethod enemy-method-128 ((this enemy) (arg0 vector) (arg1 move-above-ground-params))
(let ((gp-0 (-> this root)))
(set! (-> arg1 on-ground?) #f)
(set! (-> arg1 do-move?) #t)
(set! (-> arg1 old-gspot-pos quad) (-> gp-0 gspot-pos quad))
(set! (-> arg1 old-gspot-normal quad) (-> gp-0 gspot-normal quad))
(set! (-> gp-0 trans-old-old-old quad) (-> gp-0 trans-old-old quad))
(set! (-> gp-0 trans-old-old quad) (-> gp-0 trans-old quad))
(set! (-> gp-0 trans-old quad) (-> gp-0 trans quad))
(set! (-> gp-0 prev-status) (-> gp-0 status))
(vector-v+! (-> gp-0 trans) (-> gp-0 trans) arg0)
(set! (-> arg1 new-pos quad) (-> gp-0 trans quad))
(let ((s2-0 (new 'stack-no-clear 'collide-query)))
(cond
((enemy-method-125 this s2-0 (-> arg1 gnd-collide-with) (-> arg1 popup) 81920.0 1024.0)
(when (>= (-> gp-0 gspot-pos y) (-> arg1 new-pos y))
(set! (-> arg1 on-ground?) #t)
(set! (-> arg1 pat) (-> s2-0 best-other-tri pat))
(set! (-> arg1 new-pos y) (-> s2-0 best-other-tri intersect y))
(set! (-> gp-0 ground-impact-vel) (- (vector-dot arg0 (-> gp-0 dynam gravity-normal))))
(set! (-> arg0 y) 0.0)
)
)
(else
(if (-> arg1 hover-if-no-ground?)
(set! (-> arg1 new-pos y) (-> gp-0 trans-old y))
)
)
)
)
(set! (-> gp-0 trans quad) (-> gp-0 trans-old quad))
(move-to-point! gp-0 (-> arg1 new-pos))
(when (logtest? (logand (-> arg1 overlaps-params collide-with-filter)
(collide-spec hit-by-player-list hit-by-others-list player-list)
)
(-> gp-0 root-prim prim-core collide-with)
)
(when (find-overlapping-shapes gp-0 (-> arg1 overlaps-params))
(when (-> arg1 dont-move-if-overlaps?)
(set! (-> arg1 do-move?) #f)
(move-to-point! gp-0 (-> gp-0 trans-old))
(set! (-> gp-0 gspot-pos quad) (-> arg1 old-gspot-pos quad))
(set! (-> gp-0 gspot-normal quad) (-> arg1 old-gspot-normal quad))
)
)
)
(when (-> arg1 do-move?)
(cond
((-> arg1 on-ground?)
(let ((a1-6 (-> gp-0 gspot-pos))
(a0-21 (-> gp-0 gspot-normal))
(v1-39 (-> arg1 pat))
)
(set! (-> gp-0 grount-touch-point quad) (-> a1-6 quad))
(set! (-> gp-0 poly-normal quad) (-> a0-21 quad))
(set! (-> gp-0 surface-normal quad) (-> a0-21 quad))
(set! (-> gp-0 local-normal quad) (-> a0-21 quad))
(set! (-> gp-0 ground-poly-normal quad) (-> a0-21 quad))
(set! (-> gp-0 poly-pat) v1-39)
(set! (-> gp-0 cur-pat) v1-39)
(set! (-> gp-0 ground-pat) v1-39)
)
(logior! (-> gp-0 status) (collide-status on-surface on-ground touch-surface))
)
(else
(logclear! (-> gp-0 status) (collide-status
on-surface
on-ground
touch-surface
touch-wall
touch-ceiling
touch-actor
on-special-surface
touch-edge
blocked
on-water
impact-surface
touch-background
stuck
glance
)
)
(when (not (logtest? (-> gp-0 root-prim prim-core action) (collide-action no-normal-reset)))
(let ((v1-49 (-> gp-0 dynam gravity-normal)))
(set! (-> gp-0 local-normal quad) (-> v1-49 quad))
(set! (-> gp-0 surface-normal quad) (-> v1-49 quad))
(set! (-> gp-0 poly-normal quad) (-> v1-49 quad))
)
(set! (-> gp-0 coverage) 0.0)
(set! (-> gp-0 touch-angle) 0.0)
)
)
)
)
)
0
(none)
)
(defmethod enemy-method-111 ((this enemy))
(let ((v1-0 (-> this root)))
(when (logtest? (-> v1-0 status) (collide-status touch-surface))
(let ((f0-1 (fmax 0.0 (+ 1.0 (* 60.0 (seconds-per-frame) (+ -1.0 (-> this enemy-info friction)))))))
(vector-float*! (-> v1-0 transv) (-> v1-0 transv) f0-1)
)
0
)
)
0
(none)
)
(defmethod init-enemy-collision! ((this enemy))
"Initializes the [[collide-shape-moving]] and any ancillary tasks to make the enemy collide properly"
0
(none)
)
(defmethod init-enemy! ((this enemy))
"Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
0
(none)
)
;; WARN: Return type mismatch object vs none.
(defmethod go-idle ((this enemy))
(go (method-of-object this idle))
(none)
)
(defmethod set-enemy-info! ((this enemy) (arg0 enemy-info))
"In addition to setting the `enemy-info`, also init the `neck-joint` if applicable from it
@param info Set `enemy-info` accordingly"
(set! (-> this enemy-info) arg0)
(when (and (!= (-> this enemy-info neck-joint) -1) (zero? (-> this neck)))
(set! (-> this neck)
(new 'process 'joint-mod (joint-mod-mode flex-blend) this (-> this enemy-info neck-joint))
)
(set-vector! (-> this neck twist-max) 8192.0 8192.0 0.0 1.0)
(set! (-> this neck up) (the-as uint 1))
(set! (-> this neck nose) (the-as uint 2))
(set! (-> this neck ear) (the-as uint 0))
(set! (-> this neck max-dist) 102400.0)
(set! (-> this neck ignore-angle) 16384.0)
)
0
(none)
)
(defmethod init-enemy-behaviour-and-stats! ((this enemy) (arg0 enemy-info))
"Initializes a bunch of enemy fields related to how they should react, how many hitpoints they should have, etc"
(local-vars (sv-16 res-tag))
(when (coin-flip? this)
(let ((a0-2 (-> this node-list data 2)))
(set! (-> a0-2 param0) (the-as (function cspace transformq none) cspace<-parented-matrix-joint-flip-z!))
(set! (-> a0-2 param1) #f)
(set! (-> a0-2 param2) #f)
)
(set! (-> this enemy-flags) (the-as enemy-flag (logior (enemy-flag dislike-combo) (-> this enemy-flags))))
)
(logior! (-> this mask) (process-mask enemy))
(logior! (-> this mask) (process-mask actor-pause))
(logior! (-> this enemy-flags) (enemy-flag notice))
(set-enemy-info! this arg0)
(let ((a1-2 (-> this enemy-info idle-anim-script)))
(if a1-2
(idle-control-method-9 (-> this idle-anim-player) a1-2)
)
)
(if (-> this draw shadow)
(set! (-> this draw shadow-ctrl) (new
'process
'shadow-control
(-> this enemy-info shadow-min-y)
(-> this enemy-info shadow-max-y)
(-> this enemy-info shadow-locus-dist)
(shadow-flags shdf00 shdf04)
245760.0
)
)
(set! (-> this draw shadow-ctrl) *enemy-dummy-shadow-control*)
)
(set! (-> this water-max-height) 8192.0)
(if (logtest? (-> *game-info* secrets) (game-secrets hero-mode))
(set! (-> this hit-points) (* (-> this enemy-info default-hit-points) 2))
(set! (-> this hit-points) (-> this enemy-info default-hit-points))
)
(let* ((v1-38 *game-info*)
(a0-10 (+ (-> v1-38 attack-id) 1))
)
(set! (-> v1-38 attack-id) a0-10)
(set! (-> this attack-id) a0-10)
)
(let* ((v1-39 *game-info*)
(a0-12 (+ (-> v1-39 attack-id) 1))
)
(set! (-> v1-39 attack-id) a0-12)
(set! (-> this persistent-attack-id) a0-12)
)
(set! (-> this incoming attacker-handle) (the-as handle #f))
(enemy-method-124 this)
(set! (-> this fact) (new
'process
'fact-info-enemy
this
(the-as (pointer float) (-> arg0 fact-defaults))
(pickup-type eco-pill-random)
(-> *FACT-bank* default-eco-pill-green-inc)
)
)
(let ((a1-5 (if (logtest? (enemy-option multi-focus) (-> this fact enemy-options))
#x400406
#x400402
)
)
)
(reset-to-collide-spec (-> this focus) (the-as collide-spec a1-5))
)
(set! sv-16 (new 'static 'res-tag))
(let ((v1-49 (res-lump-data (-> this entity) 'actor-groups pointer :tag-ptr (& sv-16))))
(cond
((and v1-49 (nonzero? (-> sv-16 elt-count)))
(set! (-> this actor-group) (the-as (pointer actor-group) v1-49))
(set! (-> this actor-group-count) (the-as int (-> sv-16 elt-count)))
)
(else
(set! (-> this actor-group) (the-as (pointer actor-group) #f))
(set! (-> this actor-group-count) 0)
0
)
)
)
(set! (-> this on-notice) (res-lump-struct (-> this entity) 'on-notice pair))
(set! (-> this on-active) (res-lump-struct (-> this entity) 'on-active pair))
(set! (-> this on-hostile) (res-lump-struct (-> this entity) 'on-hostile pair))
(set! (-> this on-death) (res-lump-struct (-> this entity) 'on-death pair))
(if (-> this on-notice)
(logior! (-> this enemy-flags) (enemy-flag auto-reset-penetrate))
)
(if (-> this on-active)
(logior! (-> this enemy-flags) (enemy-flag jump-check-blocked))
)
(if (-> this on-hostile)
(logior! (-> this enemy-flags) (enemy-flag drawn-mirrored))
)
(let ((s4-0 (-> this root)))
(set! (-> this penetrated-by-all) (-> s4-0 penetrated-by))
(set! (-> s4-0 penetrated-by) (get-penetrate-info this))
(set! (-> s4-0 event-self) 'touched)
)
(set! (-> this penetrated-flinch) (-> arg0 penetrate-flinch))
(set! (-> this penetrated-knocked) (-> arg0 penetrate-knocked))
(set! (-> this reaction-time) (the-as time-frame (get-rand-int-range this 30 180)))
(let* ((v1-79 (-> this enemy-flags))
(a0-28 (-> this fact enemy-options))
(v1-80 (logior (enemy-flag
enable-on-active
checking-water
enable-on-notice
look-at-move-dest
check-water-backup
no-initial-move-to-ground
)
v1-79
)
)
)
(if (logtest? (enemy-option multi-focus) a0-28)
(set! v1-80 (logior (enemy-flag trackable) v1-80))
)
(if (logtest? (enemy-option has-trigger) a0-28)
(set! v1-80 (logior (enemy-flag called-dying) v1-80))
)
(set! (-> this enemy-flags) v1-80)
)
(logior! (-> this mask) (process-mask collectable))
(if (and (-> this enemy-info move-to-ground)
(not (logtest? (enemy-flag vulnerable-backup) (-> this enemy-flags)))
(not (logtest? (enemy-option ambush) (-> this fact enemy-options)))
)
(enemy-method-127 this 40960.0 40960.0 #t (the-as collide-spec (-> this gnd-collide)))
)
(if (zero? (-> this draw light-index))
(set! (-> this draw light-index) (the-as uint 10))
)
0
(none)
)
;; WARN: Return type mismatch object vs none.
(defbehavior enemy-init-by-other enemy ((arg0 process-drawable) (arg1 enemy-init-by-other-params))
(let ((a1-1 (-> arg1 entity)))
(if a1-1
(process-entity-set! self a1-1)
)
)
(if (-> arg1 directed?)
(logior! (-> self enemy-flags) (enemy-flag alert))
)
(if (-> arg1 no-initial-move-to-ground?)
(set! (-> self enemy-flags) (the-as enemy-flag (logior (enemy-flag vulnerable-backup) (-> self enemy-flags))))
)
(init-enemy-collision! self)
(set! (-> self root trans quad) (-> arg1 trans quad))
(quaternion-copy! (-> self root quat) (-> arg1 quat))
(vector-identity! (-> self root scale))
(init-enemy! self)
(when (> (-> self enemy-info gem-joint) 0)
(cond
((and (or (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status save)))
(not (-> self entity))
)
(not (or (task-node-closed? (game-task-node city-win-introduction))
(logtest? (-> *game-info* secrets) (game-secrets hero-mode))
)
)
)
(setup-masks
(-> self draw)
(the-as int (-> self enemy-info gem-no-seg))
(the-as int (-> self enemy-info gem-seg))
)
)
(else
(setup-masks
(-> self draw)
(the-as int (-> self enemy-info gem-seg))
(the-as int (-> self enemy-info gem-no-seg))
)
(add-connection *part-engine* self (-> self enemy-info gem-joint) self 314 (-> self enemy-info gem-offset))
)
)
)
(let ((v1-43 (-> self fact enemy-options)))
(cond
(*debug-view-anims*
(go-virtual view-anims)
)
((logtest? (enemy-option dormant) v1-43)
(enemy-method-64 self)
)
((logtest? (enemy-flag alert) (-> self enemy-flags))
(go-directed self)
)
((logtest? (enemy-option dormant-aware) v1-43)
(enemy-method-65 self)
)
((logtest? (enemy-option ambush) (-> self fact enemy-options))
(go-ambush self)
)
(else
(go-idle self)
)
)
)
(none)
)
;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! ((this enemy) (arg0 entity-actor))
"Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
This commonly includes things such as:
- stack size
- collision information
- loading the skeleton group / bones
- sounds"
(init-enemy-collision! this)
(process-drawable-from-entity! this arg0)
(init-enemy! this)
(when (>= (-> this enemy-info gem-joint) 0)
(cond
((and (or (and (-> this entity) (logtest? (-> this entity extra perm status) (entity-perm-status save)))
(not (-> this entity))
)
(not (or (task-node-closed? (game-task-node city-win-introduction))
(logtest? (-> *game-info* secrets) (game-secrets hero-mode))
)
)
)
(setup-masks
(-> this draw)
(the-as int (-> this enemy-info gem-no-seg))
(the-as int (-> this enemy-info gem-seg))
)
)
(else
(setup-masks
(-> this draw)
(the-as int (-> this enemy-info gem-seg))
(the-as int (-> this enemy-info gem-no-seg))
)
(add-connection *part-engine* this (-> this enemy-info gem-joint) this 314 (-> this enemy-info gem-offset))
)
)
)
(let ((v1-28 (-> this fact enemy-options)))
(cond
((logtest? (enemy-option spawner) v1-28)
(process-entity-status! this (entity-perm-status dead) #t)
(go (method-of-object this die-fast))
)
(*debug-view-anims*
(go (method-of-object this view-anims))
)
((logtest? (enemy-option dormant) v1-28)
(enemy-method-64 this)
)
((logtest? (enemy-option dormant-aware) v1-28)
(enemy-method-65 this)
)
(else
(go-idle this)
)
)
)
(none)
)
(defmethod in-aggro-range? ((this enemy) (arg0 process-focusable) (arg1 vector))
"Should the enemy activate.
- if `activate-distance` is `0.0`, always true
- otherwise, check if the provided process is close enough
@param proc The process used to distance check
@returns true/false"
#t
)
(defmethod enemy-method-99 ((this enemy) (arg0 process-focusable))
#f
)
(defmethod reset-to-collide-spec ((this enemy-focus) (arg0 collide-spec))
(let ((t9-0 (method-of-type focus reset-to-collide-spec)))
(t9-0 this arg0)
)
(set! (-> this aware) (enemy-aware enemy-aware-0))
0
(none)
)
;; WARN: Return type mismatch process vs none.
;; WARN: Function (method 129 enemy) has a return type of none, but the expression builder found a return statement.
(defmethod enemy-method-129 ((this enemy))
(let ((gp-0 (-> this focus)))
(let ((a1-0 (handle->process (-> gp-0 handle))))
(when a1-0
(let ((v1-4 (-> this enemy-flags)))
(cond
((and a1-0 (not (logtest? (-> (the-as process-focusable a1-0) focus-status) (focus-status disable dead))))
(when (and (logtest? (enemy-flag trackable) v1-4)
(not (logtest? (enemy-flag actor-pause-backup) v1-4))
(not (logtest? (-> gp-0 flags) (enemy-flag lock-focus)))
)
(enemy-method-97 this)
(return #f)
)
(let ((v1-14
(enemy-method-61
this
(the-as int (update-target-awareness! this (the-as process-focusable a1-0) (the-as enemy-best-focus #f)))
)
)
)
(set! (-> gp-0 aware) (the-as enemy-aware v1-14))
(if (>= 1 v1-14)
(logclear! (-> gp-0 flags) (enemy-flag lock-focus))
)
)
(return #f)
)
(else
(clear-focused gp-0)
)
)
)
)
)
(if (!= (-> gp-0 handle) #f)
(clear-focused gp-0)
)
)
(if (not (logtest? (enemy-flag actor-pause-backup) (-> this enemy-flags)))
(enemy-method-97 this)
)
(none)
)
(defmethod enemy-method-97 ((this enemy))
(let ((s4-0 (-> this focus collide-with))
(gp-0 (new 'stack-no-clear 'enemy-best-focus))
)
(set! (-> gp-0 proc) #f)
(set! (-> gp-0 rating) 409600000.0)
(set! (-> gp-0 aware) (enemy-aware enemy-aware-0))
(when (logtest? s4-0 (collide-spec player-list))
(let ((v1-4 (-> *collide-player-list* alive-list next0)))
*collide-player-list*
(let ((s3-0 (-> v1-4 next0)))
(while (!= v1-4 (-> *collide-player-list* alive-list-end))
(let ((v1-5 (the-as collide-shape (-> (the-as connection v1-4) param1))))
(when (logtest? s4-0 (-> v1-5 root-prim prim-core collide-as))
(let* ((s2-0 (-> v1-5 process))
(a1-1 (if (type? s2-0 process-focusable)
(the-as process-focusable s2-0)
)
)
)
(if (and a1-1 (and a1-1 (not (logtest? (-> a1-1 focus-status) (focus-status disable dead)))) (!= this a1-1))
(update-target-awareness! this a1-1 gp-0)
)
)
)
)
(set! v1-4 s3-0)
*collide-player-list*
(set! s3-0 (-> s3-0 next0))
)
)
)
)
(when (logtest? s4-0 (collide-spec hit-by-player-list hit-by-others-list))
(when (logtest? s4-0 (collide-spec hit-by-player-list))
(let ((v1-19 (-> *collide-hit-by-player-list* alive-list next0)))
*collide-hit-by-player-list*
(let ((s3-1 (-> v1-19 next0)))
(while (!= v1-19 (-> *collide-hit-by-player-list* alive-list-end))
(let ((v1-20 (the-as collide-shape (-> (the-as connection v1-19) param1))))
(when (logtest? s4-0 (-> v1-20 root-prim prim-core collide-as))
(let* ((s2-1 (-> v1-20 process))
(a1-3 (if (type? s2-1 process-focusable)
(the-as process-focusable s2-1)
)
)
)
(if (and a1-3 (and a1-3 (not (logtest? (-> a1-3 focus-status) (focus-status disable dead)))) (!= this a1-3))
(update-target-awareness! this a1-3 gp-0)
)
)
)
)
(set! v1-19 s3-1)
*collide-hit-by-player-list*
(set! s3-1 (-> s3-1 next0))
)
)
)
)
(when (logtest? s4-0 (collide-spec hit-by-others-list))
(let ((v1-32 (-> *collide-hit-by-others-list* alive-list next0)))
*collide-hit-by-others-list*
(let ((s3-2 (-> v1-32 next0)))
(while (!= v1-32 (-> *collide-hit-by-others-list* alive-list-end))
(let ((v1-33 (the-as collide-shape (-> (the-as connection v1-32) param1))))
(when (logtest? s4-0 (-> v1-33 root-prim prim-core collide-as))
(let* ((s2-2 (-> v1-33 process))
(a1-5 (if (type? s2-2 process-focusable)
(the-as process-focusable s2-2)
)
)
)
(if (and a1-5 (and a1-5 (not (logtest? (-> a1-5 focus-status) (focus-status disable dead)))) (!= this a1-5))
(update-target-awareness! this a1-5 gp-0)
)
)
)
)
(set! v1-32 s3-2)
*collide-hit-by-others-list*
(set! s3-2 (-> s3-2 next0))
)
)
)
)
)
(let ((s4-1 (-> gp-0 proc)))
(when s4-1
(enemy-method-63
this
(the-as process-focusable s4-1)
(the-as enemy-aware (enemy-method-61 this (the-as int (-> gp-0 aware))))
)
s4-1
)
)
)
)
;; WARN: Return type mismatch int vs enemy-aware.
(defmethod update-target-awareness! ((this enemy) (arg0 process-focusable) (arg1 enemy-best-focus))
"Checks a variety of criteria to determine the level of awareness the enemy is of the target. Sets `aware` and related fields as well!
@TODO - flesh out docs
@returns the value that sets `aware`"
(let ((f30-0 (vector-vector-distance (get-trans arg0 0) (-> this root trans)))
(s3-1 #f)
(s2-0 #f)
)
(cond
((< f30-0 (-> this enemy-info proximity-notice-distance))
(set! s3-1 #t)
(set! s2-0 (in-aggro-range? this arg0 (the-as vector #f)))
)
(else
(let ((f0-1 (the-as float (-> this enemy-info notice-distance))))
(if (< 1 (the-as int (-> this focus aware)))
(set! f0-1 (+ (the-as meters f0-1) (-> this enemy-info notice-distance-delta)))
)
(when (or (< f30-0 f0-1) (not (logtest? (-> this enemy-flags) (enemy-flag enable-on-notice))))
(set! s2-0 (in-aggro-range? this arg0 (the-as vector #f)))
(if s2-0
(set! s3-1 #t)
)
)
)
)
)
(let ((s3-2 (cond
(s3-1
(cond
((enemy-method-99 this arg0)
4
)
(s2-0
3
)
(else
2
)
)
)
((< f30-0 (-> this fact idle-distance))
1
)
(else
0
)
)
)
)
(when (and (> s3-2 0) (logtest? (enemy-flag called-dying) (-> this enemy-flags)))
(cond
((logtest? (enemy-option idle-til-trigger) (-> this fact enemy-options))
(if (not (enemy-method-130 this f30-0))
(set! s3-2 0)
)
)
(else
(if (and (< 1 s3-2) (not (enemy-method-130 this f30-0)))
(set! s3-2 1)
)
)
)
)
(when arg1
(when (and (>= s3-2 (the-as int (-> arg1 aware))) (< f30-0 (-> arg1 rating)))
(set! (-> arg1 aware) (the-as enemy-aware s3-2))
(set! (-> arg1 rating) f30-0)
(set! (-> arg1 proc) arg0)
)
)
(the-as enemy-aware s3-2)
)
)
)
(defmethod enemy-method-130 ((this enemy) (arg0 float))
(let* ((v1-0 (-> this fact))
(a2-0 (-> v1-0 trig-mask-count))
(a3-0 (-> v1-0 trig-mask))
)
(dotimes (t0-0 a2-0)
(let ((t1-1 (the-as int (-> a3-0 t0-0))))
(if (and (logtest? (the-as uint t1-1) 1) (>= (-> v1-0 trig-dist) arg0))
(set! t1-1 (the-as int (logand -2 (the-as uint t1-1))))
)
(when (logtest? (the-as uint t1-1) 2)
(let ((t2-8 (-> v1-0 trig-actor-group 0)))
(countdown (t3-0 (-> t2-8 length))
(let ((t5-0 (-> t2-8 data t3-0 actor)))
(when (and t5-0 (logtest? (-> t5-0 extra perm status) (entity-perm-status subtask-complete)))
(set! t1-1 (logand -3 t1-1))
(goto cfg-17)
)
)
)
)
)
(label cfg-17)
(when (zero? t1-1)
(logclear! (-> this enemy-flags) (enemy-flag called-dying))
(return #t)
)
)
)
)
#f
)
(defmethod enemy-method-61 ((this enemy) (arg0 int))
(let ((v1-1 (< 1 arg0)))
(cond
(v1-1
(when (not (logtest? (-> this enemy-flags) (enemy-flag spawn-gem)))
(logior! (-> this enemy-flags) (enemy-flag spawn-gem))
(set-time! (-> this notice-time))
)
(if (and (not (logtest? (-> this enemy-flags) (enemy-flag chase-startup)))
(not (time-elapsed? (-> this notice-time) (-> this reaction-time)))
)
(set! v1-1 #f)
)
)
(else
(logclear! (-> this enemy-flags) (enemy-flag spawn-gem))
)
)
(cond
(v1-1
arg0
)
((or (zero? arg0) (time-elapsed? (-> this last-draw-time) (seconds 2)))
0
)
(else
1
)
)
)
)
(defmethod general-event-handler ((this enemy) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
"Handles various events for the enemy
@TODO - unsure if there is a pattern for the events and this should have a more specific name"
(local-vars (s5-5 rgbaf) (sv-432 process) (sv-448 event-message-block))
(cond
((= arg2 'track)
(and (nonzero? (-> this hit-points))
(logtest? (-> this enemy-flags) (enemy-flag enable-on-active))
(logtest? (enemy-flag check-water-backup) (-> this enemy-flags))
)
)
((= arg2 'combo)
(and (not (logtest? (enemy-flag multi-focus) (-> this enemy-flags))) (nonzero? (-> this hit-points)))
)
((= arg2 'touch)
(enemy-method-75 this arg0 arg3)
)
((= arg2 'touched)
(when (logtest? (-> this enemy-flags) (enemy-flag attackable-backup))
(let* ((s3-1 arg0)
(v1-20 (if (type? s3-1 process-drawable)
(the-as process-drawable s3-1)
)
)
)
(when v1-20
(let* ((s3-2 (-> v1-20 root))
(a1-4 (if (type? s3-2 collide-shape)
s3-2
)
)
(s3-3 (-> arg3 param 0))
)
(if (and a1-4
s3-3
((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry s3-3)
(the-as collide-shape a1-4)
(collide-action solid)
(collide-action)
)
((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry s3-3)
(-> this root)
(collide-action solid)
(collide-action)
)
)
(set-time! (-> this auto-reset-penetrate-time))
)
)
)
)
)
(enemy-method-76 this arg0 arg3)
)
((= arg2 'attack-invinc)
(case (-> (the-as attack-info (-> arg3 param 1)) mode)
(('endlessfall)
(let ((v1-31 (-> this root root-prim)))
(set! (-> v1-31 prim-core collide-as) (collide-spec))
(set! (-> v1-31 prim-core collide-with) (collide-spec))
)
0
(kill-prefer-falling this)
)
)
)
((= arg2 'attack)
(let ((s2-0 (the-as object (-> arg3 param 1))))
(when (!= (-> (the-as attack-info s2-0) id) (-> this incoming attack-id))
(cond
((and (logtest? (-> this enemy-flags) (enemy-flag enable-on-active))
(not (logtest? (-> this focus-status) (focus-status grabbed)))
)
(let* ((s1-0 this)
(s0-0 (method-of-object s1-0 enemy-method-106))
)
(set! sv-432 arg0)
(set! sv-448 arg3)
(let ((a3-3 (get-penetrate-using-from-attack-event (the-as process-drawable arg0) arg3)))
(s0-0 s1-0 sv-432 sv-448 (the-as int a3-3) (the-as attack-info s2-0))
)
)
(send-event (ppointer->process (-> this parent)) 'child-hit)
0
(when (not *debug-unkillable*)
;; og:preserve-this for damage numbers cheat
(#cond
(PC_PORT
(let ((old-hp (-> this hit-points))
(dmg-taken (take-damage-from-attack this arg0 arg3)))
(when (> dmg-taken 0)
(process-spawn damage-number (damage-amount-from-attack this arg0 arg3) (-> this root trans) (-> this mask))
(send-damage-to-bar *health-bar-manager* this dmg-taken old-hp))
(when (nonzero? (-> this fated-time))
(aif (get-bar-for-process *health-bar-manager* this)
(send-event (ppointer->process it) 'set-hit-points 0)
(send-damage-to-bar *health-bar-manager* this 1 1))
)
)
)
(#t
(take-damage-from-attack this arg0 arg3)))
)
(let ((s2-1 (the-as attack-info (enemy-method-58 this arg0 arg3))))
(when s2-1
(logclear! (-> this enemy-flags) (enemy-flag called-dying))
(enemy-method-108 this (the-as enemy arg0) arg3)
(let ((a1-13 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-13 from) (process->ppointer arg0))
(set! (-> a1-13 num-params) arg1)
(set! (-> a1-13 message) (the-as symbol s2-1))
(set! (-> a1-13 param 0) (-> arg3 param 0))
(set! (-> a1-13 param 1) (-> arg3 param 1))
(set! (-> a1-13 param 2) (-> arg3 param 2))
(set! (-> a1-13 param 3) (-> arg3 param 3))
(set! (-> a1-13 param 4) (-> arg3 param 4))
(set! (-> a1-13 param 5) (-> arg3 param 5))
(send-event-function this a1-13)
)
)
)
)
(else
(set! (-> this incoming attack-id) (-> (the-as attack-info s2-0) id))
(enemy-method-75 this arg0 arg3)
)
)
)
)
)
((= arg2 'hit-flinch)
(when (zero? (-> this hit-points))
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this focus-status) (focus-status dangerous))
(logclear! (-> this enemy-flags) (enemy-flag enable-on-notice))
(logior! (-> this enemy-flags) (enemy-flag chase-startup))
(logior! (-> this focus-status) (focus-status hit))
(if (zero? (-> this hit-points))
(logior! (-> this focus-status) (focus-status dead))
)
(logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(enemy-method-62 this)
(logior! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(process-contact-action arg0)
(send-event arg0 'get-attack-count 1)
(kill-prefer-falling this)
)
#t
)
((= arg2 'hit-knocked)
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this focus-status) (focus-status dangerous))
(logclear! (-> this enemy-flags) (enemy-flag enable-on-notice))
(logior! (-> this enemy-flags) (enemy-flag chase-startup))
(logior! (-> this focus-status) (focus-status hit))
(if (zero? (-> this hit-points))
(logior! (-> this focus-status) (focus-status dead))
)
(logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(enemy-method-62 this)
(logior! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(process-contact-action arg0)
(send-event arg0 'get-attack-count 1)
(when (zero? (-> this hit-points))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-4) (knocked-type knocked-type-6))
(set! (-> this incoming knocked-type) (knocked-type knocked-type-0))
0
)
)
)
(go (method-of-object this knocked))
)
((= arg2 'hit)
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this focus-status) (focus-status dangerous))
(logclear! (-> this enemy-flags) (enemy-flag enable-on-notice))
(logior! (-> this enemy-flags) (enemy-flag chase-startup))
(logior! (-> this focus-status) (focus-status hit))
(if (zero? (-> this hit-points))
(logior! (-> this focus-status) (focus-status dead))
)
(logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(enemy-method-62 this)
(logior! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(process-contact-action arg0)
(send-event arg0 'get-attack-count 1)
(if (zero? (-> this hit-points))
(kill-prefer-falling this)
(go (method-of-object this hit))
)
)
((= arg2 'cue-chase)
(when (and (> (-> this hit-points) 0)
(zero? (-> this fated-time))
(not (logtest? (-> this focus-status) (focus-status grabbed)))
)
(let ((v1-162 (logtest? (enemy-flag alert) (-> this enemy-flags))))
(logclear! (-> this enemy-flags) (enemy-flag enable-on-notice alert victory called-dying))
(logior! (-> this enemy-flags) (enemy-flag dangerous-backup))
(logclear! (-> this mask) (process-mask actor-pause))
(cond
(v1-162
(if (logtest? (enemy-option ambush) (-> this fact enemy-options))
(go-ambush this)
(go-hostile this)
)
)
((and (-> this next-state) (let ((v1-173 (-> this next-state name)))
(or (= v1-173 'dormant) (= v1-173 'dormant-aware))
)
)
(if (logtest? (enemy-option ambush) (-> this fact enemy-options))
(go-ambush this)
(go (method-of-object this notice))
)
)
)
)
#t
)
)
((= arg2 'cue-wake)
(when (and (> (-> this hit-points) 0)
(zero? (-> this fated-time))
(not (logtest? (-> this focus-status) (focus-status grabbed)))
)
(logclear! (-> this enemy-flags) (enemy-flag alert victory called-dying))
(if (logtest? (enemy-option ambush) (-> this fact enemy-options))
(go-ambush this)
(react-to-focus this)
)
#t
)
)
((= arg2 'jump)
(when (and (> (-> this hit-points) 0)
(zero? (-> this fated-time))
(not (logtest? (-> this focus-status) (focus-status grabbed)))
)
(logclear! (-> this mask) (process-mask actor-pause))
(set! (-> this jump-why) (-> arg3 param 0))
(set! (-> this event-param-point quad) (-> (the-as vector (-> arg3 param 1)) quad))
(go (method-of-object this jump))
)
)
((= arg2 'death-start)
(set! (-> this enemy-flags) (the-as enemy-flag (logior (enemy-flag recover) (-> this enemy-flags))))
(send-event (ppointer->process (-> this parent)) 'child-die)
(drop-pickup (-> this fact) #t *entity-pool* (-> this fact) 0)
(let ((s5-1 (-> this on-death)))
(if s5-1
(script-eval s5-1 :vector (-> this root trans))
)
)
)
((= arg2 'death-end)
(if (-> this skel effect)
(logior! (-> this skel effect flags) (effect-control-flag ecf2))
)
(logior! (-> this draw status) (draw-control-status no-draw))
(logclear! (-> this enemy-flags) (enemy-flag enable-on-active checking-water))
(logclear! (-> this focus-status) (focus-status dangerous))
(set! (-> this enemy-flags) (logclear (-> this enemy-flags) (enemy-flag check-water)))
)
((= arg2 'instant-death)
(when (and (> (-> this hit-points) 0) (zero? (-> this fated-time)))
(set! (-> this hit-points) 0)
(set! (-> this root penetrated-by) (get-penetrate-info this))
(let ((s5-2 (enemy-method-50 this (new 'stack-no-clear 'vector))))
(vector-z-quaternion! s5-2 (-> this root quat))
(vector-float*! s5-2 s5-2 -1.0)
(vector-normalize! s5-2 1.0)
)
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this focus-status) (focus-status dangerous))
(logclear! (-> this enemy-flags) (enemy-flag enable-on-notice))
(logior! (-> this enemy-flags) (enemy-flag chase-startup))
(logior! (-> this focus-status) (focus-status hit))
(if (zero? (-> this hit-points))
(logior! (-> this focus-status) (focus-status dead))
)
(logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(enemy-method-62 this)
(logior! (-> this enemy-flags) (enemy-flag actor-pause-backup))
(kill-prefer-falling this)
)
)
((= arg2 'die-fast)
(logior! (-> this draw status) (draw-control-status no-draw))
(dispose! this)
(send-event (ppointer->process (-> this parent)) 'child-die)
(let ((s5-3 (-> this on-death)))
(if s5-3
(script-eval s5-3 :vector (-> this root trans))
)
)
(cleanup-for-death this)
(go (method-of-object this die-fast))
)
((= arg2 'victory)
(if (and (-> this enemy-info use-victory)
(not (and (-> this next-state) (= (-> this next-state name) 'victory)))
(> (-> this hit-points) 0)
(zero? (-> this fated-time))
(not (logtest? (-> this focus-status) (focus-status grabbed)))
)
(go (method-of-object this victory))
)
)
((= arg2 'nav-control)
(if (nonzero? (-> this nav))
(-> this nav)
)
)
((= arg2 'push-trans)
(move-by-vector! (-> this root) (the-as vector (-> arg3 param 0)))
)
((= arg2 'move-trans)
(move-to-point! (-> this root) (the-as vector (-> arg3 param 0)))
)
((= arg2 'shadow)
(cond
((-> arg3 param 0)
(let ((v1-320 (-> this draw shadow-ctrl)))
(logclear! (-> v1-320 settings flags) (shadow-flags disable-draw))
)
0
)
(else
(let ((v1-323 (-> this draw shadow-ctrl)))
(logior! (-> v1-323 settings flags) (shadow-flags disable-draw))
)
0
)
)
)
((= arg2 'color-effect)
(case (-> arg3 param 0)
(('dark)
(let ((f30-0 (rand-vu-float-range 0.2 1.0)))
(set-vector! (-> this draw color-mult) (lerp 1.0 1.0 f30-0) (lerp 1.0 0.0 f30-0) (lerp 1.0 1.0 f30-0) 1.0)
(set! s5-5 (-> this draw color-emissive))
(set! (-> s5-5 x) (lerp 0.0 0.3 f30-0))
(set! (-> s5-5 y) (lerp 0.0 0.0 f30-0))
(set! (-> s5-5 z) (lerp 0.0 0.3 f30-0))
)
(set! (-> s5-5 w) 1.0)
s5-5
)
((#f)
(set-vector! (-> this draw color-mult) 1.0 1.0 1.0 1.0)
(set! s5-5 (-> this draw color-emissive))
(set! (-> s5-5 quad) (the-as uint128 0))
s5-5
)
)
)
)
)
(defmethod damage-amount-from-attack ((this enemy) (arg0 process) (arg1 event-message-block))
"@returns the amount of damage taken from an attack. This can come straight off the [[attack-info]] or via [[penetrate-using->damage]]"
(let ((v1-0 (the-as attack-info (-> arg1 param 1))))
(if (logtest? (attack-mask damage) (-> v1-0 mask))
(the int (-> v1-0 damage))
(penetrate-using->damage (the-as penetrate (-> this incoming penetrate-using)))
)
)
)
(defmethod enemy-method-58 ((this enemy) (arg0 process) (arg1 event-message-block))
(let ((v1-0 (-> this incoming penetrate-using)))
(cond
((logtest? (the-as penetrate v1-0) (-> this penetrated-flinch))
'hit-flinch
)
((logtest? (the-as penetrate v1-0) (-> this penetrated-knocked))
'hit-knocked
)
(else
'hit
)
)
)
)
(defmethod take-damage-from-attack ((this enemy) (arg0 process) (arg1 event-message-block))
(let* ((v1-1 (damage-amount-from-attack this arg0 arg1))
(s5-0 (-> this hit-points))
(s4-1 (max 0 (- s5-0 v1-1)))
)
(when (and (zero? s4-1) (nonzero? s5-0) (= (-> this incoming knocked-type) (knocked-type knocked-type-6)))
(cond
((zero? (-> this fated-time))
(set-time! (-> this fated-time))
(set! s4-1 1)
)
(else
(if (not (time-elapsed? (-> this fated-time) (seconds 1)))
(set! s4-1 1)
)
)
)
)
(set! (-> this hit-points) s4-1)
(if (not (logtest? (-> this enemy-flags) (enemy-flag attackable-backup)))
(set! (-> this root penetrated-by) (get-penetrate-info this))
)
(- s5-0 s4-1)
)
)
(defmethod enemy-method-134 ((this enemy) (arg0 process) (arg1 attack-info))
(find-offending-process-focusable arg0 arg1)
)
(defmethod enemy-method-75 ((this enemy) (arg0 process) (arg1 event-message-block))
(let* ((touch-entry (the-as touching-shapes-entry (-> arg1 param 0)))
(s2-0 arg0)
(s3-0 (if (type? s2-0 process-focusable)
(the-as process-focusable s2-0)
)
)
)
(when (and (the-as uint touch-entry) s3-0)
(cond
((and (focus-test? this dangerous)
(and s3-0 (not (logtest? (-> s3-0 focus-status) (focus-status disable dead ignore grabbed))))
((method-of-type touching-shapes-entry prims-touching-action?)
touch-entry
(-> this root)
(collide-action deadly)
(collide-action)
)
)
(let ((a3-2 (if ((method-of-type touching-shapes-entry prims-touching-action?)
touch-entry
(-> this root)
(collide-action persistent-attack)
(collide-action)
)
(-> this persistent-attack-id)
(-> this attack-id)
)
)
)
(enemy-method-104 this arg0 touch-entry a3-2)
)
)
((and ((method-of-type touching-shapes-entry prims-touching-action?)
touch-entry
(-> this root)
(collide-action no-standon)
(collide-action)
)
(not (logtest? (-> this root penetrated-by) (-> s3-0 root penetrate-using)))
)
(if (send-shoves (-> this root) arg0 touch-entry 0.7 6144.0 16384.0)
(send-event this 'bouncing-off arg0)
)
)
)
)
)
)
(defmethod enemy-method-76 ((this enemy) (arg0 process) (arg1 event-message-block))
(let ((s4-0 (-> arg1 param 0)))
(when s4-0
(when (or (and (and (-> this next-state) (= (-> this next-state name) 'knocked))
(logtest? (process-mask crate) (-> arg0 mask))
)
(and (and (-> this next-state) (= (-> this next-state name) 'jump))
(logtest? (process-mask target sidekick crate bot) (-> arg0 mask))
)
)
(when ((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry s4-0)
(-> this root)
(collide-action solid semi-solid deadly)
(collide-action)
)
(let ((a3-2 (if ((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry s4-0)
(-> this root)
(collide-action persistent-attack)
(collide-action)
)
(-> this persistent-attack-id)
(-> this attack-id)
)
)
)
(enemy-method-104 this arg0 (the-as touching-shapes-entry s4-0) a3-2)
)
)
)
)
)
)
(defbehavior enemy-event-handler enemy ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(general-event-handler self arg0 arg1 arg2 arg3)
)
(defbehavior enemy-simple-post enemy ()
(track-target! self)
(update-transforms (-> self root))
0
(none)
)
(defbehavior enemy-falling-post enemy ()
(logior! (-> self enemy-flags) (enemy-flag directed))
(let ((gp-0 (-> self root)))
(cond
((focus-test? self under-water)
(enemy-method-47 self (-> gp-0 transv))
)
(else
(let ((a1-1 (new-stack-vector0)))
(vector-v++! (-> gp-0 transv) (compute-acc-due-to-gravity gp-0 a1-1 (-> self enemy-info slip-factor)))
)
)
)
(let ((a2-1 (new 'stack-no-clear 'collide-query)))
(set! (-> a2-1 collide-with) (-> gp-0 root-prim prim-core collide-with))
(set! (-> a2-1 ignore-process0) self)
(set! (-> a2-1 ignore-process1) #f)
(set! (-> a2-1 ignore-pat) (logior (new 'static 'pat-surface :noendlessfall #x1) (-> gp-0 pat-ignore-mask)))
(set! (-> a2-1 action-mask) (collide-action solid))
(fill-cache-integrate-and-collide gp-0 (-> gp-0 transv) a2-1 (meters 0))
)
)
(enemy-method-111 self)
(track-target! self)
(none)
)
(defmethod enemy-method-47 ((this enemy) (arg0 vector))
(let* ((f2-0 0.8)
(f0-1 (fmax 0.0 (+ 1.0 (* 60.0 (seconds-per-frame) (+ -1.0 f2-0)))))
)
(vector-float*! arg0 arg0 f0-1)
)
(set! (-> arg0 y) (+ (-> arg0 y) (* -204800.0 (seconds-per-frame))))
)
(defbehavior enemy-die-falling-post enemy ()
(logior! (-> self enemy-flags) (enemy-flag directed))
(let ((gp-0 (-> self root)))
(if (focus-test? self under-water)
(enemy-method-47 self (-> gp-0 transv))
(vector-v++! (-> gp-0 transv) (compute-acc-due-to-gravity gp-0 (new-stack-vector0) 0.0))
)
(let ((s4-1 (new 'stack-no-clear 'collide-query))
(s5-1 (new 'stack-no-clear 'vector))
)
(set! (-> s5-1 quad) (-> gp-0 trans quad))
(vector-v++! s5-1 (-> gp-0 transv))
(when (find-ground gp-0 s4-1 (-> self enemy-info recover-gnd-collide-with) 8192.0 81920.0 1024.0)
(when (>= (-> gp-0 gspot-pos y) (-> s5-1 y))
(set! (-> s5-1 y) (-> gp-0 gspot-pos y))
(vector-reset! (-> gp-0 transv))
)
)
(move-to-point! gp-0 s5-1)
)
)
(track-target! self)
0
(none)
)
(defstate idle (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(stop-looking-at-target! self)
(logclear! (-> self enemy-flags) (enemy-flag spawn-gem chase-startup use-notice-distance))
(logior! (-> self enemy-flags) (enemy-flag enable-on-notice))
(set! (-> self state-timeout) (seconds 0.5))
(if (-> self on-notice)
(logior! (-> self enemy-flags) (enemy-flag auto-reset-penetrate))
)
(if (-> self on-active)
(logior! (-> self enemy-flags) (enemy-flag jump-check-blocked))
)
(if (-> self on-hostile)
(logior! (-> self enemy-flags) (enemy-flag drawn-mirrored))
)
(when (not (logtest? (enemy-flag dangerous-backup) (-> self enemy-flags)))
(if (logtest? (-> self enemy-flags) (enemy-flag notice))
(logior! (-> self mask) (process-mask actor-pause))
(logclear! (-> self mask) (process-mask actor-pause))
)
)
)
:trans (behavior ()
(if (and (time-elapsed? (-> self state-time) (-> self state-timeout)) (> (the-as int (-> self focus aware)) 0))
(go-virtual active)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.1))
(sleep-code)
)
:post (behavior ()
(idle-control-method-10 (-> self idle-anim-player) self)
(if (and (nonzero? (-> self draw)) (logtest? (-> self draw status) (draw-control-status on-screen)))
(set-time! (-> self last-draw-time))
)
(enemy-method-129 self)
(ja-post)
)
)
(defstate dormant (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
((-> (method-of-type enemy idle) enter))
(set! (-> self root nav-flags) (nav-flags))
(let ((v1-4 (-> self root root-prim)))
(set! (-> v1-4 prim-core collide-as) (collide-spec))
(set! (-> v1-4 prim-core collide-with) (collide-spec))
)
0
(logior! (-> self draw status) (draw-control-status no-draw))
(set! (-> self draw origin quad) (-> self root trans quad))
(if (logtest? (enemy-flag alert) (-> self enemy-flags))
(logior! (-> self enemy-flags) (enemy-flag victory))
)
(logior! (-> self focus-status) (focus-status disable))
)
:exit (behavior ()
(logclear! (-> self focus-status) (focus-status disable))
(let ((v1-3 (-> self root root-prim)))
(set! (-> v1-3 prim-core collide-as) (-> self root backup-collide-as))
(set! (-> v1-3 prim-core collide-with) (-> self root backup-collide-with))
)
(logclear! (-> self draw status) (draw-control-status no-draw))
(logclear! (-> self enemy-flags) (enemy-flag victory))
(logior! (-> self root nav-flags) (nav-flags has-root-sphere))
)
:code sleep-code
)
(defstate dormant-aware (enemy)
:virtual #t
:event enemy-event-handler
:enter (-> (method-of-type enemy dormant) enter)
:exit (-> (method-of-type enemy dormant) exit)
:trans (behavior ()
(when (and (time-elapsed? (-> self state-time) (-> self state-timeout)) (> (the-as int (-> self focus aware)) 0))
(if (logtest? (enemy-option ambush) (-> self fact enemy-options))
(go-ambush self)
(go-virtual active)
)
)
)
:code sleep-code
:post (behavior ()
(if (and (nonzero? (-> self draw)) (logtest? (-> self draw status) (draw-control-status on-screen)))
(set-time! (-> self last-draw-time))
)
(enemy-method-129 self)
)
)
(defstate ambush (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(logior! (-> self enemy-flags) (enemy-flag chase-startup))
)
:code (behavior ()
(go-virtual notice)
)
)
(defstate active (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(logclear! (-> self enemy-flags) (enemy-flag use-notice-distance))
(when (logtest? (-> self enemy-flags) (enemy-flag jump-check-blocked))
(logclear! (-> self enemy-flags) (enemy-flag jump-check-blocked))
(let ((gp-0 (-> self on-active)))
(if gp-0
(script-eval gp-0 :vector (-> self root trans))
)
)
)
(when (not (logtest? (enemy-flag dangerous-backup) (-> self enemy-flags)))
(if (logtest? (-> self enemy-flags) (enemy-flag notice))
(logior! (-> self mask) (process-mask actor-pause))
(logclear! (-> self mask) (process-mask actor-pause))
)
)
)
:trans (behavior ()
(when (time-elapsed? (-> self state-time) (seconds 0.1))
(let ((v1-3 (-> self focus aware)))
(cond
((< (the-as int v1-3) 1)
(go-virtual idle)
)
((< 1 (the-as int v1-3))
(go-virtual notice)
)
)
)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.1))
(sleep-code)
)
:post (behavior ()
(idle-control-method-10 (-> self idle-anim-player) self)
(enemy-simple-post)
)
)
(defstate notice (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(let ((v1-3 (logior (-> self enemy-flags) (enemy-flag use-notice-distance))))
(set! (-> self enemy-flags) (logclear v1-3 (enemy-flag called-dying)))
)
(logclear! (-> self mask) (process-mask actor-pause))
(look-at-target! self (enemy-flag lock-focus))
(when (logtest? (-> self enemy-flags) (enemy-flag auto-reset-penetrate))
(logclear! (-> self enemy-flags) (enemy-flag auto-reset-penetrate))
(let ((gp-0 (-> self on-notice)))
(if gp-0
(script-eval gp-0 :vector (-> self root trans))
)
)
)
(let ((gp-1 (-> self focus aware)))
(when (logtest? (-> self enemy-flags) (enemy-flag chase-startup))
(cond
((and (= gp-1 (enemy-aware enemy-aware-3)) (get-enemy-target self))
(go-hostile self)
)
((= gp-1 (enemy-aware unaware))
(go-flee self)
)
(else
(go-stare self)
)
)
)
)
(logior! (-> self enemy-flags) (enemy-flag chase-startup))
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.075))
(let ((f30-0 (get-rand-float-range self 0.8 1.2))
(gp-0 (new 'stack-no-clear 'vector))
)
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info notice-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(vector-! gp-0 (target-pos 0) (-> self root trans))
(seek-toward-heading-vec! (-> self root) gp-0 131072.0 (seconds 0.05))
(suspend)
(ja :num! (seek! max f30-0))
)
)
(react-to-focus self)
)
:post enemy-simple-post
)
(defstate hostile (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(look-at-target! self (enemy-flag lock-focus))
(logior! (-> self enemy-flags) (enemy-flag use-notice-distance))
(logclear! (-> self enemy-flags) (enemy-flag dangerous-backup))
(logclear! (-> self mask) (process-mask actor-pause))
(when (logtest? (-> self enemy-flags) (enemy-flag drawn-mirrored))
(logclear! (-> self enemy-flags) (enemy-flag drawn-mirrored))
(let ((gp-0 (-> self on-hostile)))
(if gp-0
(script-eval gp-0 :vector (-> self root trans))
)
)
)
)
:trans (behavior ()
(if (and (logtest? (-> self enemy-flags) (enemy-flag look-at-focus)) (-> self enemy-info use-victory))
(go-virtual victory)
)
(let ((gp-0 (-> self focus aware)))
(when (time-elapsed? (-> self state-time) (-> self reaction-time))
(cond
((or (>= 2 (the-as int gp-0)) (not (get-enemy-target self)))
(go-stare self)
)
((= gp-0 (enemy-aware unaware))
(go-flee self)
)
)
)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja :group! (-> self draw art-group data (-> self enemy-info hostile-anim)))
(ja :num-func num-func-identity :frame-num 0.0)
(let ((f30-0 (get-rand-float-range self 0.9 1.1)))
(until #f
(suspend)
(ja :num! (loop! f30-0))
)
)
#f
)
:post enemy-simple-post
)
(defstate stare (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(logclear! (-> self mask) (process-mask actor-pause))
(logclear! (-> self enemy-flags) (enemy-flag dangerous-backup))
)
:trans (behavior ()
(when (time-elapsed? (-> self state-time) (seconds 0.1))
(let ((gp-0 (-> self focus aware)))
(cond
((>= 1 (the-as int gp-0))
(go-virtual active)
)
((and (= gp-0 (enemy-aware enemy-aware-3)) (get-enemy-target self))
(go-hostile self)
)
((= gp-0 (enemy-aware unaware))
(go-flee self)
)
)
)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.1))
(let ((f30-0 (get-rand-float-range self 0.9 1.1))
(gp-0 (-> self draw art-group data (-> self enemy-info idle-anim)))
)
(until #f
(ja-no-eval :group! gp-0 :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
#f
)
:post enemy-simple-post
)
(defstate victory (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(logclear! (-> self enemy-flags) (enemy-flag look-at-focus))
(logclear! (-> self mask) (process-mask actor-pause))
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.075))
(let ((f30-0 (get-rand-float-range self 0.8 1.2)))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info victory-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
(react-to-focus self)
)
:post enemy-simple-post
)
(defstate flee (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(look-at-target! self (enemy-flag lock-focus))
(logclear! (-> self enemy-flags) (enemy-flag dangerous-backup))
(logclear! (-> self mask) (process-mask actor-pause))
)
:trans (behavior ()
(when (time-elapsed? (-> self state-time) (-> self reaction-time))
(if (!= (-> self focus aware) (enemy-aware unaware))
(go-stare self)
)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja :group! (-> self draw art-group data (-> self enemy-info hostile-anim)))
(ja :num-func num-func-identity :frame-num 0.0)
(let ((f30-0 (get-rand-float-range self 0.9 1.1)))
(until #f
(suspend)
(ja :num! (loop! f30-0))
)
)
#f
)
:post enemy-simple-post
)
(defmethod enemy-method-82 ((this enemy) (arg0 enemy-jump-info))
"@abstract"
#f
)
(defmethod enemy-method-83 ((this enemy) (arg0 enemy-jump-info))
(set! (-> arg0 flags) (the-as uint 1))
(set! (-> arg0 anim-speed) (get-rand-float-range this 0.9 1.1))
(set! (-> arg0 hang-time) 0)
(set! (-> arg0 dest-pos quad) (-> this event-param-point quad))
(set! (-> arg0 start-pos quad) (-> this root trans quad))
(let ((s4-0 (new 'stack-no-clear 'collide-query)))
(if (enemy-above-ground?
this
s4-0
(-> arg0 dest-pos)
(the-as collide-spec (-> this gnd-collide))
8192.0
81920.0
1024.0
)
(set! (-> arg0 dest-pos y) (-> s4-0 best-other-tri intersect y))
)
)
(enemy-method-84 this arg0)
(none)
)
(defmethod enemy-method-84 ((this enemy) (arg0 enemy-jump-info))
(let* ((f0-0 (vector-vector-xz-distance (-> arg0 start-pos) (-> arg0 dest-pos)))
(f0-2 (fmax (-> this enemy-info jump-height-min) (* (-> this enemy-info jump-height-factor) f0-0)))
)
(setup-from-to-height! (-> arg0 traj) (-> arg0 start-pos) (-> arg0 dest-pos) f0-2 -4.551111)
)
(none)
)
(defmethod enemy-method-86 ((this enemy))
(let ((gp-0 (-> this root)))
(when (< (-> gp-0 transv y) 0.0)
(let ((a1-0 (new 'stack-no-clear 'collide-query)))
(find-ground (-> this root) a1-0 (the-as collide-spec (-> this gnd-collide)) 8192.0 81920.0 1024.0)
)
(>= (-> gp-0 gspot-pos y) (-> gp-0 trans y))
)
)
)
(defmethod enemy-method-85 ((this enemy))
(let* ((v1-0 (-> this root))
(f0-0 (-> v1-0 gspot-pos y))
)
(if (< (-> v1-0 trans y) f0-0)
(set! (-> v1-0 trans y) f0-0)
)
)
(set! (-> this root transv y) 0.0)
)
(defmethod enemy-method-92 ((this enemy) (arg0 int) (arg1 nav-poly))
"TODO - nav-poly is a guess
@abstract"
0
(none)
)
(defmethod enemy-method-91 ((this enemy) (arg0 int) (arg1 enemy-jump-info))
(case arg0
((2 3)
(logior! (-> this enemy-flags) (enemy-flag directed))
(let ((f30-0 (the float (-> arg1 hang-time))))
(let ((a1-3 (compute-trans-at-time (-> arg1 traj) f30-0 (new 'stack-no-clear 'vector))))
(move-to-point! (-> this root) a1-3)
)
(let ((s5-1 (-> this root transv)))
(compute-transv-at-time (-> arg1 traj) f30-0 s5-1)
(vector-float*! s5-1 s5-1 300.0)
)
)
)
)
0
(none)
)
(defmethod enemy-method-89 ((this enemy) (arg0 enemy-jump-info))
(let ((a0-1 (-> this skel root-channel 0)))
(set! (-> a0-1 param 0) 1.0)
(joint-control-channel-group! a0-1 (the-as art-joint-anim #f) num-func-loop!)
)
(ja-channel-push! 1 (seconds 0.1))
(let ((a1-3 (-> this draw art-group data (-> this enemy-info jump-wind-up-anim)))
(a0-5 (-> this skel root-channel 0))
)
(set! (-> a0-5 frame-group) (the-as art-joint-anim a1-3))
(set! (-> a0-5 param 0) (the float (+ (-> (the-as art-joint-anim a1-3) frames num-frames) -1)))
(set! (-> a0-5 param 1) (-> arg0 anim-speed))
(set! (-> a0-5 frame-num) 0.0)
(joint-control-channel-group! a0-5 (the-as art-joint-anim a1-3) num-func-seek!)
)
#t
)
(defmethod enemy-method-87 ((this enemy) (arg0 enemy-jump-info))
(let ((s5-0 (-> this draw art-group data (-> this enemy-info jump-in-air-anim))))
(let ((v1-6 (if (> (-> this skel active-channels) 0)
(-> this skel root-channel 0 frame-group)
)
)
)
(cond
((and v1-6 (= v1-6 (-> this draw art-group data (-> this enemy-info jump-wind-up-anim))))
(ja-channel-push! 1 0)
)
(else
(let ((a0-10 (-> this skel root-channel 0)))
(set! (-> a0-10 param 0) 1.0)
(joint-control-channel-group! a0-10 (the-as art-joint-anim #f) num-func-loop!)
)
(ja-channel-push! 1 (seconds 0.1))
)
)
)
(let ((a0-12 (-> this skel root-channel 0)))
(set! (-> a0-12 frame-group) (the-as art-joint-anim s5-0))
(set! (-> a0-12 param 0) (the float (+ (-> (the-as art-joint-anim s5-0) frames num-frames) -1)))
(set! (-> a0-12 param 1) (-> arg0 anim-speed))
(set! (-> a0-12 frame-num) 0.0)
(joint-control-channel-group! a0-12 (the-as art-joint-anim s5-0) num-func-seek!)
)
)
#t
)
(defmethod enemy-method-88 ((this enemy) (arg0 enemy-jump-info))
(let ((a0-1 (-> this skel root-channel 0)))
(set! (-> a0-1 param 0) 1.0)
(joint-control-channel-group! a0-1 (the-as art-joint-anim #f) num-func-loop!)
)
(ja-channel-push! 1 (seconds 0.075))
(let ((a1-3 (-> this draw art-group data (-> this enemy-info jump-land-anim)))
(a0-5 (-> this skel root-channel 0))
)
(set! (-> a0-5 frame-group) (the-as art-joint-anim a1-3))
(set! (-> a0-5 param 0) (the float (+ (-> (the-as art-joint-anim a1-3) frames num-frames) -1)))
(set! (-> a0-5 param 1) (-> arg0 anim-speed))
(set! (-> a0-5 frame-num) 0.0)
(joint-control-channel-group! a0-5 (the-as art-joint-anim a1-3) num-func-seek!)
)
#t
)
(defmethod enemy-method-90 ((this enemy) (arg0 int) (arg1 enemy-jump-info))
(local-vars (s5-0 symbol))
(let ((v1-0 arg0))
(cond
((zero? v1-0)
(not (enemy-method-89 this arg1))
)
((= v1-0 1)
(set! s5-0 (ja-done? 0))
(let ((a0-4 (-> this skel root-channel 0)))
(set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group frames num-frames) -1)))
(set! (-> a0-4 param 1) (-> arg1 anim-speed))
(joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!)
)
(ja-blend-eval)
s5-0
)
((= v1-0 2)
(enemy-method-87 this arg1)
#f
)
((= v1-0 3)
(set! s5-0 (ja-done? 0))
(let ((a0-9 (-> this skel root-channel 0)))
(set! (-> a0-9 param 0) (the float (+ (-> a0-9 frame-group frames num-frames) -1)))
(set! (-> a0-9 param 1) (-> arg1 anim-speed))
(joint-control-channel-group-eval! a0-9 (the-as art-joint-anim #f) num-func-seek!)
)
(ja-blend-eval)
s5-0
)
((= v1-0 4)
(not (enemy-method-88 this arg1))
)
((= v1-0 5)
(set! s5-0 (ja-done? 0))
(let ((a0-14 (-> this skel root-channel 0)))
(set! (-> a0-14 param 0) (the float (+ (-> a0-14 frame-group frames num-frames) -1)))
(set! (-> a0-14 param 1) (-> arg1 anim-speed))
(joint-control-channel-group-eval! a0-14 (the-as art-joint-anim #f) num-func-seek!)
)
(ja-blend-eval)
s5-0
)
(else
#t
)
)
)
)
(defstate jump (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(logclear! (-> self mask) (process-mask actor-pause))
(logior! (-> self focus-status) (focus-status dangerous))
(let* ((v1-6 *game-info*)
(a0-2 (+ (-> v1-6 attack-id) 1))
)
(set! (-> v1-6 attack-id) a0-2)
(set! (-> self attack-id) a0-2)
)
(logclear! (-> self focus-status) (focus-status in-air))
)
:exit (behavior ()
(if (logtest? (-> self enemy-flags) (enemy-flag check-water))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
)
:code (behavior ()
(let ((gp-0 (new 'stack-no-clear 'enemy-jump-info)))
(let ((s5-0 0))
(enemy-method-83 self gp-0)
(if (and (-> self enemy-info use-jump-blocked)
(logtest? (enemy-flag vulnerable) (-> self enemy-flags))
(enemy-method-82 self gp-0)
)
(go-virtual jump-blocked)
)
(when (logtest? (-> gp-0 flags) 1)
(until #f
(if (enemy-method-90 self s5-0 gp-0)
(goto cfg-12)
)
(enemy-method-91 self s5-0 gp-0)
(enemy-method-92 self s5-0 (the-as nav-poly gp-0))
(suspend)
(set! s5-0 1)
)
#f
)
)
(label cfg-12)
(logclear! (-> self root status) (collide-status on-surface on-ground touch-surface))
(let ((s5-1 2))
(logior! (-> self focus-status) (focus-status in-air))
(until (enemy-method-86 self)
(+! (-> gp-0 hang-time) (- (current-time) (-> self clock old-frame-counter)))
(enemy-method-90 self s5-1 gp-0)
(enemy-method-91 self s5-1 gp-0)
(enemy-method-92 self s5-1 (the-as nav-poly gp-0))
(suspend)
(set! s5-1 3)
)
)
(logclear! (-> self focus-status) (focus-status in-air))
(enemy-method-85 self)
(let ((s5-2 4))
(until #f
(if (enemy-method-90 self s5-2 gp-0)
(goto cfg-19)
)
(enemy-method-91 self s5-2 gp-0)
(enemy-method-92 self s5-2 (the-as nav-poly gp-0))
(suspend)
(set! s5-2 5)
)
)
#f
(label cfg-19)
(if (logtest? (enemy-flag alert) (-> self enemy-flags))
((lambda :behavior enemy
((arg0 enemy-jump-info))
(send-event (ppointer->process (-> self parent)) 'child-jumped)
(none)
)
gp-0
)
)
)
(enemy-method-93 self)
)
:post (behavior ()
(let ((a1-0 (new 'stack-no-clear 'overlaps-others-params)))
(set! (-> a1-0 options) (overlaps-others-options))
(set! (-> a1-0 collide-with-filter) (-> self enemy-info overlaps-others-collide-with-filter))
(set! (-> a1-0 tlist) *touching-list*)
(find-overlapping-shapes (-> self root) a1-0)
)
(enemy-simple-post)
)
)
(defstate jump-blocked (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(logclear! (-> self mask) (process-mask actor-pause))
)
:trans (behavior ()
(when (time-elapsed? (-> self state-time) (seconds 0.5))
(if (logtest? (enemy-flag alert) (-> self enemy-flags))
(go-virtual jump)
(enemy-method-93 self)
)
)
)
:code (behavior ()
(let ((v1-2 (ja-group)))
(when (not (and v1-2 (= v1-2 (-> self draw art-group data (-> self enemy-info idle-anim)))))
(ja-channel-push! 1 (seconds 0.2))
(ja :group! (-> self draw art-group data (-> self enemy-info idle-anim))
:num! (identity (rand-vu-float-range 0.0 (the float (+ (-> (ja-group) frames num-frames) -1))))
)
)
)
(let ((f30-0 (get-rand-float-range self 0.75 1.25)))
(until #f
(suspend)
(ja :num! (loop! f30-0))
)
)
#f
)
:post enemy-simple-post
)
(defstate hit (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(stop-looking-at-target! self)
(logclear! (-> self mask) (process-mask actor-pause))
(enemy-method-135 self 0)
)
:code (behavior ()
(local-vars (v1-37 enemy-flag) (v1-45 enemy-flag))
(ja-channel-push! 1 (seconds 0.2))
(let ((f30-0 (get-rand-float-range self 0.9 1.1)))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info hit-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
(if (logtest? (-> self enemy-flags) (enemy-flag check-water))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
(let ((v1-36 (-> self enemy-flags)))
(if (logtest? v1-36 (enemy-flag checking-water))
(set! v1-37 (logior v1-36 (enemy-flag enable-on-active)))
(set! v1-37 (logclear v1-36 (enemy-flag enable-on-active)))
)
)
(set! (-> self enemy-flags) v1-37)
(if (logtest? (-> self enemy-flags) (enemy-flag look-at-move-dest))
(logior! (-> self mask) (process-mask collectable))
(logclear! (-> self mask) (process-mask collectable))
)
(let ((v1-44 (-> self enemy-flags)))
(if (logtest? (enemy-flag no-initial-move-to-ground) v1-44)
(set! v1-45 (logior (enemy-flag check-water-backup) v1-44))
(set! v1-45 (logclear v1-44 (enemy-flag check-water-backup)))
)
)
(set! (-> self enemy-flags) v1-45)
(logclear! (-> self enemy-flags) (enemy-flag actor-pause-backup))
(logclear! (-> self focus-status) (focus-status hit))
(go-hostile self)
)
:post enemy-simple-post
)
;; WARN: Return type mismatch collide-spec vs none.
(defmethod enemy-method-101 ((this enemy))
(when (not (logtest? (enemy-flag use-trigger) (-> this enemy-flags)))
(logior! (-> this enemy-flags) (enemy-flag use-trigger))
(logclear! (-> this enemy-flags) (enemy-flag directed))
(enemy-method-124 this)
)
(none)
)
(defmethod enemy-method-103 ((this enemy))
(when (logtest? (enemy-flag use-trigger) (-> this enemy-flags))
(logclear! (-> this enemy-flags) (enemy-flag use-trigger directed))
(enemy-method-124 this)
)
)
(defmethod enemy-method-102 ((this enemy))
#f
)
;; WARN: Return type mismatch vector vs symbol.
(defmethod enemy-method-100 ((this enemy))
(local-vars (v0-1 vector))
(when (not (-> this enemy-info move-to-ground))
(enemy-method-103 this)
(return (the-as symbol #f))
)
(when (not (logtest? (enemy-flag directed) (-> this enemy-flags)))
(let ((s5-0 (-> this root)))
(if (focus-test? this under-water)
(enemy-method-47 this (-> s5-0 transv))
(+! (-> s5-0 transv y) (* (-> this enemy-info movement-gravity) (seconds-per-frame)))
)
(let ((a2-0 (new 'stack-no-clear 'move-above-ground-params)))
(let ((v1-16 (-> this enemy-info)))
(set! (-> a2-0 gnd-collide-with) (-> v1-16 recover-gnd-collide-with))
(set! (-> a2-0 popup) 8192.0)
(set! (-> a2-0 dont-move-if-overlaps?) #t)
(set! (-> a2-0 hover-if-no-ground?) (-> v1-16 hover-if-no-ground))
(set! (-> a2-0 overlaps-params options) (overlaps-others-options oo0 oo2))
(set! (-> a2-0 overlaps-params collide-with-filter) (-> v1-16 overlaps-others-collide-with-filter))
)
(set! (-> a2-0 overlaps-params tlist) *touching-list*)
(-> a2-0 overlaps-params)
(enemy-method-128 this (-> s5-0 transv) a2-0)
)
)
)
(logclear! (-> this enemy-flags) (enemy-flag directed))
(if (and (enemy-method-102 this) (not (logtest? (-> this focus-status) (focus-status dead))))
(kill-prefer-falling this)
)
(let ((s5-1 (-> this root))
(a1-2 (new 'stack-no-clear 'collide-query))
(s3-0 (new 'stack-no-clear 'vector))
(s4-0 (new 'stack-no-clear 'vector))
)
(set! (-> s3-0 quad) (-> s5-1 gspot-pos quad))
(set! (-> s4-0 quad) (-> s5-1 gspot-normal quad))
(the-as symbol (cond
((find-ground s5-1 a1-2 (-> this enemy-info gnd-collide-with) 8192.0 81920.0 1024.0)
(let ((f0-4 (- (-> s5-1 trans y) (-> s5-1 gspot-pos y))))
(when (>= 409.6 (fabs f0-4))
(enemy-method-103 this)
(return (the-as symbol #f))
v0-1
)
)
)
(else
(set! (-> s5-1 gspot-pos quad) (-> s3-0 quad))
(set! v0-1 (-> s5-1 gspot-normal))
(set! (-> v0-1 quad) (-> s4-0 quad))
v0-1
)
)
)
)
)
(defmethod enemy-method-46 ((this enemy) (arg0 int))
"@abstract"
0
(none)
)
;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-52 ((this enemy) (arg0 vector))
(enemy-method-50 this arg0)
(let ((s5-0 (-> this enemy-info)))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-2))
(let ((f30-0 (get-rand-float-range this 0.0 1.0)))
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-hard-vxz-lo) (-> s5-0 knocked-hard-vxz-hi) f30-0))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-hard-vy-lo) (-> s5-0 knocked-hard-vy-hi) f30-0))
)
)
(((knocked-type knocked-type-1))
(let ((f30-1 (get-rand-float-range this 0.0 1.0)))
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-medium-vxz-lo) (-> s5-0 knocked-medium-vxz-hi) f30-1))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-medium-vy-lo) (-> s5-0 knocked-medium-vy-hi) f30-1))
)
)
(((knocked-type knocked-type-3))
(let ((f30-2 (get-rand-float-range this 0.0 1.0)))
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-huge-vxz-lo) (-> s5-0 knocked-huge-vxz-hi) f30-2))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-huge-vy-lo) (-> s5-0 knocked-huge-vy-hi) f30-2))
)
)
(((knocked-type knocked-type-4))
(vector-rotate90-around-y! arg0 arg0)
(let ((v1-9 (new 'stack-no-clear 'vector)))
(vector-! v1-9 (-> this incoming attacker-pos) (-> this root trans))
(set! (-> v1-9 y) 0.0)
(if (< 0.0 (vector-dot v1-9 arg0))
(vector-negate! arg0 arg0)
)
)
(let ((f30-3 (get-rand-float-range this 0.0 1.0)))
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-yellow-vxz-lo) (-> s5-0 knocked-yellow-vxz-hi) f30-3))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-yellow-vy-lo) (-> s5-0 knocked-yellow-vy-hi) f30-3))
)
)
(((knocked-type knocked-type-5))
(let* ((f1-2 (vector-vector-xz-distance-squared (target-pos 0) (-> this root trans)))
(f0-26 1.0)
(f2-0 61440.0)
(f1-3 (fmin f1-2 (* f2-0 f2-0)))
(f2-3 61440.0)
(f30-5 (* (- f0-26 (/ f1-3 (* f2-3 f2-3))) (get-rand-float-range this 0.8 1.0)))
)
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-red-vxz-lo) (-> s5-0 knocked-red-vxz-hi) f30-5))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-red-vy-lo) (-> s5-0 knocked-red-vy-hi) f30-5))
)
)
(((knocked-type knocked-type-6))
(let* ((f1-5 (vector-vector-xz-distance-squared (target-pos 0) (-> this root trans)))
(f0-34 1.0)
(f2-6 122880.0)
(f1-6 (fmin f1-5 (* f2-6 f2-6)))
(f2-9 122880.0)
(f30-7 (* (- f0-34 (/ f1-6 (* f2-9 f2-9))) (get-rand-float-range this 0.8 1.0)))
)
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-blue-vxz-lo) (-> s5-0 knocked-blue-vxz-hi) f30-7))
(cond
((>= (the-as uint 4) (-> this incoming blue-juggle-count))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-blue-vy-lo) (-> s5-0 knocked-blue-vy-hi) f30-7))
)
(else
(if (zero? (get-rand-int this 3))
(set! (-> arg0 y) 40960.0)
)
)
)
)
)
(((knocked-type knocked-type-7))
(set! (-> arg0 quad) (-> this incoming attack-direction quad))
)
(else
(let ((f30-8 (get-rand-float-range this 0.0 1.0)))
(vector-float*! arg0 arg0 (lerp (-> s5-0 knocked-soft-vxz-lo) (-> s5-0 knocked-soft-vxz-hi) f30-8))
(set! (-> arg0 y) (lerp (-> s5-0 knocked-soft-vy-lo) (-> s5-0 knocked-soft-vy-hi) f30-8))
)
)
)
)
(none)
)
(defmethod enemy-method-51 ((this enemy))
(let ((f30-0 (quaternion-y-angle (-> this root quat))))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-4) (knocked-type knocked-type-6))
(let ((a0-5 (handle->process (-> this focus handle))))
(when a0-5
(let ((v1-9 (get-trans (the-as process-focusable a0-5) 0)))
(set! f30-0 (atan (- (-> v1-9 x) (-> this root trans x)) (- (-> v1-9 z) (-> this root trans z))))
)
)
)
)
(else
(let* ((v1-13 (-> this root transv))
(f28-0 (atan (-> v1-13 x) (-> v1-13 z)))
(f1-2 (deg- f30-0 f28-0))
(f2-0 (fabs f1-2))
(f0-6 (-> this enemy-info knocked-seek-ry-clamp))
)
(when (and (< f0-6 f2-0) (< f2-0 (- 32768.0 f0-6)))
(set! f30-0 (+ (cond
((< f2-0 16384.0)
(if (>= f1-2 0.0)
f0-6
(- f0-6)
)
)
((>= f1-2 0.0)
(- 32768.0 f0-6)
)
(else
(+ -32768.0 f0-6)
)
)
f28-0
)
)
(if (< f30-0 0.0)
(set! f30-0 (+ 65536.0 f30-0))
)
)
)
)
)
f30-0
)
)
(defmethod enemy-method-77 ((this enemy) (arg0 (pointer float)))
(ja-channel-push! 1 0)
(let ((a1-2 (-> this draw art-group data (-> this enemy-info knocked-anim)))
(a0-4 (-> this skel root-channel 0))
)
(set! (-> a0-4 frame-group) (the-as art-joint-anim a1-2))
(set! (-> a0-4 param 0) (the float (+ (-> (the-as art-joint-anim a1-2) frames num-frames) -1)))
(set! (-> a0-4 param 1) (-> arg0 0))
(set! (-> a0-4 frame-num) 0.0)
(joint-control-channel-group! a0-4 (the-as art-joint-anim a1-2) num-func-seek!)
)
#t
)
(defmethod enemy-method-78 ((this enemy) (arg0 (pointer float)))
(let ((v1-4 (-> this draw art-group data (-> this enemy-info knocked-land-anim)))
(a0-3 (-> this skel root-channel 0))
)
(set! (-> a0-3 frame-group) (the-as art-joint-anim v1-4))
(set! (-> a0-3 param 0) (the float (+ (-> (the-as art-joint-anim v1-4) frames num-frames) -1)))
(set! (-> a0-3 param 1) (-> arg0 0))
(set! (-> a0-3 frame-num) 0.0)
(joint-control-channel-group! a0-3 (the-as art-joint-anim v1-4) num-func-seek!)
)
#t
)
(defmethod enemy-method-80 ((this enemy) (arg0 enemy-knocked-info))
(let ((gp-0 (-> this root)))
(or (>= (-> arg0 on-surface-count) 3)
(and (logtest? (-> gp-0 status) (collide-status on-ground)) (>= 16384.0 (-> gp-0 transv y)))
(and (>= (-> arg0 move-count) 3)
(let ((f0-1 40.96))
(>= (* f0-1 f0-1) (vector-vector-distance-squared (-> gp-0 trans-old) (-> gp-0 trans-old-old)))
)
(let ((f0-4 40.96))
(>= (* f0-4 f0-4) (vector-vector-distance-squared (-> gp-0 trans-old-old) (-> gp-0 trans-old-old-old)))
)
)
)
)
)
(defmethod enemy-method-81 ((this enemy))
(let ((s5-0 (-> this root))
(a1-0 (new 'stack-no-clear 'collide-query))
(gp-0 #t)
)
(when (find-ground s5-0 a1-0 (-> this enemy-info recover-gnd-collide-with) 8192.0 81920.0 1024.0)
(let ((f0-1 (- (-> s5-0 trans y) (-> s5-0 gspot-pos y))))
(if (and (>= f0-1 -1228.8) (>= 6144.0 f0-1))
(set! gp-0 #f)
)
)
)
gp-0
)
)
(defmethod enemy-method-79 ((this enemy) (arg0 int) (arg1 enemy-knocked-info))
(local-vars (s5-0 symbol))
(let ((v1-0 arg0))
(cond
((zero? v1-0)
(enemy-method-77 this (the-as (pointer float) arg1))
(set! s5-0 #f)
)
((= v1-0 1)
(set! s5-0 (ja-done? 0))
(let ((a0-4 (-> this skel root-channel 0)))
(set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group frames num-frames) -1)))
(set! (-> a0-4 param 1) (-> arg1 anim-speed))
(joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!)
)
)
((= v1-0 2)
(set! s5-0 (not (enemy-method-78 this (the-as (pointer float) arg1))))
(set! (-> this incoming blue-juggle-count) (the-as uint 0))
)
((= v1-0 3)
(set! s5-0 (ja-done? 0))
(let ((a0-9 (-> this skel root-channel 0)))
(set! (-> a0-9 param 0) (the float (+ (-> a0-9 frame-group frames num-frames) -1)))
(set! (-> a0-9 param 1) (-> arg1 anim-speed))
(joint-control-channel-group-eval! a0-9 (the-as art-joint-anim #f) num-func-seek!)
)
)
((= v1-0 4)
(vector-reset! (-> this root transv))
(set! s5-0 #t)
)
(else
(set! s5-0 #t)
)
)
)
s5-0
)
(defstate knocked (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(stop-looking-at-target! self)
(logior! (-> self enemy-flags) (enemy-flag actor-pause-backup))
(logclear! (-> self mask) (process-mask actor-pause))
(let* ((v1-8 *game-info*)
(a0-4 (+ (-> v1-8 attack-id) 1))
)
(set! (-> v1-8 attack-id) a0-4)
(set! (-> self attack-id) a0-4)
)
(enemy-method-103 self)
(if (logtest? (enemy-option knocked-into-water) (-> self fact enemy-options))
(logior! (-> self enemy-flags) (enemy-flag trackable-backup))
)
(let ((v1-16 (-> self root)))
(logclear! (-> v1-16 status) (collide-status
on-surface
on-ground
touch-surface
touch-wall
touch-ceiling
touch-actor
on-special-surface
touch-edge
blocked
on-water
impact-surface
touch-background
stuck
glance
)
)
(when (not (logtest? (-> v1-16 root-prim prim-core action) (collide-action no-normal-reset)))
(let ((a0-16 (-> v1-16 dynam gravity-normal)))
(set! (-> v1-16 local-normal quad) (-> a0-16 quad))
(set! (-> v1-16 surface-normal quad) (-> a0-16 quad))
(set! (-> v1-16 poly-normal quad) (-> a0-16 quad))
)
(set! (-> v1-16 coverage) 0.0)
(set! (-> v1-16 touch-angle) 0.0)
)
(enemy-method-52 self (-> v1-16 transv))
)
(if (>= (-> self enemy-info knocked-seek-ry-clamp) 0.0)
(set! (-> self desired-angle) (enemy-method-51 self))
)
(if (zero? (-> self hit-points))
(dispose! self)
(enemy-method-135 self 0)
)
(logclear! (-> self focus-status) (focus-status dangerous))
(if (= (-> self incoming knocked-type) (knocked-type knocked-type-4))
(logclear! (-> self enemy-flags) (enemy-flag check-water-backup))
)
(set! (-> self root penetrate-using) (penetrate lunge vehicle knocked))
(enemy-method-49 self)
(enemy-method-46 self 1)
)
:exit (behavior ()
(local-vars (v1-1 enemy-flag) (v1-15 enemy-flag) (v1-23 enemy-flag))
(let ((v1-0 (-> self enemy-flags)))
(if (logtest? (enemy-flag enable-on-hostile) v1-0)
(set! v1-1 (logior (enemy-flag trackable-backup) v1-0))
(set! v1-1 (logclear v1-0 (enemy-flag trackable-backup)))
)
)
(set! (-> self enemy-flags) v1-1)
(when (nonzero? (-> self hit-points))
(set! (-> self root penetrate-using)
(the-as penetrate (logclear (-> self root penetrate-using) (penetrate knocked)))
)
(enemy-method-46 self 2)
(if (logtest? (-> self enemy-flags) (enemy-flag check-water))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
(let ((v1-14 (-> self enemy-flags)))
(if (logtest? v1-14 (enemy-flag checking-water))
(set! v1-15 (logior v1-14 (enemy-flag enable-on-active)))
(set! v1-15 (logclear v1-14 (enemy-flag enable-on-active)))
)
)
(set! (-> self enemy-flags) v1-15)
(if (logtest? (-> self enemy-flags) (enemy-flag look-at-move-dest))
(logior! (-> self mask) (process-mask collectable))
(logclear! (-> self mask) (process-mask collectable))
)
(let ((v1-22 (-> self enemy-flags)))
(if (logtest? (enemy-flag no-initial-move-to-ground) v1-22)
(set! v1-23 (logior (enemy-flag check-water-backup) v1-22))
(set! v1-23 (logclear v1-22 (enemy-flag check-water-backup)))
)
)
(set! (-> self enemy-flags) v1-23)
(logclear! (-> self enemy-flags) (enemy-flag actor-pause-backup))
(logclear! (-> self focus-status) (focus-status hit))
)
)
:trans (behavior ()
(if (>= (-> self enemy-info knocked-seek-ry-clamp) 0.0)
(seek-toward-yaw-angle! (-> self root) (-> self desired-angle) 138353.78 (seconds 0.1))
)
)
:code (behavior ()
(let ((gp-0 (new 'stack-no-clear 'enemy-knocked-info)))
(let ((s5-0 0))
(set! (-> gp-0 anim-speed) (get-rand-float-range self 0.9 1.1))
(set! (-> gp-0 on-surface-count) 0)
(set! (-> gp-0 move-count) 0)
(until (enemy-method-80 self gp-0)
(if (time-elapsed? (-> self state-time) (seconds 2))
(kill-prefer-falling self)
)
(if (logtest? (-> self root status) (collide-status on-surface))
(+! (-> gp-0 on-surface-count) 1)
)
(enemy-method-79 self s5-0 gp-0)
(suspend)
(+! (-> gp-0 move-count) 1)
(set! s5-0 1)
)
)
(let ((s5-1 2))
(set-time! (-> gp-0 land-can-land-time))
(until #f
(if (logtest? (-> self root status) (collide-status on-surface))
(+! (-> gp-0 on-surface-count) 1)
)
(if (enemy-method-79 self s5-1 gp-0)
(goto cfg-15)
)
(suspend)
(+! (-> gp-0 move-count) 1)
(set! s5-1 3)
(if (enemy-method-80 self gp-0)
(set-time! (-> gp-0 land-can-land-time))
)
)
)
#f
(label cfg-15)
(if (and (not (logtest? (enemy-flag recover) (-> self enemy-flags)))
(or (time-elapsed? (-> gp-0 land-can-land-time) (seconds 0.1)) (enemy-method-81 self) (enemy-method-102 self))
)
(kill-prefer-falling self)
)
(while (not (enemy-method-79 self 4 gp-0))
(suspend)
)
)
(enemy-method-101 self)
(cond
((or (zero? (-> self hit-points)) (nonzero? (-> self fated-time)))
(cond
((logtest? (enemy-flag recover) (-> self enemy-flags))
(set! (-> self hit-points) 0)
(let ((v1-67 (-> self root root-prim)))
(set! (-> v1-67 prim-core collide-as) (collide-spec))
(set! (-> v1-67 prim-core collide-with) (collide-spec))
)
0
(enemy-method-103 self)
(send-event self 'death-end)
(while (-> self child)
(suspend)
)
(cleanup-for-death self)
)
(else
(kill-prefer-falling self)
)
)
)
(else
(go-hostile self)
)
)
)
:post enemy-falling-post
)
(defmethod dispose! ((this enemy))
"Cleans-up the enemy and any associated resources. Potentially spawns skull gems"
(when (not (logtest? (enemy-flag recover-applied-velocity) (-> this enemy-flags)))
(set! (-> this enemy-flags)
(the-as enemy-flag (logior (enemy-flag recover-applied-velocity) (-> this enemy-flags)))
)
(enemy-method-135 this 1)
(when (and (>= (-> this enemy-info gem-joint) 0)
(not (logtest? (enemy-flag cam-attack-mode) (-> this enemy-flags)))
(or (and (not (and (-> this entity) (logtest? (-> this entity extra perm status) (entity-perm-status save))))
(-> this entity)
)
(task-node-closed? (game-task-node city-win-introduction))
(logtest? (-> *game-info* secrets) (game-secrets hero-mode))
)
)
(logior! (-> this enemy-flags) (enemy-flag cam-attack-mode))
(remove-from-process *part-engine* this)
(setup-masks
(-> this draw)
(the-as int (-> this enemy-info gem-no-seg))
(the-as int (-> this enemy-info gem-seg))
)
(let ((a0-18
(vector<-cspace! (new 'stack-no-clear 'vector) (-> this node-list data (-> this enemy-info gem-joint)))
)
)
(birth-pickup-at-point a0-18 (pickup-type gem) 1.0 #t *entity-pool* (-> this fact))
)
)
(logclear! (-> this enemy-flags) (enemy-flag enable-on-active checking-water))
(logclear! (-> this focus-status) (focus-status dangerous))
(logclear! (-> this enemy-flags) (enemy-flag check-water))
(logclear! (-> this mask) (process-mask collectable))
(logclear! (-> this enemy-flags) (enemy-flag look-at-move-dest))
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this enemy-flags) (enemy-flag notice))
(logior! (-> this focus-status) (focus-status dead))
(if (-> this skel effect)
(logior! (-> this skel effect flags) (effect-control-flag ecf1))
)
(stop-looking-at-target! this)
)
(none)
)
(defstate die (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(dispose! self)
(let ((v1-3 (-> self root root-prim)))
(set! (-> v1-3 prim-core collide-as) (collide-spec))
(set! (-> v1-3 prim-core collide-with) (collide-spec))
)
0
(set-time! (-> self state-time))
(set! (-> self hit-points) 0)
(enemy-method-103 self)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.075))
(let ((f30-0 (get-rand-float-range self 0.8 1.2)))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info die-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
(send-event self 'death-end)
(while (-> self child)
(suspend)
)
(cleanup-for-death self)
)
:post enemy-simple-post
)
(defmethod enemy-method-133 ((this enemy))
(let ((s5-0 (-> this root))
(a1-0 (new 'stack-no-clear 'collide-query))
(gp-0 #t)
)
(when (find-ground s5-0 a1-0 (-> this enemy-info recover-gnd-collide-with) 8192.0 81920.0 1024.0)
(if (< (- (-> s5-0 trans y) (-> s5-0 gspot-pos y)) 8192.0)
(set! gp-0 #f)
)
)
gp-0
)
)
(defstate die-falling (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(dispose! self)
(let ((v1-3 (-> self root root-prim)))
(set! (-> v1-3 prim-core collide-as) (collide-spec))
(set! (-> v1-3 prim-core collide-with) (collide-spec))
)
0
(set! (-> self hit-points) 0)
(if (logtest? (enemy-option knocked-into-water) (-> self fact enemy-options))
(logior! (-> self enemy-flags) (enemy-flag trackable-backup))
)
(enemy-method-103 self)
)
:exit (behavior ()
(local-vars (v0-0 enemy-flag))
(let ((v1-0 (-> self enemy-flags)))
(if (logtest? (enemy-flag enable-on-hostile) v1-0)
(set! v0-0 (logior (enemy-flag trackable-backup) v1-0))
(set! v0-0 (logclear v1-0 (enemy-flag trackable-backup)))
)
)
(set! (-> self enemy-flags) v0-0)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.1))
(let ((gp-0 (-> self draw art-group data (if (enemy-method-133 self)
(-> self enemy-info die-falling-anim)
(-> self enemy-info die-anim)
)
)
)
(f30-0 (get-rand-float-range self 0.8 1.2))
)
(ja-no-eval :group! gp-0 :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
(send-event self 'death-end)
(while (-> self child)
(suspend)
)
(cleanup-for-death self)
)
:post enemy-die-falling-post
)
(defstate directed (enemy)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(logior! (-> self enemy-flags) (enemy-flag victory))
((-> (method-of-type enemy idle) enter))
)
:exit (behavior ()
(logclear! (-> self enemy-flags) (enemy-flag victory))
)
:code (-> (method-of-type enemy idle) code)
:post (-> (method-of-type enemy idle) post)
)
(defstate die-fast (enemy)
:virtual #t
:code nothing
)
(defstate view-anims (enemy)
:virtual #t
:enter (behavior ()
'()
)
:trans (behavior ()
'()
)
:code (behavior ()
(let ((gp-0 (-> self draw art-group)))
(until #f
(dotimes (s5-0 (-> gp-0 length))
(let ((s4-0 (-> gp-0 data s5-0)))
(when (and s4-0 (= (-> s4-0 type) art-joint-anim))
(ja-channel-set! 1)
(ja-no-eval :group! s4-0 :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
)
)
)
#f
)
:post transform-post
)
(defbehavior ja-group-index? enemy ((arg0 int))
(ja-group? (-> self draw art-group data arg0))
)