

useractor notenemy TNTFLOOR TOUGH
fall sizeat 32 32 cstat 256
getactor[THISACTOR].pal pal
ifvare pal 0
{
iffloordistl 8 { spawn EXPLOSION3 } else { spawn EXPLOSION2 quake 26 }
hitradius 1024 60 100 160 300
globalsound EXPLODCM
debris SCRAP2 3
setvar detonatecount 0
killit
} else
ifvare pal 30
{
	getactorvar[THISACTOR].detonatetime tmp
	subvarvar tmp 156 mulvar tmp -1
	ifvarg tmp 0 { subvarvar tmp detonatecount }
	ifvare tmp 0
	{
		iffloordistl 8 { spawn EXPLOSION3 } else { spawn EXPLOSION2 quake 26 }
		hitradius 1024 60 100 160 300
		globalsound EXPLODCM
		debris SCRAP2 3
		setvar TNTFLOORALT 0
		setvar detonatecount 0
		killit
	}
}

ifhitweapon
{
	spawn EXPLOSION3
	hitradius 1024 60 100 160 300
	globalsound EXPLODCM
	debris SCRAP2 3
	setvar TNTFLOORALT 0
	setvar detonatecount 0
	killit
}
enda

useractor notenemy ENEMYTNTFLOOR TOUGH
	fall sizeat 32 32 cstat 256
	iffloordistl 8 { spawn EXPLOSION3 } else { spawn EXPLOSION2 quake 26 }
	hitradius 512 60 100 160 300
	globalsound EXPLODCM
	killit
enda

useractor notenemy REMOTEFLOOR TOUGH
fall sizeat 32 32 cstat 256
setactorvar[THISACTOR].active 1
ifvare peractor 0
{
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 144
	setvar green 0
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 128
	setactor[RETURN].z z
	setvar peractor 1
}
getplayer[THISACTOR].hbomb_on hbomb_on
ifvare hbomb_on 0 { setvar hbomb_on 1 state MINEEXPLODE }
ifhitweapon { state MINEEXPLODE }
enda

useractor notenemy PROXIMITYFLOOR TOUGH
fall sizeat 32 32 cstat 256
setactorvar[THISACTOR].active 1
ifvare peractor 0
{
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 0
	setvar green 144
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 128
	setactor[RETURN].z z
	setvar peractor 1
}
ifcount 52
{
	ifspritepal 0 { globalsound PROXARM spritepal 30 }
	findnearactor ZOMBIE 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor HERETIC 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor EVILHAND 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor FATRAT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor COMMANDERSTAYPUT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor RECON 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor TANK 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor PIGCOP 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor PIGCOPSTAYPUT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor PIGCOPDIVE 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor LIZMAN 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor LIZMANSTAYPUT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor LIZMANSPITTING 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor LIZMANFEEDING 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor LIZMANJUMP 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor ROTATEGUN 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor GREENSLIME 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor NEWBEAST 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor NEWBEASTSTAYPUT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor NEWBEASTJUMP 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor NEWBEASTHANG 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS1 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS1STAYPUT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS1SHOOT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS1LOB 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS2 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS3 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS4 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	findnearactor BOSS4STAYPUT 1536 tmp
	ifvarn tmp -1 { state MINEEXPLODE } else
	ifpdistl 1536 { state MINEEXPLODE }
}
ifhitweapon { state MINEEXPLODE }
enda

useractor notenemy SPRAYFLOOR TOUGH
fall sizeat 32 32 cstat 256
setactorvar[THISACTOR].active 1
ifvare peractor 0
{
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 144
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 128
	setactor[RETURN].z z
	setvar peractor 1
}
getactor[THISACTOR].pal pal
ifvare pal 0
{
espawn EXPLOSION6
setactor[RETURN].xrepeat 64
setactor[RETURN].yrepeat 64
setactor[RETURN].cstat 0
globalsound EXPLODFS
debris SCRAP2 3
setactorvar[THISACTOR].active 0
killit
} else
ifvare pal 30
{
	getactorvar[THISACTOR].detonatetime tmp
	subvarvar tmp 156 mulvar tmp -1
	ifvarg tmp 0 { subvarvar tmp detonatecount }
	ifvare tmp 0
	{
	espawn EXPLOSION6
	setactor[RETURN].xrepeat 64
	setactor[RETURN].yrepeat 64
	setactor[RETURN].cstat 0
	globalsound EXPLODFS
	debris SCRAP2 3
	setvar detonatecount 0
	setvar SPRAYFLOORALT 0
	setactorvar[THISACTOR].active 0
	killit
	}
}
ifhitweapon
{
espawn EXPLOSION6
setactor[RETURN].xrepeat 64
setactor[RETURN].yrepeat 64
setactor[RETURN].cstat 0
globalsound EXPLODFS
debris SCRAP2 3
setvar detonatecount 0
setvar SPRAYFLOORALT 0
setactorvar[THISACTOR].active 0
killit
}
enda

actor FIRE1
ifspawnedby TORCH01
{
getactor[THISACTOR].z z
ifspritepal 0 { addvar z -2944 spritepal 30 }
setactor[THISACTOR].z z
}
enda

action WATERSPLASH 0 4 1 1 7
ai AIWATERSPLASH WATERSPLASH

actor WATERDRIP2
sizeat 18 18 fall
ifspritepal 0
{
	getactor[THISACTOR].x coorx1
	getactor[THISACTOR].y coory1
	getactor[THISACTOR].z coorz1
	setactorvar[THISACTOR].peractor 96
	spritepal 30
}
ifai AIWATERSPLASH 
{ 
	ifactioncount 4	{ cstat 32768 }  
	getactorvar[THISACTOR].peractor tmp
	subvar tmp 1
	setactorvar[THISACTOR].peractor tmp
	ifvare tmp 1 
	{
		espawn WATERDRIP2 
		setactor[RETURN].pal 30 
		setactor[RETURN].x coorx1 
		setactor[RETURN].y coory1 
		setactor[RETURN].z coorz1 
		setactorvar[RETURN].coorx1 coorx1 
		setactorvar[RETURN].coory1 coory1 
		setactorvar[RETURN].coorz1 coorz1 
		setactorvar[RETURN].peractor 96
		killit 
	}
}
else iffloordistl 1 { ai AIWATERSPLASH ifpdistl 4096 ifcansee globalsound DRIP1 }
enda

action WATERSPLASH_2 -11 4 1 1 7
ai AIWATERSPLASH_2 WATERSPLASH_2

actor WATERDRIP3
sizeat 24 24 fall
ifspritepal 0
{
	getactor[THISACTOR].x coorx1
	getactor[THISACTOR].y coory1
	getactor[THISACTOR].z coorz1
	setactorvar[THISACTOR].peractor 96
	spritepal 30
}
ifai AIWATERSPLASH_2
{ 
	ifactioncount 4	{ cstat 32768 }  
	getactorvar[THISACTOR].peractor tmp
	subvar tmp 1
	setactorvar[THISACTOR].peractor tmp
	ifvare tmp 1 
	{
		espawn WATERDRIP3 
		setactor[RETURN].pal 30 
		setactor[RETURN].x coorx1 
		setactor[RETURN].y coory1 
		setactor[RETURN].z coorz1 
		setactorvar[RETURN].coorx1 coorx1 
		setactorvar[RETURN].coory1 coory1 
		setactorvar[RETURN].coorz1 coorz1 
		setactorvar[RETURN].peractor 96
		killit 
	}
}
else iffloordistl 1 { ai AIWATERSPLASH_2 ifpdistl 4096 ifcansee globalsound DRIP1 }
enda

useractor notenemy TORCH01
ifspritepal 0 
{ 
	setactorvar[THISACTOR].active 1
	espawn FIRE1
	setactor[RETURN].cstat 128
	setactor[RETURN].xrepeat 18
	setactor[RETURN].yrepeat 18
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 144
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 4096
	setactor[RETURN].z z
	espawn MUSICANDSFX
	setactor[RETURN].lotag 492
	setactor[RETURN].hitag 2048
	spritepal 30 
}
enda

useractor notenemy LIGHTER1
ifspritepal 0 
{ 
	setactorvar[THISACTOR].active 1
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 144
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 8192
	setactor[RETURN].z z
	spritepal 30 
}
enda

useractor notenemy LIGHTER2
ifspritepal 0 
{ 
	setactorvar[THISACTOR].active 1
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 144
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 4096
	setactor[RETURN].z z
	spritepal 30 
}
enda

useractor notenemy KEYICON1
ifspritepal 0 
{ 
	setactorvar[THISACTOR].active 1
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 255
	setvar blue 255
	state spawnlight
	spritepal 30 
}
enda

useractor notenemy KEYICON4
ifspritepal 0 
{ 
	setactorvar[THISACTOR].active 1
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 255
	setvar blue 255
	state spawnlight
	spritepal 30 
}
enda

useractor notenemy 5760
ifspritepal 0 
{ 
	setactorvar[THISACTOR].active 1
	espawn SMALLSMOKE
	setvar light_radius 1024
	setvar red 255
	setvar green 144
	setvar blue 0
	state spawnlight
	getactor[THISACTOR].z z
	subvar z 8192
	setactor[RETURN].z z
	spritepal 30 
}
enda

useractor notenemy ZHEADFLOOR
cstat 257 sizeat 32 32
fall
		
ifpdistl 812 
{ 
	getactorvar[THISACTOR].active peractor
	ifp prunning { setprojectile[ZOMBIEHEAD].vel 800 ezshoot 4096 ZOMBIEHEAD sound BDYPTIM2 } else 
	{ setprojectile[ZOMBIEHEAD].vel 600 ezshoot 2048 ZOMBIEHEAD sound BDYPTIM2 } 
	setactorvar[RETURN].active peractor
	killit 
}
ifhitweapon { killit }
enda

action TREE3_BURNING 2809 10 1 1 12
ai AITREE3BURNING TREE3_BURNING
useractor notenemy CHARRYBOLE WEAK fall cstat 385 sizeat 32 32
ifhitweapon { guts JIBS1 20 killit }
enda

useractor notenemy TREE3 WEAK fall cstat 385 sizeat 32 32
ifhitweapon 
{ 
	ifwasweapon RADIUSEXPLOSION { ai AITREE3BURNING } 
	else ifwasweapon RPG { ai AITREE3BURNING } 
	else ifwasweapon FIREEXT { ai AITREE3BURNING }
	else strength WEAK 
}
ifai AITREE3BURNING { ifactioncount 10 { spawn CHARRYBOLE killit } }
enda

//Inventory and items code

spritenopal AKIMBOITEM
useractor notenemy AKIMBOITEM
fall
sizeat 30 30 
getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	ifvare AKIMBOTIME 0
	{
			setvar AKIMBOTIME 780
			setvar activeakimbo 1
	        quote 131 globalsound PICKAMMO
	        ifspawnedby AKIMBOITEM state getcode
	        else state quikget

	}  
}
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal HEART
useractor notenemy HEART 0 FRAME_FRAME1
fall
sizeat 30 30 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 128
 ifmove RESPAWN_ACTOR_FLAG state respawnit
 else ifp pshrunk nullop else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifphealthl MAXPLAYERHEALTH ifcanseetarget
   {
        addphealth 20
        quote 130 globalsound PICKHEAL
        ifspawnedby HEART state getcode
        else state quikget
   }  
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal LIFESEED
useractor notenemy LIFESEED fall sizeat 30 30 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit else ifp pshrunk nullop else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
      {
		getplayer[THISACTOR].i r0
        getactor[r0].extra extra
        addvar extra 100
		ifvarg extra 200 { setvar extra 200 } 
		{
             setactor[r0].extra extra
             quote 141 globalsound PICKHEAL
         	 ifspawnedby LIFESEED state getcode
		     else state quikget
		}
      }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal MEDICINEBAG
useractor notenemy MEDICINEBAG
fall sizeat 30 30 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit else ifp pshrunk nullop else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifphealthl MAXPLAYERHEALTH ifcanseetarget
      {
        addphealth 50
        quote 164 globalsound PICKHEAL
        ifspawnedby MEDICINEBAG state getcode
        else state quikget
   }  
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal FLAREPISTOL
useractor notenemy FLAREPISTOL
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
	    ifgotweaponce 0 break
        addweapon 1 9
		quote 138 globalsound PICKWEPN
        ifspawnedby FLAREPISTOL state getweaponcode
        else state quikweaponget
    }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal SAWED-OFF
useractor notenemy SAWED-OFF
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
	    ifgotweaponce 0 break
        addweapon 2 8
		quote 154 globalsound PICKWEPN
        ifspawnedby SAWED-OFF state getweaponcode
        else state quikweaponget
    }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal TOMMY
useractor notenemy TOMMY
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		ifgotweaponce 0 break
        addweapon 3 50
		quote 156 globalsound PICKWEPN
        ifspawnedby TOMMY state getweaponcode
        else state quikweaponget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal NAPALMLAUCHER
useractor notenemy NAPALMLAUCHER
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		ifgotweaponce 0 break
        addweapon 4 6
		quote 147 globalsound PICKWEPN
        ifspawnedby NAPALMLAUCHER state getweaponcode
        else state quikweaponget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

spritenopal PROXIMITYMINE
useractor notenemy PROXIMITYMINE
fall sizeat 32 32
getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	ifvarl PROXIMITYMINE_AMMOAMOUNT 50
	{
		ifgotweaponce 0 break
		setplayer[THISACTOR].gotweapon 5 1
		addammo 5 1
		ifvare PROXIMITYMINE_AMMOAMOUNT 0 { ifinwater nullop else { setvar changeweappos 2 setplayer[THISACTOR].weapon_pos -1 } }
		addvar PROXIMITYMINE_AMMOAMOUNT 1
	    quote 153
	    ifspawnedby PROXIMITYMINE state getcode
	    else state quikget
	}
}
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy REMOTETNT
fall sizeat 32 32
state rotatestate
getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	ifvarl REMOTETNT_AMMOAMOUNT 50
	{
		ifgotweaponce 0 break
		setplayer[THISACTOR].gotweapon 5 1
		addammo 5 1
		ifvare REMOTETNT_AMMOAMOUNT 0 { ifinwater nullop else { setvar changeweappos 3 setplayer[THISACTOR].weapon_pos -1 } }
		addvar REMOTETNT_AMMOAMOUNT 1
	    quote 151
	    ifspawnedby REMOTETNT state getcode
	    else state quikget
	}
}
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy TNTSPRITE
fall sizeat 32 32
state rotatestate
getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	ifvarl TNT_AMMOAMOUNT 50
	{
		ifgotweaponce 0 break
		setplayer[THISACTOR].gotweapon 5 1
		addammo 5 1
		ifvare TNT_AMMOAMOUNT 0 { ifinwater nullop else { setvar changeweappos 1 setplayer[THISACTOR].weapon_pos -1 } }
		addvar TNT_AMMOAMOUNT 1
	    quote 139
	    ifspawnedby TNTSPRITE state getcode
	    else state quikget
	}
}
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy CASEOFTNT
fall sizeat 32 32
getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	ifvarl TNT_AMMOAMOUNT 50
	{
		ifgotweaponce 0 break
		setplayer[THISACTOR].gotweapon 5 1
		addammo 5 1
		ifvare TNT_AMMOAMOUNT 0	{ ifinwater nullop else { setvar changeweappos 1 setplayer[THISACTOR].weapon_pos -1 } }
		addvar TNT_AMMOAMOUNT 5
	    quote 150
	    ifspawnedby CASEOFTNT state getcode
	    else state quikget
	}
}
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy SPRAYSPRITE
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		ifgotweaponce 0 break
        addweapon 6 48
		quote 160 globalsound PICKAMMO
        ifspawnedby SPRAYSPRITE state getweaponcode
        else state quikweaponget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy TESLACANNON
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		ifgotweaponce 0 break
        addweapon 7 64
		quote 162 globalsound PICKWEPN
        ifspawnedby TESLACANNON state getweaponcode
        else state quikweaponget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy VOODOOSPRITE
fall sizeat 32 32
state rotatestate
getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		ifgotweaponce 0 break
        addweapon 9 100
		quote 161 globalsound PICKWEPN
        ifspawnedby VOODOOSPRITE state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy FLARESBOX
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 1 8
        quote 148 globalsound PICKAMMO
        ifspawnedby FLARESBOX state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy BOXOFSHELLS
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 2 15
        quote 149 globalsound PICKAMMO
        ifspawnedby BOXOFSHELLS state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy FEWSHELLS
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 2 4
        quote 155 globalsound PICKAMMO
        ifspawnedby FEWSHELLS state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy DRUMOFBULLET
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 3 100
        quote 146 globalsound PICKAMMO
        ifspawnedby DRUMOFBULLET state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy FEWBULLETS
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 3 15
        quote 152 globalsound PICKAMMO
        ifspawnedby FEWBULLETS state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy GASOLINE
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 4 6
        quote 157 globalsound PICKAMMO
        ifspawnedby GASOLINE state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy TESLACHARGE
fall sizeat 24 24 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 7 32
        quote 158 globalsound PICKAMMO
        ifspawnedby TESLACHARGE state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy TRAPPEDSOUL
fall sizeat 16 16 getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 8 10
        quote 159 globalsound PICKAMMO
        ifspawnedby TRAPPEDSOUL state getcode
        else state quikget
    }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy HELLSTAFF
sizeat 32 32 fall
getactor[THISACTOR].hitag HITAGSAVED
ifvare HITAGSAVED 0 // Hellstaff item
{
state rotatestate
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
	    ifgotweaponce 0 break
        addweapon 8 35
		quote 138 globalsound PICKWEPN
        ifspawnedby HELLSTAFF state getweaponcode
        else state quikweaponget
    }
}
ifvare HITAGSAVED 1 // Alt-fire hellstaff
{
	ifspritepal 0 { setvar hellextra 500 spritepal 30 }
	ifp palive
	ifpdistl RETRIEVEDISTANCE
	ifp pfacing
	ifhitspace
	ifcansee
	{
		getactor[THISACTOR].lotag tmp
		addweapon 8 0
		setplayer[THISACTOR].ammo_amount 8 tmp
		killit
	}
	setvar spriteid 0
	whilevarn spriteid 16384
	{
		ldist xydist THISACTOR spriteid
		ifvarvarl xydist STAFFDIST 
		{
			getactor[spriteid].picnum picnum
			getactorvar[THISACTOR].friend_id perplayer
			switch picnum
				case ZOMBIE
				case HERETIC
				case BAT
				case COMMANDER
				case RECON
				case TANK
				case PIGCOP
				case LIZMAN
				case ROTATEGUN
				case GREENSLIME
				case NEWBEAST
				case BOSS1
				case BOSS2
				case BOSS3
				case BOSS4
				case APLAYER
				ifvarvarn spriteid perplayer { state staff_fire }
				break
			endswitch
		}
		addvar spriteid 1
	}
	ifvarl hellextra 0 { debris SCRAP2 3 killit }
}
	
enda


useractor notenemy BEASTVISION
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
        ifvarl BEASTVISIONAM 1200
        {
        setvar BEASTVISIONAM 1200
        getplayer[THISACTOR].inven_icon tmp
        ifvare tmp 0 { setplayer[THISACTOR].inven_icon 11 }
        quote 126 globalsound PICKUP
        ifspawnedby BEASTVISION state getcode
        else state quikget
        }
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }
enda

useractor notenemy DOCTORSBAG
fall getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
        ifvarl DOCTORSBAGAM MAXPLAYERHEALTH
        {
        setvar DOCTORSBAGAM MAXPLAYERHEALTH
        getplayer[THISACTOR].inven_icon tmp
        ifvare tmp 0 { setplayer[THISACTOR].inven_icon 8 }
        quote 125 globalsound PICKUP
        ifspawnedby DOCTORSBAG state getcode
        else state quikget
        }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }		
enda

useractor notenemy DIVINGSUIT
fall getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
        ifvarl DIVINGSUITAM 1200
        {
        setvar DIVINGSUITAM 1200
        getplayer[THISACTOR].inven_icon tmp
        ifvare tmp 0 { setplayer[THISACTOR].inven_icon 9 }
        quote 127 globalsound PICKUP
        ifspawnedby DIVINGSUIT state getcode
        else state quikget
        }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }		
enda

useractor notenemy CRYSTALLBALL
fall getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0

ifmultiplayer
{
	ifmove RESPAWN_ACTOR_FLAG state respawnit
	else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
        ifvarl CRYSTALLBALLAM 1200
        {
        setvar CRYSTALLBALLAM 1200
        getplayer[THISACTOR].inven_icon tmp
        ifvare tmp 0 { setplayer[THISACTOR].inven_icon 10 }
        quote 129 globalsound PICKUP
        ifspawnedby CRYSTALLBALL state getcode
        else state quikget
        }	
} 
else 
{
	getactor[THISACTOR].pal pal
	ifvare pal 1 { setactor[THISACTOR].pal 0 } else killit
}
enda

useractor notenemy BOOTSOFJUMPING
fall getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
        ifvarl BOOTSOFJUMPINGAM 1200
        {
        setvar BOOTSOFJUMPINGAM 1200
        getplayer[THISACTOR].inven_icon tmp
        ifvare tmp 0 { setplayer[THISACTOR].inven_icon 12 }
        quote 128 globalsound PICKUP
        ifspawnedby BOOTSOFJUMPING state getcode
        else state quikget
        }
}
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }		
enda

useractor notenemy BODYARMOR
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
		getactorvar[r0].bodyshield BODYSHIELD_AMOUNT
        ifvarl BODYSHIELD_AMOUNT 100
        {
		addvar BODYSHIELD_AMOUNT 100
		ifvarg BODYSHIELD_AMOUNT 100 { setvar BODYSHIELD_AMOUNT 100 }
		setactorvar[r0].bodyshield BODYSHIELD_AMOUNT
        quote 140 globalsound PICKARMR
        ifspawnedby BODYARMOR state getcode
		else state quikget
		}
}
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

useractor notenemy FIREARMOR
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	getactorvar[r0].fireshield FIRESHIELD_AMOUNT
	ifvarl FIRESHIELD_AMOUNT 100
	{
        addvar FIRESHIELD_AMOUNT 100
        ifvarg FIRESHIELD_AMOUNT 100 { setvar FIRESHIELD_AMOUNT 100 }
		setactorvar[r0].fireshield FIRESHIELD_AMOUNT
        quote 142 globalsound PICKARMR
        ifspawnedby FIREARMOR state getcode
		else state quikget
        }
}
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

useractor notenemy SPIRITARMOR
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{	
	getactorvar[r0].spiritshield SPIRITSHIELD_AMOUNT
	ifvarl SPIRITSHIELD_AMOUNT 100
	{
        addvar SPIRITSHIELD_AMOUNT 100
        ifvarg SPIRITSHIELD_AMOUNT 100 { setvar SPIRITSHIELD_AMOUNT 100 }
		setactorvar[r0].spiritshield SPIRITSHIELD_AMOUNT
        quote 165 globalsound PICKARMR
        ifspawnedby SPIRITARMOR state getcode
		else state quikget
    }
}
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

useractor notenemy SUPERARMOR
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		setactorvar[r0].bodyshield 200
		setactorvar[r0].fireshield 200
		setactorvar[r0].spiritshield 200
        quote 144 globalsound PICKARMR
        ifspawnedby SUPERARMOR state getcode
		else state quikget
    }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

useractor notenemy BASICARMOR
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
		getactorvar[r0].bodyshield BODYSHIELD_AMOUNT
		getactorvar[r0].fireshield FIRESHIELD_AMOUNT
		getactorvar[r0].spiritshield SPIRITSHIELD_AMOUNT
        ifvarl BODYSHIELD_AMOUNT 50 { setvar BODYSHIELD_AMOUNT 50 }
		ifvarl FIRESHIELD_AMOUNT 50 { setvar FIRESHIELD_AMOUNT 50 }
		ifvarl SPIRITSHIELD_AMOUNT 50 { setvar SPIRITSHIELD_AMOUNT 50 }
		setactorvar[r0].bodyshield BODYSHIELD_AMOUNT
		setactorvar[r0].fireshield FIRESHIELD_AMOUNT
		setactorvar[r0].spiritshield SPIRITSHIELD_AMOUNT
		quote 166 globalsound PICKARMR
        ifspawnedby BASICARMOR state getcode
		else state quikget
}
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

useractor notenemy SKULLKEY
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0 sizeat 24 24
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_SKULLKEY 1
		quote 131 globalsound PICKKEY
        ifspawnedby SKULLKEY state getcode
        else state quikget
    }
enda

useractor notenemy EYEKEY
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0 
sizeat 24 24
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_EYEKEY 1
		quote 132 globalsound PICKKEY
        ifspawnedby EYEKEY state getcode
        else state quikget
    }	
enda

useractor notenemy FIREKEY
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
 sizeat 24 24
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_FIREKEY 1
		quote 133 globalsound PICKKEY
        ifspawnedby FIREKEY state getcode
        else state quikget
    }	
enda

useractor notenemy DAGGERKEY
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
 sizeat 24 24
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_DAGGERKEY 1
		quote 134 globalsound PICKKEY
        ifspawnedby DAGGERKEY state getcode
        else state quikget
    }
enda

useractor notenemy SPIDERKEY
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
 sizeat 24 24
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_SPIDERKEY 1
		quote 135 globalsound PICKKEY
        ifspawnedby SPIDERKEY state getcode
        else state quikget
    }
enda

useractor notenemy MOONKEY
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
 sizeat 24 24
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_MOONKEY 1
		quote 136 globalsound PICKKEY
        ifspawnedby MOONKEY state getcode
        else state quikget
    }
enda

useractor notenemy DEATHMASK 
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 0
sizeat 24 24
ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar DEATHMASK_ON 1
        quote 145
        ifspawnedby DEATHMASK state getcode
        else state quikget
    }
enda

useractor notenemy REFLSHOOTITEM
fall getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 128
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
		getplayer[THISACTOR].i PLAYERID
		setactorvar[PLAYERID].reflective 1
		setvar REFLTIME 0
		quote 143 globalsound POWERUP
        ifspawnedby REFLSHOOTITEM state getcode
        else state quikget
    }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

useractor notenemy PREFLBALL
	cstat 514 sizeat 58 48
	getactorvar[THISACTOR].spriteid tmp
	getactorvar[tmp].reflective tmp2
	getactor[tmp].x x
	getactor[tmp].y y
	getactor[tmp].z z
	getactor[tmp].ang ang
	setvarvar x2 x
	addvar x2 -150
	rotatepoint x y x2 y ang x3 y3
	setactor[THISACTOR].x x3
	setactor[THISACTOR].y y3
	setactor[THISACTOR].z z
	ifvare tmp2 0 { killit }
enda

useractor notenemy INVISIBLEITEM
fall getactor[THISACTOR].cstat acstat
ifvarl acstat 0 nullop else setactor[THISACTOR].cstat 514
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
		getplayer[THISACTOR].i PLAYERID
		setactorvar[PLAYERID].invisible 1
		setvar REFLTIME 0
		quote 143 globalsound POWERUP
        ifspawnedby INVISIBLEITEM state getcode
        else state quikget
    }
	getactor[THISACTOR].pal pal
	ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit }	
enda

// New Lock system ( LOCKER )

eventloadactor LOCKER
	getactor[THISACTOR].hitag HITAGSET
	espawn ACTIVATOR 
	setactor[RETURN].lotag HITAGSET
	setactor[THISACTOR].hitag 0
	  
	getactor[THISACTOR].sectnum sectorid
	getsector[sectorid].wallptr wallptr
	getsector[sectorid].wallnum wallnum
	
	setvar tmp 0
	ifvarl wallnum 1 break
	whilevarvarn tmp wallnum
	{
		ifvarl HITAGSET 7 { setwall[wallptr].hitag HITAGSET } else
		{
			ifvarvarg HITAGSET 6 ifvarvarl HITAGSET 101
			{
				getwall[wallptr].hitag wallhitag
				ifvarvarn wallhitag HITAGSET { setwall[wallptr].hitag 100 }
			} 
			else 
			{
				getwall[wallptr].hitag wallhitag
				ifvarvarn wallhitag HITAGSET { setwall[wallptr].hitag 200 }
			}
		}
		addvar wallptr 1
		addvar tmp 1
	}
    cstat 32768
enda

useractor notenemy LOCKER 0 DELAY1	
getactor[THISACTOR].pal pal
ifvare pal 1
{
	ifvarn HITWALL -1
	{
		getwall[HITWALL].nextwall wallid
		ifvarn wallid -1 { getwall[wallid].hitag HITAG } else setvar HITAG 0
		ifvarg HITAG 0 ifvarl HITAG 201
		{
			getplayer[THISACTOR].posx px
			getplayer[THISACTOR].posy py
			getplayer[THISACTOR].posy pz
			subvarvar HITX px
			subvarvar HITY py
			mulvarvar HITX HITX
			mulvarvar HITY HITY
			addvarvar HITX HITY
			sqrt HITX WALLDIST
		} else setvar WALLDIST -1
	} else { setvar WALLDIST -1 setvar HITAG 0 }

	ifvarg HITAGSET 100
	{
		setvar spriteid 0
		setvar enemycount 0
		whilevarn spriteid 16384
		{
			getactor[spriteid].picnum picnum
			switch picnum
			case ZOMBIE
			case HERETIC
				getactorvar[spriteid].w_enemyhitag r_enemyhitag
				ifvarvare r_enemyhitag HITAGSET addvar enemycount 1
			break
			endswitch
			addvar spriteid 1
		}
		ifvare enemycount 0
		ifvare peractor 0
		{
			operateactivators HITAGSET THISACTOR
			action DELAY2
			setvar peractor 1
		}
	}
				
	ifvarl WALLDIST 1278
	{ 
		ifhitspace
		{
			ifaction DELAY1
			{
				ifvarvarn VAR_SKULLKEY 1
				ifvarvare HITAG 1
				{
			        quote 137
			        soundonce 473
			        action DELAY2
			    }
				ifvarvarn VAR_EYEKEY 1
				ifvarvare HITAG 2
				{
				    quote 137
					soundonce 473
				    action DELAY2
				}
				ifvarvarn VAR_FIREKEY 1
				ifvarvare HITAG 3
				{
				    quote 137
				    soundonce 473
				    action DELAY2
				}
				ifvarvarn VAR_DAGGERKEY 1
				ifvarvare HITAG 4
				{
				    quote 137
					soundonce 473
				    action DELAY2
				}
				ifvarvarn VAR_SPIDERKEY 1
				ifvarvare HITAG 5
				{
				    quote 137
					soundonce 473
				    action DELAY2
				}
				ifvarvarn VAR_MOONKEY 1
				ifvarvare HITAG 6
				{
				    quote 137
					soundonce 473
				    action DELAY2
				}
				ifvarvare HITAG 100 // Открывается только со стороны, которая имеет hitag = locker hitag (заблокированная сторона имеет hitag = 100...hitag ставить с внутренней стороны сектора!!!)
				{
				    quote 168
				    soundonce 538
				    action DELAY2
				}
				ifvarvare HITAG 200 // Открывается только со стороны, которая имеет hitag = locker hitag (заблокированная сторона имеет hitag = 200...hitag ставить с внутренней стороны сектора!!!)
				ifvarvarg enemycount 0 // счетчик мостров (для locker hitag > 100
				{
				    quote 168
				    soundonce 538
				    action DELAY2
				}
				ifvare enemycount 0
				ifvarg HITAGSET 100
				{
					getactor[THISACTOR].sectnum sectorid
					getsector[sectorid].wallptr wallptr
					getsector[sectorid].wallnum wallnum
					
					setvar tmp 0
					ifvarl wallnum 1 break
					whilevarvarn tmp wallnum
					{
						getwall[wallptr].hitag wallhitag
						ifvarvarn wallhitag HITAGSET { setwall[wallptr].hitag HITAGSET }
						addvar wallptr 1
						addvar tmp 1
					}
				}
			}
			ifaction DELAY1
			ifvarvare HITAG HITAGSET
			{
				operateactivators HITAGSET THISACTOR
				action DELAY2
			}
		}
		else
		ifaction DELAY2
		action DELAY1
	}

}
enda

action ABLOODSPARK 0 4 1 1 4
actor BLOODSPARK1 
cstat 4 sizeat 32 32
ifaction 0 action ABLOODSPARK
ifactioncount 4 killit
enda

eventloadactor HCHECK
	getactor[THISACTOR].hitag HITAGSET
	setactor[THISACTOR].hitag 0
    cstat 32768
enda

useractor notenemy HCHECK 0 DELAY1	
findnearactor3d ZHEADFLOOR 2048 spriteid
ifvarn spriteid -1 
{
	canseespr THISACTOR spriteid see
	ifvare see 1 
	{
		getactorvar[spriteid].active tmp
		ifvare tmp 0 { getactorvar[THISACTOR].numbofhead tmp addvar tmp 1 setactorvar[THISACTOR].numbofhead tmp setactorvar[spriteid].active 1 }
	}
	getactorvar[THISACTOR].numbofhead tmp
	ifvarg tmp 2 
	ifaction DELAY1
	{
		sound 8
		operateactivators HITAGSET THISACTOR
		action DELAY2
	}
}

enda

eventloadactor BCHECK
	getactor[THISACTOR].hitag HITAGSET
	setactor[THISACTOR].hitag 0
    cstat 32768
enda

useractor notenemy BCHECK 0 DELAY1	
getactorvar[THISACTOR].active tmp
ifvarg tmp 3
ifaction DELAY1
{
	sound 8
	operateactivators HITAGSET THISACTOR
	action DELAY2
}
enda

eventloadactor BL_BUTTON1
{
    getactor[THISACTOR].hitag HITAGSAVED
    getactor[THISACTOR].lotag LOTAGSAVED
    setactor[THISACTOR].hitag 0
    setactor[THISACTOR].lotag 0
}
enda

actor BL_BUTTON1
state KEYSWITCH
enda

eventloadactor MULTIBUTTON
{
    getactor[THISACTOR].hitag HITAGSAVED
    getactor[THISACTOR].lotag LOTAGSAVED
    setactor[THISACTOR].hitag 0
    setactor[THISACTOR].lotag 0
}
enda

actor MULTIBUTTON
getactor[THISACTOR].pal buttonpal
ifpdistl 1024 ifp palive ifp pfacing ifcansee ifhitspace ifcount 13
{
    sound QLATCH2
	ifaction 0 { action ONE } else ifaction ONE { action TWO } 
	else ifaction TWO { action THREE } else ifaction THREE { action FOUR } 
	else ifaction FOUR { action FIVE } else ifaction FIVE { action 0 }
	
	ifvare HITAGSAVED 1 ifaction 0 { setactorvar[THISACTOR].active 1 } else 
	ifvare HITAGSAVED 2 ifaction ONE { setactorvar[THISACTOR].active 1 } else
	ifvare HITAGSAVED 3 ifaction TWO { setactorvar[THISACTOR].active 1 } else
	ifvare HITAGSAVED 4 ifaction THREE { setactorvar[THISACTOR].active 1 } else
	ifvare HITAGSAVED 5 ifaction FOUR { setactorvar[THISACTOR].active 1 } else
	ifvare HITAGSAVED 6 ifaction FIVE { setactorvar[THISACTOR].active 1 } else setactorvar[THISACTOR].active 0
	
	setvar spriteid 1
	setvar buttonnum 0
	setvar SUMM 0
	whilevarn spriteid 16384
	{
		getactor[spriteid].picnum picnum
		getactor[spriteid].pal pal
		ifvare picnum MULTIBUTTON
		ifvarvare pal buttonpal
		{
			getactorvar[spriteid].active peractor
			addvarvar SUMM peractor
			addvar buttonnum 1
		}
		addvar spriteid 1
	}
	
	ifvarvare SUMM buttonnum 
	{       
		operateactivators LOTAGSAVED THISACTOR
		operaterespawns LOTAGSAVED
		operatemasterswitches LOTAGSAVED 
	}
    resetcount
}
stopsound DUKE_SEARCH
stopsound DUKE_SEARCH2
enda

// Breakobjects code
// Thanks to Eddy Zikov for this code

actor DROPPER1 state drippercode enda
actor DROPPER2 state drippercode enda
actor DROPPER3 state drippercode enda
actor 5828 enda
actor 5767 enda
actor BEERBOTTLE cstat 257 state bottlecode enda
actor BOTTLE01 TOUGH state bottlecode enda
actor BOTTLE02 TOUGH state bottlecode enda
actor BOTTLE03 TOUGH state bottlecode enda
actor BOTTLE04 TOUGH state bottlecode enda
actor LAMP01 state bottlecode enda
actor LAMP02 state bottlecode enda
actor BANK01 state bottlecode enda
actor BANK02 state bottlecode enda
actor VASE1 state vasecode enda
actor VASE2 state vasecode enda
actor VASE3 state vasecode enda
actor VASE4 state vasecode enda
actor VASE5 state vasecode enda
actor RACK1 state rackcode enda
actor RACK2 state rackcode enda
actor RACK3 fall cstat 257
ifhitweapon { state leafs_state sound GLASS_HEAVYBREAK killit } enda
actor RACK4 state rackcode2 enda
actor RACK5 state rackcode2 enda
actor RACK6 state rackcode2 enda
actor RACK7 state rackcode2 enda
actor RACK8 state rackcode2 enda
actor RACK9 state rackcode2 enda
actor RACK10 state rackcode2 enda
actor RACK11 state rackcode2 enda
actor RACK12 state rackcode2 enda

actor JECK TOUGH
fall cstat 257
ifhitweapon { ifdead { lotsofglass 20 state squishcode sound GLASS_BREAKING killit } else { guts JIBS6 5 lotsofglass 10 } }
enda

actor VASE6 fall cstat 257
ifhitweapon 
{ 
	lotsofglass 20 
	setprojectile[NEWSCRAP1].pal 6
	state sparkstate 
	state sparkstate 
	state sparkstate 
	state sparkstate 
	state sparkstate 
	state sparkstate 
	state sparkstate 
	state sparkstate 
	sound GLASS_BREAKING 
	killit 
} 
enda

actor BVASE cstat 257
ifhitweapon { debris SCRAP5 10 sound GLASS_HEAVYBREAK spawn BURNING killit }
enda

actor MEAT1 fall cstat 257
ifhitweapon { state squishcode killit }
enda

actor MEAT2 fall cstat 257
ifhitweapon { state squishcode killit }
enda

move AIRBALLSPEED 10 -100
actor AIRBALL cstat 257
ifhitweapon { debris SCRAP3 8 killit }
ifpdistl 1000 ifcansee ifhitspace { move AIRBALLSPEED geth }
ifceilingdistl 10 { debris SCRAP3 8 killit } 
enda

actor DEADMAN1 fall cstat 257
ifhitweapon { state jibs_state killit }
enda

actor DEADMAN2 fall cstat 257
ifhitweapon { state jibs_state killit }
enda

actor DEADMAN3 fall cstat 257
ifhitweapon { state jibs_state killit }
enda

actor DEADMAN4 TOUGH cstat 273
ifhitweapon { ifdead { state jibs_state killit } else { guts JIBS6 5 sound DUKE_GRUNT } }
enda

actor DEADMAN5 TOUGH cstat 273
ifhitweapon { ifdead { state jibs_state killit } else { guts JIBS6 5 sound DUKE_GRUNT } }
enda


actor DEADLADY TOUGH cstat 273
ifhitweapon { ifdead { state jibs_state killit } else { guts JIBS6 5 sound LADY_SCREAM } }
enda

actor DEADDOG cstat 257
ifhitweapon { state jibs_state killit } //state squishcode
enda

actor MANHEAD fall cstat 257
ifhitweapon { state jibs_state killit }
enda

actor BRAIN1
fall cstat 257
ifhitweapon { lotsofglass 20 sound GLASS_BREAKING state squishcode killit }
enda

actor BRAIN2
fall cstat 257
ifhitweapon { lotsofglass 20 sound GLASS_BREAKING state squishcode killit }
enda

actor TOXICBARREL
fall cstat 257
ifhitweapon { debris SCRAP1 20 sound VENT_BUST killit }
enda

actor WINEGLASS1
cstat 257
ifhitweapon { lotsofglass 10 spawn BLOODPOOL sound GLASS_BREAKING killit }
enda

actor WINEGLASS2
cstat 257
ifhitweapon { lotsofglass 10 sound GLASS_BREAKING killit }
enda

actor WINEGLASS3
cstat 257
ifhitweapon { lotsofglass 10 spawn BLOODPOOL sound GLASS_BREAKING killit }
enda
 
actor COOKER
fall cstat 257
ifhitweapon { debris SCRAP1 2 sound GLASS_HEAVYBREAK killit }
enda

actor EWER
fall cstat 257
ifhitweapon { lotsofglass 20 debris SCRAP5 5 sound GLASS_BREAKING killit }
enda

actor MAETBARREL1
fall cstat 257
ifhitweapon { state squishcode debris SCRAP1 2 sound VENT_BUST killit }
enda

actor MAETBARREL2
fall cstat 257
ifhitweapon { state squishcode debris SCRAP1 2 sound VENT_BUST killit }
enda

actor SKULL1
fall cstat 257
ifhitweapon { lotsofglass 20 debris SCRAP5 5 sound GLASS_HEAVYBREAK killit }
enda

actor TNTBARREL
fall cstat 257
ifhitweapon { debris SCRAP1 20 sound PIPEBOMB_EXPLODE spawn EXPLOSION2 spawn EXPLOSION4 spawn EXPLOSION5 hitradius 2500 50 70 90 110 killit }
enda

actor BARREL
fall cstat 257
ifhitweapon { debris SCRAP1 20 sound GLASS_HEAVYBREAK killit }
enda

action GRIDA1 0 0 0 0 0
action BGRIDA1 1 0 0 0 0
actor GRID1
ifaction 0 { cstat 273 action GRIDA1 } 
ifaction GRIDA1 ifhitweapon { cstat 16 action BGRIDA1 debris SCRAP1 5 sound VENT_BUST }
enda

action GRIDA2 0 0 0 0 0
action BGRIDA2 1 0 0 0 0
actor GRID2 
ifaction 0 { cstat 273 action GRIDA2 } 
ifaction GRIDA2 ifhitweapon { cstat 16 action BGRIDA2 debris SCRAP1 5 sound VENT_BUST }
enda

action MIRROR1 0 0 0 0 0
action BMIRROR1 1 0 0 0 0
actor MIRROR01 
ifaction 0 { cstat 273 action MIRROR1 } 
ifaction MIRROR1 ifhitweapon { cstat 16 action BMIRROR1 lotsofglass 20 debris SCRAP1 2 sound GLASS_BREAKING }
enda

action FANA2 0 0 0 0 0
action BFANA2 3 0 0 0 0
actor FAN01 
ifaction 0 { cstat 273 action FANA2 } 
ifaction FANA2 ifhitweapon { cstat 16 action BFANA2 debris SCRAP1 5 sound GLASS_HEAVYBREAK }
enda

action ABLOODCLOCK1 0 0 0 0 0
action ABLOODCLOCK2 1 0 0 0 0
actor BLOODCLOCK
ifaction 0 { cstat 273 action ABLOODCLOCK1 } 
ifaction ABLOODCLOCK1 ifhitweapon { cstat 16 action ABLOODCLOCK2 debris SCRAP1 5 sound GLASS_HEAVYBREAK }
enda

action PAIL1 0 0 0 0 0
action PAILKICKED 1 1 1 1 1

move PKICK1 -300
move PKICK2 300

ai AIPAIL1 PAIL1
ai AIPAIL2 PAILKICKED PKICK1 jumptoplayer
ai AIPAIL3 PAILKICKED PKICK2 geth

actor PAIL TOUGH
cstat 257 fall
ifai NO { strength 20 sizeat 48 48 cstator 257 ai AIPAIL1 }
else { ifp pfacing ifpdistl 1048 { ai AIPAIL2 soundonce ENDSEQVOL2SND4 } }
ifai AIPAIL2 ifnotmoving { sound ENDSEQVOL2SND4 ai AIPAIL3 }
ifai AIPAIL2 ifcount 50 ai AIPAIL1
ifai AIPAIL3 ifcount 50 ai AIPAIL1
ifhitweapon { ifdead { debris SCRAP1 10 sound VENT_BUST killit } else { ai AIPAIL2 debris SCRAP1 5 sound VENT_BUST } }
enda

actor MIM TOUGH state enemyeffects
fall cstat 257
ifhitweapon { ifwasweapon RPG { addkills 1 spawn BURNINGGUY killit } else ifwasweapon RADIUSEXPLOSION { addkills 1 spawn BURNINGGUY killit } else ifdead { addkills 1 state squishcode killit } else { guts JIBS6 5 sound DUKE_GRUNT } }
enda

useractor notenemy JIBS7FLOOR fall sizeat 24 24 cstat 256 ifhitweapon {  qspawn BLOODPOOL2 killit } enda
useractor notenemy JIBS8FLOOR fall sizeat 24 24 cstat 256 ifhitweapon { qspawn BLOODPOOL2 killit } enda
useractor notenemy JIBS9FLOOR fall sizeat 24 24 cstat 256 ifhitweapon { qspawn BLOODPOOL2 killit } enda
useractor notenemy JIBS10 fall sizeat 24 24 cstat 256 ifhitweapon { qspawn BLOODPOOL2 killit } enda
useractor notenemy JIBS11 fall sizeat 24 24 cstat 256 ifhitweapon { qspawn BLOODPOOL2 killit } enda

useractor notenemy YELLOWLEAFFLOOR fall sizeat 24 24 enda
useractor notenemy GREENLEAFFLOOR fall sizeat 24 24 enda 