
// Fusion's FUSION.AI FIle
// Artificial Intelligence File, all in one, quicker load

// Definitions

setgamename FUSION REDUX

define SECTOREFFECTOR 1
define ACTIVATOR 2
define TOUCHPLATE 3
define ACTIVATORLOCKED 4
define MUSICANDSFX 5
define LOCATORS 6
define CYCLER 7
define MASTERSWITCH 8
define RESPAWN 9
define GPSPEED 10
define ARROW 20
define FIRSTGUNSPRITE 21
define CHAINGUNSPRITE 22
define RPGSPRITE 23
define FREEZESPRITE 24
define SHRINKERSPRITE 25
define HEAVYHBOMB 26
define TRIPBOMBSPRITE 27
define SHOTGUNSPRITE 28
define DEVISTATORSPRITE 29
define HEALTHBOX 30
define AMMOBOX 31
define GROWSPRITEICON 32
define INVENTORYBOX 33
define FREEZEAMMO 37
define AMMO 40
define BATTERYAMMO 41
define DEVISTATORAMMO 42
define RPGAMMO 44
define GROWAMMO 45
define CRYSTALAMMO 46
define HBOMBAMMO 47
define AMMOLOTS 48
define SHOTGUNAMMO 49
define COLA 51
define SIXPAK 52
define FIRSTAID 53
define SHIELD 54
define STEROIDS 55
define AIRTANK 56
define JETPACK 57
define HEATSENSOR 59
define ACCESSCARD 60
define BOOTS 61
define MIRRORBROKE 70
define CLOUDYOCEAN 78
define CLOUDYSKIES 79
define MOONSKY1 80
define MOONSKY2 81
define MOONSKY3 82
define MOONSKY4 83
define BIGORBIT1 84
define BIGORBIT2 85
define BIGORBIT3 86
define BIGORBIT4 87
define BIGORBIT5 88
define LA 89
define REDSKY1 98
define REDSKY2 99
define ATOMICHEALTH 100
define TECHLIGHT2 120
define TECHLIGHTBUST2 121
define TECHLIGHT4 122
define TECHLIGHTBUST4 123
define WALLLIGHT4 124
define WALLLIGHTBUST4 125
define ACCESSSWITCH 130
define SLOTDOOR 132
define LIGHTSWITCH 134
define SPACEDOORSWITCH 136
define SPACELIGHTSWITCH 138
define FRANKENSTINESWITCH 140
define NUKEBUTTON 142
define MULTISWITCH 146
define DOORTILE5 150
define DOORTILE6 151
define DOORTILE1 152
define DOORTILE2 153
define DOORTILE3 154
define DOORTILE4 155
define DOORTILE7 156
define DOORTILE8 157
define DOORTILE9 158
define DOORTILE10 159
define DOORSHOCK 160
define DIPSWITCH 162
define DIPSWITCH2 164
define TECHSWITCH 166
define DIPSWITCH3 168
define ACCESSSWITCH2 170
define REFLECTWATERTILE 180
define FLOORSLIME 200
define BIGFORCE 230
define EPISODE 247
define MASKWALL9 255
define W_LIGHT 260
define SCREENBREAK1 263
define SCREENBREAK2 264
define SCREENBREAK3 265
define SCREENBREAK4 266
define SCREENBREAK5 267
define SCREENBREAK6 268
define SCREENBREAK7 269
define SCREENBREAK8 270
define SCREENBREAK9 271
define SCREENBREAK10 272
define SCREENBREAK11 273
define SCREENBREAK12 274
define SCREENBREAK13 275
define MASKWALL1 285
define W_TECHWALL1 293
define W_TECHWALL2 297
define W_TECHWALL15 299
define W_TECHWALL3 301
define W_TECHWALL4 305
define W_TECHWALL10 306
define W_TECHWALL16 307
define WATERTILE2 336
define BPANNEL1 341
define PANNEL1 342
define PANNEL2 343
define WATERTILE 344
define STATIC 351
define W_SCREENBREAK 357
define W_HITTECHWALL3 360
define W_HITTECHWALL4 361
define W_HITTECHWALL2 362
define W_HITTECHWALL1 363
define MASKWALL10 387
define MASKWALL11 391
define DOORTILE22 395
define FANSPRITE 407
define FANSPRITEBROKE 411
define FANSHADOW 412
define FANSHADOWBROKE 416
define DOORTILE18 447
define DOORTILE19 448
define DOORTILE20 449
define SPACESHUTTLE 487
define SATELLITE 489
define VIEWSCREEN2 499
define VIEWSCREENBROKE 501
define VIEWSCREEN 502
define GLASS 503
define GLASS2 504
define STAINGLASS1 510
define MASKWALL5 514
define SATELITE 516
define FUELPOD 517
define SLIMEPIPE 538
define CRACK1 546
define CRACK2 547
define CRACK3 548
define CRACK4 549
define FOOTPRINTS 550
define DOMELITE 551
define CAMERAPOLE 554
define CHAIR1 556
define CHAIR2 557
define BROKENCHAIR 559
define MIRROR 560
define WATERFOUNTAIN 563
define WATERFOUNTAINBROKE 567
define FEMMAG1 568
define TOILET 569
define STALL 571
define STALLBROKE 573
define FEMMAG2 577
define REACTOR2 578
define REACTOR2BURNT 579
define REACTOR2SPARK 580
define GRATE1 595
define BGRATE1 596
define SOLARPANNEL 602
define NAKED1 603
define ANTENNA 607
define MASKWALL12 609
define TOILETBROKE 615
define PIPE2 616
define PIPE1B 617
define PIPE3 618
define PIPE1 619
define CAMERA1 621
define BRICK 626
define SPLINTERWOOD 630
define PIPE2B 633
define BOLT1 634
define W_NUMBERS 640
define WATERDRIP 660
define WATERBUBBLE 661
define WATERBUBBLEMAKER 662
define W_FORCEFIELD 663
define VACUUM 669
define FOOTPRINTS2 672
define FOOTPRINTS3 673
define FOOTPRINTS4 674
define EGG 675
define SCALE 678
define CHAIR3 680
define CAMERALIGHT 685
define MOVIECAMERA 686
define IVUNIT 689
define POT1 694
define POT2 695
define POT3 697
define PIPE3B 700
define WALLLIGHT3 701
define WALLLIGHTBUST3 702
define WALLLIGHT1 703
define WALLLIGHTBUST1 704
define WALLLIGHT2 705
define WALLLIGHTBUST2 706
define LIGHTSWITCH2 712
define WAITTOBESEATED 716
define DOORTILE14 717
define STATUE 753
define MIKE 762
define VASE 765
define SUSHIPLATE1 768
define SUSHIPLATE2 769
define SUSHIPLATE3 774
define SUSHIPLATE4 779
define DOORTILE16 781
define SUSHIPLATE5 792
define OJ 806
define MASKWALL13 830
define HURTRAIL 859
define POWERSWITCH1 860
define LOCKSWITCH1 862
define POWERSWITCH2 864
define ATM 867
define STATUEFLASH 869
define ATMBROKE 888
define BIGHOLE2 893
define STRIPEBALL 901
define QUEBALL 902
define POCKET 903
define WOODENHORSE 904
define TREE1 908
define TREE2 910
define CACTUS 911
define MASKWALL2 913
define MASKWALL3 914
define MASKWALL4 915
define FIREEXT 916
define TOILETWATER 921
define NEON1 925
define NEON2 926
define CACTUSBROKE 939
define BOUNCEMINE 940
define BROKEFIREHYDRENT 950
define BOX 951
define BULLETHOLE 952
define BOTTLE1 954
define BOTTLE2 955
define BOTTLE3 956
define BOTTLE4 957
define FEMPIC5 963
define FEMPIC6 964
define FEMPIC7 965
define HYDROPLANT 969
define OCEANSPRITE1 971
define OCEANSPRITE2 972
define OCEANSPRITE3 973
define OCEANSPRITE4 974
define OCEANSPRITE5 975
define GENERICPOLE 977
define CONE 978
define HANGLIGHT 979
define HYDRENT 981
define MASKWALL14 988
define TIRE 990
define PIPE5 994
define PIPE6 995
define PIPE4 996
define PIPE4B 997
define BROKEHYDROPLANT 1003
define PIPE5B 1005
define NEON3 1007
define NEON4 1008
define NEON5 1009
define BOTTLE5 1012
define BOTTLE6 1013
define BOTTLE8 1014
define SPOTLITE 1020
define HANGOOZ 1022
define MASKWALL15 1024
define BOTTLE7 1025
define HORSEONSIDE 1026
define GLASSPIECES 1031
define HORSELITE 1034
define DONUTS 1045
define NEON6 1046
define MASKWALL6 1059
define CLOCK 1060
define RUBBERCAN 1062
define BROKENCLOCK 1067
define PLUG 1069
define OOZFILTER 1079
define FLOORPLASMA 1082
define REACTOR 1088
define REACTORSPARK 1092
define REACTORBURNT 1096
define DOORTILE15 1102
define HANDSWITCH 1111
define CIRCLEPANNEL 1113
define CIRCLEPANNELBROKE 1114
define PULLSWITCH 1122
define MASKWALL8 1124
define BIGHOLE 1141
define ALIENSWITCH 1142
define DOORTILE21 1144
define HANDPRINTSWITCH 1155
define BOTTLE10 1157
define BOTTLE11 1158
define BOTTLE12 1159
define BOTTLE13 1160
define BOTTLE14 1161
define BOTTLE15 1162
define BOTTLE16 1163
define BOTTLE17 1164
define BOTTLE18 1165
define BOTTLE19 1166
define DOORTILE17 1169
define MASKWALL7 1174
define JAILBARBREAK 1175
define DOORTILE11 1178
define DOORTILE12 1179
define VENDMACHINE 1212
define VENDMACHINEBROKE 1214
define COLAMACHINE 1215
define COLAMACHINEBROKE 1217
define CRANEPOLE 1221
define CRANE 1222
define BARBROKE 1225
define BLOODPOOL 1226
define NUKEBARREL 1227
define NUKEBARRELDENTED 1228
define NUKEBARRELLEAKED 1229
define CANWITHSOMETHING 1232
define MONEY 1233
define BANNER 1236
define EXPLODINGBARREL 1238
define EXPLODINGBARREL2 1239
define FIREBARREL 1240
define SEENINE 1247
define SEENINEDEAD 1248
define STEAM 1250
define CEILINGSTEAM 1255
define PIPE6B 1260
define TRANSPORTERBEAM 1261
define RAT 1267
define TRASH 1272
define FEMPIC1 1280
define FEMPIC2 1289
define BLANKSCREEN 1293
define PODFEM1 1294
define FEMPIC3 1298
define FEMPIC4 1306
define FEM1 1312
define FEM2 1317
define FEM3 1321
define FEM5 1323
define BLOODYPOLE 1324
define FEM4 1325
define FEM6 1334
define FEM6PAD 1335
define FEM8 1336
define HELECOPT 1346
define FETUSJIB 1347
define HOLODUKE 1348
define SPACEMARINE 1353
define INDY 1355
define FETUS 1358
define FETUSBROKE 1359
define MONK 1352
define LUKE 1354
define COOLEXPLOSION1 1360
define WATERSPLASH2 1380
define FIREVASE 1390
define SCRATCH 1393
define FEM7 1395
define APLAYERTOP 1400
define APLAYER 1405
define PLAYERONWATER 1420
define DUKELYINGDEAD 1518
define DUKETORSO 1520
define DUKEGUN 1528
define DUKELEG 1536
define SHARK 1550
define BLOOD 1620
define FIRELASER 1625
define TRANSPORTERSTAR 1630
define SPIT 1636
define LOOGIE 1637
define FIST 1640
define FREEZEBLAST 1641
define DEVISTATORBLAST 1642
define SHRINKSPARK 1646
define TONGUE 1647
define MORTER 1650
define SHRINKEREXPLOSION 1656
define RADIUSEXPLOSION 1670
define FORCERIPPLE 1671
define LIZTROOP 1680
define LIZTROOPRUNNING 1681
define LIZTROOPSTAYPUT 1682
define LIZTOP 1705
define LIZTROOPSHOOT 1715
define LIZTROOPJETPACK 1725
define LIZTROOPDSPRITE 1734
define LIZTROOPONTOILET 1741
define LIZTROOPJUSTSIT 1742
define LIZTROOPDUCKING 1744
define HEADJIB1 1768
define ARMJIB1 1772
define LEGJIB1 1776
define CANNONBALL 1817
define OCTABRAIN 1820
define OCTABRAINSTAYPUT 1821
define OCTATOP 1845
define OCTADEADSPRITE 1855
define INNERJAW 1860
define DRONE 1880
define EXPLOSION2 1890
define COMMANDER 1920
define COMMANDERSTAYPUT 1921
define RECON 1960
define TANK 1975
define PIGCOP 2000
define PIGCOPSTAYPUT 2001
define PIGCOPDIVE 2045
define PIGCOPDEADSPRITE 2060
define PIGTOP 2061
define LIZMAN 2120
define LIZMANSTAYPUT 2121
define LIZMANSPITTING 2150
define LIZMANFEEDING 2160
define LIZMANJUMP 2165
define LIZMANDEADSPRITE 2185
define FECES 2200
define LIZMANHEAD1 2201
define LIZMANARM1 2205
define LIZMANLEG1 2209
define EXPLOSION2BOT 2219
define USERWEAPON 2235
define HEADERBAR 2242
define JIBS1 2245
define JIBS2 2250
define JIBS3 2255
define JIBS4 2260
define JIBS5 2265
define BURNING 2270
define FIRE 2271
define JIBS6 2286
define BLOODSPLAT1 2296
define BLOODSPLAT3 2297
define BLOODSPLAT2 2298
define BLOODSPLAT4 2299
define OOZ 2300
define OOZ2 2309
define WALLBLOOD1 2301
define WALLBLOOD2 2302
define WALLBLOOD3 2303
define WALLBLOOD4 2304
define WALLBLOOD5 2305
define WALLBLOOD6 2306
define WALLBLOOD7 2307
define WALLBLOOD8 2308
define BURNING2 2310
define FIRE2 2311
define CRACKKNUCKLES 2324
define SMALLSMOKE 2329
define SMALLSMOKEMAKER 2330
define FLOORFLAME 2333
define ROTATEGUN 2360
define GREENSLIME 2370
define WATERDRIPSPLASH 2380
define SCRAP6 2390
define SCRAP1 2400
define SCRAP2 2404
define SCRAP3 2408
define SCRAP4 2412
define SCRAP5 2416
define ORGANTIC 2420
define BETAVERSION 2440
define PLAYERISHERE 2442
define PLAYERWASHERE 2443
define SELECTDIR 2444
define F1HELP 2445
define NOTCHON 2446
define NOTCHOFF 2447
define GROWSPARK 2448
define DUKEICON 2452
define BADGUYICON 2453
define FOODICON 2454
define GETICON 2455
define MENUSCREEN 2456
define MENUBAR 2457
define KILLSICON 2458
define FIRSTAID_ICON 2460
define HEAT_ICON 2461
define BOTTOMSTATUSBAR 2462
define BOOT_ICON 2463
define FRAGBAR 2465
define JETPACK_ICON 2467
define AIRTANK_ICON 2468
define STEROIDS_ICON 2469
define HOLODUKE_ICON 2470
define ACCESS_ICON 2471
define DIGITALNUM 2472
define DUKECAR 2491
define CAMCORNER 2482
define CAMLIGHT 2484
define LOGO 2485
define TITLE 2486
define NUKEWARNINGICON 2487
define MOUSECURSOR 2488
define SLIDEBAR 2489
define DREALMS 2492
define BETASCREEN 2493
define WINDOWBORDER1 2494
define TEXTBOX 2495
define WINDOWBORDER2 2496
define DUKENUKEM 2497
define THREEDEE 2498
define INGAMEDUKETHREEDEE 2499
define TENSCREEN 2500
define PLUTOPAKSPRITE 2501
define DEVISTATOR 2510
define KNEE 2521
define CROSSHAIR 2523
define FIRSTGUN 2524
define FIRSTGUNRELOAD 2528
define FALLINGCLIP 2530
define CLIPINHAND 2531
define HAND 2532
define SHELL 2533
define SHOTGUNSHELL 2535
define CHAINGUN 2536
define RPGGUN 2544
define RPGMUZZLEFLASH 2545
define FREEZE 2548
define CATLITE 2552
define SHRINKER 2556
define HANDHOLDINGLASER 2563
define TRIPBOMB 2566
define LASERLINE 2567
define HANDHOLDINGACCESS 2568
define HANDREMOTE 2570
define HANDTHROW 2573
define TIP 2576
define GLAIR 2578
define SCUBAMASK 2581
define SPACEMASK 2584
define FORCESPHERE 2590
define SHOTSPARK1 2595
define RPG 2605
define LASERSITE 2612
define SHOTGUN 2613
define BOSS1 2630
define BOSS1STAYPUT 2631
define BOSS1SHOOT 2660
define BOSS1LOB 2670
define BOSSTOP 2696
define BOSS2 2710
define BOSS3 2760
define SPINNINGNUKEICON 2813
define BIGFNTCURSOR 2820
define SMALLFNTCURSOR 2821
define STARTALPHANUM 2822
define ENDALPHANUM 2915
define BIGALPHANUM 2940
define BIGPERIOD 3002
define BIGCOMMA 3003
define BIGX 3004
define BIGQ 3005
define BIGSEMI 3006
define BIGCOLIN 3007
define THREEBYFIVE 3010
define BIGAPPOS 3022
define BLANK 3026
define MINIFONT 3072
define BUTTON1 3164
define GLASS3 3187
define RESPAWNMARKERRED 3190
define RESPAWNMARKERYELLOW 3200
define RESPAWNMARKERGREEN 3210
define BONUSSCREEN 3240
define VIEWBORDER 3250
define VICTORY1 3260
define ORDERING 3270
define TEXTSTORY 3280
define LOADSCREEN 3281
define BORNTOBEWILDSCREEN 3370
define BLIMP 3400
define FEM9 3450
define FOOTPRINT 3701
define POOP 4094
define FRAMEEFFECT1 4095
define SPARK 4130
define SWOODSCRAP 4134

spritenoshade SPARK

defineprojectile SPARK PROJ_WORKSLIKE 6278
defineprojectile SPARK PROJ_HITRADIUS 0
defineprojectile SPARK PROJ_VEL 150
defineprojectile SPARK PROJ_DROP -200
defineprojectile SPARK PROJ_BOUNCES 1
defineprojectile SPARK PROJ_BSOUND -1
defineprojectile SPARK PROJ_ISOUND -1
defineprojectile SPARK PROJ_XREPEAT 6
defineprojectile SPARK PROJ_YREPEAT 6
defineprojectile SPARK PROJ_EXTRA 0
defineprojectile SPARK PROJ_SPAWNS -1

defineprojectile SWOODSCRAP PROJ_WORKSLIKE 6278
defineprojectile SWOODSCRAP PROJ_HITRADIUS 0
defineprojectile SWOODSCRAP PROJ_VEL 140
defineprojectile SWOODSCRAP PROJ_DROP -140
defineprojectile SWOODSCRAP PROJ_BOUNCES 1
defineprojectile SWOODSCRAP PROJ_BSOUND -1
defineprojectile SWOODSCRAP PROJ_XREPEAT 6
defineprojectile SWOODSCRAP PROJ_YREPEAT 6
defineprojectile SWOODSCRAP PROJ_EXTRA 0
defineprojectile SWOODSCRAP PROJ_SPAWNS -1

gamevar PICNUM 0 2

gamevar TEMP 0 2
gamevar TEMP2 0 2
gamevar TEMP3 0 2
gamevar TEMP4 0 2
gamevar TEMP5 0 2
gamevar TEMP6 0 2
gamevar TEMP7 0 2

onevent EVENT_EGS
getactor[THISACTOR].picnum PICNUM

switch PICNUM
case SWOODSCRAP:
case SPARK:
	randvar TEMP 2048
	setactor[THISACTOR].ang TEMP
	randvar TEMP -4096
	setactor[THISACTOR].zvel TEMP
	setactor[THISACTOR].yvel 0
	break
endswitch

endevent


// These tile positions are reserved!

define RESERVEDSLOT1 6132
define RESERVEDSLOT2 6133
define RESERVEDSLOT3 6134
define RESERVEDSLOT4 6135
define RESERVEDSLOT5 6136
define RESERVEDSLOT6 6132
define RESERVEDSLOT7 6133
define RESERVEDSLOT8 6134
define RESERVEDSLOT9 6135
define RESERVEDSLOT10 6136
define RESERVEDSLOT11 6137
define RESERVEDSLOT12 6138
define RESERVEDSLOT13 6139
define RESERVEDSLOT14 6140
define RESERVEDSLOT15 6141
define RESERVEDSLOT16 6142
define RESERVEDSLOT17 6143

// Defines weapon, not to be used with the 'shoot' keyword.

define KNEE_WEAPON         0
define PISTOL_WEAPON       1
define SHOTGUN_WEAPON      2
define CHAINGUN_WEAPON     3
define RPG_WEAPON          4
define HANDBOMB_WEAPON     5
define SHRINKER_WEAPON     6
define DEVISTATOR_WEAPON   7
define TRIPBOMB_WEAPON     8
define FREEZE_WEAPON       9
define HANDREMOTE_WEAPON   10
define GROW_WEAPON         11

// Defines the motion characteristics of an actor
define faceplayer 1
define geth 2
define getv 4
define randomangle 8
define faceplayerslow 16
define spin 32
define faceplayersmart 64
define fleeenemy 128
define jumptoplayer 257
define seekplayer 512
define furthestdir 1024
define dodgebullet 4096

// Some misc defines
define NO       0
define YES      1

// Defines for 'useractor' keyword
define notenemy       0
define enemy          1
define enemystayput   2

// Player Actions.
define pstanding 1
define pwalking 2
define prunning 4
define pducking 8
define pfalling 16
define pjumping 32
define phigher 64
define pwalkingback 128
define prunningback 256
define pkicking 512
define pshrunk 1024
define pjetpack 2048
define ponsteroids 4096
define ponground 8192
define palive 16384
define pdead 32768
define pfacing 65536


define GET_STEROIDS     0
define GET_SHIELD       1
define GET_SCUBA        2
define GET_HOLODUKE     3
define GET_JETPACK      4
define GET_ACCESS       6
define GET_HEATS        7
define GET_FIRSTAID     9
define GET_BOOTS       10


define KICK_HIT                         0
define PISTOL_RICOCHET                  1
define PISTOL_BODYHIT                   2
define PISTOL_FIRE                      3
define EJECT_CLIP                       4
define INSERT_CLIP                      5
define CHAINGUN_FIRE                    6
define RPG_SHOOT                        7
define POOLBALLHIT                      8
define RPG_EXPLODE                      9
define CAT_FIRE                        10
define SHRINKER_FIRE                   11
define ACTOR_SHRINKING                 12
define PIPEBOMB_BOUNCE                 13
define PIPEBOMB_EXPLODE                14
define LASERTRIP_ONWALL                15
define LASERTRIP_ARMING                16
define LASERTRIP_EXPLODE               17
define VENT_BUST                       18
define GLASS_BREAKING                  19
define GLASS_HEAVYBREAK                20
define SHORT_CIRCUIT                   21
define ITEM_SPLASH                     22
define DUKE_BREATHING                  23
define DUKE_EXHALING                   24
define DUKE_GASP                       25
define SLIM_RECOG                      26
define ENDSEQVOL3SND1                  27
define DUKE_URINATE                    28
define ENDSEQVOL3SND2                  29
define ENDSEQVOL3SND3                  30
define DUKE_PASSWIND                   32
define DUKE_CRACK                      33
define SLIM_ATTACK                     34
define SOMETHINGHITFORCE               35
define DUKE_DRINKING                   36
define DUKE_KILLED1                    37
define DUKE_GRUNT                      38
define DUKE_HARTBEAT                   39
define DUKE_ONWATER                    40
define DUKE_DEAD                       41
define DUKE_LAND                       42
define DUKE_WALKINDUCTS                43
define DUKE_GLAD                       44
define DUKE_YES                        45
define DUKE_HEHE                       46
define DUKE_SHUCKS                     47
define DUKE_UNDERWATER                 48
define DUKE_JETPACK_ON                 49
define DUKE_JETPACK_IDLE               50
define DUKE_JETPACK_OFF                51
define RUSTYBRIDGE                     52
define BATZ                            53
define SWAMP1                          54
define SWAMP2                          55
define DUKETALKTOBOSS                  56
define LIZCAPT_GROWL                   57
define LIZCAPT_TALK1                   58
define LIZCAPT_TALK2                   59
define LIZCAPT_TALK3                   60
define LIZARD_BEG                      61
define LIZARD_PAIN                     62
define LIZARD_DEATH                    63
define LIZARD_SPIT                     64
define DRONE1_HISSRATTLE               65
define DRONE1_HISSSCREECH              66
define DUKE_TIP2                       67
define FLESH_BURNING                   68
define SQUISHED                        69
define TELEPORTER                      70
define ELEVATOR_ON                     71
define DUKE_KILLED3                    72
define ELEVATOR_OFF                    73
define DOOR_OPERATE1                   74
define SUBWAY                          75
define SWITCH_ON                       76
define FAN                             77
define DUKE_GETWEAPON3                 78
define FLUSH_TOILET                    79
define HOVER_CRAFT                     80
define EARTHQUAKE                      81
define INTRUDER_ALERT                  82
define END_OF_LEVEL_WARN               83
define ENGINE_OPERATING                84
define REACTOR_ON                      85
define COMPUTER_AMBIENCE               86
define GEARS_GRINDING                  87
define BUBBLE_AMBIENCE                 88
define MACHINE_AMBIENCE                89
define SEWER_AMBIENCE                  90
define WIND_AMBIENCE                   91
define SOMETHING_DRIPPING              92
define STEAM_HISSING                   93
define THEATER_BREATH                  94
define BAR_MUSIC                       95
define BOS1_ROAM                       96
define BOS1_RECOG                      97
define BOS1_ATTACK1                    98
define BOS1_PAIN                       99
define BOS1_DYING                     100
define BOS2_ROAM                      101
define BOS2_RECOG                     102
define BOS2_ATTACK                    103
define BOS2_PAIN                      104
define BOS2_DYING                     105
define GETATOMICHEALTH                106
define DUKE_GETWEAPON2                107
define BOS3_DYING                     108
define SHOTGUN_FIRE                   109
define PRED_ROAM                      110
define PRED_RECOG                     111
define PRED_ATTACK                    112
define PRED_PAIN                      113
define PRED_DYING                     114
define CAPT_ROAM                      115
define CAPT_ATTACK                    116
define CAPT_RECOG                     117
define CAPT_PAIN                      118
define CAPT_DYING                     119
define PIG_ROAM                       120
define PIG_RECOG                      121
define PIG_ATTACK                     122
define PIG_PAIN                       123
define PIG_DYING                      124
define COMM_RECOG                     136
define DEMON_SIGHT                    148
define DEMON_JUMP                     164
define DEMON_IDLE                     125
define DEMON_EVISCERATE               126
define DEMON_PAIN                     127
define DEMON_DEATH                    128
define JOHN_JUMP                      137
define BEEPSWITCH1                    139
define OCTA_ROAM                      140
define OCTA_RECOG                     141
define OCTA_ATTACK1                   142
define OCTA_PAIN                      143
define OCTA_DYING                     144
define TURR_ROAM                      145
define TURR_RECOG                     146
define TURR_ATTACK                    147
define SLIM_DYING                     149
define BOS3_ROAM                      150
define BOS3_RECOG                     151
define BOS3_ATTACK1                   152
define BOS3_PAIN                      153
define BOS1_ATTACK2                   154
define COMM_SPIN                      155
define BOS1_WALK                      156
define DRON_ROAM                      130
define DRON_RECOG                     131
define DRON_ATTACK1                   132
define DRON_PAIN                      133
define DRON_DYING                     134
define DRON_ATTACK2                   157
define THUD                           158
define OCTA_ATTACK2                   159
define WIERDSHOT_FLY                  160
define TURR_PAIN                      161
define TURR_DYING                     162
define SLIM_ROAM                      163
define DOOR_OPERATE2                  165
define DOOR_OPERATE3                  166
define DOOR_OPERATE4                  167
define BORNTOBEWILDSND                168
define SHOTGUN_COCK                   169
define GENERIC_AMBIENCE1              170
define GENERIC_AMBIENCE2              171
define GENERIC_AMBIENCE3              172
define GENERIC_AMBIENCE4              173
define GENERIC_AMBIENCE5              174
define GENERIC_AMBIENCE6              175
define BOS3_ATTACK2                   176
define GENERIC_AMBIENCE17             177
define GENERIC_AMBIENCE18             178
define GENERIC_AMBIENCE19             179
define GENERIC_AMBIENCE20             180
define GENERIC_AMBIENCE21             181
define GENERIC_AMBIENCE22             182
define SECRETLEVELSND                 183
define GENERIC_AMBIENCE8              184
define GENERIC_AMBIENCE9              185
define GENERIC_AMBIENCE10             186
define GENERIC_AMBIENCE11             187
define GENERIC_AMBIENCE12             188
define GENERIC_AMBIENCE13             189
define GENERIC_AMBIENCE14             190
define GENERIC_AMBIENCE15             192
define GENERIC_AMBIENCE16             193
define FIRE_CRACKLE                   194
define BONUS_SPEECH1                  195
define BONUS_SPEECH2                  196
define BONUS_SPEECH3                  197
define PIG_CAPTURE_DUKE               198
define BONUS_SPEECH4                  199
define DUKE_LAND_HURT                 200
define DUKE_HIT_STRIPPER1             201
define DUKE_TIP1                      202
define DUKE_KILLED2                   203
define PRED_ROAM2                     204
define PIG_ROAM2                      205
define DUKE_GETWEAPON1                206
define DUKE_SEARCH2                   207
define DUKE_CRACK2                    208
define DUKE_SEARCH                    209
define DUKE_GET                       210
define DUKE_LONGTERM_PAIN             211
define MONITOR_ACTIVE                 212
define NITEVISION_ONOFF               213
define DUKE_HIT_STRIPPER2             214
define DUKE_CRACK_FIRST               215
define DUKE_USEMEDKIT                 216
define DUKE_TAKEPILLS                 217
define DUKE_PISSRELIEF                218
define SELECT_WEAPON                  219
define WATER_GURGLE                   220
define DUKE_GETWEAPON4                221
define JIBBED_ACTOR1                  222
define JIBBED_ACTOR2                  223
define JIBBED_ACTOR3                  224
define JIBBED_ACTOR4                  225
define JIBBED_ACTOR5                  226
define JIBBED_ACTOR6                  227
define JIBBED_ACTOR7                  228
define DUKE_GOTHEALTHATLOW            229
define BOSSTALKTODUKE                 230
define HG_ROAM                        231
define HG_ALERT                       232
define HG_PAIN                        233
define SLV_RECOG                      234
define SLV_PAIN                       235
define SLV_ROAM                       236
define HC_ALERT                       237
define HC_ATTACK                      238
define HC_PAIN                        239
define BARNEYFALL                     240
define ALIEN_TALK1                    241
define ALIEN_TALK2                    242
define EXITMENUSOUND                  243
define FLY_BY                         244
define DUKE_SCREAM                    245
define SHRINKER_HIT                   246
define RATTY                          247
define INTO_MENU                      248
define BONUSMUSIC                     249
define DUKE_BOOBY                     250
define DUKE_TALKTOBOSSFALL            251
define DUKE_LOOKINTOMIRROR            252
define PIG_ROAM3                      253
define KILLME                         254
define DRON_JETSND                    255
define SPACE_DOOR1                    256
define SPACE_DOOR2                    257
define SPACE_DOOR3                    258
define SPACE_DOOR4                    259
define SPACE_DOOR5                    260
define ALIEN_ELEVATOR1                261
define VAULT_DOOR                     262
define JIBBED_ACTOR13                 263
define DUKE_GETWEAPON6                264
define JIBBED_ACTOR8                  265
define JIBBED_ACTOR9                  266
define JIBBED_ACTOR10                 267
define JIBBED_ACTOR11                 268
define JIBBED_ACTOR12                 269
define DUKE_KILLED4                   270
define DUKE_KILLED5                   271
define ALIEN_SWITCH1                  272
define DUKE_STEPONFECES               273
define DUKE_LONGTERM_PAIN2            274
define DUKE_LONGTERM_PAIN3            275
define DUKE_LONGTERM_PAIN4            276
define COMPANB2                       277
define KTIT                           278
define HELICOP_IDLE                   279
define STEPNIT                        280
define SPACE_AMBIENCE1                281
define SPACE_AMBIENCE2                282
define SLIM_HATCH                     283
define RIPHEADNECK                    284
define FOUNDJONES                     285
define ALIEN_DOOR1                    286
define ALIEN_DOOR2                    287
define ENDSEQVOL3SND4                 288
define ENDSEQVOL3SND5                 289
define ENDSEQVOL3SND6                 290
define ENDSEQVOL3SND7                 291
define ENDSEQVOL3SND8                 292
define ENDSEQVOL3SND9                 293
define WHIPYOURASS                    294
define ENDSEQVOL2SND1                 295
define ENDSEQVOL2SND2                 296
define ENDSEQVOL2SND3                 297
define ENDSEQVOL2SND4                 298
define ENDSEQVOL2SND5                 299
define ENDSEQVOL2SND6                 300
define ENDSEQVOL2SND7                 301
define GENERIC_AMBIENCE23             302
define SOMETHINGFROZE                 303
define DUKE_LONGTERM_PAIN5            304
define DUKE_LONGTERM_PAIN6            305
define DUKE_LONGTERM_PAIN7            306
define DUKE_LONGTERM_PAIN8            307
define WIND_REPEAT                    308
define SOLDIER_1                      309
define SOLDIER_2                      310
define SOLDIER_3                      311
define SOLDIER_4                      312
define ALARM1                         313
define ALARM2                         314
define ALARM3                         315
define FANMOVING                      316
define ARMOR_CHARGE                   317
define MED_CHARGE                     318
define NA_0                           320
define NA_9                           321
define CANTSTAYHEREMORE               322
define BIGTHUNDER                     323 
define THUNDER1                       324
define THUNDER2                       325
define THUNDER3                       326
define RAINING                        333
define BLOOD_WIND                     334
define THEDRIPS                       335 
define JOHNSTEP                       330
define GRAVAMB                        331
define CNTAMB                         332
define BR_ROAM1                       336
define BR_ROAM2                       337
define BR_PAIN                        338
define BR_DIE                         339
define DR_ROLL                        340
define JUKEBOX                        341
define CASUL_FIRE                     342
define CT_PAIN                        327
define CT_DIE                         328
define CT_LAF                         329
define CT_LAND                        343
define CT_GET                         344
define BR_RECOG                       345 
define PAUL_SECURITY                  346
define BARNEYBEFOREOPEN1              347
define JOHNSTEP2                      348
define JOHN_JUMP2                     349
define DIRT_STEP                      350
define DIRT_STEP2                     351
define GRASS_STEP                     352
define GRASS_STEP2                    353
define GRATE_STEP                     354
define GRATE_STEP2                    355
define GRAVEL_STEP                    356
define GRAVEL_STEP2                   357
define METAL_STEP                     358
define METAL_STEP2                    359
define METAL_STEP3                    360
define METAL_STEP4                    361
define VENT_STEP                      362
define VENT_STEP2                     363
define WATER_STEP                     364
define WATER_STEP2                    365
define FLASHLIGHT                     366
define HITMETAL                       367
define HITMETAL2                      368
define HITMETAL3                      369
define HITMETAL4                      370
define WOOD_STEP                      371
define WOOD_STEP2                     372
define HITWOOD                        373


// Player hit counter stuff
gamevar PBEENHIT 0 1
gamevar PHITANGLE 0 1

gamevar z_mod 4096 2
gamevar distance 128 2

gamevar light_radius 0 2
gamevar red 0 2
gamevar green 0 2
gamevar blue 0 2
gamevar light_id 0 2

gamevar STEPSOUNDS 0 2
gamevar FLOORTEX 0 2

gamevar PHEALTH 0 2

state floorsounds
switch FLOORTEX
case 330 case 3533 case 3665 case 3666 case 3675
	setvar STEPSOUNDS 1 // Dirt
	break
case 3537 case 3660 case 3672 case 3883 case 3884 
	setvar STEPSOUNDS 2 // Grass
	break
case 285 case 710 case 3493 case 3516 case 3512 case 3511 case 3540 case 3555 case 3556 case 3557 case 3618 case 3709
case 3906 case 3948 case 3949 case 3950 case 4009
	setvar STEPSOUNDS 3 // Grate
	break
case 796 
	setvar STEPSOUNDS 4 // Gravel
	break
case 194 case 206 case 242 case 243 case 292 case 294 case 343 case 344 case 345 case 346 case 364 case 365 case 390 case 391 case 392
case 419 case 427 case 428 case 440 case 441 case 446 case 447 case 449 case 453 case 454 case 460 case 463 case 464 case 465 case 468
case 469 case 470 case 480 case 481 case 482 case 483 case 484 case 485 case 493 case 513 case 709 case 781 case 795 case 797 case 834
case 835 case 836 case 837 case 913 case 915 case 3495 case 3462 case 3478 case 3460 case 3461 case 3496 case 3503 case 3547
case 3550 case 3551 case 3552 case 3554 case 3562 case 3564 case 3574 case 3586 case 3587 case 3596 case 3629 case 3630 case 3631
case 3632 case 3633 case 3634 case 3670 case 3693 case 3694 case 3695 case 3696 case 3700 case 3702 case 3704 case 3711 case 3712 case 3713
case 3714 case 3715 case 3716 case 3717 case 3720 case 3723 case 3724 case 3729 case 3730 case 3731 case 3733 case 3734 case 3735 case 3736
case 3749 case 3774 case 3808 case 3910 case 3911 case 3913 case 3917 case 3918 case 3921 case 3930 case 3931 case 3932 case 3935 case 3937
case 3940 case 3944 case 3945 case 3954 case 3961 case 3962 case 3996 case 3997 case 3998 case 3999 case 4002 case 4006 case 4007
	setvar STEPSOUNDS 5 // Metal
	break
case 341 case 342 case 3561 case 3705
	setvar STEPSOUNDS 6 // Vent
	break
case 335 case 859 case 889
	setvar STEPSOUNDS 7 // Water
	break
case 377 case 378 case 379 case 418 case 420 case 444 case 474 case 745 case 884 case 3221 case 3518 case 3545 
case 3546 case 3592 case 3594 case 3597 case 3600 case 3619 case 3644 case 3650 case 3651 case 3652 case 3653 case 3667 
case 3669 case 3679 case 3680 case 3799 case 3806 case 3820 case 3861
	setvar STEPSOUNDS 8 // Wood
	break
default
	setvar STEPSOUNDS 0 // Default
	break
endswitch
ends

define DOUBLESIZE 131072
define NORMALSIZE 65536
define HALFSIZE 32768
define INVENSIZE 27000
define QUARTERSIZE 16384

gamevar SCREENSIZE 0 2

gamevar ALTHUD 0 2

state character_face
	ifvarg PHEALTH 80
		{
		ifvarg PBEENHIT 0
			{
			ifvarl PHITANGLE 256 rotatesprite 160 185 NORMALSIZE 0 4102 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 768 rotatesprite 160 185 NORMALSIZE 0 4107 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1280 rotatesprite 160 185 NORMALSIZE 0 4102 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1792 rotatesprite 160 185 NORMALSIZE 1024 4107 0 0 4 0 0 xdim ydim else
			rotatesprite 160 185 NORMALSIZE 0 4102 0 0 0 0 0 xdim ydim
			}
		else
		rotatesprite 160 185 NORMALSIZE 0 4096 0 0 0 0 0 xdim ydim
		}
	else
	ifvarg PHEALTH 60
		{
		ifvarg PBEENHIT 0
			{
			ifvarl PHITANGLE 256 rotatesprite 160 185 NORMALSIZE 0 4103 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 768 rotatesprite 160 185 NORMALSIZE 0 4108 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1280 rotatesprite 160 185 NORMALSIZE 0 4103 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1792 rotatesprite 160 185 NORMALSIZE 1024 4108 0 0 4 0 0 xdim ydim else
			rotatesprite 160 185 NORMALSIZE 0 4103 0 0 0 0 0 xdim ydim
			}
		else
		rotatesprite 160 185 NORMALSIZE 0 4097 0 0 0 0 0 xdim ydim
		}
	else
	ifvarg PHEALTH 40
		{
		ifvarg PBEENHIT 0
			{
			ifvarl PHITANGLE 256 rotatesprite 160 185 NORMALSIZE 0 4104 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 768 rotatesprite 160 185 NORMALSIZE 0 4109 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1280 rotatesprite 160 185 NORMALSIZE 0 4104 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1792 rotatesprite 160 185 NORMALSIZE 1024 4109 0 0 4 0 0 xdim ydim else
			rotatesprite 160 185 NORMALSIZE 0 4104 0 0 0 0 0 xdim ydim
			}
		else
		rotatesprite 160 185 NORMALSIZE 0 4098 0 0 0 0 0 xdim ydim
		}
	else
	ifvarg PHEALTH 20
		{
		ifvarg PBEENHIT 0
			{
			ifvarl PHITANGLE 256 rotatesprite 160 185 NORMALSIZE 0 4105 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 768 rotatesprite 160 185 NORMALSIZE 0 4110 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1280 rotatesprite 160 185 NORMALSIZE 0 4105 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1792 rotatesprite 160 185 NORMALSIZE 1024 4110 0 0 4 0 0 xdim ydim else
			rotatesprite 160 185 NORMALSIZE 0 4105 0 0 0 0 0 xdim ydim
			}
		else
		rotatesprite 160 185 NORMALSIZE 0 4099 0 0 0 0 0 xdim ydim
		}
	else
	ifvarg PHEALTH 0
		{
		ifvarg PBEENHIT 0
			{
			ifvarl PHITANGLE 256 rotatesprite 160 185 NORMALSIZE 0 4106 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 768 rotatesprite 160 185 NORMALSIZE 0 4111 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1280 rotatesprite 160 185 NORMALSIZE 0 4106 0 0 0 0 0 xdim ydim else
			ifvarl PHITANGLE 1792 rotatesprite 160 185 NORMALSIZE 1024 4111 0 0 4 0 0 xdim ydim else
			rotatesprite 160 185 32768 0 4106 0 0 0 0 0 xdim ydim
			}
		else
		rotatesprite 160 185 NORMALSIZE 0 4100 0 0 0 0 0 xdim ydim
		}
	else
	ifvarl PHEALTH 1
		{
		rotatesprite 160 185 NORMALSIZE 0 4101 0 0 0 0 0 xdim ydim
		}
		
	getuserdef[THISACTOR].god TEMP
	ifvare TEMP 1 rotatesprite 160 185 NORMALSIZE 0 4112 0 0 0 0 0 xdim ydim
ends

gamevar HUDON 1 2

onevent EVENT_DISPLAYREST
getuserdef[THISACTOR].screen_size TEMP
ifvare TEMP 4 // Toggles the HUD on and off
{
ifvare HUDON 0 setvar HUDON 1
else ifvare HUDON 1 setvar HUDON 2 
else setvar HUDON 0
}
setuserdef[THISACTOR].screen_size 0

ifvarn HUDON 0 // If the HUD is active
{
getuserdef[THISACTOR].althud ALTHUD
ifvare ALTHUD 1
	{
	ifvare HUDON 1
	state character_face
	}
else
	{
	  ifvare VOLUME 0 rotatesprite 34 187 NORMALSIZE 0 4143 0 0 0 0 0 xdim ydim // HEALTH AND AMMO BOX
	  ifvare VOLUME 1 rotatesprite 34 187 NORMALSIZE 0 4116 0 0 0 0 0 xdim ydim // HEALTH AND AMMO BOX
	  ifvare VOLUME 2 rotatesprite 34 187 HALFSIZE 0 4146 0 0 0 0 0 xdim ydim // HEALTH AND AMMO BOX
	  
	  ifvare HUDON 1 // If the HUD is 'full size'
	  {
	  ifvare VOLUME 1 rotatesprite 160 185 NORMALSIZE 0 4114 0 0 0 0 0 xdim ydim
	  ifvare VOLUME 2 rotatesprite 160 185 40768 0 4148 0 0 0 0 0 xdim ydim
	  state character_face
	  ifvare VOLUME 0 rotatesprite 17 13 NORMALSIZE 0 4144 0 0 0 0 0 xdim ydim // ARMOUR BOX
	  ifvare VOLUME 1 rotatesprite 17 13 NORMALSIZE 0 4118 0 0 0 0 0 xdim ydim // ARMOUR BOX
	  ifvare VOLUME 2 rotatesprite 17 13 32768 0 4149 0 0 0 0 0 xdim ydim // ARMOUR BOX
      getplayer[THISACTOR].shield_amount TEMP // Gets the player's armour into a variable
	  ifvare VOLUME 1
		  {
	      ifvarg TEMP 99 digitalnumber 4120 20 9 TEMP 0 10 0 0 0 xdim ydim else
	      ifvarg TEMP 9  digitalnumber 4120 25 9 TEMP 0 10 0 0 0 xdim ydim else
			digitalnumber 4120 29 9 TEMP 0 10 0 0 0 xdim ydim
		  }
		 else digitalnumber 4120 20 13 TEMP 0 10 0 0 0 xdim ydim
	  }

	ifvare VOLUME 1
	{
      ifvarg PHEALTH 99 digitalnumber 4120 21 183 PHEALTH 0 10 0 0 0 xdim ydim else
      ifvarg PHEALTH 9 digitalnumber 4120 26 183 PHEALTH 0 10 0 0 0 xdim ydim else 
	digitalnumber 4120 29 183 PHEALTH 0 10 0 0 0 xdim ydim // HEALTH NUMBER
	}
	else digitalnumber 4120 21 183 PHEALTH 0 10 0 0 0 xdim ydim 
	ifvare currentweapon 10 // If the player has the Pipebomb trigger selected than get the amount of pipebomb ammo into TEMP
		{
		getplayer[THISACTOR].ammo_amount 5 TEMP
		}
	else
	getplayer[THISACTOR].ammo_amount currentweapon TEMP // otherwise get the current weapon's ammo into TEMP
	ifvarg TEMP 99 digitalnumber 4120 55 183 TEMP 0 0 0 0 0 xdim ydim else
	ifvarg TEMP 9 digitalnumber 4120 59 183 TEMP 0 0 0 0 0 xdim ydim else
      digitalnumber 4120 63 183 TEMP 0 0 0 0 0 xdim ydim // Display the ammo amount


	getplayer[THISACTOR].got_access TEMP // Get the access card bit into TEMP
	ifvarand TEMP 1 { rotatesprite 284 168 QUARTERSIZE 0 60 0 0 0 0 0 xdim ydim } // If the player has the blue card, display it
	ifvarand TEMP 2 { rotatesprite 294 168 QUARTERSIZE 0 60 0 21 0 0 0 xdim ydim } // If the player has the red card, display it
	ifvarand TEMP 4 { rotatesprite 304 168 QUARTERSIZE 0 60 0 23 0 0 0 xdim ydim } // If the player has the yellow card, display it

	getplayer[THISACTOR].inven_icon TEMP
	ifvarn TEMP 0 // If the player's inventory is 'active'
		{
		ifvare VOLUME 1 rotatesprite 284 187 NORMALSIZE 0 4117 0 0 0 0 0 xdim ydim // INVENTORY BOX
		ifvare VOLUME 2 rotatesprite 294 184 HALFSIZE 0 4147 0 0 0 0 0 xdim ydim // INVENTORY BOX
		ifvare TEMP 1 // MEDKIT
			{
			rotatesprite 285 186 NORMALSIZE 0 2460 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].firstaid_amount TEMP2
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		ifvare TEMP 2 // STEROIDS
			{
			rotatesprite 285 186 NORMALSIZE 0 2469 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].steroids_amount TEMP2
			divvar TEMP2 4
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		ifvare TEMP 3 // HOLODUKE
			{
			rotatesprite 285 186 NORMALSIZE 0 2470 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].holoduke_amount TEMP2
			divvar TEMP2 24
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		ifvare TEMP 4 // JETPACK
			{
			rotatesprite 285 186 NORMALSIZE 0 2467 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].jetpack_amount TEMP2
			divvar TEMP2 16
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		ifvare TEMP 5 // NIGHT VISION GOGGLES
			{
			rotatesprite 285 186 NORMALSIZE 0 2461 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].heat_amount TEMP2
			divvar TEMP2 12
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		ifvare TEMP 6 // SCUBA GEAR
			{
			rotatesprite 285 186 NORMALSIZE 0 2468 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].scuba_amount TEMP2
			divvar TEMP2 64
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		ifvare TEMP 7 // BOOTS
			{
			rotatesprite 285 186 NORMALSIZE 0 2463 0 0 0 0 0 xdim ydim
			getplayer[THISACTOR].boot_amount TEMP2
			divvar TEMP2 2
			digitalnumber 3087 309 182 TEMP2 0 10 0 0 0 xdim ydim
			}
		}

	}
}

ifvarg PBEENHIT 0 { subvar PBEENHIT 1 rotatesprite 160 100 32768 PHITANGLE 4113 0 0 1 0 0 xdim ydim }

endevent

eventloadactor 74 setactor[THISACTOR].shade -32 enda

spritenoshade 74
spritenoshade 3558
spritenoshade 3559
spritenoshade 3637
spritenoshade 3654
spritenoshade 3955
spritenoshade 3956


state CHECKSTEPSOUNDS
getplayer[THISACTOR].spritebridge TEMP // IF THE PLAYER IS ON A FLAT SPRITE
ifvare TEMP 1 
	{ 
	getplayer[THISACTOR].sbs TEMP2 // GET THE FLATSPRITE'S ID TAG
	getactor[TEMP2].picnum TEMP // CHECK IT'S TEXTURE
	setvarvar FLOORTEX TEMP // SET THE VARIABLE FLOORTEX TO IT'S TEXTURE
	state floorsounds // AND CHECK THE STEP DEFINES
	} 
else
	{
	getsector[THISACTOR].floorpicnum FLOORTEX
	state floorsounds
	}
ends

state stepsounds
ifonwater // Water water everywhere nor a drop to drink
	{
	ifrnd 128 sound WATER_STEP else sound WATER_STEP2
	}
else
ifvare STEPSOUNDS 0 // Standard
	{
	ifrnd 128 sound JOHNSTEP else sound JOHNSTEP2
	}
else
ifvare STEPSOUNDS 1 // Dirt
	{
	ifrnd 128 sound DIRT_STEP else sound DIRT_STEP2
	}
else
ifvare STEPSOUNDS 2 // Grass
	{
	ifrnd 128 sound GRASS_STEP else sound GRASS_STEP2
	}
else
ifvare STEPSOUNDS 3 // Grate
	{
	ifrnd 128 sound GRATE_STEP else sound GRATE_STEP2
	}
else
ifvare STEPSOUNDS 4 // Gravel
	{
	ifrnd 128 sound GRAVEL_STEP else sound GRAVEL_STEP2
	}
else
ifvare STEPSOUNDS 5 // Metal
	{
	ifrnd 64 sound METAL_STEP else ifrnd 64 sound METAL_STEP2 else
	ifrnd 64 sound METAL_STEP3 else sound METAL_STEP4
	}
else
ifvare STEPSOUNDS 6 // Vent
	{
	ifrnd 128 sound VENT_STEP else sound VENT_STEP2
	}
else
ifvare STEPSOUNDS 7 // Water
	{
	ifrnd 128 sound WATER_STEP else sound WATER_STEP2
	}
else
ifvare STEPSOUNDS 8 // Water
	{
	ifrnd 128 sound WOOD_STEP else sound WOOD_STEP2
	}
ends


// ******************
// MISC GAME SETTINGS
// ******************

define SWEARFREQUENCY          100      // The lower, the less.

define CAMERASDESTRUCTABLE      NO               // YES
define FREEZERHURTOWNER         YES

define MAXPLAYERHEALTH          100
define MAXWATERFOUNTAINHEALTH    50

define YELLHURTSOUNDSTRENGTH     40
define YELLHURTSOUNDSTRENGTHMP   50

define MAXXSTRETCH 70
define MAXYSTRETCH 70

define MINXSTRETCH 9
define MINYSTRETCH 8

define MAXPLAYERATOMICHEALTH    200
define DOUBLEMAXPLAYERHEALTH    MAXPLAYERATOMICHEALTH
define STARTARMORHEALTH         50
define RETRIEVEDISTANCE         844
define SQUISHABLEDISTANCE      1024 
define DEFAULTVISIBILITY        512
define FROZENQUICKKICKDIST      980

define GENERICIMPACTDAMAGE      10

define MAXPISTOLAMMO           500
define MAXSHOTGUNAMMO          100
define MAXCHAINGUNAMMO         400
define MAXRPGAMMO               40
define MAXHANDBOMBAMMO          20
define MAXGROWAMMO               0  
define MAXSHRINKERAMMO           5
define MAXDEVISTATORAMMO        150
define MAXFREEZEAMMO            10
define MAXTRIPBOMBAMMO          5
define TRIPBOMBLASERMODE        0     // 0 = always visable
                                      // 1 = transluscense
                                      // 2 = invisible w/o IR goggles
                                      // 3 = totally invisable


define RESPAWNACTORTIME         768
define RESPAWNITEMTIME          768

// The BLIMP has a high respawn time (any value smaller runs the risk
// of spawning too many sprites, resulting in "Bog City")
define BLIMPRESPAWNTIME 2048

define NUMFREEZEBOUNCES          0  


define RUNNINGSPEED 53200
define GRAVITATIONALCONSTANT 176

define PLAYDEADTIME 120

define SHRUNKCOUNT 270
define SHRUNKDONECOUNT 304

define FROZENDRIPTIME 90
define THAWTIME 138


// Various blast radius distances

define RPGBLASTRADIUS           1780
define PIPEBOMBRADIUS           2500
define SHRINKERBLASTRADIUS      650
define TRIPBOMBBLASTRADIUS      3880
define MORTERBLASTRADIUS        2500
define BOUNCEMINEBLASTRADIUS    2500
define SEENINEBLASTRADIUS       2048

define QSIZE                   64       // total number of active
                                        // bullet holes, blood,
                                        // footprints, money, ect...
                                        // (max 1024)



gamestartup     DEFAULTVISIBILITY GENERICIMPACTDAMAGE MAXPLAYERHEALTH
                STARTARMORHEALTH  RESPAWNACTORTIME RESPAWNITEMTIME
                RUNNINGSPEED GRAVITATIONALCONSTANT RPGBLASTRADIUS
                PIPEBOMBRADIUS SHRINKERBLASTRADIUS TRIPBOMBBLASTRADIUS
                MORTERBLASTRADIUS BOUNCEMINEBLASTRADIUS SEENINEBLASTRADIUS
                MAXPISTOLAMMO MAXSHOTGUNAMMO MAXCHAINGUNAMMO
                MAXRPGAMMO MAXHANDBOMBAMMO MAXSHRINKERAMMO
                MAXDEVISTATORAMMO MAXGROWAMMO MAXTRIPBOMBAMMO MAXFREEZEAMMO
                CAMERASDESTRUCTABLE NUMFREEZEBOUNCES
                FREEZERHURTOWNER QSIZE TRIPBOMBLASERMODE



define KNEE_WEAPON_STRENGTH             10
define PISTOL_WEAPON_STRENGTH            6  // Adds rand()%5 (0 to 5)
define HANDBOMB_WEAPON_STRENGTH        140



// For direct hits with the rocket launcher,
// this amount is actually doubled.  Otherwise,
// damage values depend on distance. The
// further, the weaker.

define RPG_WEAPON_STRENGTH              140


define SHRINKER_WEAPON_STRENGTH        400 
define SHOTGUN_WEAPON_STRENGTH          10
define CHAINGUN_WEAPON_STRENGTH          9
define FREEZETHROWER_WEAPON_STRENGTH     0
define COOL_EXPLOSION_STRENGTH          38
define TRIPBOMB_STRENGTH               100
define FIRELASER_WEAPON_STRENGTH         7
define MORTER_WEAPON_STRENGTH           50
define BOUNCEMINE_WEAPON_STRENGTH      150
define SPIT_WEAPON_STRENGTH              8
define BULLET_WEAPON_STRENGTH           30

// Enemy strengths (hit points).

define TROOPSTRENGTH            70
define PIGCOPSTRENGTH          100
define PIG_SHIELD_AMOUNT1       75
define PIG_SHIELD_AMOUNT2       50
define LIZSTRENGTH             190
define LIZGETTINGDAZEDAT        15
define LIZEATINGPLAYER          -2
define OCTASTRENGTH           175
define OCTASCRATCHINGPLAYER   -11
define RECONSTRENGTH            50
define TURRETSTRENGTH           30
define ROTTURRETSTRENGTH        40
define DRONESTRENGTH           150
define CAPTAINSTRENGTH          50
define CAPTSPINNINGPLAYER      -11
define COMMANDERSTRENGTH        350
define SHARKSTRENGTH            35
define SHARKBITESTRENGTH        -9

define PISTOLAMMOAMOUNT         12
define SHOTGUNAMMOAMOUNT        10
define CHAINGUNAMMOAMOUNT       50
define RPGAMMOBOX               5
define CRYSTALAMMOAMOUNT        1
define DEVISTATORAMMOAMOUNT     15
define FREEZEAMMOAMOUNT         25
define HANDBOMBBOX              4


define BOSS1STRENGTH            110
define BOSS1PALSTRENGTH         110
define BOSS2STRENGTH            80
define BOSS3STRENGTH            50


// Miscellaneous strengths.

define WEAKEST           1
define WEAK              5
define MEDIUMSTRENGTH    10
define TOUGH             20
define REALLYTOUGH       30
define HBOMBTOUGH       100
define GOTTASMART        90
define BOMBTOUGH        100


// Players' inventory amounts.

define STEROID_AMOUNT           400
define SHIELD_AMOUNT            100
define SCUBA_AMOUNT            6400
define HOLODUKE_AMOUNT         2400
define JETPACK_AMOUNT          1600
define HEAT_AMOUNT             1200
define FIRSTAID_AMOUNT          MAXPLAYERHEALTH
define BOOT_AMOUNT              200

define SPAWNAMMOODDS             30


// Maximum quote size is 64 characters.

definequote  0        AUTO AIMING
definequote  1        SHOW MAP: OFF
definequote  2        ACTIVATED
definequote  3        DOCTOR'S BAG
definequote  4        LOCKED
definequote  5        ALL STUFF!
definequote  6        BOOTS
definequote  7        WASTED!
definequote  8        SOMETHING HAS BEEN UNLOCKED...
definequote  9        YOU FOUND A SECRET!
definequote 10        SQUISH!
definequote 11        ALL DOORS UNLOCKED
definequote 12        USED STEROIDS
definequote 13        PRESS SPACE TO RESTART LEVEL
definequote 14        MINI ROCKETS!
definequote 15        DEACTIVATED
definequote 16        SWITCH OPERATED ONLY!
definequote 17        GOD MODE: ON
definequote 18        GOD MODE: OFF
definequote 19        ATOMIC HEALTH!
definequote 20        CROSSHAIR: ON
definequote 21        CROSSHAIR: OFF
definequote 22        YOU'RE TOO GOOD TO BE CHEATING!
definequote 23        MESSAGES: ON
definequote 24        MESSAGES: OFF
definequote 25        TYPE THE CHEAT CODE:
definequote 26        DETAIL: LOW
definequote 27        DETAIL: HIGH
definequote 28        < EMPTY >
definequote 29        BRIGHTNESS LEVEL: ONE
definequote 30        BRIGHTNESS LEVEL: TWO
definequote 31        BRIGHTNESS LEVEL: THREE
definequote 32        BRIGHTNESS LEVEL: FOUR
definequote 33        BRIGHTNESS LEVEL: FIVE
definequote 34        SOUND: ON
definequote 35        SOUND: OFF
definequote 36        SCREEN CAPTURED
definequote 37        STEROIDS
definequote 38        ARMOR
definequote 39        SCUBA GEAR
definequote 40        Press F1 for Help
definequote 41        JET BOOTS
definequote 42        BODY SUIT
definequote 43        ACCESS CARD
definequote 44        MOUSE LOOKING DEACTIVATED
definequote 45        MOUSE LOOKING ACTIVATED
definequote 46        CHEAT CODE:  UNRECOGNIZED
definequote 47        HOLODUKE ON
definequote 48        HOLODUKE OFF
definequote 49        HOLODUKE NOT FOUND YET!
definequote 50        JET BOOTS NOT FOUND YET!
definequote 51        HOLODUKE
definequote 52        JET BOOTS ACTIVATED
definequote 53        JET BOOTS DEACTIVATED
definequote 54        HUNTING RIFLE! 
definequote 55        PACK OF 4 PIPEBOMBS!
definequote 56        ROCKET LAUNCHER!
definequote 57        SHOTGUN!
definequote 58        LASER TRIPBOMB!
definequote 59        H&K MP5!
definequote 60        NUKE WEAPON!!
definequote 61        PICKED UP MEDKIT
definequote 62        PICKED UP LIFE ESSENCE
definequote 63        AMMO FOR RIFLE!
definequote 64        ROCKETS!
definequote 65        AUTOMAG CLIP!
definequote 66        MP5 CLIP!
definequote 67        BOOTS OFF
definequote 68        BOOTS ON
definequote 69        SHOTGUN SHELLS!
definequote 70        BLUE ACCESS CARD REQUIRED
definequote 71        RED ACCESS CARD REQUIRED
definequote 72        YELLOW ACCESS CARD REQUIRED
definequote 73        WEAPON LOWERED
definequote 74        WEAPON RAISED
definequote 75        PROTECTIVE BOOTS ON
definequote 76        SCUBA GEAR ON
definequote 77        SPACE SUIT ON
definequote 78        NUKE BOMB!!
definequote 79        BUY MAJOR STRYKER
definequote 80                      
definequote 81        WEAPON MODE ON
definequote 82        WEAPON MODE OFF
definequote 83        
definequote 84        
definequote 85        RUN MODE OFF
definequote 86        RUN MODE ON
definequote 87        RPG AKIMBO!
definequote 88        JET BOOTS
definequote 89        AIRTANK
definequote 90        STEROIDS
definequote 91        HOLODUKE
definequote 92        MUSIC: ON
definequote 93        MUSIC: OFF
definequote 94        SCROLL MODE: ON
definequote 95        SCROLL MODE: OFF
definequote 96        BRIGHTNESS LEVEL: SIX
definequote 97        BRIGHTNESS LEVEL: SEVEN
definequote 98        BRIGHTNESS LEVEL: EIGHT
definequote 99        REGISTER COSMO TODAY!
definequote 100       ALL LOCKS TOGGLED
definequote 101       NIGHT VISION GOGGLES
definequote 102       PAUL: OK, LET'S KICK SOME ALIEN ASSES!
definequote 103       SCREEN SAVED
definequote 104       GOT USED ARMOR
definequote 105       PIRATES SUCK!
definequote 106       NIGHT VISION ON
definequote 107       NIGHT VISION OFF
definequote 108       YOU'RE BURNING!  
definequote 109       VIEW MODE OFF
definequote 110       VIEW MODE ON
definequote 111       SHOW MAP: ON
definequote 112       CLIPPING: ON
definequote 113       CLIPPING: OFF
definequote 114       !!! INCORRECT VERSION !!!
definequote 115       <Please Leave Blank>
definequote 116       <Please Leave Blank>
definequote 117       <Please Leave Blank>
definequote 118       YOU CAN NOT "QUICK SAVE" WHEN DEAD
definequote 119       ALL WEAPONS/AMMO
definequote 120       ALL INVENTORY
definequote 121       ALL KEYS
definequote 122       AUTOMAG!
definequote 123       SOMEONE FELL TO DEATH!
definequote 124       TELEPORT DEVICE DESTROYED!!!!
definequote 128       
definequote 129       
definequote 130       
definequote 133       
definequote 134       
definequote 150       
definequote 151       
definequote 152       
definequote 153       
definequote 155       PAUL: WAIT, I'LL DEACTIVATE THE SECURITY
definequote 156       RADIOACTIVE DANGER!
definequote 157       GET YELLOW AND BLUE CARDS BEFORE EXITING



// Level file names cannot excede 13 characters.
// Level par cannot excede 5 characters (min:sec)
// Level titles cannot excede 32 characters.

definevolumename 0 CHEMICAL ASSAULT
definevolumename 1 THE ANCIENT WORLD
definevolumename 2 NEW MADRID CITY

defineskillname 0 FOR GRANDMAS
defineskillname 1 FOR MEN
defineskillname 2 FOR SADICS
defineskillname 3 FOR KILLERS!

definelevelname 0 0 c1a1.map 04:45 02:02 THE INFILTRATION
definelevelname 0 1 c1a2.map 04:10 02:01 STORAGE FACILITY
definelevelname 0 2 c1a3.map 07:35 04:20 CHEMICAL LABS
definelevelname 0 3 c1a4.map 07:20 04:41 SURFACE ACCESS
definelevelname 0 4 c1a5.map 04:10 02:21 THE CANYON
definelevelname 0 5 c1a6.map 03:15 01:50 THE SECRET BASE
definelevelname 0 7 E1L8.map 00:00 00:00 USER MAP

definelevelname 1 0 c2a1.map 02:30 01:19 THE ANCIENT VILLAGE
definelevelname 1 1 c2a2.map 02:30 01:26 MEDIEVAL RUINS
definelevelname 1 2 c2a3.map 05:00 02:26 THE HIDDEN CATHEDRAL
definelevelname 1 3 c2a4.map 04:30 02:14 TEMPLE OF THE GODS
definelevelname 1 4 c2a5.map 03:00 01:26 STORMY NIGHT
definelevelname 1 5 c2a6.map 02:30 01:04 THE TELEPORT DEVICE

definelevelname 2 0 c3a1.map 02:30 01:11 DARK STREETS
definelevelname 2 1 c3a2.map 04:45 02:18 THE JAIL
definelevelname 2 2 c3a3.map 03:00 01:57 THE NEW RETIRO
definelevelname 2 3 c3a4.map 03:15 01:46 OUTSKIRTS
definelevelname 2 4 c3a5.map 02:30 01:04 THE SEWAGE SYSTEM
definelevelname 2 5 c3a6.map 03:30 01:30 FINAL SHOWDOWN
definelevelname 2 6 MPARENA1.map 02:00 00:55 MULTIPLAYER ARENA 1
definelevelname 2 7 E3L8.map 02:15 01:09 MULTIPLAYER ARENA 2
definelevelname 2 8 C1A6.map 02:45 01:17 MULTIPLAYER ARENA 3
definelevelname 2 9 E3L10.map 00:45 00:10 MULTIPLAYER ARENA 4
definelevelname 2 10 E3L11.map 02:00 01:07 MULTIPLAYER ARENA 5

// Music will not play if the .MID file excedes 72000 bytes.

// If you are an owner of a Gravis Ultrasound and wish to change the
// MIDI files, you may want to delete the ULTRAMID.INI file that we
// supply since it does not contain a full General MIDI patch set.
// Deleting the ULTRAMID.INI will cause the game to use the file found
// in your Ultrasound directory.  Remember to keep a backup of ours,
// or the music might not sound as good!
// I use "none" to silence music in a level.

// Music for title and end
music 0 FASTWAY.MID ITSGREEN.MID

// Music for the individual levels
music 1 music/missimp.ogg music/dam.ogg music/ahgeez.ogg music/runw.ogg music/base.ogg
        music/cradle.ogg music/ahgeez.ogg dethtoll.mid streets.mid watrwld1.mid snake1.mid

music 2 music/cblood2.ogg music/cod.ogg music/cblood7.ogg music/cblood5.ogg music/cblood1.ogg 
        music/portal.ogg alienz.mid xplasma.mid alfredh.mid gloomy.mid intents.mid

music 3 ktulu.mid unforgiv.mid none none music/cblood10.ogg LiveDie.mid
        233c.mid lordofla.mid urban.mid spook.mid whomp.mid

/*
--------------------------------------------------------------------------------
ABOUT CHANGING SOUND FX

þ Duke may have up to 348 different sounds, currently there
  are aprox. 254 slots used.

The sound fx section follows this explanation.  

1. The program expects to find any sound file that is in a
   .VOC or .WAV file format.
2. You can either change the VOC name listed below to match your new
   sound, or you can rename your file to match the name here.
3. New sound files should be added to the game directory.  Though
   all sound files shipped with the game are included inside the 
   .GRP file, the program will know if there are sound files outside
   the .GRP file, and will use them instead.
4. The numbers that are to the right of the sound file name are technical
   parameters which will not be explained here, except as follows...
   - The first 2 numbers define a random pitch variation range.  They
     can be positive or negative numbers.
   - The 3rd number is a priority flag.
   - The 4th number is a bit parsed set of technical variables that identify
     the type of sound it is in the game.
   - The 5th number is volume adjustment.

--------------------------------------------------------------------------------
*/

// *****************************************
//      ACTOR SOUNDS
// *****************************************

// Predator Trooper
definesound PRED_ROAM     hg_taunt.wav          0   0   3   0   0
definesound PRED_ROAM2    hg_throw.wav          0   0   3   0   0
definesound PRED_RECOG    hg_alert.wav          0   0   3   0   0
definesound PRED_ATTACK   guncock.wav           0   0   3   0   0
definesound PRED_PAIN     hg_cover.wav          0   0   3   0   0
definesound SOLDIER_1     ba_pain2.wav          0   0   3   0   0
definesound PRED_DYING    ba_pain3.wav          0   0   3   0   0
definesound LIZARD_BEG    hg_alert.wav          0   0   3   0   0
                                             
// Lizard Captain                                                                       
definesound CAPT_ROAM     infidle1.wav          0   0  3   0   0
definesound CAPT_RECOG    infsght1.wav        0  0   3   0   0
definesound CAPT_ATTACK   infatck1.wav      0     0    3   0   -200
definesound CAPT_PAIN     infpain1.wav        0  0 3   0   0
definesound CAPT_DYING    infdeth2.wav        0  0 3   0   0
definesound LIZARD_SPIT   lizspit.voc         0   0   0   0   0

// Pig Cop
definesound PIG_ROAM      solsrch1.wav           0 0   3   0   0
definesound PIG_ROAM2     solsrch1.wav           0 0   3   0   0
definesound PIG_ROAM3     solsrch1.wav            0 0   3   0   0
definesound PIG_RECOG     solsght1.wav           0 0   3   0   0
definesound PIG_ATTACK    guncock.wav        0  0  4   0   0
definesound PIG_PAIN      solpain2.wav            0 0   3   0   0
definesound PIG_DYING     soldeth2.wav           0 0   3   0   0
definesound PIG_CAPTURE_DUKE schldy.wav           0   0   255 8   0

// Recon car
definesound COMM_RECOG    hg_alert.wav           0   0   3   0   0

// Octabrain
definesound OCTA_ROAM     gargspot.voc          0   0    3   0   0
definesound OCTA_RECOG    gargroam.voc             0   0    3   0   0
definesound OCTA_ATTACK1  gargspot.voc            0   0    3   0   0
definesound OCTA_ATTACK2  gargclaw.voc            0   600  3   0   0
definesound OCTA_PAIN     gargpain.voc          0   0    3   0   0
definesound OCTA_DYING    gargdie2.voc          0   0 3   0   0
definesound WIERDSHOT_FLY octaat1.voc            0   0    3   0   0

// Organic turret
definesound TURR_ROAM     gar_idle.wav             0   0   3   0   0
definesound TURR_RECOG    gar_alrt.wav             0   0   3   0   0
definesound TURR_ATTACK   gar_atck.wav             0   0   3   0   0
definesound TURR_PAIN     gar_pain.wav             0   0   3   0   0
definesound TURR_DYING    gar_die.wav             0   0   3   0   0

// Green slimer
definesound SLIM_HATCH    gar_step.wav             0   0   3   0   0
definesound SLIM_ROAM     heattack.wav             0   0   3   0   0
definesound SLIM_RECOG    heroam.wav             0   0   3   0   0
definesound SLIM_ATTACK   hepain.wav             0   0   3   0   0
definesound SLIM_DYING    hedie.wav             0   0   3   0   0

// BOSS2
definesound BOS2_ROAM     gunsrch1.wav             0   0   3   0   0
definesound BOS2_RECOG    sight1.wav             0   0   3   0   0
definesound BOS2_ATTACK   gunidle1.wav             0   0   3   0   0
definesound BOS2_PAIN     gunpain1.wav             0   0   3   0   0
definesound BOS2_DYING    death1.wav             0   0   3   0   0

// BOSS3                                                                                
definesound BOS3_ROAM     cultroa1.voc             0   0   3   0   0
definesound BOS3_RECOG    cultreco.voc             0   0   3   0   0
definesound BOS3_ATTACK1  saw_fir4.voc             0   0   3   0   0
definesound BOS3_ATTACK2  cultroa2.voc             0   0   3   0   0
definesound BOS3_PAIN     cultpain.voc             0   0   3   0   0
definesound BOS3_DYING    cultdead.voc             0   0   3   0   0


// BOSS1                                                                                
definesound BOS1_ROAM     bos1rm.voc             0   0   3   0   0
definesound BOS1_RECOG    sight2.wav             0   0   5   0   0
definesound BOS1_ATTACK1  chaingun.voc           0   0   3   0   0
definesound BOS1_ATTACK2  rocket.wav            0   0   3   0   0
definesound BOS1_PAIN     bos1pn.voc             0   0   3   0   0
definesound BOS1_DYING    bos1dy.voc             0   0   3   0   0
definesound BOS1_WALK     thud.voc               0   0   3   0   0


// *************
// WEAPON SOUNDS                                                                        
// *************
definesound KICK_HIT            kick.wav       0     0     4   0   0
definesound PISTOL_RICOCHET     ricochet.voc      0     0     0   0 4096
definesound PISTOL_BODYHIT      blltht1.wav      0     0     0   0   0
definesound PISTOL_FIRE         amshot.wav           0     0   254   0   0
definesound EJECT_CLIP          clipout.voc       0     0     3   0   0
definesound INSERT_CLIP         clipin.voc        512   512   3   0   0
definesound CHAINGUN_FIRE       ak3.voc          0   0  254   0   512
definesound SHOTGUN_FIRE        sshot.wav      0    0    254 0   0
definesound SHOTGUN_COCK        null.voc      96    192   3   0   0
definesound RPG_SHOOT           rocket.wav       -32   0     4   0   0
definesound FLY_BY              flyby.voc         -256  256   3   0   0
definesound RPG_EXPLODE         bombexpl.voc      -512 0  254 0   0
definesound CAT_FIRE            dk5.wav       0   0   4   0   0
definesound SHRINKER_FIRE       rocket.wav      0  0     4   0   0
definesound ACTOR_SHRINKING     shrink.voc        0     0     2   0   0
definesound PIPEBOMB_BOUNCE     pbombbnc.voc      0     0     2   0 6144
definesound PIPEBOMB_EXPLODE    bombexpl.voc  -512      0     128 0   0
definesound LASERTRIP_ONWALL    lsrbmbpt.voc      0     0     3   0   0
definesound LASERTRIP_ARMING    lsrbmbwn.voc      0     0     3   0   0
definesound LASERTRIP_EXPLODE   bombexpl.voc  -512      0     4   0   0
definesound NITEVISION_ONOFF    goggle12.voc      0     0     0   0   0
definesound SELECT_WEAPON       gunchang.VOC      128   128   3   0   0

// Affect Environment Sounds                                                            
definesound VENT_BUST           ventbust.voc      -32   32 2  0  0
definesound GLASS_BREAKING      glass.voc         -412  0  3  0  8192
definesound GLASS_HEAVYBREAK    glashevy.voc      -412  0  3  0  8192
definesound SHORT_CIRCUIT       shorted.voc       0 0 0 0 6500
definesound ITEM_SPLASH         splash.voc        0 0 2 0 0
definesound BONUSMUSIC          bonus.voc         0 0 255 3 0

// Duke's Body Sounds                                                                   
definesound DUKE_BREATHING      hlminhal.voc       0   0   255 4   0
definesound DUKE_EXHALING       hlmexhal.voc       0   0   255 4   0
definesound DUKE_GASP           bdeath1.wav           0   0   255 4   0
definesound DUKE_URINATE        pissing.voc        0   0   4   0   0
definesound DUKE_CRACK2         whsyrddd.wav       0   0   255 4   0
definesound DUKE_CRACK          whsyrddd.wav       0   0   255 4   0
definesound DUKE_TALKTOBOSSFALL gunsrch1.wav       0   0   255 12  0
definesound DUKE_CRACK_FIRST    knuckle.voc        0   0   3   0   0
definesound DUKE_GET            pickammo.voc     -64  64   255 0   0
definesound DUKE_GETWEAPON1     harry.wav         0   0   255 4   0
definesound DUKE_GETWEAPON2     rcknrll2.wav       0   0   255 4   0
definesound DUKE_GETWEAPON3     harry.wav       0   0   255 4   0
definesound DUKE_GETWEAPON4     rcknrll2.wav       0   0   255 4   0
definesound JIBBED_ACTOR13      gtthrt.wav       0   0   255 4   0
definesound DUKE_GETWEAPON6     pickwepn.voc         0   0   255 4   0
definesound DUKE_GOTHEALTHATLOW medkit01.voc       0   0   255 4   0

definesound DUKE_SEARCH         fall1.wav       0   0   2   4     0
definesound DUKE_SEARCH2        getbent.wav       0   0   255 4   0
definesound DUKE_LONGTERM_PAIN  pain16.wav     0   0   255 4   0
definesound DUKE_LONGTERM_PAIN2 pain2.wav      0   0   255 4   0
definesound DUKE_LONGTERM_PAIN3 pain3.wav      0   0   255 4   0
definesound DUKE_LONGTERM_PAIN4 scream1.wav      0   0   255 4   0
definesound DUKE_LONGTERM_PAIN5 pain5.wav        0   0   255 4   0
definesound DUKE_LONGTERM_PAIN6 pain6.wav        0   0   255 4   0
definesound DUKE_LONGTERM_PAIN7 pain16.wav        0   0   255 4   0
definesound DUKE_LONGTERM_PAIN8 scream1.wav        0   0   255 4   0

definesound DUKE_PISSRELIEF     flush.voc       0   0   255 4   0

// Duke Health Sounds
definesound SOMETHINGHITFORCE   teleport.voc       0   0    2   0   8192
definesound DUKE_DRINKING       drink18.voc        0   0   2   4   0
definesound DUKE_KILLED1        bdeath1.wav         0   0   255 12  0
definesound DUKE_KILLED2        bdeath1.wav       0   0   255 12  0
definesound DUKE_KILLED3        bdeath1.wav       0   0   255 12  0
definesound DUKE_KILLED4        bdeath1.wav       0   0   255 4   0
definesound DUKE_KILLED5        bdeath1.wav       0   0   255 12  0
definesound DUKE_GRUNT          pain3.wav          0   0   2   4   0
definesound DUKE_DEAD           bdeath1.wav      -64  64   255 4  0
definesound DUKE_HARTBEAT       hartbeat.voc       0   0   0   0   0
definesound DUKE_STEPONFECES    pain2.wav       0   0   0   12  0

// Duke Movement Sounds                                                                 
definesound DUKE_ONWATER        wetfeet.voc        0   0    4   0   0
definesound DUKE_LAND           land02.voc         0   0    2   0   0
definesound DUKE_LAND_HURT      fall3.wav         0   0    255 4   0
definesound DUKE_WALKINDUCTS    ductwlk.voc      -64   128  2   0   0
definesound DUKE_LOOKINTOMIRROR   lookin01.voc       0   0    255 12  0

definesound DUKE_TIP1           dance01.voc        0   0   255  4   0
definesound DUKE_TIP2           shake2a.voc        0   0   255  4   0
definesound DUKE_BOOBY          BOOBY04.voc        0   0   255  4   0
definesound DUKE_HIT_STRIPPER1  damnit04.voc       0   0   255  12  0
definesound DUKE_HIT_STRIPPER2  damn03.voc         0   0   255  12  0
definesound ALIEN_TALK1         MUSTDIE.voc        0   0   255  12  0
definesound ALIEN_TALK2         DEFEATED.VOC       0   0   255  12  0
definesound BONUS_SPEECH1       harry.wav       0   0   255  4   0
definesound BONUS_SPEECH2       harry.wav        0   0   255  4   0
definesound BONUS_SPEECH3       rcknrll2.wav        0   0   255  4   0
definesound BONUS_SPEECH4       rcknrll2.wav       0   0   255  4   0
definesound DUKE_YES            yes.voc            0   0   255  4   0
definesound DUKE_USEMEDKIT      medkit01.voc          0   0   255  4   0
definesound DUKE_TAKEPILLS      gulp01.voc         0   0   255  4   0
definesound DUKETALKTOBOSS      thud.wav       0   0   255  12  0
definesound BOSSTALKTODUKE      gravamb.voc         0   0   255  0   0
definesound SHRINKER_HIT        thud.voc           0   0   3    0   0
definesound SOMETHINGFROZE      freeze.voc         0   0   3    0   0

// Duke Equipment Sounds
definesound DUKE_UNDERWATER     scuba.voc          0   0   2   0   0
definesound DUKE_JETPACK_ON     jetpakon.voc       0   0   4   0   0
definesound DUKE_JETPACK_IDLE   jetpaki.voc        0   0   1   0   0
definesound DUKE_JETPACK_OFF    jetpakof.voc       0   0   2   0   0

// Common Death Sounds
definesound FLESH_BURNING       fire09.voc      -256   0   0   0   6100
definesound THUD                thud.voc           0   0   0   0   0
definesound SQUISHED            gib1.wav         0   0   3   0   0

// Equipment Sounds                                                                     
definesound TELEPORTER          teleport.voc       0   0   0   0   0
definesound ELEVATOR_ON         gbelev01.voc       0   0   0   0   0
definesound ELEVATOR_OFF        gbelev02.voc       0   0   0   0   0
definesound ALIEN_ELEVATOR1     hydro43.voc        0   0   0   0   0
definesound SUBWAY              subway.voc         0   0   0   0   0
definesound SWITCH_ON           switch.voc         0   0   0   0   0

definesound FAN                 fan.voc            0   0   0   0   0
definesound FLUSH_TOILET        flush.voc          0   0   3   2   0
definesound HOVER_CRAFT         hover.voc          0   0   0   0   0
definesound EARTHQUAKE          quake.voc          0   0   0   0   0
                                                                                        
// Warning Sounds                                                                       
definesound INTRUDER_ALERT      alert.voc          0   0   0   0   0
definesound END_OF_LEVEL_WARN   monitor.voc        0   0   0   0   0
definesound POOLBALLHIT         poolbal1.voc       0   0   0   0   0

// Ambience Sounds

definesound ENGINE_OPERATING    onboard.voc        0   0   0   2   0
definesound REACTOR_ON          reactor.voc        0   0   0   2   0
definesound COMPUTER_AMBIENCE   compamb.voc        0   0   0   2   0
definesound GEARS_GRINDING      geargrnd.voc       0   0   0   2   0
definesound BUBBLE_AMBIENCE     bubblamb.voc    -256   0   0   2   0
definesound MACHINE_AMBIENCE    machamb.voc        0   0   0   2   0
definesound SEWER_AMBIENCE      drip3.voc          0   0   0   0   0
definesound WIND_AMBIENCE       wind54.voc         0   0   0   2   0
definesound WIND_REPEAT         wind54.voc         0   0   0   3   0

definesound SOMETHING_DRIPPING  drip3.voc       0   0   0   0    9000
definesound STEAM_HISSING       steamhis.voc       0   0   0   1   8192
definesound BAR_MUSIC           barmusic.voc       0   0 254   3   0
definesound DUKE_SCREAM         scream1.wav       0   0 255   0   0
definesound KILLME              killme.voc      -128   0   0   0   0

// Miscellaneous Sounds

definesound GETATOMICHEALTH     teleport.voc   2048 2048   255 0   0
definesound DOOR_OPERATE1       slidoor.voc     -256   0   0   0   0
definesound DOOR_OPERATE2       dr_crk8.voc    0   0   0   0   0
definesound DOOR_OPERATE3       edoor10.voc     -256   0   0   0   0
definesound DOOR_OPERATE4       edoor11.voc     -256   0   0   0   0
definesound KTIT                ktitx.voc         0   0 254   2   0
definesound MONITOR_ACTIVE      monitor.voc        0   0   0   0   0
definesound WATER_GURGLE        h2ogrgl2.voc       0   0   1   2   9000
definesound EXITMENUSOUND       item15.voc         0   0   0   0   0
definesound RATTY               mice3.voc          0   0   0   0   0
definesound INTO_MENU           bulithit.voc    1024 1024  0   0   0

// Six misc ambience city sounds

definesound GENERIC_AMBIENCE1      grind.voc       0   0   0   1   0
definesound GENERIC_AMBIENCE2      enghum.voc      0   0   0   2   0
definesound GENERIC_AMBIENCE3      gravamb.voc      0   0   0   2   0
definesound GENERIC_AMBIENCE4      bubblamb.voc -256   0   0   2   0
definesound GENERIC_AMBIENCE5      phonbusy.voc    0   0   0   0   0
definesound GENERIC_AMBIENCE6      roam22.voc      0   0   0   2   0
definesound SECRETLEVELSND         secret.voc      0   0   255 0   0
definesound GENERIC_AMBIENCE8      amb81b.voc      0   0   0   2   0
definesound GENERIC_AMBIENCE9      roam98b.voc     0   0   0   2   0
definesound GENERIC_AMBIENCE10     h2orush2.voc    0   0   0   3   0
definesound GENERIC_AMBIENCE11     projrun.voc     0   0   0   3   0
definesound GENERIC_AMBIENCE12     blank.voc       0   0   0   0   0
definesound GENERIC_AMBIENCE13     goc.voc         0   0   255 0   0
definesound GENERIC_AMBIENCE14     ctaunt1.voc     0   0   255 0   0
definesound GENERIC_AMBIENCE15     ctaunt2.voc     0   0   255 0   0
definesound GENERIC_AMBIENCE16     saw_fir3.voc    0   0   128 0   0
definesound GENERIC_AMBIENCE17     _tom.voc        0   0   255 0   0
definesound GENERIC_AMBIENCE18     monolith.voc    0   0   0   2   0
definesound GENERIC_AMBIENCE19     hydro50.voc     0   0   0   2   0
definesound GENERIC_AMBIENCE20     con03.voc       0   0   0   4   0
definesound GENERIC_AMBIENCE21     cf.voc          0   0   255 0   0
definesound GENERIC_AMBIENCE22     mmf.voc         0   0   255 0   0
definesound GENERIC_AMBIENCE23     cdead2.voc      0   0   255 0   0

definesound FIRE_CRACKLE           fire09.voc       0   0   254 2   0


definesound JIBBED_ACTOR1       harry.wav       0   0   255 4   0
definesound JIBBED_ACTOR2       gtthrt.wav      0   0   255 12  0
definesound JIBBED_ACTOR3       rcknrll2.wav      0   0   255 4   0
definesound JIBBED_ACTOR4       bang.wav      0   0   255 12  0
definesound JIBBED_ACTOR5       lkthh!.wav      0   0   255 12  0
definesound JIBBED_ACTOR6       rcknrll.wav       0   0   255 4   0
definesound JIBBED_ACTOR7       fuckyou.wav      0   0   255 4   0
definesound JIBBED_ACTOR8       rstnpcs.wav      0   0   255 12  0
definesound JIBBED_ACTOR9       mess.wav      0   0   255 12  0
definesound JIBBED_ACTOR10      bestugot.wav        0   0   255 12  0
definesound JIBBED_ACTOR11      trynw1.wav      0   0   255 12  0
definesound WHIPYOURASS         gunsrch1.wav      0   0   255 4   0
definesound JIBBED_ACTOR12      brngon.wav      0   0   255 4   0


definesound SPACE_DOOR1      hydro22.voc      0   0   0    0   8192
definesound SPACE_DOOR2      hydro24.voc      0   0   0    0   0
definesound SPACE_DOOR3      hydro27.voc      0   0   0    0   8192
definesound SPACE_DOOR4      hydro34.voc      0   0   0    0   0
definesound SPACE_DOOR5      hydro40.voc      0   0   0    0   0

 definesound SPACE_AMBIENCE1   monolith.voc      0   0   0  16  0
 definesound SPACE_AMBIENCE2   hydro50.voc       0   0   0  16  0
 definesound VAULT_DOOR        vault04.voc      0   0   0   0   0

definesound ALIEN_ELEVATOR1   hydro43.voc       0   0   0  0   0
definesound ALIEN_DOOR1       adoor1.voc        0   0   0  0   0
definesound ALIEN_DOOR2       adoor2.voc        0   0   0  0   0

definesound ALIEN_SWITCH1     aswtch23.voc      0   0   0  0   0
definesound COMPANB2          CTRLRM25.VOC  0  0  0  2   0
definesound HELICOP_IDLE      hlidle03.voc  0  0  255  3   0
definesound FOUNDJONES        jones04.voc   0  0  0  4  0
definesound STEPNIT           LIZSHIT3.VOC  0  0  254  12  0
definesound RIPHEADNECK       cultroa1.voc     0  0  254  12 0

definesound ENDSEQVOL2SND1    null.voc     0   0   249 0   0
definesound ENDSEQVOL2SND2    null.VOC    0   0   250 0   0
definesound ENDSEQVOL2SND3    null.VOC      0   0   251 0   0
definesound ENDSEQVOL2SND4    null.VOC       0   0   252 0   0
definesound ENDSEQVOL2SND5    null.voc     0   0   253 0   0
definesound ENDSEQVOL2SND6    null.voc        0   0   254 0   0
definesound ENDSEQVOL2SND7    null.voc     0   0   255 0   0

definesound ENDSEQVOL3SND1    null.VOC    0   0   254 0   0
definesound ENDSEQVOL3SND2    null.VOC    0   0   254 0   0
definesound ENDSEQVOL3SND3    null.VOC       0   0   254 0   0
definesound ENDSEQVOL3SND4    GRABBAG.VOC     0   0   254 1   0
definesound ENDSEQVOL3SND5    bonus.voc      0   0   250 0   0
definesound ENDSEQVOL3SND6    null.voc       0   0   251 0   0
definesound ENDSEQVOL3SND7    null.voc      0   0   252 0   0
definesound ENDSEQVOL3SND8    null.voc      0   0   253 0   0
definesound ENDSEQVOL3SND9    null.voc    0   0   254 0   0

// Misc FUSION TC sounds

definesound BR_ROAM1          br_roam1.voc    0   0   0   0   0
definesound BR_ROAM2          br_roam2.voc    0   0   0   0   0
definesound BR_PAIN           br_pain.voc     0   0   0   0   0
definesound BR_DIE            br_die.voc      0   0   0   0   0
definesound ALARM1            warn1.wav       0   0   0   2   0
definesound ALARM2            bizwarn.wav     0   0   0   2   0
definesound ALARM3            warn3.wav       0   0   0   2   0
definesound FANMOVING         fan4.wav        0   0   0   2   0
definesound MED_CHARGE        medcharg.wav    0   0   0   0   0
definesound ARMOR_CHARGE      armcharg.wav    0   0   0   0   0
definesound NA_0              na0.wav         0   0   254 2   0
definesound BORNTOBEWILDSND   na9.wav         0   0   254 2   0
definesound BIGTHUNDER        bthunder.voc    0   0   255 0   0
definesound BLOOD_WIND        bwind.voc       0   0   0   2   0
definesound RAINING           rain1.voc       0   0   0   2   0    
definesound THEDRIPS          bdrips.voc      0   0   0   2   0
definesound GRAVAMB           gravamb.voc     0   0   0   2   0
definesound CNTAMB            cntamb.voc      0   0   0   2   0
definesound DR_ROLL           dr_roll.voc    -256 0   0   0   0
definesound JUKEBOX           jukebox.voc     0   0   0   2   0
definesound CASUL_FIRE        pistola.voc     0   0   0   0   0
definesound CT_PAIN           ct_pain.voc     0   0   0   0   0
definesound CT_DIE            ct_die.voc      0   0   0   0   0
definesound CT_LAF            ct_laf.voc      0   0   0   0   0
definesound CT_LAND           ct_land.voc     0   0   0   0   0
definesound CT_GET            ct_get.voc      0   0   0   0   0
definesound BR_RECOG          br_recog.voc    0   0   0   0   0
definesound THUNDER1          thunder1.voc    0   0   0   0   0
definesound THUNDER2          thunder2.voc    0   0   0   0   0
definesound THUNDER3          thunder3.voc    0   0   0   0   0
definesound PAUL_SECURITY     paulend.voc     0   0   0   0   0
definesound RUSTYBRIDGE       sbridge2.wav    0   0   0   2   0
definesound BATZ              bats.wav        0   0   0   2   0
definesound SWAMP1            swmp10.wav      0   0   0   2   0
definesound SWAMP2            swmp8.wav       0   0   0   2   0
definesound HG_ROAM           fight!.wav      0   0   0   0   0     
definesound HG_ALERT          CHARLIE!.wav    0   0   0   0   0     
definesound HG_PAIN           all!.wav        0   0   0   0   0     
definesound SLV_RECOG         slvalert.wav    0   0   0   0   0     
definesound SLV_PAIN          slv_pain.wav    0   0   0   0   0     
definesound SLV_ROAM          slv_word.wav    0   0   0   0   0
definesound HC_ALERT          hcalert.wav     0   0   0   0   0
definesound HC_ATTACK         hcattack.wav    0   0   0   0   0
definesound HC_PAIN           hcpain.wav      0   0   0   0   0
definesound DEMON_SIGHT       sight2.wav      0   0   0   0   0
definesound DEMON_JUMP        djump.wav       0   0   0   0   0
definesound DEMON_IDLE        idle1.wav       0   0   0   0   0
definesound DEMON_EVISCERATE  dhit2.wav       0   0   0   0   0
definesound DEMON_PAIN        dpain1.wav      0   0   0   0   0
definesound DEMON_DEATH       ddeath.wav      0   0   0   0   0
definesound JOHN_JUMP         jump1.wav       0   0   255 0   0
definesound JOHN_JUMP2        jump2.wav       0   0   255 0   0
definesound BARNEYBEFOREOPEN1 ba_talk1.wav    0   0   255 0   0
definesound BEEPSWITCH1       blip1.wav       0   0   255 0   0
definesound BARNEYFALL        bafall.wav      0   0   255 0   0
definesound CANTSTAYHEREMORE  nomas.wav       0   0   255 0   0

// Skaarj Trooper

definesound DRON_ROAM     roam11s.wav             0   0   3   0   0
definesound DRON_RECOG    chalnge1.wav             0   0   3   0   0
definesound DRON_ATTACK1  skrjshot.wav            0   0   3   0   0
definesound DRON_ATTACK2  sroam1.wav           0   0   3   0   0
definesound DRON_PAIN     injur2sk.wav             0   0   3   0   0
definesound DRON_DYING    death1sk.wav             0   0   3   0   0
definesound DRON_JETSND   ENGHUM.VOC             1300 1300 0   0   0

// misc

definesound FLASHLIGHT    flashl.wav       0 0 255 0 0

definesound HITMETAL              HMETAL.wav   128 -128 1 0 0
definesound HITMETAL2             HMETAL2.wav  128 -128 1 0 0
definesound HITMETAL3             HMETAL3.wav  128 -128 1 0 0
definesound HITMETAL4             HMETAL4.wav  128 -128 1 0 0
definesound HITWOOD               HWOOD.wav   256 -256 1 0 4000

// Step sounds

definesound JOHNSTEP          step1.wav      -164 164 220 0   0  
definesound JOHNSTEP2         step2.wav     -164 164 220 0   0

definesound DIRT_STEP  dirt1.wav      -164 164 220 0   0  
definesound DIRT_STEP2  dirt2.wav      -164 164 220 0   0  
definesound GRASS_STEP  g1.wav      -164 164 220 0   0  
definesound GRASS_STEP2  g2.wav      -164 164 220 0   0  
definesound GRATE_STEP grstep1.wav      -164 164 220 0   0  
definesound GRATE_STEP2  grstep2.wav      -164 164 220 0   0  
definesound GRAVEL_STEP  gstp1.wav      -164 164 220 0   0  
definesound GRAVEL_STEP2  gstp2.wav      -164 164 220 0   0  
definesound METAL_STEP  mstep1.wav      -164 164 220 0   0  
definesound METAL_STEP2 mstep2.wav      -164 164 220 0   0  
definesound METAL_STEP3  mstep3.wav      -164 164 220 0   0  
definesound METAL_STEP4  mstep4.wav      -164 164 220 0   0  
definesound VENT_STEP  vent1.wav      -164 164 220 0   0  
definesound VENT_STEP2 vent2.wav      -164 164 220 0   0  
definesound WATER_STEP wastep1.wav      -164 164 220 0   0  
definesound WATER_STEP2  wastep2.wav      -164 164 220 0   0  
definesound WOOD_STEP     wstep1.wav       -164 164 200 0  0
definesound WOOD_STEP2    wstep2.wav       -164 164 200 0  0

onevent EVENT_GAME
getactor[THISACTOR].picnum PICNUM

switch PICNUM
case 2000
case 2001
	setactor[THISACTOR].xrepeat 20 
	setactor[THISACTOR].yrepeat 17 
	break
case 1680
	setactor[THISACTOR].xrepeat 20
	setactor[THISACTOR].yrepeat 20
	break
case SHARK
	ifspritepal 5 { setactor[THISACTOR].xrepeat 27 setactor[THISACTOR].yrepeat 27 } else
	{ setactor[THISACTOR].xrepeat 21 setactor[THISACTOR].yrepeat 21 }
	break
case FIREVASE setactor[THISACTOR].xrepeat 17 setactor[THISACTOR].yrepeat 17 break
case FEM1 setactor[THISACTOR].xrepeat 23 setactor[THISACTOR].yrepeat 23 break
case FEM4 setactor[THISACTOR].xrepeat 17 setactor[THISACTOR].yrepeat 17 break
case FEM7 setactor[THISACTOR].xrepeat 14 setactor[THISACTOR].yrepeat 13 break
case LIZMANSTAYPUT setactor[THISACTOR].xrepeat 22 setactor[THISACTOR].yrepeat 19 break
case LIZMAN setactor[THISACTOR].xrepeat 22 setactor[THISACTOR].yrepeat 19 break
case DRONE setactor[THISACTOR].xrepeat 27 setactor[THISACTOR].yrepeat 22 break
case BOSS1 setactor[THISACTOR].xrepeat 23 setactor[THISACTOR].yrepeat 23 break
case BOSS1STAYPUT setactor[THISACTOR].xrepeat 23 setactor[THISACTOR].yrepeat 23 break
case BOSS2 setactor[THISACTOR].xrepeat 22 setactor[THISACTOR].yrepeat 19 break
case BOSS3 setactor[THISACTOR].xrepeat 28 setactor[THISACTOR].yrepeat 28 break
case COMMANDER setactor[THISACTOR].xrepeat 17 setactor[THISACTOR].yrepeat 17 break
endswitch

endevent


state sangre guts  JIBS6 5  guts JIBS5 5 ifrnd 5 spawn BLOOD ends

state jib_sounds
        ifrnd 16 globalsound JIBBED_ACTOR1
        else ifrnd 16 globalsound JIBBED_ACTOR2
        else ifrnd 16 globalsound JIBBED_ACTOR3
        else ifrnd 16 globalsound JIBBED_ACTOR5
        else ifrnd 16 globalsound JIBBED_ACTOR6
        else ifrnd 16 globalsound JIBBED_ACTOR10
        else ifrnd 16 globalsound JIBBED_ACTOR7
        else ifrnd 16 globalsound JIBBED_ACTOR4
        else ifrnd 16 globalsound JIBBED_ACTOR8
        else ifrnd 16 globalsound JIBBED_ACTOR13
        else ifrnd 16 globalsound JIBBED_ACTOR9
        else ifrnd 16 globalsound JIBBED_ACTOR11
        else ifrnd 16 globalsound JIBBED_ACTOR12
   
ends

state random_wall_jibs
    ifrnd 96 shoot BLOODSPLAT1
    ifrnd 96 shoot BLOODSPLAT2
    ifrnd 96 shoot BLOODSPLAT3
    ifrnd 96 shoot BLOODSPLAT4
    ifrnd 96 shoot BLOODSPLAT1
ends
state paul_jibs
    ifmultiplayer
    {
    guts JIBS2 2
    guts JIBS3 3
    guts JIBS4 1
    guts JIBS5 6
    guts JIBS6 3
    guts JIBS1 2
    }
    else
    {
    guts JIBS2 2
    guts JIBS3 12
    guts JIBS4 1
    guts JIBS5 200
    guts JIBS6 16
    guts JIBS1 2
    }
    ifactor NUKEBARREL { } else { spawn BLOODPOOL }

ends


state standard_jibs
    state paul_jibs
    state jib_sounds
ends



move STOPVEL

state checksquished
    ifsquished { addkills 1 sound SQUISHED state paul_jibs spawn OOZ killit }
ends

state genericpsychocode
    move STOPVEL
    spritepal 2
    ifactioncount 60 {
                                 
                 resetactioncount
                 soundonce SQUISHED
                 state standard_jibs
                 state standard_jibs
                 // addkills 1
                 killit
                 
                }
                else ifactioncount 50 { spritepal 1 }
                else ifactioncount 40 { spritepal 8 }
                else ifactioncount 30 { spritepal 2 }
                else ifactioncount 20 { spritepal 1 }
                else ifactioncount 10 { spritepal 8 }
ends






state genericshrunkcode
    ifcount 32 { ifpdistl SQUISHABLEDISTANCE pstomp }
    else { sizeto 9 8 spawn FRAMEEFFECT1 }
ends

move SHUTTLEVELS 16

gamevar CHARGE_AMOUNT 75 2

action ACTIVE 0
action OUT -1

actor SPACESHUTTLE TOUGH
        ifp palive ifpdistl 1024 ifp pfacing ifcount 3
            ifphealthl MAXPLAYERHEALTH ifhitspace ifcansee 
        {
			ifvarg CHARGE_AMOUNT 0
					{
		            soundonce MED_CHARGE
					subvar CHARGE_AMOUNT 1
		            addphealth 1
		            resetcount
					}
			else { action OUT soundonce NA_9 }
        }

enda

state SPAWN_IN_FRONT
		getactor[THISACTOR].x TEMP
		getactor[THISACTOR].y TEMP2
		setvarvar TEMP3 TEMP
		addvarvar TEMP3 distance
		getactor[THISACTOR].ang TEMP4
		rotatepoint TEMP TEMP2 TEMP3 TEMP2 TEMP4 TEMP5 TEMP6
		setactor[RETURN].x TEMP5 
		setactor[RETURN].y TEMP6
ends

state spawnlight
	getactor[THISACTOR].z TEMP
	subvarvar TEMP z_mod
	setactor[RETURN].z TEMP
	setactor[RETURN].lotag 49 
	setactor[RETURN].hitag light_radius 
	setactor[RETURN].shade 0
	setactor[RETURN].xvel red 
	setactor[RETURN].yvel green
	setactor[RETURN].zvel blue
	setactor[RETURN].picnum SECTOREFFECTOR
	changespritestat RETURN 3
	setvarvar light_id RETURN
ends

actor SATELLITE TOUGH
      ifspritepal 0
      {
	  ifaction 0 // Spawn a light
				{ 
				espawn SMALLSMOKE
				setvar distance 64
				state SPAWN_IN_FRONT
				setvar light_radius 512
				setvar red 0
				setvar green 250
				setvar blue 120
				state spawnlight
				action ACTIVE
				}
        ifp palive ifpdistl 1024 ifp pfacing ifcount 3
        ifhitspace ifcansee ifaction ACTIVE
		{
			ifvarg CHARGE_AMOUNT 0
	        {
	            soundonce ARMOR_CHARGE
	            addinventory GET_SHIELD 1
				subvar CHARGE_AMOUNT 1
	            resetcount
	        }
			else 
				{ 
				action OUT 
				setactor[light_id].xvel 200 
				setactor[light_id].yvel 0
				setactor[light_id].zvel 0
				soundonce NA_9  
				}
		}
      }
      else
      {
        ifp palive ifpdistl 1024
        {
            ifspritepal 10
            {
				action OUT
                soundonce NA_9
            }
        }
      }
enda

definegamefuncname 14 LIGHT

gamevar LIGHTON 0 2

gamevar FLASHLIGHT_ID 0 2

state torch_light
ifcount 13
{
ifvare LIGHTON 0 { sound FLASHLIGHT setvar LIGHTON 1 }
ifvare LIGHTON 2 { sound FLASHLIGHT setvar LIGHTON 3 }
resetcount
}
ends

state HOLD_LIGHT_INFRONT
ifvare LIGHTON 1
	{
	espawn SMALLSMOKE
	setactor[RETURN].lotag 50 
	setactor[RETURN].hitag 9000 
	setactor[RETURN].shade 0
	setactor[RETURN].xvel 230 
	setactor[RETURN].yvel 230
	setactor[RETURN].zvel 250
	setactor[RETURN].xrepeat 2
	setactor[RETURN].yrepeat 2
	setactor[RETURN].picnum SECTOREFFECTOR
	changespritestat RETURN 3
	setvarvar FLASHLIGHT_ID RETURN
	setvar LIGHTON 2
	}
else
ifvare LIGHTON 2
	{
		getplayer[THISACTOR].posx TEMP
		getplayer[THISACTOR].posy TEMP2
		setvarvar TEMP3 TEMP
		addvarvar TEMP3 128
		getactor[THISACTOR].ang TEMP4
		setactor[FLASHLIGHT_ID].ang TEMP4
		rotatepoint TEMP TEMP2 TEMP3 TEMP2 TEMP4 TEMP5 TEMP6
		setactor[FLASHLIGHT_ID].x TEMP5 
		setactor[FLASHLIGHT_ID].y TEMP6
		updatesector TEMP5 TEMP6 TEMP7
		ifvarn TEMP7 -1 setactor[FLASHLIGHT_ID].sectnum TEMP7
		getplayer[THISACTOR].posz TEMP7
		addvar TEMP7 512
		setactor[FLASHLIGHT_ID].z TEMP7
		getplayer[THISACTOR].horiz TEMP6
		setactor[FLASHLIGHT_ID].extra TEMP6
		setactor[FLASHLIGHT_ID].shade 0
	}
else
ifvare LIGHTON 3
	{
	setactor[FLASHLIGHT_ID].hitag 0 
	setactor[FLASHLIGHT_ID].picnum 77
	changespritestat FLASHLIGHT_ID 1
	setvar LIGHTON 0
	}
ends

useractor notenemy 77 killit enda

onevent EVENT_LOOKRIGHT // Light
setvar RETURN -1
state torch_light
endevent


action ACC_ON 1
action ACC_OFF 0

useractor notenemy 3543 // Access denied blinking sign

ifaction 0
	{
	espawn SMALLSMOKE
	setvar distance 256
	state SPAWN_IN_FRONT
	setvar light_radius 512
	setvar red 255
	setvar green 0
	setvar blue 0
	state spawnlight
	action ACC_OFF
	resetcount
	}

ifaction ACC_OFF
	ifcount 13
		{
		setactor[light_id].hitag 1024
		action ACC_ON
		resetcount
		}
else
ifaction ACC_ON
	ifcount 13
		{
		setactor[light_id].hitag 512
		action ACC_OFF
		resetcount
		}
		
enda

define TANKBOSSSTRENGTH 2000
define TANKSTRENGTH 480

action ATANKSTAND        0 1 1 1 1
action ATANKWALK        -1250 16 1 1 7
action ATANKSHOOT       -1233 12 1 1 7
action ATANKROCKETPREP   530 9 1 1 9
action ATANKSHOOTROCKET  538 2 1 1 13
action ATANKDYING        540 18 1 1 9
action ATANKDEAD         557 1 1 1 1

move TANKWALKSPEED 65
move TANKSTOP

ai AITANKWALK ATANKWALK TANKWALKSPEED seekplayer
ai AITANKSHOOT ATANKSHOOT TANKSTOP faceplayer
ai AITANKRPREP ATANKROCKETPREP TANKSTOP faceplayer
ai AITANKRSHOOT ATANKSHOOTROCKET TANKSTOP faceplayer
ai AITANKDYING ATANKDYING TANKSTOP faceplayer



state tseek
    ifcansee
    {
        ifrnd 10
        {
        ifcanshoottarget
        {
            ifpdistg 4906
            {
                ai AITANKRPREP
                break
            }
            else
            {
            ai AITANKSHOOT
            break
            }
        }
        }
    }
  
ends

state tankpreparerockets
    ifactioncount 9
    {
        resetactioncount
        ai AITANKRSHOOT
        break
    }
ends

state tankshootrockets
    ifactioncount 2
    {
        resetactioncount
        shoot RPG
        sound RPG_SHOOT
    }
    ifcount 30
    {
        resetcount
        ai AITANKWALK
        break
    }
ends

state tshoot
    ifactioncount 12
    {
        resetactioncount
        ai AITANKWALK
        break
    }
    else ifactioncount 4
    {
        shoot SHOTSPARK1
        sound CAPT_ATTACK
      
    }
ends

gamevar spawnaccess 0 2

state thit
    ifdead
    {
		ifspritepal 3 ifstrength 240 spritepal 10 else
		ifspritepal 5 ifstrength 500 spritepal 10
        state sangre
        debris SCRAP2 4
        ai AITANKDYING
		ifvare spawnaccess 1 spawn ACCESSCARD
		spritepal 9
    }
    else
    {
	setactor[THISACTOR].xvel 0
        state sangre
        debris SCRAP2 4
        state random_wall_jibs
    }
ends

state tdying
    ifactioncount 18 { resetactioncount action ATANKDEAD break }
ends

state tcode
    fall
    ifspritepal 5
    {
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    }
    else
    {
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    sizeto 21 21
    }
    ifaction ATANKSTAND { ifspritepal 0 { strength TANKSTRENGTH ai AITANKWALK break } 
	else ifspritepal 3 { strength TANKSTRENGTH ai AITANKWALK setvar spawnaccess 1 break } 
	else ifspritepal 5 { strength TANKBOSSSTRENGTH ai AITANKWALK setvar spawnaccess 1 break } }
    else ifaction ATANKDEAD
    {
      ifcount 150
        {
        resetcount
        cstat 32768
        killit
        break
        }
        else
    ifcount 125
      cstat 514
    else
  ifcount 100
    cstat 2
    }

    else ifai AITANKWALK state tseek
    else ifai AITANKSHOOT state tshoot
    else ifai AITANKRPREP state tankpreparerockets
    else ifai AITANKRSHOOT state tankshootrockets
    else ifai AITANKDYING state tdying
    ifhitweapon state thit  else state checksquished
ends

eventloadactor SHARK 
ifspritepal 5 setactor[THISACTOR].xrepeat 27 setactor[THISACTOR].yrepeat 27  else
setactor[THISACTOR].xrepeat 21 setactor[THISACTOR].yrepeat 21 
enda

actor SHARK TANKSTRENGTH ATANKSTAND state tcode enda

action APAULSTAND 635 1 1
action APAULTALK 635 2 1 1 16
action APAULBUTTONPUSH 637 2 5 1 15

move PAULSTOP




state paulcode

    

    ifaction APAULBUTTONPUSH
            {
            ifactioncount 38
                {
                resetactioncount
                spawn EXPLOSION2
                soundonce PIPEBOMB_EXPLODE
                hitradius 2048 140 100 60 10
                sound SQUISHED
                state paul_jibs
                state paul_jibs
                killit
                }
            }
       
    else ifaction APAULTALK
    {
            ifspritepal 0
            {
            ifpdistl 5000
                 {
                 quote 155
                 ifcount 190
                 {
                 soundonce PAUL_SECURITY                 
                 action APAULBUTTONPUSH
                 }
                 }
            }
            else ifspritepal 3 { }
    }


    else ifaction APAULSTAND
    {
        ifspritepal 0
        {
            {
               action APAULTALK break
            }
       }
       else ifspritepal 3 {  }


     }

ends

actor BLIMP 60 APAULSTAND state paulcode enda

state rats
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
    ifrnd 128 spawn RAT
ends

move RESPAWN_ACTOR_FLAG


actor RUBBERCAN 
    cstat 32800
    ifpdistl 2048 endofgame 52
    killit
enda

state headhitstate
wackplayer
ends


action EXPBARRELFRAME         0   2   1   1   15

action BURNING_FLAME    0   12   1   1   2
move BURNING_VELS 

state burningstate

    ifgapzl 16 break
    ifpdistg 10240 break

    ifcount 128
    {
        ifspawnedby TIRE
        {
            ifactioncount 512
            {
                sizeto 16 16
                killit
            }
            ifrnd 16 sizeto 64 48
        }
        else
        {
            sizeto 8 8 sizeto 8 8
            ifactioncount 192 killit
        }
    }
    else
    {
        ifmove 0 move BURNING_VELS

        ifspawnedby BOX
            { sizeto 32 32 ifcount 32 { spawn SMALLSMOKE killit } }
        else ifspawnedby TREE1 sizeto 96 96
        else ifspawnedby TREE2 sizeto 96 96
        else ifspawnedby APLAYER { sizeto 40 40 sizeto 40 40 }
        else sizeto 52 52
        ifp palive ifpdistl 844 ifrnd 32 ifcansee { soundonce DUKE_LONGTERM_PAIN addphealth -1 palfrom 24 16 }
    }

ends

actor BURNING WEAK BURNING_FLAME
    state burningstate
enda





action TOILETWATERFRAMES 0 4 1 1 1
actor TOILETWATER 0 TOILETWATERFRAMES
    ifpdistl 8192
    {
        soundonce WATER_GURGLE
        ifspawnedby TOILET sizeto 34 34
        else
        {
            ifspawnedby WATERFOUNTAINBROKE
                sizeto 6 15
            else ifspawnedby TOILETWATER { } else sizeto 24 32
        }

        ifp palive ifpdistl RETRIEVEDISTANCE ifp pfacing ifactioncount 32
            ifphealthl MAXPLAYERHEALTH ifhitspace ifcansee
        {
            addphealth 1
            globalsound DUKE_DRINKING
            resetactioncount
        }
    }
enda


action AZOMSTAND 1 1 1 1 1
action AZOMWALK 1066 6 1 1 8
action AZOMAXE 1078 7 1 1 8
action AZOMDYING 1072 6 1 1 7
action AZOMDEAD 1077 1 1 1 1

move ZOMWALKSPEED 208
move ZOMSTOP

ai AIZOMSEEK AZOMWALK ZOMWALKSPEED seekplayer
ai AIZOMAXE AZOMAXE ZOMSTOP faceplayer
ai AIZOMDYING AZOMDYING ZOMSTOP faceplayer

state zomseek
    ifcansee
    {
        ifp palive ifpdistl 1024
        {
            ai AIZOMAXE
            break
        }
    }
ends

state zomaxe
    ifactioncount 7
    {
        resetactioncount
        palfrom 32 32
        ifpinventory GET_SHIELD 3
            addphealth -10
        else ifpinventory GET_SHIELD 2
            addphealth -18
        else
            addphealth -35
    }
    ifpdistg 1024
    {
        ai AIZOMSEEK
        break
    }
ends

state zomdying
    ifactioncount 6
    {
        action AZOMDEAD
        cstat 0
        move 0
        break
    }
ends

state zomhit
    ifdead
    {
        ifwasweapon RPG
        {
            state paul_jibs
            sound SQUISHED
            killit
        }
        else ifwasweapon RADIUSEXPLOSION
        {
            state paul_jibs
            sound SQUISHED
            killit
        }
        else
        {
            cstat 0
            ai AIZOMDYING
            break
        }
    }
    else
    {
        guts JIBS6 5
        state random_wall_jibs
    }
ends

state zomcode
ends

define ZOMBIESTRENGTH 70

actor WOODENHORSE AZOMSTAND
    cstat 0
    fall
    ifaction AZOMSTAND ai AIZOMSEEK
    else ifaction AZOMDEAD { cstat 0 move 0 }
    else ifai AIZOMSEEK state zomseek
    else ifai AIZOMAXE state zomaxe
    else ifai AIZOMDYING state zomdying
    ifhitweapon state zomhit 
enda


state steamcode
    ifpdistl 8192 soundonce STEAM_HISSING

    ifcount 20
    {
        resetcount
        ifp palive ifpdistl 1024
        {
            addphealth -1
            palfrom 16 16
        }
    }
    else
    {
        ifspawnedby STEAM break ifspawnedby CEILINGSTEAM break
        sizeto 24 24
    }
ends


actor STEAM 0
    cstat 32768
    ifspritepal 0
    {

        killit
    }
enda

actor CEILINGSTEAM 0 
	cstat 0
	ifspritepal 0
	{
      
		killit
	}
	else ifspritepal 3
	{
      
		killit
	}
	else ifspritepal 5
	{
      
		killit
	}
enda

actor WATERBUBBLEMAKER 0 0 randomangle
    ifpdistl 3084 ifrnd 24 spawn WATERBUBBLE
enda

action BUBBLE
action CRACKEDBUBBLE    1
move BUBMOVE           -10 -36
move BUBMOVEFAST           -10 -52

actor WATERBUBBLE 0 BUBBLE BUBMOVE getv geth randomangle

    ifaction CRACKEDBUBBLE
    {
        ifinwater ifrnd 192 killit
        ifactioncount 7 killit
    }
    else
    {
        ifcount 4
        {
            ifrnd 192 move BUBMOVE getv geth randomangle
            else move BUBMOVEFAST getv geth randomangle
            resetcount
        }

        ifonwater
        {
            iffloordistl 8 action CRACKEDBUBBLE
        }
        else ifactioncount 40 action CRACKEDBUBBLE
    }
enda


move SMOKEVEL 8 -16
move ENGINE_SMOKE 64 -64
move SMOKESHOOTOUT -192
action SMOKEFRAMES 0 4 1 1 10
actor SMALLSMOKE 0 SMOKEFRAMES
    ifmove 0
    {
        ifspawnedby RECON
            move SMOKESHOOTOUT geth
        else ifspawnedby SECTOREFFECTOR
            move ENGINE_SMOKE geth getv
        else move SMOKEVEL geth getv faceplayer
        ifspawnedby RPG
        cstat 2
    }
    ifpdistl 1596 ifspawnedby RPG killit
    ifactioncount 4 killit
enda

action BARREL_DENTING  2 2 1 1 6
action BARREL_DENTED   1
action BARREL_DENTED2  2

move SPAWNED_BLOOD

actor NUKEBARRELDENTED 
    cstat 32800
    ifcount 75
    {
        resetcount
        globalsound RAINING
    }
enda

actor NUKEBARRELLEAKED WEAK
    cactor NUKEBARREL
    action BARREL_DENTED2
enda

// ---------------------
// BILLY RAY CODE
// ---------------------

define BILLYSTRENGTH 50

action ABILLYSTAND -117 1 1 1 1
action ABILLYWALK  -117 6 1 1 9
action ABILLYSHOOT -111 5 1 1 9
action ABILLYPSYCHO -117 1 1 1 1
action ABILLYDYING -106 10 1 1 12
action ABILLYDEAD  -97  1  1

move BILLYWALKSPEED 90
move BILLYDODGESPEED 200
move BILLYSTOP

ai AIBILLYSEEKENEMY ABILLYWALK BILLYWALKSPEED seekplayer
ai AIBILLYFLEEENEMY ABILLYWALK BILLYWALKSPEED fleeenemy
ai AIBILLYDODGE ABILLYWALK BILLYDODGESPEED dodgebullet
ai AIBILLYSHOOTENEMY ABILLYSHOOT BILLYSTOP faceplayer

state billyseekenemystate
  
  ifactornotstayput
  {
     ifrnd 22
     {
       ifp palive
         ifcansee
           ifcanshoottarget
           {
             ai AIBILLYSHOOTENEMY
             break
           }
     }
     else ifrnd 32
     {
        ifpdistg 3084
        {
          ai AIBILLYSEEKENEMY
          break
        }
     }

     ifrnd 28
       ifnotmoving
         operate

  }

  else
  {
    ifrnd 32
      ifp palive
        ifcansee
          ifcanshoottarget
        {
          ai AIBILLYSHOOTENEMY
          break
        }

    ifcount 48
    {
      ifrnd 8
        ifp palive
          ifcansee
            ifcanshoottarget
          {
            
              ai AIBILLYSHOOTENEMY
            break
          }
    }
  }
ends

state billyshootstate
ifcansee ifcanshoottarget
{
    ifactioncount 5
    {
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        sound SHOTGUN_FIRE
        spawn SHOTGUNSHELL
        resetactioncount
    }
    ifcount 80
    {
        resetcount
        ai AIBILLYSEEKENEMY
        break
    }
}
   else ai AIBILLYSEEKENEMY
ends

state billydying

   ifactioncount 10 { resetactioncount soundonce THUD action ABILLYDEAD break }
ends

state checkbillyhit
   ifdead
   {
    addkills 1
    state sangre

    ifwasweapon RPG { state paul_jibs soundonce SQUISHED killit }
    else ifwasweapon RADIUSEXPLOSION { state paul_jibs soundonce SQUISHED killit }
    else { soundonce BR_DIE action ABILLYDYING break }
   }
   else
   {
     soundonce BR_PAIN
     state sangre
     state random_wall_jibs
   }
ends

state billycode

    fall
    state checksquished
    ifrnd 1 { ifrnd 128 { ifaction ABILLYDEAD { } else { soundonce BR_ROAM1 } } }
    else ifrnd 1 { ifrnd 100 { ifaction ABILLYDEAD { } else { soundonce BR_ROAM2  } } }
    ifaction ABILLYSTAND  { soundonce BR_RECOG ai AIBILLYSEEKENEMY }
    else ifaction ABILLYDEAD { cstat 0 strength -1 move BILLYSTOP }
    else ifaction ABILLYDYING { move BILLYSTOP state billydying }
    else ifaction ABILLYPSYCHO { state genericpsychocode break }

    else ifai AIBILLYSEEKENEMY state billyseekenemystate
    else ifai AIBILLYSHOOTENEMY state billyshootstate

    ifhitweapon state checkbillyhit

ends

actor NUKEBARREL BILLYSTRENGTH ABILLYSTAND state billycode enda





state burningbarrelcode
    fall
    ifcount 32
    {
        resetcount
        ifp palive ifpdistl 1480 ifp phigher
        {
            addphealth -1
            palfrom 16 16
            ifrnd 96 sound DUKE_LONGTERM_PAIN
        }
    }
    ifhitweapon
    {
        sound VENT_BUST
        debris SCRAP1 10
        ifrnd 128 spawn BURNING
        else spawn BURNING2
        killit
    }
ends

action ASLAVESTAND   0  1  1  1  1
action ASLAVEWALK  -60  6  1  1 12
action ASLAVESHOOT -54  7  1  1 13

move SLAVEWALK   103
move SLAVEWALKB -150
move SLAVEDODGE  260
move SLAVESTOP

ai AISLAVESEEK   ASLAVEWALK  SLAVEWALK   seekplayer
ai AISLAVEBACK   ASLAVEWALK  SLAVEWALKB  faceplayer
ai AISLAVESCRTC  ASLAVESHOOT SLAVESTOP   faceplayer
ai AISLAVEDODGE  ASLAVEWALK  SLAVEDODGE  dodgebullet
ai AISLAVESHOOT  ASLAVESHOOT SLAVESTOP   faceplayer

state slavescrtc
    ifactioncount 7
    {
        resetactioncount
        addphealth -40
        sound OCTA_ATTACK2
        palfrom 32 32
    }
    ifpdistg 1024
    {
        ai AISLAVESEEK
        break
    }
ends


state slaveseek

    ifcansee
    {

        ifbulletnear { ai AISLAVEDODGE break }
        ifpdistl 1024
        {
            ai AISLAVESCRTC
            break
        }
            ifcanshoottarget
            {
                ifrnd 12
                {
                ai AISLAVESHOOT
                break
                }
            }
        
        
    }

ends

state slaveback
    ifpdistg 5096
    {
        ai AISLAVESHOOT
        break
    }
    else ifpdistl 1024
    {
        ai AISLAVESCRTC
        break
    }
    ifcount 50
    {
        resetcount
        ai AISLAVESEEK
        break
    }
ends

state slaveshoot
        ifcanshoottarget
        {
        ifactioncount 7
        {
        resetactioncount
        sound THUD
        shoot SPIT
        shoot SPIT
        shoot SPIT
        shoot SPIT
        ai AISLAVESEEK
        break
        
        }
        }
        else ai AISLAVESEEK
ends

state slavedodge
    ifactioncount 6
    {
        resetactioncount
        ai AISLAVESHOOT
        break
     }
ends    

state slavecode
    fall
    ifrnd 1 { soundonce SLV_ROAM }
    ifaction ASLAVESTAND { soundonce SLV_RECOG ai AISLAVESEEK }
    ifai AISLAVESEEK state slaveseek
    else ifai AISLAVESCRTC state slavescrtc
    else ifai AISLAVESHOOT state slaveshoot
    else ifai AISLAVEBACK state slaveback
    else ifai AISLAVEDODGE state slavedodge
    ifhitweapon
    {
        ifdead
        {
            state paul_jibs
            sound SQUISHED
            spawn BLOODPOOL
            killit
        }
        else
        {
            soundonce SLV_PAIN
            state random_wall_jibs
            state sangre
        }
    }
    else state checksquished
ends

actor FIREBARREL 110 ASLAVESTAND state slavecode enda



action AHGRUNTSTAND 0 1 1 1 1
action AHGRUNTWALK  -573 4 1 1 10
action AHGRUNTFIRE  -568 2 1 1 5
action AHGRUNTDIE   -566 5 1 1 19
action AHGRUNTDEAD  -561 1 1

move HGRUNTWALK 145
move HGRUNTDODGE 300
move HGRUNTSTOP

ai AIHGRUNTWALK  AHGRUNTWALK HGRUNTWALK  seekplayer
ai AIHGRUNTDODGE AHGRUNTWALK HGRUNTDODGE dodgebullet
ai AIHGRUNTFIRE  AHGRUNTFIRE HGRUNTSTOP  faceplayer
ai AIHGRUNTDYING AHGRUNTDIE  HGRUNTSTOP  faceplayer

state hgruntseek
    ifcansee
    {
        ifrnd 1 { ifrnd 128 { soundonce HG_ROAM } }
        ifbulletnear { ai AIHGRUNTDODGE break }
        ifcansee 
        {
            ifcount 45
            {
                resetcount
                ai AIHGRUNTFIRE
            }
        }        
    }

ends

state hgruntdodge
    ifactioncount 5
    {
        ai AIHGRUNTFIRE
        break
    }
ends

state hgruntfire
    ifactioncount 2
    {
        resetactioncount
        sound CAT_FIRE
        shoot SHOTSPARK1
        spawn SHELL
    }
    ifcount 50
    {
        resetcount
        ai AIHGRUNTWALK
        break
    }
ends

state hgruntdying
    cstat 0
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    sizeto 27 27
    ifactioncount 5 { cstat 0 action AHGRUNTDEAD }
ends

state checkhgrunthit
    ifdead
    {
        state sangre
        ifwasweapon RPG
        {
        state paul_jibs
        sound SQUISHED
        killit
        }
        else ifwasweapon RADIUSEXPLOSION
        {
        state paul_jibs
        sound SQUISHED
        killit
        }
        else { ifrnd 16 spawn SHIELD ai AIHGRUNTDYING break }
    }
    else
    {
        soundonce HG_PAIN
        state random_wall_jibs
        state sangre
    }
ends

state hgruntcode
    fall
    ifceilingdistl 12000 { } else { iffloordistl 16 { quote 123 globalsound SQUISHED state paul_jibs killit } }
    ifaction AHGRUNTSTAND { soundonce HG_ALERT ai AIHGRUNTWALK }
    else ifaction AHGRUNTDEAD
    {
      ifcount 150
        {
        resetcount
        cstat 32768
        killit
        break
        }
        else
    ifcount 125
      cstat 514
    else
  ifcount 100
    cstat 2
    }
    ifai AIHGRUNTWALK state hgruntseek
    else ifai AIHGRUNTDYING state hgruntdying
    else ifai AIHGRUNTDODGE state hgruntdodge
    else ifai AIHGRUNTFIRE state hgruntfire
    ifhitweapon state checkhgrunthit else state checksquished
ends

eventloadactor FIREVASE setactor[THISACTOR].xrepeat 19 setactor[THISACTOR].yrepeat 17 enda

actor FIREVASE 50 AHGRUNTSTAND state hgruntcode enda

    

action SHRINKERFRAMES 0 4 1 1 10
actor SHRINKEREXPLOSION 0 SHRINKERFRAMES
        ifactioncount 1 { resetactioncount cstat 32768  spawn HEATSENSOR spawn EXPLOSION2 killit }
enda

action EXPLOSION_FRAMES 0 20 1 1  4
action NUKEFRAMES       -90 20 1 1  12

define NUKESOUND 138
definesound NUKESOUND hbomb2.voc -400 -400 0 0 0

actor EXPLOSION2 1 EXPLOSION_FRAMES

    
    ifspawnedby FECES { cstat 32768 ifactioncount 20 { killit break } }
    else ifspawnedby SHRINKEREXPLOSION
    {
       
       
       action NUKEFRAMES
       ifaction NUKEFRAMES
       {
       ifcount 2 { } else ifcount 1
       {
            resetcount
            sizeto 1024 2048
            hitradius 5500 40 100 200 350
            globalsound PIPEBOMB_EXPLODE
            globalsound NUKESOUND
            
            debris SCRAP2 10
            palfrom 63 63 63 63
            palfrom 63 63 63 63 
       }
       
       ifactioncount 20 { killit }
       }
    }
    
        else
        {
        ifpdistl 1024
        {
        ifcount 2
        {
            resetcount
            addphealth -1
            palfrom 24 48
        }
        }
        ifactioncount 20 { killit }
        }
    

    
enda


actor EXPLOSION2BOT 1 EXPLOSION_FRAMES
    ifactioncount 20 killit
enda

action ACRABSTAND  0 1 1 1 1 
action ACRABWALK   -1132 4 1 1 14
action ACRABJUMP   -1128 3 1 1 18
action ACRABFALL   -1126 1 1 1 1

move CRABWALK  70
move CRABJUMP  200

ai AICRABSEEK ACRABWALK CRABWALK seekplayer
ai AICRABJUMP ACRABJUMP CRABJUMP jumptoplayer

state crabseek
ifcansee
{
    ifpdistl 624
    {
        ifactioncount 3
        {
            resetactioncount
            addphealth -2
            palfrom 32  32
            sound THUD
        }
    }
    ifpdistl 4094
    {
        ifpdistg 2200
        {
        ifrnd 15
        {
        ifgapzl 56 { }
        else
        {
        ai AICRABJUMP
        break
        }
        }
        }
    }
}
ends

state crabjump
    ifaction ACRABJUMP { ifpdistl 900 { addphealth -10 palfrom 32 32 wackplayer } }
    ifaction ACRABFALL
    {
        ifpdistl 900 { addphealth -10 palfrom 32 32 wackplayer }
        iffloordistl 16 ai AICRABSEEK
    }
    else ifactioncount 3 action ACRABFALL
ends

state crabhit
ifdead
{
    state sangre
    sound SQUISHED
    killit
}
else
{
    sound HC_ATTACK
    guts JIBS6 1
}
ends

state crabcode
    fall
    ifaction ACRABSTAND { ifcansee { soundonce HC_ALERT ai AICRABSEEK } }
    ifai AICRABSEEK state crabseek
    else ifai AICRABJUMP { soundonce HC_ATTACK state crabjump }
    ifhitweapon state crabhit else state checksquished
ends

actor FLOORFLAME 10 ACRABSTAND state crabcode enda




action ASATNSPIN   0 5 1 1 4
action ASATSHOOTING -10 3 5 1 40
action ASATWAIT 0 1 5 1 1
move TURRVEL

actor ROTATEGUN ROTTURRETSTRENGTH
// ASATSHOOTING TURRVEL faceplayer

    ifaction 0
    {
        action ASATSHOOTING
        move TURRVEL faceplayer
    }
    else ifaction ASATNSPIN
        { ifactioncount 32 { action ASATWAIT move TURRVEL faceplayer } }
    else ifaction ASATSHOOTING
    {
        ifactioncount 12 { ifrnd 32 action ASATWAIT }
        ifcount 32 resetcount
        else ifcount 16 { ifcount 17 { } else { sound DRON_ATTACK1 shoot FIRELASER } }
        else ifcount 4 { ifcount 5 { } else { ifcansee ifcanshoottarget { sound DRON_ATTACK1 shoot FIRELASER } } }
    }
    else ifaction ASATWAIT
        { ifactioncount 64 ifrnd 32 ifp palive ifcansee { action ASATSHOOTING move TURRVEL faceplayer } }
    ifhitweapon { ifdead { addkills 1 sound LASERTRIP_EXPLODE debris SCRAP1 15 spawn EXPLOSION2 killit }
        else { action ASATNSPIN debris SCRAP1 4 } move 0 }

enda

action RIP_F 0 8 1 1 1
actor FORCERIPPLE 0 RIP_F
    ifactioncount 8 killit
enda

action TRANSFOWARD 0  6  1  1  2
action TRANSBACK   5  6  1 -1  2
actor TRANSPORTERSTAR 0 TRANSFOWARD
    ifaction TRANSFOWARD
    {
        ifactioncount 6
            action TRANSBACK
    }
    else
        ifactioncount 6 killit
enda

action BEAMFOWARD  0  4  1  1  9
actor TRANSPORTERBEAM 0 BEAMFOWARD
    sizeto 32 64 sizeto 32 64 sizeto 32 64
    ifactioncount 4 killit
enda

state getcode
    ifactor ATOMICHEALTH globalsound GETATOMICHEALTH
    else ifactor COLA globalsound DUKE_USEMEDKIT
    else ifactor SIXPAK globalsound DUKE_USEMEDKIT
    else globalsound DUKE_GET
    palfrom 16 0 32
    ifrespawn
    {
        move RESPAWN_ACTOR_FLAG
        spawn RESPAWNMARKERRED
        cstat 32768
    }
    else killit
ends

state randgetweapsnds
    globalsound DUKE_GETWEAPON6
ends

state getweaponcode

    state randgetweapsnds

    palfrom 32 0 32
    ifgotweaponce 1 break
    ifrespawn
    {
        move RESPAWN_ACTOR_FLAG
        spawn RESPAWNMARKERRED
        cstat 32768
    }
    else killit
ends


state respawnit
    ifcount RESPAWNITEMTIME { spawn TRANSPORTERSTAR move 0 cstat 0 sound TELEPORTER }
ends

state quikget
    ifactor ATOMICHEALTH globalsound GETATOMICHEALTH
    else globalsound DUKE_GET
    palfrom 16 0 32
    killit
ends

state quikweaponget
    state randgetweapsnds
    palfrom 32 0 32
    ifgotweaponce 1 break
    killit
ends

action RAD_FRAMES 2725 18 1 1 8

actor STEROIDS 0 RAD_FRAMES
    spritepal 22
    ifpdistl 3096
    {
        ifrnd 40
        {
        addphealth -10
        quote 156
        palfrom 16 0 32
        }
    }
    ifcount 500 killit
enda

actor HEATSENSOR
    cstat 34
    sizeto 750 750
    ifpdistl 196 { addphealth -500 palfrom 63 63 }
    ifcount 95 { spawn STEROIDS killit }
enda

actor BOOTS
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_BOOTS BOOT_AMOUNT
        ifcanseetarget
    {
        addinventory GET_BOOTS BOOT_AMOUNT quote 6
        ifspawnedby BOOTS state getcode
        else state quikget
    }
enda

actor SHIELD
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_SHIELD SHIELD_AMOUNT
        ifcanseetarget
    {
        ifspawnedby PIGCOP
        {
            ifrnd 128 addinventory GET_SHIELD PIG_SHIELD_AMOUNT1
            else addinventory GET_SHIELD PIG_SHIELD_AMOUNT2
            quote 104
            sound KICK_HIT palfrom 24 0 32 killit
        }
        else addinventory GET_SHIELD 25 quote 38
        ifspawnedby SHIELD state getcode
        else state quikget
    }
enda

actor AIRTANK
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_SCUBA SCUBA_AMOUNT
        ifcanseetarget
    {
        addinventory GET_SCUBA SCUBA_AMOUNT quote 39 state getcode
        ifspawnedby AIRTANK state getcode
        else state quikget
    }
enda

action HOLODUKE_FRAMES 0 4 1 1 8
actor HOLODUKE 0 HOLODUKE_FRAMES
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_HOLODUKE HOLODUKE_AMOUNT
        ifcanseetarget
    {
        addinventory GET_HOLODUKE HOLODUKE_AMOUNT quote 51 state getcode
        ifspawnedby HOLODUKE state getcode
        else state quikget
    }
enda

actor JETPACK
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifpinventory GET_JETPACK JETPACK_AMOUNT ifcanseetarget
    {
        addinventory GET_JETPACK JETPACK_AMOUNT quote 41 state getcode
        ifspawnedby JETPACK state getcode
        else state quikget
    }
enda

actor ACCESSCARD
    fall
    ifspawnedby SHARK spritepal 23
    else ifspawnedby FEM4 spritepal 21
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifpinventory GET_ACCESS 0 break
        addinventory GET_ACCESS 1
        quote 43
        state getcode
    }
enda

// test boss_recod


actor AMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        addammo PISTOL_WEAPON PISTOLAMMOAMOUNT quote 65
        ifspawnedby AMMO state getcode
        else state quikget
    }
enda

actor FREEZEAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        addammo FREEZE_WEAPON FREEZEAMMOAMOUNT quote 66
        ifspawnedby FREEZEAMMO state getcode
        else state quikget
    }
enda



actor SHOTGUNAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        ifspawnedby LIZMAN
        {
        addammo SHOTGUN_WEAPON 3 quote 69
        ifspawnedby SHOTGUNAMMO state getcode
        else state quikget
        }
        else
        {
        addammo SHOTGUN_WEAPON SHOTGUNAMMOAMOUNT quote 69
        ifspawnedby SHOTGUNAMMO state getcode
        else state quikget
        }

    }
enda

actor AMMOLOTS
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        addammo PISTOL_WEAPON 48 quote 65
        ifspawnedby AMMOLOTS state getcode
        else state quikget
    }
enda

actor CRYSTALAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        addammo SHRINKER_WEAPON CRYSTALAMMOAMOUNT quote 78
        ifspawnedby CRYSTALAMMO state getcode
        else state quikget
    }
enda

actor BATTERYAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        addammo CHAINGUN_WEAPON CHAINGUNAMMOAMOUNT quote 63
        ifspawnedby BATTERYAMMO state getcode
        else state quikget
    }
enda

actor DEVISTATORAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        addammo DEVISTATOR_WEAPON DEVISTATORAMMOAMOUNT quote 14
        ifspawnedby DEVISTATORAMMO state getcode
        else state quikget
    }
enda

actor RPGAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        addammo RPG_WEAPON RPGAMMOBOX quote 64
        ifspawnedby RPGAMMO state getcode
        else state quikget
    }
enda

actor HBOMBAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break // ( Multiplayer (mode 3) only )

        addweapon HANDBOMB_WEAPON 1 quote 55
        addammo HANDBOMB_WEAPON 3

        ifspawnedby HBOMBAMMO state getweaponcode
        else state quikweaponget
    }
enda

actor RPGSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break // ( Multiplayer (mode 3) only )
        
        addweapon RPG_WEAPON RPGAMMOBOX quote 56
        ifspawnedby RPGSPRITE state getweaponcode
        else state quikweaponget
    }
enda

spritenoshade SHOTGUNSPRITE
spriteshadow SHOTGUNSPRITE

actor SHOTGUNSPRITE
    fall
	
	
getactor[THISACTOR].ang TEMP
subvar TEMP 6
setactor[THISACTOR].ang TEMP

	getactor[THISACTOR].shade TEMP3
	ifvarl TEMP3 1 setvar TEMP2 1 else ifvarg TEMP3 19 setvar TEMP2 0
	ifvare TEMP2 1
		{
		addvar TEMP3 1 setactor[THISACTOR].shade TEMP3
		}
	ifvare TEMP2 0
		{
		subvar TEMP3 1 setactor[THISACTOR].shade TEMP3
		}
	
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifspawnedby PIGCOP
        {
             
            addweapon SHOTGUN_WEAPON 0
            ifrnd 64 addammo SHOTGUN_WEAPON 4
            else ifrnd 64 addammo SHOTGUN_WEAPON 3
            else ifrnd 64 addammo SHOTGUN_WEAPON 2
            else addammo SHOTGUN_WEAPON 1
        }
        else
        {
            
            ifgotweaponce 0 break // Multiplayer only
            
            addweapon SHOTGUN_WEAPON SHOTGUNAMMOAMOUNT quote 57
        }
        ifspawnedby SHOTGUNSPRITE state getweaponcode
        else state quikweaponget
    }
enda



actor SIXPAK
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifphealthl MAXPLAYERHEALTH ifcanseetarget
    {
        addphealth 30 quote 62
        ifspawnedby SIXPAK state getcode
        else state quikget
    }
enda

actor COLA
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifphealthl MAXPLAYERHEALTH // ifcanseetarget
    {
        addphealth 10 quote 61
        ifspawnedby COLA state getcode
        else state quikget
    }
enda

actor ATOMICHEALTH
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
        ifphealthl MAXPLAYERATOMICHEALTH
    {
        addphealth 50 quote 19
        ifspawnedby ATOMICHEALTH state getcode
        else state quikget
    }
enda




actor FIRSTAID
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6
        ifpinventory GET_FIRSTAID FIRSTAID_AMOUNT ifcanseetarget
    {
        addinventory GET_FIRSTAID FIRSTAID_AMOUNT quote 3

        ifspawnedby FIRSTAID state getcode
        else state quikget
    }
enda


actor FIRSTGUNSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break
        
        addweapon PISTOL_WEAPON 48 quote 122
        ifspawnedby FIRSTGUNSPRITE state getweaponcode
        else state quikweaponget
    }
enda


actor TRIPBOMBSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break
        
        addweapon TRIPBOMB_WEAPON 1
        quote 58
        ifspawnedby TRIPBOMBSPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor CHAINGUNSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break
        
        addweapon CHAINGUN_WEAPON 50 quote 54
        ifspawnedby CHAINGUNSPRITE state getweaponcode
        else state quikweaponget
    }
enda

spritenoshade SHRINKERSPRITE
spriteshadow SHRINKERSPRITE

actor SHRINKERSPRITE
    fall
	

getactor[THISACTOR].ang TEMP
subvar TEMP 6
setactor[THISACTOR].ang TEMP

	getactor[THISACTOR].shade TEMP3
	ifvarl TEMP3 1 setvar TEMP2 1 else ifvarg TEMP3 19 setvar TEMP2 0
	ifvare TEMP2 1
		{
		addvar TEMP3 1 setactor[THISACTOR].shade TEMP3
		}
	ifvare TEMP2 0
		{
		subvar TEMP3 1 setactor[THISACTOR].shade TEMP3
		}
	
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break
        
        addweapon SHRINKER_WEAPON 1 quote 60
        ifspawnedby SHRINKERSPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor FREEZESPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break
        
        addweapon FREEZE_WEAPON FREEZEAMMOAMOUNT quote 59
        ifspawnedby FREEZESPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor DEVISTATORSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break // ( Multiplayer (mode 3) only )
        
        addweapon DEVISTATOR_WEAPON DEVISTATORAMMOAMOUNT quote 87
        ifspawnedby DEVISTATORSPRITE state getweaponcode
        else state quikweaponget
    }
enda

action FIRE_FRAMES   -1 14 1 1 1
move FIREVELS


state firestate

  ifaction 0
    ifrnd 16
    {
      action FIRE_FRAMES
      cstator 128
    }

  sleeptime 300         // Never let it fall to sleep

  ifspawnedby FIRE
  {
    ifgapzl 16
      break
  }
  else
    ifspawnedby FIRE2
  {
    ifgapzl 16
      break
  }

  ifinwater
    killit

  ifp palive
    ifpdistl 844
      ifrnd 32
        ifcansee
  {
    soundonce DUKE_LONGTERM_PAIN
    addphealth -1
    palfrom 32 32
  }

  ifactor FIRE
  {
    ifspawnedby FIRE
      break
  }
  else
    ifactor FIRE2
      ifspawnedby FIRE2
        break

  iffloordistl 128
  {
    ifrnd 128
    {
      ifcount 84
        killit
                // This line(and the else below)
                // is not necessary, since actors
                // with zero x-size are automatically
                // deleted anyway!
      else
        ifcount 42
          sizeto 0 0
      else
        sizeto 32 32
    }
  }
  else
    killit

ends

useractor notenemy FIRE WEAK 0 FIREVELS state firestate enda
useractor notenemy FIRE2 WEAK 0 FIREVELS state firestate enda


actor FECES  // STORM GENERATOR. For use only in outside levels.
             
    cstat 32800
            ifcount 380
            {
                resetcount
                globalsound THUNDER1
                ifcansee ifpdistl 6048 palfrom 32 63 63 63
                flash
            }

            else ifcount 375
            {
                flash
                
            }
          
enda

state drop_ammo spawn AMMO ends
state drop_battery ifrnd SPAWNAMMOODDS spawn BATTERYAMMO ends
state drop_sgshells ifrnd SPAWNAMMOODDS spawn SHOTGUNAMMO ends
state drop_shotgun ifrnd SPAWNAMMOODDS spawn SHOTGUNSPRITE ends
state drop_chaingun
    ifrnd SPAWNAMMOODDS
    {
        ifrnd 32 spawn CHAINGUNSPRITE
        else spawn BATTERYAMMO
    }
ends


action AFANASTAND  0 1 1 1 1
action AFANASHOOT  708 2 1 1 5
action AFANAWALK   710 5 1 1 12
action AFANADYING  715 7 1 1 8
action AFANADEAD   721 1 1 1 1
action FANAFLINTCH 715 2 1 1 3

move FANAWALKVELS 85
move FANARUNVELS  132
move FANASTOPPED

ai AIFANASEEK AFANAWALK FANAWALKVELS seekplayer
ai AIFANASHOOT AFANASHOOT FANASTOPPED faceplayer
ai AIFANADYING AFANADYING FANASTOPPED faceplayer
ai AIFANAHIT FANAFLINTCH FANASTOPPED faceplayer


state fanahit
    ifactioncount 2
    {
        resetactioncount
        ai AIFANASEEK
        break
    }
ends

state fanaseekenemystate

    ifcansee  ifrnd 48 ifcanshoottarget
    {
        ifp palive 
            ai AIFANASHOOT
    }
ends

state fanadyingstate
  ifactioncount 6 { action AFANADEAD break }
ends

state fanalobbedstate
       ifcansee
       {
       ifactioncount 2
        {
            shoot SHOTSPARK1
            sound GENERIC_AMBIENCE17
            resetactioncount
            ifrnd 20 ai AIFANASEEK
        }
       }
       else ai AIFANASEEK
    
ends

state checkfanahitstate
    ifrnd 2 spawn BLOODPOOL
    ifdead
    {
        addkills 1
            
             ifwasweapon SHRINKSPARK { state paul_jibs soundonce SQUISHED killit }
             else ifwasweapon RPG { state paul_jibs sound SQUISHED spawn BLOODPOOL killit }
             else ifwasweapon RADIUSEXPLOSION { state paul_jibs sound SQUISHED spawn BLOODPOOL killit }
        else
        {
         
         ai AIFANADYING
         ifrnd 120 { sound BOS3_DYING } else { sound GENERIC_AMBIENCE23 }
        }

    }
    else
    {
        state sangre
        ifrnd 32 { ai AIFANAHIT move 0 }
       soundonce BOS3_PAIN
     
        
    }
ends

state fanacode
    fall
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    sizeto 25 25
    ifaction AFANADEAD { }
    else
    {
        ifcount 75
        {
            resetcount
            ifrnd 110 soundonce GENERIC_AMBIENCE21
            else ifrnd 126 soundonce GENERIC_AMBIENCE13 
            else soundonce GENERIC_AMBIENCE22
        }
    }
    ifaction AFANASTAND   ai AIFANASEEK  
    else ifaction AFANADEAD { cstat 0 move 0 }
    else ifai AIFANASEEK state fanaseekenemystate
    else ifai AIFANAHIT state fanahit
    else ifai AIFANASHOOT state fanalobbedstate
    ifai AIFANADYING state fanadyingstate
    else
    {
      ifhitweapon state checkfanahitstate else state checksquished
        
    }
    
ends

eventloadactor FEM1 setactor[THISACTOR].xrepeat 25 setactor[THISACTOR].yrepeat 25 enda

actor FEM1 30 AFANASTAND state fanacode enda   // The Fanatic

actor FEM2 100 enda

action AGARGANTUASTAND 0    1 1 1 1
action AGARGANTUADIE   0    1 1 1 2
action AGARGANTUAWALK  257  7 1 1 9
action AGARGANTUASHOOT 267  3 1 1 20
action AGARGANTUASMASH 272  4 1 1 10

move GARGANTUARUN 379
move GARGANTUASTOP

ai AIGARGANTUASEEK  AGARGANTUAWALK  GARGANTUARUN  seekplayer
ai AIGARGANTUASHOOT AGARGANTUASHOOT GARGANTUASTOP faceplayer
ai AIGARGANTUADIE   AGARGANTUADIE   GARGANTUASTOP faceplayer
ai AIGARGANTUASMASH AGARGANTUASMASH GARGANTUASTOP faceplayer

state gargantuaseek
ifcansee
{
    ifactioncount 3 { resetactioncount sound SLIM_HATCH }
    ifp palive ifpdistl 2098
    {
        ai AIGARGANTUASMASH
        break
    }
    else ifp palive ifpdistl 5096
    {
        ifrnd 18
        {
        ifcanshoottarget
        {
            soundonce TURR_ATTACK
            ai AIGARGANTUASHOOT
            break
        }
        }
    }
}    
ends

state gargantuashoot
    ifpdistg 5096
    {
        ai AIGARGANTUASEEK
        break
    }
    ifactioncount 3
    {
        resetactioncount
        shoot RPG
        shoot RPG
    }
    ifcount 80
    {
        ai AIGARGANTUASEEK
        break
    }
ends

state gargantuasmash

    ifactioncount 4
    {
        resetactioncount
        soundonce SLIM_HATCH
        palfrom 32 32
        addphealth -95
    }
    ifpdistg 1024
    {
        ai AIGARGANTUASEEK
        break
    }
ends

state checkgargantuahit
    ifdead
    {
        soundonce TURR_DYING
        ai AIGARGANTUADIE
        break
    }
    else
    {
        soundonce TURR_PAIN
        state random_wall_jibs
        state sangre
        state sangre
    }
ends

state gargantuadie
    sizeto 9 9
    spawn FRAMEEFFECT1
    ifcount 70
    {
    resetcount
    spawn EXPLOSION2
    hitradius 4096 40 80 140 220
    soundonce PIPEBOMB_EXPLODE
    ifspritepal 5 endofgame 52
    killit
    }
ends

state gargantuacode
    fall
    cstat 257
    ifrnd 1 soundonce TURR_ROAM
    ifaction AGARGANTUASTAND { soundonce TURR_RECOG ai AIGARGANTUASEEK }
    ifai AIGARGANTUASEEK state gargantuaseek
    else ifai AIGARGANTUASHOOT state gargantuashoot
    else ifai AIGARGANTUADIE state gargantuadie
    else ifai AIGARGANTUASMASH state gargantuasmash
    ifhitweapon state checkgargantuahit
    ifpdistl 1516 { palfrom 32 32 addphealth -1000 }
ends


actor FEM5 1200 AGARGANTUASTAND state gargantuacode enda   // Gargantua Monster


action AHUMANSTAND    0 1 1 1 1
action AHUMANWALK   405 6 1 1 8
action AHUMANSHOOT  415 2 1 1 11
action AHUMANKICK   420 8 1 1 8
action AHUMANDIE    430 6 1 1 13
action AHUMANRAPPEL 440 2 1 1 14
action AHUMANDEAD   436 1 1 1 1

move HUMANWALK   176
move HUMANDODGE  372
move HUMANSTOP
move HUMANRAPPEL -200 -200

ai AIHUMANSEEK    AHUMANWALK    HUMANWALK   seekplayer
ai AIHUMANDODGE   AHUMANWALK    HUMANDODGE  dodgebullet
ai AIHUMANSHOOT   AHUMANSHOOT   HUMANSTOP   faceplayer
ai AIHUMANKICK    AHUMANKICK    HUMANSTOP   faceplayer
ai AIHUMANRAPPEL  AHUMANRAPPEL  HUMANSTOP   faceplayer
ai AIHUMANDIE     AHUMANDIE     HUMANSTOP   faceplayer

state humanseek
ifcansee
{
    ifrnd 1  { ifrnd 1 { soundonce PRED_ROAM } }
    ifpdistl 1024
    {
        ai AIHUMANKICK
        break
    }
    ifcansee ifpdistg 1024
    {
        ifcount 20
        {
            resetcount
            ai AIHUMANSHOOT
            break
        }
    }
}
ends

state humanshoot
    ifactioncount 2
    {
        resetactioncount
        shoot SHOTSPARK1
        sound CAT_FIRE
        spawn SHELL
    }
    ifcount 70
    {
        ai AIHUMANSEEK
        break
    }
ends

state humankick
    ifactioncount 8 resetactioncount
    else ifactioncount 6
    {
        soundonce KICK_HIT
        addphealth -4
    }
    ifpdistg 1240
    {
        ai AIHUMANSEEK
        break
    }
ends

state humandodge
    ifactioncount 6
    {
        resetactioncount
        ai AIHUMANSHOOT
        break
    }
ends

state humanrappel
    iffloordistl 4
    {
        ai AIHUMANSEEK
        break
    }
    else fall
ends

state humandie
    cstat 0
    ifactioncount 6
    {
        resetactioncount
        cstat 0
        action AHUMANDEAD
    }
ends

state checkhumanhit
    ifdead
    {
        ifspritepal 5 { spawn ACCESSCARD }
        state sangre
        ifwasweapon RPG { state paul_jibs sound SQUISHED killit }
        else ifwasweapon RADIUSEXPLOSION { state paul_jibs sound SQUISHED killit }
        else { sound PRED_DYING ai AIHUMANDIE break }
    }
    else
    {
        state random_wall_jibs
        soundonce SOLDIER_1
        state sangre
    }
ends

state humancode
    fall
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    ifaction AHUMANSTAND
    {
    soundonce PRED_RECOG
    ifspritepal 0 { ai AIHUMANSEEK }
    else { ai AIHUMANRAPPEL }
    }
    else ifaction AHUMANDEAD
    {
      ifcount 150
        {
        resetcount
        cstat 32768
        killit
        break
        }
        else
    ifcount 125
      cstat 514
    else
  ifcount 100
    cstat 2
    }
    ifai AIHUMANSEEK state humanseek
    else ifai AIHUMANDODGE state humandodge
    else ifai AIHUMANSHOOT state humanshoot
    else ifai AIHUMANKICK state humankick
    else ifai AIHUMANRAPPEL state humanrappel
    else ifai AIHUMANDIE state humandie
    ifhitweapon state checkhumanhit else state checksquished
ends

eventloadactor FEM4 setactor[THISACTOR].xrepeat 17 setactor[THISACTOR].yrepeat 17 enda

actor FEM4 35 AHUMANSTAND state humancode enda   // Human Grunt w/o Helmet. The only difference with the Helmet one is that can kick you and may use a rappel



action AEYESTAND     0  1  5  1  1
action AEYEATTACK    0  1  5  1  1
action AEYEWALK    555  2  5  1 11
action AEYEDIE     565  4  1  1 18
action AEYEDEAD    569  1  1  1  1

move EYEWALK  267
move EYESTOP

ai AIEYESEEK    AEYEWALK   EYEWALK seekplayer
ai AIEYEATTACK  AEYEATTACK EYESTOP faceplayer
ai AIEYEDIE     AEYEDIE    EYESTOP faceplayer

state eyeseek
ifcansee
    {
    ifrnd 1 { soundonce SLIM_RECOG }
    ifpdistl 3096
    {
        soundonce SLIM_ROAM
        ai AIEYEATTACK
        break
    }
    }
ends

state eyeshoot   // Kamikaze attack
    ifcount 70
    {
        spawn EXPLOSION2
        hitradius 8096 20 40 80 120
        soundonce PIPEBOMB_EXPLODE
        state sangre
        state sangre
        state paul_jibs
        killit
    }
ends

state eyedie
    ifactioncount 4 action AEYEDEAD
ends

state checkeyehit
    ifdead
    {
        state sangre
        ifwasweapon RPG { soundonce SQUISHED state paul_jibs killit }
        else ifwasweapon RADIUSEXPLOSION { soundonce SQUISHED state paul_jibs killit }
        else { soundonce SLIM_DYING ai AIEYEDIE break }
    }
    else
    {
        soundonce SLIM_ATTACK
        state random_wall_jibs
        state sangre
    }
ends

state eyecode
    fall
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    sizeto 14 13
    ifaction AEYESTAND { soundonce SLIM_RECOG ai AIEYESEEK }
    else ifaction AEYEDEAD
    {
      ifcount 150
        {
        resetcount
        cstat 32768
        killit
        break
        }
        else
    ifcount 125
      cstat 514
    else
  ifcount 100
    cstat 2
    }

    ifai AIEYESEEK state eyeseek
    else ifai AIEYEATTACK state eyeshoot
    else ifai AIEYEDIE state eyedie
    ifhitweapon state checkeyehit else state checksquished
ends

eventloadactor FEM7 setactor[THISACTOR].xrepeat 14 setactor[THISACTOR].yrepeat 13 enda
    
actor FEM7 40 AEYESTAND state eyecode enda    // The Hound Eye

action AOSPREYROTOR 0 1 1 1 1

state checkospreyhit
    ifdead
    {
        spawn EXPLOSION2
        spawn EXPLOSION2
        sound PIPEBOMB_EXPLODE
        debris SCRAP2 350
        killit
    }
    else
    {
        debris SCRAP2 6
    }
ends

state ospreycode
    soundonce HELICOP_IDLE
    ifhitweapon state checkospreyhit
ends


actor FEM6 0 AOSPREYROTOR state ospreycode enda    // V-22 Osprey Helicopter


action AGILLSTAND 0 1 1 1 1
action AGILLSWIM 684 5 1 1 8
action AGILLBITE 689 3 1 1 13
action AGILLDYING 692 10 1 1 9
action AGILLDEAD 701 1 1 1 1

move GILLSWIMVELS 386
move GILLUPVELS 386 -30
move GILLSTOP

move GILLRUNVELS 386 64
move GILLRUNUPVELS 387 -64
move GILLBULLVELS 252 -64
move GILLBACKWARDS -64 -64
move GILLRISE 320 -320
move GILLSTOPPED -16

ai AIGILLGETE AGILLSWIM GILLRUNVELS faceplayerslow getv
ai AIGILLWAIT AGILLSWIM GILLSTOPPED faceplayerslow
ai AIGILLGETUP AGILLSWIM GILLRUNUPVELS faceplayer getv
ai AIGILLDYING AGILLDYING GILLSTOPPED faceplayer
ai AIGILLPULLBACK AGILLSWIM GILLBACKWARDS faceplayerslow
ai AIGILLBITE AGILLBITE GILLSTOPPED faceplayerslow
ai AIGILLHIT AGILLSWIM GILLBACKWARDS faceplayer
ai AIGILLDODGE AGILLSWIM GILLBULLVELS dodgebullet geth
ai AIGILLDODGEUP AGILLSWIM GILLRISE getv geth

state dronedying
  ifactioncount 10 action AGILLDEAD
ends

state checkdronehitstate

  ifdead
  {
    ai AIGILLDYING break
  }
  else
  {
    state sangre
    ifbulletnear
    {
      ifceilingdistl 64
        ifrnd 48
          ai AIGILLDODGE
      ai AIGILLDODGEUP
    }
    else
      ai AIGILLGETE
  }
ends


state checkdronenearplayer

  ifp palive
    ifpdistl 1596
  {
    ifactioncount 3
    {
        resetactioncount
        palfrom 32 32
        addphealth -45
    }
  }

ends

state dronegetstate
  ifrnd 192
  {
    ifcansee
    {
      ifbulletnear
      {
        ai AIGILLDODGE
        break
      }
      ifmove GILLBULLVELS
      {
        ifcount 64
          ai AIGILLPULLBACK
        else
          ifnotmoving
            ifcount 16
              ai AIGILLPULLBACK
      }
      else
        ifcount 32
      {
        ifp phigher
          move GILLBULLVELS geth getv
        else
          move GILLBULLVELS geth
      }
    }
    else
      ifrnd 1
        operate
  }
ends

state dronedodgestate
  ifai AIGILLDODGEUP
  {
     ifcount 8
       ai AIGILLGETE
     else
       ifnotmoving
         ai AIGILLGETE
  }
  else
  {
    ifcount 8
      ai AIGILLGETE
    else
      ifnotmoving
        ai AIGILLGETE
  }
ends

define GILLSTRENGTH 50

actor FEM8 GILLSTRENGTH
  state checkdronenearplayer

    fall

  ifaction AGILLSTAND
    ai AIGILLGETE
  else ifaction AGILLDEAD { }
  else
    ifai AIGILLWAIT
  {
    ifactioncount 4
      ifrnd 16
        ifcansee
    {
      
      ifp phigher
        ai AIGILLGETUP
      else ai AIGILLGETE
    }
  }
  else
    ifai AIGILLGETE
      state dronegetstate
  else
    ifai AIGILLGETUP
      state dronegetstate
  else
    ifai AIGILLPULLBACK
  {
    ifcount 32
    ai AIGILLWAIT
  }
  else
    ifai AIGILLHIT
  {
    ifcount 8
      ai AIGILLWAIT
  }
  else
    ifai AIGILLDODGE
      state dronedodgestate
  else
    ifai AIGILLDODGEUP
      state dronedodgestate

  ifhitweapon
    state checkdronehitstate


enda


action ADDAMMOANDHEALTH 0 1 1 1 1 

state levelstartcode
    cstat 0
    cstat 32800
    ifspritepal 3
    {
    ifphealthl MAXPLAYERHEALTH addphealth 40
    addammo PISTOL_WEAPON 100
    }
    else ifspritepal 23
    {
        addinventory GET_ACCESS 1
        spritepal 0
        addinventory GET_ACCESS 1
        ifphealthl MAXPLAYERHEALTH
        {
            addphealth 40
        }
    }
    killit
ends

actor FEM9 0 ADDAMMOANDHEALTH state levelstartcode enda   // Sets your health to 40% more of the health you had at the end of the previous level

state checkkeys
    ifpinventory GET_ACCESS 2 killit
    else { cstat 25 ifpdistl 1024 quote 157 }
ends

actor NAKED1 0 state checkkeys enda   // A metal barrier that will let you pass if you have 2 keys


state teledevice    // Spawns a random creature, used for the Teleport Device of Episode 2
    ifcount 90
    {
        resetcount
        ifrnd 44 spawn SIXPAK
        else ifrnd 104 spawn BOSS1
        else ifrnd 100 spawn PIGCOP
        else ifrnd 120 spawn LIZMAN
        else spawn LIZTROOP
    }
    ifhitweapon
    {
        ifdead
        {
            spawn EXPLOSION2
            sound PIPEBOMB_EXPLODE
            debris SCRAP2 60
            quote 124
            endofgame 52
            
        }
        else
        {
            debris SCRAP2 15
        }
    }
ends

actor PODFEM1 3670 state teledevice enda

actor BLOODYPOLE TOUGH enda

actor STATUEFLASH fall // state statuehit
    ifcount 32 cactor STATUE
enda


// COOT CODE

action ACOOTSTAND        0   1 1 1 1
action ACOOTPSYCHO       0   1 1 1 1
action ACOOTWALK         462 6 1 1 10
action ACOOTSHOOT        468 2 1 1 25
action ACOOTDUCKWALK     470 8 1 1 10
action ACOOTDYING        478 8 1 1 13
action ACOOTDEAD         486 1 1  

move COOTWALKSPEED 78
move COOTWALKBACKSPEED -78
move COOTDODGESPEED 165
move COOTDUCKWALKSPEED 54
move COOTSTOP

ai AICOOTSEEKPLAYER ACOOTWALK COOTWALKSPEED seekplayer
ai AICOOTFLEEPLAYER ACOOTWALK COOTWALKBACKSPEED faceplayer
ai AICOOTDUCK ACOOTDUCKWALK COOTDUCKWALKSPEED seekplayer
ai AICOOTSHOOT ACOOTSHOOT COOTSTOP faceplayer
ai AICOOTDODGE ACOOTDUCKWALK COOTDODGESPEED dodgebullet

state cootseekplayer
    ifcansee
    {
        ifbulletnear { ai AICOOTDODGE }
        ifcanshoottarget
        {
            ifpdistg 4096
            {
                ifrnd 30 ai AICOOTSHOOT
                break
            }
            else
            {
                ifrnd 10 { ai AICOOTFLEEPLAYER }
                else ifrnd 100 { ai AICOOTDUCK }
                else ai AICOOTSHOOT
                break
            }
        }
        ifpdistl 4097
        {
            ifrnd 100 ai AICOOTDUCK
            else ifrnd 24 ai AICOOTSHOOT
            else ai AICOOTFLEEPLAYER
            break
        }
        
    }
ends

state cootduck
    ifbulletnear { ai AICOOTDODGE }
    ifcanshoottarget
    {
        ifcount 80
        {
            resetcount
            ai AICOOTSHOOT
            break
        }
    }
    else ai AICOOTSEEKPLAYER
ends

state cootshoot

    ifactioncount 2
    {
        resetactioncount
        sound CASUL_FIRE
        shoot SHOTSPARK1
        shoot SHOTSPARK1
        shoot SHOTSPARK1
    }
    

    ifcount 40
    {
        resetcount
        ai AICOOTSEEKPLAYER
        break
    }
    
ends

state cootdodge
    ifactioncount 6
    {
        resetactioncount
        ai AICOOTSHOOT
        break
    }
ends

state cootflee

    ifactioncount 7
    {
        resetactioncount
        ai AICOOTSHOOT
        break
    }
ends

state checkcoothit

    ifdead
    {                                         
    addkills 1
    state sangre
    ifwasweapon RPG { state paul_jibs soundonce SQUISHED killit }
    else ifwasweapon RADIUSEXPLOSION { state paul_jibs soundonce SQUISHED killit }
    else { soundonce CT_DIE action ACOOTDYING break }
        
        
    }
    else
    {
        soundonce CT_PAIN
        state random_wall_jibs
        state sangre
    }
ends

state cootdying
    ifactioncount 7 { resetactioncount sound THUD action ACOOTDEAD break }    
ends

state cootcode
    fall
    state checksquished
    ifaction ACOOTSTAND  { soundonce CT_GET ai AICOOTSEEKPLAYER }
    else ifaction ACOOTDEAD { move COOTSTOP cstat 0 }
    else ifaction ACOOTDYING { move COOTSTOP state cootdying break }
    else ifaction ACOOTPSYCHO { state genericpsychocode break }

    else ifai AICOOTSEEKPLAYER state cootseekplayer
    else ifai AICOOTDODGE state cootdodge
    else ifai AICOOTFLEEPLAYER state cootflee
    else ifai AICOOTDUCK state cootduck
    else ifai AICOOTSHOOT state cootshoot

    ifhitweapon state checkcoothit

  ifrnd 5
  {
      ifaction ACOOTDEAD { }
      else
      {
      ifrnd 16
        soundonce CT_LAF
      else ifrnd 16
        soundonce CT_LAND
      }
  }

ends


actor EXPLODINGBARREL 50 ACOOTSTAND state cootcode enda
    
// ----------------------------------------------------------------

actor MIKE 
    ifpdistl 1696 { ifhitspace { mikesnd  } }
enda

state troop_body_jibs
    ifrnd 64 guts HEADJIB1 1
    ifrnd 64 guts LEGJIB1 2
    ifrnd 64 guts ARMJIB1 1
    ifrnd 48 spawn BLOODPOOL
ends

state liz_body_jibs
ifrnd 64 guts LIZMANHEAD1 1
    ifrnd 64 guts LIZMANLEG1 2
    ifrnd 64 guts LIZMANARM1 1
    ifrnd 48 spawn BLOODPOOL
ends

state delete_enemy killit ends


action BLOODFRAMES 0 4 1 1 15
actor BLOOD 0 BLOODFRAMES
    sizeto 72 72 sizeto 72 72 sizeto 72 72
    ifpdistg 3144 killit
    ifactioncount 4 killit
enda

actor EGG 0
    cstat 289
    ifpdistl 512
    {
        sound PIPEBOMB_EXPLODE
        spawn EXPLOSION2
        hitradius 2048 500 256 128 64
        killit
    }
    ifhitweapon
    {
        ifwasweapon RADIUSEXPLOSION
        {
            sound PIPEBOMB_EXPLODE
            spawn EXPLOSION2
            hitradius 2048 500 256 128 64
            killit
        }
        else ifwasweapon RPG
        {
            sound PIPEBOMB_EXPLODE
            spawn EXPLOSION2
            hitradius 2048 500 256 128 64
            killit
        }
    }
enda

actor KNEE KNEE_WEAPON_STRENGTH enda
actor SPIT SPIT_WEAPON_STRENGTH enda
actor CHAINGUN CHAINGUN_WEAPON_STRENGTH enda
actor SHOTGUN SHOTGUN_WEAPON_STRENGTH enda
actor FIRELASER FIRELASER_WEAPON_STRENGTH enda
actor HEAVYHBOMB HANDBOMB_WEAPON_STRENGTH enda
actor BOUNCEMINE BOUNCEMINE_WEAPON_STRENGTH enda
actor MORTER MORTER_WEAPON_STRENGTH enda
actor SHRINKSPARK SHRINKER_WEAPON_STRENGTH enda
actor RPG RPG_WEAPON_STRENGTH enda
actor FREEZEBLAST FREEZETHROWER_WEAPON_STRENGTH enda
actor DEVISTATORBLAST FREEZETHROWER_WEAPON_STRENGTH enda
actor COOLEXPLOSION1 COOL_EXPLOSION_STRENGTH enda
actor TRIPBOMB TRIPBOMB_STRENGTH enda


spritenoshade 4131

useractor notenemy 4131

ifaction 0
{
setactor[THISACTOR].shade -16
getactor[THISACTOR].xrepeat TEMP addvar TEMP 4 setactor[THISACTOR].xrepeat TEMP
getactor[THISACTOR].yrepeat TEMP addvar TEMP 4 setactor[THISACTOR].yrepeat TEMP
ifvarg TEMP 16 killit
cstat 128
}

enda

gamevar hitwall 0 2

gamevar x 0 1
gamevar y 0 1
gamevar z 0 2

state SPAWNWOODHOLE
getwall[hitwall].nextsector TEMP3
ifvarn TEMP3 -1
{
getsector[TEMP3].lotag TEMP
ifvarn TEMP 0 break else setvar TEMP2 1
ifvare TEMP2 1
	{
	getsector[TEMP3].floorz TEMP
	getactor[THISACTOR].z TEMP4
	ifvarvarg TEMP TEMP4 setvar TEMP2 0 else setvar TEMP2 1
	}
} else setvar TEMP2 1
ifvare TEMP2 1
{
getsector[THISACTOR].lotag TEMP
ifvarn TEMP 0 setvar TEMP2 0 else setvar TEMP2 1
ifvare TEMP2 1 eqspawn 3452
ifvarn hitwall -1 
ifvarn RETURN -1
	{
	getwall[hitwall].shade TEMP4
	setactor[RETURN].shade TEMP4
	getwall[hitwall].pal TEMP4
	setactor[RETURN].pal TEMP4
	}
}
ends

action ZERO 0

useractor notenemy 3452 // Wood
ifaction 0
{
cstat 16
randvar TEMP 6
ifvarl TEMP 2 setvar TEMP 2
setactor[THISACTOR].xrepeat TEMP
setactor[THISACTOR].yrepeat TEMP
action ZERO
}
enda

state getfloordist
  getactor[THISACTOR].x x
  getactor[THISACTOR].y y
  updatesector x y TEMP4 // You should not trust [THISACTOR].Sectnum
  ifvarn TEMP4 -1 getflorzofslope TEMP4 x y z
  getactor[THISACTOR].z TEMP5
  subvarvar z TEMP5
  shiftvarr z 8
  subvar z 1
ends

state BULLETHITSOUNDS
ifcount 1
{
ifvare STEPSOUNDS 3
{ ifrnd 96 sound HITMETAL2 else ifrnd 96 sound HITMETAL2 else sound HITMETAL4 shoot SPARK shoot SPARK spawn 4131  }
else
ifvare STEPSOUNDS 5
{ ifrnd 96 sound HITMETAL2 else ifrnd 96 sound HITMETAL2 else sound HITMETAL4 shoot SPARK shoot SPARK spawn 4131  }
else
ifvare STEPSOUNDS 6
{ ifrnd 96 sound HITMETAL2 else ifrnd 96 sound HITMETAL2 else sound HITMETAL4 shoot SPARK shoot SPARK spawn 4131  }
else
ifvare STEPSOUNDS 8 
{ sound HITWOOD shoot SWOODSCRAP }
killit
}
ends

action WEAP2FRAMES 0  4  1  1  6
actor SHOTSPARK1 PISTOL_WEAPON_STRENGTH WEAP2FRAMES
    ifdead killit
    ifactioncount 4 killit
    else
    {
        ifactioncount 3 { ifinwater spawn WATERBUBBLE }
        else ifcount 2 { } else ifonwater spawn WATERSPLASH2
    }
	
getactor[THISACTOR].htg_t 6 hitwall
ifvarn hitwall -1
{
   getwall[hitwall].picnum FLOORTEX
	state floorsounds
   state BULLETHITSOUNDS 
   ifvare STEPSOUNDS 8 state SPAWNWOODHOLE
   getwall[hitwall].overpicnum FLOORTEX
	state floorsounds
   state BULLETHITSOUNDS
}
else
state getfloordist
ifvarl z 0 
{
getsector[THISACTOR].floorpicnum FLOORTEX
state floorsounds
state BULLETHITSOUNDS
break
}
else
ifceilingdistl 4
{
ifoutside break
getsector[THISACTOR].ceilingpicnum FLOORTEX
state floorsounds
state BULLETHITSOUNDS
break
}
	
enda

state standard_pjibs
    guts JIBS1 1
    guts JIBS3 2
    guts JIBS4 1
    guts JIBS5 1
    guts JIBS6 2
    guts DUKETORSO 1
    guts DUKELEG 2
    guts DUKEGUN 1
    ifrnd 16 money 1
ends

move DUKENOTMOVING
state handle_dead_dukes
    fall
    ifmove 0     // 1st time initializiation...
    {
        ifrnd 128 cstat 4
        else cstat 0
        move DUKENOTMOVING
    }

    ifsquished
    {
        sound SQUISHED
        spawn OOZ
        killit
    }
    else ifcount 1024 ifpdistg 4096 killit
    else
    {
        strength 0
        ifhitweapon ifwasweapon RADIUSEXPLOSION
        {
            state standard_jibs
            killit
        }
    }
ends

action PLYINGFRAMES 0 1 0 1 1
actor DUKELYINGDEAD 0 PLYINGFRAMES
    state handle_dead_dukes
enda

action PSTAND       0   1   5   1    1
action PEXPLODE     106   5   1   1   10
action PEXPLODEAD   113   1   1

action PJPHOUVER    15   1   5   1
action PWALK        20   4   5   1   16
action PRUN         20   4   5   1   10
action PWALKBACK    45   4   5  -1   16
action PRUNBACK     45   4   5  -1   10
action PJUMPING     20   3   5   1   30
action PFALLING     60   1   5
action PDUCKING     86   1   5
action PCRAWLING    86   3   5   1   20
action PAKICKING    40   2   5   1   25
action PFLINTCHING  106  1   1   1   10
action PTHROWNBACK  106  5   1   1   18
action PFROZEN       20  1   5
action PLYINGDEAD   113  1   1

action PSWIMMINGGO   20    1   5   1   10
action PSWIMMING     20   4   5   1   13
action PSWIMMINGWAIT 0    1   5   1   13
action PTREDWATER    0    2   5   1   17

move PSTOPED
move PSHRINKING // used as a var only

state check_dead_thrown_back
    ifdead
    {
        strength 0
        action PTHROWNBACK
    }
ends

state check_pstandard
    ifp pwalking action PWALK
    else ifp pkicking action PAKICKING
    else ifp pwalkingback action PWALKBACK
    else ifp prunning action PRUN
    else ifp prunningback action PRUNBACK
    else ifp pjumping
        {
        ifrnd 128 soundonce JOHN_JUMP2 else soundonce JOHN_JUMP
        action PJUMPING
        }

    else ifp pducking action PDUCKING
ends


actor APLAYER 100 PSTAND 0 0
getactor[THISACTOR].extra PHEALTH

getactor[THISACTOR].htextra TEMP
ifvarg TEMP 0 // if the actor is set to take some damage from a weapon...
	{
	   setvar PBEENHIT 26
	   getactor[THISACTOR].htang TEMP7
	   getactor[THISACTOR].ang TEMP2
	   subvarvar TEMP7 TEMP2
	   setvarvar PHITANGLE TEMP7
   }
   

state HOLD_LIGHT_INFRONT

state CHECKSTEPSOUNDS

    ifaction 0 action PSTAND
    ifdead
    {
        ifsquished palfrom 32 63 63 63
        else fall

        ifactioncount 7 { move 0 } else ifactioncount 6
        {
            ifmultiplayer { }
            else
            {
                ifrnd 32 sound DUKE_KILLED5
                else ifrnd 32 sound DUKE_KILLED3
                else ifrnd 32 sound DUKE_KILLED1
                else ifrnd 32 sound DUKE_KILLED2
            }
        }

        ifaction PLYINGDEAD
        {
            ifactioncount 3 move PSTOPED
            quote 13
            ifhitspace
            {
                action PSTAND
                spawn DUKELYINGDEAD
                resetplayer
            }
            break
        }
        else ifaction PTHROWNBACK
        {
            ifactioncount 5
            {
                spawn BLOODPOOL
                action PLYINGDEAD
            }
            else ifactioncount 1 move 0
            break
        }
        else ifaction PFROZEN
        {
            cstat 257

            palfrom 16 0 0 24

            ifhitweapon
            {
                ifwasweapon FREEZEBLAST break
                lotsofglass 60
                ifrnd 84 spawn BLOODPOOL

                getlastpal
                sound GLASS_BREAKING
                spawn ATOMICHEALTH
                cstat 32768
                action PLYINGDEAD
                break
            }

            ifactioncount THAWTIME { getlastpal strength 1 move 0 action PSTAND }
            else ifactioncount FROZENDRIPTIME { ifrnd 32 spawn WATERDRIP }

            ifp pfacing   // assumes some other player
                ifpdistl FROZENQUICKKICKDIST pkick

            break
        }
        else ifaction PEXPLODEAD
        {
            quote 13
            ifhitspace
            {
                action PSTAND
                resetplayer
            }
            break
        }
        else ifaction PEXPLODE
        {
            ifactioncount 5
            {
                action PEXPLODEAD
                spawn BLOODPOOL
            }
            break
        }

        else ifp pshrunk
        {
            state paul_jibs
            spawn BLOODPOOL

            sound SQUISHED
            sound DUKE_DEAD

            cstat 32768                 // Hide the sprite

            action PLYINGDEAD
        }

        else
        {
            ifinwater
            {
                action PLYINGDEAD
                spawn WATERBUBBLE
                spawn WATERBUBBLE
            }
            else
            {
                action PEXPLODE
                state paul_jibs
                cstat 32768
                sound SQUISHED
                sound DUKE_DEAD
            }
        }
        break
    }

    ifsquished
    {
        strength -1
        sound SQUISHED
        spawn OOZ
        break
    }

    ifp ponsteroids
    {
        ifp pstanding { }
        else spawn FRAMEEFFECT1
    }

    ifmove PSHRINKING
    {
        ifcount 32
        {
            ifcount SHRUNKDONECOUNT move 0
            else ifcount SHRUNKCOUNT
            {
                sizeto 42 36
                ifgapzl 24
                {
                    strength 0
                    sound SQUISHED
                    palfrom 48 64
                    break
                }
            }
            else ifp ponsteroids count SHRUNKCOUNT
        }
        else
        {
            ifp ponsteroids count SHRUNKCOUNT
            else { sizeto 8 9 spawn FRAMEEFFECT1 }
        }
    }

    else ifhitweapon
    {
        ifdead { sound DUKE_KILLED4 }
        else
        {
                state sangre
                sound PISTOL_BODYHIT
                ifphealthl YELLHURTSOUNDSTRENGTHMP
                {
                
                    // state headhitstate
                    ifrnd 64 sound DUKE_LONGTERM_PAIN2
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN3
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN4
                    else sound DUKE_DEAD
                }
                else
                {
                
                    ifrnd 64 sound DUKE_LONGTERM_PAIN5
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN6
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN7
                    else sound DUKE_LONGTERM_PAIN8
                }
            }

        ifwasweapon RPG
        {
            ifrnd 32 spawn BLOOD
            ifdead state paul_jibs
            palfrom 48 52
            break
        }
        ifwasweapon RADIUSEXPLOSION
        {
            ifrnd 32 spawn BLOOD
            ifdead state paul_jibs
            palfrom 48 52
            break
        }
        ifwasweapon FIREEXT
        {
            ifrnd 32 spawn BLOOD
            ifdead state paul_jibs
            palfrom 48 52
            break
        }

        ifwasweapon SHRINKSPARK
        {
            state paul_jibs
            palfrom 32 32
            break
        }

        ifwasweapon SHOTSPARK1 palfrom 24 48
        else ifwasweapon COOLEXPLOSION1 palfrom 48 48 0 48
        else ifwasweapon KNEE palfrom 16 32
        else ifwasweapon FIRELASER palfrom 32 32
        state check_dead_thrown_back
        state random_wall_jibs

        break
    }

    ifaction PFLINTCHING
    {
        ifactioncount 2 action PSTAND
        break
    }

    ifinwater
    {
        ifaction PTREDWATER
        {
            ifp pwalking prunning action PSWIMMINGGO
        }
        else ifp pstanding pwalkingback prunningback action PTREDWATER
        else
        {
            ifaction PSWIMMING
            {
                ifrnd 4 spawn WATERBUBBLE
                ifactioncount 4
                    action PSWIMMINGWAIT
            }
            else ifaction PSWIMMINGWAIT
            {
                ifactioncount 2
                    action PSWIMMINGGO
            }
            else ifaction PSWIMMINGGO
            {
                ifactioncount 2
                    action PSWIMMING
            }
            else action PTREDWATER
        }

        ifrnd 4 spawn WATERBUBBLE // For effect

        break
    }
    else ifp pjetpack
    {
        ifaction PJPHOUVER
        {
            ifactioncount 4
                resetactioncount
        }
        else action PJPHOUVER
        break
    }
    else
    {
        ifaction PTREDWATER action PSTAND
        ifaction PSWIMMING action PSTAND
        ifaction PSWIMMINGWAIT action PSTAND
        ifaction PSWIMMINGGO action PSTAND
        ifaction PJPHOUVER action PFALLING
    }

    ifaction PFALLING
    {
        ifp ponground
            { state stepsounds action PSTAND }
        else
        {
            ifp pfalling break
            else state check_pstandard
        }
    }

    ifaction PDUCKING
    {
        ifgapzl 48
        {
            ifp pwalking pwalkingback prunning prunningback action PCRAWLING
        }
        else ifp pducking
        {
            ifp pwalking pwalkingback prunning prunningback action PCRAWLING
        }
        else
        {
            ifp pstanding action PSTAND
            else state check_pstandard
        }
    }

    else ifaction PCRAWLING
    {
        ifgapzl 48
        {
            ifp pstanding action PCRAWLING
        }
        else ifp pducking
        {
            ifp pstanding action PDUCKING
        }
        else
        {
            ifp pstanding action PSTAND
            else state check_pstandard
        }
    }
    else ifgapzl 48 action PDUCKING

    else ifaction PJUMPING
    {
        ifp ponground action PSTAND
        else ifactioncount 4 ifp pfalling action PFALLING
    }

    ifp pfalling action PFALLING
    else ifaction PSTAND state check_pstandard
    else ifaction PAKICKING
    {
        ifactioncount 2 action PSTAND
        break
    }
    else ifaction PWALK
    {
        ifactioncount 3 { ifonwater { } else { resetactioncount state stepsounds } }
        ifp pfalling action PFALLING
        else ifp pstanding action PSTAND
        else ifp prunning action PRUN
        else ifp pwalkingback action PWALKBACK
        else ifp prunningback action PRUNBACK
        else ifp pjumping
            {
             ifrnd 128 soundonce JOHN_JUMP2 else soundonce JOHN_JUMP
             action PJUMPING
            }
        else ifp pducking action PDUCKING
    }

    else ifaction PRUN
    {
        ifactioncount 3 { ifonwater { } else { resetactioncount state stepsounds } }
        ifp pstanding action PSTAND
        else ifp pwalking action PWALK
        else ifp pwalkingback action PWALKBACK
        else ifp prunningback action PRUNBACK
        else ifp pjumping
            {
             ifrnd 128 soundonce JOHN_JUMP2 else soundonce JOHN_JUMP
             action PJUMPING
            }
        else ifp pducking action PDUCKING
    }

    else ifaction PWALKBACK
    {
        ifactioncount 3 { ifonwater { } else { resetactioncount state stepsounds } }
        ifp pstanding action PSTAND
        else ifp pwalking action PWALK
        else ifp prunning action PRUN
        else ifp prunningback action PRUNBACK
        else ifp pjumping
        {
             ifrnd 128 soundonce JOHN_JUMP2 else soundonce JOHN_JUMP
             action PJUMPING
        }
        else ifp pducking action PDUCKING
    }

    else ifaction PRUNBACK
    {
        ifactioncount 3 { ifonwater { } else { resetactioncount state stepsounds } }
        ifp pstanding action PSTAND
        else ifp pwalking action PWALK
        else ifp prunning action PRUN
        else ifp pwalkingback action PWALKBACK
        else ifp pjumping
            {
             ifrnd 128 soundonce JOHN_JUMP2 else soundonce JOHN_JUMP
             action PJUMPING
            }
        else ifp pducking action PDUCKING
    }
   addammo FREEZE_WEAPON 11 shoot SHOTGUN  spawn SHELL 
  {
  }

enda

actor ORGANTIC TURRETSTRENGTH
    ifcount 48 resetcount
    else { ifcount 32 sizeto 32 32 }
    else ifcount 16 { sizeto 48 18 ifpdistl 2048 { sound TURR_ATTACK addphealth -2 palfrom 32 16 } }
    ifhitweapon { ifdead { addkills 1 sound TURR_DYING guts JIBS5 10 state delete_enemy } sound TURR_PAIN break }
    ifrnd 1 soundonce TURR_ROAM
enda

state rf
    ifrnd 128 cstat 4
    else cstat 0
ends




//
//
//      YELLOW SOLDIER CODE
//
//

action ATROOPSTAND       0    1    1    1    1
action ATROOPSTAYSTAND   0    1    1    1    1
action ATROOPWALKING     0    6    1    1   10
action ATROOPWALKINGBACK 0    6    1    1   10
action ATROOPRUNNING     0    6    1    1   10
action ATROOPSHOOT       6    4    1    1   10
action ATROOPJETPACK    40    1    5    1    1
action ATROOPJETPACKILL 40    2    5    1   50
action ATROOPFLINTCH    50    1    1    1    6
action ATROOPDYING      10    5    1    1   12
action ATROOPDEAD       14
action ATROOPPLAYDEAD   14
action ATROOPSUFFERDEAD 58    2    1   -4   24
action ATROOPSUFFERING  59    2    1    1   21
action ATROOPDUCK       9     1    1    1    3
action ATROOPDUCKSHOOT  6     4    1    1   10
action ATROOPABOUTHIDE  74    1    1    1   25
action ATROOPHIDE       79    1    1    1   25
action ATROOPREAPPEAR   74    1    1    1   25
action ATROOPFROZEN      0    1    1

move TROOPWALKVELS 72
move TROOPWALKVELSBACK -72
move TROOPJETPACKVELS 64 -84
move TROOPJETPACKILLVELS 192 -38
move TROOPRUNVELS 108
move TROOPDODGEVELS 210
move TROOPSTOPPED
move DONTGETUP
move SHRUNKVELS 32

ai AITROOPSEEKENEMY  ATROOPWALKING   TROOPWALKVELS seekplayer
ai AITROOPSEEKPLAYER ATROOPWALKING   TROOPWALKVELS seekplayer
ai AITROOPFLEEING    ATROOPWALKING   TROOPWALKVELS fleeenemy
ai AITROOPFLEEINGBACK ATROOPWALKINGBACK   TROOPWALKVELSBACK faceplayer
ai AITROOPDODGE      ATROOPWALKING   TROOPDODGEVELS  faceplayer dodgebullet
ai AITROOPSHOOTING   ATROOPSHOOT     TROOPSTOPPED  faceplayer
ai AITROOPDUCKING    ATROOPDUCK      TROOPSTOPPED  faceplayer
ai AITROOPJETPACK    ATROOPJETPACK   TROOPJETPACKVELS seekplayer
ai AITROOPSHRUNK     ATROOPWALKING   SHRUNKVELS fleeenemy
ai AITROOPHIDE       ATROOPABOUTHIDE TROOPSTOPPED faceplayer

state troopdodgestate
    ifactioncount 6 { ai AITROOPSEEKPLAYER break }
ends

state troophidestate
    ifaction ATROOPREAPPEAR
    {
        ifactioncount 2 { sound TELEPORTER ai AITROOPSHOOTING cstat 257 }
        else { sizeto 41 40 sizeto 41 40 sizeto 41 40 sizeto 41 40 spawn FRAMEEFFECT1 }
    }
    else ifaction ATROOPWALKING
    {
        ifpdistl 2448 ifpdistg 1024
        {
            ifceilingdistl 48 break
            ifp pfacing break

            ifgapzl 64 { } else ifawayfromwall { spawn TRANSPORTERSTAR action ATROOPREAPPEAR move 0 break }
        }
    }
    else ifaction ATROOPHIDE
    {
        ifactioncount 2
        {
            spawn TRANSPORTERSTAR
            sound TELEPORTER
            action ATROOPWALKING move TROOPWALKVELS faceplayer
            cstat 32768
        }
        else
        {
            sizeto 0 40
            sizeto 0 40
            sizeto 0 40
            sizeto 0 40
            spawn FRAMEEFFECT1
        }
    }
    else ifaction ATROOPABOUTHIDE ifactioncount 2 { action ATROOPHIDE cstat 0 }
ends


state troopgunnashoot
    ifp palive
    {
        ifpdistl 1024 ai AITROOPSHOOTING
        else ifactornotstayput
        {
            ifactioncount 12 ifrnd 16 ifcanshoottarget
            {
                ifspritepal 21 ifrnd 4 ifpdistg 4096 ai AITROOPHIDE
                else
                {
                    ifpdistl 1100 ai AITROOPFLEEING
                    else
                    {
                        ifpdistl 4096 ifcansee ifcanshoottarget ai AITROOPSHOOTING
                        else { move TROOPRUNVELS seekplayer action ATROOPRUNNING }
                    }
                }
            }
        }
        else ifcount 26 ifrnd 32 ai AITROOPSHOOTING
    }
ends

state troopseekstate
    state troopgunnashoot
    ifbulletnear {  ai AITROOPDODGE }
    ifinwater { ai AITROOPJETPACK break }
    ifcansee
    {
        ifmove TROOPRUNVELS ifpdistl 1596 ai AITROOPDUCKING

        ifrnd 2
        {
            ifspritepal 21 ifpdistg 1596 { ai AITROOPHIDE break }

        }
    }
    ifnotmoving { ifrnd 32 operate else ifcount 32 ifp palive ifcansee ifcanshoottarget ai AITROOPSHOOTING }
    ifrnd 1  { soundonce PRED_ROAM } 
ends

state troopduckstate
    ifaction ATROOPDUCK
        { ifactioncount 8 { ifp palive { ifrnd 128 action ATROOPDUCKSHOOT } else ifmove DONTGETUP break else ai AITROOPSEEKPLAYER } }
    else ifaction ATROOPDUCKSHOOT
    {
        ifcount 64
        {
            ifmove DONTGETUP resetcount
            else
            {
                ifpdistl 1100
                    ai AITROOPFLEEING
                else ai AITROOPSEEKPLAYER
            }
        }
        else ifactioncount 4 { ifcanshoottarget { sound PIG_ATTACK resetactioncount shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN spawn SHOTGUNSHELL } else ai AITROOPSEEKPLAYER }
    }
ends

state troopshootstate
        ifbulletnear {  ai AITROOPDODGE }
    ifactioncount 4
    {
        ifcanshoottarget
        {
            sound PIG_ATTACK
            shoot SHOTGUN shoot SHOTGUN shoot SHOTGUN spawn SHOTGUNSHELL resetactioncount
            ifrnd 128 ai AITROOPSEEKPLAYER
            ifcount 24
            {
                ifrnd 96 ifpdistg 2048 ai AITROOPSEEKPLAYER
                else
                {
                    ifpdistg 1596 ai AITROOPFLEEING
                    else ai AITROOPFLEEINGBACK
                }
            }
        }
        else ai AITROOPSEEKPLAYER
    }
ends

state troopfleestate
        ifbulletnear {  ai AITROOPDODGE }
    ifactioncount 7
    {
        ifpdistg 3084 { ai AITROOPSEEKPLAYER break }
        else ifrnd 32 ifp palive ifcansee ifcanshoottarget { ifrnd 128 ai AITROOPDUCKING else ai AITROOPSHOOTING break }
    }
    ifnotmoving
    {
        ifrnd 32 operate else ifcount 32 ifp palive ifcansee ifcanshoottarget
            { ifrnd 128 ai AITROOPSHOOTING else ai AITROOPDUCKING }
    }
ends

state troopdying
    iffloordistl 32 { ifactioncount 5 { cstat 0 iffloordistl 8 sound THUD ifrnd 64 spawn BLOODPOOL state rf strength 0 move TROOPSTOPPED action ATROOPDEAD } break }
    else { state rf move 0 action ATROOPDYING }
ends

state checktroophit
//    ifaction ATROOPSUFFERING { stopsound LIZARD_BEG soundonce PRED_DYING cstat 0 strength 0 action ATROOPSUFFERDEAD break }
    ifdead
    {
        state drop_ammo
        state sangre
        state random_wall_jibs
        addkills 1

        ifwasweapon RPG { sound SQUISHED state troop_body_jibs state standard_jibs state delete_enemy }
        else ifwasweapon RADIUSEXPLOSION { sound SQUISHED state troop_body_jibs state standard_jibs state delete_enemy }
        else { soundonce PRED_DYING action ATROOPDYING break }
    }
    else
    {
        state sangre
        state random_wall_jibs
        ifwasweapon RPG { soundonce PRED_PAIN } else { soundonce SOLDIER_1 }
        ifwasweapon SHRINKSPARK { sound ACTOR_SHRINKING ai AITROOPSHRUNK }

    }
ends

state troopjetpackstate
    ifaction ATROOPJETPACKILL
    {
        ifcansee ifactioncount 2
        {
            resetactioncount
            sound PRED_ATTACK
            shoot FIRELASER
        }

        ifp phigher ai AITROOPJETPACK
        else ifinwater ai AITROOPJETPACK
        else ifcount 26 iffloordistl 32 ai AITROOPSEEKPLAYER
    }
    else ifcount 48 ifcansee
        { action ATROOPJETPACKILL move TROOPJETPACKILLVELS seekplayer }
ends


state troopsufferingstate
    ifactioncount 2
    {
        ifrnd 16 spawn WATERDRIP
        ifactioncount 14 { stopsound LIZARD_BEG cstat 0 strength 0 action ATROOPSUFFERDEAD break }
    }
ends

state troopshrunkstate
    ifcount SHRUNKDONECOUNT ai AITROOPSEEKENEMY
    else ifcount SHRUNKCOUNT sizeto 48 40
    else state genericshrunkcode
ends

state troopcode fall
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    sizeto 20 20
    ifinwater ifrnd 1 spawn WATERBUBBLE
    ifaction ATROOPSTAND { ifrnd 192 ai AITROOPSHOOTING else ai AITROOPSEEKPLAYER }
    else ifaction ATROOPFROZEN
    {
        state genericpsychocode
        break
    }
    else ifaction ATROOPPLAYDEAD
    {
        ifhitweapon
        {
            ifwasweapon RADIUSEXPLOSION { sound SQUISHED state troop_body_jibs state standard_jibs state delete_enemy }
            break
        }
        else state checksquished

        ifcount PLAYDEADTIME { addkills -1 soundonce PRED_ROAM cstat 257 strength 1 ai AITROOPSHOOTING }
        else ifp pfacing resetcount

        break
    }
    else ifaction ATROOPDEAD
    {
        strength 0
        ifrespawn ifcount RESPAWNACTORTIME { spawn TRANSPORTERSTAR cstat 257 strength TROOPSTRENGTH ai AITROOPSEEKENEMY }
        ifhitweapon
        {
            ifwasweapon RADIUSEXPLOSION { sound SQUISHED state troop_body_jibs state standard_jibs state delete_enemy }
            break
        }
        else state checksquished
        break
    }
    else ifaction ATROOPSUFFERDEAD
    {
        ifactioncount 2
        {
            ifrnd 64 { resetcount action ATROOPPLAYDEAD }
            else { soundonce PRED_DYING action ATROOPDEAD }
        }
    }
    else ifaction ATROOPDYING { state troopdying break }
    else ifaction ATROOPSUFFERING
        { state troopsufferingstate ifhitweapon state checktroophit break }
    else ifaction ATROOPFLINTCH { ifactioncount 4 ai AITROOPSEEKENEMY }
    else
    {
        ifai AITROOPSEEKPLAYER state troopseekstate
        else ifai AITROOPJETPACK
        {
            state troopjetpackstate
            ifinwater { } else soundonce DUKE_JETPACK_IDLE
        }
        else ifai AITROOPSEEKENEMY state troopseekstate
        else ifai AITROOPSHOOTING state troopshootstate
        else ifai AITROOPFLEEING state troopfleestate
        else ifai AITROOPFLEEINGBACK state troopfleestate
        else ifai AITROOPDODGE  { ifrnd 2 { soundonce PRED_ROAM2 } state troopdodgestate }
        else ifai AITROOPDUCKING state troopduckstate
        else ifai AITROOPSHRUNK state troopshrunkstate
        else ifai AITROOPHIDE { state troophidestate break }
    }

    ifhitweapon state checktroophit else state checksquished
ends

eventloadactor LIZTROOP setactor[THISACTOR].xrepeat 20 setactor[THISACTOR].yrepeat 20 enda

actor LIZTROOP TROOPSTRENGTH ATROOPSTAND state troopcode enda

action ALIZWALKING       0     10   1    1    9
action ALIZRUNNING       0     10   1    1    7
action ALIZSHOOTING      10    2    1    1    6
action ALIZDYING         12    8    1    1    11
action ALIZLYINGDEAD     19    1
action ALIZFROZEN         0    1    1

move LIZWALKVEL 62
move LIZRUNVEL  82
move LIZDODGEVEL 432
move LIZSTOP

ai AILIZGETENEMY ALIZWALKING LIZWALKVEL seekplayer
ai AILIZDODGE ALIZSHOOTING LIZDODGEVEL dodgebullet faceplayer
ai AILIZCHARGEENEMY ALIZRUNNING LIZRUNVEL seekplayer
ai AILIZSHOOTENEMY ALIZSHOOTING LIZSTOP faceplayer
ai AILIZFLEENEMY ALIZWALKING LIZWALKVEL faceplayer
ai AILIZSHRUNK ALIZWALKING SHRUNKVELS fleeenemy
ai AILIZDYING ALIZDYING LIZSTOP faceplayer

state lizseekstate

    ifbulletnear {  ai AILIZDODGE  }
    ifactornotstayput
    {
        ifcansee ifp palive ifcount 16 ifcanshoottarget { resetcount ai AILIZSHOOTENEMY break }
        ifai AILIZCHARGEENEMY
        {
            ifcount 72 ifcanshoottarget { ai AILIZSHOOTENEMY break }

        }
        else ifpdistg 4096 { ifrnd 13 { ifcanshoottarget ai AILIZSHOOTENEMY } else ifcount 24 { ai AILIZCHARGEENEMY break } }


        ifrnd 4 ifnotmoving operate
    }
    else
    {
        ifactioncount 16 { ifp palive ifrnd 32 ifcansee ifcanshoottarget ai AILIZSHOOTENEMY }
        ifcount 16 ifrnd 32 move LIZWALKVEL randomangle geth
    }

ends

state lizshrunkstate
    ifcount SHRUNKDONECOUNT ai AILIZGETENEMY
    else ifcount SHRUNKCOUNT sizeto 48 40
    else state genericshrunkcode
ends

state lizfleestate
    ifbulletnear {  ai AILIZDODGE  }
    ai AILIZGETENEMY break
ends


state lizshootstate
    ifbulletnear {  ifrnd 60 { ai AILIZDODGE  } }
    ifcount 20 ifrnd 8
    {
        ifcansee ifpdistl 2048 { ifrnd 128 ai AILIZFLEENEMY break }
        ai AILIZGETENEMY
    }
    ifactioncount 2
    {
        ifcansee
        {
            ifcanshoottarget { sound CAPT_ATTACK shoot SHOTSPARK1 resetactioncount }
            
        }
        else ai AILIZGETENEMY
    }
ends

state checklizhit
    
    
    ifai AILIZSHRUNK
        { addkills 1 sound SQUISHED state standard_jibs state delete_enemy }
    ifdead
    {
		spritepal 3
        state sangre
        state drop_sgshells


        addkills 1

        ifwasweapon RPG { sound SQUISHED  state standard_jibs state delete_enemy }
        else ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy }
        else { state rf ai AILIZDYING ifrnd 64 spawn BLOODPOOL }
        sound CAPT_DYING
    }
    else
    {
		ifstrength 95 spritepal 3
        state sangre
        soundonce CAPT_PAIN
        ifwasweapon SHRINKSPARK { sound ACTOR_SHRINKING ai AILIZSHRUNK break }
        state random_wall_jibs
        
    }
ends


state lizdyingstate
    
    ifaction ALIZLYINGDEAD
    {
        strength 0
        ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy }
        ifcount RESPAWNACTORTIME ifrespawn
        {
            spawn TRANSPORTERSTAR cstat 257 strength LIZSTRENGTH ai AILIZGETENEMY
        }
    }
    else ifai AILIZDYING ifactioncount 8 { iffloordistl 8 sound THUD move LIZSTOP action ALIZLYINGDEAD }
ends

state lizdodgestate
    ifactioncount 2 {  resetactioncount sound CAPT_ATTACK shoot SHOTSPARK1 }
    ifcount 8 ai AILIZGETENEMY
ends

eventloadactor LIZMANSTAYPUT setactor[THISACTOR].xrepeat 22 setactor[THISACTOR].yrepeat 19 enda

actor LIZMANSTAYPUT LIZSTRENGTH ai AILIZGETENEMY cactor LIZMAN enda

eventloadactor LIZMAN setactor[THISACTOR].xrepeat 22 setactor[THISACTOR].yrepeat 19 enda

actor LIZMAN LIZSTRENGTH fall
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    state checksquished
    ifai 0 ai AILIZGETENEMY
    else ifaction ALIZLYINGDEAD { fall state lizdyingstate break }
    else ifaction ALIZFROZEN
    {
        state genericpsychocode
        break
    }

    else
    {
        fall
        ifai AILIZGETENEMY state lizseekstate
        else ifai AILIZCHARGEENEMY state lizseekstate
        else ifai AILIZDODGE state lizdodgestate
        else ifai AILIZSHOOTENEMY state lizshootstate
        else ifai AILIZFLEENEMY state lizfleestate
        else ifai AILIZSHRUNK state lizshrunkstate
        else ifai AILIZDYING state lizdyingstate
    }

    ifai AILIZSHRUNK break
    ifhitweapon state checklizhit
enda


action AOCTAWALK        0   2   5   1   30
action AOCTASTAND       0   1   5   1   15
action AOCTASCRATCH     10  3   1   1   18 
action AOCTAHIT        0    1   1   1   10
action AOCTASHOOT      15   3   1   1    9
action AOCTADYING      30   8   1   1   17
action AOCTADEAD       38   1   1   1    1
action AOCTAFROZEN      0   1   5

move OCTAWALKVELS 320 -30
move OCTAUPVELS 320 -70
move OCTASTOPPED 0 -30
move OCTAINWATER 96 24
move OCTAFAST 520

ai AIOCTAGETENEMY AOCTAWALK OCTAWALKVELS seekplayer
ai AIOCTASHOOTENEMY AOCTASHOOT OCTASTOPPED faceplayer
ai AIOCTAGETFAST AOCTAWALK OCTAFAST faceplayer seekplayer
ai AIOCTASCRATCHENEMY AOCTASCRATCH OCTASTOPPED faceplayer
ai AIOCTAHIT AOCTAHIT OCTASTOPPED faceplayer
ai AIOCTASHRUNK AOCTAWALK SHRUNKVELS faceplayer
ai AIOCTADYING AOCTADYING OCTASTOPPED faceplayer

state octafaststate
    ifpdistl 4000
    {
        ifrnd 128
        {
            ai AIOCTASHOOTENEMY
        }
        else
        {
            ai AIOCTAGETFAST
        }
    }
    ifpdistl 1280
    {
        ai AIOCTASCRATCHENEMY
    }
ends

state octagetenemystate

    ifcansee
    {
        ifpdistg 7048 { ai AIOCTAGETFAST }
        ifrnd 48 { ifcanshoottarget { ifpdistl 4016 { soundonce OCTA_ATTACK1 ai AIOCTASHOOTENEMY break } else { ai AIOCTAGETFAST break } } }
        else ifpdistl 1280 ai AIOCTASCRATCHENEMY
    }

ends

state octascratchenemystate
    ifpdistg 1280 ai AIOCTAGETENEMY
    else ifactioncount 3 { resetactioncount sound OCTA_ATTACK2 palfrom 8 32 addphealth OCTASCRATCHINGPLAYER }
ends

state octashootenemystate
    ifpdistg 7048 { ai AIOCTAGETFAST }
    ifcount 25 { ifcount 27 ai AIOCTAGETENEMY }
    ifactioncount 3 { resetactioncount sound THUD shoot SPIT }
ends

state checkoctahitstate

    ifwasweapon SHRINKSPARK { sound ACTOR_SHRINKING ai AIOCTASHRUNK }
    else
    {
        ifdead
        {
           state sangre

            addkills 1
            ifwasweapon RPG { sound SQUISHED state standard_jibs state delete_enemy }
            else ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy }
            else { state rf ai AIOCTADYING }
            soundonce OCTA_DYING
        }
        else
        {
            state sangre
            ifwasweapon RPG
            {
                soundonce OCTA_DYING
                addkills 1
                state standard_jibs
                killit
            }
            soundonce OCTA_PAIN 
            ifrnd 64 ai AIOCTAHIT

        }
    }
    state random_wall_jibs
ends

state octashrunkstate
    ifcount SHRUNKDONECOUNT ai AILIZGETENEMY
    else ifcount SHRUNKCOUNT sizeto 48 40
    else state genericshrunkcode
ends

state octadyingstate
    ifactioncount 8 { ifrnd 64 spawn BLOODPOOL move OCTASTOPPED action AOCTADEAD break }
    else ifactioncount 5 { } else ifactioncount 4 iffloordistl 8 sound THUD
ends

actor OCTABRAINSTAYPUT OCTASTRENGTH ai AIOCTAGETENEMY cactor OCTABRAIN enda

actor OCTABRAIN OCTASTRENGTH fall

    state checksquished

    ifai 0 ai AIOCTAGETENEMY
    else ifaction AOCTADEAD
    {
        strength 0
        ifcount RESPAWNACTORTIME ifrespawn
            { addkills -1 spawn TRANSPORTERSTAR cstat 257 strength OCTASTRENGTH ai AIOCTAGETENEMY }
        ifhitweapon ifwasweapon RADIUSEXPLOSION { state standard_jibs killit }
        break
    }
    else ifaction AOCTAFROZEN
    {
        state genericpsychocode
        break
    }

    else
    {
        ifrnd 1 soundonce OCTA_ROAM

        ifai AIOCTAGETENEMY state octagetenemystate
        else ifai AIOCTAHIT { ifcount 8 ai AIOCTASHOOTENEMY }
        else ifai AIOCTAGETFAST state octafaststate
        else ifai AIOCTADYING { state octadyingstate break }
        else ifai AIOCTASCRATCHENEMY state octascratchenemystate
        else ifai AIOCTASHOOTENEMY state octashootenemystate
        else ifai AIOCTASHRUNK state octashrunkstate

        ifmove OCTAUPVELS { } else ifp phigher move OCTAUPVELS seekplayer
        else ifmove OCTAINWATER { } else ifinwater move OCTAINWATER seekplayer

        ifhitweapon state checkoctahitstate
    }
enda

action ASKAARJSTAND  0 1 1 1 1
action ASKAARJRUN    271 10 1 1 8
action ASKAARJFIGHT  260 11 1 1 8
action ASKAARJSHOOT  281 6 1 1 8
action ASKAARJCLAW   287 9 1 1 8
action ASKAARJDYING  300 6 1 1 14
action ASKAARJDEAD   305 1 1 1 1
action ASKAARJJUMP   306 3 1 1 25
action ASKAARJINAIR  309 1 1 1 1
action ASKAARJDUCK   310 1 1 1 1

move SKAARJRUNVELS 316
move SKAARJJUMPVELS 351
move SKAARJDODGEVELS 525
move SKAARJSTOP

ai AISKAARJRUNENEMY ASKAARJRUN SKAARJRUNVELS seekplayer
ai AISKAARJDODGE ASKAARJRUN SKAARJDODGEVELS dodgebullet
ai AISKAARJFIGHT ASKAARJFIGHT SKAARJSTOP faceplayer
ai AISKAARJSHOOT ASKAARJSHOOT SKAARJSTOP faceplayer
ai AISKAARJCLAW ASKAARJCLAW SKAARJSTOP faceplayerslow
ai AISKAARJDYING ASKAARJDYING SKAARJSTOP faceplayerslow
ai AISKAARJJUMP ASKAARJJUMP SKAARJJUMPVELS jumptoplayer
ai AISKAARJFALL ASKAARJINAIR SKAARJJUMPVELS jumptoplayer
ai AISKAARJDUCK ASKAARJDUCK SKAARJSTOP faceplayer


state skaarjseek
fall
ifcansee
{
    ifbulletnear { ifrnd 80 { ai AISKAARJDUCK } else { ai AISKAARJDODGE } break }
    ifpdistl 1024
    {
        ai AISKAARJCLAW
        break
    }
    ifpdistg 6048
    {
        ifrnd 7
        {
            ai AISKAARJJUMP
            break
        }
    }
    ifcanshoottarget
    {
        ifrnd 6
        {
        ai AISKAARJSHOOT
        break
        }
    }
    ifrnd 9
    {
            ai AISKAARJFIGHT
            break
        
    }
}
ends

state skaarjfight
    fall
    ifbulletnear { ifrnd 80 { ai AISKAARJDUCK } else { ai AISKAARJDODGE } break }
    ifactioncount 22
    {
        resetactioncount
        ifcanshoottarget
        {
            ai AISKAARJSHOOT
            break
        }
        else
        {
            ai AISKAARJRUNENEMY
            break
        }
    }
ends

state skaarjshoot
    fall
    ifbulletnear { ifrnd 80 { ai AISKAARJDUCK } else { ai AISKAARJDODGE } break }
    ifcansee
    {
    ifactioncount 6
    {
        resetactioncount
        sound DRON_ATTACK1
        shoot FIRELASER
        shoot FIRELASER
    }
    }
    else { ai AISKAARJRUNENEMY }
    ifcount 80 ai AISKAARJRUNENEMY
ends

state skaarjdodge
    fall
    ifactioncount 10
    {
        resetactioncount
        ai AISKAARJSHOOT
        break
    }
ends

state skaarjclaw
    fall
    ifactioncount 9
    {
        resetactioncount
        soundonce OCTA_ATTACK2
        palfrom 32 32
        addphealth -30
    }
    ifpdistg 1024
    {
        ai AISKAARJSHOOT
        break
    }
ends

state skaarjdying
    ifactioncount 6
    {
        resetactioncount
        action ASKAARJDEAD
        break
    }
ends

state skaarjduck
    cstat 0
    ifcount 20
    {
        resetcount
        cstat 257
        fall
        ai AISKAARJSHOOT
        break
    }
ends

state skaarjjump
    ifactioncount 3
    {
        resetactioncount
        ai AISKAARJFALL
    }
ends

state skaarjfall
    ifcount 40
    {
        resetcount
        ai AISKAARJRUNENEMY
        break
    }
    else ifpdistl 1026
    {
        move 0
        fall
        ifpdistl 1024
        {
            ai AISKAARJCLAW
            break
        }
        else
        {
            ai AISKAARJSHOOT
            break
        }
    }
ends

state checkskaarjhit
    ifdead
    {
        ifwasweapon RPG { state paul_jibs state sangre sound SQUISHED killit }
        else ifwasweapon RADIUSEXPLOSION { state paul_jibs state sangre sound SQUISHED killit }
        else { soundonce DRON_DYING state sangre ai AISKAARJDYING break }
    }
    else
    {
        soundonce DRON_PAIN
        state random_wall_jibs
        state sangre
    }
ends

state skaarjcode
    fall
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    sizeto 27 22
    ifinwater fall
    ifonwater fall
    ifrnd 1 { ifaction ASKAARJDEAD { } else { soundonce DRON_ROAM } }
    ifrnd 1 { ifaction ASKAARJDEAD { } else { ifrnd 8 { soundonce DRON_ATTACK2 } } }
    ifaction ASKAARJSTAND { ai AISKAARJSHOOT }
    else ifaction ASKAARJDEAD
    {
      ifcount 150
        {
        resetcount
        cstat 32768
        killit
        break
        }
        else
    ifcount 125
      cstat 514
    else
  ifcount 100
    cstat 2
    }

    ifai AISKAARJRUNENEMY state skaarjseek
    else ifai AISKAARJDODGE state skaarjdodge
    else ifai AISKAARJSHOOT state skaarjshoot
    else ifai AISKAARJFIGHT state skaarjfight
    else ifai AISKAARJCLAW state skaarjclaw
    else ifai AISKAARJDYING state skaarjdying
    else ifai AISKAARJJUMP state skaarjjump
    else ifai AISKAARJFALL state skaarjfall
    else ifai AISKAARJDUCK state skaarjduck
    ifhitweapon state checkskaarjhit else state checksquished
ends

eventloadactor DRONE setactor[THISACTOR].xrepeat 27 setactor[THISACTOR].yrepeat 22 enda

actor DRONE 90 ASKAARJSTAND state skaarjcode enda


action APIGWALK         0  7 1 1 10
action APIGRUN          0  7 1 1 8
action APIGSHOOT        7  2 1 1 8
action APIGSTAND        0  1 1 1 1
action APIGDYING        9  6 1 1 12
action APIGDEAD         15 1 1 1 1
action APIGFROZEN       0  1 1

move PIGWALKVELS 122
move PIGDODGEVELS 260
move PIGRUNVELS 158
move PIGSTOPPED

ai AIPIGSEEKENEMY APIGWALK PIGWALKVELS seekplayer
ai AIPIGSHOOTENEMY APIGSHOOT PIGSTOPPED faceplayer
ai AIPIGCHARGE APIGRUN PIGRUNVELS seekplayer
ai AIPIGFLEEENEMY APIGWALK PIGWALKVELS fleeenemy
ai AIPIGSHOOT APIGSHOOT PIGSTOPPED faceplayer
ai AIPIGDODGE APIGRUN PIGDODGEVELS dodgebullet faceplayer
ai AIPIGDYING APIGDYING PIGSTOPPED faceplayer
ai AIPIGSHRINK APIGWALK SHRUNKVELS fleeenemy


state pigseekenemystate

    ifbulletnear ai AIPIGDODGE 
    ifai AIPIGCHARGE
    {
        ifrnd 3 ifp palive ifcanshoottarget {  ai AIPIGSHOOTENEMY  break }           
        ifcansee ifpdistl 3084
        {
            ai AIPIGSEEKENEMY
 
        }
        break
    }
    else iffloordistl 32
    {
        ifpdistg 4096 { ifactornotstayput ai AIPIGCHARGE }
        ifrnd 3 ifp palive ifcanshoottarget {  ai AIPIGSHOOTENEMY  break } 
    }

    ifrnd 128 ifcansee
    {
        ifai AIPIGDODGE { ifcount 32 ai AIPIGCHARGE break }
        iffloordistl 32
        {
            ifpdistl 1024 ifp palive ifcanshoottarget
                { ai AIPIGSHOOTENEMY break }
                ifrnd 8 ifp palive ifcanshoottarget {  ai AIPIGSHOOTENEMY  break } 
        }
    }
ends


state pigdodgestate
      ifactioncount 7
      {
        ai AIPIGSHOOTENEMY
      }
ends


state pigshootenemystate
//    ifcansee
    {
        ifbulletnear { ifrnd 34 ai AIPIGDODGE }
        ifactioncount 2
        {
            ifcanshoottarget { resetactioncount sound PISTOL_FIRE shoot SHOTSPARK1 shoot SHOTSPARK1 }
            else ai AIPIGSEEKENEMY
        }
        
        ifcount 62
        {
                resetcount
                ifpdistl 768 ai AIPIGFLEEENEMY
                else ai AIPIGSEEKENEMY
            
        }
        
    }
    else ai AIPIGSEEKENEMY
ends

state pigfleeenemystate
    ifbulletnear ai AIPIGDODGE 
    ifactioncount 8 ai AIPIGSEEKENEMY
    else ifnotmoving ai AIPIGSEEKENEMY
ends


state checkpighitstate
    
    ifdead
    {
		spritepal 3
        state sangre
        state random_wall_jibs

        addkills 1
        ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy }
        else ifwasweapon RPG { sound SQUISHED state standard_jibs state delete_enemy }
        ai AIPIGDYING sound PIG_DYING
    }
    else
    {
		ifstrength 50 spritepal 3
        soundonce PIG_PAIN
        state sangre
        state random_wall_jibs

        ifwasweapon SHRINKSPARK { sound ACTOR_SHRINKING ai AIPIGSHRINK }
        ifrnd 64 ai AIPIGSHOOTENEMY

    }
ends

state pigshrinkstate
    ifcount SHRUNKDONECOUNT ai AIPIGSEEKENEMY
    else ifcount SHRUNKCOUNT sizeto 48 40
    else state genericshrunkcode
ends

state pigdyingstate
    ifactioncount 5 { ifrnd 64 spawn BLOODPOOL state rf iffloordistl 8 sound THUD action APIGDEAD move PIGSTOPPED break }
ends


eventloadactor PIGCOPSTAYPUT setactor[THISACTOR].xrepeat 20 setactor[THISACTOR].yrepeat 17 enda

actor PIGCOPSTAYPUT PIGCOPSTRENGTH ai AIPIGSEEKENEMY cactor PIGCOP enda

eventloadactor PIGCOP setactor[THISACTOR].xrepeat 20 setactor[THISACTOR].yrepeat 17 enda

actor PIGCOP PIGCOPSTRENGTH APIGSTAND
    fall
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    sizeto 20 17
    state checksquished
    ifaction APIGSTAND
    {
        ai AIPIGSEEKENEMY
    }
    else ifaction APIGDEAD
    {
        ifrespawn ifcount RESPAWNACTORTIME
            { spawn TRANSPORTERSTAR cstat 257 strength PIGCOPSTRENGTH ai AIPIGSEEKENEMY }
        else { strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy } break }
    }
    else ifaction APIGFROZEN
    {
        state genericpsychocode
        break
    }
    else ifai AIPIGDYING state pigdyingstate
    else ifai AIPIGSHRINK state pigshrinkstate
    else
    {
        ifai AIPIGSEEKENEMY state pigseekenemystate
        else ifai AIPIGDODGE state pigdodgestate
        else ifai AIPIGSHOOTENEMY state pigshootenemystate
        else ifai AIPIGFLEEENEMY state pigfleeenemystate
        else ifai AIPIGCHARGE state pigseekenemystate
        ifhitweapon state checkpighitstate
        ifrnd 1
        {
            ifrnd 32 soundonce PIG_ROAM
            else ifrnd 64 soundonce PIG_ROAM2
            else soundonce PIG_ROAM3
        }
    }
enda




action ABOSS1STAND               0  1  5  1  1
action ABOSS1WALK                5  6  5  1  10
action ABOSS1RUN                 5  6  5  1  10
action ABOSS1SCRATCH            40 14  1  1  10
action ABOSS1DYING              57 8  1  1  14
action ABOSS1JUMP               54 3 1 1 20
action ABOSS1FALL               56 1 1 1 1  
action ADEMONHIT                70 6 1 1 10
action ABOSS1DEAD               65 1  1  1   1

move PALBOSS1SHRUNKRUNVELS 32
move PALBOSS1RUNVELS 209
move DEMONBACK   -208
move BOSS1WALKVELS 208
move BOSS1RUNVELS 440
move BOSS1STOPPED

ai AIBOSS1SEEKENEMY ABOSS1WALK BOSS1WALKVELS seekplayer
ai AIBOSS1SCRATCHENEMY ABOSS1SCRATCH BOSS1STOPPED faceplayer
ai AIBOSS1DYING ABOSS1DYING BOSS1STOPPED faceplayer
ai AIDEMONBACK ABOSS1RUN  DEMONBACK faceplayer  
ai AIDEMONHIT ADEMONHIT BOSS1STOPPED faceplayer
ai AIBOSS1JUMP ABOSS1JUMP BOSS1RUNVELS jumptoplayer

state demonback
    ifpdistg 1200
    {
        ai AIBOSS1SCRATCHENEMY
        break
    }
ends

state demonhithead
    ifactioncount 6
    {
        ifpdistl 2048
        {
        ai AIBOSS1SEEKENEMY
        break
        }
        else
        {
        ai AIBOSS1JUMP
        break
        }
    }
ends
    

state demonseek
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23

    cstat 257
    ifrnd 4 { soundonce DEMON_IDLE }
    ifcansee
    {
        ifpdistg 2986
            {
            ifrnd 30
            {
            soundonce DEMON_JUMP
            ai AIBOSS1JUMP
            break
            }
        }
        ifpdistl 1348
        {
            ai AIBOSS1SCRATCHENEMY
            break
        }
    }
ends

state demonscratch
    cstat 257
    ifpdistl 1348
    {
        ifactioncount 7
        {
        resetactioncount
        soundonce DEMON_EVISCERATE
        addphealth -17
        palfrom 32 32
        }
    }
    else ai AIBOSS1SEEKENEMY
ends

state demonjump
    
    ifaction ABOSS1JUMP
    {
    cstat 257
    ifpdistl 1348 { move 0 addphealth -2 palfrom 32 32 wackplayer }
    ifactioncount 3 action ABOSS1FALL
    }
    ifaction ABOSS1FALL
    {
        cstat 257
        ifpdistl 1348 { move 0 addphealth -2 palfrom 32 32 wackplayer }
        iffloordistl 16 { ifpdistg 1348 { ai AIBOSS1SEEKENEMY break } else { move 0 ai AIBOSS1SCRATCHENEMY break } }
    }
ends

state demonhit
    ifdead
    {
        state sangre
        ifwasweapon RADIUSEXPLOSION { state paul_jibs sound SQUISHED spawn BLOODPOOL killit }
        else ifwasweapon RPG { state paul_jibs sound SQUISHED spawn BLOODPOOL killit }
        else { cstat 0 move 0 ai AIBOSS1DYING soundonce DEMON_DEATH break }
    }
    else
    {
        soundonce DEMON_PAIN
        state sangre
        ifrnd 30 ai AIDEMONHIT
    }
ends

state demondying
    ifactioncount 8 { resetactioncount action ABOSS1DEAD  break }
ends

state demoncode
    
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    sizeto 23 23
    ifaction ABOSS1STAND {
    soundonce DEMON_SIGHT ai AIBOSS1SEEKENEMY
    }
    else ifaction ABOSS1DEAD { }
    ifai AIBOSS1SEEKENEMY state demonseek
    else ifai AIBOSS1JUMP state demonjump
    else ifai AIDEMONHIT state demonhithead
    else ifai AIDEMONBACK state demonback
    else ifai AIBOSS1SCRATCHENEMY state demonscratch
    else ifai AIBOSS1DYING state demondying
    ifhitweapon state demonhit else state checksquished
ends

eventloadactor BOSS1 setactor[THISACTOR].xrepeat 23 setactor[THISACTOR].yrepeat 23 enda
eventloadactor BOSS1STAYPUT setactor[THISACTOR].xrepeat 23 setactor[THISACTOR].yrepeat 23 enda

actor BOSS1 BOSS1STRENGTH ABOSS1STAND fall state demoncode enda
actor BOSS1STAYPUT BOSS1STRENGTH ABOSS1STAND cactor BOSS1 enda

define BOSS2PALSTRENGTH 80


action ABOSS2WALK                0  14 1  1  8
action ABOSS2FROZEN              0  1  1
action ABOSS2RAISEGUN            22 4  1  1  11
action ABOSS2LOWERGUN            28 4  1  1  11
action ABOSS2RUN                 14 8  1  1  8
action ABOSS2SHOOT               26 2  1  1  5
action ABOSS2DYING              32 6  1  1  13
action BOSS2FLINTCH             32 2  1  1  6
action ABOSS2DEAD               37

move PALBOSS2SHRUNKRUNVELS 40
move PALBOSS2RUNVELS 115
move BOSS2WALKVELS 87
move BOSS2RUNVELS 270
move BOSS2STOPPED

ai AIBOSS2SEEKENEMY ABOSS2WALK BOSS2WALKVELS seekplayer
ai AIBOSS2RAISEGUN ABOSS2RAISEGUN BOSS2STOPPED faceplayer
ai AIBOSS2RUN ABOSS2RUN BOSS2RUNVELS seekplayer
ai AIBOSS2LOWERGUN ABOSS2LOWERGUN BOSS2STOPPED faceplayer
ai AIBOSS2RUNENEMY ABOSS2RUN BOSS2RUNVELS faceplayer
ai AIBOSS2SHOOTENEMY ABOSS2SHOOT BOSS2STOPPED faceplayer
ai AIBOSS2DYING ABOSS2DYING BOSS2STOPPED faceplayer



state raisegunstate
    ifactioncount 4
    {
        resetactioncount
        ai AIBOSS2SHOOTENEMY
        break
    }
ends


state lowergunstate
    ifactioncount 4
    {
        resetactioncount
        ai AIBOSS2SEEKENEMY
        break
    }
ends

state checkboss2seekstate
    ai AIBOSS2SEEKENEMY
ends

state boss2runstate
     ifpdistl 5020
     {
         ai AIBOSS2SEEKENEMY
     }
     ifhitweapon
     {
        ai AIBOSS2RAISEGUN
        break
     }
ends

state boss2runenemystate
    ifcansee
    {
        ifactioncount 3 { ifcanshoottarget { resetactioncount } else ai AIBOSS2SEEKENEMY }
        ifcount 48 ifrnd 2 { ifp palive { sound BOS2_ATTACK ai AIBOSS2RAISEGUN } break }
    }
    else ai AIBOSS2SEEKENEMY
ends

state boss2seekenemystate
    ifpdistg 6000 { ai AIBOSS2RUN }
    ifrnd 2 soundonce BOS2_ROAM
    else ifactioncount 3 { resetactioncount }

    ifcansee ifcount 32 ifp palive ifrnd 48 ifcanshoottarget
    {
        ifrnd 64 ifpdistg 4096
        {
            ai AIBOSS2RUNENEMY
            break
        }

       
        else { sound BOS2_ATTACK ai AIBOSS2RAISEGUN }
    }
ends

state boss2dyingstate
  ifactioncount 6 { action ABOSS2DEAD cstat 0 }
ends


state boss2shootenemy
    
    ifactioncount 2
    {
        sound CAPT_ATTACK
        shoot SHOTSPARK1
        resetactioncount
    }
    ifcount 80
    {
        ai AIBOSS2LOWERGUN
        break
    }
ends

state checkboss2hitstate
    
    ifdead
    {
        addkills 1
		spritepal 3
        ifwasweapon RADIUSEXPLOSION { state paul_jibs debris SCRAP2 5 soundonce SQUISHED killit }
        else ifwasweapon RPG { state paul_jibs debris SCRAP3 5 soundonce SQUISHED killit }        
        else
        {
        sound BOS2_DYING
        ai AIBOSS2DYING
        }
    }
    else
    {
        ifstrength 40 spritepal 3
        soundonce BOS2_PAIN
        debris SCRAP2 2       
        state sangre
    }
ends

state boss2code
    fall
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    sizeto 22 19
    ifai 0 { ai AIBOSS2SEEKENEMY }
    else ifaction ABOSS2DEAD { cstat 0 move 0 }
    else ifai AIBOSS2SEEKENEMY state boss2seekenemystate
    else ifai AIBOSS2RUN state boss2runstate
    else ifai AIBOSS2RAISEGUN state raisegunstate
    else ifai AIBOSS2LOWERGUN state lowergunstate
    else ifai AIBOSS2RUNENEMY state boss2runenemystate
    else ifai AIBOSS2SHOOTENEMY state boss2shootenemy
    else ifai AIBOSS2DYING state boss2dyingstate
    
    ifhitweapon state checkboss2hitstate else state checksquished
        
    


ends

eventloadactor BOSS2 setactor[THISACTOR].xrepeat 22 setactor[THISACTOR].yrepeat 19 enda

actor BOSS2 BOSS2PALSTRENGTH state boss2code enda


action ABOSS3WALK                2  5  1  1  12
action ABOSS3RUN                 2  5  1  1  10
action ABOSS3SHOOT               0  2  1  1  27
action ABOSS3FROZEN              1  1  1  1  1
action ABOSS3DYING               7  6  1  1  12
action BOSS3FLINTCH              7  2  1  1  8
action ABOSS3DEAD                12

move PALBOSS3SHRUNKRUNVELS 130
move PALBOSS3RUNVELS 131
move BOSS3WALKVELS 85
move BOSS3RUNVELS  132
move BOSS3STOPPED

ai AIBOSS3SEEKENEMY ABOSS3WALK BOSS3WALKVELS seekplayer
ai AIBOSS3RUNENEMY ABOSS3RUN BOSS3RUNVELS faceplayerslow
ai AIBOSS3SHOOTENEMY ABOSS3SHOOT BOSS3STOPPED faceplayer
ai AIBOSS3DYING ABOSS3DYING BOSS3STOPPED faceplayer
ai AIBOSS3PALSHRINK ABOSS3WALK PALBOSS3SHRUNKRUNVELS faceplayer
ai AIBOSS3HIT BOSS3FLINTCH BOSS2STOPPED faceplayer

state boss3palshrunkstate
    ifcount SHRUNKDONECOUNT ai AIBOSS3SEEKENEMY
    else ifcount SHRUNKCOUNT sizeto 40 40
    else state genericshrunkcode
ends

state checkboss3seekstate
    ai AIBOSS3SEEKENEMY
ends

state boss3hit
    ifactioncount 2
    {
        resetactioncount
        ai AIBOSS3SEEKENEMY
        break
    }
ends



state boss3runenemystate
    ifcansee { ifactioncount 3 { ifcanshoottarget { ai AIBOSS3SHOOTENEMY  } else ai AIBOSS3SEEKENEMY } }
    else ai AIBOSS3SEEKENEMY
ends

state boss3seekenemystate
    ifrnd 2 soundonce BOS3_ROAM
    ifcansee  ifrnd 48 ifcanshoottarget
    {
        ifrnd 64
            ifpdistg 4096
            {
                ai AIBOSS3RUNENEMY
                ifspritepal 0 break
                move PALBOSS3RUNVELS seekplayer
                break
            }

        ifp palive 
            ai AIBOSS3SHOOTENEMY
    }
ends

state boss3dyingstate
  ifactioncount 6 { action ABOSS3DEAD break }
ends

state boss3lobbedstate
    ifcansee
    {
        
            ifactioncount 2
        {
            shoot SHOTGUN
            shoot SHOTGUN
            shoot SHOTGUN
                       

            ifrnd 78 sound BOS3_ATTACK1
            else sound GENERIC_AMBIENCE16
            resetactioncount
            ifrnd 20 ai AIBOSS3SEEKENEMY
        }


    }
    else state checkboss3seekstate
ends

state checkboss3hitstate
    ifrnd 2 spawn BLOODPOOL
    ifdead
    {
        addkills 1
            
             ifwasweapon SHRINKSPARK { state paul_jibs soundonce SQUISHED killit }
             else ifwasweapon RPG { state paul_jibs sound SQUISHED spawn BLOODPOOL killit }
             else ifwasweapon RADIUSEXPLOSION { state paul_jibs sound SQUISHED spawn BLOODPOOL killit }
        else
        {
         
         ai AIBOSS3DYING
         ifrnd 100 { sound BOS3_DYING } else { sound GENERIC_AMBIENCE23 }
        }

    }
    else
    {
        state sangre
        ifrnd 32 { ai AIBOSS3HIT move 0 }
       soundonce BOS3_PAIN
     
        
    }
ends

state boss3code fall
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    sizeto 30 30
    ifaction ABOSS3DEAD { }
    else
    {
        ifcount 75
        {
            resetcount
            ifrnd 110 soundonce GENERIC_AMBIENCE21
            else ifrnd 126 soundonce GENERIC_AMBIENCE13 
            else soundonce GENERIC_AMBIENCE22
        }
    }
    ifai 0 { ai AIBOSS3RUNENEMY  }
    else ifaction ABOSS3DEAD { cstat 0 move 0 }
    else ifai AIBOSS3SEEKENEMY state boss3seekenemystate
    else ifai AIBOSS3RUNENEMY state boss3runenemystate
    else ifai AIBOSS3HIT state boss3hit
    else ifai AIBOSS3SHOOTENEMY state boss3lobbedstate
    else ifai AIBOSS3PALSHRINK state boss3palshrunkstate

    ifai AIBOSS3DYING state boss3dyingstate
    else
    {
      ifhitweapon state checkboss3hitstate else state checksquished
        
    }
    
ends

eventloadactor BOSS3 setactor[THISACTOR].xrepeat 30 setactor[THISACTOR].yrepeat 30 enda

actor BOSS3 BOSS3STRENGTH state boss3code enda



action ABSWALK 2130 6 5 1 9
action ABSSTAND 0 1 1 1 1
action ABSSHOOT 2160 4 1 1 5
action ABSDIE 20 6 1 1 12
action ABSDEAD 25 1 1 1 1

move BSWALKSPEED 120
move BSDODGESPEED 320
move BSSTOPPED

ai AIBSSEEK ABSWALK BSWALKSPEED seekplayer
ai AIBSSHOOT ABSSHOOT BSSTOPPED faceplayer
ai AIBSDIE ABSDIE BSSTOPPED faceplayer
ai AIBSDODGE ABSSHOOT BSDODGESPEED dodgebullet

state bsseekstate
    ifcansee
    {
        ifbulletnear { ai AIBSDODGE break }
        ifcanshoottarget
        {
            ifrnd 32
            {
                ai AIBSSHOOT
                break
            }
        }
        
     }
     
ends

state bsshootstate
    ifcount 80
    {
        resetcount
        ai AIBSSEEK
        break
    }
    ifcansee ifcanseetarget ifcanshoottarget
    {
    ifbulletnear { ai AIBSDODGE break }
    ifactioncount 4
    {
        resetactioncount
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        sound PISTOL_FIRE
        spawn SHOTGUNSHELL
    }
    }
    else
    {
    ai AIBSSEEK
    break
    }
ends

state checkbshit
        ifdead
        {
             ifwasweapon RPG { state paul_jibs sound SQUISHED killit  }
             else ifwasweapon RADIUSEXPLOSION { state paul_jibs sound SQUISHED killit  }
             else { ai AIBSDIE break }
			 ifrnd 32 spawn SHIELD
        }
        else
        {
            state sangre
        }
    
ends

state bsdie
    ifactioncount 6
    {
        spawn BLOODPOOL
        soundonce THUD
        action ABSDEAD
        break
    }
ends

state bsdodgestate
    ifactioncount 4
    {
        resetactioncount
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        sound PISTOL_FIRE
        spawn SHOTGUNSHELL
        ai AIBSSEEK
     }
ends

state bscode
    fall
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17
    sizeto 17 17


    ifaction ABSSTAND ai AIBSSEEK
    else ifaction ABSDEAD
    {
        cstat 0
    }

    else ifai AIBSSEEK state bsseekstate
    else ifai AIBSSHOOT state  bsshootstate
    else ifai AIBSDIE state bsdie
    else ifai AIBSDODGE state bsdodgestate

    ifhitweapon state checkbshit else state checksquished 
ends

eventloadactor COMMANDER setactor[THISACTOR].xrepeat 17 setactor[THISACTOR].yrepeat 17 enda

actor COMMANDER 140 ABSSTAND state bscode enda







