1 | (defun Njug_can_hit_player ()
|
---|
2 | (let ((firex (x))
|
---|
3 | (firey (- (y) 24))
|
---|
4 | (playerx (with_object (bg) (x)))
|
---|
5 | (playery (- (with_object (bg) (y)) 15)))
|
---|
6 | (can_see firex firey playerx playery nil)))
|
---|
7 |
|
---|
8 | (defun Njug_fire_at_player ()
|
---|
9 | (let ((firex (x) )
|
---|
10 | (firey (- (y) 24) )
|
---|
11 | (playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 1))))
|
---|
12 | (playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 1)))))
|
---|
13 |
|
---|
14 | (if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil))
|
---|
15 | (progn
|
---|
16 | (let ((angle (atan2 (- firey playery)
|
---|
17 | (- playerx firex))))
|
---|
18 | (fire_object (me) (aitype) firex firey angle (bg))
|
---|
19 | (set_state weapon_fire))
|
---|
20 |
|
---|
21 | ))))
|
---|
22 |
|
---|
23 | (defun Njug_ai ()
|
---|
24 | (if (<= (hp) 0)
|
---|
25 | (if (eq (state) dieing)
|
---|
26 | (next_picture)
|
---|
27 | (set_state dieing))
|
---|
28 | (if (activated)
|
---|
29 | (progn
|
---|
30 | (set_targetable T)
|
---|
31 | (push_char 35 40)
|
---|
32 | (select (aistate)
|
---|
33 | (0 ;; prepare to walk toward player
|
---|
34 | (if (eq stationary 0)
|
---|
35 | (progn
|
---|
36 | (set_state running)
|
---|
37 | (go_state 1))
|
---|
38 | (if (> (state_time) throw_xvel)
|
---|
39 | (progn
|
---|
40 | (set_state weapon_fire)
|
---|
41 | (set_aistate 2)))))
|
---|
42 |
|
---|
43 | (1 ;; walk toward player
|
---|
44 | (if (eq stationary 0)
|
---|
45 | (progn
|
---|
46 | (set_direction (toward))
|
---|
47 | (let ((curx (x));; save position in case we fall off a cliff
|
---|
48 | (cury (y)))
|
---|
49 | (if (next_picture)
|
---|
50 | (if (eq (current_frame) 8)
|
---|
51 | (play_sound JSTOMP_SND 127 (x) (y)))
|
---|
52 | (progn
|
---|
53 | (play_sound JSTOMP_SND 127 (x) (y))
|
---|
54 | (set_state weapon_fire)
|
---|
55 | (set_aistate 2)))
|
---|
56 | (if (can_see (x) (y) (x) (+ (y) 5) nil)
|
---|
57 | (progn
|
---|
58 | (set_x curx)
|
---|
59 | (set_y cury)
|
---|
60 | (try_move 0 10)))))
|
---|
61 | (if (> (state_time) throw_xvel)
|
---|
62 | (progn
|
---|
63 | (set_state weapon_fire)
|
---|
64 | (set_aistate 2)))))
|
---|
65 |
|
---|
66 | (2 ;; start fire
|
---|
67 | (if (eq (Njug_can_hit_player) nil) (go_state 0))
|
---|
68 | (if (> (state_time) 3)
|
---|
69 | (let ((myself (me)))
|
---|
70 | (set_direction (toward))
|
---|
71 | (Njug_fire_at_player)
|
---|
72 | (go_state 0))
|
---|
73 | (next_picture)))
|
---|
74 | (3 ;; wait for fire animation
|
---|
75 | (if (next_picture) nil (set_aistate 0))))
|
---|
76 | T)
|
---|
77 | (progn (set_targetable nil)
|
---|
78 | T))))
|
---|
79 |
|
---|
80 | (defun Njug_cons ()
|
---|
81 | (setq throw_xvel 3)
|
---|
82 | (setq throw_yvel -10)
|
---|
83 | (set_aitype 1))
|
---|
84 |
|
---|
85 | (def_char NJUGGER
|
---|
86 | (range 200 0)
|
---|
87 | (funs (ai_fun Njug_ai)
|
---|
88 | (constructor Njug_cons)
|
---|
89 | (get_cache_list_fun explo_damage_cache)
|
---|
90 | (damage_fun explo_damage))
|
---|
91 | (flags (hurtable T)
|
---|
92 | (can_block T))
|
---|
93 | (abilities (start_hp 50)
|
---|
94 | (push_xrange 1))
|
---|
95 | (vars throw_xvel throw_yvel stationary)
|
---|
96 | (fields ("hp" ai_health)
|
---|
97 | ("aitype" ai_type)
|
---|
98 | ("throw_xvel" jug_throw_spd)
|
---|
99 | ("throw_yvel" jug_throw_yv)
|
---|
100 | ("stationary" jug_stat)
|
---|
101 | ("aistate" ai_state))
|
---|
102 |
|
---|
103 | (states "art/jug.spe"
|
---|
104 | (stopped "robo0001.pcx")
|
---|
105 | (running (seq "rwlk" 1 13))
|
---|
106 | (weapon_fire (seq "robo" 1 10))
|
---|
107 | (dieing (seq "jugdie" 1 8))))
|
---|