1(setq ant_tints (make-array 14 :initial-contents (list 2 (def_tint "art/tints/ant/green.spe") 3 (def_tint "art/tints/ant/blue.spe") 4 (def_tint "art/tints/ant/brown.spe") 5 (def_tint "art/tints/ant/egg.spe") 6 (def_tint "art/tints/ant/yellow.spe") 7 (def_tint "art/tints/ant/mustard.spe") 8 (def_tint "art/tints/ant/orange.spe") 9 (def_tint "art/tints/ant/gray.spe") 10 normal_tint 11 normal_tint 12 normal_tint 13 (def_tint "addon/leon/gray.spe") 14 (def_tint "addon/leon/gray.spe") 15 (def_tint "addon/leon/gray.spe") 16 ))) 17 18(defun crackN_ai () 19 (if (eq (aistate) 0) 20 (if (if (eq (total_objects) 0) 21 (and (< (distx) 50) (< (disty) 70)) 22 (with_object (get_object 0) (not (eq (aistate) 0)))) 23 (set_aistate 1)) 24 (select (current_frame) 25 (4 nil) 26 (3 27 (let ((d (direction)) 28 (type (aitype))) 29 (if (or (eq create_total 0) (eq create_total 1)) 30 (set_current_frame 4) 31 (progn 32 (setq create_total (- create_total 1)) 33 (set_current_frame 0))) 34 (with_object (add_object_after ANT (+ (x) (* (direction) 20)) (y)) 35 (progn 36 (set_aitype type) 37 (set_direction d) 38 (set_xvel (* d 20)) 39 (set_state run_jump) 40 (set_aistate 6))) 41 )) 42 (0 (next_picture)) 43 (1 (next_picture)) 44 (2 (next_picture)))) 45 T) 46 47 48 49(def_char ANT_CRACK_HIDDEN 50 (funs (ai_fun crack_ai) 51 (draw_fun dev_draw) 52 (get_cache_list_fun ant_cache) 53 (constructor crack_cons)) 54 (range 250 0) 55 (vars create_total) 56 (fields ("create_total" ant_total) 57 ("aitype" ant_type)) 58 (states "art/ant.spe" 59 (stopped (seq "aisw" 2 6)))) 60 61(def_char ANT_CRACK_NEW 62 (funs (ai_fun crackN_ai) 63 (draw_fun ant_draw) 64 (get_cache_list_fun ant_cache) 65 (constructor crack_cons)) 66 (range 250 0) 67 (vars create_total) 68 (fields ("create_total" ant_total) 69 ("aitype" ant_type)) 70 (states "art/ant.spe" 71 (stopped (seq "aisw" 2 6)))) 72 73 74 75 76(defun anthole_ai () 77 (select (aistate) 78 (0 79 (if (and (activated) (< (total_objects) (+ (xvel) 1) ) ) 80 (go_state 2) 81 ) 82 ) 83 (3 84 (if (and (activated) (< (total_objects) (+ (xvel) 1) ) ) 85 (progn 86 (if (eq (current_frame) 4) 87 (set_current_frame 1) 88 ) 89 (go_state 4) 90 ) 91 ) 92 ) 93 (4 94 (select (current_frame) 95 (0 (next_picture)) 96 (1 (next_picture)) 97 (2 (next_picture)) 98 (3 (next_picture)) 99 (4 (go_state 2)) 100 ) 101 ) 102 103 (1 104 (if (eq (state_time) (yvel)) 105 (select (otype) (ANTHOLE (go_state 0)) 106 (ANTCRACK2 (go_state 3)) 107 ) 108 ) 109 ) 110 (2 111 (if (eq (otype) ANTHOLE) 112 (let ( ( newant (add_object_after ANT_ROOF (x) (y) ) ) ( type (aitype) ) ) 113 (with_object newant 114 (progn 115 (set_aitype type) 116 (set_state run_jump) 117 (set_aistate 1) 118 ) 119 ) 120 (link_object newant) 121 ) 122 (let ( ( newant (add_object_after ANT_ROOF (+ (x) (* (direction) 20)) (y) ) ) ( type (aitype) ) ( d (direction) ) ) 123 (with_object newant 124 (progn 125 (set_aitype type) 126 (set_direction d) 127 (set_xvel (* d 20)) 128 (set_state run_jump) 129 (set_aistate 6) 130 ) 131 ) 132 (link_object newant) 133 ) 134 ) 135 (go_state 1) 136 ) 137 ) 138 T 139) 140 141(def_char ANTHOLE 142 (funs (ai_fun anthole_ai) 143 (draw_fun dev_draw) 144 (get_cache_list_fun ant_cache)) 145 (range 250 0) 146 (fields ("xvel" "max ants") 147 ("aitype" ai_type) 148 ("aistate" "ai_state") 149 ("yvel" "delay")) 150 (states "art/ant.spe" 151 (stopped (seq "affc" 1 2)))) 152 153(defun crack2_cons () 154 (set_aistate 3)) 155 156(def_char ANTCRACK2 157 (funs (ai_fun anthole_ai) 158 (draw_fun ant_draw) 159 (get_cache_list_fun ant_cache) 160 (constructor crack2_cons)) 161 (range 250 0) 162 (fields ("xvel" "max ants") 163 ("aitype" ai_type) 164 ("aistate" "ai_state") 165 ("yvel" "delay")) 166 (states "art/ant.spe" 167 (stopped (seq "aisw" 2 6)))) 168 169(defun make_new_ant_type ( name aifun drawfun damfun runspd shp pacel tacel jumpyvel jumpxvel ) 170 (eval `(def_char ,name 171 (vars need_to_dodge 172 no_see_time 173 hide_flag 174 xvar1 175 xvar2 176 xvar3 177 aivar1 178 aivar2) 179 180 (fields 181 ("xvar1" "class specific var1") 182 ("xvar2" "class specific var2") 183 ("xvar3" "class specific var3") 184 ("hide_flag" ant_hide) 185 ("fade_count" ai_fade) 186 ("aitype" ai_type) 187 ("hp" ai_health) 188 ("aistate" ai_state)) 189 (range 250 20) 190 (draw_range 40 40) 191 (funs (ai_fun ,aifun) 192 (draw_fun ,drawfun) 193 (constructor ant_cons) 194 (type_change_fun ant_ct) 195 (get_cache_list_fun ant_cache) 196 (damage_fun ,damfun)) 197 198 (abilities (run_top_speed runspd) 199 (start_hp shp) 200 (stop_acel pacel) 201 (start_acel tacel) 202 (jump_yvel jumpyvel) 203 (jump_xvel jumpxvel) 204 (push_xrange 1) 205 (jump_top_speed (+ jumpyvel jumpxvel) )) 206 207 (flags 208 (hurtable T) 209 (force_health T)) 210 211 (states "art/ant.spe" 212 (hanging (rep "ant" 2)) 213 214 (fall_start "affc0001.pcx") 215 (falling "affc0002.pcx") 216 217 (stopped "awlk0001.pcx") 218 (running (seq "awlk" 1 10)) 219 (landing (seq "acff" 1 4)) 220 (pounce_wait "acff0001.pcx") 221 (turn_around (seq "atrn" 1 5)) 222 223 (run_jump "dive") 224 (run_jump_fall "dive") 225 (start_run_jump "dive") 226 (fire_wait (seq "wait" 1 3)) 227 228 (ceil_fire (seq "cfire" 1 3)) 229 (top_walk (seq "awkc" 1 10)) 230 (flinch_up (rep "afh10001.pcx" 2)) 231 (flinch_down (rep "afh20001.pcx" 2)) 232 (blown_back_dead "adib0009.pcx") 233 (jump_up "ajmp.pcx") 234 (hiding "hidden") 235 (dead "hidden") 236 (weapon_fire (seq "asht" 2 5)))) 237)) 238 239 240 241 242(setq ai_ammo (make-array 15 :initial-contents (list MBULLET_ICON5 243 MBULLET_ICON5 244 GRENADE_ICON2 245 ROCKET_ICON2 246 PLASMA_ICON20 247 MBULLET_ICON5 248 MBULLET_ICON5 249 MBULLET_ICON5 250 MBULLET_ICON5 251 MBULLET_ICON20 252 MBULLET_ICON20 253 MBULLET_ICON20 254 MBULLET_ICON20 255 MBULLET_ICON20 256 MBULLET_ICON20))) 257 258(defun ant_Ndamage (amount from hitx hity push_xvel push_yvel) ; Some piece of really ugly looking code 259 260 (if (and (not (eq (state) dead)) 261 (or (not from) 262 (with_object from (if (eq (total_objects) 0) 263 (not (eq (otype) ANT_ROOF)) 264 (with_object (get_object 0) (not (eq (otype) ANT_ROOF))))))) 265 (if (not (eq (aistate) 15)) 266 (progn 267 (if (eq (random 2) 0) 268 (set_state flinch_up) 269 (set_state flinch_down)) 270 (damage_fun amount from hitx hity push_xvel push_yvel) 271 (play_sound APAIN_SND 127 (x) (y)) 272 (setq need_to_dodge 1) 273 (if (<= (hp) 0) 274 (progn 275 (if (eq (aitype) 0) 276 (play_sound (aref ASML_DEATH (random 2)) 127 (x) (y)) 277 (play_sound (aref ALRG_DEATH (random 3)) 127 (x) (y))) 278 279 (set_state dead) 280 (if (or (eq (aitype) 2) (eq (aitype) 4) ) (set_aitype 0) nil ) 281 (set_hp 0 ) 282 (if (eq (random (select difficulty 283 ('easy 2) 284 ('medium 5) 285 ('hard 8) 286 ('extreme 20))) 0) 287 (if (eq (random 4) 0) 288 (add_object (aitype_to_ammo (+ (aitype) 1)) (x) (y))) 289 (add_object (aitype_to_ammo (aitype)) (x) (y))) 290(if ( eq (get_dead_part from) flaming_part ) 291; Explosive weapon? 292 (if (eq (random 2) 0) (create_dead_parts ant_dead_parts (* (get_dead_part from) 3) (aitype)) 293 (let ((d (direction)) 294 (type (aitype))) 295 (with_object (add_object ANTBODY (x) (y)) 296 (progn 297 (set_aitype type) 298 (set_direction d) 299))) 300) 301; No? 302 (if (eq (random 5) 0) (create_dead_parts ant_dead_parts (* (get_dead_part from) 3) (aitype)) 303 (let ((d (direction)) 304 (type (aitype))) 305 (with_object (add_object DECO_ANTBODY (x) (y)) 306 (progn 307 (set_aitype type) 308 (set_direction d) 309))) 310) 311 312) 313 314 315 316 317) 318 ))))) 319 320 321 322(defun pred_draw () 323 (if (edit_mode) 324 (ant_draw) 325 (draw_predator))) 326 327(defun great_damage (amount from hitx hity push_xvel push_yvel) 328 (if (and (eq (fade_count) 0) (not (eq (aistate) 15)) ) 329 (progn 330 (play_sound APAIN_SND 127 (x) (y)) 331 (if (eq (random 3) 0) 332 (damage_fun amount from hitx hity push_xvel push_yvel) 333 (add_hp (* amount -1) ) ) 334 (if (eq (hp) 0) 335 (progn 336 (if (> xvar1 0) (set_hp 100) nil) 337 (setq xvar1 (- xvar1 1)) 338 (if (eq xvar1 -1) ;; substract 1 life 339 (let ((d (direction)) 340 (type (aitype))) 341 (with_object (add_object GRANTBODY (x) (y)) 342 (progn 343 (set_aitype type) 344 (set_direction d) 345))) 346 (set_aistate 6))))))) ;; Continue 347 348 349 350(defun grantbody_ai () 351 (if (< (hp) 12) (play_sound (aref ASML_DEATH (random 2)) 127 (x) (y)) nil) 352 (if (< (hp) 16) (play_sound (aref ALRG_DEATH (random 3)) 127 (x) (y)) nil) 353 (if (< (hp) 9) (create_dead_parts ant_dead_parts (* normal_part 3) (aitype)) nil) 354 (if (< (hp) 16 ) (progn (next_picture) (set_hp (+ (hp) 1) ) ) nil ) 355 (if (eq0 (aistate)) (progn 356 (try_move 0 10) 357 (if (eq (second (see_dist (x) (y) (x) (+ (y) 1))) (y)) ; if we are on the floor, don't check falling anymore 358 (set_aistate 1)))) 359 T 360) 361 362 363(def_char GRANTBODY 364 (funs (ai_fun grantbody_ai) 365 (draw_fun ant_draw)) 366 (flags (unlistable T) (add_front T)) 367 (states "art/ant.spe" (stopped (seq "adib" 1 16)))) 368 369(defun grant_ai () 370 (if (eq (aistate) 6) 371 (if (eq xvar2 1) 372 (progn 373 (if (eq (random 3) 0) 374 (set_aistate 2) 375 (set_aistate 8) 376 ) 377 (ant_ai) 378 ) 379 (ant_ai) 380 ) 381 (ant_ai) 382 ) 383) 384 385(defun stat( aistat ) 386 (eq (aistate) aistat) 387) 388 389(defun tant_ai () 390 (if (stat 8) 391 (progn 392 (ant_ai) 393 (set_direction (toward) ) 394 (if (and (stat 2) (not (eq (random 5) 0) ) ) 395 (set_aistate 8) 396 ) 397 ) 398 (ant_ai) 399 ) 400 (if (eq (hp) 0 ) nil T ) 401) 402 403(defun tough_damage (amount from hitx hity push_xvel push_yvel) 404 (if (not (eq (aistate) 15)) 405 (progn 406 (if (eq (random 5) 0) 407 (damage_fun amount from hitx hity push_xvel push_yvel) 408 (add_hp (* amount -1) ) ) 409 (if (<= (hp) 0) 410 (let ((d (direction)) 411 (type (aitype))) 412 (with_object (add_object ANTBODY (x) (y)) 413 (progn 414 (set_aitype type) 415 (set_direction d) 416 ) 417 ) 418 (play_sound (aref ASML_DEATH (random 2)) 127 (x) (y)) 419 (create_dead_parts ant_dead_parts (* normal_part 3) type) 420 ) 421 ) 422 ) 423 ) 424) 425 426(make_new_ant_type 'ANT_PRED 'ant_ai 'pred_draw 'ant_damage 7 20 20 20 -4 20) 427(make_new_ant_type 'ANT_JUMPER 'ant_ai 'ant_draw 'ant_Ndamage 7 20 20 20 -12 10) 428(make_new_ant_type 'ANT 'ant_ai 'ant_draw 'ant_Ndamage 6 30 15 15 -6 18) 429(make_new_ant_type 'ANT_GREATER2 'grant_ai 'ant_draw 'great_damage 12 100 30 30 -6 15) 430 ;; Xvar1 = Number of lives. Xvar2 = Can't jump? 431 ;; Used to be ANT_GREATER, but this class was removed when I added make_new_ant_type function. 432(make_new_ant_type 'ANT_TOUGH 'tant_ai 'ant_draw 'tough_damage 9 200 10 10 -6 10)