// Alpha Project V0.0 Alpha
// By Marcolino123

scriptsize 131072

setgamename Alpha Project

setcfgname Alpha.cfg

onevent EVENT_GETLOADTILE
setvar RETURN 3588
endevent

spritenoshade 3747
spritenoshade 3746

define FLESH1 3869
define FLESH1G 3870
define FLESH2 3871
define FLESH2G 3872
define FLESH3 3873
define FLESH3G 3874
define BRAIN 3875
define BRAING 3876
define SPINE 3877
define SPINEG 3878
define NEWBLOOD1 5756
define NEWBLOOD2 5757
define NEWBLOOD3 5758
define NEWBLOOD4 5759
define NEWBLOOD5 5760

defineprojectile FLESH1 PROJ_WORKSLIKE 6278 // contains 128
defineprojectile FLESH1 PROJ_EXTRA 0
defineprojectile FLESH1 PROJ_HITRADIUS 0
defineprojectile FLESH1 PROJ_XREPEAT 20
defineprojectile FLESH1 PROJ_YREPEAT 20
defineprojectile FLESH1 PROJ_VEL 544
defineprojectile FLESH1 PROJ_BOUNCES 4
defineprojectile FLESH1 PROJ_SPAWNS 5000
defineprojectile FLESH1 PROJ_DROP -175
defineprojectile FLESH1 PROJ_BSOUND JIBLAND
defineprojectile FLESH1 PROJ_CLIPDIST 16

defineprojectile 3682 PROJ_WORKSLIKE 6278
defineprojectile 3682 PROJ_EXTRA 300
defineprojectile 3682 PROJ_HITRADIUS 7000
defineprojectile 3682 PROJ_XREPEAT 30
defineprojectile 3682 PROJ_YREPEAT 30
defineprojectile 3682 PROJ_VEL 2000
defineprojectile 3682 PROJ_TRAIL 3669
defineprojectile 3682 PROJ_BOUNCES 2
defineprojectile 3682 PROJ_SPAWNS EXPLOSION2

defineprojectile FLESH2 PROJ_WORKSLIKE 6278 // contains 128
defineprojectile FLESH2 PROJ_EXTRA 0
defineprojectile FLESH2 PROJ_HITRADIUS 0
defineprojectile FLESH2 PROJ_XREPEAT 20
defineprojectile FLESH2 PROJ_YREPEAT 20
defineprojectile FLESH2 PROJ_VEL 480
defineprojectile FLESH2 PROJ_BOUNCES 4
defineprojectile FLESH2 PROJ_SPAWNS 5000
defineprojectile FLESH2 PROJ_DROP -175
defineprojectile FLESH2 PROJ_BSOUND JIBLAND
defineprojectile FLESH2 PROJ_CLIPDIST 16

defineprojectile FLESH3 PROJ_WORKSLIKE 6278 // contains 128
defineprojectile FLESH3 PROJ_EXTRA 0
defineprojectile FLESH3 PROJ_HITRADIUS 0
defineprojectile FLESH3 PROJ_XREPEAT 20
defineprojectile FLESH3 PROJ_YREPEAT 20
defineprojectile FLESH3 PROJ_VEL 480
defineprojectile FLESH3 PROJ_BOUNCES 4
defineprojectile FLESH3 PROJ_SPAWNS 5000
defineprojectile FLESH3 PROJ_DROP -175
defineprojectile FLESH3 PROJ_BSOUND JIBLAND
defineprojectile FLESH3 PROJ_CLIPDIST 16

defineprojectile BRAIN PROJ_WORKSLIKE 6278 // contains 128
defineprojectile BRAIN PROJ_EXTRA 0
defineprojectile BRAIN PROJ_HITRADIUS 0
defineprojectile BRAIN PROJ_XREPEAT 20
defineprojectile BRAIN PROJ_YREPEAT 20
defineprojectile BRAIN PROJ_VEL 416
defineprojectile BRAIN PROJ_BOUNCES 4
defineprojectile BRAIN PROJ_SPAWNS 5000
defineprojectile BRAIN PROJ_DROP -175
defineprojectile BRAIN PROJ_BSOUND JIBLAND
defineprojectile BRAIN PROJ_CLIPDIST 16

defineprojectile SPINE PROJ_WORKSLIKE 6278 // contains 128
defineprojectile SPINE PROJ_EXTRA 0
defineprojectile SPINE PROJ_HITRADIUS 0
defineprojectile SPINE PROJ_XREPEAT 20
defineprojectile SPINE PROJ_YREPEAT 20
defineprojectile SPINE PROJ_VEL 320
defineprojectile SPINE PROJ_BOUNCES 4
defineprojectile SPINE PROJ_SPAWNS 5000
defineprojectile SPINE PROJ_DROP -175
defineprojectile SPINE PROJ_BSOUND JIBLAND
defineprojectile SPINE PROJ_CLIPDIST 16

defineprojectile 3698 PROJ_WORKSLIKE 6278
defineprojectile 3698 PROJ_EXTRA 0
defineprojectile 3698 PROJ_HITRADIUS 0
defineprojectile 3698 PROJ_XREPEAT 32
defineprojectile 3698 PROJ_YREPEAT 32
defineprojectile 3698 PROJ_VEL 800
defineprojectile 3698 PROJ_DROP -500
defineprojectile 3698 PROJ_BSOUND 415
defineprojectile 3698 PROJ_SPAWNS 3707
defineprojectile 3698 PROJ_BOUNCES 3

defineprojectile 5001 PROJ_WORKSLIKE 6278 // contains 128
defineprojectile 5001 PROJ_EXTRA 0
defineprojectile 5001 PROJ_HITRADIUS 0
defineprojectile 5001 PROJ_XREPEAT 16
defineprojectile 5001 PROJ_YREPEAT 16
defineprojectile 5001 PROJ_VEL 320
defineprojectile 5001 PROJ_BOUNCES 1
defineprojectile 5001 PROJ_SPAWNS 5000
defineprojectile 5001 PROJ_DROP -175
defineprojectile 5001 PROJ_BSOUND -1
defineprojectile 5001 PROJ_CLIPDIST 16


defineprojectile 3660 PROJ_WORKSLIKE 36866
defineprojectile 3660 PROJ_EXTRA 33
defineprojectile 3660 PROJ_SPAWNS -1
defineprojectile 3660 PROJ_HITRADIUS 2000
defineprojectile 3660 PROJ_VEL 1000
defineprojectile 3660 PROJ_XREPEAT 26
defineprojectile 3660 PROJ_YREPEAT 24
defineprojectile 3660 PROJ_TRAIL 3661
defineprojectile 3660 PROJ_ISOUND 405
defineprojectile 3660 PROJ_CSTAT 0



defineprojectile 3668 PROJ_WORKSLIKE 1
defineprojectile 3668 PROJ_EXTRA 100
defineprojectile 3668 PROJ_VEL 500
defineprojectile 3668 PROJ_XREPEAT 8
defineprojectile 3668 PROJ_YREPEAT 8
defineprojectile 3668 PROJ_TRAIL 3669
defineprojectile 3668 PROJ_TNUM 100
defineprojectile 3668 PROJ_DECAL 3731

defineprojectile 10339 PROJ_WORKSLIKE 1
defineprojectile 10339 PROJ_EXTRA 2
defineprojectile 10339 PROJ_VEL 500
defineprojectile 10339 PROJ_XREPEAT 4
defineprojectile 10339 PROJ_YREPEAT 4
defineprojectile 10339 PROJ_TRAIL 10340
defineprojectile 10339 PROJ_TNUM 100
defineprojectile 10339 PROJ_DECAL 3731

defineprojectile 3742 PROJ_WORKSLIKE 20678
defineprojectile 3742 PROJ_EXTRA 0
defineprojectile 3742 PROJ_CLIPDIST 12
defineprojectile 3742 PROJ_SPAWNS -1
defineprojectile 3742 PROJ_RANGE 20
defineprojectile 3742 PROJ_CSTAT 128
defineprojectile 3742 PROJ_XREPEAT 4
defineprojectile 3742 PROJ_YREPEAT 4
defineprojectile 3742 PROJ_BOUNCES 2
defineprojectile 3742 PROJ_VEL 50
defineprojectile 3742 PROJ_DROP -128
defineprojectile 3742 PROJ_HITRADIUS 0
defineprojectile 3742 PROJ_BSOUND -1

defineprojectile 10495 PROJ_WORKSLIKE 16
defineprojectile 10495 PROJ_EXTRA 10
defineprojectile 10495 PROJ_VEL 3000

defineprojectile 10493 PROJ_WORKSLIKE 16
defineprojectile 10493 PROJ_EXTRA 15
defineprojectile 10493 PROJ_VEL 3000

defineprojectile 10400 PROJ_WORKSLIKE 36866
defineprojectile 10400 PROJ_EXTRA 50
defineprojectile 10400 PROJ_VEL 3000
defineprojectile 10400 PROJ_SPAWNS -1
defineprojectile 10400 PROJ_ISOUND -1

action no 0 1 1 1 1

move INIT
move movespark1 5 20
move movespark2 5 50

useractor notenemy 3743
cstator 32768
ifcount 72 { sound 420
randvar angvar 512
setactor[THISACTOR].ang angvar
randvar z 256
mulvar z -1
ezshoot z 3742
randvar angvar 512
setactor[THISACTOR].ang angvar
randvar z 512
mulvar z -1
ezshoot z 3742
randvar angvar 512
setactor[THISACTOR].ang angvar
randvar z 128
mulvar z -1
ezshoot z 3742
resetcount
}
enda

useractor notenemy 3733 0
ifmove 0
{
	sizeat 3 3
	cstator 2
	move INIT
	insertspriteq
}
enda

useractor notenemy 3739 0
ifmove 0
{
	sizeat 3 3
	cstator 2
	move INIT
	insertspriteq
}
enda

useractor notenemy 3735 0
ifmove 0
{
	sizeat 3 3
	cstator 2
	move INIT
	insertspriteq
	
}
enda

useractor notenemy 3740 0
ifmove 0
{
	sizeat 8 8
	move INIT
	insertspriteq
}
enda

useractor notenemy 3737 0
ifmove 0
{
	iffloordistl 2 sizeat 6 3 else
	sizeat 4 4
	cstator 2
	move INIT
	insertspriteq
}
enda

action WEAP2FRAMES 0  4  1  1  6
actor SHOTSPARK1 PISTOL_WEAPON_STRENGTH WEAP2FRAMES
  ifdead
    killit
ifcount 1
{
espawn 8057
} 
  ifactioncount 4
    killit
  else
  {
    ifactioncount 3
    {
      ifinwater
      spawn WATERBUBBLE
    }
    else
      ifcount 2 nullop
      else
        ifonwater
          spawn WATERSPLASH2
  }
ifcount 1 nullop else 
{
state getfloordist
	  getactor[THISACTOR].htg_t 6 hitwall
		ifvarn hitwall -1
{
			getwall[hitwall].picnum FLOORTEX
			state CHECKSTEPS
			state BULLETHITSOUNDS	
			ifvare FLOORTEX 638 
			{
				sound GLASS_HEAVYBREAK 
				lotsofglass 15 
				setwall[hitwall].picnum 358 
			}
			
		}
else
ifvarl z 0 
{
getsector[THISACTOR].floorpicnum FLOORTEX
			state CHECKSTEPS
			state BULLETHITSOUNDS
			ifvare FLOORTEX W_TECHWALL1 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].floorpicnum 363 } else
			ifvare FLOORTEX W_TECHWALL2 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].floorpicnum 362 } else
			ifvare FLOORTEX W_TECHWALL3 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].floorpicnum 360 } else
			ifvare FLOORTEX W_TECHWALL4 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].floorpicnum 361 } else
			ifvare FLOORTEX 5645 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].floorpicnum 5638 } else
			{
				getsector[THISACTOR].floorstat temp
				ifvarand temp 1 nullop else ifvarand temp 2 nullop else ifawayfromwall
				{
					setvarvar target2 FLOORTEX
					
					espawn BULLETHOLE
					setactor[RETURN].cstat 32
				}
			}
}
else
		ifceilingdistl 3
		{
			getsector[THISACTOR].ceilingpicnum FLOORTEX
			state CHECKSTEPS
			state BULLETHITSOUNDS
			ifvare FLOORTEX W_TECHWALL1 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].ceilingpicnum 363 } else
			ifvare FLOORTEX W_TECHWALL2 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].ceilingpicnum 362 } else
			ifvare FLOORTEX W_TECHWALL3 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].ceilingpicnum 360 } else
			ifvare FLOORTEX W_TECHWALL4 { sound VENT_BUST debris SCRAP1 8 setsector[THISACTOR].ceilingpicnum 361 } else
			{
				getsector[THISACTOR].ceilingstat temp
				ifvarand temp 1 nullop else ifvarand temp 2 nullop else ifawayfromwall
				{
					setvarvar target2 FLOORTEX
					
					espawn BULLETHOLE
					state getceilz
					setactor[RETURN].z z
					setactor[RETURN].cstat 32
				}
			}
		}
}



enda

state changetodecal
getactorvar[myspawner].target2 FLOORTEX
ifvare FLOORTEX -1
{
	getactor[myspawner].htg_t 6 hitwall
	ifvare hitwall -1 break
	getwall[hitwall].picnum FLOORTEX
}
getactor[myspawner].htg_t 6 hitwall	
getwall[hitwall].picnum FLOORTEX
state CHECKSTEPS
setvar x 0
switch STEPSOUNDFX
case 1 setvar picnum 3737
setvar x 10
break
case 2 setvar picnum 3735
setvar x 7
break
case 5 case 7 

setvar picnum 3733 setvar x 7
break
case 10 setvar picnum 3739
setvar x 8
break
case 11 setvar picnum 3740 
setvar x 8
break
endswitch
ifvarn picnum BULLETHOLE
{
	setactor[THISACTOR].picnum picnum
	setactor[THISACTOR].xrepeat x
	setactor[THISACTOR].yrepeat x
	cstator 16
	cstator 128
	ifrnd 128 cstator 4
	changespritestat THISACTOR 1
}
ends


useractor notenemy 3707
fall
sizeat 32 32
//ifpdistl 758 { quote 139 ifhitspace { ifcount 16 { addweapon HANDBOMB_WEAPON 1 killit } } }
ifcount 72 { spawn EXPLOSION2 hitradius 3000 20 60 80 250 sound PIPEBOMB_EXPLODE resetcount killit }
enda

useractor notenemy 3711
shoot 3698
killit
enda

state bloodshooter
randvar angvar 2048
setactor[THISACTOR].ang angvar
randvar zdist 512
mulvar zdist -1
ezshoot zdist 5001
ends

useractor notenemy 3669 0
sizeat 4 4
ifcount 5
killit
enda

useractor notenemy 10340 0
sizeat 2 2
ifcount 5
killit
enda

useractor notenemy 3712
cstator 32768
hitradius 2000 0 0 0 0
killit
enda

useractor notenemy 3731
ifawayfromwall killit
else
ifmove 0 
{
cstator 2
move INIT
sizeat 1 1
insertspriteq
}
enda


state random_wall_jibs
  ifrnd 96
    shoot BLOODSPLAT1
spawn BSPAWNER
  ifrnd 96
    shoot BLOODSPLAT2

  ifrnd 96
    shoot BLOODSPLAT3

  ifrnd 96
    shoot BLOODSPLAT4
  ifrnd 96
    shoot BLOODSPLAT1
ends

state attachfloor

getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
updatesectorz x y z mysector
ifvarn mysector -1
{
	getflorzofslope mysector x y z // z is the return var
	setactor[THISACTOR].z z
}

ends

action JIBSTILL2 0 1 1 1 1
action JIBSTILL -1 1 1 1 1

spritenoshade BLOODPOOL

state jibcode

ifvare countvar 0
{
	cstat 256
	ifrnd 128 cstator 4
	action JIBSTILL
	setvar countvar 1
	spawn BLOODPOOL
}

setvar temp 0

fall


ifhitweapon 
	ifdead { guts JIBS6 2 killit }
	


ends

action JIBMODELFRAME1 4026 1 1 1 1

state jibcode2
fall
ifvare countvar 0
{
	cstat 256
	ifrnd 128 cstator 4
	action JIBSTILL2
	setvar countvar 1
	spawn BLOODPOOL
	state attachfloor
}
strength 0
ifhitweapon { guts JIBS6 2 killit }

ends

useractor notenemy 5000 0
ifspawnedby FLESH1 { espawn FLESH1G killit }
ifspawnedby FLESH2 { espawn FLESH2G killit }
ifspawnedby FLESH3 { espawn FLESH3G killit }
ifspawnedby BRAIN { espawn BRAING killit }
ifspawnedby SPINE { espawn SPINEG killit }  
ifspawnedby 5001 { 
	getactor[THISACTOR].htg_t 6 hitwall 
	ifvarn hitwall -1 
	{
	ifrnd 128 
	{ 
	ifrnd 128 spawn 7421 killit else ifrnd 128 spawn 7422 killit 
	}
	else ifrnd 128 
	{ 
	ifrnd 128 spawn 7423 killit else ifrnd 128 spawn 7424 killit
	} 
	} 
	ifvare hitwall -1 
	{ 
	ifrnd 128 spawn 7421 killit else ifrnd 128 spawn 7422 killit else ifrnd 128 spawn 7423 killit else ifrnd 128 spawn 7424 killit
	}
	}
enda

useractor notenemy 2249 state jibcode2 enda // JIBS1 = ?
useractor notenemy 2254 state jibcode2 enda // JIBS2 = eyeball
useractor notenemy 2259 state jibcode2 enda // JIBS3 = heart
useractor notenemy 2264 state jibcode2 enda // JIBS4 = guts
useractor notenemy 2269 state jibcode2 enda // JIBS5 = ribcage

state newbloodstate

ifspawnedby SHOTSPARK1 nullop else fall

ifvare countvar 0
{
	//cstat 130
	//sizeat 12 12
	setvar countvar 1

	setvar tempb 130
	ifrnd 128 addvar tempb 4
	ifrnd 128 addvar tempb 8
	setactor[THISACTOR].cstat tempb
	randvar monstx 10
	addvar monstx 8
	setactor[THISACTOR].xrepeat monstx
	randvar monsty 10
	addvar monsty 8
	setactor[THISACTOR].yrepeat monsty
}

iffloordistl 1 
{
	cstat 162
	getsector[THISACTOR].floorz mz
	getactor[THISACTOR].z z
	addvar z 2048
	ifvarvarl z mz sizeto 0 0
}
ifvarl framerate 20 killit
ifcount 1560 killit
ends

move BLOODMOVED

useractor notenemy NEWBLOOD1 0
ifmove 0
{
	randvar tempb 3
	switch tempb
	case 0 cactor NEWBLOOD2 break
	case 1 cactor NEWBLOOD3 break
	case 2 cactor NEWBLOOD4 break
	endswitch
	move BLOODMOVED
}
state newbloodstate
enda

useractor notenemy NEWBLOOD2 0
state newbloodstate
enda
useractor notenemy NEWBLOOD3 0
state newbloodstate
enda
useractor notenemy NEWBLOOD4 0
state newbloodstate
enda
useractor notenemy NEWBLOOD5 0
state newbloodstate
enda

action SHELLROLLING -1 2 1 1 6
action SHELLSTOPPED -1 1 1 1 1

move SHELLROLL1 48
move SHELLBOUNCE 48 -20
move SHELLBOUNCE2 48
move SHELLROLL2	32
move SHELLROLL3 16
move SHELLSTOP

state shellcode
fall

setvar temp 0
ifinwater setvar temp 1
ifvare temp 1
{
	ifmove SHELLSTOP nullop else
	{
		ifmove SHELLROLL3 nullop else
		move SHELLROLL3 geth
	}
}

ifvare countvar 0
{
  setactor[THISACTOR].pitch 512
  clipdist 8
  setvar countvar 1
  getactor[THISACTOR].ang angvar
  randvar temp 256
  ifrnd 128 mulvar temp -1
  addvarvar angvar temp
  setactor[THISACTOR].ang angvar
  move SHELLBOUNCE geth getv
  ifactor 2534 // bullet shell
  {
	  action SHELLROLLING
	  ifrnd 128 sound 409 else sound 410
  }
  else // shotgun shell
  {
	  ifrnd 128 sound 411else sound 412
  }
  resetcount
  cstat 384
}

ifmove SHELLBOUNCE ifcount 6
{
	move SHELLBOUNCE2 geth
	resetcount
}

ifmove SHELLBOUNCE2
{
	getactor[THISACTOR].zvel temp
	ifvarg temp 96 setactor[THISACTOR].zvel 96
	setvar tempb 0
	iffloordistl 1 setvar tempb 1
	ifcount 8 setvar tempb 1
	ifvare tempb 1
	{
		ifrnd 128 move SHELLROLL2 geth else
	  	move SHELLROLL1 geth
	  	ifactor 3509 { ifmove SHELLROLL1 move SHELLROLL2 geth else move SHELLROLL3 geth }
	    resetcount
    }
}


ifmove SHELLROLL1 ifcount 22 { move SHELLROLL2 geth resetcount }
ifmove SHELLROLL2 ifcount 16 { move SHELLROLL3 geth resetcount }
ifmove SHELLROLL3 
  ifcount 12
    ifrnd 32 
{
	 setactor[THISACTOR].mdflags 2
     move SHELLSTOP
     ifactor 2534 action SHELLSTOPPED
     ifrnd 128 cstat 388
     
     getactor[THISACTOR].x x
     getactor[THISACTOR].y y
     getactor[THISACTOR].sectnum mysector
     getflorzofslope mysector x y z // z is the return var
     setactor[THISACTOR].z z
}

ifnotmoving
{
	getactor[THISACTOR].ang angvar
	addvar angvar 1024
	randvar temp 256
	ifrnd 128 mulvar temp -1
	addvarvar angvar temp
	setactor[THISACTOR].ang angvar
}

ifhitweapon
{
	getactor[THISACTOR].htang angvar
	ifactor 2534 espawn SHELL else
	espawn SHOTGUNSHELL
	setactor[RETURN].ang angvar
	randvar temp 32
	addvar temp 96
	setactor[RETURN].xvel temp
	killit
}

ifspawnedby APLAYER { ifcount 1560 killit }
else
ifcount 260 killit

ends

state shelleject
espawn SHELL
setactor[RETURN].xrepeat 8
setactor[RETURN].yrepeat 8
getactor[THISACTOR].ang angvar
addvar angvar 512
setactor[RETURN].ang angvar
randvar temp 64
addvar temp 64
setactor[RETURN].xvel temp
ends

state shelleject2
ifactor PIGCOPDIVE
{
	getactor[THISACTOR].z z
	addvar z 4096
	setactor[THISACTOR].z z
}
espawn SHOTGUNSHELL
setactor[RETURN].xrepeat 8
setactor[RETURN].yrepeat 8
getactor[THISACTOR].ang angvar
addvar angvar 512
setactor[RETURN].ang angvar
randvar temp 32
addvar temp 32
setactor[RETURN].xvel temp
ifactor PIGCOPDIVE
{
	getactor[THISACTOR].z z
	subvar z 4096
	setactor[THISACTOR].z z
}
ends

useractor notenemy 2534 0 state shellcode enda // SHELL +1

useractor notenemy 6325 0 state shellcode enda // shotgunshell

state checkfloordist

setvar temp 3072
getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
updatesectorz x y z mysector
ifvarn mysector -1
{
	getflorzofslope mysector x y temp // temp is the return var
	subvarvar temp z
}

ends


onevent EVENT_GAME
ifactor SHELL { cactor 2534 changespritestat THISACTOR 1 }
ifactor SHOTGUNSHELL { cactor 6325 changespritestat THISACTOR 1 }
ifactor SHOTGUNSHELL
ifactor JIBS1 ifvare gore 1 {
ifvare mtype 0
{
	ifrnd 32 state random_wall_jibs spawn NEWBLOOD1
	ifrnd 48 //96
	{
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
	}
	state checkfloordist
	ifvarl temp 2048
	{
		getactor[THISACTOR].picnum picnum
		setvar mtype 1
		setvar NOCODE 1
		addvar picnum 4
		espawnvar picnum
		getactor[THISACTOR].xrepeat x
		setactor[RETURN].xrepeat x
		getactor[THISACTOR].yrepeat y
		setactor[RETURN].yrepeat y
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
		ifrnd 64 { ifrnd 128 sound JIBLAND else sound JIBLAND2 }
		setvar NOCODE 1
	}

}
}
ifactor JIBS2 ifvare gore 1 {
ifvare mtype 0
{
	ifrnd 32 state random_wall_jibs spawn NEWBLOOD1
	ifrnd 48 //96
	{
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
	}
	state checkfloordist
	ifvarl temp 2048
	{
		getactor[THISACTOR].picnum picnum
		setvar mtype 1
		setvar NOCODE 1
		addvar picnum 4
		espawnvar picnum
		getactor[THISACTOR].xrepeat x
		setactor[RETURN].xrepeat x
		getactor[THISACTOR].yrepeat y
		setactor[RETURN].yrepeat y
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
		ifrnd 64 { ifrnd 128 sound JIBLAND else sound JIBLAND2 }
		setvar NOCODE 1
	}

}
}
ifactor JIBS3 ifvare gore 1 {
ifvare mtype 0
{
	ifrnd 32 state random_wall_jibs spawn NEWBLOOD1
	ifrnd 48 //96
	{
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
	}
	state checkfloordist
	ifvarl temp 2048
	{
		getactor[THISACTOR].picnum picnum
		setvar mtype 1
		setvar NOCODE 1
		addvar picnum 4
		espawnvar picnum
		getactor[THISACTOR].xrepeat x
		setactor[RETURN].xrepeat x
		getactor[THISACTOR].yrepeat y
		setactor[RETURN].yrepeat y
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
		ifrnd 64 { ifrnd 128 sound JIBLAND else sound JIBLAND2 }
		setvar NOCODE 1
	}

}
}
ifactor JIBS4 ifvare gore 1 {
ifvare mtype 0
{
	ifrnd 32 state random_wall_jibs spawn NEWBLOOD1
	ifrnd 48 //96
	{
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
	}
	state checkfloordist
	ifvarl temp 2048
	{
		getactor[THISACTOR].picnum picnum
		setvar mtype 1
		setvar NOCODE 1
		addvar picnum 4
		espawnvar picnum
		getactor[THISACTOR].xrepeat x
		setactor[RETURN].xrepeat x
		getactor[THISACTOR].yrepeat y
		setactor[RETURN].yrepeat y
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
		ifrnd 64 { ifrnd 128 sound JIBLAND else sound JIBLAND2 }
		setvar NOCODE 1
	}

}
}
ifactor JIBS5 ifvare gore 1 {
ifvare mtype 0
{
	ifrnd 32 state random_wall_jibs spawn NEWBLOOD1
	ifrnd 48 //96
	{
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
	}
	state checkfloordist
	ifvarl temp 2048
	{
		getactor[THISACTOR].picnum picnum
		setvar mtype 1
		setvar NOCODE 1
		addvar picnum 4
		espawnvar picnum
		getactor[THISACTOR].xrepeat x
		setactor[RETURN].xrepeat x
		getactor[THISACTOR].yrepeat y
		setactor[RETURN].yrepeat y
		getactor[THISACTOR].pal pal
		setactor[RETURN].pal pal
		ifrnd 64 { ifrnd 128 sound JIBLAND else sound JIBLAND2 }
		setvar NOCODE 1
	}

}
}

getactor[THISACTOR].picnum PICNUM

switch PICNUM

case BLOODSPLAT1 case BLOODSPLAT2
    case BLOODSPLAT3 case BLOODSPLAT4
      ifspritepal 1 break
      ifspawnedby NEWBEAST  { cactor NEWBEAST } else
      ifspawnedby GBSPAWNER { cactor NEWBEAST }

      ifrnd 128 { ifrnd 128 spawn NEWBLOODSPLAT1 else spawn NEWBLOODSPLAT2 }
           else { ifrnd 128 spawn NEWBLOODSPLAT3 else spawn NEWBLOODSPLAT4 }
      spritepal 1
      cstator 32768
      break
endswitch

endevent 

useractor notenemy 3661 0

ifvare countvar 0 
{
	sizeat 26 24
}
else
{
	getactor[THISACTOR].xrepeat x
	subvar x 1
	setactor[THISACTOR].xrepeat x
	setactor[THISACTOR].yrepeat x
}
addvar countvar 1
ifvare countvar 8 cstat 2
ifvare countvar 12 cstat 514

enda

action ANULLACTION 0

state brainshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist BRAIN
  ifvare mtype 1 
	{ 
	setthisprojectile[RETURN].pal 6
	setactorvar[RETURN].mtype 1
	}
  ifspritepal 22 setthisprojectile[RETURN].pal 22

 ends

state flesh1shoot
ifvarl framerate 26 break
 randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 8192
  mulvar zdist -1
  ezshoot zdist FLESH1
  ifvare mtype 1 
	{ 
	setthisprojectile[RETURN].pal 6
	setactorvar[RETURN].mtype 1
	}
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state spineshoot
 randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 2048
  mulvar zdist -1
  ezshoot zdist SPINE
   ifvare mtype 1 
	{ 
	setthisprojectile[RETURN].pal 6
	setactorvar[RETURN].mtype 1
	}
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state flesh2shoot
ifvarl framerate 26 break
randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist FLESH2
  ifvare mtype 1 
	{ 
	setthisprojectile[RETURN].pal 6
	setactorvar[RETURN].mtype 1
	}
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state flesh3shoot
ifvarl framerate 26 break
randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist FLESH3
  ifvare mtype 1
  { 
	setthisprojectile[RETURN].pal 6
	setactorvar[RETURN].mtype 1
  }
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

onevent EVENT_EGS
getactor[THISACTOR].picnum picnum
switch picnum

	case FLESH1
	case FLESH2
	case FLESH3
	case BRAIN 
	case SPINE
	case 5001
	addvar countvar 1
	ifvarvarl countvar countvarb 
	{
	 	ifrnd 96
	 	{ 
			espawn NEWBLOOD1
			ifvare mtype 1 setactor[RETURN].pal 6
		}
	}
	else ifrnd 32 
	{ 
		espawn NEWBLOOD1
		ifvare mtype 1 setactor[RETURN].pal 6
	}

	getactor[THISACTOR].pitch my
	addvarvar my hammo2
	ifvarg my 2047 subvar my 2048
	setactor[THISACTOR].pitch my
	getactor[THISACTOR].roll mx
	addvarvar mx hammo3
	ifvarg mx 2047 subvar mx 2048
	setactor[THISACTOR].roll mx

	
	ifrnd 16 state random_wall_jibs

	getactor[THISACTOR].yvel tempb
	ifvare tempb 1
	{
		getactor[THISACTOR].picnum tilenum
		addvar tilenum 1
		setactor[THISACTOR].picnum tilenum
		setactor[THISACTOR].statnum 1
		setactor[THISACTOR].zvel 0
		setactor[THISACTOR].pitch 0
		setactor[THISACTOR].roll 0
		ifspritepal 22 nullop else
		ifrnd 128 soundonce JIBLAND else soundonce JIBLAND2
	}
		
	break

case BLOODP2 case BLOODP3 case BLOODP4 case BLOODP1
    case NEWBLOODSPLAT1 case NEWBLOODSPLAT2 case NEWBLOODSPLAT3 case NEWBLOODSPLAT4
case BSPAWNER
    case GBSPAWNER
case NEWBLOOD54
    case GNEWBLOOD
spriteflags 16
    break


endswitch

ifactor BULLETHOLE 
{
	getactor[THISACTOR].owner myspawner
	ifvarn myspawner -1
	{
		getactor[myspawner].picnum temp
		ifvare temp SHOTSPARK1
			state changetodecal
		
	}
}

ifactor BLOODPOOL {
cstat 2 }

endevent

state jibstate
fall
ifvare gore 1
{
ifcount 1 nullop else 
{
	espawn BLOODPOOL 
	cstat 256
	ifspritepal 22 cstat 2
}
ifhitweapon
{
	ifwasweapon RADIUSEXPLOSION 
	{
		spawn BLOOD
		state random_wall_jibs
		ifspritepal 6 setvar mtype 1
		ifrnd 128 state flesh1shoot
		getactor[THISACTOR].picnum temp
		ifvarg temp 3894 ifrnd 128 state flesh1shoot
		killit
	}
}
}
ifvarl framerate 20 killit
ifcount 1560 killit
ifvare gore 0 killit
ends

useractor notenemy FLESH1G 0
sizeat 20 20
ifvare countvar 0 { sizeat 20 20 setvar countvar 1 }
state jibstate
enda

useractor notenemy FLESH2G 0
sizeat 20 20
ifvare countvar 0 { sizeat 20 20 setvar countvar 1 }
state jibstate
enda

useractor notenemy FLESH3G 0
sizeat 20 20
ifvare countvar 0 { sizeat 20 20 setvar countvar 1 }
state jibstate
enda

useractor notenemy BRAING 0
sizeat 16 16
ifvare countvar 0 { sizeat 16 16 setvar countvar 1 }
state jibstate
enda

useractor notenemy SPINEG 0
sizeat 20 20
ifvare countvar 0 { sizeat 20 20 setvar countvar 1 }
state jibstate
enda

define SPACESHUTTLE 487
move SHUTTLEVELS 16
actor SPACESHUTTLE TOUGH
//  ifmove 0          //  Init once
//    move SHUTTLEVELS getv geth
enda


actor SATELLITE TOUGH
  //  ifmove 0 move SHUTTLEVELS getv geth
  //  ifcount 120 move SHUTTLEVELS getv geth randomangle
enda

state jib_sounds
  ifrnd SWEARFREQUENCY
  {
    ifrnd 128
    {
      ifrnd 128
      {
        ifrnd 128
        {
          ifrnd 128
          {
            ifrnd 128
              globalsound JIBBED_ACTOR12
            else
              globalsound JIBBED_ACTOR1
          }
          else
          {
            ifrnd 128
              globalsound JIBBED_ACTOR9
            else
              globalsound JIBBED_ACTOR14
          }
        }
        else
        {
          ifrnd 128
            globalsound SMACKED
          else
            globalsound JIBBED_ACTOR2
        }
      }
      else
      {
        ifrnd 128
          globalsound MDEVSPEECH
        else
          globalsound JIBBED_ACTOR5
      }
    }
    else
    {
      ifrnd 128
      {
        ifrnd 128
        {
          ifrnd 128
            globalsound JIBBED_ACTOR11
          else
            globalsound JIBBED_ACTOR13
        }
        else
        {
          ifrnd 128
            globalsound JIBBED_ACTOR3
          else
            globalsound JIBBED_ACTOR8
        }
      }
      else
      {
        ifrnd 128
        {
          ifrnd 128
            globalsound JIBBED_ACTOR6
          else
            globalsound JIBBED_ACTOR4
        }
        else
        {
          ifrnd 128
          {
            ifrnd 128
              globalsound JIBBED_ACTOR10
            else
              globalsound JIBBED_ACTOR15

          }
          else
            globalsound JIBBED_ACTOR7
        }
      }
    }
  }
ends


state standard_jibs
  guts JIBS2 1
  guts JIBS3 2
  guts JIBS4 3
  guts JIBS5 2
  guts JIBS6 3
espawn 3665
espawn NEWBLOOD1
espawn NEWBLOOD2
espawn NEWBLOOD3
espawn NEWBLOOD4
espawn NEWBLOOD5
spawn BSPAWNER
spawn BSPAWNER
spawn BSPAWNER
spawn BSPAWNER
  ifrnd 6
  {
    guts JIBS1 1
    spawn BLOODPOOL
  }         // a badly drawn spine

  state jib_sounds
ends

state genericshrunkcode
  ifcount 32
  {
    ifpdistl SQUISHABLEDISTANCE
    pstomp
  }
  else
  {
    sizeto MINXSTRETCH MINYSTRETCH
    spawn FRAMEEFFECT1
  }
ends

state genericgrowcode
  ifcount 32
  {
    guts JIBS4 24
    guts JIBS6 28
    addkills 1
    sound SQUISHED
    sound PIPEBOMB_EXPLODE
    hitradius 2048 60 70 80 90
    spawn BLOODPOOL
    spawn EXPLOSION2
    killit
  }
  else
  {
    ifactor COMMANDER
      sizeto 100 100
    else
      ifactor SHARK
        sizeto 84 84
    else
      sizeto MAXXSTRETCH MAXYSTRETCH
    break
  }
ends




action ASHARKCRUZING 0 8 5 1 24
action ASHARKFLEE  0 8 5 1 10
action ASHARKATACK   0 8 5 1 6
action ASHARKSHRUNK  0 8 5 1 24
action ASHARKGROW  0 8 5 1 24
action ASHARKFROZEN  0 1 5 1 24

move SHARKVELS 24
move SHARKFASTVELS 72
move SHARKFLEEVELS 40

actor SHARK SHARKSTRENGTH ASHARKCRUZING SHARKVELS randomangle geth
  ifaction ASHARKSHRUNK
  {
    ifcount SHRUNKDONECOUNT
      action ASHARKCRUZING
    else ifcount SHRUNKCOUNT
      sizeto 60 60
    else
      state genericshrunkcode
    break
  }
  else
    ifaction ASHARKGROW
  {
    ifcount SHRUNKDONECOUNT
      action ASHARKCRUZING
    else
      ifcount SHRUNKCOUNT
        sizeto 24 24
    else
      state genericgrowcode
  }
  else
    ifaction ASHARKFROZEN
  {
    fall

    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick

    ifcount THAWTIME
    {
      action ASHARKFLEE
      getlastpal
      break
    }
    else
      ifcount FROZENDRIPTIME
        ifactioncount 26
          resetactioncount

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
        break

      lotsofglass 30
      sound GLASS_BREAKING
      addkills 1
      killit
    }
    break
  }
  else
    ifaction ASHARKFLEE
  {
    ifcount 16
      ifrnd 48
    {
      action ASHARKCRUZING
      move SHARKVELS randomangle geth
    }
  }
  else
    ifaction ASHARKCRUZING
  {
    ifcansee
      ifcount 48
        ifrnd 2
          ifcanshoottarget
    {
      action ASHARKATACK
      move SHARKFASTVELS faceplayerslow getv break
    }
    ifcount 32
      ifnotmoving
    {
      ifrnd 128
        move SHARKVELS randomangle geth
      else
        move SHARKFASTVELS randomangle geth
    }
  }
  else
    ifaction ASHARKATACK
  {
    ifcount 4
    {
      ifpdistl 1280
      {
        ifp palive ifcanshoottarget
        {
          sound DUKE_GRUNT
          palfrom 32 32
          addphealth SHARKBITESTRENGTH
        }
        action ASHARKFLEE
        move SHARKFLEEVELS fleeenemy
      }
    }
    else
      ifnotmoving
    {
      ifcount 32
      {
        action ASHARKCRUZING
        move SHARKVELS randomangle geth
      }
    }
    else
      ifcount 48
        ifrnd 2
    {
      action ASHARKCRUZING
      move SHARKFASTVELS randomangle geth
    }
  }

  ifhitweapon
  {
    ifdead
    {
      ifwasweapon GROWSPARK
      {
        move 0
        cstat 0
        action ASHARKGROW
        sound ACTOR_GROWING
        break
      }
      else
        ifwasweapon FREEZEBLAST
      {
        spritepal 1
        strength 0
        action ASHARKFROZEN
        sound SOMETHINGFROZE
      }
      else
      {
        sound SQUISHED
        guts JIBS6 5
        addkills 1
        killit
      }
    }
    else
    {
      ifwasweapon SHRINKSPARK
      {
        action ASHARKSHRUNK
        sound ACTOR_SHRINKING
        move 0
        break
      }
      else
        ifwasweapon GROWSPARK
          sound EXPANDERHIT

      move SHARKVELS randomangle geth
    }
  }
enda


action BLIMPWAITTORESPAWN

state blimphitstate
  cstat 0
  spawn FIRSTGUNSPRITE
  spawn EXPLOSION2

  debris SCRAP1 40      // Weapons and ammo!
  debris SCRAP2 32
  debris SCRAP3 32
  debris SCRAP4 32
  debris SCRAP5 32

  sound PIPEBOMB_EXPLODE
  ifrespawn
  {
    action BLIMPWAITTORESPAWN
    count 0
    cstat 32768
  }
  else
    killit
ends

actor BLIMP 1

  ifaction BLIMPWAITTORESPAWN
  {
    ifcount BLIMPRESPAWNTIME
    {
      action 0
      cstat 0
    }
    break
  }

  ifhitweapon
  {
    ifwasweapon RADIUSEXPLOSION
      state blimphitstate
    ifwasweapon RPG
      state blimphitstate
    strength 1
  }
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
move MOUSEVELS 32

action RUBCANDENT 1 1 1 1 1

actor RUBBERCAN WEAK
  ifaction RUBCANDENT
  {
    ifactioncount 16
    {
      strength 0
      action ANULLACTION
      break
    }
  }
  else
    ifhitweapon
  {
    ifwasweapon RADIUSEXPLOSION
    {
      state rats
      ifrnd 48
        spawn BURNING
      debris SCRAP3 12
      killit
    }
    else
      action RUBCANDENT
  }
enda

state toughgalspeech
  ifrnd 64
  {
    ifnosounds
      soundonce TOUGHGALSND1
  }
  else
    ifrnd 64
  {
    ifnosounds
      soundonce TOUGHGALSND2
  }
  else
    ifrnd 64
  {
    ifnosounds
      soundonce TOUGHGALSND3
  }
  else
    ifnosounds
      soundonce TOUGHGALSND4
ends

state jibfood
  sound SQUISHED
  guts JIBS6 3
  killit
ends

state breakobject
  ifaction 0
  {
    action ANULLACTION
    cstator 257
    ifactor ROBOTMOUSE
      clipdist 64
  }
  else
    ifactor ROBOTMOUSE
  {
      ifdead
      {
        ifcount 32
        {
          globalsound MOUSEANNOY
          killit
        }
        break
      }
      ifcount 64 ifrnd 6
      {
        ifrnd 128
          move MOUSEVELS randomangle geth
        else
        {
          ifrnd 64
            soundonce HAPPYMOUSESND1
          else
            ifrnd 64
              soundonce HAPPYMOUSESND2
          else
            ifrnd 64
              soundonce HAPPYMOUSESND3
          else
            soundonce HAPPYMOUSESND4
        }
        resetcount
      }
  }

  ifhitweapon
  {
    ifdead
    {
      ifactor FOODOBJECT6
        state jibfood
      else
        ifactor FOODOBJECT11
          state jibfood
      else
        ifactor FOODOBJECT12
          state jibfood
      else
        ifactor FOODOBJECT13
          state jibfood
      else
        ifactor FOODOBJECT14
          state jibfood
      else
        ifactor FOODOBJECT15
          state jibfood
      else
        ifactor FOODOBJECT16
          state jibfood
      else
        ifactor FOODOBJECT17
          state jibfood
      else
        ifactor SKINNEDCHICKEN
          state jibfood
      else
        ifactor SHOPPINGCART
      {
        debris SCRAP1 5
        debris SCRAP2 5
        debris SCRAP3 5
        sound GLASS_HEAVYBREAK
        killit
      }
      else
        ifactor ROBOTDOG2
      {
        soundonce DEAD_DOG
        guts JIBS2 1
        guts JIBS3 2
        guts JIBS6 3
        killit
      }
      else
        ifactor FEATHEREDCHICKEN
          state jibfood
      else
        ifactor DOLPHIN1
      {
        guts JIBS2 1
        guts JIBS3 2
        guts JIBS4 3
        guts JIBS5 2
        state jibfood
      }
      else
        ifactor DOLPHIN2
      {
        guts JIBS2 1
        guts JIBS3 2
        guts JIBS4 3
        guts JIBS5 2
        state jibfood
      }
      else
        ifactor SNAKEP
      {
        guts JIBS2 1
        guts JIBS3 2
        guts JIBS4 3
        guts JIBS5 2
        state jibfood
      }
      else
        ifactor DONUTS
      {
        spritepal 7
        guts JIBS6 2
        killit
      }
      else
        ifactor DONUTS2
      {
        debris SCRAP1 1
        spritepal 7
        guts JIBS6 2
        killit
      }
      else
        ifactor MAILBAG
        {
          mail 30
          debris SCRAP3 5
          debris SCRAP4 3
          killit
        }
      else
        ifactor TEDDYBEAR
      {
        debris SCRAP3 5
        spritepal 1
        debris SCRAP3 6
      }
      else
      {
        ifrnd 128
          sound GLASS_BREAKING
        else
          sound GLASS_HEAVYBREAK
      }

      ifactor CLOCK
      {
        cactor BROKENCLOCK
        break
      }
      else
        ifactor JOLLYMEAL
      {
        spawn ATOMICHEALTH
        debris SCRAP3 1
        debris SCRAP4 2
      }
      else
        ifactor GUMBALLMACHINE
      {
        cactor GUMBALLMACHINEBROKE
        strength 1
        debris SCRAP4 2
        lotsofglass 10
        break
      }
      else
        ifactor GUMBALLMACHINEBROKE
      {
        debris SCRAP3 3
        debris SCRAP4 2
        lotsofglass 10
      }
      else
        ifactor DUKEBURGER
      {
        debris SCRAP3 14
        debris SCRAP1 13
        debris SCRAP4 12
        debris SCRAP2 12
        debris SCRAP5 11
      }
      else
        ifactor POLICELIGHTPOLE
      {
        debris SCRAP3 4
        debris SCRAP1 3
        debris SCRAP4 2
        debris SCRAP2 2
        debris SCRAP5 1
      }
      else
        ifactor TOPSECRET
          paper 10
      else
        ifactor GUNPOWDERBARREL
      {
        spawn EXPLOSION2
        sound PIPEBOMB_EXPLODE
        hitradius 2048 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
        ifpdistl 2048
          wackplayer
        debris SCRAP1 10      // Weapons and ammo!
        debris SCRAP2 13
        debris SCRAP3 4
        debris SCRAP4 17
        debris SCRAP5 6
      }
      else
        ifactor FLOORBASKET
      {
        spawn PUKE
        debris SCRAP1 2
        debris SCRAP3 3
        debris SCRAP4 2
      }
      else
        ifactor ROBOTMOUSE
      {
        debris SCRAP2 10
        spritepal 1
        debris SCRAP3 4
        resetcount
        cstat 32768
        break
      }
      else
        ifactor ROBOTPIRATE
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE1A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor MAN
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor MAN2
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE2A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE3A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE4A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE4A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE5A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
        ifactor PIRATE6A
      {
        debris SCRAP2 10
        debris SCRAP1 5
        debris SCRAP3 3
        lotsofglass 10
      }
      else
      {
        lotsofglass 10
        debris SCRAP4 3
      }
      killit
    }
    else
      ifactor DOLPHIN1
    {
      guts JIBS6 1
      soundonce DOLPHINSND
      ifstrength TOUGH
      {
        cactor DOLPHIN2
        sound SQUISHED
      }
    }
    else
      ifactor DOLPHIN2
    {
      guts JIBS6 1
      soundonce DOLPHINSND
    }
    else
      ifactor ROBOTDOG2
    {
      guts JIBS6 1
      soundonce WHINING_DOG
    }
  }
  else
  {
    ifactor CLOCK
      nullop
    else
      ifactor TOPSECRET
        nullop
    else
      ifactor SKINNEDCHICKEN
        nullop
    else
      ifactor FEATHEREDCHICKEN
        nullop
    else
      ifactor FOODOBJECT2
        nullop
    else
      ifactor FOODOBJECT6
        nullop
    else
      ifactor DOLPHIN1
        nullop
    else
      ifactor DOLPHIN2
        nullop
    else
      fall
  }


ends

action ABURGERROTS 0 1 5
useractor notenemy DUKEBURGER PIRATEGALSTRENGTH ABURGERROTS state breakobject enda

useractor notenemy MOP WEAK state breakobject enda

useractor notenemy BROOM WEAK state breakobject enda

useractor notenemy WETFLOOR WEAK state breakobject enda

useractor notenemy DESKLAMP WEAK state breakobject ifvare INlight 0 { spawn 3747 setvar INlight 1 } enda

// useractor notenemy DUKECUTOUT WEAK state breakobject enda

useractor notenemy HATRACK WEAK state breakobject enda

useractor notenemy GUNPOWDERBARREL TOUGH state breakobject enda

useractor notenemy COFFEEMACHINE WEAK state breakobject enda

useractor notenemy TEDDYBEAR WEAK state breakobject enda

useractor notenemy TOPSECRET WEAK state breakobject enda

useractor notenemy ROBOTMOUSE ROBOTMOUSESTRENGTH state breakobject enda

useractor notenemy MAN PIRATEGALSTRENGTH state breakobject enda

useractor notenemy MAN2 PIRATEGALSTRENGTH state breakobject enda

useractor notenemy WOMAN PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATE1A PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATE2A PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATE3A PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATE4A PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATE5A PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATE6A PIRATEGALSTRENGTH state breakobject enda

useractor notenemy ROBOTPIRATE PIRATEGALSTRENGTH state breakobject enda

useractor notenemy PIRATEHALF TOUGH state breakobject enda

useractor notenemy CHESTOFGOLD WEAK state breakobject enda

useractor notenemy ROBOTDOG PIRATEGALSTRENGTH state breakobject enda

useractor notenemy ROBOTDOG2 TOUGH state breakobject enda

useractor notenemy PLEASEWAIT state breakobject enda

useractor notenemy FOODOBJECT1 WEAK state breakobject enda

useractor notenemy FOODOBJECT2 WEAK state breakobject enda

useractor notenemy FOODOBJECT3 WEAK state breakobject enda

useractor notenemy FOODOBJECT4 WEAK state breakobject enda

useractor notenemy FOODOBJECT5 WEAK state breakobject enda

useractor notenemy FOODOBJECT6 WEAK state breakobject enda

useractor notenemy FOODOBJECT7 WEAK state breakobject enda

useractor notenemy FOODOBJECT8 WEAK state breakobject enda

useractor notenemy FOODOBJECT9 WEAK state breakobject enda

useractor notenemy FOODOBJECT10 WEAK state breakobject enda

useractor notenemy FOODOBJECT11 WEAK state breakobject enda

useractor notenemy FOODOBJECT12 WEAK state breakobject enda

useractor notenemy FOODOBJECT13 WEAK state breakobject enda

useractor notenemy FOODOBJECT14 WEAK state breakobject enda

useractor notenemy FOODOBJECT15 WEAK state breakobject enda

useractor notenemy FOODOBJECT16 WEAK state breakobject enda

useractor notenemy FOODOBJECT17 WEAK state breakobject enda

useractor notenemy FOODOBJECT18 WEAK state breakobject enda

useractor notenemy FOODOBJECT19 WEAK state breakobject enda

useractor notenemy FOODOBJECT20 WEAK state breakobject enda

useractor notenemy JOLLYMEAL WEAK state breakobject enda

useractor notenemy GUMBALLMACHINE WEAK state breakobject enda

useractor notenemy GUMBALLMACHINEBROKE WEAK state breakobject enda

useractor notenemy POLICELIGHTPOLE TOUGH state breakobject ifvare INlight 0 { spawn 3747 setvar INlight 1 } enda

useractor notenemy CLOCK WEAK state breakobject enda

useractor notenemy MAILBAG WEAK state breakobject enda

useractor notenemy FEATHEREDCHICKEN WEAK state breakobject enda

useractor notenemy SKINNEDCHICKEN WEAK state breakobject enda

useractor notenemy HEADLAMP WEAK state breakobject enda

useractor notenemy DOLPHIN1 DOLPHINSTRENGTH state breakobject enda

useractor notenemy DOLPHIN2 DOLPHINSTRENGTH state breakobject enda

useractor notenemy SNAKEP MEDIUMSTRENGTH state breakobject enda

useractor notenemy DONUTS WEAK state breakobject enda

useractor notenemy GAVALS WEAK state breakobject enda

useractor notenemy GAVALS2 WEAK state breakobject enda

useractor notenemy CUPS WEAK state breakobject enda

useractor notenemy DONUTS2 WEAK state breakobject enda

useractor notenemy FLOORBASKET WEAK state breakobject enda

useractor notenemy METER WEAK state breakobject enda

useractor notenemy DESKPHONE WEAK state breakobject enda

useractor notenemy MACE WEAK state breakobject enda

useractor notenemy SHOPPINGCART WEAK state breakobject enda

useractor notenemy COFFEEMUG WEAK state breakobject enda



state headhitstate

// Unrem the following line to invoke screen tilting during
// low player hitpoint damage.

// wackplayer

ends


action EXPBARRELFRAME     0   2   1   1   15
actor EXPLODINGBARREL 26
  fall
  ifaction EXPBARRELFRAME
  {
    ifactioncount 2
    {
      hitradius 1024 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      spawn EXPLOSION2
      debris SCRAP2 2
      sound PIPEBOMB_EXPLODE
      killit
    }
    break
  }
  ifsquished
  {
    debris SCRAP1 5
    killit
    break
  }
  ifhitweapon
    action EXPBARRELFRAME
enda

action BURNING_FLAME  0   12   1   1   2
move BURNING_VELS 

state burningstate

  sleeptime 300


  ifspawnedby BURNING
  {
    ifgapzl 16
      break
  }
  else
    ifspawnedby BURNING2
  {
    ifgapzl 16
      break
  }

  ifpdistg 10240
    break

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

    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

actor BURNING2 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
          nullop
      else
        sizeto 24 32
    }

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

action WOODENHORSEFRAME  0   1   4
action WOODENFALLFRAME  122  1   5

actor HORSEONSIDE WEAKEST
  cactor WOODENHORSE
  action WOODENFALLFRAME
enda
actor WOODENHORSE WEAK WOODENHORSEFRAME
  fall
  ifhitweapon
  {
    ifdead
    {
      debris SCRAP1 4
      debris SCRAP2 3
      killit
    }
    else
      action WOODENFALLFRAME
  }
enda

state steamcode
  ifpdistl 6144
    soundonce STEAM_HISSING

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

    sizeto 24 24
  }
ends

action STEAMFRAMES    0     5     1     1     1
actor STEAM 0 STEAMFRAMES
  state steamcode
enda

actor CEILINGSTEAM 0 STEAMFRAMES
  state steamcode
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

      ifrnd 84
        sizeat 8 10
      else
        ifrnd 84
          sizeat 10 8
      else
        sizeat 9 9
    }

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


move SMOKEVEL 8 -4
move ENGINE_SMOKE 64 -32
move SMOKESHOOTOUT -96
action SMOKEFRAMES 0 4 1 1 10
actor SMALLSMOKE 0
cstat 0
ifmove 0
{
move stop faceplayer
}
getactor[THISACTOR].roll temp
addvar temp 4
setactor[THISACTOR].roll temp
    ifspawnedby RECON {
      sizeat 3 3 }
    else
      ifspawnedby SECTOREFFECTOR {
        sizeat 3 3 }
    else
      sizeat 3 3
    ifspawnedby RPG {
      cstat 2 sizeat 15 15 }

  ifpdistl 1596
    ifspawnedby RPG
      killit
  ifcount 20
    killit
enda

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

move SPAWNED_BLOOD

actor NUKEBARRELDENTED WEAK
  cactor NUKEBARREL
  action BARREL_DENTED
enda

actor NUKEBARRELLEAKED WEAK
  cactor NUKEBARREL
  action BARREL_DENTED2
enda

state random_ooz
  ifrnd 128
    spawn OOZ2
  else
    spawn OOZ
ends

actor NUKEBARREL MEDIUMSTRENGTH
  ifsquished
  {
    debris SCRAP1 32
    spawn BLOODPOOL
    state random_ooz
    killit
  }
  fall
  ifaction BARREL_DENTING
  {
    ifactioncount 2
    {
      debris SCRAP1 10
      ifrnd 2 spawn BLOODPOOL
      killit
    }
  }
  else
    ifhitweapon
  {
    ifdead
    {
      sound VENT_BUST

      ifrnd 128
        spawn BLOODPOOL
      action BARREL_DENTING
    }
    else
    {
      ifaction 0
        action BARREL_DENTED
      else
        ifaction BARREL_DENTED
      {
        action BARREL_DENTED2
        spawn BLOODPOOL
      }
      else
        ifaction BARREL_DENTED2
          action BARREL_DENTING
    }
  }
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

actor FIREBARREL
  state burningbarrelcode
enda
actor FIREVASE
  state burningbarrelcode
enda

action SHRINKERFRAMES 0 4 1 1 10
actor SHRINKEREXPLOSION 0 SHRINKERFRAMES
  ifactioncount 4
    killit
enda

action EXPLOSION_FRAMES 0 17 1 1  4
action nuke_frames 1751 13 1 1 20
actor EXPLOSION2 1 EXPLOSION_FRAMES
setvar temp 0
ifspawnedby 3595 { sizeto 3500 3500 ifaction EXPLOSION_FRAMES { espawn 8057 setactor[RETURN].xrepeat 128 setactor[RETURN].yrepeat 128 getactor[RETURN].z z addvar z -27468 setactor[RETURN].z z action nuke_frames } }
ifspawnedby 3594 { sizeat 3000 3000 ifactioncount 17 { espawn 8057 setactor[RETURN].xrepeat 128 setactor[RETURN].yrepeat 128 getactor[RETURN].z z addvar z -27468 setactor[RETURN].z z } }
ifspawnedby 3600 { sizeat 3000 3000 ifactioncount 17 {  espawn 8057 setactor[RETURN].xrepeat 128 setactor[RETURN].yrepeat 128 getactor[RETURN].z z addvar z -27468 setactor[RETURN].z z } }
ifspawnedby 3603 { sizeat 3000 3000 ifactioncount 17 {  espawn 8057 setactor[RETURN].xrepeat 128 setactor[RETURN].yrepeat 128 getactor[RETURN].z z addvar z -27468 setactor[RETURN].z z } }
ifspawnedby 3707 { spritepal 1 sizeat 90 90 ifactioncount 14 { randvar angvar 2048 setactor[THISACTOR].ang angvar shoot SHOTSPARK1 shoot SHOTSPARK1 randvar angvar 2048 setactor[THISACTOR].ang angvar shoot SHOTSPARK1 randvar angvar 2048 setactor[THISACTOR].ang angvar shoot SHOTSPARK1 shoot SHOTSPARK1 randvar angvar 2048 setactor[THISACTOR].ang angvar shoot SHOTSPARK1 shoot SHOTSPARK1 shoot SHOTSPARK1 randvar angvar 2048 setactor[THISACTOR].ang angvar shoot SHOTSPARK1 debris SCRAP1 5 } }
ifaction nuke_frames { ifactioncount 13 killit }
ifactioncount 17
{
espawn 8057 setactor[RETURN].xrepeat 64 setactor[RETURN].yrepeat 64 getactor[RETURN].z z addvar z -27468 setactor[RETURN].z z
killit
}
enda

actor EXPLOSION2BOT 1 EXPLOSION_FRAMES
  ifactioncount 20
    killit
enda

action FFLAME_FR 0 16 1 1 1
action FFLAME 0 1 1 1 1

actor FLOORFLAME 0 FFLAME_FR
  ifaction FFLAME_FR
  {
    ifpdistl 1024
      hitradius 1024 WEAKEST WEAKEST WEAKEST WEAKEST
    ifactioncount 16
      action FFLAME
  }
  ifaction FFLAME
    ifrnd 4
  {
    action FFLAME_FR
    sound CAT_FIRE
    resetactioncount
  }
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
      move 0
    }
    ifcount 32
      resetcount
    else
      ifcount 16
    {
      ifcount 17 nullop
      else
      {
        sound PRED_ATTACK
        shoot FIRELASER
      }
    }
    else
      ifcount 4
    {
      ifcount 5 nullop
      else
      {
        ifcansee
          ifcanshoottarget
        {
          sound PRED_ATTACK
          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 472
else
globalsound 471
  ifrespawn
  {
    move RESPAWN_ACTOR_FLAG
    spawn RESPAWNMARKERRED
    cstat 32768
  }
  else
    killit
ends

state randgetweapsnds
  ifrnd 64
    globalsound DUKE_GETWEAPON1
  else
    ifrnd 96
      globalsound DUKE_GETWEAPON2
  else
    ifrnd 128
      globalsound DUKE_GETWEAPON3
  else
    ifrnd 140
      globalsound DUKE_GETWEAPON4
  else
    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 472
  else
    globalsound DUKE_GET
  killit
ends

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

actor STEROIDS
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk
      nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
            ifpinventory GET_STEROIDS STEROID_AMOUNT
              ifcanseetarget
      {
        addinventory GET_STEROIDS STEROID_AMOUNT
        quote 37
        ifspawnedby STEROIDS
          state getcode
        else
          state quikget
      }
enda

actor BOOTS
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk
      nullop
    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 HEATSENSOR
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk
      nullop
  else
    ifp palive
      ifcount 6
        ifpdistl RETRIEVEDISTANCE
          ifpinventory GET_HEATS HEAT_AMOUNT
            ifcanseetarget
      {
        addinventory GET_HEATS HEAT_AMOUNT
        quote 101
        ifspawnedby HEATSENSOR
          state getcode
        else
          state quikget
      }
enda

actor SHIELD
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
            ifpinventory GET_SHIELD 400
              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
globalsound 472
          state getcode
  killit
        
      }
enda


actor AIRTANK

spawn ATOMICHEALTH
killit
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
            ifpinventory GET_SCUBA SCUBA_AMOUNT
              ifcanseetarget
      {
        addinventory GET_SCUBA SCUBA_AMOUNT
        quote 39
        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 nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
            ifpinventory GET_HOLODUKE HOLODUKE_AMOUNT
              ifcanseetarget
      {
        addinventory GET_HOLODUKE HOLODUKE_AMOUNT
        quote 51
        ifspawnedby HOLODUKE
          state getcode
        else
          state quikget
      }
enda

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

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

actor AMMO
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
            ifcanseetarget
      {
        addvar pistol_ammo 18
        quote 65
        ifspawnedby AMMO
          state getcode
globalsound 471
        killit
      }
enda

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

actor SHOTGUNAMMO
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifcount 6
          ifpdistl RETRIEVEDISTANCE
ifvarl shotgam 600
            ifcanseetarget
      {
        addvar shotgam 50
        quote 69
        ifspawnedby SHOTGUNAMMO
          state getcode
     globalsound 471
        killit
      }
enda

actor AMMOLOTS
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    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 nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        addammo SHRINKER_WEAPON CRYSTALAMMOAMOUNT
        quote 78
        ifspawnedby CRYSTALAMMO
          state getcode
     globalsound 471
        killit
      }
enda

actor GROWAMMO
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        addammo GROW_WEAPON GROWCRYSTALAMMOAMOUNT
        quote 123
        ifspawnedby GROWAMMO
          state getcode
        globalsound 471
        killit
      }
enda

actor BATTERYAMMO
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
ifvarl mammo 150
            ifcanseetarget
      {
        addvar mammo 30
          quote 63
        ifspawnedby BATTERYAMMO
          state getcode
       globalsound 471
        killit
      }
enda

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

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

actor HBOMBAMMO
  fall
  ifmove RESPAWN_ACTOR_FLAG state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifgotweaponce 0
          break

        addvar gran 2
        quote 55
//        addammo HANDBOMB_WEAPON HANDBOMBBOX

        ifspawnedby HBOMBAMMO
          state getweaponcode
        else
          state quikweaponget
      }
enda

actor RPGSPRITE
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifgotweaponce 0
          break

        addweapon RPG_WEAPON RPGAMMOBOX
        quote 56
        ifspawnedby RPGSPRITE
          state getweaponcode
        else
          state quikweaponget
      }
enda

actor SHOTGUNSPRITE
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget       
{
     ifgotweaponce 0
break
          setplayer[THISACTOR].gotweapon 2 1
addvar shotgam 50
          quote 57
        ifspawnedby SHOTGUNSPRITE
          state getweaponcode
        else
          state quikweaponget
}
enda



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

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

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




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


actor FIRSTGUNSPRITE
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifgotweaponce 0
          break
        setplayer[THISACTOR].gotweapon 1 1
        addvar pistol_ammo 9
        ifspawnedby FIRSTGUNSPRITE
          state getweaponcode
        else
          state quikweaponget
      }
enda


actor TRIPBOMBSPRITE
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    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 nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifgotweaponce 0
          break

        setplayer[THISACTOR].gotweapon 3 1
addvar mammo 8
        quote 54
        ifspawnedby CHAINGUNSPRITE
          state getweaponcode
        else
          state quikweaponget
      }
enda



actor SHRINKERSPRITE
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifgotweaponce 0
          break
        addweapon SHRINKER_WEAPON 10
        quote 60
        ifspawnedby SHRINKERSPRITE
          state getweaponcode
        else
          state quikweaponget
      }
enda

actor FREEZESPRITE
  fall
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    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 nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifgotweaponce 0
          break
        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
  ifcount 24
  {
    ifpdistl RETRIEVEDISTANCE
    {
      ifrnd SWEARFREQUENCY
        soundonce DUKE_STEPONFECES

      sound STEPNIT

      spawn BLOODPOOL   // Will be brown
      killit
    }
  }
  else
    sizeto 32 32
enda

state drop_ammo
    spawn AMMO
ends

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




action FEMSHRUNK
action FEMFROZEN1 1
action FEMGROW
action FEMFROZEN2
action FEMDANCE1 19 1 1 1 16
action FEMDANCE3 19 1 1 1 26
action FEMDANCE2 20 2 1 1 10

action FEMANIMATESLOW 0 2 1 1 100
action TOUGHGALANIM   0 5 1 1 25
action FEMANIMATE

state femcode

  ifactor NAKED1 nullop
  else
    ifactor FEM6 nullop
    else
    {
      fall
      ifactor BLOODYPOLE
        ifhitweapon
          ifdead
      {
        state standard_jibs
        killit
      }
    }

  ifaction FEMSHRUNK
  {
    ifcount SHRUNKDONECOUNT
    {
      action FEMANIMATE
      cstat 257
    }
    else
      ifcount SHRUNKCOUNT
        sizeto 40 40
    else
      state genericshrunkcode
  }
  else ifaction FEMGROW
  {
    ifcount 32
    {
      respawnhitag
      guts JIBS4 20
      guts JIBS6 20
      spritepal 6
      soundonce LADY_SCREAM
      ifactor NAKED1
        debris SCRAP3 4
      else
        ifactor PODFEM1
          debris SCRAP3 4
      sound SQUISHED
      killit
    }
    else
      sizeto MAXXSTRETCH MAXYSTRETCH
  }

  else
    ifaction FEMDANCE1
  {
    ifactioncount 2
      action FEMDANCE2
  }
  else
    ifaction FEMDANCE2
  {
    ifactioncount 8
      action FEMDANCE3
  }
  else
    ifaction FEMDANCE3
  {
    ifactioncount 2
    action FEMANIMATE
  }
  else
    ifaction FEMFROZEN1
  {
    ifcount THAWTIME
    {
      action FEMANIMATE
      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      lotsofglass 30
      sound GLASS_BREAKING
      respawnhitag
      ifrnd 84
        spawn BLOODPOOL
      killit
    }
    else
      ifp pfacing
        ifpdistl FROZENQUICKKICKDIST
          pkick
    break
  }
  else ifaction FEMFROZEN2
  {
    ifcount THAWTIME
    {
      ifactor TOUGHGAL
        action TOUGHGALANIM
      else
        ifactor FEM10
          action FEMANIMATESLOW
      else
        action FEMANIMATE

      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
          break
      }

      lotsofglass 30

      sound GLASS_BREAKING
      ifrnd 84
        spawn BLOODPOOL
      respawnhitag

      ifrnd 128
        sound DUKE_HIT_STRIPPER1
      else
        sound DUKE_HIT_STRIPPER2

      killit
    }
    else
      ifp pfacing
        ifpdistl FROZENQUICKKICKDIST
          pkick
    break
  }

  ifhitweapon
  {
    ifdead
    {
      ifwasweapon GROWSPARK
      {
        cstat 0
        move 0
        sound ACTOR_GROWING
        action FEMGROW
        break
      }
      else ifwasweapon FREEZEBLAST
      {
        ifaction FEMSHRUNK
          break

        ifactor NAKED1
          action FEMFROZEN2
        else
          ifactor FEM5
            action FEMFROZEN2
        else
          ifactor FEM6
            action FEMFROZEN2
        else
          ifactor FEM8
            action FEMFROZEN2
        else
          ifactor FEM9
            action FEMFROZEN2
        else
          ifactor FEM10
            action FEMFROZEN2
        else
          ifactor TOUGHGAL
            action FEMFROZEN2
        else
          ifactor PODFEM1
            action FEMFROZEN2
        else
          action FEMFROZEN1

        move 0
        spritepal 1
        strength 0

        sound SOMETHINGFROZE

        break
      }

      ifrnd 128
        sound DUKE_HIT_STRIPPER1
      else
        sound DUKE_HIT_STRIPPER2

      respawnhitag
      state standard_jibs
      state random_wall_jibs
      spawn BLOODPOOL

      ifactor FEM1
        money 5
      else
        ifactor FEM2
      {
        money 7
        cactor BARBROKE
        cstat 0
      }
      else
        ifactor FEM3
          money 4
      else
        ifactor FEM7
          money 8

      ifactor FEM5
      {
        strength TOUGH
        cactor BLOODYPOLE
      }
      else ifactor FEM6
      {
        cstat 0
        cactor FEM6PAD
      }
      else
        ifactor FEM8
      {
        strength TOUGH
        cactor BLOODYPOLE
      }
      else
      {
        spritepal 6
        soundonce LADY_SCREAM
        ifactor NAKED1
          debris SCRAP3 18
        else
          ifactor PODFEM1
            debris SCRAP3 18
        killit
      }
    }
    else
    {
      ifwasweapon SHRINKSPARK
      {
        sound ACTOR_SHRINKING
        move 0
        action FEMSHRUNK
        cstat 0
        break
      }
      else
        ifwasweapon GROWSPARK
          sound EXPANDERHIT
      ifactor FEM8
        break

      ifactor TOUGHGAL
          state toughgalspeech
      else sound SQUISHED

      guts JIBS6 1
    }
  }
ends

state killme
  ifinwater nullop
  else
    ifp pfacing
      ifpdistl 1280
        ifhitspace
          soundonce KILLME
ends

state tipme
  ifp pfacing
    ifpdistl 1280
      ifhitspace
  {
    tip
    ifrnd 128
      soundonce DUKE_TIP1
    else
      soundonce DUKE_TIP2
    ifactor FEM1
      action FEMDANCE1
  }
ends

state toughgaltalk
  ifp pfacing
    ifpdistl 1280
      ifhitspace
        state toughgalspeech
ends

actor FEM1 TOUGH FEMANIMATE
  state tipme
  state femcode
enda
actor FEM2 TOUGH FEMANIMATE
  state tipme
  state femcode
enda
actor FEM3 TOUGH FEMANIMATE
  state tipme
  state femcode
enda
actor FEM4 TOUGH FEMANIMATE
  state femcode
enda
actor FEM5 TOUGH FEMANIMATE
  state killme
  state femcode
enda
actor FEM6 TOUGH FEMANIMATE
  state killme
  state femcode
enda
actor FEM7 TOUGH FEMANIMATE
  state tipme
  state femcode
enda
actor FEM8 TOUGH FEMANIMATE
  state femcode
enda
actor FEM9 TOUGH FEMANIMATE
  state femcode
enda
actor FEM10 TOUGH FEMANIMATESLOW
  state tipme
  state femcode
enda

actor TOUGHGAL MANWOMANSTRENGTH TOUGHGALANIM
  state toughgaltalk
  state femcode
enda

actor NAKED1 TOUGH FEMANIMATE
  state killme
  state femcode
enda
actor PODFEM1 TOUGH FEMANIMATE
  state killme
  state femcode
enda
actor BLOODYPOLE TOUGH
  state femcode
enda
actor STATUEFLASH
  fall
  ifcount 32
    cactor STATUE
enda
actor STATUE
  fall
  ifp pfacing
    ifpdistl 1280
      ifhitspace
  {
    cactor STATUEFLASH
    move 0
  }
enda

actor MIKE
  ifp pfacing
    ifpdistl 1280
      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

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

action EGGOPEN1 1 1 1 1 4
action EGGOPEN2 2 1 1 1 4
action EGGOPEN3 2 1 1 1 4
action EGGWAIT  0
action EGGFROZEN 1
action EGGGROW 1
action EGGSHRUNK 1

actor EGG TOUGH
  fall
  ifaction 0
  {
    ifcount 64
    {
      ifrnd 128
      {
        action EGGWAIT
        move 0
      }
      else
      {
        sound SLIM_HATCH
        action EGGOPEN1
      }
    }
  }
  else
    ifaction EGGOPEN1
      ifactioncount 4
        action EGGOPEN2
  else
    ifaction EGGOPEN2
      ifactioncount 4
    {
      spawn GREENSLIME
action EGGOPEN3
    }
  else
    ifaction EGGGROW
      state genericgrowcode
  else
    ifaction EGGSHRUNK
      state genericshrunkcode
  else
    ifaction EGGFROZEN
  {
    ifcount THAWTIME
    {
      action 0
      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      lotsofglass 30

      sound GLASS_BREAKING
      ifrnd 84
        spawn BLOODPOOL

      addkills 1
      killit
    }

    // ifp pducking
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick

    break
  }

  ifhitweapon
  {
    ifdead
    {
      ifwasweapon FREEZEBLAST
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action EGGFROZEN
        strength 0
        break
      }
      else
        ifwasweapon GROWSPARK
      {
        cstat 0
        move 0
        sound ACTOR_GROWING
        action EGGGROW
        break
      }

      addkills 1

      sound SQUISHED

      state standard_jibs
      killit
    }
    else
      ifwasweapon SHRINKSPARK
      {
        move 0
        sound ACTOR_SHRINKING
        action EGGSHRUNK
        break
      }

      ifwasweapon GROWSPARK
        sound EXPANDERHIT
  }
  else
    ifaction EGGWAIT
  {
    ifcount 512
      ifrnd 2
    {
      ifaction EGGSHRUNK
        break
      sound SLIM_HATCH
      action EGGOPEN1
    }
  }

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 GROWSPARK GROWSPARK_WEAPON_STRENGTH
  ifcount 18
    killit
  else
    ifcount 9
  {
    sizeto 0 0
    sizeto 0 0
    sizeto 0 0
    sizeto 0 0
  }
  else
  {
    sizeto 28 28
    sizeto 28 28
    sizeto 28 28
    sizeto 28 28
  }
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

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
    state random_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 PGROWING   0
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   50   4   5   1   30
action PFALLING   65   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   375   1   5   1   10
action PSWIMMING   375   4   5   1   13
action PSWIMMINGWAIT 395   1   5   1   13
action PTREDWATER  395   2   5   1   17

move PSTOPED
move PSHRINKING // used as a var only

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
      action PJUMPING
  else
    ifp pducking
      action PDUCKING
ends

state gunwork
ifvare curweap 1 {
getplayer[THISACTOR].ammo_amount 1 tmp
ifvare weapon_1 0 { setvarvar CURRENTGUNMAG DEAGLEMAG }
else
ifvare weapon_1 1 { setvarvar CURRENTGUNMAG MP5KMAG }
getplayer[THISACTOR].kickback_pic kickbackpic
ifvare kickbackpic  1 {
ifvare weapon_1 0 {
getplayer[THISACTOR].horiz temp
addvar temp 3
setplayer[THISACTOR].horiz temp
} else
ifvare weapon_1 1 {
getplayer[THISACTOR].horiz temp
addvar temp 5
setplayer[THISACTOR].horiz temp
}
}
ifvare kickbackpic 1 {
ifvare weapon_1 0 { subvar DEAGLEMAG 1 addvar tmp 1 setplayer[THISACTOR].ammo_amount 1 tmp } else
ifvare weapon_1 1 { addvar tmp 1 setplayer[THISACTOR].ammo_amount 1 tmp subvar MP5KMAG 1 }
}
}
else
ifvare curweap 2 { ifvare r12 0 {
getplayer[THISACTOR].ammo_amount 2 temp
setvarvar CURRENTGUNMAG RIFLE12MAG
getplayer[THISACTOR].kickback_pic kickbackpic
ifvare kickbackpic 1 { getplayer[THISACTOR].horiz temp
addvar temp 5
setplayer[THISACTOR].horiz temp
}
ifvare kickbackpic 1 { subvar RIFLE12MAG 1 addvar temp 1 setplayer[THISACTOR].ammo_amount 2 temp }
} 
}
ifvare curweap 4 { getplayer[THISACTOR].kickback_pic kickbackpic
ifvare kickbackpic 1 {
getplayer[THISACTOR].horiz temp
addvar temp 10
setplayer[THISACTOR].horiz temp
}
}
ifvare curweap 3 {
getplayer[THISACTOR].ammo_amount 3 temp
setvarvar CURRENTGUNMAG mmag
getplayer[THISACTOR].kickback_pic kickbackpic
ifvare kickbackpic 1 { getplayer[THISACTOR].horiz tmp
addvar tmp 5
setplayer[THISACTOR].horiz tmp
}
ifvare kickbackpic 1 { subvar mmag 1 addvar temp 2 setplayer[THISACTOR].ammo_amount 3 temp }
}
ends

move PGROWINGPOP        // Used only as a variable

definesound 493 sound/player/soundd.ogg 0 0 0 4 0

actor APLAYER MAXPLAYERHEALTH PSTAND 0 0

ifvare chapter1 2
{
sound 449
setvar chapter1 3
}

ifvare INTRO01 2
{
sound 494
setvar INTRO01 3
}

getinput[THISACTOR].bits tmp4
ifvarand tmp4 8
{
ifvarg gran 0
ifcount 5
{
setvar shootdyna 1
subvar gran 1
resetcount
}
}

ifvarg gran 6 { setvar gran 6 }

ifvare Plight 1
{
spawn 3747
setvar Plight 2
}

ifvare other 1
{
stopsound 407
stopsound 418
soundonce 463
addvar countvar 1
ifvare countvar 512
{
setvar other 20
setvar countvar 0
}
}

ifvare other 20
{
soundonce 469
setvar other 0
}

ifvare slowmotion 1
{
addvar countvar3 1
inittimer 40
ifvare countvar3 128
{
setvar slowmotion 0
setvar countvar3 0
}
}

ifvare slowmotion 2
{
addvar countvar3 1
inittimer 100
palfrom 50 63 63 63
soundonce 493
ifvare countvar3 50
{
setvar slowmotion 0
setvar countvar3 0
}
}

ifvare slowmotion 0
{
inittimer 120
}

ifinwater
{
ifvarg OX 0
{
setplayer[THISACTOR].scuba_amount 2
soundonce 465
addvar countvar2 1
ifvare countvar2 50
{
subvar OX 1
setvar countvar2 0
}
getplayer[THISACTOR].scuba_amount temp
ifvarn temp 2
{
setplayer[THISACTOR].scuba_amount 2
}
}
else
ifvarl OX 1
{
ifvarl energy 40
ifvarg energy 10
{
addvarvar OX energy 
setvar energy 0
}
else
ifvarl energy 1
{
setplayer[THISACTOR].scuba_amount -1
}
else
ifvarg energy 40
{
subvar energy 40
setvar OX 40
}
}
}

getplayer[THISACTOR].cursectnum mysector
getsector[mysector].lotag temp5
ifvare temp5 50
{ 
{
ifvarg OX 0
{
setplayer[THISACTOR].scuba_amount 2
soundonce 465
addvar countvar2 1
ifvare countvar2 50
{
subvar OX 1
setvar countvar2 0
}
getplayer[THISACTOR].scuba_amount temp
ifvarn temp 2
{
setplayer[THISACTOR].scuba_amount 2
}
}
else
ifvarl OX 1
{
ifvarl energy 40
ifvarg energy 10
{
addvarvar OX energy 
setvar energy 0
}
else
ifvarl energy 1
{
setplayer[THISACTOR].scuba_amount -1
addvar countvar 1
ifvare countvar 12
{
addphealth -10
setvar countvar 0
}
}
else
ifvarg energy 40
{
subvar energy 40
setvar OX 40
}
}
}
}

ifvare VOLUME 0 {
ifvare LEVEL 1 {
ifvare reseti 0 {
setvar countvar 0
setvar tmp3 0
setvar testc 0
setvar tmp2 0
setvar energy 0
setvar temp 0
setvar temp2 0
setvar temp3 0
setvar temp4 0
setvar temp5 0
setvar temp6 0
setvar temp7 0
setvar tmp 0
setvar tmp4 0
setvar tmp5 0
resetcount
setvar reseti 1
}
}
}
//ifvare curweap 0 { ifvare chain 1 {
//soundonce 439 } }
ifvare curweap 0 { ifvare chain 0 { setplayer[THISACTOR].weapon_pos -9 } }
state gunwork
ifvare DNSUIT 2 {
soundonce DUKE_JETPACK_IDLE
}

//ifvare chapter1 1 { addvar countvar 1 ifvare countvar 150 { setvar chapter1 0 setvar countvar 0 } }
ifvarg testc 0 {
soundonce REACTOR_ON }
ifvare testc 1 { setvar ene8 1 addvar countvar3 1 ifvare countvar3 512 { setvar testc 2 } }
ifvare testc 2 {
setvar testc 3 }
ifvare testc 3 {
ifcount 30 { sound RPG_EXPLODE quake 50 addvar tmp3 1 resetcount }
ifvare tmp3 1 { setvar countvar 0 }
ifvare tmp3 2 { soundonce 499 }
ifvare tmp3 3 { soundonce 500 }
ifvare tmp3 9 { soundonce 498 espawn TRANSPORTERBEAM }
ifvare tmp3 10 { setvar Black_Screen 1 }
ifvare tmp3 11 { startlevel VOLUME 1 } 
}
ifvare DNSUIT 0 
{ 
setplayer[THISACTOR].weapon_pos -9 
}
ifvare putdn 1 { ifcount 72 {
palfrom 100 100 100 100
palfrom 100 100 100 100
palfrom 100 100 100 100
resetcount
setvar putdn 3 } }
ifvare putdn 3 { ifcount 32 {
setvar DNSUIT 1
stopsound REACTOR_ON
ifcount 128 {
resetcount
setvar putdn 2
}
}
}

ifvare shootdyna 1 { shoot 3698 setvar shootdyna 0 }
ifvarg shotgam 300 { setvar shotgam 300 }
ifvarg pistol_ammo 180 { setvar pistol_ammo 180 }
ifvarg mammo 150 { setvar mammo 150 }

ifvare medkitbegin 0 {
spawn FIRSTAID setvar medkitbegin 1
}

getactor[THISACTOR].extra health

ifvarl health 30 { soundonce 398 }
ifvare health 0 { stopsound 398 soundonce 404 }

getplayer[THISACTOR].firstaid_amount medkit

getactor[THISACTOR].htextra temp
ifvarg temp 0 {
getuserdef[THISACTOR].god tmp3 ifvare tmp3 1 nullop else
{
getplayer[THISACTOR].shield_amount armor
ifvarg  armor 0 {
subvarvar armor temp
setplayer[THISACTOR].shield_amount armor
setactor[THISACTOR].htextra 0
ifvarl armor 0 {
getactor[THISACTOR].extra tmp2
addvarvar tmp2 armor
setactor[THISACTOR].extra tmp2
setplayer[THISACTOR].shield_amount 0
}
}
}
} 
ifvare recharge 1 {
ifvarn energy 100 { ifcount 80 { addvar energy 1 resetcount } } }
ifvarg energy 100 { setvar recharge 0 }
ifvare energy 100 { setvar recharge 0 }
ifvare recharge 0 { ifvarl energy 0 { setvar recharge 1 } }
ifvare curweap 9 { getplayer[THISACTOR].ammo_amount 9 egon2 ifvarg egon2 30  { getinput[THISACTOR].bits tmp ifvarand tmp 8192 {
ifcount 16 { subvar egon2 30 setplayer[THISACTOR].ammo_amount 9 egon2 shoot 3682 sound CAT_FIRE resetcount } } } }
ifvare recharge 0 { getplayer[THISACTOR].shield_amount tmp2 ifvarl tmp2 100 { ifcount 128 { addvar tmp2 5 setplayer[THISACTOR].shield_amount tmp2 subvar energy 3 resetcount } } }
ifvare recharge 0 { ifvarg energy 14 {  getplayer[THISACTOR].jumping_counter tmp ifvarg tmp 0 { setplayer[THISACTOR].poszv -11000 setvar temp6 1 ifcount 16 { subvar energy 10 sound 414 resetcount } } } }

/*
ifvare curweap 5
{
getplayer[THISACTOR].ammo_amount 5 dyna ifvarg dyna 0 { getinput[THISACTOR].bits tmp ifvarand tmp 8192 {
ifcount 16 { subvar dyna 1 setplayer[THISACTOR].ammo_amount 5 dyna espawn 3707 quote 140 resetcount } } } }
*/


ifvare temp6 1
{
getplayer[THISACTOR].poszv tmp4 ifvarg tmp4 1000 {  setplayer[THISACTOR].poszv 100 ifcount 56 { setvar temp6 0 resetcount  } } }

ifvarg mp5k_ammo 150 { setvar mp5k_ammo 150 }

getinput[THISACTOR].bits temp
ifvarand temp 64 {
ifvare curweap 1 {
ifvare weapon_1 0 {
ifvarvare DEAGLEMAG pistol_ammo { break }
ifvare DEAGLEMAG 18 { break }
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 4
ifvarl pistol_ammo 1 { break }
ifvarvarg pistol_ammo DEAGLEMAG {
addvarvar DEAGLEMAG pistol_ammo
setvar pistol_ammo 0
setvarvar tmp2 DEAGLEMAG
subvar tmp2 18
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar pistol_ammo tmp2 setvar DEAGLEMAG 18 } } else ifvarvarl pistol_ammo DEAGLEMAG {
addvarvar DEAGLEMAG pistol_ammo
setvar pistol_ammo 0
setvarvar tmp2 DEAGLEMAG
subvar tmp2 18
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar pistol_ammo tmp2 setvar DEAGLEMAG 18 }
}
}
else ifvare weapon_1 1 {
ifvarvare MP5KMAG mp5k_ammo { break }
ifvare MP5KMAG 30 { break }
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 6
soundonce EJECT_CLIP
ifvarl mp5k_ammo 1 { break }
ifvarvarg mp5k_ammo MP5KMAG {
addvarvar MP5KMAG mp5k_ammo
setvar mp5k_ammo 0
setvarvar tmp2 MP5KMAG
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mp5k_ammo tmp2 setvar MP5KMAG 30 } } else ifvarvarl mp5k_ammo MP5KMAG {
addvarvar MP5KMAG mp5k_ammo
setvar mp5k_ammo 0
setvarvar tmp2 MP5KMAG
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mp5k_ammo tmp2 setvar MP5KMAG 30 }
}
}
}
else
ifvare curweap 2 { 
getplayer[THISACTOR].ammo_amount 2 temp
ifvarvare RIFLE12MAG shotgam { break }
ifvare RIFLE12MAG 50 { break }
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 9
ifvarl shotgam 1 { break }
ifvarvarg shotgam RIFLE12MAG {
addvarvar RIFLE12MAG shotgam
setvar shotgam 0
setvarvar tmp2 RIFLE12MAG
subvar tmp2 50
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar shotgam tmp2 setvar RIFLE12MAG 50 } } else ifvarvarl shotgam RIFLE12MAG {
addvarvar RIFLE12MAG shotgam
setvar shotgam 0
setvarvar tmp2 RIFLE12MAG
subvar tmp2 50
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar shotgam tmp2 setvar RIFLE12MAG 50 } }
}
ifvare curweap 3 {
ifvarvare mmag mammo { break }
ifvare mmag 30 { break }
ifvarl mammo 1 { break }
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 9
soundonce 434
ifvarvarg mammo mmag {
addvarvar mmag mammo
setvar mammo 0
setvarvar tmp2 mmag
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mammo tmp2 setvar mmag 30 } } else ifvarvarl mammo mmag {
addvarvar mmag mammo
setvar mammo 0
setvarvar tmp2 mmag
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mammo tmp2 setvar mmag 30 } } }
else { break }
}

getplayer[THISACTOR].curr_weapon curweap

ifp pdead nullop else
state stepsoundstuff
else
ifp pjumping state STOPSTEPSOUNDS
else
ifp pfalling state STOPSTEPSOUNDS else
ifinwater state STOPSTEPSOUNDS

//ifvare TRACK 1 { soundonce 418 stopsound 407 }
//ifvare TRACK 2 { soundonce 407 stopsound 418 }
//ifvare TRACK 3 { soundonce 466 }

getuserdef[THISACTOR].team team
ifvare team 0 { spritepal 7 } else ifvare team 1 { spritepal 2 } else ifvare team 2 { spritepal 8 } else ifvare team 3 { nullop }


ifaction 0

    action PSTAND

  ifaction PFROZEN
  {
    cstat 257

    fall

    palfrom 16 0 0 24

    ifmove 0
    {
      ifhitweapon
      {
        ifwasweapon FREEZEBLAST
          break
        lotsofglass 60
        ifrnd 84
          spawn BLOODPOOL

        sound GLASS_BREAKING
        spawn ATOMICHEALTH

        getlastpal

        move 1
        break
      }
    }
    else
    {
      cstat 32768
      quote 13
      ifhitspace
      {
        action PSTAND
        resetplayer
      }
      break
    }

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

    ifp pfacing   // assumes another other player  (multiplayer)
      ifpdistl FROZENQUICKKICKDIST
        pkick

    break
  }

  ifdead
  {
    ifaction PGROWING
    {
      ifmove PGROWINGPOP
      {
        quote 13
        ifhitspace
        {
          action 0
          resetplayer
        }
        break
      }
      else
      {
        ifcount 32
        {
          sound SQUISHED
          palfrom 48 64

          state standard_pjibs

          guts JIBS4 20
          guts JIBS6 20
          move PGROWINGPOP
          cstat 32768
          tossweapon

          hitradius 2048 60 70 80 90

        }
        else
          sizeto MAXXSTRETCH MAXYSTRETCH
      }
      break
    }

    ifsquished
      palfrom 32 63 63 63
    else
      fall

    ifactioncount 7
      move 0
    else
      ifactioncount 6
    {
      ifmultiplayer nullop
      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
    }

    ifaction PTHROWNBACK
    {
      ifactioncount 5
      {
        spawn BLOODPOOL
        action PLYINGDEAD
      }
      else
        ifactioncount 1
          move 0
      break
    }

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

    ifp pshrunk
    {
      state standard_pjibs
      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 standard_pjibs
        cstat 32768
        sound SQUISHED
        sound DUKE_DEAD
      }
    }

    tossweapon

    break
  }

  ifsquished
  {
    strength -1
    sound SQUISHED
    state random_ooz
    break
  }

  ifp ponsteroids
  {
    ifp pstanding nullop
    else
      spawn FRAMEEFFECT1
  }

  ifmove PSHRINKING
  {
    ifcount 32
    {
      ifcount SHRUNKDONECOUNT
      {
        move 0
        cstat 257
      }
      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
    {
      ifmultiplayer
        sound DUKE_KILLED4

      ifwasweapon GROWSPARK
      {
        palfrom 48 48
        action PGROWING
        count 0
        move 0
        sound ACTOR_GROWING
        cstat 0
        break
      }
    }
    else
    {
      ifmultiplayer
      {
        ifphealthl YELLHURTSOUNDSTRENGTHMP
        {
          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
        }
      }
      else
      {
        ifphealthl YELLHURTSOUNDSTRENGTH
        {
          ifrnd 74
            sound DUKE_LONGTERM_PAIN2
          else
            ifrnd 8
              sound DUKE_LONGTERM_PAIN3
          else
            sound DUKE_LONGTERM_PAIN4
        }
        ifrnd 128
          sound DUKE_LONGTERM_PAIN
      }
    }
    ifstrength TOUGH
    {
      state headhitstate
      sound DUKE_GRUNT
      ifp pstanding
        action PFLINTCHING
    }

    ifwasweapon RPG
    {
      ifrnd 32
        spawn BLOOD
      ifdead
        state standard_pjibs
      palfrom 48 52
      break
    }
    ifwasweapon RADIUSEXPLOSION
    {
      ifrnd 32
        spawn BLOOD
      ifdead
        state standard_pjibs
      palfrom 48 52
      break
    }
    ifwasweapon FIREEXT
    {
      ifrnd 32
        spawn BLOOD
      ifdead
        state standard_pjibs
      palfrom 48 52
      break
    }
    ifwasweapon GROWSPARK
    {
      palfrom 48 52
      sound EXPANDERHIT
      break
    }
    ifwasweapon SHRINKSPARK
    {
      palfrom 48 0 48
      move PSHRINKING // used as a var only.
      sound ACTOR_SHRINKING
      cstat 0
      break
    }
    ifwasweapon SHOTSPARK1
      palfrom 24 48
    ifwasweapon FREEZEBLAST
    {
      palfrom 48 0 0 48
      ifdead
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action PFROZEN
        break
      }
    }
    ifwasweapon COOLEXPLOSION1
      palfrom 48 48 0 48
    ifwasweapon KNEE
      palfrom 16 32
    ifwasweapon FIRELASER
      palfrom 32 32

    ifdead
    {
      action PTHROWNBACK
      tossweapon
    }

    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
      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
  {
    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
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }

  else
    ifaction PRUN
  {
    ifp pstanding
      action PSTAND
    else
      ifp pwalking
        action PWALK
    else
      ifp pwalkingback
        action PWALKBACK
    else
      ifp prunningback
        action PRUNBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }

  else
    ifaction PWALKBACK
  {
    ifp pstanding
      action PSTAND
    else
      ifp pwalking
        action PWALK
    else
      ifp prunning
        action PRUN
    else
      ifp prunningback
        action PRUNBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }

  else
    ifaction PRUNBACK
  {
    ifp pstanding
      action PSTAND
    else
      ifp pwalking
        action PWALK
    else
      ifp prunning
        action PRUN
    else
      ifp pwalkingback
        action PWALKBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }
enda


state checking
ifvare curweap 1 {
ifvare weapon_1 0 ifvarg pistol_ammo 0
{
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 4
soundonce 434
ifvarvarg pistol_ammo DEAGLEMAG {
addvarvar DEAGLEMAG pistol_ammo
setvar pistol_ammo 0
setvarvar tmp2 DEAGLEMAG
subvar tmp2 18
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar pistol_ammo tmp2 setvar DEAGLEMAG 18 } } else ifvarvarl pistol_ammo DEAGLEMAG {
addvarvar DEAGLEMAG pistol_ammo
setvar pistol_ammo 0
setvarvar tmp2 DEAGLEMAG
subvar tmp2 18
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar pistol_ammo tmp2 setvar DEAGLEMAG 18 } } }
else
ifvare weapon_1 1 ifvarg mp5k_ammo 0 {
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 6
soundonce EJECT_CLIP
ifvarvarg mp5k_ammo MP5KMAG {
addvarvar MP5KMAG mp5k_ammo
setvar mp5k_ammo 0
setvarvar tmp2 MP5KMAG
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mp5k_ammo tmp2 setvar MP5KMAG 30 } } else ifvarvarl mp5k_ammo MP5KMAG {
addvarvar MP5KMAG mp5k_ammo
setvar mp5k_ammo 0
setvarvar tmp2 MP5KMAG
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mp5k_ammo tmp2 setvar MP5KMAG 30 } }
}
}
ifvare curweap 3 {
ifvarg mammo 0 {
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 9
soundonce 434
ifvarvarg mammo mmag {
addvarvar mmag mammo
setvar mammo 0
setvarvar tmp2 mmag
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mammo tmp2 setvar mmag 30 } } else ifvarvarl mammo mmag {
addvarvar mmag mammo
setvar mammo 0
setvarvar tmp2 mmag
subvar tmp2 30
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar mammo tmp2 setvar mmag 30 } } } }
else
ifvare curweap 2 { getplayer[THISACTOR].ammo_amount 2 tmp ifvare r12 0
ifvarg shotgam 0 {
setplayer[THISACTOR].reloading 1
setplayer[THISACTOR].kickback_pic 7
ifvarvarg shotgam RIFLE12MAG {
addvarvar RIFLE12MAG shotgam
setvar shotgam 0
setvarvar tmp2 RIFLE12MAG
subvar tmp2 50
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar shotgam tmp2 setvar RIFLE12MAG 50 } } else ifvarvarl shotgam RIFLE12MAG {
addvarvar RIFLE12MAG shotgam
setvar shotgam 0
setvarvar tmp2 RIFLE12MAG
subvar tmp2 50
ifvarl tmp2 1 { nullop } else
ifvarg tmp2 0 { addvarvar shotgam tmp2 setvar RIFLE12MAG 50 } } } }
ends

action open 0 2 1 1 4
action walk 2 3 1 1 4
action attack 5 2 1 1 4

move WALK2 200
move STOPPED1

ai aiwalk walk WALK2 faceplayer
ai aiattack attack STOPPED1 faceplayer

actor ORGANTIC TURRETSTRENGTH
sizeat 32 32
cstator 268
fall
ifp palive
ifcanseetarget
{
ifaction 0
{
action open
}
}
ifaction open
{
ifactioncount 4
{
ifai 0
{
shoot SPIT
shoot SPIT
shoot SPIT
ai aiwalk
}
}
}
ifai aiwalk
{
ifpdistl 1024
{
ai aiattack
}
}
ifai aiattack
{
ifpdistl 1024 
{
ifactioncount 4
{
addphealth -5
sound TURR_ATTACK
palfrom 32 20
resetactioncount
}
} 
else
ifpdistg 2048
{
ifai aiattack
{
ai aiwalk
}
}
}
ifhitweapon 
{
state random_wall_jibs
sound TURR_PAIN
ifdead 
{
state standard_jibs
spawn BLOODPOOL
state random_wall_jibs
killit
}
}
enda

state rf
  ifrnd 128
    cstat 4
  else
    cstat 0
ends


//
//
//    TROOP/LIZTROOP CODE
//
//

action ATROOPSTAND     0  1  5  1  1
action ATROOPGROW    0  1  5  1  1
action ATROOPSTAYSTAND  -2  1  5  1  1
action ATROOPWALKING   0  4  5  1   12
action ATROOPWALKINGBACK 15   4  5   -1   12
action ATROOPRUNNING   0  4  5  1  8
action ATROOPSHOOT    35  1  5  1   30
action ATROOPJETPACK  40  1  5  1  1
action ATROOPJETPACKILL 40  2  5  1   50
action ATROOPFLINTCH  50  1  1  1  6
action ATROOPDYING    50  5  1  1   16
action ATROOPDEAD     54
action ATROOPPLAYDEAD   54
action ATROOPSUFFERDEAD 58  2  1   -4   24
action ATROOPSUFFERING  59  2  1  1   21
action ATROOPDUCK     64  1  5  1  3
action ATROOPDUCKSHOOT  64  2  5  1   25
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  5

move TROOPWALKVELS 72
move TROOPWALKVELSBACK -72
move TROOPJETPACKVELS 64 -84
move TROOPJETPACKILLVELS 192 -38
move TROOPRUNVELS 108
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   TROOPRUNVELS  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
ai AITROOPGROW     ATROOPGROW    DONTGETUP faceplayerslow

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 nullop
      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 4 40
      sizeto 4 40
      sizeto 4 40
      sizeto 4 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
  ifinwater
  {
    ai AITROOPJETPACK
    break
  }
  ifcansee
  {
    ifmove TROOPRUNVELS
      ifpdistl 1596
        ai AITROOPDUCKING
    ifp phigher
    {
      ifceilingdistl 128 nullop
      else
        ifactornotstayput
          ai AITROOPJETPACK
      break
    }
    else
      ifrnd 2
    {
      ifspritepal 21
        ifpdistg 1596
      {
        ai AITROOPHIDE
        break
      }
      ifbulletnear
      {
        ifrnd 128
          ai AITROOPDODGE
        else
          ai AITROOPDUCKING
        break
      }
    }
  }
  ifnotmoving
  {
    ifrnd 32
      operate
    else
      ifcount 32
        ifp palive
          ifcansee
            ifcanshoottarget
              ai AITROOPSHOOTING
  }
  ifrnd 1
  {
    ifrnd 128
      soundonce PRED_ROAM
    else
      soundonce PRED_ROAM2
  }
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 2
      {
        ifcanshoottarget
        {
          sound PRED_ATTACK
          resetactioncount
          shoot FIRELASER
        }
        else ai AITROOPSEEKPLAYER
      }
  }
ends

state troopshootstate
  ifactioncount 2
  {
    ifcanshoottarget
    {
      shoot FIRELASER
      sound PRED_ATTACK
      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
  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
    sound PRED_DYING
    cstat 0
    strength 0
    action ATROOPSUFFERDEAD
    break
  }
  ifdead
  {
    ifwasweapon FREEZEBLAST
    {
      sound SOMETHINGFROZE
      spritepal 1
      move 0
      action ATROOPFROZEN
      strength 0
      break
    }

    state drop_ammo
    state random_wall_jibs

    ifwasweapon GROWSPARK
    {
      cstat 0
      sound ACTOR_GROWING
      ai AITROOPGROW
      break
    }

    addkills 1

    ifwasweapon RPG
    {
      sound SQUISHED
      state troop_body_jibs
      state standard_jibs
      killit
    }
    else
      ifwasweapon RADIUSEXPLOSION
    {
      sound SQUISHED
      state troop_body_jibs
      state standard_jibs
      killit
    }
    else
    {
      sound PRED_DYING
      ifrnd 32
        iffloordistl 32
      {
        sound LIZARD_BEG
        spawn BLOODPOOL
        strength 0
        move 0
        action ATROOPSUFFERING
        break
      }
      action ATROOPDYING
      break
    }
  }
  else
  {
    state random_wall_jibs
    sound PRED_PAIN

    ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AITROOPSHRUNK
    }
    else
      ifwasweapon GROWSPARK
        sound EXPANDERHIT
    else
      iffloordistl 32
        ifrnd 96
          action ATROOPFLINTCH
  }
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 checksquished
  ifsquished
  {
    addkills 1
    sound SQUISHED
    state standard_jibs
    state random_ooz
    killit
  }
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
  ifinwater
    ifrnd 1
      spawn WATERBUBBLE
  ifaction ATROOPSTAND
  {
    ifrnd 192
      ai AITROOPSHOOTING
    else
      ai AITROOPSEEKPLAYER
  }
  else
    ifaction ATROOPFROZEN
  {
    ifcount THAWTIME
    {
      ai AITROOPSEEKENEMY
      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }
    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1

      ifrnd 84
        spawn BLOODPOOL
      lotsofglass 30
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  else ifaction ATROOPPLAYDEAD
  {
    ifhitweapon
    {
      ifwasweapon RADIUSEXPLOSION
      {
        sound SQUISHED
        state troop_body_jibs
        state standard_jibs
        killit
      }
      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
        killit
      }
      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
   setvar enter 0
    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 nullop
      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
        state troopseekstate
    else
      ifai AITROOPDUCKING
        state troopduckstate
    else
      ifai AITROOPSHRUNK
        state troopshrunkstate
    else
      ifai AITROOPGROW
        state genericgrowcode
    else
      ifai AITROOPHIDE
    {
      state troophidestate
      break
    }
  }

  ifhitweapon
    state checktroophit
  else
    state checksquished
ends

state checktrooppalette
  ifai 0
  {
    ifspritepal 0
        nullop
    else
        ifspritepal 21
          addstrength TROOPSTRENGTH // Double the hitpoint vals
  }
ends


actor LIZTROOPJETPACK TROOPSTRENGTH
  state checktrooppalette
  ai AITROOPJETPACK
  cactor LIZTROOP
enda

actor LIZTROOPDUCKING TROOPSTRENGTH
  state checktrooppalette
  ai AITROOPDUCKING
  cactor LIZTROOP
  ifgapzl 48
    move DONTGETUP
enda

actor LIZTROOPSHOOT TROOPSTRENGTH ATROOPSTAND
  state checktrooppalette
  ai AITROOPSHOOTING
  cactor LIZTROOP
enda
actor LIZTROOPSTAYPUT TROOPSTRENGTH ATROOPSTAYSTAND
  state checktrooppalette
  ai AITROOPSEEKPLAYER
  cactor LIZTROOP
enda
actor LIZTROOPRUNNING TROOPSTRENGTH ATROOPSTAND
  state checktrooppalette
  ai AITROOPSEEKPLAYER
  cactor LIZTROOP
enda
actor LIZTROOPONTOILET TROOPSTRENGTH
  ifcount 24
  {
    sound FLUSH_TOILET
    operate
    ai AITROOPSEEKPLAYER
    cactor LIZTROOP
  }
  else
    ifcount 2
      nullop
  else
    state checktrooppalette
enda

actor LIZTROOPJUSTSIT TROOPSTRENGTH
  ifcount 30
  {
    operate
    ai AITROOPSEEKPLAYER
    cactor LIZTROOP
  }
  else
    ifcount 2
      nullop
  else
    state checktrooppalette
enda


actor LIZTROOP TROOPSTRENGTH ATROOPSTAND
spawn 9360 killit
  state checktrooppalette
  state troopcode
enda

action ALIZSTAND     0
action ALIZWALKING     0   4  5  1  15
action ALIZRUNNING     0   4  5  1  11
action ALIZTHINK     20  2  5  1  40
action ALIZSCREAM    30  1  5  1  2
action ALIZJUMP      45  3  5  1  20
action ALIZFALL      55  1  5
action ALIZSHOOTING    70  2  5  1  7
action ALIZDYING     60  6  1  1  15
action ALIZLYINGDEAD   65  1
action ALIZFROZEN     0  1  5

move LIZWALKVEL 72
move LIZRUNVEL 192
move LIZJUMPVEL 184
move LIZSTOP

ai AILIZGETENEMY ALIZWALKING LIZWALKVEL seekplayer
ai AILIZDODGE ALIZRUNNING LIZRUNVEL dodgebullet
ai AILIZCHARGEENEMY ALIZRUNNING LIZRUNVEL seekplayer
ai AILIZFLEENEMY ALIZWALKING LIZWALKVEL fleeenemy
ai AILIZSHOOTENEMY ALIZSHOOTING LIZSTOP faceplayer
ai AILIZJUMPENEMY ALIZJUMP LIZJUMPVEL jumptoplayer
ai AILIZTHINK ALIZTHINK LIZSTOP faceplayerslow
ai AILIZSHRUNK ALIZWALKING SHRUNKVELS fleeenemy
ai AILIZGROW ALIZSTAND  LIZSTOP faceplayerslow
ai AILIZSPIT ALIZSCREAM LIZSTOP faceplayerslow
ai AILIZDYING ALIZDYING LIZSTOP faceplayer

state lizseekstate

  ifactornotstayput
  {
    ifcansee
      ifp palive
        ifpdistl 2048
          ifcount 16
            ifcanshoottarget
    {
      ai AILIZSHOOTENEMY
      break
    }
    ifai AILIZCHARGEENEMY
    {
      ifcount 72
        ifcanshoottarget
      {
        ai AILIZSHOOTENEMY
        break
      }
      ifp phigher
        ifpdistg 2048
          ifrnd 6
      {
        ai AILIZJUMPENEMY
        break
      }
    }
    else
      ifpdistg 4096
    {
      ifrnd 92
      {
        ifcount 48
          ifcanshoottarget
            ai AILIZSHOOTENEMY
      }
      else
        ifcount 24
      {
        ai AILIZCHARGEENEMY
        break
      }
    }

    iffloordistl 16
    {
      ifcount 48
        ifnotmoving
          ifcansee
      {
        ai AILIZJUMPENEMY
        break
      }
    }
    else
    {
      ifpdistg 1280
        ai AILIZJUMPENEMY
      break
    }

    ifrnd 4
      ifnotmoving
        operate
    else
      ifrnd 1
        ifbulletnear
    {
      ifgapzl 128
        ai AILIZDODGE
      else
        ifactornotstayput
      {
        ifrnd 32
          ai AILIZJUMPENEMY
        else
          ai AILIZDODGE
      }
    }
  }
  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
  ifcount 16
  {
    ifrnd 48
      ifp palive
        ifcansee
          ai AILIZSPIT
  }
  else
  {
    iffloordistl 16 nullop
    else
      ai AILIZGETENEMY
    break
  }
ends

state lizthinkstate
  ifrnd 8
    soundonce CAPT_ROAM
  ifactioncount 3
  {
    ifrnd 32
      ifp palive
        ifcansee
          ai AILIZSPIT
        else
          ifrnd 96
            ai AILIZGETENEMY
  }
  else
    ifactioncount 2
      ifrnd 1
        spawn FECES
  ifrnd 1
    ifbulletnear
  {
    ifgapzl 96
      ai AILIZDODGE
    else
    {
      ifrnd 128
        ai AILIZJUMPENEMY
      else
        ai AILIZDODGE
    }
  }
ends

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

state checklizhit
  spawn BLOOD
  ifai AILIZSHRUNK
  {
    addkills 1
    sound SQUISHED
    state standard_jibs
    killit
  }
  ifdead
  {
    ifwasweapon FREEZEBLAST
    {
      sound SOMETHINGFROZE
      spritepal 1
      move 0
      action ALIZFROZEN
      strength 0
      break
    }

    state drop_chaingun

    ifwasweapon GROWSPARK
    {
      cstat 0
      sound ACTOR_GROWING
      ai AILIZGROW
      break
    }

    addkills 1

    ifwasweapon RPG
    {
      sound SQUISHED
      state liz_body_jibs
      state standard_jibs
      killit
    }
    else
      ifwasweapon RADIUSEXPLOSION
    {
      sound SQUISHED
      state liz_body_jibs
      state standard_jibs
      killit
    }
    else
    {
      state rf
      ai AILIZDYING
      ifrnd 64
        spawn BLOODPOOL
    }
    sound CAPT_DYING
  }
  else
  {
    sound CAPT_PAIN
    ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AILIZSHRUNK
      break
    }
    ifwasweapon GROWSPARK
      sound EXPANDERHIT

    state random_wall_jibs
    ifp palive
      ifcansee
        ifcanshoottarget
    {
      ai AILIZSHOOTENEMY
      break
    }
  }
ends

state lizjumpstate
  ifaction ALIZFALL
  {
    iffloordistl 16
      ai AILIZGETENEMY
  }
  else
    ifactioncount 3
      action ALIZFALL
ends

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

state lizdodgestate
  ifcount 13
    ai AILIZGETENEMY
ends

actor LIZMANSTAYPUT LIZSTRENGTH ai AILIZGETENEMY cactor LIZMAN enda
actor LIZMANSPITTING LIZSTRENGTH ai AILIZSPIT cactor LIZMAN enda
actor LIZMANJUMP LIZSTRENGTH ai AILIZJUMPENEMY cactor LIZMAN enda

state lizcode
  state checksquished
  ifai 0
    ai AILIZGETENEMY
  else
    ifaction ALIZLYINGDEAD
  {
    fall
    state lizdyingstate
    break
  }
  else
    ifaction ALIZFROZEN
  {
    ifcount THAWTIME
    {
      ai AILIZGETENEMY
      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1

      ifrnd 84
        spawn BLOODPOOL
      lotsofglass 30
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  else
    ifai AILIZJUMPENEMY
      state lizjumpstate
  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 AILIZTHINK
        state lizthinkstate
    else
      ifai AILIZSHRUNK
        state lizshrunkstate
    else
      ifai AILIZGROW
        state genericgrowcode
    else
      ifai AILIZDYING
        state lizdyingstate
    else
      ifai AILIZSPIT
    {
      ifcount 26
        ai AILIZGETENEMY
      else
        ifcount 18
          ifrnd 96
      {
        shoot SPIT
        sound LIZARD_SPIT
      }
    }
  }

  ifai AILIZSHRUNK
    break
  ifhitweapon
    state checklizhit
ends

actor LIZMAN LIZSTRENGTH
  fall
ifstrength 1
{ }
else
{
spawn 3908
}
  state lizcode
enda






action DRONEFRAMES   0   1   7   1   1
action DRONESCREAM   0   1   7   1   1
move DRONERUNVELS 128 64
move DRONERUNUPVELS 128 -64
move DRONEBULLVELS 252 -64
move DRONEBACKWARDS -64 -64
move DRONERISE 32 -32
move DRONESTOPPED -16

ai AIDRONEGETE DRONESCREAM DRONERUNVELS faceplayerslow getv
ai AIDRONEWAIT DRONEFRAMES DRONESTOPPED faceplayerslow
ai AIDRONEGETUP DRONESCREAM DRONERUNUPVELS faceplayer getv
ai AIDRONEPULLBACK DRONEFRAMES DRONEBACKWARDS faceplayerslow
ai AIDRONEHIT DRONESCREAM DRONEBACKWARDS faceplayer
ai AIDRONESHRUNK DRONEFRAMES SHRUNKVELS fleeenemy
ai AIDRONEDODGE DRONEFRAMES DRONEBULLVELS dodgebullet geth
ai AIDRONEDODGEUP DRONEFRAMES DRONERISE getv geth

state dronedead
  addkills 1
  debris SCRAP1 8
  debris SCRAP2 4
  debris SCRAP3 7
  spawn EXPLOSION2
  sound RPG_EXPLODE
  hitradius 2048 15 20 25 30
  killit
ends

state checkdronehitstate

  ifdead state dronedead
  else ifsquished state dronedead
  else
  {
    sound DRON_PAIN
    ifbulletnear
    {
      ifceilingdistl 64
        ifrnd 48
          ai AIDRONEDODGE
      ai AIDRONEDODGEUP
    }
    else
      ai AIDRONEGETE
  }
ends

state droneshrunkstate
  ifcount 24
    killit
  else
    sizeto 1 1
ends

state checkdronenearplayer

  ifp palive
    ifpdistl 1596
  {
    ifcount 8
    {
      addkills 1
      sound DRON_ATTACK2
      debris SCRAP1 8
      debris SCRAP2 4
      debris SCRAP3 7
      spawn EXPLOSION2
      sound RPG_EXPLODE
      hitradius 2048 15 20 25 30
      killit
    }
    else
      ifcount 3 nullop
      else
        sound LASERTRIP_ARMING
  }

ends

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

state dronedodgestate
  ifai AIDRONEDODGEUP
  {
     ifcount 8
       ai AIDRONEGETE
     else
       ifnotmoving
         ai AIDRONEGETE
  }
  else
  {
    ifcount 8
      ai AIDRONEGETE
    else
      ifnotmoving
        ai AIDRONEGETE
  }
ends

actor DRONE DRONESTRENGTH
spawn ORGANTIC killit
  state checkdronenearplayer

  ifrnd 2
    fall
  else
    soundonce DRON_JETSND

  ifaction 0
    ai AIDRONEGETE

  else
    ifai AIDRONEWAIT
  {
    ifactioncount 4
      ifrnd 16
        ifcansee
    {
      sound DRON_ATTACK1
      ifp phigher
        ai AIDRONEGETUP
      else ai AIDRONEGETE
    }
  }
  else
    ifai AIDRONEGETE
      state dronegetstate
  else
    ifai AIDRONEGETUP
      state dronegetstate
  else
    ifai AIDRONEPULLBACK
  {
    ifcount 32
    ai AIDRONEWAIT
  }
  else
    ifai AIDRONEHIT
  {
    ifcount 8
      ai AIDRONEWAIT
  }
  else
    ifai AIDRONESHRUNK
      state droneshrunkstate
  else
    ifai AIDRONEDODGE
      state dronedodgestate
  else
    ifai AIDRONEDODGEUP
      state dronedodgestate

  ifhitweapon
    state checkdronehitstate

  ifrnd 1
    soundonce DRON_ROAM

enda



action AOCTAWALK    0   3   5   1   15
action AOCTASTAND     0   1   5   1   15
action AOCTASCRATCH   0   4   5   1   15
action AOCTAHIT    30   1   1   1   10
action AOCTASHOOT    20   1   5   1   10
action AOCTADYING    30   8   1   1   17
action AOCTADEAD     35   1   1   1  1
action AOCTAFROZEN    0   1   5

move OCTAWALKVELS 96 -30
move OCTAUPVELS 96 -70
move OCTASTOPPED 0 -30
move OCTAINWATER 96 24

ai AIOCTAGETENEMY AOCTAWALK OCTAWALKVELS seekplayer
ai AIOCTASHOOTENEMY AOCTASHOOT OCTASTOPPED faceplayer
ai AIOCTASCRATCHENEMY AOCTASCRATCH OCTASTOPPED faceplayerslow
ai AIOCTAHIT AOCTAHIT OCTASTOPPED faceplayer
ai AIOCTASHRUNK AOCTAWALK SHRUNKVELS faceplayer
ai AIOCTAGROW AOCTASTAND OCTASTOPPED faceplayerslow
ai AIOCTADYING AOCTADYING OCTASTOPPED faceplayer

state octagetenemystate

  ifcansee
  {
    ifactioncount 32
    {
      ifrnd 48
        ifcanshoottarget
      {
        sound OCTA_ATTACK1
        ai AIOCTASHOOTENEMY
        break
      }
    }
    else
      ifpdistl 1280
        ai AIOCTASCRATCHENEMY
  }

ends

state octascratchenemystate
  ifpdistg 1280
    ai AIOCTAGETENEMY
  else
    ifcount 32
  {
    resetcount
    sound OCTA_ATTACK2
    palfrom 8 32
    addphealth OCTASCRATCHINGPLAYER
  }
ends

state octashootenemystate
  ifcount 25
  {
    ifcount 27
      ai AIOCTAGETENEMY
  }
  else
    ifcount 24
      shoot COOLEXPLOSION1
  else
    ifactioncount 6
      resetactioncount
ends

state checkoctahitstate
  ifwasweapon SHRINKSPARK
  {
    sound ACTOR_SHRINKING
    ai AIOCTASHRUNK
  }
  else
  {
    ifdead
    {
      ifwasweapon FREEZEBLAST
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action AOCTAFROZEN
        strength 0
        break
      }

      addkills 1
      ifwasweapon RPG
      {
        sound SQUISHED
        state standard_jibs
        killit
      }
      else
        ifwasweapon RADIUSEXPLOSION
      {
        sound SQUISHED
        state standard_jibs
        killit
      }
      else
        ifwasweapon GROWSPARK
      {
        cstat 0
        sound ACTOR_GROWING
        ai AIOCTAGROW
        break
      }
      else
      {
        state rf
        ai AIOCTADYING
      }
      sound OCTA_DYING
    }
    else
    {
      ifwasweapon RPG
      {
        sound OCTA_DYING
        addkills 1
        state standard_jibs
        killit
      }
      else
        ifwasweapon GROWSPARK
          sound EXPANDERHIT

      sound OCTA_PAIN
      spawn BLOOD
      ifrnd 64
        ai AIOCTAHIT
    }
  }
  state random_wall_jibs
ends

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


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

actor OCTABRAINSTAYPUT OCTASTRENGTH
  ai AIOCTAGETENEMY
  cactor OCTABRAIN
enda

actor OCTABRAIN OCTASTRENGTH
  fall
ifstrength 1
{ }
else
{
spawn 3908
}
  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
  {
    ifcount THAWTIME
    {
      ai AIOCTAGETENEMY
      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
      {
        ifactioncount 26
        {
          spawn WATERDRIP
          resetactioncount
        }
      }

    ifhitweapon
    {
      addkills 1
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }

      lotsofglass 30
      ifrnd 84
        spawn BLOODPOOL
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  else
  {
    ifrnd 1
      soundonce OCTA_ROAM

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

    ifmove OCTAUPVELS nullop
    else
      ifp phigher
        move OCTAUPVELS seekplayer
    else
      ifmove OCTAINWATER nullop
      else
        ifinwater
          move OCTAINWATER seekplayer

    ifhitweapon
      state checkoctahitstate
  }
enda

action APIGWALK     0  4 5 1 20
action APIGRUN      0  4 5 1 11
action APIGSHOOT    30 2 5 1 58
action APIGCOCK     25 1 5 1 16
action APIGSTAND    30 1 5 1 1
action APIGDIVE     40 2 5 1 40
action APIGDIVESHOOT  45 2 5 1 58
action APIGDYING    55 5 1 1 15
action APIGHIT      55 1 1 1 10
action APIGDEAD     60 1 1 1 1
action APIGFROZEN    0 1 5
action APIGGROW      0


move PIGWALKVELS 72
move PIGRUNVELS 108
move PIGSTOPPED

ai AIPIGSEEKENEMY APIGWALK PIGWALKVELS seekplayer
ai AIPIGSHOOTENEMY APIGSHOOT PIGSTOPPED faceplayer
ai AIPIGFLEEENEMY APIGWALK PIGWALKVELS fleeenemy
ai AIPIGSHOOT APIGSHOOT PIGSTOPPED faceplayer
ai AIPIGDODGE APIGRUN PIGRUNVELS dodgebullet
ai AIPIGCHARGE APIGRUN PIGRUNVELS seekplayer
ai AIPIGDIVING APIGDIVE PIGSTOPPED faceplayer
ai AIPIGDYING APIGDYING PIGSTOPPED faceplayer
ai AIPIGSHRINK APIGWALK SHRUNKVELS fleeenemy
ai AIPIGGROW APIGGROW PIGSTOPPED faceplayerslow
ai AIPIGHIT APIGHIT PIGSTOPPED faceplayer

state pigseekenemystate

  ifai AIPIGCHARGE
  {
    ifcansee
      ifpdistl 3084
    {
      ifnotmoving
        ai AIPIGSEEKENEMY
      else
        ai AIPIGDIVING
    }
    break
  }
  else iffloordistl 32
  {
    ifpdistg 4096
    {
      ifactornotstayput
      ai AIPIGCHARGE
    }
    ifrnd 8
    {
      ifbulletnear
        ai AIPIGDODGE
    }
  }

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


state pigshootenemystate
//  ifcansee
  {
    ifcount 12 nullop
    else
      ifcount 11
    {
      ifcanshoottarget
      {
        sound PIG_ATTACK
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
      }
      else
        ai AIPIGSEEKENEMY
    }
    ifcount 25 nullop
    else
      ifcount 24
      {
        action APIGCOCK
        sound SHOTGUN_COCK
      }
    ifcount 48 nullop
    else
      ifcount 47
    {
      ifcanshoottarget
      {
        sound PIG_ATTACK
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
        shoot SHOTGUN
      }
      else
        ai AIPIGSEEKENEMY
    }
    ifcount 60 nullop
    else
      ifcount 59
      {
        action APIGCOCK
        sound SHOTGUN_COCK
      }
    ifcount 72
    {
      ifrnd 64
        resetcount
      else
      {
        ifpdistl 768
          ai AIPIGFLEEENEMY
        else
          ai AIPIGSEEKENEMY
      }
    }
    ifaction APIGCOCK
      ifactioncount 2
        action APIGSHOOT
  }
  else
    ai AIPIGSEEKENEMY
ends

state pigfleeenemystate
  ifactioncount 8
    ai AIPIGSEEKENEMY
  else
    ifnotmoving
      ai AIPIGSEEKENEMY
ends

state pigdivestate
  ifaction APIGDIVESHOOT
  {
    ifcansee
    {
      ifcount 12 nullop
      else
        ifcount 11
      {
        ifcanshoottarget
        {
          sound PIG_ATTACK
          shoot SHOTGUN
          shoot SHOTGUN
          shoot SHOTGUN
          shoot SHOTGUN
        }
        else
          ai AIPIGSEEKENEMY
      }
      ifcount 25 nullop
      else
        ifcount 24
          sound SHOTGUN_COCK
      ifcount 48 nullop
      else
        ifcount 47
      {
        ifcanshoottarget
        {
          sound PIG_ATTACK
          shoot SHOTGUN
          shoot SHOTGUN
          shoot SHOTGUN
          shoot SHOTGUN
        }
        else
          ai AIPIGSEEKENEMY
      }
      ifcount 60 nullop
      else
        ifcount 59
      {
        sound SHOTGUN_COCK
        ifgapzl 32
          ai AIPIGDIVING
        else
        {
          ifpdistl 4096
            ai AIPIGFLEEENEMY
          else
            ai AIPIGSEEKENEMY
        }
      }
    }
    else
      ifgapzl 32
        ai AIPIGDIVING
      else
        ai AIPIGSEEKENEMY
  }
  else
    ifactioncount 2
    ifp palive
    {
      resetcount
      action APIGDIVESHOOT
    }
ends

state checkpighitstate
  spawn BLOOD
  ifdead
  {
    state random_wall_jibs
    ifrnd 16
      spawn SHIELD
    else
      state drop_shotgun

    ifwasweapon GROWSPARK
    {
      sound ACTOR_GROWING
      ai AIPIGGROW
      break
    }

    addkills 1

    ifwasweapon FREEZEBLAST
    {
      sound SOMETHINGFROZE
      spritepal 1
      move 0
      action APIGFROZEN
      strength 0
      break
    }
    ifwasweapon RADIUSEXPLOSION
    {
      sound SQUISHED
      state standard_jibs
      killit
    }
    else
      ifwasweapon RPG
    {
      sound SQUISHED
      state standard_jibs
      killit
    }
    else
      ai AIPIGDYING
        sound PIG_DYING
  }
  else
  {
    sound PIG_PAIN
    state random_wall_jibs

    ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AIPIGSHRINK
    }
    else
      ifwasweapon GROWSPARK
        sound EXPANDERHIT
    else
      ifrnd 32
        ai AIPIGHIT
    else
      ifrnd 64
        ai AIPIGSHOOTENEMY
    else
      ifrnd 64
      {
        ai AIPIGDIVING
        action APIGDIVESHOOT
      }
  }
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


actor PIGCOPDIVE PIGCOPSTRENGTH
  ai AIPIGDIVING
  action APIGDIVESHOOT
  cactor PIGCOP
enda
actor PIGCOPSTAYPUT PIGCOPSTRENGTH
  ai AIPIGSEEKENEMY
  cactor PIGCOP
enda
actor PIGCOP PIGCOPSTRENGTH APIGSTAND
  fall
spawn 9360 killit
  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
        killit
      }
      break
    }
  }
  else
    ifaction APIGFROZEN
  {
    ifcount THAWTIME
    {
      ai AIPIGSEEKENEMY
      getlastpal
    }
    else
      ifcount FROZENDRIPTIME
        ifrnd 8
          spawn WATERDRIP

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1

      lotsofglass 30
      ifrnd 84 spawn BLOODPOOL
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  else
    ifai AIPIGDYING
      state pigdyingstate
  else
    ifai AIPIGHIT
    {
      ifactioncount 3
      ai AIPIGSEEKENEMY
    }
  else
    ifai AIPIGSHRINK
      state pigshrinkstate
  else
  {
    ifai AIPIGSEEKENEMY
      state pigseekenemystate
    else
      ifai AIPIGDODGE
        state pigseekenemystate
    else
      ifai AIPIGSHOOTENEMY
        state pigshootenemystate
    else
      ifai AIPIGGROW
        state genericgrowcode
    else
      ifai AIPIGFLEEENEMY
        state pigfleeenemystate
    else
      ifai AIPIGDIVING
        state pigdivestate
    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 ABOSS1WALK        0  4  5  1  12
action ABOSS1FROZEN        30 1  5
action ABOSS1RUN         0  6  5  1  5
action ABOSS1SHOOT         30 2  5  1  4
action ABOSS1LOB         40 2  5  1  35
action ABOSS1DYING        50 5  1  1  35
action BOSS1FLINTCH       50 1  1  1  1
action ABOSS1DEAD         55

move PALBOSS1SHRUNKRUNVELS 32
move PALBOSS1RUNVELS 128
move BOSS1WALKVELS 208
move BOSS1RUNVELS 296
move BOSS1STOPPED

ai AIBOSS1SEEKENEMY ABOSS1WALK BOSS1WALKVELS seekplayer
ai AIBOSS1RUNENEMY ABOSS1RUN BOSS1RUNVELS faceplayer
ai AIBOSS1SHOOTENEMY ABOSS1SHOOT BOSS1STOPPED faceplayer
ai AIBOSS1LOBBED ABOSS1LOB BOSS1STOPPED faceplayer // faceplayersmart
ai AIBOSS1DYING ABOSS1DYING BOSS1STOPPED faceplayer
ai AIBOSS1PALSHRINK ABOSS1WALK PALBOSS1SHRUNKRUNVELS furthestdir

state boss1palshrunkstate
  ifcount SHRUNKDONECOUNT
    ai AITROOPSEEKENEMY
  else
    ifcount SHRUNKCOUNT
      sizeto 40 40
  else
    state genericshrunkcode
ends

state checkboss1seekstate
  ai AIBOSS1SEEKENEMY
  ifspritepal 0 nullop
    else   // a fake way of doing a ifspritepal NOT.
      move PALBOSS1RUNVELS seekplayer
ends

state boss1runenemystate
  ifpdistl 2048
  {
    ifp palive
      ai AIBOSS1SHOOTENEMY
    break
  }
  else
    ifcansee
  {
    ifactioncount 6
    {
      ifcanshoottarget
      {
        resetactioncount
        sound BOS1_WALK
      }
      else
        ai AIBOSS1SEEKENEMY
    }
  }
  else
    ai AIBOSS1SEEKENEMY
ends

state boss1seekenemystate
  ifrnd 2
    soundonce BOS1_ROAM
  else
    ifactioncount 6
  {
    resetactioncount
    sound BOS1_WALK
  }

  ifpdistl 2548
    ifp palive
  {
    ai AIBOSS1SHOOTENEMY
    break
  }

  ifcansee
    ifcount 32
  {
    ifrnd 32
    {
      ifp palive
        ifcanshoottarget
          ai AIBOSS1SHOOTENEMY
    }
    else
      ifpdistg 2548
        ifrnd 192
          ifcanshoottarget
    {
      ifrnd 64
      {
        ai AIBOSS1RUNENEMY
        ifspritepal 0 nullop
        else
          move PALBOSS1RUNVELS seekplayer
      }
      else
        ai AIBOSS1LOBBED
    }
  }

ends

state boss1dyingstate
  ifaction ABOSS1DEAD
  {
    ifspritepal 0
      break
    ifrespawn
      ifcount RESPAWNACTORTIME
    {
      spawn TRANSPORTERSTAR
      cstat 257
      strength PIGCOPSTRENGTH
      state checkboss1seekstate
    }
    else
    {
      strength 0
      ifhitweapon
        ifwasweapon RADIUSEXPLOSION
      {
        sound SQUISHED
        state standard_jibs
        killit
      }
      break
    }
  }
  ifactioncount 5
  {
    iffloordistl 8
      sound THUD
    action ABOSS1DEAD
    cstat 0
    ifspritepal 0
    endofgame 52
  }
ends

state boss1lobbedstate
  ifcansee
  {
    ifactioncount 2
    {
      resetactioncount
      sound BOS1_ATTACK2
      shoot MORTER
    }
    else
      ifcount 64
        ifrnd 16
          state checkboss1seekstate
  }
  else
    state checkboss1seekstate
ends

state boss1shootenemy
  ifcount 72
    state checkboss1seekstate
  else
    ifaction ABOSS1SHOOT
      ifactioncount 2
  {
    sound BOS1_ATTACK1
    shoot SHOTSPARK1
    shoot SHOTSPARK1
    shoot SHOTSPARK1
    shoot SHOTSPARK1
    shoot SHOTSPARK1
    shoot SHOTSPARK1
    resetactioncount
  }
ends

state checkboss1hitstate
  ifrnd 2
    spawn BLOODPOOL
  ifdead
  {
    ifspritepal 0
      globalsound DUKE_TALKTOBOSSFALL
    else
    {
      ifrnd 64
        globalsound DUKE_TALKTOBOSSFALL
      ifwasweapon FREEZEBLAST
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action ABOSS1FROZEN
        strength 0
        break
      }
    }

    sound BOS1_DYING

    addkills 1
    ai AIBOSS1DYING
  }
  else
  {
    ifrnd 32
    {
      action BOSS1FLINTCH
      move 0
    }

    ifspritepal 0 nullop
    else
      ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AIBOSS1PALSHRINK
      cstat 0
      break
    }

    soundonce BOS1_PAIN

    debris SCRAP1 1
    guts JIBS6 1
  }
ends

state boss1code

  ifaction ABOSS1FROZEN
  {
    ifcount THAWTIME
    {
      ai AIBOSS1SEEKENEMY
      spritepal 21
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1
      lotsofglass 30

      ifrnd 84
        spawn BLOODPOOL
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  ifai 0
  {
    ifspritepal 0
      ai AIBOSS1RUNENEMY
    else
    {
      strength BOSS1PALSTRENGTH
      ai AIBOSS1SHOOTENEMY
    }
  }
  else
    ifaction BOSS1FLINTCH
  {
    ifactioncount 3
    ai AIBOSS1SHOOTENEMY
  }
  else
    ifai AIBOSS1SEEKENEMY
      state boss1seekenemystate
  else
    ifai AIBOSS1RUNENEMY
      state boss1runenemystate
  else
    ifai AIBOSS1SHOOTENEMY
      state boss1shootenemy
  else
    ifai AIBOSS1LOBBED
      state boss1lobbedstate
  else
    ifai AIBOSS1PALSHRINK
      state boss1palshrunkstate

  ifai AIBOSS1DYING
    state boss1dyingstate
  else
  {
    ifhitweapon
      state checkboss1hitstate
    else
      ifp palive
        ifspritepal 0
          ifpdistl 1280
    {
      addphealth -1000
      palfrom 63 63
    }
  }
ends

actor BOSS1STAYPUT BOSS1STRENGTH cactor BOSS1 enda
actor BOSS1 BOSS1STRENGTH 
fall 
ifstrength 1
{ }
else
{
spawn 3908
} 
state boss1code 
enda


action ABOSS2WALK        0  4  5  1  30
action ABOSS2FROZEN        0  1  5
action ABOSS2RUN         0  4  5  1  15
action ABOSS2SHOOT         20 2  5  1  15
action ABOSS2LOB         30 2  5  1  105
action ABOSS2DYING        40 8  1  1  35
action BOSS2FLINTCH       40 1  1  1  1
action ABOSS2DEAD         48

move PALBOSS2SHRUNKRUNVELS 32
move PALBOSS2RUNVELS 84
move BOSS2WALKVELS 192
move BOSS2RUNVELS 256
move BOSS2STOPPED

ai AIBOSS2SEEKENEMY ABOSS2WALK BOSS2WALKVELS seekplayer
ai AIBOSS2RUNENEMY ABOSS2RUN BOSS2RUNVELS faceplayer
ai AIBOSS2SHOOTENEMY ABOSS2SHOOT BOSS2STOPPED faceplayer
ai AIBOSS2LOBBED ABOSS2LOB BOSS2STOPPED faceplayer
ai AIBOSS2DYING ABOSS2DYING BOSS2STOPPED faceplayer
ai AIBOSS2PALSHRINK ABOSS2WALK PALBOSS2SHRUNKRUNVELS furthestdir

state boss2palshrunkstate
  ifcount SHRUNKDONECOUNT
  {
    cstat 257
    ai AITROOPSEEKENEMY
  }
  else
    ifcount SHRUNKCOUNT
      sizeto 40 40
  else
    state genericshrunkcode
ends

state checkboss2seekstate
  ai AIBOSS2SEEKENEMY
  ifspritepal 0 nullop
  else   // a fake way of doing a ifspritepal NOT.
    move PALBOSS2RUNVELS seekplayer
ends

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

state boss2seekenemystate
  ifrnd 2
    soundonce BOS2_ROAM
  else
    ifactioncount 3
  {
    resetactioncount
    sound BOS1_WALK
  }

  ifcansee
    ifcount 32
      ifp palive
        ifrnd 48
          ifcanshoottarget
  {
    ifrnd 64
      ifpdistg 4096
    {
      ai AIBOSS2RUNENEMY
      ifspritepal 0 nullop
      else
        move PALBOSS2RUNVELS seekplayer
      break
    }

    ifpdistl 10240
    {
      ifrnd 128
      {
        sound BOS2_ATTACK
        ai AIBOSS2LOBBED
      }
    }
    else
    {
      sound BOS2_ATTACK
      ai AIBOSS2SHOOTENEMY
    }
  }
ends

state boss2dyingstate
  ifaction ABOSS2DEAD
  {
    ifspritepal 0
      break
    ifrespawn
      ifcount RESPAWNACTORTIME
    {
      spawn TRANSPORTERSTAR
      cstat 257
      strength PIGCOPSTRENGTH
      state checkboss2seekstate
    }
    else
    {
      strength 0
      ifhitweapon
        ifwasweapon RADIUSEXPLOSION
      {
        sound SQUISHED
        state standard_jibs
        killit
      }
      break
    }
  }
  ifactioncount 8
  {
    iffloordistl 8
      sound THUD
    action ABOSS2DEAD
    cstat 0
    ifspritepal 0
      endofgame 52
  }
ends

state boss2lobbedstate
  ifcansee
  {
    ifactioncount 2
      resetactioncount
    else
      ifactioncount 1
    {
      ifrnd 128
        shoot COOLEXPLOSION1
    }
    else
      ifcount 64
        ifrnd 16
          state checkboss2seekstate
  }
  else
    state checkboss2seekstate
ends

state boss2shootenemy
  ifcount 72
    state checkboss2seekstate
  else
    ifaction ABOSS2SHOOT
      ifactioncount 2
  {
    shoot RPG
    resetactioncount
  }
ends

state checkboss2hitstate
  ifrnd 2
    spawn BLOODPOOL
  ifdead
  {
    ifspritepal 0
      globalsound DUKE_TALKTOBOSSFALL
    else
    {
      ifrnd 64
        globalsound DUKE_TALKTOBOSSFALL
      ifwasweapon FREEZEBLAST
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action ABOSS2FROZEN
        strength 0
        break
      }
    }

    sound BOS2_DYING

    addkills 1

    ai AIBOSS2DYING
  }
  else
  {
    ifrnd 144
    {
      ifrnd 32
      {
        action BOSS2FLINTCH
        move 0
      }
      else
      {
        sound BOS2_ATTACK
        ai AIBOSS2SHOOTENEMY
      }
    }

    ifspritepal 0 nullop
    else
      ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AIBOSS2PALSHRINK
      break
    }

    soundonce BOS2_PAIN

    debris SCRAP1 1
    guts JIBS6 1
  }
ends

state boss2code

  ifaction ABOSS2FROZEN
  {
    ifcount THAWTIME
    {
      ai AIBOSS2SEEKENEMY
        spritepal 21
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1

      lotsofglass 30
      sound GLASS_BREAKING
      ifrnd 84 spawn BLOODPOOL
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  ifai 0
  {
    ifspritepal 0
      ai AIBOSS2RUNENEMY
    else
    {
      strength 1
      sound BOS2_ATTACK ai AIBOSS2SHOOTENEMY
    }
  }
  else
    ifaction BOSS2FLINTCH
  {
    ifactioncount 3
      ai AIBOSS2SEEKENEMY
  }
  else
    ifai AIBOSS2SEEKENEMY
      state boss2seekenemystate
  else
    ifai AIBOSS2RUNENEMY
      state boss2runenemystate
  else
    ifai AIBOSS2SHOOTENEMY
      state boss2shootenemy
  else
    ifai AIBOSS2LOBBED
      state boss2lobbedstate
  else
    ifai AIBOSS2PALSHRINK
      state boss2palshrunkstate

  ifai AIBOSS2DYING
    state boss2dyingstate
  else
  {
    ifhitweapon state checkboss2hitstate
    else
      ifp palive
        ifspritepal 0 ifpdistl
          1280
    {
      addphealth -1000
      palfrom 63 63
    }
  }


ends

actor BOSS2 BOSS2STRENGTH fall state boss2code enda

action ABOSS3WALK        0  4  5  1  30
action ABOSS3FROZEN        0  1  5
action ABOSS3RUN         0  4  5  1  15
action ABOSS3LOB        20 4  5  1  50
action ABOSS3LOBBING      30 2  5  1  15
action ABOSS3DYING        40 8  1  1  20
action BOSS3FLINTCH       40 1  1  1  1
action ABOSS3DEAD         48

move PALBOSS3SHRUNKRUNVELS 32
move PALBOSS3RUNVELS 84
move BOSS3WALKVELS 208
move BOSS3RUNVELS 270
move BOSS3STOPPED

ai AIBOSS3SEEKENEMY ABOSS3WALK BOSS3WALKVELS seekplayer
ai AIBOSS3RUNENEMY ABOSS3RUN BOSS3RUNVELS faceplayerslow
ai AIBOSS3LOBENEMY ABOSS3LOB BOSS3STOPPED faceplayer
ai AIBOSS3DYING ABOSS3DYING BOSS3STOPPED faceplayer
ai AIBOSS3PALSHRINK ABOSS3WALK PALBOSS3SHRUNKRUNVELS faceplayer

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

state checkboss3seekstate
  ai AIBOSS3SEEKENEMY
  ifspritepal 0 nullop
  else   // a fake way of doing a ifspritepal NOT.
    move PALBOSS3RUNVELS seekplayer
ends

state boss3runenemystate
  ifcansee
  {
    ifactioncount 3
    {
      ifcanshoottarget
      {
        resetactioncount
        sound BOS1_WALK
      }
      else
        ai AIBOSS3SEEKENEMY
    }
  }
  else
    ai AIBOSS3SEEKENEMY
ends

state boss3seekenemystate
  ifrnd 2
    soundonce BOS3_ROAM
  else
    ifactioncount 3
    {
      resetactioncount
      sound BOS1_WALK
    }

  ifcansee
    ifcount 32
      ifrnd 48
        ifcanshoottarget
  {
    ifrnd 64
      ifpdistg 4096
      {
        ai AIBOSS3RUNENEMY
        ifspritepal 0
          break
        move PALBOSS3RUNVELS seekplayer
        break
      }

    ifp palive
      ai AIBOSS3LOBENEMY
  }
ends

state boss3dyingstate
  ifaction ABOSS3DEAD
  {
    ifspritepal 0
      break
    ifrespawn
      ifcount RESPAWNACTORTIME
    {
      spawn TRANSPORTERSTAR
      cstat 257
      strength PIGCOPSTRENGTH
      state checkboss3seekstate
    }
    else
    {
      strength 0
      ifhitweapon
        ifwasweapon RADIUSEXPLOSION
      {
        sound SQUISHED
        state standard_jibs
        killit
      }
      break
    }
  }
  ifactioncount 8
  {
    iffloordistl 8
      sound THUD
    action ABOSS3DEAD
    cstat 0
    ifspritepal 0
    endofgame 52
  }
ends

state boss3lobbedstate
  ifcansee
  {
    ifaction ABOSS3LOBBING
      ifactioncount 2
    {
      shoot RPG
      resetactioncount
      ifrnd 8
        ai AIBOSS3SEEKENEMY
    }

    ifactioncount 3
    {
      action ABOSS3LOBBING
      resetcount
    }
  }
  else
    state checkboss3seekstate
ends

state checkboss3hitstate
  ifrnd 2
    spawn BLOODPOOL
  ifdead
  {
    ifspritepal 0
      globalsound DUKE_TALKTOBOSSFALL
    else
    {
      ifrnd 64
        globalsound DUKE_TALKTOBOSSFALL
      ifwasweapon FREEZEBLAST
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action ABOSS3FROZEN
        strength 0
        break
      }
    }

    addkills 1
    ai AIBOSS3DYING

    sound BOS3_DYING
    sound JIBBED_ACTOR9

  }
  else
  {
    ifrnd 32
    {
      action BOSS3FLINTCH
      move 0
    }

    ifspritepal 0 nullop
    else
      ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AIBOSS3PALSHRINK
      break
    }

    soundonce BOS3_PAIN

    debris SCRAP1 1
    guts JIBS6 1
  }
ends

state boss3code

  ifaction ABOSS3FROZEN
  {
    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }

      addkills 1
      lotsofglass 30

      ifrnd 84
        spawn BLOODPOOL
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  ifai 0
  {
    ifspritepal 0
      ai AIBOSS3RUNENEMY
    else
    {
      strength 1
      ai AIBOSS3LOBENEMY
    }
  }
  else
    ifaction BOSS3FLINTCH
    {
      ifactioncount 3
      ai AIBOSS3SEEKENEMY
    }
  else
    ifai AIBOSS3SEEKENEMY
      state boss3seekenemystate
  else
    ifai AIBOSS3RUNENEMY
      state boss3runenemystate
  else
    ifai AIBOSS3LOBENEMY
      state boss3lobbedstate
  else
    ifai AIBOSS3PALSHRINK
      state boss3palshrunkstate

  ifai AIBOSS3DYING
    state boss3dyingstate
  else
  {
    ifhitweapon
      state checkboss3hitstate
    else
      ifp palive
        ifspritepal 0
          ifpdistl 1280
      {
        addphealth -1000
        palfrom 63 63
      }
  }
ends

actor BOSS3 BOSS3STRENGTH fall state boss3code enda


action ACOMMBREETH  0  3  5  1  40
action ACOMMFROZEN  0  1  5
action ACOMMSPIN   -5  1  5  1  12
action ACOMMGET   0  3  5  1  30
action ACOMMSHOOT  20  1  5   1 35
action ACOMMABOUTTOSHOOT 20 1 5 1 30
action ACOMMDYING  30  8  1  1  12
action ACOMMDEAD   38  1  1  1  1


move COMMGETUPVELS 128 -64
move COMMGETVELS 128 64
move COMMSLOW 64 24
move COMMSTOPPED

ai AICOMMWAIT ACOMMBREETH COMMSTOPPED faceplayerslow
ai AICOMMGET ACOMMGET COMMGETVELS seekplayer
ai AICOMMSHOOT ACOMMSHOOT COMMSTOPPED faceplayerslow
ai AICOMMABOUTTOSHOOT ACOMMABOUTTOSHOOT COMMSTOPPED faceplayerslow
ai AICOMMSPIN ACOMMSPIN COMMGETVELS spin
ai AICOMMDYING ACOMMDYING COMMSTOPPED faceplayer
ai AICOMMSHRUNK ACOMMGET COMMSLOW furthestdir
ai AICOMMGROW ACOMMGET COMMSTOPPED furthestdir

state checkcommhitstate

  ifhitweapon
  {
    guts JIBS6 2

    ifdead
    {
      ifwasweapon FREEZEBLAST
      {
        sound SOMETHINGFROZE
        spritepal 1
        move 0
        action ACOMMFROZEN
        strength 0
        break
      }
      else
        ifwasweapon GROWSPARK
      {
        sound ACTOR_GROWING
        ai AICOMMGROW
        break
      }

      addkills 1

      ifwasweapon RADIUSEXPLOSION
      {
        spawn BLOODPOOL
        sound SQUISHED
        state standard_jibs
        killit
      }
      else
        ifwasweapon RPG
      {
        sound SQUISHED
        spawn BLOODPOOL
        state standard_jibs
        killit
      }

      sound COMM_DYING
      ai AICOMMDYING
    }
    else
    {
      soundonce COMM_PAIN
      ifwasweapon SHRINKSPARK
      {
        sound ACTOR_SHRINKING
        ai AICOMMSHRUNK
      }
      else
        ifwasweapon GROWSPARK
          sound EXPANDERHIT
      else
        ifrnd 24
          ai AICOMMABOUTTOSHOOT
    }
  }
ends

actor COMMANDERSTAYPUT COMMANDERSTRENGTH
  cactor COMMANDER
  ai AICOMMABOUTTOSHOOT
enda

actor COMMANDER COMMANDERSTRENGTH
spawn 9680 killit
  state checksquished

  ifaction ACOMMFROZEN
  {
    fall

    ifcount THAWTIME
    {
      getlastpal
      ai AICOMMWAIT
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1

      ifrnd 84
        spawn BLOODPOOL
      lotsofglass 30
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  ifai 0
    ai AICOMMSHOOT
  else
    ifai AICOMMWAIT
  {
    ifcount 20
    {
      ifcansee
      {
        ifcanshoottarget
        {
          ifrnd 96
            ai AICOMMGET
          else
            ai AICOMMABOUTTOSHOOT
        }
      }
      else
        ai AICOMMGET
    }
  }
  else
    ifai AICOMMABOUTTOSHOOT
  {
    ifactioncount 2
    {
      ifcansee
        ai AICOMMSHOOT
      else
      {
        ai AICOMMGET
        break
      }
    }
    ifrnd 32 soundonce COMM_ATTACK
  }
  else
    ifai AICOMMSHOOT
  {
    ifcanshoottarget
    {
      ifcount 24
        ifrnd 16
          ai AICOMMWAIT
      ifactioncount 2
      {
        shoot RPG
        resetactioncount
      }
    }
    else
      ai AICOMMGET
  }
  else
    ifai AICOMMSHRUNK
  {
    ifcount SHRUNKDONECOUNT
      ai AICOMMGET
    else
      ifcount SHRUNKCOUNT
        sizeto 48 40
    else
      state genericshrunkcode
  }
  else
    ifai AICOMMGROW
      state genericgrowcode
  else
    ifai AICOMMGET
  {
    ifnotmoving
      ifrnd 4
        operate
    ifpdistl 1024
      ifp palive
    {
      sound COMM_SPIN
      ai AICOMMSPIN
      break
    }

    ifcansee
    {
      ifp phigher
        move COMMGETUPVELS getv geth faceplayer
      else
        move COMMGETVELS getv geth faceplayer
    }
    ifactioncount 8
      ifrnd 2
        ai AICOMMABOUTTOSHOOT
  }
  else
    ifai AICOMMSPIN
  {
    soundonce COMM_SPIN
    ifcount 16
    {
      ifpdistl 1280
      {
        addphealth CAPTSPINNINGPLAYER
        sound DUKE_GRUNT
        palfrom 32
        16 resetcount
      }
      else
        ifpdistg 2300
          ai AICOMMWAIT
    }
    ifactioncount 52
      ai AICOMMWAIT
    ifnotmoving
      ifrnd 32
        operate
  }

  ifai AICOMMDYING
  {
    fall
    strength 0

    ifhitweapon
      ifwasweapon RADIUSEXPLOSION
    {
      sound SQUISHED
      spawn BLOODPOOL
      state standard_jibs
      killit
    }

    ifaction ACOMMDYING
      ifactioncount 8
    {
      iffloordistl 8
        sound THUD
      cstat 0
      action ACOMMDEAD
    }
  }
  else
  {
    ifrnd 2
      soundonce COMM_ROAM
    state checkcommhitstate
  }
enda


// CANNONBALL for Pirates of the Carribean
define CANNONBALLSTRENGTH 400
move CANNONBALL1 512 0
move CANNONBALL2 512 10
move CANNONBALL3 512 20
move CANNONBALL4 512 40
move CANNONBALL5 512 80

useractor notenemy CANNONBALL CANNONBALLSTRENGTH

  ifaction 0
  {
    sizeat 32 32
    cstat 257         // Force actor to block
    action ANULLACTION
  }

    ifactioncount 46
    {
      ifactioncount 47 nullop
      else
        move CANNONBALL5 geth getv
    }
    else
      ifactioncount 44
    {
      ifactioncount 45 nullop
      else
        move CANNONBALL4 geth getv
    }
    else
      ifactioncount 40
    {
      ifactioncount 41 nullop
      else
        move CANNONBALL3 geth getv
    }
    else
      ifactioncount 32
    {
      ifactioncount 33 nullop
      else
        move CANNONBALL2 geth getv
    }
    else
      ifactioncount 16
    {
      ifactioncount 17 nullop
      else move CANNONBALL1 geth getv
    }

  ifnotmoving
  {
    spawn EXPLOSION2
    sound PIPEBOMB_EXPLODE
    hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
    killit
  }

  ifhitweapon
  {
    ifdead
    {
      spawn EXPLOSION2
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      killit
    }
    else
      debris SCRAP1 3
  }

enda


define CANNONBALLS 1818
define CANNONBALLSSTRENGTH 10
move CANNONBALLSVEL

useractor notenemy CANNONBALLS CANNONBALLSSTRENGTH
  ifaction 0
  {
    cstator 257
    action ANULLACTION
  }
  ifhitweapon
  {
    ifdead
    {
      spawn EXPLOSION2
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      killit
    }
    else
      debris SCRAP1 3
  }
enda


define CANNON 1810
define CANNONSTRENGTH 400
action ACANNONWAIT 0 1 7 1 1
action ACANNONSHOOTING 0 1 7 1 1
move CANNONSTOP

useractor enemy CANNON CANNONSTRENGTH // fall

  ifaction 0
  {
//    sizeat 64 64
    action ACANNONWAIT
  }
  else
    ifaction ACANNONSHOOTING
  {
    spawn CANNONBALL
    action ACANNONWAIT
  }
  else
    ifaction ACANNONWAIT
  {
    ifactioncount 64
    {
      ifrnd 128
        action ACANNONSHOOTING
      else
        resetactioncount
    }
  }

  ifhitweapon
  {
    ifdead
    {
      addkills 1
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      spawn EXPLOSION2
      killit
    }
    else debris SCRAP1 3
  }

  ifpdistl 1024
    ifhitspace
  {
    ifp pfacing
      ifcanshoottarget
        spawn CANNONBALL
      else break
  }
enda

useractor notenemy HOTMEAT TOUGH
  ifaction 0
  {
    action ANULLACTION
    cstat 257
  }
  ifhitweapon
  {
    ifdead
    {
      sound SQUISHED
      guts JIBS5 8
      guts JIBS6 9
      killit
    }
    else
      guts JIBS6 1
  }
  ifrnd 1
    spawn WATERDRIP

enda

action ASPEAKERBROKE 1
useractor notenemy SPEAKER
  ifaction 0
  {
    ifhitweapon
    {
      stopsound STORE_MUSIC
      soundonce STORE_MUSIC_BROKE
      action ASPEAKERBROKE
    }
    else
    {
      ifpdistl 10240
          soundonce STORE_MUSIC
      cstat 289
    }
  }
enda

action ALAVABUBBLE
action ALAVABUBBLEANIM 0 5 1 1 16

useractor notenemy LAVABUBBLE
  ifaction 0
  {
    cstat 32768
    action ALAVABUBBLE
  }
  else
    ifaction ALAVABUBBLE
  {
    ifcount 72
      ifrnd 2
    {
      cstat 0
      action ALAVABUBBLEANIM
    }
  }
  else
  {
    ifactioncount 5
    {
      cstat 32768
      action ALAVABUBBLE
    }
  }
enda

// RIOT TANK with Pigcop inside

define TANKSTRENGTH       500      // 2 3 4 5 7 8
//           off-set, numofframes, numofrot, skipframes, delay
action ATANKSPIN   0 1 7 1 4
action ATANKSHOOTING 7 2 7 1 10
action ATANKWAIT 0 1 7 1 1
action ATANKDESTRUCT 0 1 7 1 1
action ATANKDEAD 0 1 7 1 1
// move TANKVEL horiz vert
move TANKFORWARD 100
move TANKSTOP

useractor enemy TANK TANKSTRENGTH fall

  ifaction 0
  {
    sizeat 60 60
    action ATANKWAIT
    cstat 257
    clipdist 100
  }
  else
    ifaction ATANKSPIN
  {
    soundonce TANK_ROAM

    ifactioncount 20
    {
      ifrnd 16
        ifcansee
          ifcanshoottarget
      {
        move TANKSTOP geth
        action ATANKSHOOTING
        stopsound TANK_ROAM
      }
    }

    ifrnd 16
      move TANKFORWARD seekplayer
  }
  else
    ifaction ATANKSHOOTING
  {
    ifactioncount 22
    {
      ifpdistg 8192
      {
        sound BOS1_ATTACK2
        shoot MORTER
      }
      resetcount
      move 0 action ATANKWAIT
    }
    else
      ifactioncount 2
    {
      ifcansee
      {
        ifpdistl 16384
        {
          ifrnd 128
          {
            sound PISTOL_FIRE
            shoot SHOTSPARK1
          }
        }
        else
          ifrnd 128
        {
          sound PRED_ATTACK
          shoot FIRELASER
        }
      }
      else
      {
        move TANKFORWARD seekplayer
        action ATANKSPIN
      }
    }

    ifrnd 16
    {
      stopsound TANK_ROAM
      move TANKSTOP faceplayerslow
    }
  }
  else
    ifaction ATANKWAIT
  {
    ifactioncount 32
    {
      move TANKFORWARD seekplayer
      action ATANKSPIN
    }
  }
  else
    ifaction ATANKDESTRUCT
  {
    ifactioncount 64
      action ATANKDEAD
    else
      ifactioncount 56
       sound LASERTRIP_ARMING
     else
       ifactioncount 48
         sound LASERTRIP_ARMING
     else
       ifactioncount 32
         sound LASERTRIP_ARMING
     else
       ifactioncount 16
         sound LASERTRIP_ARMING
     break
  }
  else
    ifaction ATANKDEAD
  {
    addkills 1
    hitradius 6144 TOUGH TOUGH TOUGH TOUGH
    sound LASERTRIP_EXPLODE
    debris SCRAP1 15
    spawn EXPLOSION2
    ifrnd 128 spawn PIGCOP
    killit
  }

  ifhitweapon
  {
    ifdead
      action ATANKDEAD
    else
    {
      debris SCRAP1 1
      ifaction ATANKSHOOTING break

      ifrnd 192
      {
        move TANKSTOP geth
        action ATANKSHOOTING
        stopsound TANK_ROAM
      }
    }
  }

  ifpdistl 1280
    ifhitspace
      ifp pfacing
        ifangdiffl 512
          action ATANKDESTRUCT
enda







action ABOSS4WALK          0 4  5  1  30
action ABOSS4DYING        40 9  1  1  20
action ABOSS4ABOUTTOSHOOT 20 1  5  1  40
action ABOSS4SHOOT        25 2  5  1  10
action ABOSS4LAYIT        50 3  5  1  120
action BOSS4FLINTCH       40 1  1  1  1
action ABOSS4DEAD         49

move BOSS4WALKVELS 128
move BOSS4STOPPED

ai AIBOSS4LAYEGGS ABOSS4WALK BOSS4WALKVELS randomangle geth
ai AIBOSS4SHOOT ABOSS4ABOUTTOSHOOT BOSS4STOPPED faceplayer
ai AIBOSS4DYING ABOSS4DYING BOSS4STOPPED faceplayer

state boss4shootstate
  ifaction ABOSS4ABOUTTOSHOOT
    ifactioncount 3
      action ABOSS4SHOOT

  ifaction ABOSS4SHOOT
  {
    ifcount 48
    {
      ifrnd 4
        ai AIBOSS4LAYEGGS
    }
    ifcount 26
      ifrnd 32
    {
      ifrnd 128
      {
        sound SHORT_CIRCUIT
        addphealth -2
      }
      else
      {
        sound DUKE_GRUNT
        addphealth -1
      }
      palfrom 32 32 0 0
    }
  }

ends

state boss4layeggs
  ifrnd 2
    sound BOS4_ROAM

  ifaction ABOSS4LAYIT
  {
    ifactioncount 3
      ifcount 32
    {
      ai AIBOSS4LAYEGGS
      ifrnd 32
        move BOSS4WALKVELS furthestdir geth
      spawn NEWBEASTHANG
    }
  }
  else
    ifcount 64
      ifrnd 4
  {
    move 0

    ifrnd 88
    {
      action ABOSS4LAYIT
      sound BOS4_LAY
    }
    else
      ifp palive
        ifcansee
    {
      ai AIBOSS4SHOOT
      sound BOS4_ATTACK
    }
  }

ends

state boss4dyingstate
  ifaction ABOSS4DEAD
    break
  else
    ifactioncount 9
  {
    iffloordistl 8
      sound THUD

    endofgame 52
    action ABOSS4DEAD
    cstat 0
  }
ends

state checkboss4hitstate
  ifrnd 2
    spawn BLOODPOOL

  ifdead
  {
    globalsound DUKE_TALKTOBOSSFALL

    addkills 1
    ai AIBOSS4DYING

    sound BOS4_DYING
    sound BOSS4_DEADSPEECH
  }
  else
  {
    soundonce BOS4_PAIN
    debris SCRAP1 1
    guts JIBS6 1

    ifaction ABOSS4LAYIT
      break

    ifrnd 16
    {
      action BOSS4FLINTCH
      move 0
    }
  }
ends

state boss4code

  ifai 0
    ai AIBOSS4LAYEGGS
  else
    ifaction BOSS4FLINTCH
    {
      ifactioncount 3
        ai AIBOSS4LAYEGGS
    }
  else
    ifai AIBOSS4LAYEGGS
      state boss4layeggs
  else
    ifai AIBOSS4SHOOT
      state boss4shootstate

  ifai AIBOSS4DYING
    state boss4dyingstate
  else
  {
    ifhitweapon
      state checkboss4hitstate
    else
      ifp palive
        ifpdistl 1280
      {
        addphealth -1000
        palfrom 63 63
      }
  }
ends

actor BOSS4STAYPUT BOSS4STRENGTH

  fall
  cactor BOSS4
  spritepal 6
  state boss4code
  getlastpal

enda

actor BOSS4 BOSS4STRENGTH

  fall
  cactor BOSS4
  spritepal 6
  state boss4code
  getlastpal

enda

action ANEWBEASTSTAND     0
action ANEWBEASTWALKING   10  4  5  1  12
action ANEWBEASTRUNNING   10  4  5  1  8
action ANEWBEASTTHINK     0   2  5  1  40
action ANEWBEASTSCRATCHING  30  3  5  1  20
action ANEWBEASTDYING     72  8  1  1  15
action ANEWBEASTFLINTCH   71  1  1  1  1
action ANEWBEASTLYINGDEAD 79  1  1
action ANEWBEASTSCREAM    50  2  5  1  40
action ANEWBEASTJUMP      80  2  5  1  50
action ANEWBEASTFALL      90  1  5
action ANEWBEASTFROZEN    10  1  5

action ANEWBEASTHANG      0  1  5
useractor enemy NEWBEASTHANG NEWBEASTSTRENGTH
ifspritepal 6 { sizeat 128 128 strength 20000 }
  ifaction 0
  {
    action ANEWBEASTHANG
    cstator 257
ifspritepal 6 { sizeat 128 128 strength 20000 }
   
  }
  else
    ifhitweapon
  {
    cactor NEWBEAST
    action ANEWBEASTSTAND
    sound NEWBEAST_PAIN
  }
  else
    ifspawnedby BOSS4
      ifcount 200
        ifrnd 1
  {
    cactor NEWBEAST
    action ANEWBEASTSTAND
    sound NEWBEAST_PAIN
  }
enda

action ANEWBEASTHANGDEAD      -1  1  5
useractor enemy NEWBEASTHANGDEAD TOUGH

  ifaction 0
  {
    action ANEWBEASTHANGDEAD
    sizeat 40 40
    cstator 257
  }
  else
    ifhitweapon
  {
    ifdead
    {
      state standard_jibs
      spawn BLOODPOOL
      sound SQUISHED
      killit
    }
    else
    {
      guts JIBS6 1
      sound SQUISHED
    }
  }
enda

move NEWBEASTWALKVEL 182
move NEWBEASTRUNVEL 256
move NEWBEASTJUMPVEL 264
move NEWBEASTSTOP

ai AINEWBEASTGETENEMY ANEWBEASTWALKING NEWBEASTWALKVEL seekplayer
ai AINEWBEASTDODGE ANEWBEASTRUNNING NEWBEASTRUNVEL dodgebullet
ai AINEWBEASTCHARGEENEMY ANEWBEASTRUNNING NEWBEASTRUNVEL seekplayer
ai AINEWBEASTFLEENEMY ANEWBEASTWALKING NEWBEASTWALKVEL fleeenemy
ai AINEWBEASTSCRATCHENEMY ANEWBEASTSCRATCHING NEWBEASTSTOP faceplayerslow
ai AINEWBEASTJUMPENEMY ANEWBEASTJUMP NEWBEASTJUMPVEL jumptoplayer
ai AINEWBEASTTHINK ANEWBEASTTHINK NEWBEASTSTOP
// ai AINEWBEASTSHRUNK ANEWBEASTWALKING SHRUNKVELS fleeenemy
ai AINEWBEASTGROW ANEWBEASTSTAND  NEWBEASTSTOP faceplayerslow
ai AINEWBEASTDYING ANEWBEASTDYING NEWBEASTSTOP faceplayer
ai AINEWBEASTSHOOT ANEWBEASTSCREAM NEWBEASTSTOP faceplayerslow
ai AINEWBEASTFLINTCH ANEWBEASTFLINTCH NEWBEASTSTOP faceplayerslow


state newbeastseekstate

  ifactornotstayput
  {
    ifp palive
      ifcansee
        ifpdistl 1596
    {
      ai AINEWBEASTSCRATCHENEMY
      break
    }

    ifai AINEWBEASTCHARGEENEMY
    {
      ifp palive
        ifpdistl 1596
          ifcansee
      {
        ai AINEWBEASTSCRATCHENEMY
        break
      }

      ifrnd 1
        ifpdistg 4096
          ifp palive
            ifcansee
      {
        ai AINEWBEASTSHOOT
        break
      }
    }
    else
      ifpdistg 4096
    {
      ai AINEWBEASTCHARGEENEMY
      break
    }

    iffloordistl 16
    {
      ifcount 32
        ifrnd 16
      {
        ifceilingdistl 96 break
        ai AINEWBEASTJUMPENEMY
      }
      break
    }

    ifrnd 4
    {
      ifnotmoving
        operate
    }
    else
      ifrnd 16
        ifbulletnear
    {
      ifgapzl 128
        ai AINEWBEASTDODGE
      else
        ifactornotstayput
      {
        ifrnd 128
        {
          ifceilingdistl 96 break
          ai AINEWBEASTJUMPENEMY
        }
        else
          ai AINEWBEASTDODGE
      }
    }
  }
  else
  {
    ifactioncount 16
    {
      ifp palive
        ifpdistl 1596
          ifcansee
      {
        ai AINEWBEASTSCRATCHENEMY
        break
      }
    }
    ifcount 16
      ifrnd 32
        move NEWBEASTWALKVEL randomangle geth
  }

ends

/*
state newbeastshrunkstate
  ifcount SHRUNKDONECOUNT
    ai AINEWBEASTGETENEMY
  else
    ifcount SHRUNKCOUNT
      sizeto 48 40
  else
    state genericshrunkcode
ends
*/

state newbeastfleestate
  ifcount 8
  {
    ifrnd 64
      ifpdistg 3500
        ifp palive
          ifcansee
            ai AINEWBEASTSHOOT
  }
  else
  {
    iffloordistl 16
    {
      ifnotmoving
        ai AINEWBEASTGETENEMY
    }
    else
      ai AINEWBEASTGETENEMY
    break
  }
ends

state newbeastthinkstate

  ifrnd 8
    soundonce NEWBEAST_ROAM

  ifactioncount 3
  {
    ifrnd 128
    {
      ifpdistg 3500
        ifp palive
          ifcansee
            ai AINEWBEASTSHOOT
    }
    else
      ai AINEWBEASTGETENEMY
  }

  ifrnd 16
    ifbulletnear
  {
    ifgapzl 96
      ai AINEWBEASTDODGE
    else
    {
      ifrnd 128
      {
        ifceilingdistl 144 break
        ai AINEWBEASTJUMPENEMY
      }
      else
        ai AINEWBEASTDODGE
    }
  }
ends

state newbeastscratchstate
  ifcount 20
    ifrnd 8
  {
    ifcansee
      ifpdistl 2048
    {
      ifrnd 128
        ai AINEWBEASTFLEENEMY
      break
    }
    ifrnd 80
      ai AINEWBEASTTHINK
    else
      ai AINEWBEASTGETENEMY
  }

  ifactioncount 3
  {
    ifpdistg 1596
      ai AINEWBEASTTHINK
    else ifp palive ifcansee
    {
      palfrom 16 16
      addphealth NEWBEASTSCRATCHAMOUNT
      sound DUKE_GRUNT
      resetactioncount
      resetcount
    }
  }
  else
    ifcount 15
      nullop
  else
    ifcount 14
  {
    ifpdistl 1596
      soundonce NEWBEAST_ATTACK
    else
      soundonce NEWBEAST_ATTACKMISS
  }
ends

state checknewbeasthit
  spawn BLOOD
/*
  ifai AINEWBEASTSHRUNK
  {
    addkills 1
    sound SQUISHED
    state standard_jibs
    killit
  }
*/
  ifdead
  {
    ifwasweapon FREEZEBLAST
    {
      sound SOMETHINGFROZE
      spritepal 1
      move 0
      action ANEWBEASTFROZEN
      strength 0
      break
    }

    ifwasweapon GROWSPARK
    {
      cstat 0
      sound ACTOR_GROWING
      ai AINEWBEASTGROW
      break
    }

    addkills 1

    ifwasweapon RPG
    {
      sound SQUISHED
      state liz_body_jibs
      state standard_jibs
      killit
    }
    else
      ifwasweapon RADIUSEXPLOSION
    {
      sound SQUISHED
      state liz_body_jibs
      state standard_jibs
      killit
    }
    else
    {
      state rf
      ai AINEWBEASTDYING
      ifrnd 64
        spawn BLOODPOOL
    }
    sound NEWBEAST_DYING
  }
  else
  {
    sound NEWBEAST_PAIN
    ifwasweapon GROWSPARK
      sound EXPANDERHIT
/*
//  The alien is immune to the shrinker
    ifwasweapon SHRINKSPARK
    {
      sound ACTOR_SHRINKING
      ai AINEWBEASTSHRUNK
      break
    }
*/
    state random_wall_jibs
    ifrnd 32
      ai AINEWBEASTFLINTCH
    else
      ifrnd 32
        ifpdistg 3500
          ifp palive
            ifcansee
              ai AINEWBEASTSHOOT
  }
ends

state newbeastjumpstate
  ifaction ANEWBEASTFALL
  {
    iffloordistl 16
      ai AINEWBEASTGETENEMY
  }
  else
    ifcount 32
      action ANEWBEASTFALL
ends

state newbeastdyingstate
  ifaction ANEWBEASTLYINGDEAD
  {
    strength 0
    ifhitweapon
      ifwasweapon RADIUSEXPLOSION
    {
      sound SQUISHED
      state standard_jibs
      killit
    }
    ifcount RESPAWNACTORTIME
      ifrespawn
    {
      spawn TRANSPORTERSTAR
      cstat 257
      strength NEWBEASTSTRENGTH
      ai AINEWBEASTGETENEMY
    }
  }
  else
    ifai AINEWBEASTDYING
      ifactioncount 7
  {
    iffloordistl 8
      sound THUD
    move NEWBEASTSTOP
    action ANEWBEASTLYINGDEAD
  }
ends

state newbeastdodgestate
  ifcount 13
    ai AINEWBEASTGETENEMY
ends

useractor enemystayput NEWBEASTSTAYPUT NEWBEASTSTRENGTH ai AINEWBEASTGETENEMY cstator 257 cactor NEWBEAST enda
useractor enemy NEWBEASTJUMP NEWBEASTSTRENGTH ai AINEWBEASTJUMPENEMY cstator 257 cactor NEWBEAST enda

state newbeastcode
  state checksquished
  ifai 0
  {
    cstator 257
    ai AINEWBEASTGETENEMY
  }
  else
    ifaction ANEWBEASTLYINGDEAD
  {
    fall
    state newbeastdyingstate
    break
  }
  else
    ifaction ANEWBEASTFROZEN
  {
    ifcount THAWTIME
    {
      ai AINEWBEASTGETENEMY
      spritepal 0
    }
    else
      ifcount FROZENDRIPTIME
    {
      ifactioncount 26
      {
        spawn WATERDRIP
        resetactioncount
      }
    }

    ifhitweapon
    {
      ifwasweapon FREEZEBLAST
      {
        strength 0
        break
      }
      addkills 1

      ifrnd 84
        spawn BLOODPOOL
      lotsofglass 30
      sound GLASS_BREAKING
      killit
    }
    ifp pfacing
      ifpdistl FROZENQUICKKICKDIST
        pkick
    break
  }
  else
    ifai AINEWBEASTJUMPENEMY
      state newbeastjumpstate
  else
  {
    fall
    ifai AINEWBEASTGETENEMY
      state newbeastseekstate
    else
      ifai AINEWBEASTCHARGEENEMY
        state newbeastseekstate
    else
      ifai AINEWBEASTFLINTCH
    {
      ifcount 8
        ai AINEWBEASTGETENEMY
    }

    else
      ifai AINEWBEASTDODGE
        state newbeastdodgestate
    else
      ifai AINEWBEASTSCRATCHENEMY
        state newbeastscratchstate
    else
      ifai AINEWBEASTFLEENEMY
        state newbeastfleestate
    else
      ifai AINEWBEASTTHINK
        state newbeastthinkstate
/*
    else
      ifai AINEWBEASTSHRUNK
        state newbeastshrunkstate
*/
    else
      ifai AINEWBEASTGROW
        state genericgrowcode
    else
      ifai AINEWBEASTDYING
        state newbeastdyingstate
    else
      ifai AINEWBEASTSHOOT
    {
      ifp pshrunk
        ai AINEWBEASTGETENEMY
      else
        ifcount 26
          ai AINEWBEASTGETENEMY
      else
        ifcount 25
          shoot 3660
      else
      {
        ifcount 5
          nullop
        else
          ifcount 4
            sound NEWBEAST_SPIT
      }
    }
  }

  ifhitweapon
    state checknewbeasthit
ends


useractor enemy NEWBEAST NEWBEASTSTRENGTH
  fall
ifstrength 1
{ }
else
{
spawn 3908
}
  ifaction 0
  {
    cstator 257
    sizeat 40 40
    ai AINEWBEASTDODGE
  }
  ifaction ANEWBEASTFROZEN
    state newbeastcode
  else
  {
    spritepal 6
    state newbeastcode
    ifaction ANEWBEASTFROZEN
      break
    getlastpal
  }
enda

onevent EVENT_LOOKLEFT
setvar RETURN -1
endevent

onevent EVENT_DISPLAYREST

ifvare slowmotion 0
{

ifvare DNSUIT 1 {
getplayer[THISACTOR].shield_amount shield
minitext 270 170 136 0 0 
digitalnumber 5135 280 90 gran 0 0 0 0 0 xdim ydim
digitalnumber 2837 280 180 OX 0 0 0 0 0 xdim ydim
digitalnumber 5135 280 10 health 0 0 0 0 0 xdim ydim
digitalnumber 5135 260 30 shield 0 0 0 0 0 xdim ydim
ifvare curweap 1 { ifvare weapon_1 1 { setvarvar ammo mp5k_ammo } else ifvare weapon_1 0 { setvarvar ammo pistol_ammo } } else ifvare curweap 2 { setvarvar ammo shotgam } else ifvare curweap 3 { setvarvar ammo mammo } else getplayer[THISACTOR].ammo_amount currentweapon ammo  
digitalnumber 5135 240 50 ammo 0 0 0 0 0 xdim ydim
digitalnumber 5135 260 50 CURRENTGUNMAG 0 0 0 0 0 xdim ydim
rotatesprite 240 70 32768 0 3657 0 0 0 0 0 xdim ydim
digitalnumber 3010 260 70 medkit 0 0 0 0 0 xdim ydim

digitalnumber 2472 50 190 energy 0 0 0 0 0 xdim ydim
minitext 50 170 126 0 0
//rotatesprite 50 100 65536 0 100 0 0 0 0 0 xdim ydim

ifvare health 100 {
rotatesprite 200 20 16384 0 3658 0 1 0 0 0 xdim ydim
}
ifvarl health 100 {
rotatesprite 200 20 16384 0 3658 0 1 0 0 0 xdim ydim
}
ifvarl health 80 {
rotatesprite 200 20 16384 0 3658 0 0 0 0 0 xdim ydim
}
ifvarl health 50 {
rotatesprite 200 20 16384 0 3658 20 0 0 0 0 xdim ydim
}
ifvarl health 30 {
rotatesprite 200 20 16384 0 3659 0 21 0 0 0 xdim ydim
}
ifvare health 0 {
rotatesprite 200 20 16384 0 3658 0 4 0 0 0 xdim ydim
}
ifvarg health 100 {
rotatesprite 200 20 16384 0 3658 0 1 33 0 0 xdim ydim
}

}
}
ifvare Black_Screen 1 {
rotatesprite 160 100 65536 0 3588 0 0 0 0 0 xdim ydim
}
ifvare INTRO02 1 {
rotatesprite 160 100 65536 0 3589 introshade 0 0 0 0 xdim ydim
}
ifvare INTRO02 2 {
rotatesprite 160 100 65536 0 3589 0 0 33 0 0 xdim ydim
}
ifvare chapter1_2 1 {
rotatesprite 160 100 65536 0 8193 introshade 0 0 0 0 xdim ydim
}
ifvare other 947161
{
rotatesprite 160 100 65536 0 8147 0 0 0 0 0 xdim ydim
}
ifvare slowmotion 1
{
myospal 160 100 18 0 0 0
}

endevent

onevent EVENT_GETMENUTILE
setvar RETURN 3588
endevent

onevent EVENT_GETLOADTILE
setvar RETURN 3588
endevent

onevent EVENT_RESETWEAPONS
ifvare MULTIMODE 1 {
ifvare VOLUME 0 {
ifvare LEVEL 0 {
setplayer[THISACTOR].gotweapon 1 0
setplayer[THISACTOR].ammo_amount 1 0
setvar DNSUIT 0
setvar DEAGLEMAG 0
setvar pistol_ammo 0
setvar chain 0
setvar gran 0
}
}
}
ifvare VOLUME 1 {
setvar chain 0
setvar pistol_ammo 0
setvar DEAGLEMAG 0
setplayer[THISACTOR].gotweapon 1 0
setplayer[THISACTOR].ammo_amount 1 0
}
ifvare VOLUME 0 {
ifvare LEVEL 8 {
setvar chain 1 } }
setvar pal 0
setvar WEAPON1_SHOOTS SHOTSPARK1 
setplayer[THISACTOR].ammo_amount 1 2
setplayer[THISACTOR].ammo_amount 2 2
setplayer[THISACTOR].ammo_amount 3 2
setvar shotgam 0
setvar mammo 0
setvar reseti 0
setvar gran 3
setvar pistol_ammo 18
setvar weapon_1 0
setvar mp5k 0
setvar mmag 30
setvar slowmotion 0
setvar RIFLE12MAG 50
setvar mp5k_ammo 0
setvar MP5KMAG 30
setvar DEAGLEMAG 18
setvar energy 0
setvar WEAPON1_TOTALTIME 6
setvar WEAPON1_FLAGS 32768
setvar WEAPON1_RELOAD 71
setvar WEAPON1_SPAWN 2533
setvar WEAPON1_CLIP 0
setvar WEAPON3_SPAWN 2533
setvar WEAPON3_TOTALTIME 3
setvar WEAPON3_RELOAD 71
setvar WEAPON3_FIREDELAY 2
setvar WEAPON3_FLAGS 32768
setvar WEAPON3_CLIP 0
setvar WEAPON3_RELOADSOUND1 EJECT_CLIP
setvar WEAPON9_SHOOTS 3668 
setvar WEAPON9_TOTALTIME 7
setvar WEAPON4_TOTALTIME 8
setvar PIPEBOMB_CONTROL 2
setvar TRACK 0
setvar shootdyna 0
setvar WEAPON1_FIRESOUND PISTOL_FIRE
setvar medkitbegin 0
endevent

onevent EVENT_DISPLAYSBAR
ifvare DNSUIT 1 {
setvar RETURN -2 }
endevent 

action nul 0 1 1 1 2
action nl 0 1 1 1 2

eventloadactor 8455
{
getactor[THISACTOR].x xintro
getactor[THISACTOR].y yintro
getactor[THISACTOR].z zintro
}
enda

useractor notenemy 8455
cstator 32768
getactor[THISACTOR].x xintro
getactor[THISACTOR].y yintro
getactor[THISACTOR].z zintro
killit
enda

useractor notenemy 3590
cstator 32768
ifaction 0 { action nul }
ifaction nul {
setvar INTRO01 1 setvar Black_Screen 1 setvar INTRO02 1 setvar introme 1 action nl }
ifvare introme 1
{
subvar introshade 1
}
ifvare introshade -50
{
setvar introme 2
}
ifvare introme 2
{
addvar introshade 1
ifvare introshade 50
{
setvar introme 0
}
}
ifvare introme 0
{
setvar INTRO01 2 setvar Black_Screen 0 setvar INTRO02 0
setplayer[THISACTOR].posx xintro
setplayer[THISACTOR].posy yintro
setplayer[THISACTOR].posz zintro
soundonce 494
setplayer[THISACTOR].pals 0 0
setplayer[THISACTOR].pals 1 0
setplayer[THISACTOR].pals 2 0
setplayer[THISACTOR].pals_time 110
killit
}
enda  

action NUCLEARBOMB 0 4 1 1 6
action NUKEBOMB 3 0 0 1 0
move anyway 10000

actor 3603
ifmove 0 { move anyway geth }
randvar temp 2048
setactor[THISACTOR].ang angvar
ifmove anyway { 
ifcount 16
{
spawn 3600
resetcount
}
}
addvar countvar 1
ifvare countvar 256
{
killit
}
enda

actor 3600
ifmove 0 { move anyway randomangle }
ifmove anyway { ifcount 30
spawn EXPLOSION2 sound 402 
hitradius 12000 12000 12000 12000 12000 ifcount 32
spawn 3594
killit
}
enda

actor 3594
ifmove 0 { move anyway randomangle }
ifmove anyway { ifcount 20
spawn EXPLOSION2 sound 402 
hitradius 12000 12000 12000 12000 12000 ifcount 32
quake 100
killit
}
enda

move nuke 0 -30
move superjato 1000


actor 3639
cstat 32 sizeat 500 500 ifmove 0 { move nuke getv }  ifmove nuke { ifcount 50 { resetcount spawn 3603 spawn 3603 spawn 3603 shoot MORTER } ifceilingdistl 128 { killit } } enda

actor 3595
sizeat 32 32
fall
ifaction 0 { action NUCLEARBOMB }
ifaction  NUCLEARBOMB { ifactioncount 6 { action NUKEBOMB } }
ifaction NUKEBOMB { move 200 -200 getv soundonce 401 iffloordistl 2  { sound BIGBANG spawn EXPLOSION2 hitradius 15000 15000 15000 15000 15000 randvar temp 2048 setactor[THISACTOR].ang temp spawn 3639 spawn 3639 spawn 3639 spawn 3639 spawn 3639 spawn 3603 spawn 3603 spawn 3603 spawn 3603 spawn 3603 spawn 3639 palfrom 100 100 100 100 palfrom 100 100 100 100 palfrom 100 100 100 100 quake 500 killit } }
enda 

move jato 800
move jatolento 500
move stop 0

actor 3593 100 0 jato randomangle
sizeat 50 50
cstat 16
ifmove jato { soundonce 400 ifvare nukebomb 0 { ifcount 16 { spawn 3595 resetcount setvar nukebomb 1 } } ifnotmoving { setvar nukebomb 0 killit } }
enda

actor 3592 100 0 jatolento randomangle
sizeat 50 50
cstat 16
ifmove jatolento { soundonce 400 ifnotmoving killit } enda

actor 3655 100 0 jato randomangle
sizeat 50 50
cstat 16
ifmove jato { soundonce 400 ifnotmoving killit } enda


actor 3599
fall
sizeat 32 32
soundonce 401
ifonwater { killit }
iffloordistl 2 { spawn EXPLOSION2
sound 403
hitradius 2000 2000 2000 2000 2000
spawn BURNING2
debris SCRAP1 5
killit
}
enda

actor 3710
fall 
state respawnit
sizeat 32 32
ifp palive
ifpdistl 758
ifvarl mp5k_ammo 150
ifcount 6
ifcanseetarget {
setplayer[THISACTOR].gotweapon 1 1
addvar mp5k_ammo 30
setvar mp5k 1
quote 125
ifspawnedby 3710
state getcode
else
state quikget
killit
}
enda

actor 3713
fall
state respawnit
sizeat 32 32
ifp palive
ifvarl mp5k_ammo 210
ifpdistl 758
ifcount 6
ifcanseetarget {
addvar mp5k_ammo 30
quote 129
ifspawnedby 3713
state getcode
else
state quikget
killit
}
enda

action airplane 0 2 1 1 2
action firing 2 2 1 1 2

actor 3601 100 airplane jato randomangle
sizeat 100 100
cstat 32
ifmove jato { soundonce 400 ifcount 8 { spawn 3599 resetcount } ifnotmoving killit } 
enda

actor 3604 100 airplane jato randomangle
sizeat 50 50
cstat 32
ifmove jato { soundonce 400 ifcount 2 { action firing shoot SHOTSPARK1 sound CHAINGUN_FIRE resetcount } ifnotmoving  killit } enda

state displayknee
setvar x 151
setvar y 100
addvarvar x weapon_xoffset
subvarvar x looking_angSR1
addvarvar y looking_arc
subvarvar y gun_pos
setvar picnum 3980
switch weaponcount
case 0
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 1
case 2
case 3
addvar y 6
subvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 4
case 5
case 6
case 7
case 8
case 9
case 10
case 11
case 12
case 13
case 14
case 15
case 16
subvar picnum 1
addvar y 6
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
endswitch
ends


state rpg
switch weaponcount
case 0
setvar x 250
setvar y 250
addvarvar x weapon_xoffset
subvarvar x looking_angSR1
addvarvar y looking_arc
subvarvar y gun_pos
setvar tilenum 5348
myospal x y tilenum 0 0 0
break
case 1
case 2
case 3
case 4
case 5
case 6
case 7
setvar x 250
setvar y 230
addvarvar x weapon_xoffset
subvarvar x looking_angSR1
addvarvar y looking_arc
subvarvar y gun_pos
setvar tilenum 5348
myospal x y tilenum 0 0 0
break
endswitch
ends

state pistol_ammom
ifvarl weaponcount 8
 {
    setvar x 183 // 195-12
    addvarvar x weapon_xoffset
    ifvare weaponcount 3
    {
        subvar x 3
    }
    subvarvar x looking_angSR1

    setvar y 244
    addvarvar y looking_arc
    subvarvar y gun_pos
    
    setvar tilenum FIRSTGUN
switch weaponcount
        case 1
         
setvarvar mx x
setvarvar my y
subvar my 30
subvar mx 10
rotatesprite mx my 65536 0 3830 0 0 33 0 0 xdim ydim
            break
        case 2
            setvarvar mx x
setvarvar my y
addvar tilenum 2
            break
case 3
case 4
case 5
case 6
case 7
setvar tilenum FIRSTGUN
break
    endswitch
          
    setvar orientation 2
    rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
    
 }
 else
 {
    ifvarl weaponcount 10
    {
        setvar x 194
        subvarvar x looking_angSR1
        
        setvar y 230
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 4

        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
        
    }
    else ifvarl weaponcount 15
    {
        setvar x 244
        setvarvar wp_temp weaponcount
        mulvar wp_temp 2 // <<1
        mulvar wp_temp 4 // << 2
        mulvar wp_temp 8 // << 3
        subvarvar x wp_temp
        subvarvar x looking_angSR1
        
        setvar y 130
        addvarvar y looking_arc
        mulvarvar wp_temp wp_temp // << 4
        addvarvar y wp_temp
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 6

        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
// ///////      
        setvar x 224
        subvarvar x looking_angSR1
        
        setvar y 220
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 5


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
        
    }
    else ifvarl weaponcount 20
    {
        setvar x 124
        setvarvar wp_temp weaponcount
        mulvarvar wp_temp wp_temp // <<1
        addvarvar x wp_temp
        subvarvar x looking_angSR1
        
        setvar y 430
        addvarvar y looking_arc
        mulvarvar wp_temp wp_temp // << 2
        mulvarvar wp_temp wp_temp // << 3
        subvarvar y wp_temp
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 6


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
// ///////      
        setvar x 224
        subvarvar x looking_angSR1
        
        setvar y 220
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 5


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
        
    }
    else ifvarl weaponcount 23
    {
        setvar x 184
        subvarvar x looking_angSR1
        
        setvar y 235
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 8


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
// ///////      
        setvar x 224
        subvarvar x looking_angSR1
        
        setvar y 210
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 5


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
        
    }
    else ifvarl weaponcount 25
    {
        setvar x 164
        subvarvar x looking_angSR1
        
        setvar y 245
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 8


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
// ///////      
        setvar x 224
        subvarvar x looking_angSR1
        
        setvar y 220
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 5


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
    }
    else ifvarl weaponcount 27
    {
        setvar x 194
        subvarvar x looking_angSR1
        
        setvar y 235
        addvarvar y looking_arc
        subvarvar y gun_pos
        
        setvar tilenum FIRSTGUN
        addvar tilenum 5


        rotatesprite x y 65536 1024 tilenum 0 0 4 0 0 xdim ydim
    }
 }
ends

state m4a1
setvar x 183
setvar y 50
addvarvar x weapon_xoffset
subvarvar x looking_angSR1
addvarvar y looking_arc
subvarvar y gun_pos
setvar picnum 2537

switch weaponcount
case 0 
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 1
randvar temp 2048
randvar temp2 2048
randvar temp3 2048
setvar mx 190
setvar my 125
rotatesprite mx my 131072 temp 3826 0 0 33 0 0 xdim ydim
rotatesprite mx my 131072 temp2 3826 0 0 33 0 0 xdim ydim
rotatesprite mx my 131072 temp3 3826 0 0 33 0 0 xdim ydim
addvar picnum 1
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 2
case 3
addvar picnum 1
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 4
case 5
addvar picnum 1
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 6
case 7
case 8
case 9
case 10
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 11
case 12
case 13
case 14
case 15
case 16
case 17
case 18
case 19
case 20
case 21
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 
case 22
case 23
case 24
case 25
case 26
case 27
case 28
case 29
case 30
case 31
case 32
case 33
case 34
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 
case 35
case 36
case 37
case 38
case 39
case 40
case 41
case 42
case 43
case 44
case 45
case 46
case 47
case 48
case 49
case 50
case 51
case 52
case 53
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 
case 54
case 55
case 56
case 57
case 58
case 59
case 60
case 61
case 62
case 63
case 64
case 65
case 66
case 67
case 68
case 69
case 70
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 

endswitch
ends

state pnoventa

setvar x 183
setvar y 120
addvarvar x weapon_xoffset
subvarvar x looking_angSR1
addvarvar y looking_arc
subvarvar y gun_pos
setvar picnum 8456

switch weaponcount
case 0 
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 1
randvar temp 2048
randvar temp2 2048
randvar temp3 2048
setvar mx 210
setvar my 140
rotatesprite mx my 131072 temp 3826 0 0 33 0 0 xdim ydim
rotatesprite mx my 131072 temp2 3826 0 0 33 0 0 xdim ydim
rotatesprite mx my 131072 temp3 3826 0 0 33 0 0 xdim ydim
addvar picnum 1
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 2
case 3
addvar picnum 1
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 4
case 5
addvar picnum 1
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 6
case 7
case 8
case 9
case 10
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break
case 11
case 12
case 13
case 14
case 15
case 16
case 17
case 18
case 19
case 20
case 21
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 
case 22
case 23
case 24
case 25
case 26
case 27
case 28
case 29
case 30
case 31
case 32
case 33
case 34
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 
case 35
case 36
case 37
case 38
case 39
case 40
case 41
case 42
case 43
case 44
case 45
case 46
case 47
case 48
case 49
case 50
case 51
case 52
case 53
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 
case 54
case 55
case 56
case 57
case 58
case 59
case 60
case 61
case 62
case 63
case 64
case 65
case 66
case 67
case 68
case 69
case 70
addvar picnum 2
rotatesprite x y 65536 1024 picnum 0 0 4 0 0 xdim ydim
break 

endswitch
ends


onevent EVENT_DISPLAYWEAPON

ifvare curweap 0 { ifvare chain 1 {
setvar RETURN -1
state displayknee
}
else
ifvare chain 0 { setplayer[THISACTOR].weapon_pos -9 }
}

ifvare curweap 4 {
setvar RETURN -1
state rpg
}

ifvare currentweapon 2
{
setvar RETURN -1
state pnoventa
}

ifvare currentweapon 1 
{
ifvare weapon_1 1
{
setvar RETURN -1
state mp5k
}
else
ifvare weapon_1 0
{
setvar RETURN -1
state deagle
}
}

ifvare curweap 3 {
setvar RETURN -1 
state m4a1 }

endevent

useractor notenemy 3664
setvar GAMEMENU 1
killit
enda

useractor notenemy 3665 0
cstator 32768
 ifvare countvar 0
 {
  ifspawnedby NEWBEAST setvar mtype 1
  getactor[THISACTOR].z z
  subvar z 9216
  setactor[THISACTOR].z z
  state brainshoot
  state flesh1shoot
  }

ifvare countvar 1
 {
	 addvar z 2048
	 setactor[THISACTOR].z z
	 state spineshoot
	 state flesh1shoot
	 state flesh2shoot
	 state flesh1shoot
	 state flesh2shoot
 }

ifvare countvar 2
{
	addvar z 3072
	setactor[THISACTOR].z z
	state flesh2shoot
	state flesh3shoot
	state flesh1shoot
	state flesh3shoot
}

addvar countvar 1
ifvarg countvar 2 killit
enda

onevent EVENT_WEAPKEY2
ifvare currentweapon 1 {
ifvare  weapon_1 0 ifvare mp5k 1 {
setvar WEAPON1_TOTALTIME 3
setvar WEAPON1_RELOAD 71
setvar WEAPON1_FIRESOUND 416
setvar WEAPON1_SHOOTS SHOTSPARK1
setvar WEAPON1_FLAGS 32768
setplayer[THISACTOR].weapon_pos  -1
setvar weapon_1 1
}
else ifvare weapon_1 1 {
setvar WEAPON1_TOTALTIME 6
setvar WEAPON1_RELOAD 71
setvar WEAPON1_FIRESOUND PISTOL_FIRE
setvar WEAPON1_SHOOTS SHOTSPARK1
setvar WEAPON1_FLAGS 32768
setplayer[THISACTOR].weapon_pos -1
setvar weapon_1 0
}
}
endevent

onevent EVENT_WEAPKEY3
getplayer[THISACTOR].ammo_amount 2 temp
ifvare curweap 2 {
ifvarvarg RIFLE12MAG shotgam { setvarvar RIFLE12MAG shotgam }
}
endevent

onevent EVENT_FIRE
ifvare curweap 1 { getplayer[THISACTOR].ammo_amount 1 tmp
ifvare weapon_1 0 {
ifvarl pistol_ammo 1 ifvarl DEAGLEMAG 1 setvar RETURN 1 else ifvarl pistol_ammo 1 ifvarg DEAGLEMAG 1 setvar RETURN 0 } } 
ifvare curweap 2 { getplayer[THISACTOR].ammo_amount 2 tmp2
ifvarl shotgam 1 ifvarl RIFLE12MAG 1 setvar RETURN 1 else ifvarl shotgam 1 ifvarg RIFLE12MAG 1 setvar RETURN 0 }
ifvare curweap 3 {
ifvarl mammo 1 ifvarl mmag 1 setvar RETURN 1 else ifvarl mammo 1 ifvarg mmag 1 setvar RETURN 0 }
ifvare curweap 5 {
getplayer[THISACTOR].ammo_amount 5 temp
ifvarl temp 1 
{
setvar RETURN 1
}
}
getplayer[THISACTOR].kickback_pic kickbackpic
ifvare curweap 1 { getplayer[THISACTOR].ammo_amount 1 tmp ifvare weapon_1 1 { ifvarl MP5KMAG 1 { setvar RETURN 1 state checking } else
ifvarg mp5k_ammo 0
ifvare kickbackpic 0 {
setplayer[THISACTOR].kickback_pic 1 } } else ifvare weapon_1 0 { ifvarl DEAGLEMAG 1 { setvar RETURN 1 state checking } else ifvarg  pistol_ammo 0 ifvare kickbackpic 0 { setplayer[THISACTOR].kickback_pic 1 } } }
getplayer[THISACTOR].kickback_pic kickbackpic
ifvare curweap 2  { ifvarl RIFLE12MAG 1 { setvar RETURN 1 state checking } else ifvarg shotgam 0
ifvare kickbackpic 0 { setplayer[THISACTOR].kickback_pic 1 } }
ifvare curweap 3 {
ifvarl mmag 1 { setvar RETURN 1 state checking } else
ifvarg mammo 0
ifvare kickbackpic 0 { setplayer[THISACTOR].kickback_pic 1 } }
endevent

onevent EVENT_LOOKUP
setvar RETURN -1
endevent

action GLASSBREAK 2 5 1 1 3
action GLASSCRACK 2 1 1 1 1

useractor notenemy GLASS 50
ifaction GLASSBREAK { ifactioncount 5 {
lotsofglass 10
killit
}
break
}
ifaction GLASSCRACK strength 0
ifhitweapon {
ifaction 0 { action GLASSCRACK soundonce 422 } else
ifaction GLASSCRACK { action GLASSBREAK soundonce GLASS_BREAKING }
ifdead {
action GLASSBREAK soundonce GLASS_BREAKING }
}
enda

eventloadactor 3750
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

action NORMAL 0 1 5 1 1
action DIE 5 5 1 1 10
action DEAD 10 1 1 1 1
action one 1 1 1 1 1
action talk 0 2 1 1 15
action WALK 52 3 5 1 4
move WALK1 120

useractor notenemy 3750 PERSONSTR NORMAL
sizeat 32 32
cstat 256
ifhitweapon { ifwasweapon RADIUSEXPLOSION { state standard_jibs sound BODY_SPLAT state random_wall_jibs killit } else
{ state random_wall_jibs sound 431 ifvare lotagsaved 0 { action WALK } else { nullop } ifdead { action DIE } } }
ifaction WALK { move WALK1 faceplayerslow }
ifaction WALK { ifnotmoving { move WALK1 faceplayerslow } }
ifvare lotagsaved 0 {
ifmove WALK1 { ifpdistl 2048 { move stop faceplayer action NORMAL } }
ifmove stop { ifaction NORMAL {  ifp palive ifcanseetarget ifcount 8 { sound PISTOL_FIRE shoot SHOTSPARK1 resetcount } else ifpdistg 2048 action WALK } } }
ifaction DIE { ifactioncount 4 { action DEAD spawn BLOODPOOL move stop faceplayer sound 432 state random_wall_jibs break } }
enda

state custon_sw
ifpdistl 1548
ifp palive
ifp pfacing
ifcansee
ifhitspace
ifcount 13 
{
stopsound DUKE_SEARCH
stopsound DUKE_SEARCH2
ifvare hitagsaved 0 { sound SWITCH_ON } else { soundvar hitagsaved }
ifaction 0 { action one } else ifaction one { action 0 }
operateactivators lotagsaved 0
operaterespawns lotagsaved
operatemasterswitches lotagsaved
resetcount
}
ends

eventloadactor 3767
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3767
state custon_sw
enda

eventloadactor 3770
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3770
state custon_sw
enda

eventloadactor 3778
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3778
state custon_sw
enda

eventloadactor 3780
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3780
state custon_sw
enda

eventloadactor 3782
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3782
state custon_sw
enda

eventloadactor 3784
{
getactor[THISACTOR].hitag hitagsaved
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3784
state custon_sw
enda

action NR 0 1 5 1 1
action WL 20 5 5 1 2
action DY 106 5 1 1 2
action DE 113 1 1 1 1

useractor notenemy 5501 PERSONSTR
cstat 256
sizeat 32 32
ifaction WL { move WALK1 faceplayerslow ifnotmoving { move WALK1 faceplayerslow } }
ifpdistl 3000 { action NR }
else
ifpdistg 3000 { action WL }
ifaction NR { move stop }
findnearactor PIGCOP 4096 target
ifvarn target -1 {
getactor[target].x x
getactor[target].y y
getactor[THISACTOR].x mx
getactor[THISACTOR].y my
subvarvar x mx
subvarvar y my
getangle angvar mx my
mulvar angvar -1
setactor[THISACTOR].ang angvar
sound PISTOL_FIRE shoot SHOTSPARK1 resetcount
}
ifhitweapon { ifwasweapon RPG { state random_wall_jibs state standard_jibs state random_wall_jibs spawn BLOODPOOL killit } else {
state random_wall_jibs sound 431 ifdead {
action DY } } }
ifaction DY {
ifactioncount 4 {
action DE
spawn BLOODPOOL
move stop faceplayer
state random_wall_jibs
sound 432
break
}
}
enda

useractor notenemy 3818
ifp palive
ifpdistl 1548
ifp pfacing
ifcansee
ifvare DNSUIT 0
ifhitspace
{
ifcount 16
{
soundonce REACTOR_ON
setvar putdn 1 } }
enda

useractor notenemy 3835
cstator 0
sizeat 1 1
ifvare testc 1 ifvare ene5 0 {
spawn 3836 setvar ene5 1 }
ifvare testc 3 { ifcount 30 {
spawn EXPLOSION2
debris SCRAP1 5
resetcount
}
}
enda

useractor notenemy 3836
sizeat 1000 3500
sizeat 1000 3500
enda

eventloadactor 3821
getactor[THISACTOR].hitag hitagsaved
setactor[THISACTOR].hitag 0
enda

useractor notenemy 3821
ifp palive
ifp pfacing
ifpdistl 1758 
ifcansee
ifhitspace
{
ifcount 13 
{
setvar testc 1
setvar ene8 1
ifaction 0 { action one }
soundvar hitagsaved
resetcount
}
}
enda


useractor notenemy 3834
cstat 0
sizeat 1 1
ifvare testc 3 {
ifcount 40 { spawn EXPLOSION2  debris SCRAP1 30 resetcount }
}
enda

useractor notenemy 4092
cstator 32768
ifpdistl 2048 {
quote 130 killit }
enda

useractor notenemy 4093
cstator 32768
ifvare DNSUIT 0 
ifpdistl 2048 { quote 133 addvar countvar 1 ifvare countvar 72 { quote 131 killit } }
enda

useractor notenemy 4094
cstator 32768
ifpdistl 2048 {
quote 132 killit }
enda

actor 3982
fall
sizeat 32 32
ifp palive
ifpdistl 758
ifcansee
{
setvar chain 1
state quikget
else
state getcode
killit
}
enda

action ZOMBIE1_WALKING 0 5 5 1 15
action ZOMBIE1_ATTACKING 64 2 5 1 20
action ZOMBIE1_SHOOTINGSTONES 64 2 5 1 4
action ZOMBIE1_DIEING 50 5 1 1 15
action ZOMBIE1_DEAD 54 1 1 1 1

move WALKER1 50
move STOP2

ai AIZOMBIE1_WALK ZOMBIE1_WALKING WALKER1 randomangle geth faceplayerslow
ai AIZOMBIE1_ATTACK ZOMBIE1_ATTACKING STOP2 faceplayer
ai AIZOMBIE1_SHOOT ZOMBIE1_SHOOTINGSTONES STOP2 faceplayer
ai AIZOMBIE1_DIE ZOMBIE1_DIEING STOP2 faceplayer
ai AIZOMBIE1_DEAD ZOMBIE1_DEAD STOP2 faceplayer 

useractor enemy 9360 ZOMBIESTR
fall
sizeat 32 32
cstator 256

angoff -512

ifstrength 1
{ }
else
{
spawn 3908
}

ifp palive
ifcanseetarget
{
ifai 0
{
ai AIZOMBIE1_SHOOT
}
}

ifcanseetarget
{
ifdead { } else
ifvare track_used 1
{
setvar TRACK 2
}
}

ifai AIZOMBIE1_SHOOT
{
ifactioncount 4
{
ai AIZOMBIE1_WALK
}
}


ifai AIZOMBIE1_WALK
{
ifpdistl 1024
{
ai AIZOMBIE1_ATTACK
sound 454
}
}

ifai AIZOMBIE1_ATTACK
{
ifpdistl 1024
{
ifactioncount 6
{
addphealth -10
sound 452
wackplayer
resetactioncount
}
}
else
ifpdistg 2048
{
ifai AIZOMBIE1_ATTACK
{
ai AIZOMBIE1_WALK
}
}
}


ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
setvarvar TRACK track_used
spawn BLOODPOOL
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
setvarvar TRACK track_used
spawn BLOODPOOL
killit
}
else
{
state random_wall_jibs
state random_wall_jibs
sound 453
ifdead
{
ai AIZOMBIE1_DIE
}
}
}

ifai AIZOMBIE1_DIE
{
ifactioncount 5
{
ai AIZOMBIE1_DEAD
spawn BLOODPOOL
state random_wall_jibs
sound 453
cstat 0
setvarvar TRACK track_used
break
resetactioncount
}
}

enda

action wl 0 2 5 1 20

move slower 50

useractor notenemy 10220
fall
sizeat 32 32 
ifaction 0
{
action wl
}

ifaction wl
{
move slower faceplayerslow
ifcount 72 
{
spawn NEWBLOOD1
resetcount
}
}

ifcount 72 
{
espawn NEWBLOOD2
resetcount
}


ifmove slower
{
ifnotmoving
{
move slower faceplayerslow
}
}

ifhitweapon
{
state random_wall_jibs
ifdead
{
state random_wall_jibs
state random_wall_jibs
state standard_jibs
spawn BLOODPOOL
spawn 1857
killit
}
}

ifaction wl
{
ifpdistl 2048
{
state random_wall_jibs
state random_wall_jibs
state standard_jibs
spawn BLOODPOOL
spawn 1857
killit
}
}

enda

action zmwl 0 4 5 1 15
action zmatt 40 3 5 1 20
action zmdie 55 6 1 1 15
action zmdead 60 1 1 1

move zmslow 30

ai zmwa zmwl zmslow randomangle geth faceplayerslow
ai zmo zmatt stop faceplayer
ai zmat zmatt stop faceplayer
ai zmd zmdie stop faceplayer
ai zmde zmdead stop

useractor notenemy 9680 350

sizeat 32 32
cstator 256
fall

ifstrength 1
{ }
else
{
spawn 3908
}

ifcanseetarget
{
ifai 0
{
ai zmo
}
}

ifai zmo
{
ifactioncount 6
{
ai zmwa
resetactioncount
}
}

ifcanseetarget
{
ifdead { } else
ifvare track_used 1
{
setvar TRACK 2
}
}

ifai zmwa
{
ifpdistl 1024
{
sound 454
ai zmat
}
}

ifai zmat
{
ifpdistl 1024
{
ifactioncount 6
{
sound 452
shoot 10493
palfrom 32 50
wackplayer
resetactioncount
}
}
else
ifpdistg 2048
{
ifai zmat
{
ai zmwa
}
}
}


ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
setvarvar TRACK track_used
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
setvarvar TRACK track_used
killit
}
else
{
state random_wall_jibs
state random_wall_jibs
sound 453
ifdead
{
ai zmd
}
}
}

ifai zmd
{
ifactioncount 6
{
setvar enter 0
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
cstat 0
setvarvar TRACK track_used
ai zmde
break
}
}
enda

useractor notenemy 3908 0

sizeat 32 32
cstat 32768

getactor[THISACTOR].owner myspawner

getactor[myspawner].x x
getactor[myspawner].y y
getactor[myspawner].z z

setactor[THISACTOR].x x
setactor[THISACTOR].y y
setactor[THISACTOR].z z

ifcount 1
killit

enda

useractor notenemy 3909 0

cstat 32768
sizeat 32 32

ifcount 1
killit

enda

action btwl 20 4 5 1 10
action btshot 40 1 5 3
action btdie 106 5 1 1 4
action botde 113 1 1 1 1

move btwlm 200
move btjump 200 -150

ai btw btwl btwlm randomangle geth faceplayerslow
ai btst NORMAL stop faceplayerslow
ai btst2 NORMAL stop
ai di btdie stop faceplayer
ai dea botde stop faceplayer
ai btwtk btwl btwlm randomangle
ai btj btwl btjump faceplayerslow
ai btsh btshot stop 
ai btst2 NORMAL stop faceplayerslow

useractor notenemy 5501 100
fall
sizeat 32 32
cstat 256

ifdead { } else { spawn 3909 }

ifcanseetarget
ifai 0
{
ai btst
}

getactor[THISACTOR].sectnum mysector
getsector[mysector].lotag temp
ifvare temp 50
{
setactor[THISACTOR].htextra 5000
}

ifai btj
{
ifactioncount 1
{
fall
ai btst
resetactioncount
}
}

ifai btw
{
operate
ifpdistl 3000
{
ai btst
}
}

ifai btst
{
ifpdistg 3000
{
ai btw
}
}

ifai btw
{
ifp phigher
{
ai btj
}
}

ifai btsh
{
ai btst
}

ifdead
{ }
else
{
findnearactor 3908 10000 target
ifvarn target -1
{
getactor[target].owner target2
canseespr THISACTOR target2 temp
ifvare temp 0 { setvar target -1 setvar btt 0
}

ifvarn temp 0
{
setvar btt 1
}

ifvare btt 1 
{
ai btsh
getactor[target2].x x
getactor[target2].y y
getactor[THISACTOR].x mx
getactor[THISACTOR].y my
subvarvar x mx
subvarvar y my
getangle angvar x y
setactor[THISACTOR].ang angvar
addvar countvar 1
ifvare countvar 3
{
shoot SHOTSPARK1 sound 416 setvar countvar 0
}
}
}
}

ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
killit
}
else
{
state random_wall_jibs
state random_wall_jibs
ifdead
{
ai di
}
}
}

ifai di
{
ifactioncount 5
{
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
cstat 0
spawn FIRSTGUNSPRITE
ai dea
break
}
}
enda

useractor notenemy 4088
cstator 32768
ifpdistl 2048
{
addvar countvar 1
{
ifvare countvar 5
{
setvar track_used 1
setvar TRACK 1
killit
setvar countvar 0
}
}
}
enda

useractor notenemy 4089
cstator 32768
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum tmp
ifvarvare mysector tmp
{
setvar other 1
killit
}
enda

action bugwl 0 2 5 1 3
action bugdead 10 1 1 1 1

move bug 120
move bugjump 120 -50

ai bgwl bugwl bug randomangle geth faceplayerslow
ai bgde bugdead stop randomangle
ai bgjmtp bugwl bugjump jumptoplayer
ai bugdeadi bugdead stop randomangle

useractor enemy 8042 150

fall
cstator 256
sizeat 32 32

ifstrength 1
{ }
else
{
spawn 3908
}

ifai 0
{
ai bgwl
}

ifai bgwl
{
ifp phigher
{
ai bgjmtp
}
}

ifai bgjmtp
{
ifactioncount 3
{
fall
ifceilingdistl 2
{
ai bgwl
resetactioncount
}
}
}

ifai bgwl
{
ifpdistl 1024
{
ifactioncount 3
{
addphealth -5
palfrom 32 32
resetactioncount
}
}
}


ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
killit
}
else
{
state random_wall_jibs
ifdead
{
ai bugdeadi
}
}
}

ifai bugdeadi
{
ifactioncount 3
{
spawn BLOODPOOL
cstat 0
ai bgde
break
}
}

enda

useractor notenemy 4090
cstator 32768
ifvare other 2
{
addvar countvar 1
ifvare countvar 80
{
setvar destroy 1
setvar gore 0
spawn 4099
killit
}
}

enda

useractor notenemy 3931
cstator 32768
ifvare destroy 1
{
hitradius 10000 10000 10000 10000 10000
killit
}
enda
 
useractor notenemy 3932
cstator 32768
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum tmp
ifvarvare mysector tmp
{
setvar other 2
killit
}
enda

useractor notenemy 4099
cstator 32768
addvar countvar 1
ifvare countvar 15
{
setvar gore 1
setvar other 0
killit
}
enda

eventloadactor 3587
{
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
getactor[THISACTOR].hitag hitagsaved
setactor[THISACTOR].hitag 0
}
enda

useractor notenemy 3587
cstator 32768

ifvare lotagsaved 1
{
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp
ifvarvare mysector temp
{
ifcount 72
{
setvar other 3
resetcount
killit
}
}
}

ifvare lotagsaved 2
{
ifvare other 3
{
setsector[THISACTOR].lotag 2
killit
}
}

ifvare lotagsaved 3
{
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp
ifvarvare temp mysector
{
palfrom 100
setsector[THISACTOR].lotag 0
setsector[THISACTOR].floorpicnum WATERTILE2
stopsoundvar TRACK
stopallsounds
killit
}
}

ifvare lotagsaved 4
{
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp2
ifvarvare temp2 mysector
{
setvar other 10
}
ifvare other 10 
{
ifcount 72
{
quake 10
addvar tmp2 1
resetcount
}
ifvare tmp2 10
{
setvar other 0
killit
}
}
}

ifvare lotagsaved 5
{
killit
}

ifvare lotagsaved 6
{
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp2
ifvarvare temp2 mysector
ifvarn temp 500
{
setplayer[THISACTOR].posx gx
setplayer[THISACTOR].posy gy
setplayer[THISACTOR].posz gz
setplayer[THISACTOR].ang gang
setvar temp 500
}
else
{
setvar temp 501
}
}

ifvare lotagsaved 8
{
getactor[THISACTOR].x gx
getactor[THISACTOR].y gy
getactor[THISACTOR].z gz
getactor[THISACTOR].ang gang
}

ifvare lotagsaved 9
{
espawn 3747
getactor[THISACTOR].pal pal
setactor[RETURN].pal pal
espawn 3744
setactor[RETURN].xrepeat hitagsaved
setactor[RETURN].yrepeat hitagsaved
getactor[THISACTOR].pal pal
setactor[RETURN].pal pal
killit
}

ifvare lotagsaved 10
{
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp2
ifvarvare temp2 mysector
{
setvar destroy 555
killit
}
}

ifvare lotagsaved 11
{
ifvare destroy 555
{
spawn EXPLOSION2
sound RPG_EXPLODE
killit
}
}

enda

useractor notenemy 3838
setactor[THISACTOR].picnum 3833
enda


action bwl2 0 7 5 1 4
action bat2 824 6 5 1 4
action bdi2 62 23 1 1 4
action bd2 54 1 5 1 1

move bug2 200 

ai bw2 bwl2 bug2 randomangle geth faceplayerslow
ai ba bat2 stop faceplayer
ai bdie bdi2 stop randomangle
ai bdead2 bd2 stop randomangle

useractor enemy 6288 400

sizeat 32 32
fall
cstat 256

ifdead { } else { spawn 3908 }

ifstrength 1
{ }
else
{
spawn 3908
}

ifp palive
ifcansee
ifcanseetarget
ifai 0
{
sound 458
ai bw2
}

ifai bw2
{
ifpdistl 1024
{
sound 460
ai ba
}
}

ifai bw2
{
randvar tmp5 100
ifvare tmp5 15
{
sound 459
}
ifvare tmp5 2
{
sound 460
}
}

ifai ba
{
ifpdistl 2048
{
ifactioncount 20
{
addphealth -5
palfrom 32 32
wackplayer
sound 461
resetactioncount
}
}
else
ifpdistg 2048
{
ai bw2
}
}

ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
killit
}
else
{
state random_wall_jibs
ifdead
{
ai bdie
}
}
}

ifai bdie
{
ifactioncount 23
{
sound 462
state random_wall_jibs
state random_wall_jibs
spawn BLOODPOOL
ai bdead2
break
}
}

enda

useractor notenemy 9216
cstator 32768
ifcanseetarget
{
addvar countvar 1
ifvare countvar 50
{
spawn 6288
setvar countvar 0
}
}

ifvare destroy 5
{
killit
}

ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
killit
}
ifwasweapon RPG
{
killit
}
}

enda

actor 9217
cstator 32768

getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp
ifvarvare temp mysector
{
stopsound 407
stopsound 418
setvar TRACK 3
setvar track_used 3
killit
}

enda

actor 9218
cstator 32768
getplayer[THISACTOR].cursectnum mysector
getactor[THISACTOR].sectnum temp
ifvarvare temp mysector
{
setvar destroy 5
killit
}
enda

move FLAMEMOVE 400 0

action FLALICK 0 11 1 1 4

useractor notenemy 9827
sizeat 38 38

ifcount 1 { addvar temp 1 resetcount }

ifaction 0
{
  ifrnd 128
    cstat 4
action FLALICK
}

ifaction FLALICK
{
move FLAMEMOVE geth 

ifactioncount 11
{
killit
}

ifinwater
{
killit
}

ifpdistl 812
{
ifvarg temp 3
{
wackplayer
palfrom 20 20 0 0
addphealth -1 
setvar temp 0
}
}

}

enda

eventloadactor 9761
{
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
}
enda

action sb 0 8 5 1 10
action sbat 46 6 1 1 15
action sbat2 51 1 1 1
action sbdie 53 7 1 1 15
action sbdead 60 1 5 1 1

move running 150

ai sb1 sb running randomangle geth faceplayerslow
ai sb2 sbat stop faceplayer
ai sb3 sbat2 stop faceplayer
ai sb4 sbdie stop faceplayer
ai sb5 sbdead stop randomangle 

useractor enemy 9761 6000

fall
ifspritepal 2 { sizeat 1000 1000 strength 10000 } else
sizeat 128 128
cstat 256

ifdead { } else { spawn 3908 }

ifstrength 1
{ }
else
{
spawn 3908
}

ifcansee
ifcanseetarget
ifp palive
ifai 0
{
ai sb1
}

ifai sb1
{
ifcount 10
{
quake 2
resetcount
}
}

ifai sb1
{
ifpdistl 6000
{
ai sb2
}
}

ifai sb2
{
ifpdistl 7500
{
ifactioncount 6
{
ai sb3
resetactioncount
}
}
else
ifpdistg 7500
{
ai sb1
}
}

ifai sb3
{
ifpdistl 7500
ifcanshoottarget
{
ifcount 5
{
spawn 9827
sound 403
resetactioncount
}
}
else
ifpdistg 7500
{
ai sb1
}
}

ifhitweapon
{
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
ifdead
{
ai sb4
}
}

ifai sb4
{
ifactioncount 7
{
ai sb5
cstat 0
spawn 6288
spawn 6288
spawn 6288
operateactivators lotagsaved 0
break
}
}

enda

action litrobo 0 3 5 1 6
action litroboatack 10 2 5 1 15
action litrobodie 20 6 1 1 20

move litroborun 200

ai lrb litrobo litroborun randomangle geth faceplayerslow
ai lrba litroboatack stop faceplayer
ai lrbd litrobodie stop faceplayer

useractor enemy 8820 100

fall
sizeat 32 32
cstat 256

ifdead { } else { spawn 3908 }

ifp palive
ifcansee
ifcanseetarget
ifai 0
{
ai lrb
}

ifai lrb
{
ifpdistl 3000
{
ai lrba
}
}

ifai lrba
{
ifpdistl 3000
ifcanshoottarget
{
ifactioncount 2
{
shoot 10339
sound CHAINGUN_FIRE
resetactioncount
}
}
else
ifpdistg 3000
{
ai lrb
}
}

ifhitweapon
{
debris SCRAP1 1
ifdead
{
ai lrbd
}
}

ifai lrbd
{
ifactioncount 6
{
debris SCRAP1 5
sound PIPEBOMB_EXPLODE
killit
}
}
enda

eventloadactor 16
{
getactor[THISACTOR].lotag lotagsaved
setactor[THISACTOR].lotag 0
}
enda

move superfast 9999

useractor notenemy 16
cstator 32768
ifmove 0 { move superfast randomangle }
getactor[THISACTOR].sectnum mysector
getplayer[THISACTOR].cursectnum temp3
ifvarvare temp3 mysector
{
//getplayer[THISACTOR].posx x
//getplayer[THISACTOR].posy y
randvar angvar 2047
setactor[THISACTOR].ang angvar
addvar countvar 1
ifvare countvar 5
{
espawn 14
//setactor[RETURN].x temp
//setactor[RETURN].y temp2
setvar countvar 0
}
}
enda

move down 50 500

useractor notenemy 14

sizeat 32 32
spritepal 2

ifmove 0 { move down geth getv }

iffloordistl 10
{
spawn EXPLOSION2BOT
killit
}

ifinwater { killit }

ifpdistl 1024
{
palfrom 32 32
addphealth -3
spawn EXPLOSION2BOT
killit
}

enda

action tent1 0 5 1 1 15
action tent2 5 5 1 1 15

useractor enemy 10495

strength 20000
clipdist 128
cstat 256

ifaction 0
{
action tent1
randvar angvar 2048
setactor[THISACTOR].ang angvar
}

ifaction tent1
{
ifcount 72
{
action tent2
randvar angvar 2048
setactor[THISACTOR].ang angvar
resetcount
}
}

ifaction tent2
{
ifactioncount 10
{
ifrnd 72
sound 475
else
ifrnd 72
sound 476
spawn 10506

ifcount 128
{
action tent1
ifrnd 72
sound 477
else
ifrnd 72
sound 478
resetcount
} 
resetactioncount
}
}

ifvare destroy 3
{
spawn EXPLOSION2
sound RPG_EXPLODE
killit
}

enda

useractor enemy 10506

sizeat 64 64

getactor[THISACTOR].owner myspawner
ifvarn myspawner -1
{
getactor[myspawner].ang angvar
addvar angvar 512
setactor[THISACTOR].ang angvar

ifpdistl 6000
{
shoot 10400
}
}
killit

enda

useractor notenemy 4058
ifp palive
ifp pfacing
ifcansee
ifcanseetarget
ifpdistl 758
ifvarn temp 5 
ifhitspace
{
ifcount 13
{
setvar destroy 3
setvar temp 5
ifaction 0 { action one }
resetcount
}
}
enda

useractor notenemy 4060
cstator 32768
ifvare destroy 3
{
spawn EXPLOSION2
sound RPG_EXPLODE
spawn BOLT1
killit
}
enda

useractor notenemy 4061
cstator 32768
ifvare destroy 3
{
soundonce REACTOR_ON
getactor[THISACTOR].sectnum mysector
setsector[mysector].lotag 50
}
enda

eventloadactor 8054
{
	getactor[THISACTOR].lotag lotagsaved
	ifvare lotagsaved 1
	{
		setactor[THISACTOR].lotag 0
		cstat 32768
		getactor[THISACTOR].xrepeat mxx
		getactor[THISACTOR].yrepeat myy
		getactor[THISACTOR].hitag hitagsaved // the number of ticks between gusts
		getactor[THISACTOR].xvel tmp45 // this determines speed of gusts
		getactor[THISACTOR].yvel countvar3 // the max duration of spawned gust
		setvar temp 100
		subvarvar temp tmp45
		ifvarl temp 1 setvar temp 1
		setvarvar tmp45 temp
		getactor[THISACTOR].pal pal2
		// pal is applied to spawned gusts
		// so is the size
		getactor[THISACTOR].shade shade1
		// and the shade
		getactor[THISACTOR].ang mzz
		
	}
}
enda

useractor notenemy 8054
ifvarn lotagsaved 1 break

setactor[THISACTOR].ang mzz

addvar countvar 1
ifvarvarg countvar hitagsaved
{
	setvar countvar 0
	espawn 8055
	setactor[RETURN].xrepeat mxx
	setactor[RETURN].yrepeat myy
	setactor[RETURN].pal pal2
	setactor[RETURN].shade shade1
	setactorvar[RETURN].mzz mzz
	setactorvar[RETURN].countvar3 countvar3
	setactorvar[RETURN].tmp45 tmp45
}

enda

move smokeg 
useractor notenemy 8055 0
ifmove 0
{
move smokeg faceplayer
}
getactor[THISACTOR].roll temp
addvar temp 4
setactor[THISACTOR].roll temp

// initz is the angle to move at

cos mxx mzz
sin myy mzz
divvarvar mxx tmp45
divvarvar myy tmp45
setvar z 0
movesprite THISACTOR mxx myy z CLIPMASK0 RETURN
ifvarn RETURN 0 killit

getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
updatesectorz x y z mysector
ifvare mysector -1 killit
ifnotmoving killit
ifvarg countvar3 0 ifvarvarg countvar countvar3 killit
addvar countvar 1
enda

useractor notenemy 8056 0
sizeat 128 128
cstat 0
ifmove 0
{
move smokeg faceplayer
}
getactor[THISACTOR].roll temp
addvar temp 4
setactor[THISACTOR].roll temp
enda

useractor notenemy 8057 0
sizeat 32 32
cstat 0
ifmove 0
{
move smokeg faceplayer
}
getactor[THISACTOR].roll temp
addvar temp 4
setactor[THISACTOR].roll temp
ifspawnedby SHOTSPARK1
{
sizeat 3 3
ifcount 50
{
resetcount
killit
}
}
else
ifspawnedby EXPLOSION2
{
sizeat 128 128
ifcount 128
{
resetcount
killit
}
}
enda

useractor notenemy 8059
cstat 32768
addvar countvar 1
ifvare countvar 20
{
espawn 8058
setvar countvar 0
}
enda

move smokeup 0 -128

useractor notenemy 8058
cstat 0
ifmove 0
{
move smokeup faceplayer getv
}
ifceilingdistl 2
{
killit
}
ifspawnedby 8059
{
sizeat 32 32
}
ifspawnedby FIRE
{
sizeat 10 10
spritepal 4
}
ifspawnedby FIRE2
{
sizeat 10 10
spritepal 4
}
enda

action hecs 0 1 5 1 4
action hecr 0 2 5 1 4
action hecj 10 1 5 1 4
action hde 15 1 1 1 5
action hdee 16 1 1 1 1

move hecr1 50
move hecj1 100

ai ahecs hecs stop
ai ahecr hecr hecr1 randomangle geth faceplayerslow
ai ahecj hecj hecj1 jumptoplayer
ai ahecget hecr hecr1 faceplayerslow
ai ahd hde stop
ai hdej hdee stop

useractor enemy 1857 50

fall
sizeat 32 32
cstat 256

ifdead { } else { spawn 3908 }

ifcanseetarget
ifai  0
{
ai ahecget
sound 485
}

ifai ahecget
{
ifrnd 32
sound 486
ai ahecr
}

ifai ahecr
{
ifp phigher { sound 487 ai ahecj }
ifpdistl 1024
{
sound 487
ai ahecj
}
}

ifai ahecj
{
ifactioncount 5
{
sound 488
fall
ai ahecr
resetactioncount
}
ifpdistl 850
{
ifcount 2
{
sound 489
addphealth -3
palfrom 32 32
wackplayer
resetcount
}
}
}

ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
state random_wall_jibs
sound 490
ifdead
{
ai ahd
}
}

ifai ahd 
{
ifactioncount 20
{
cstat 0
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
ai hdej
break
}
}

enda

action sprobot 0 4 5 1 30
action sprobotatt 30 2 5 1 7
action sprobotdie 40 8 1 1 18
action sprobotdead 47 1 5 1 

move robotmove 150

ai arbw sprobot robotmove randomangle geth faceplayerslow
ai arbatt sprobotatt stop faceplayer
ai arbdie sprobotdie stop faceplayer
ai arbdead sprobotdead stop faceplayer

useractor enemy 8538 600

fall
sizeat 48 48
cstat 256

ifdead { } else { spawn 3908 }

ifcansee
ifcanseetarget
ifp palive
ifai 0
{
ai arbw
}

ifai arbw
{

ifactioncount 2
{
sound 491
resetactioncount
}

ifpdistl 3000
{
ai arbatt
}

}

ifai arbatt
{
ifcanshoottarget
ifpdistl 3000 
{
ifactioncount 2
{
shoot SHOTSPARK1
sound 416
resetactioncount
}
}
else
ifpdistg 3000
{
ai arbw
}
}

ifhitweapon
{
debris SCRAP1 3
ifdead
{
ai arbdie
}
}

ifai arbdie
{
debris SCRAP1 1
ifactioncount 8
{
cstat 0
ai arbdead
break
}
}

enda

onevent EVENT_LOOKRIGHT
setvar RETURN -1

ifcount 13
{
ifvare slowmotion 0
{
palfrom 20 63 63 63
setvar slowmotion 1
}
else
ifvare slowmotion 1
{
palfrom 20 63 63 63
setvar slowmotion 0
}
resetcount
}

endevent 

onevent EVENT_AIMUP
setvar RETURN -1
endevent

//action 

onevent EVENT_DISPLAYCROSSHAIR
ifvare INTRO01 1
{
setvar RETURN -1
}
ifvare chapter1 1
{
setvar RETURN -1
}
endevent

action sctls 9 1 1 1 1
action sctlw 8 1 1 1 1
action sctl 0 1 1 1 1

move walk 50

ai sc1 sctl stop faceplayerslow
ai sc2 sctls stop faceplayerslow
ai sc3 sctlw walk 

useractor notenemy 6323 100

ifcansee
{
ifspritepal 24
{
setvar tmp4 1
}
else
{
ifspritepal 25
{
setvar tmp4 2
}
}
}

enda

eventloadactor 6374
{
getactor[THISACTOR].lotag lotagsaved
getactor[THISACTOR].hitag hitagsaved
setactor[THISACTOR].hitag 0
setactor[THISACTOR].lotag 0
}
enda

useractor notenemy 6374 0

sizeat 32 32
cstat 256
fall

ifvare ene9 0
{ 
ifpdistl 1024
{
ifhitspace
{
ifcount 13
{
ifvare DNSUIT 0
{
sound 496
resetcount
}
else
ifvare DNSUIT 1
{
sound 497
resetcount
setvar ene9 1
}
}
}
}
}

ifvare ene9 1
{
getactor[THISACTOR].ang angvar
subvar angvar 1024
setactor[THISACTOR].ang angvar
setvar ene9 2
}

ifvare ene9 2
{
action one
addvar countvar 1
ifvare countvar 72
{
setvar ene9 4
setvar countvar 0
}

ifvare ene9 4
{
operateactivators lotagsaved 0
action 0
getactor[THISACTOR].ang angvar
subvar angvar -1024
setactor[THISACTOR].ang angvar
setvar ene9 3
}
}

enda

useractor notenemy 8322

cstat 32768

ifaction 0 { action nul }
ifaction nul { setvar chapter1 1 setvar Black_Screen 1 setvar chapter1_2 1 setvar introme 1 action nl }
ifvare introme 1
{
addvar countvar 1
ifvare countvar 140
{
setvar introshade -100
setvar introme 2
}
}

ifvare introme 2
{
addvar introshade 1
ifvare introshade 50
{
setvar introme 0
}
}

ifvare introme 0
{
setvar chapter1 2 setvar Black_Screen 0 setvar chapter1_2 0
setplayer[THISACTOR].posx xintro
setplayer[THISACTOR].posy yintro
setplayer[THISACTOR].posz zintro
setplayer[THISACTOR].pals 0 0
setplayer[THISACTOR].pals 1 0
setplayer[THISACTOR].pals 2 0
setplayer[THISACTOR].pals_time 110
killit
}
enda  

useractor notenemy 9414 0
cstat 256
sizeat 32 32
fall
ifvare countvar 0
{
randvar angvar2 2048
setactor[THISACTOR].ang angvar2
setvar countvar 1
}
ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
}

enda

useractor notenemy 9740 0
cstat 256
sizeat 32 32
fall
ifvare countvar 0
{
randvar angvar2 2048
setactor[THISACTOR].ang angvar2
setvar countvar 1
}
ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
}

enda

useractor notenemy 4001 0
cstat 256
sizeat 32 32
fall
ifvare countvar 0
{
randvar angvar2 2048
setactor[THISACTOR].ang angvar2
setvar countvar 1
}
ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
}

enda

useractor notenemy 4003 0
cstat 256
sizeat 32 32
fall
ifvare countvar 0
{
randvar angvar2 2048
setactor[THISACTOR].ang angvar2
setvar countvar 1
}
ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
}

enda

useractor notenemy 5614 0
cstat 256
sizeat 32 32
fall
ifvare countvar 0
{
randvar angvar2 2048
setactor[THISACTOR].ang angvar2
setvar countvar 1
}
ifhitweapon
{
ifwasweapon RADIUSEXPLOSION
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
else
ifwasweapon RPG
{
state standard_jibs
state random_wall_jibs
state random_wall_jibs
state random_wall_jibs
killit
}
}

enda