This commit is contained in:
water
2023-05-04 18:37:15 -04:00
parent 50230e05fa
commit c937238366
+120 -10
View File
@@ -660,9 +660,9 @@
(set! (-> self gun track-tilt-range) 327680.0)
(set! (-> self gun track-angle-mult) 1.75)
(set! (-> self gun track-require) (the-as uint 3))
(set! (-> self gun fire-delay) (the-as uint 15))
(set! (-> self gun combo-fire-delay) (the-as uint 30))
(set! (-> self gun track-beam-size) 2457.6)
(set! (-> self gun fire-delay) (the-as uint 1))
(set! (-> self gun combo-fire-delay) (the-as uint 1))
(set! (-> self gun track-beam-size) 245700.6)
(remove-setting! 'gun-min-height)
(remove-setting! 'gun-max-height)
)
@@ -703,8 +703,8 @@
(set! (-> self gun track-turn-range) 1638400.0)
(set! (-> self gun track-find-range) 1638400.0)
(set! (-> self gun track-angle-mult) 1.75)
(set! (-> self gun fire-delay) (the-as uint 255))
(set! (-> self gun combo-fire-delay) (the-as uint 150))
(set! (-> self gun fire-delay) (the-as uint 1))
(set! (-> self gun combo-fire-delay) (the-as uint 1))
(set! (-> self gun track-beam-size) 1228.8)
(set! (-> self gun track-require) (the-as uint 2))
(remove-setting! 'gun-min-height)
@@ -1170,7 +1170,113 @@
(none)
)
(deftype best-track (structure)
((dist float)
(obj process-drawable)
)
)
(defun is-dead-enemy? ((proc process))
(and (type-type? (-> proc type) enemy) (<= (-> (the enemy proc) hit-points) 0))
)
(defun is-dead-dummy? ((proc process))
(and (type-type? (-> proc type) gun-dummy) (<= (-> (the gun-dummy proc) hit-points) 0))
)
(defun is-good-guy? ((proc process))
(or (type-type? (-> proc type) gun-cit-a)
(type-type? (-> proc type) gun-cit-b)
(type-type? (-> proc type) gun-cit-c)
(type-type? (-> proc type) gun-cit-d)
)
)
(defun get-trans-for-aim ((vec vector) (proc process-drawable))
;(if (type-type? (-> proc type) process-focusable)
; (vector-copy! vec (get-trans (the process-focusable proc) 3))
(vector+! vec (get-trans (the process-focusable proc) 3) (new 'static 'vector :y (meters 0.15)))
; )
vec
)
(defbehavior target-gun-find-track target ()
(define *best-track* (new 'stack 'best-track))
(set! (-> *best-track* dist) (meters 100000000.))
(set! (-> *best-track* obj) #f)
(iterate-process-tree
*active-pool*
(lambda ((proc process))
(when (logtest? (-> proc mask) (process-mask enemy guard vehicle civilian))
;(format 0 "enemy ~A~%" proc)
(when (and (type-type? (-> proc type) process-focusable)
;(not (= (-> proc state name) 'knocked))
(not (is-dead-enemy? proc))
(not (is-dead-dummy? proc))
(not (is-good-guy? proc))
)
(let* ((pos ;(get-trans (the process-focusable proc) 2)
(get-trans-for-aim (new-stack-vector0) (the process-drawable proc))
)
(dist (vector-vector-distance pos
;(-> *target* root trans)
(get-trans *target* 3)
))
)
;(add-debug-sphere #t (bucket-id debug2) pos (meters 1.0) *color-red*)
;(format 0 " dist ~m meters~%" dist)
(when (< dist (-> *best-track* dist))
(let ((cquery (new 'stack 'collide-query)))
(vector-! (-> cquery move-dist) pos (get-trans *target* 3))
(vector-copy! (-> cquery start-pos) (get-trans *target* 3))
(set! (-> cquery radius) (meters 0.01))
(set! (-> cquery ignore-process0) #f)
(set! (-> cquery ignore-process1) #f)
(set! (-> cquery ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> cquery action-mask) (collide-action solid))
(set! (-> cquery collide-with) (the-as collide-spec #x241))
(let ((u (fill-and-probe-using-line-sphere *collide-cache* cquery)))
(when (< u 0.0)
(format *stdcon* "u ~f: ~A ~A~%" u (-> proc state) (-> proc state name))
(set! (-> *best-track* dist) dist)
(set! (-> *best-track* obj) (the process-drawable proc))
(add-debug-line #t (bucket-id debug2) (get-trans *target* 3) pos *color-green* #f (the rgba -1))
)
(when (>= u 0.0)
(let ((p0 (get-trans *target* 3))
(p1 (new-stack-vector0))
)
(set! (-> p1 quad) (-> cquery move-dist quad))
(vector-float*! p1 p1 u)
(vector+! p1 p1 (-> cquery start-pos))
;(add-debug-line #t (bucket-id debug2) p0 p1 *color-orange* #f (the rgba -1))
;(add-debug-sphere #t (bucket-id debug2) p1 (meters 1.0) *color-blue*)
)
)
)
)
)
)
)
)
)
*null-kernel-context*)
(when (-> *best-track* obj)
(format *stdcon* "tracking ~A~%" (-> *best-track* obj))
(set! (-> self gun track?) 7)
(set! (-> self gun track-trans quad) (-> (get-trans (the process-focusable (-> *best-track* obj)) 3) quad))
)
(when (not (-> *best-track* obj))
(set! (-> self gun track?) 0)
)
(none)
)
(defbehavior target-gun-find-track2 target ()
(if (logtest? (-> self gun upper-body track-mode) (track-mode lock-on))
(logior! (-> self gun track?) 8)
(logand! (-> self gun track?) -9)
@@ -1777,21 +1883,23 @@
)
(cond
((and (logtest? (-> self gun track?) 1)
(logtest? (process-mask enemy guard) (-> (handle->process (-> self gun track-target 0 handle)) mask))
;(logtest? (process-mask enemy guard crate) (-> (handle->process (-> self gun track-target 0 handle)) mask))
)
(if (and (< (- (current-time) (-> self gun track-press-start-time)) (seconds 0.5))
#|(if #t (and (< (- (-> self clock frame-counter) (-> self gun track-press-start-time)) (seconds 0.5))
(< (-> self control time-between-zero-inputs) (seconds 0.5))
(and (= (-> self control turn-to-magnitude) 0.0)
(not (logtest? (-> self control current-surface flags) (surface-flag air attack)))
(-> self gun active?)
)
)
)|#
(forward-up-nopitch->quaternion
(-> self control dir-targ)
(vector-! (new 'stack-no-clear 'vector) (-> self gun track-trans) (-> self control trans))
(vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ))
)
)
;)
(cond
((or (and (nonzero? (-> self gun track-target-hold-time)) (< (current-time) (-> self gun track-target-hold-time)))
(and (nonzero? (-> self gun turn-fast-hold-time)) (< (current-time) (-> self gun turn-fast-hold-time)))
@@ -2606,6 +2714,8 @@
(if (cpad-pressed? (-> self control cpad number) r1)
(set! (-> gp-0 fire-start-time) (current-time))
)
(format *stdcon* "gc: ~D~%" (-> gp-0 gun-control))
(set! (-> gp-0 gun-control) 4)
(case (-> gp-0 gun-control)
((1)
(when (and (cpad-pressed? (-> self control cpad number) r1)
@@ -2686,7 +2796,7 @@
(sar (shl (the int (+ (-> gp-0 fire-spin) (* (-> gp-0 fire-spinv) (-> self clock seconds-per-frame)))) 48) 48)
)
)
(set! (-> gp-0 fire-delay) (the-as uint (the int (lerp-scale 120.0 30.0 (-> gp-0 fire-spinv) 0.0 218453.33))))
(set! (-> gp-0 fire-delay) 0);(the-as uint (the int (lerp-scale 120.0 30.0 (-> gp-0 fire-spinv) 0.0 218453.33))))
(when (and (>= (-> gp-0 fire-spinv) 218453.33)
(and (or (< 0.0 (-> self game gun-ammo 2))
(logtest? (state-flags sf16) (-> self state-flags))