
include blcons/interact.con

spritenoshade NEWSCRAP1
defineprojectile NEWSCRAP1 PROJ_WORKSLIKE 6274
defineprojectile NEWSCRAP1 PROJ_EXTRA 0
defineprojectile NEWSCRAP1 PROJ_HITRADIUS 0
defineprojectile NEWSCRAP1 PROJ_VEL 64
defineprojectile NEWSCRAP1 PROJ_SPAWNS -1
defineprojectile NEWSCRAP1 PROJ_DROP -256
defineprojectile NEWSCRAP1 PROJ_BSOUND -1
defineprojectile NEWSCRAP1 PROJ_CLIPDIST 16
defineprojectile NEWSCRAP1 PROJ_XREPEAT 18
defineprojectile NEWSCRAP1 PROJ_YREPEAT 18

actor BUBBLES 
cstator 2
getactor[THISACTOR].z z
subvarvar z 512
setactor[THISACTOR].z z
ifceilingdistl 16 killit
enda

eventloadactor BUBBLESGEN
cstat 32768
enda

actor BUBBLESGEN
ifcansee {
	ifcount 10 {
		espawn BUBBLES
		
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		getactor[THISACTOR].xrepeat xrepeat
		setvarvar x2 x
		shiftvarl xrepeat 3
		addvarvar x2 xrepeat
		randvar ang 2048
		ifrnd 128 mulvar ang -1
		rotatepoint x y x2 y ang x3 y3
		setactor[RETURN].x x3
		setactor[RETURN].y y3
		
		getactor[THISACTOR].xrepeat xrepeat
		shiftvarr ang 8
		addvarvar xrepeat ang
		subvar xrepeat 8
		setactor[RETURN].xrepeat xrepeat
		setactor[RETURN].yrepeat xrepeat
		
		resetcount
	}
}
enda

actor NEWSCRAP1 0 FRAME_FRAME1 enda

spritenoshade NEWFIRE
defineprojectile NEWFIRE PROJ_WORKSLIKE 4226
defineprojectile NEWFIRE PROJ_DROP 64
defineprojectile NEWFIRE PROJ_HITRADIUS 0
defineprojectile NEWFIRE PROJ_SPAWNS -1
defineprojectile NEWFIRE PROJ_EXTRA 0
defineprojectile NEWFIRE PROJ_VEL 0
defineprojectile NEWFIRE PROJ_XREPEAT 4
defineprojectile NEWFIRE PROJ_YREPEAT 4
defineprojectile NEWFIRE PROJ_CSTAT 128
defineprojectile NEWFIRE PROJ_RANGE 1152

actor NEWFIRE 0 FRAME_FRAME1 enda

state enemies_loadactor
	switch sprite[THISACTOR].picnum
		case ZOMBIE
		case ZOMBIERISE
		case HERETIC
		case HERETICSTOPED1
		case HERETICSTOPED2
		case HERETICDUCKED1
		case MIM
		case EZOMBIEFALL
		case FISH
		case SPIDER
		case PHANTASM
		case HELLDOG
		case GILLBEAST
		case GARGOYLE
		case BUTCHER
		case FATRAT
		case EVILHAND
		case CIVILIAN
		case BOSSSPIDER
		case BATSLEEP
		case BAT
		case CERBERUS
		case GARBSTATUE
		case TCHERNOBOG
		case POD
		case TENTACLE
		case BEAST
			getactor[THISACTOR].lotag lotag
			getuserdef[THISACTOR].m_player_skill skillit //враги на разных уровнях сложности
			ifmultiplayer addvar skillit 1
			ifvare skillit 3 setvar skillit 4 else 
			ifvare skillit 4 setvar skillit 8 else 
			ifvare skillit 5 setvar skillit 16
			
			ifvarg lotag 0 {
				ifvarvarand lotag skillit {
					setactor[THISACTOR].lotag 0
				} else killit
			}
		break
	endswitch
ends


onevent EVENT_ANIMATESPRITES
	// Make actors invisible
	ifactor TRUNK settspr[THISACTOR].tsprxrepeat 0
	ifactor STAFFPROJ { dist DIST THISACTOR PLAYERID ifvarl DIST 1536 settspr[THISACTOR].tsprxrepeat 0 else settspr[THISACTOR].tsprxrepeat 48  }
	ifactor PLASMAPROJ { dist DIST THISACTOR PLAYERID ifvarl DIST 768 settspr[THISACTOR].tsprxrepeat 0 else settspr[THISACTOR].tsprxrepeat 32  }
	ifactor FLAME { dist DIST THISACTOR PLAYERID ifvarl DIST 768 settspr[THISACTOR].tsprxrepeat 0 else settspr[THISACTOR].tsprxrepeat 32  }
	ifactor FLAME2 { dist DIST THISACTOR PLAYERID ifvarl DIST 768 settspr[THISACTOR].tsprxrepeat 0 else settspr[THISACTOR].tsprxrepeat 32  }
	ifactor PLASMASHINE { dist DIST THISACTOR PLAYERID ifvarl DIST 768 settspr[THISACTOR].tsprxrepeat 0 else settspr[THISACTOR].tsprxrepeat 32  }
	ifactor ALTTESLA { dist DIST THISACTOR PLAYERID ifvarl DIST 768 settspr[THISACTOR].tsprxrepeat 0 else settspr[THISACTOR].tsprxrepeat 32  }
	ifactor STAFFALTPROJ { settspr[THISACTOR].tsprxrepeat 32 settspr[THISACTOR].tspryrepeat 32 }
	ifactor PR_NAPALM { settspr[THISACTOR].tsprxrepeat 32 settspr[THISACTOR].tspryrepeat 32 }

	getplayer[THISACTOR].i PLAYERID
	gettspr[THISACTOR].tsprowner tmp
	getactor[tmp].picnum picnum
	ifvare picnum APLAYER { setactorvar[PLAYERID].pcount 2 setactorvar[PLAYERID].animspritevar tmp }
	ifactor PREFLBALL 
	{ 
		getactorvar[THISACTOR].spriteid spriteid 
		getactorvar[PLAYERID].animspritevar animspritevar
		ifvarn spriteid -1 ifvarvare spriteid animspritevar settspr[THISACTOR].tsprxrepeat 58 
			else settspr[THISACTOR].tsprxrepeat 0 
	}
	ifactor PLAYERFIRE 
	{ 
		getactorvar[THISACTOR].spriteid spriteid 
		getactorvar[PLAYERID].animspritevar animspritevar
		ifvarn spriteid -1 ifvarvare spriteid animspritevar ifvarvarn animspritevar PLAYERID settspr[THISACTOR].tsprxrepeat 28 
			else settspr[THISACTOR].tsprxrepeat 0 
	}
	ifactor BUTCHER
	{
		getactorvar[THISACTOR].enemy_ang ang
		settspr[THISACTOR].tsprang 512
	}

endevent

onevent EVENT_SPAWN
	ifactor EXPLOSION4 {
		ifspawnedby TCHERNMISSLE {
			setactor[THISACTOR].pal 1
			ifvare QUAKETIME 0 { setvar QUAKETIME 36 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } 
			stopsound SPRAYFIR 
		}
	}
	ifactor SLOTDOOR
	{
			getactor[THISACTOR].htflags temp
			orvar temp 256
			setactor[THISACTOR].htflags temp
	}
	ifactor LIGHTSWITCH
	{
			getactor[THISACTOR].htflags temp
			orvar temp 256
			setactor[THISACTOR].htflags temp
	}
	ifactor SPACEDOORSWITCH
	{
			getactor[THISACTOR].htflags temp
			orvar temp 256
			setactor[THISACTOR].htflags temp
	}
	ifactor SPACELIGHTSWITCH
	{
			getactor[THISACTOR].htflags temp
			orvar temp 256
			setactor[THISACTOR].htflags temp
	}
	ifactor FRANKENSTINESWITCH
	{
			getactor[THISACTOR].htflags temp
			orvar temp 256
			setactor[THISACTOR].htflags temp
	}
endevent

onevent EVENT_PRELEVEL
	setvarvar NUMSPRITES Numsprites
endevent

onevent EVENT_LOADACTOR
	ifvarvarl NUMSPRITES Numsprites
		setvarvar NUMSPRITES Numsprites

	state enemies_loadactor
	setvarvar se_xvel sprite[THISACTOR].xvel
	setvarvar se_yvel sprite[THISACTOR].yvel
	setvarvar mover_rid sprite[THISACTOR].owner

	state loadsprite_trigger //trigger.con
	
	ifvare stat14_load 0 {
		setvarvar wallnum NUMWALLS
		subvar wallnum 1
		setvar bwall_tmp 0
		whilevarvarn bwall_tmp wallnum
		{
			getwall[bwall_tmp].lotag lotag
			ifvare lotag 511
			{
				getwall[bwall_tmp].x bwall_x1
				getwall[bwall_tmp].y bwall_y1
				getwall[bwall_tmp].point2 bwall_tmp2
				getwall[bwall_tmp2].x bwall_x2
				getwall[bwall_tmp2].y bwall_y2
				getwall[bwall_tmp].nextsector sectorid
				ifvarn sectorid -1
				{
					espawn BRKW_ACTOR
					setactorvar[RETURN].bwall_x1 bwall_x1
					setactorvar[RETURN].bwall_y1 bwall_y1
					setactorvar[RETURN].bwall_x2 bwall_x2
					setactorvar[RETURN].bwall_y2 bwall_y2
					setactorvar[RETURN].broken_id bwall_tmp
					subvarvar bwall_x2 bwall_x1
					subvarvar bwall_y2 bwall_y1
					setactorvar[RETURN].bwall_vecx bwall_x2
					setactorvar[RETURN].bwall_vecy bwall_y2
					setvarvar bwall_tmp2 bwall_x2
					setvarvar bwall_tmp3 bwall_y2
					mulvarvar bwall_tmp2 bwall_tmp2
					mulvarvar bwall_tmp3 bwall_tmp3
					addvarvar bwall_tmp2 bwall_tmp3
					sqrt bwall_tmp2 bwall_tmp3
					setactorvar[RETURN].bwall_veclen bwall_tmp3
					
					divvarvar bwall_x2 2
					divvarvar bwall_y2 2
					addvarvar bwall_x1 bwall_x2
					addvarvar bwall_y1 bwall_y2
					getsector[sectorid].floorz z
					setactor[RETURN].x bwall_x1
					setactor[RETURN].y bwall_y1
					setactor[RETURN].z z
				}
			}	
			addvar bwall_tmp 1
		}
		
		whilevarvarn stat14_load NUMSPRITES //похоже, при загрузке обычного актора все переменные стираются, остаются только в тех спрайтах, которые не загружаются
		{	
			//xvel для специальных объектов
			setactorvar[stat14_load].se_xvel sprite[stat14_load].xvel
			setactorvar[stat14_load].mover_rid sprite[stat14_load].owner
			setactorvar[stat14_load].se_yvel sprite[stat14_load].yvel

			setactorvar[stat14_load].obj_zvel sprite[stat14_load].zvel
			setactorvar[stat14_load].obj_statnum sprite[stat14_load].statnum
			setactorvar[stat14_load].obj_lotag sprite[stat14_load].lotag
			setactorvar[stat14_load].obj_sparks2 sprite[stat14_load].blend
			setactorvar[stat14_load].stat14_cstat sprite[stat14_load].cstat
			setactorvar[stat14_load].obj_hitag sprite[stat14_load].clipdist
			setactorvar[stat14_load].obj_extra sprite[stat14_load].extra
			setactorvar[stat14_load].obj_sound sprite[stat14_load].hitag	
		
			switch actorvar[stat14_load].obj_statnum // Breakable objects set
			case 15 //разбиваемый спрайт
				//setactor[stat14_load].statnum 1
				changespritestat stat14_load 1
				setactor[stat14_load].lotag 0
				setactor[stat14_load].clipdist 32
				setactor[stat14_load].extra 1
				
				ifvarand sprite[stat14_load].zvel 2 { ifvare sprite[stat14_load].hitag 0 setactor[stat14_load].hitag 1 } else 
				setactor[stat14_load].hitag 0
				ifvarg sprite[stat14_load].yvel 0 {
					setvar tmp 0
					whilevarvarn tmp NUMSPRITES {
						ifvare sprite[tmp].picnum TRIGGER {
							ifvarvare sprite[stat14_load].yvel sprite[tmp].xvel {
							ifvare sprite[tmp].zvel 3
								setactorvar[stat14_load].triggerlink 3 else
							ifvare sprite[tmp].zvel 6
								setactorvar[stat14_load].triggerlink 6
							}
						}
						addvar tmp 1
					}
				}
			break
			case 16 //кнопка
				setactor[stat14_load].lotag 0
				//setactor[stat14_load].statnum 1
				changespritestat stat14_load 1
					
				getactor[stat14_load].picnum picnum
				ifvare picnum BL_MULTISWITCH setactorvar[stat14_load].multisw_stat16 1

				ifvarn sprite[stat14_load].yvel 0
				{
					setvar sectorid 0
					setvar rx_id_numbers 0
					whilevarvarn sectorid NUMSECTORS 
					{
						headspritesect spriteid_1 sectorid
						whilevarn spriteid_1 -1 
						{
							getactor[spriteid_1].xvel rx_can
							ifvarvare rx_can sprite[stat14_load].yvel { addvar rx_id_numbers 1 setactorvar[stat14_load].rx_id_numbers rx_id_numbers } // количество акторов, которые надо активировать
							nextspritesect spriteid_1 spriteid_1
						}
						addvar sectorid 1
					}
				}

				getactor[stat14_load].cstat cstat_var
				ifvarand cstat_var 256 { xorvar cstat_var 256 setactor[stat14_load].cstat cstat_var }

				setactorvar[stat14_load].obj_owner sprite[stat14_load].owner
				setactorvar[stat14_load].obj_picplus sprite[stat14_load].extra
				
				ifvarg sprite[stat14_load].yvel 0 {
					setvar tmp 0
					whilevarvarn tmp NUMSPRITES {
						ifvare sprite[tmp].picnum TRIGGER {
							ifvarvare sprite[stat14_load].yvel sprite[tmp].xvel {
							ifvare sprite[tmp].zvel 3
								setactorvar[stat14_load].triggerlink 3 else
							ifvare sprite[tmp].zvel 6
								setactorvar[stat14_load].triggerlink 6
							}
						}
						addvar tmp 1
					}
				}
			break
			case 17 //меняет анимацию при активации
				setactor[stat14_load].lotag 0
				//setactor[stat14_load].statnum 1
				changespritestat stat14_load 1

				setactorvar[stat14_load].obj_picplus sprite[stat14_load].extra
				
				ifvarg sprite[stat14_load].yvel 0 {
					setvar tmp 0
					whilevarvarn tmp NUMSPRITES {
						ifvare sprite[tmp].picnum TRIGGER {
							ifvarvare sprite[stat14_load].yvel sprite[tmp].xvel 
								setactorvar[stat14_load].triggerlink sprite[tmp].zvel
						}
						addvar tmp 1
					}
				}
			break
			endswitch
			addvar stat14_load 1
		}
		setvar stat14_load 1
	}
	
	//определение дистанции плоских спрайтов до стены, для применения теней
	getactor[THISACTOR].cstat sprite_cst
	ifvarand sprite_cst 2048 nullop else
	ifvarand sprite_cst 16
	{
		getactor[THISACTOR].x sprite_x
		getactor[THISACTOR].y sprite_y
		getactor[THISACTOR].z sprite_z
		getactor[THISACTOR].sectnum sprite_sect
		getactor[THISACTOR].ang sprite_ang
		addvar sprite_ang 1024
		cos mycos sprite_ang
		sin mysin sprite_ang
		hitscan sprite_x sprite_y sprite_z sprite_sect mycos mysin 0 RETURN sprite_wall RETURN sprite_x2 sprite_y2 RETURN CLIPMASK0
		
		subvarvar sprite_x2 sprite_x
		subvarvar sprite_y2 sprite_y
		mulvarvar sprite_x2 sprite_x2
		mulvarvar sprite_y2 sprite_y2
		addvarvar sprite_x2 sprite_y2
		sqrt sprite_x2 sprite_dist
	}

ifactor SECTOREFFECTOR
{
	getactor[THISACTOR].yvel yvel
	setactorvar[THISACTOR].se_yvel yvel
	getactor[THISACTOR].zvel zvel
	setactorvar[THISACTOR].se_zvel zvel
	getactor[THISACTOR].lotag lotag
	setactorvar[THISACTOR].se_lotag lotag
	getactor[THISACTOR].hitag hitag
	setactorvar[THISACTOR].se_hitag hitag
	getactor[THISACTOR].owner htowner
	setactorvar[THISACTOR].se_owner htowner
	getactor[THISACTOR].pal pal
	ifvare pal 1 {
	setactorvar[THISACTOR].se_pal pal
	setactor[THISACTOR].pal 0 }
	
	getactor[THISACTOR].lotag lotag
	ifvare lotag 24
	{
		getactor[THISACTOR].xvel rx_can
		getactor[THISACTOR].zvel tr_bits
		getactorvar[THISACTOR].active active
		ifvarg rx_can 0
		ifvarand tr_bits 1
		{
			getactor[THISACTOR].sectnum sectnum1
			getsector[sectnum1].floorxpanning tmp
			setactorvar[THISACTOR].savepanningx tmp
			
			ifvarand tr_bits 2 {
				getsector[sectnum1].wallptr wallptr
				getwall[wallptr].x bwall_x1
				getwall[wallptr].y bwall_y1
				getwall[wallptr].point2 wallptr
				getwall[wallptr].x bwall_x2
				getwall[wallptr].y bwall_y2
				subvarvar bwall_x2 bwall_x1
				subvarvar bwall_y2 bwall_y1
				getangle wallang bwall_x2 bwall_y2
			}
	
			setvar spriteid 0
			whilevarvarn spriteid NUMSPRITES
			{
				getactor[spriteid].picnum picnum
				ifvare picnum GPSPEED
				{
					getactor[THISACTOR].xvel rx_can
					getactor[spriteid].xvel tx_can
					ifvarvare rx_can tx_can
					{	
						getactor[spriteid].lotag lotag
						setactorvar[THISACTOR].pl_yvel lotag	
					}
				} 
				addvar spriteid 1
			}
		}
	}
	state se_loadactor //movsprs.con
}
ifactor MUSICANDSFX
{
	getactor[THISACTOR].xvel msfx_rxcan
	getactor[THISACTOR].zvel tr_bits
	getactor[THISACTOR].owner se_owner
	getactor[THISACTOR].lotag msfx_lotag
	getactor[THISACTOR].hitag msfx_hitag
	ifvarg msfx_rxcan 0 ifvare tr_bits 1
	{
		espawn MUSICHELPER
		ifvare se_owner 1 
			setactorvar[RETURN].active 1
		setactor[RETURN].xvel msfx_rxcan
		setactorvar[RETURN].se_xvel msfx_rxcan
		setactorvar[RETURN].msfx_lotag msfx_lotag
		setactorvar[RETURN].msfx_hitag msfx_hitag
		killit
	}
}
setvar spriteid -1 // сброс переменной циклов в -1,  иначе в каждом спрайте будет записана эта переменная равная последнему ID спрайта на уровне
endevent

actor MUSICHELPER
cstat 32768
ifvare active 1 
ifvare msfx_tmp 0
{
	espawn MUSICANDSFX
	setactor[RETURN].lotag msfx_lotag
	setactor[RETURN].hitag msfx_hitag
	setvarvar msfx_id RETURN 
	setvar msfx_tmp 1
} else ifvarn active 1 ifvare msfx_tmp 1
{
	setactorvar[msfx_id].msfx_kill 1
	setvar msfx_tmp 0
}
enda

state expanding_sprite
getactor[THISACTOR].xrepeat save_repeatx
getactor[THISACTOR].yrepeat save_repeaty
getactor[THISACTOR].xvel rx_can
ifvarn rx_can 0 
{ 
setactor[THISACTOR].xrepeat 2
setactor[THISACTOR].yrepeat 2
getactor[THISACTOR].cstat exp_cstat
cstator 32768 
}
ends

state game_expandingspr
ifvarn rx_can 0
{
	getactorvar[THISACTOR].active active
	ifvare active 0 
	{ 
	getactor[THISACTOR].xrepeat xrepeat2
	getactor[THISACTOR].yrepeat yrepeat2
	ifvarvarg xrepeat2 2 subvarvar xrepeat2 2
	ifvarvarg yrepeat2 2 subvarvar yrepeat2 2
	setactor[THISACTOR].xrepeat xrepeat2
	setactor[THISACTOR].yrepeat yrepeat2
	ifvarvare xrepeat2 2 ifvarvare yrepeat2 2 cstator 32768 
	} else 
	{
		setactor[THISACTOR].cstat exp_cstat
		ifvarvarl xrepeat2 save_repeatx addvar xrepeat2 2
		setactor[THISACTOR].xrepeat xrepeat2
		ifvarvarl yrepeat2 save_repeaty addvar yrepeat2 2
		setactor[THISACTOR].yrepeat yrepeat2
	}
	fall
}
ends

state pal_option
getactor[THISACTOR].pal pal
ifvare pal 1 { ifmultiplayer setactor[THISACTOR].pal 0 else killit } else
ifvare pal 2 { ifmultiplayer killit else setactor[THISACTOR].pal 0 }
ends

state rotatestate
getactor[THISACTOR].ang rotate
addvar rotate 32
setactor[THISACTOR].ang rotate
ends


state killit_jibsstate
/*
getactor[THISACTOR].picnum picnum
switch picnum
case 5768
case 5800
case 5802
case 6015
case 6387
case 6388
case 6389
case 6447
case 6574
case 6575
case 6576
case 7173
case 7193
case 7257
case 7274
case 7450
case 7453
case 7454
case 7524
case 7567

break
endswitch
*/
ends


state MINEEXPLODE
	iffloordistl 8 { spawn EXPLOSION3 ifvare QUAKETIME 0 { setvar QUAKETIME 26 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } } else { spawn EXPLOSION4 ifvare QUAKETIME 0 { setvar QUAKETIME 26 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } }
	hitradius 1536 50 100 125 200
	soundonce EXPLODCM
	killit
ends

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

action METAL2FRAMES 0  6  1  1  6
action STONE2FRAMES 0  6  1  1  6
action WOOD2FRAMES 5895 4  1  1  4 //4821 4588
action BLOOD2FRAMES 3250  4  1  1  4

actor SHOTSPARK1 PISTOL_WEAPON_STRENGTH NO

  ifaction NO 
  {
	ifspawnedby APLAYER
	{
		cstat 32768
		sizeat 1 1
		ifvare sparkanim 1 { ifrnd 128 cstat 2 else cstat 6 sizeat 32 32 ifvare CURRWEAP 0 { globalsound PWOOD ifvare active 0 { spawn NEWSMOKE } } action WOOD2FRAMES } else
		ifvare sparkanim 2 { ifrnd 128 cstat 0 else cstat 4 sizeat 32 32 globalsound PMETAL ifvare active 0 { spawn NEWSMOKE } action METAL2FRAMES } else
		ifvare sparkanim 4 { ifrnd 128 cstat 0 else cstat 4 sizeat 32 32 ifvare CURRWEAP 0 globalsound PSTONE ifvare active 0 { spawn NEWSMOKE } action STONE2FRAMES } else
		ifvare sparkanim 8 { ifrnd 128 cstat 2 else cstat 6 sizeat 32 32 ifvare CURRWEAP 0 globalsound PFLESH action BLOOD2FRAMES }
		ifvare sparkanim 16 { ifrnd 128 cstat 0 else cstat 4 sizeat 32 32 globalsound LNDDIRT action METAL2FRAMES }
		ifvare sparkanim 32 { ifrnd 128 cstat 0 else cstat 4 sizeat 32 32 killit }
	} else
	ifspawnedby SHOTSPARK1 killit else
	{ 
		ifvare sparkanim 0 { action STONE2FRAMES } else
		ifvare sparkanim 1 ifvare active 1 { cstat 6 sizeat 32 32 globalsound PWOOD action WOOD2FRAMES } else
		ifvare sparkanim 2 ifvare active 1 { cstat 4 sizeat 32 32 globalsound PMETAL action METAL2FRAMES } else
		ifvare sparkanim 4 ifvare active 1 { cstat 4 sizeat 32 32 globalsound PSTONE action STONE2FRAMES } else
		ifvare sparkanim 8 { globalsound PFLESH action BLOOD2FRAMES }
		ifvare sparkanim 16 { globalsound LNDDIRT action METAL2FRAMES }
		ifvare sparkanim 32 { cstat 0 sizeat 32 32 killit }
	}
	
	ifvare active 0
	ifvare sparkanim 1
	{
		espawn SHOTSPARK1
		setactorvar[RETURN].active 1
		setactorvar[RETURN].sparkanim 1
	}
	ifvare active 0
	ifvare CURRWEAP 2
	ifvare sparkanim 2
	{
		espawn SHOTSPARK1
		setactorvar[RETURN].active 1
		setactorvar[RETURN].sparkanim 2
	}
	ifvare active 0
	ifvare CURRWEAP 2
	ifvare sparkanim 4
	{
		espawn SHOTSPARK1
		setactorvar[RETURN].active 1
		setactorvar[RETURN].sparkanim 4
	}
	
  }
  ifdead killit
  ifactioncount 6 killit 
  else
  {
    ifactioncount 3
    {
      ifinwater
      spawn WATERBUBBLE
    }
    else
      ifcount 2 nullop
      else
        ifonwater
          spawn WATERSPLASH2
	ifvare sparkanim 1 ifactioncount 4 killit
	ifvare sparkanim 8 ifactioncount 4 killit
  }
enda

//Inventory and items code

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

	}  
}
state pal_option
enda

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

spritenopal LIFESEED
useractor notenemy LIFESEED fall sizeat 30 30 getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit 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 sound PICKHEAL
         	 ifspawnedby LIFESEED state getcode
		     else state quikget
		}
      }
state pal_option
enda

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


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

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

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

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

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

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

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

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

useractor notenemy SPRAYSPRITE
fall sizeat 32 32 getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		getplayer[THISACTOR].ammo_amount 6 ammo
		ifvarl ammo 288
		{
		ifgotweaponce 0 break
        setplayer[THISACTOR].gotweapon 6 1
		ifvare ammo 0 ifvare player[THISACTOR].kickback_pic 0 ifvare player[THISACTOR].weapon_pos 0 { ifinwater nullop else { setvar changeweappos 4 setplayer[THISACTOR].weapon_pos -1 } }
		addvar ammo 48
		ifvarg ammo 288 setvar ammo 288
		setplayer[THISACTOR].ammo_amount 6 ammo
		quote 160 sound PICKAMMO
        ifspawnedby SPRAYSPRITE state getweaponcode
        else state quikweaponget
		}
    }
state pal_option
enda

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

useractor notenemy VOODOOSPRITE
fall sizeat 32 32
state rotatestate
getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		ifgotweaponce 0 break
        addweapon 9 100
		quote 161 sound PICKAMMO
        ifspawnedby VOODOOSPRITE state getcode
        else state quikget
    }
state pal_option
enda

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

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

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

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

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

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

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

useractor notenemy TRAPPEDSOUL
fall sizeat 16 16 getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
        addammo 8 10
        quote 159 sound PICKAMMO
        ifspawnedby TRAPPEDSOUL state getcode
        else state quikget
    }
state pal_option
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 palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
	    ifgotweaponce 0 break
        addweapon 8 35
		quote 163 sound PICKAMMO
        ifspawnedby HELLSTAFF state getweaponcode
        else state quikweaponget
    }
	state pal_option
} else
state hellstaffaltunit
enda


useractor notenemy BEASTVISION
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
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 sound PICKUP
        ifspawnedby BEASTVISION state getcode
        else state quikget
        }
state pal_option
enda

useractor notenemy DOCTORSBAG
fall getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
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 sound PICKUP
        ifspawnedby DOCTORSBAG state getcode
        else state quikget
        }
	state pal_option		
enda

useractor notenemy DIVINGSUIT
fall getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
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 sound PICKUP
		ifinwater {
			setvar DIVINGSUITON 1
		}
        ifspawnedby DIVINGSUIT state getcode
        else state quikget
        }
	state pal_option	
enda

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

ifmultiplayer
{
	ifmove RESPAWN_ACTOR_FLAG state respawnit
	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 sound PICKUP
        ifspawnedby CRYSTALLBALL state getcode
        else state quikget
        }	
} 

state pal_option

enda

useractor notenemy BOOTSOFJUMPING
fall getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
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 sound PICKUP
        ifspawnedby BOOTSOFJUMPING state getcode
        else state quikget
        }
}
	state pal_option		
enda

useractor notenemy BODYARMOR
getplayer[THISACTOR].i PLAYERID
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
		getactorvar[PLAYERID].bodyshield BODYSHIELD_AMOUNT
        ifvarl BODYSHIELD_AMOUNT 100
        {
		addvar BODYSHIELD_AMOUNT 100
		ifvarg BODYSHIELD_AMOUNT 100 { setvar BODYSHIELD_AMOUNT 100 }
		setactorvar[PLAYERID].bodyshield BODYSHIELD_AMOUNT
        quote 140 sound PICKARMR
        ifspawnedby BODYARMOR state getcode
		else state quikget
		}
}
	state pal_option	
enda

useractor notenemy FIREARMOR
getplayer[THISACTOR].i PLAYERID
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	getactorvar[PLAYERID].fireshield FIRESHIELD_AMOUNT
	ifvarl FIRESHIELD_AMOUNT 100
	{
        addvar FIRESHIELD_AMOUNT 100
        ifvarg FIRESHIELD_AMOUNT 100 { setvar FIRESHIELD_AMOUNT 100 }
		setactorvar[PLAYERID].fireshield FIRESHIELD_AMOUNT
        quote 142 sound PICKARMR
        ifspawnedby FIREARMOR state getcode
		else state quikget
        }
}
	state pal_option	
enda

useractor notenemy SPIRITARMOR
getplayer[THISACTOR].i PLAYERID
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{	
	getactorvar[PLAYERID].spiritshield SPIRITSHIELD_AMOUNT
	ifvarl SPIRITSHIELD_AMOUNT 100
	{
        addvar SPIRITSHIELD_AMOUNT 100
        ifvarg SPIRITSHIELD_AMOUNT 100 { setvar SPIRITSHIELD_AMOUNT 100 }
		setactorvar[PLAYERID].spiritshield SPIRITSHIELD_AMOUNT
        quote 167 sound PICKARMR
        ifspawnedby SPIRITARMOR state getcode
		else state quikget
    }
}
	state pal_option
enda

useractor notenemy SUPERARMOR
getplayer[THISACTOR].i PLAYERID
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		setactorvar[PLAYERID].bodyshield 200
		setactorvar[PLAYERID].fireshield 200
		setactorvar[PLAYERID].spiritshield 200
        quote 144 sound PICKARMR
        ifspawnedby SUPERARMOR state getcode
		else state quikget
    }
	state pal_option	
enda

useractor notenemy BASICARMOR
fall state rotatestate getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 0
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget {
	getactorvar[PLAYERID].bodyshield BODYSHIELD_AMOUNT
	getactorvar[PLAYERID].fireshield FIRESHIELD_AMOUNT
	getactorvar[PLAYERID].spiritshield SPIRITSHIELD_AMOUNT
    ifvarl BODYSHIELD_AMOUNT 100 { addvar BODYSHIELD_AMOUNT 50 ifvarg BODYSHIELD_AMOUNT 100 { setvar BODYSHIELD_AMOUNT 100 } setactorvar[PLAYERID].bodyshield BODYSHIELD_AMOUNT setvar peractor 1 }
	ifvarl FIRESHIELD_AMOUNT 100 { addvar FIRESHIELD_AMOUNT 50 ifvarg FIRESHIELD_AMOUNT 100 { setvar FIRESHIELD_AMOUNT 100 } setactorvar[PLAYERID].fireshield FIRESHIELD_AMOUNT setvar peractor 1 }
	ifvarl SPIRITSHIELD_AMOUNT 100 { addvar SPIRITSHIELD_AMOUNT 50 ifvarg SPIRITSHIELD_AMOUNT 100 { setvar SPIRITSHIELD_AMOUNT 100 } setactorvar[PLAYERID].spiritshield SPIRITSHIELD_AMOUNT setvar peractor 1 }
		
	ifvare peractor 1 {		
		quote 166 sound PICKARMR
		ifspawnedby BASICARMOR state getcode
		else state quikget
	}
}
	state pal_option	
enda

spritenopal BLOODBOOK
useractor notenemy BLOODBOOK
fall sizeat 32 32
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
{
	quote 193 
	sound GUST4
    palfrom 32 0 32
	killit
}
enda

state findenemy_keykeeper
ifvarl peractor 3
{
	getactor[THISACTOR].yvel tx_can
	ifvarn tx_can 0
	{	
		setvar sectorid 0
		setvar key_enemyid 0
		whilevarvarn sectorid NUMSECTORS 
		{
			headspritesect spriteid sectorid
			whilevarn spriteid -1 
			{
				getactorvar[spriteid].se_xvel rx_can
				getactor[spriteid].statnum statnum
				getactor[spriteid].extra extra
				getactor[spriteid].picnum picnum
				
				ifvarvare rx_can tx_can ifvarn picnum APLAYER ifvarn statnum 1024
				ifvarg extra 0 { setvarvar key_enemyid spriteid }
				nextspritesect spriteid spriteid
			}
			addvar sectorid 1
		}
		ifvarn key_enemyid 0 { addvar key_id_number 1 setactor[THISACTOR].cstat 32768 }
	} 
	addvar peractor 1
}
ends

useractor notenemy SKULLKEY state findenemy_keykeeper
fall state rotatestate sizeat 24 24
ifvarg key_id_number 0 
ifvare peractor 3
{ 
	setactor[THISACTOR].cstat 32768
	getactor[key_enemyid].extra extra 
	ifvarg extra 0 
	{
		getactor[key_enemyid].x x
		getactor[key_enemyid].y y
		getactor[key_enemyid].z z
		getactor[key_enemyid].sectnum sect2
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
		setactor[THISACTOR].sectnum sect2
	} 
	else 
	{ 
	setvar peractor 0
	state findenemy_keykeeper
	ifvare key_enemyid 0 { setactor[THISACTOR].cstat 0 setvar key_id_number 0 }
	} 
} else
ifvare key_id_number 0
{
	ifmove RESPAWN_ACTOR_FLAG state respawnit
	else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		setvar VAR_SKULLKEY 1
		quote 131 sound PICKKEY
		ifspawnedby SKULLKEY state getcode
		else state quikget
	}
}
enda

useractor notenemy EYEKEY state findenemy_keykeeper

fall state rotatestate sizeat 24 24 
ifvarg key_id_number 0 
ifvare peractor 3
{ 
	setactor[THISACTOR].cstat 32768
	getactor[key_enemyid].extra extra 
	ifvarg extra 0 
	{
		getactor[key_enemyid].x x
		getactor[key_enemyid].y y
		getactor[key_enemyid].z z
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
	} else 
	{ 
	setvar peractor 0
	state findenemy_keykeeper
	ifvare key_enemyid 0 { setactor[THISACTOR].cstat 0 setvar key_id_number 0 }
	} 
} else
ifvare key_id_number 0
{
	ifmove RESPAWN_ACTOR_FLAG state respawnit
	else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
	{
		setvar VAR_EYEKEY 1
		quote 132 sound PICKKEY
		ifspawnedby EYEKEY state getcode
		else state quikget
	}	
}
enda

useractor notenemy FIREKEY state findenemy_keykeeper
fall state rotatestate sizeat 24 24 
ifvarg key_id_number 0 
ifvare peractor 3
{ 
	setactor[THISACTOR].cstat 32768
	getactor[key_enemyid].extra extra 
	ifvarg extra 0 
	{
		getactor[key_enemyid].x x
		getactor[key_enemyid].y y
		getactor[key_enemyid].z z
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
	} else 
	{ 
	setvar peractor 0
	state findenemy_keykeeper
	ifvare key_enemyid 0 { setactor[THISACTOR].cstat 0 setvar key_id_number 0 }
	} 
} else
ifvare key_id_number 0
{
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_FIREKEY 1
		quote 133 sound PICKKEY
        ifspawnedby FIREKEY state getcode
        else state quikget
    }	
}
enda

useractor notenemy DAGGERKEY state findenemy_keykeeper

fall state rotatestate sizeat 24 24
ifvarg key_id_number 0 
ifvare peractor 3
{ 
	setactor[THISACTOR].cstat 32768
	getactor[key_enemyid].extra extra 
	ifvarg extra 0 
	{
		getactor[key_enemyid].x x
		getactor[key_enemyid].y y
		getactor[key_enemyid].z z
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
	} else 
	{ 
	setvar peractor 0
	state findenemy_keykeeper
	ifvare key_enemyid 0 { setactor[THISACTOR].cstat 0 setvar key_id_number 0 }
	} 
} else
ifvare key_id_number 0
{
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_DAGGERKEY 1
		quote 134 sound PICKKEY
        ifspawnedby DAGGERKEY state getcode
        else state quikget
    }
}
enda

useractor notenemy SPIDERKEY state findenemy_keykeeper

fall state rotatestate sizeat 24 24
ifvarg key_id_number 0 
ifvare peractor 3
{ 
	setactor[THISACTOR].cstat 32768
	getactor[key_enemyid].extra extra 
	ifvarg extra 0 
	{
		getactor[key_enemyid].x x
		getactor[key_enemyid].y y
		getactor[key_enemyid].z z
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
	} else 
	{ 
	setvar peractor 0
	state findenemy_keykeeper
	ifvare key_enemyid 0 { setactor[THISACTOR].cstat 0 setvar key_id_number 0 }
	} 
} else
ifvare key_id_number 0
{
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_SPIDERKEY 1
		quote 135 sound PICKKEY
        ifspawnedby SPIDERKEY state getcode
        else state quikget
    }
}
enda

useractor notenemy MOONKEY state findenemy_keykeeper
fall state rotatestate sizeat 24 24 
ifvarg key_id_number 0
ifvare peractor 3
{ 
	setactor[THISACTOR].cstat 32768
	getactor[key_enemyid].extra extra 
	ifvarg extra 0 
	{
		getactor[key_enemyid].x x
		getactor[key_enemyid].y y
		getactor[key_enemyid].z z
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
	} else 
	{ 
	setvar peractor 0
	state findenemy_keykeeper
	ifvare key_enemyid 0 { setactor[THISACTOR].cstat 0 setvar key_id_number 0 }
	} 
} else
ifvare key_id_number 0
{
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        setvar VAR_MOONKEY 1
		quote 136 sound PICKKEY
        ifspawnedby MOONKEY state getcode
        else state quikget
    }
}
enda

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

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

useractor notenemy PREFLBALL
	 sizeat 58 58
	cstat 514
	getactor[THISACTOR].mdflags  tmp
	orvar  tmp 16
	setactor[THISACTOR].mdflags  tmp

	getactorvar[THISACTOR].spriteid tmp
	ifvarn tmp -1
	{
		getactorvar[tmp].reflective tmp2
		getactor[tmp].x x
		getactor[tmp].y y
		getactor[tmp].z z
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z z
		ifvare tmp2 0 { killit }
	}
enda

useractor notenemy INVISIBLEITEM
fall getactor[THISACTOR].cstat acstat
ifvare acstat 32768 nullop else setactor[THISACTOR].cstat 2
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
		getplayer[THISACTOR].i PLAYERID
		setactorvar[PLAYERID].invisible 1
		setvar REFLTIME 0
		quote 165 sound POWERUP
        ifspawnedby INVISIBLEITEM state getcode
        else state quikget
    }
	state pal_option
enda

// Breakobjects code

action ALIGHT5_1 339 3 1 1 10
action ALIGHT5_13 339 3 1 1 10
action ALIGHT5_2 340 2 1 1 10
action ALIGHT5_3 357 3 1 1 10
action ALIGHT5_4 359 1 1 1 1
action ALIGHT5_5 358 1 1 1 1 //1154
action ALIGHT5_6 357 1 1 1 1
action ALIGHT5_7 358 1 1 1 1
action ALIGHT5_8 359 1 1 1 1
action ALIGHT5_9 358 1 1 1 1 //1154
action ALIGHT5_10 357 1 1 1 1
action ALIGHT5_11 358 1 1 1 1
action ALIGHT5_12 359 1 1 1 1

useractor notenemy LIGHT5 WEAK
ifhitweapon 
{
	setactor[THISACTOR].htextra 10
	setactorvar[THISACTOR].newscrap_pal 10
	setactorvar[THISACTOR].setspark_phis 2
	getactor[THISACTOR].htpicnum enemy_htpic
	setvar in1 10
	setvar in2 SPARK1
	state spawn_multiply
	action ALIGHT5_1
}
ifaction ALIGHT5_1 ifactioncount 3 action ALIGHT5_2
ifaction ALIGHT5_2 ifactioncount 2 action ALIGHT5_13
ifaction ALIGHT5_13 ifactioncount 3 action ALIGHT5_3
ifaction ALIGHT5_3 ifactioncount 3 action ALIGHT5_4
ifaction ALIGHT5_4 //1155
{
	addvar light5count 1
	ifvarg light5count 40 { action ALIGHT5_5 setvar light5count 0 }
}
ifaction ALIGHT5_5 //1154
{
	addvar light5count 1
	ifvarg light5count 3 { action ALIGHT5_6 setvar light5count 0 }
}
ifaction ALIGHT5_6 //1153
{
	addvar light5count 1
	ifvarg light5count 3 { action ALIGHT5_7 setvar light5count 0 }
}
ifaction ALIGHT5_7 //1154
{
	addvar light5count 1
	ifvarg light5count 3 { action ALIGHT5_8 setvar light5count 0 }
}
ifaction ALIGHT5_8 //1155
{
	addvar light5count 1
	ifvarg light5count 40 { action ALIGHT5_9 setvar light5count 0 }
}

ifaction ALIGHT5_9 //1154
{
	addvar light5count 1
	ifvarg light5count 3 { action ALIGHT5_10 setvar light5count 0 }
}
ifaction ALIGHT5_10 //1153
{
	addvar light5count 1
	ifvarg light5count 3 { action ALIGHT5_11 setvar light5count 0 }
}
ifaction ALIGHT5_11 //1154
{
	addvar light5count 1
	ifvarg light5count 3 { action ALIGHT5_12 setvar light5count 0 }
}

enda

state spark3spwn
setvar in1 10
setvar in2 SPARK3
state spawn_multiply
sound SPLNTWOD
killit
ends

state tree_explosion
findnearactorvar EXPLOSION2 2048 spriteid
ifvarn spriteid -1 { state spark3spwn } else
findnearactorvar EXPLOSION3 2048 spriteid
ifvarn spriteid -1 { state spark3spwn } else
findnearactorvar EXPLOSION4 2048 spriteid
ifvarn spriteid -1 { state spark3spwn } else
findnearactorvar EXPLOSION6 2048 spriteid
ifvarn spriteid -1 { state spark3spwn }
ends

actor TRUNK fall cstator 256
getactor[THISACTOR].mdflags  tmp
orvar  tmp 16
setactor[THISACTOR].mdflags  tmp

findnearactorvar EXPLOSION2 2048 spriteid
ifvarn spriteid -1 { killit } else
findnearactorvar EXPLOSION3 2048 spriteid
ifvarn spriteid -1 { killit } else
findnearactorvar EXPLOSION4 2048 spriteid
ifvarn spriteid -1 { killit } else
findnearactorvar EXPLOSION6 2048 spriteid
ifvarn spriteid -1 { killit }
enda

state tree1_cstatcheck
ifvarand sprite[THISACTOR].cstat 128
{
	cstat 0
	getactor[THISACTOR].z z
	addvar z 20480
	setactor[THISACTOR].z z
}
ends

action TREE1_BURNING 2814 10 1 1 12
action TREE1_BURNED 2822 1 1 1 1

spritenoshade TREE1
eventloadactor TREE1
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].yrepeat yrepeat
espawn TRUNK 
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat yrepeat
enda

actor TREE1
cstator 1 
getactor[THISACTOR].cstat acstat
ifvarand acstat 256 { xorvar acstat 256 setactor[THISACTOR].cstat acstat }
findnearactorvar EXPLOSION2 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 state tree1_cstatcheck action TREE1_BURNING setvar peractor 1 } else
findnearactorvar EXPLOSION3 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 state tree1_cstatcheck action TREE1_BURNING setvar peractor 1 } else
findnearactorvar EXPLOSION4 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 state tree1_cstatcheck action TREE1_BURNING setvar peractor 1 } else
findnearactorvar EXPLOSION6 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 state tree1_cstatcheck action TREE1_BURNING setvar peractor 1 }

ifvare pfire 1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 state tree1_cstatcheck action TREE1_BURNING setvar peractor 1 setvar pfire 0 }


ifaction TREE1_BURNING ifactioncount 9 ifvare peractor 1
{ 
	setactorvar[THISACTOR].lights_on 0 
	action TREE1_BURNED 
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	espawn TRUNK 
	setactor[RETURN].cstat 32768
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat yrepeat
	setvar peractor 2
}
ifaction TREE1_BURNED state tree_explosion
enda

eventloadactor TREE2
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].yrepeat yrepeat
espawn TRUNK 
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat yrepeat
enda

actor TREE2 cstator 1 
getactor[THISACTOR].cstat acstat
ifvarand acstat 256 { xorvar acstat 256 setactor[THISACTOR].cstat acstat }
state tree_explosion enda


action TREE3_BURNING 2809 10 1 1 12
action TREE3_BURNED 2818 1 1 1 1

spritenoshade TREE3
eventloadactor TREE3
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].yrepeat yrepeat
espawn TRUNK 
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat yrepeat
enda

actor TREE3
cstator 1 
getactor[THISACTOR].cstat acstat
ifvarand acstat 256 { xorvar acstat 256 setactor[THISACTOR].cstat acstat }
findnearactorvar EXPLOSION2 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 action TREE3_BURNING setvar peractor 1 } else
findnearactorvar EXPLOSION3 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 action TREE3_BURNING setvar peractor 1 } else
findnearactorvar EXPLOSION4 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 action TREE3_BURNING setvar peractor 1 } else
findnearactorvar EXPLOSION6 2048 spriteid
ifvarn spriteid -1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 action TREE3_BURNING setvar peractor 1 }

ifvare pfire 1 ifvare peractor 0 { setactorvar[THISACTOR].lights_on 1 state tree1_cstatcheck action TREE1_BURNING setvar peractor 1 setvar pfire 0 }

ifaction TREE3_BURNING ifactioncount 9 ifvare peractor 1 
{ 
	setactorvar[THISACTOR].lights_on 0 
	action TREE3_BURNED 
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	espawn TRUNK 
	setactor[RETURN].cstat 32768
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat yrepeat
	setvar peractor 2
}
ifaction TREE3_BURNED state tree_explosion
enda

eventloadactor TREE4
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].yrepeat yrepeat
espawn TRUNK 
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat yrepeat
enda

actor TREE4 cstator 1 getactor[THISACTOR].cstat acstat
ifvarand acstat 256 { xorvar acstat 256 setactor[THISACTOR].cstat acstat } state tree_explosion enda

eventloadactor TREE5
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].yrepeat yrepeat
espawn TRUNK 
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat yrepeat
enda

actor TREE5 cstator 1 getactor[THISACTOR].cstat acstat
ifvarand acstat 256 { xorvar acstat 256 setactor[THISACTOR].cstat acstat } state tree_explosion enda

action NETBRONING 18 2 1 1 12
action NETBROKEN 20 1 1 1 1

action FIRENETBRONING 1351 3 1 1 12 //7540
action FIRENETBROKEN 1354 1 1 1 1

actor SPIDERNET WEAK 

ifvare peractor 0 
{ getactor[THISACTOR].cstat acstat
orvar acstat 257 setactor[THISACTOR].cstat acstat setvar peractor 1 }

ifhitweapon { getactor[THISACTOR].htpicnum enemy_htpic action NETBRONING }
ifaction NETBRONING ifactioncount 2 action NETBROKEN
ifaction NETBROKEN ifvare peractor 1
{ getactor[THISACTOR].cstat acstat
xorvar acstat 257 setactor[THISACTOR].cstat acstat setvar peractor 2 }

getactorvar[THISACTOR].pfire pfire
ifvare pfire 1 { action FIRENETBRONING setactorvar[THISACTOR].pfire 0 }
getactorvar[THISACTOR].flamedamage flamedamage
ifvarg flamedamage 0 { setactorvar[THISACTOR].spidernet_damage 1 action FIRENETBRONING setactorvar[THISACTOR].flamedamage 0 }
ifaction FIRENETBRONING ifactioncount 3 action FIRENETBROKEN
ifaction FIRENETBROKEN ifvare peractor 1
{ getactor[THISACTOR].cstat acstat
xorvar acstat 257 setactor[THISACTOR].cstat acstat setvar peractor 2 }
enda

action WOODBROKEN 1

actor WOODENCAP WEAK 
ifvare peractor 0 
{ getactor[THISACTOR].cstat acstat
orvar acstat 257 setactor[THISACTOR].cstat acstat setvar peractor 1 }

ifhitweapon
{ soundonce SPLNTWOD 
setvar in1 20
setvar in2 SPARK5
state spawn_multiply 
getactor[THISACTOR].htpicnum enemy_htpic
action WOODBROKEN 
}
ifaction WOODBROKEN ifvare peractor 1
{ getactor[THISACTOR].cstat acstat
xorvar acstat 257 setactor[THISACTOR].cstat acstat setvar peractor 2 }
enda

actor SMILETARG TOUGH 
cstator 257
ifhitweapon { 
	setvar in1 10
	setvar in2 GLASS_PART
	state spawn_multiply
	sound GLASS_BREAKING killit }
enda

actor DUCKTARG TOUGH 
cstator 257
ifhitweapon 
{ 
setvar in1 5
setvar in2 JIBS9
state spawn_multiply killit  
}
enda

useractor notenemy JUKEBOX WEAK
cstator 257
ifpdistl 1024 ifp pfacing ifcansee ifhitspace { setvar peractor 1 }
ifvare peractor 1 { soundonce MOANS }
ifhitweapon { soundonce RECSCRAP stopsound MOANS soundonce GLASS_HEAVYBREAK killit }
enda

state detonation ifstrength 0 { sound EXPLODCL spawn EXPLOSION4 spawn EXPLOSION3  hitradius 2600 280 340 380 380 killit } ends

useractor notenemy TNTBARREL 50
setactorvar[THISACTOR].width 160
setactorvar[THISACTOR].height 4092
fall
cstator 257 sizeat 48 48
state pal_option
ifhitweapon
{
ifwasweapon SHOTSPARK1 state detonation else
ifwasweapon PLASMAPROJ state detonation else
ifwasweapon ALTTESLA state detonation else
ifwasweapon PR_NAPALM { sound EXPLODCL spawn EXPLOSION4 spawn EXPLOSION3  hitradius 2600 280 340 380 380 killit } else
ifwasweapon STAFFPROJ state detonation
}
getactor[THISACTOR].extra extra
ifvarl extra 0 { addvar COUNTER 1 ifvare COUNTER 6 state detonation }





findnearactorvar EXPLOSION6 1024 spriteid
ifvarn spriteid -1 { ifvarg extra 0 { getactorvar[THISACTOR].flamedamage tmp addvar tmp 2 setactorvar[THISACTOR].flamedamage tmp } }
getactorvar[THISACTOR].flamedamage temp
ifvarg temp 0 
{ 
	addvar COUNTER 1 state newfirestate
	ifvare extra 1 { sound EXPLODCL spawn EXPLOSION4 spawn EXPLOSION3  hitradius 1600 50 70 90 110 killit  }
	ifvarvare COUNTER temp { setactor[THISACTOR].extra extra setactorvar[THISACTOR].flamedamage 0 setvar COUNTER 0 } 
}

getactorvar[THISACTOR].active active
ifvare active 1 { sound EXPLODCL spawn EXPLOSION4 spawn EXPLOSION3  hitradius 1600 50 70 90 110 killit  }
enda

action ADUKEACTION 1

actor DEADDUKE TOUGH cstator 257 sizeat 30 30
getactor[THISACTOR].htextra htextra
ifaction NO ifhitweapon { getactor[THISACTOR].htpicnum enemy_htpic ifvarg htextra 0 setactor[THISACTOR].htextra htextra action ADUKEACTION }
ifaction NO ifhitspace ifcansee ifpdistl 2048 { action ADUKEACTION }
ifaction ADUKEACTION { setactor[THISACTOR].htextra -1 addvar COUNTER 1 ifvare COUNTER 1 setactorvar[PLAYERID].playervoice SHAKEIT ifvarg COUNTER 114 { setvar COUNTER 0 strength TOUGH action NO } }
enda

eventloadactor LAMP03 //факел, создает огонь BLOODFIRE1 над собой
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
ifvare LOTAGSAVED 0
{
	espawn BLOODFIRE1
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	divvar xrepeat 2
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat xrepeat
	getactor[THISACTOR].z emz
	getactor[THISACTOR].cstat acstat
	ifvarand acstat 128 mulvarvar yrepeat 120 else mulvarvar yrepeat 240
	subvarvar emz yrepeat
	setactor[RETURN].z emz
}
enda

eventloadactor 5692 //факел, создает огонь BLOODFIRE1 над собой !!!! тайл меняется на следующий, то же самое для остальных факелов, которые спавнят огонь
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
ifvare LOTAGSAVED 0
{
	espawn BLOODFIRE1
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	//divvar xrepeat 2
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat xrepeat
	getactor[THISACTOR].z emz
	getactor[THISACTOR].cstat acstat
	ifvarand acstat 128 mulvarvar yrepeat 104 else mulvarvar yrepeat 208
	subvarvar emz yrepeat
	setactor[RETURN].z emz
}
enda

useractor notenemy LIGHT6 TOUGH cstator 257
ifhitweapon 
ifaction NO
{ 
	setactor[THISACTOR].htextra 10
	getactor[THISACTOR].htpicnum enemy_htpic
	setactorvar[THISACTOR].newscrap_pal 10
	setactorvar[THISACTOR].setspark_phis 2
	setvar in1 12
	setvar in2 SPARK1
	state spawn_multiply
	action ONE
	setactorvar[THISACTOR].setglass_phis 1
	setvar in1 10
	setvar in2 GLASS_PART
	state spawn_multiply
	sound GLASS_BREAKING
}
enda

useractor notenemy LIGHT1 TOUGH 
cstator 257
ifhitweapon 
ifaction NO
{ 
	setactor[THISACTOR].htextra 10
	getactor[THISACTOR].htpicnum enemy_htpic
	setactorvar[THISACTOR].newscrap_pal 10
	setactorvar[THISACTOR].setspark_phis 2
	setvar in1 12
	setvar in2 SPARK1
	state spawn_multiply
	action ONE
	setactorvar[THISACTOR].setglass_phis 1
	setvar in1 10
	setvar in2 GLASS_PART
	state spawn_multiply
	sound GLASS_BREAKING
}
enda

action AZOMBACTION 1

actor DEADZOMB TOUGH cstator 257 sizeat 30 30
ifaction NO ifhitweapon {  ifwasweapon RADIUSEXPLOSION strength TOUGH else ifwasweapon PR_NAPALM strength TOUGH else ifwasweapon STAFFPROJ strength TOUGH else ifwasweapon ALTNAPALM strength TOUGH else ifwasweapon ALTTESLA strength TOUGH else { getactor[THISACTOR].htpicnum enemy_htpic /*нужен для триггера*/ soundonce 450 action AZOMBACTION } }
ifaction AZOMBACTION { addvar COUNTER 1 ifvarg COUNTER 114 { setactor[THISACTOR].htextra -1 setvar enemy_htpic -1 setvar COUNTER 0 strength TOUGH action NO } }
enda

eventloadactor LAMP
getactor[THISACTOR].hitag HITAGSET
setactor[THISACTOR].hitag 0
enda

action LAMP_ON 1
action LAMP_OFF 0

actor LAMP 0 LAMP_OFF
getactorvar[THISACTOR].active active
ifvare HITAGSET 1 { setactorvar[THISACTOR].active 1 setvar HITAGSET 0 }
ifvare active 1
{
	ifaction LAMP_OFF { action LAMP_ON }
} else ifaction LAMP_ON { action LAMP_OFF }
enda

eventloadactor SAW
getactor[THISACTOR].hitag HITAGSET
setactor[THISACTOR].hitag 0

espawn SAW_BLOOD
setactorvar[THISACTOR].saw_blood RETURN
getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].ang ang
rotatepoint x y x y ang x3 y3
setactor[RETURN].x x3
setactor[RETURN].y y3
setactor[RETURN].cstat 32768
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat xrepeat
getactor[THISACTOR].ang ang
setactor[RETURN].ang ang
mulvar xrepeat 64
addvarvar z xrepeat
setactor[RETURN].z z


espawn 0
getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].ang ang
setvarvar y2 y
mulvar xrepeat 10
addvarvar y2 xrepeat
getactor[THISACTOR].xrepeat xrepeat
rotatepoint x y x y2 ang se_x3 se_y3
setactor[RETURN].x se_x3
setactor[RETURN].y se_y3
setactor[RETURN].cstat 32768
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat xrepeat
getactor[RETURN].ang ang
addvar ang 1024
setactor[RETURN].ang ang
mulvar xrepeat 128
addvarvar z xrepeat
setactor[RETURN].z z
setactorvar[THISACTOR].spriteid_1 RETURN

espawn 0
getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].ang ang
setvarvar y2 y
mulvar xrepeat 10
subvarvar y2 xrepeat
getactor[THISACTOR].xrepeat xrepeat
rotatepoint x y x y2 ang se_x3 se_y3
setactor[RETURN].x se_x3
setactor[RETURN].y se_y3
setactor[RETURN].cstat 32768
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat xrepeat
getactor[RETURN].ang ang
addvar ang 1024
setactor[RETURN].ang ang
mulvar xrepeat 128
addvarvar z xrepeat
setactor[RETURN].z z
setactorvar[THISACTOR].spriteid_2 RETURN

espawn 0
getactor[THISACTOR].x x
getactor[THISACTOR].y y
getactor[THISACTOR].z z
getactor[THISACTOR].xrepeat xrepeat
getactor[THISACTOR].ang ang
rotatepoint x y x y ang se_x3 se_y3
setactor[RETURN].x se_x3
setactor[RETURN].y se_y3
setactor[RETURN].cstat 32768
setactor[RETURN].xrepeat xrepeat
setactor[RETURN].yrepeat xrepeat
getactor[RETURN].ang ang
addvar ang 1024
setactor[RETURN].ang ang
mulvar xrepeat 128
subvarvar z xrepeat
setactor[RETURN].z z
setactorvar[THISACTOR].spriteid_3 RETURN
		
enda

action SAW_ON 0
action SAW_OFF 1
action BLOODYSAW_ON 117
action BLOODYSAW_OFF 118

actor SAW 0 SAW_OFF
ifvarg active 1 setvar active 0
ifvare spriteid_1 0 ifvare spriteid_2 0 ifvare spriteid_3 0 setactorvar[THISACTOR].active 0 
ifvare HITAGSET 1 { setactorvar[THISACTOR].active 1 setvar HITAGSET 0 }
ifvare active 1
{
	getactorvar[THISACTOR].spriteid_1 spriteid_1
	getactorvar[THISACTOR].spriteid_2 spriteid_2
	getactorvar[THISACTOR].spriteid_3 spriteid_3
	getactorvar[THISACTOR].saw_blood saw_blood
	ldist DIST spriteid_1 PLAYERID
	ldist DIST2 spriteid_2 PLAYERID
	ldist DIST3 spriteid_3 PLAYERID
	getactor[THISACTOR].xrepeat xrepeat
	divvarvar DIST xrepeat
	divvarvar DIST2 xrepeat
	divvarvar DIST3 xrepeat
	ifvarg spriteid_1 0
	ifvarvarl DIST 6
	{
		setactor[saw_blood].cstat 16
		soundonce SAWCUT
		getactor[PLAYERID].extra paextra
		subvar paextra 1
		setactor[PLAYERID].extra paextra
		ifcount 26 { ifrnd 96 sound PLAY1106 else ifrnd 96 sound PLAY1107 else sound PLAY1108 resetcount }
		setvar peractor 1
	} else
	ifvarg spriteid_2 0
	ifvarvarl DIST2 6
	{
		setactor[saw_blood].cstat 16
		soundonce SAWCUT
		getactor[PLAYERID].extra paextra
		subvar paextra 1
		setactor[PLAYERID].extra paextra
		ifcount 26 { ifrnd 96 sound PLAY1106 else ifrnd 96 sound PLAY1107 else sound PLAY1108 resetcount }
		setvar peractor 1
	}  else
	ifvarg spriteid_3 0
	ifvarvarl DIST3 6
	{
		setactor[saw_blood].cstat 16
		soundonce SAWCUT
		getactor[PLAYERID].extra paextra
		subvar paextra 1
		setactor[PLAYERID].extra paextra
		ifcount 26 { ifrnd 96 sound PLAY1106 else ifrnd 96 sound PLAY1107 else sound PLAY1108 resetcount }
		setvar peractor 1
	}
	else setactor[saw_blood].cstat 32768
	
	ifvare peractor 1 action BLOODYSAW_ON
	ifaction SAW_OFF { action SAW_ON } else
	ifaction BLOODYSAW_OFF { action BLOODYSAW_ON }
} 
else { stopactorsound THISACTOR SAWRUN
ifaction SAW_ON action SAW_OFF else
ifaction BLOODYSAW_ON action BLOODYSAW_OFF
}
enda


// Thanks to Eddy Zikov for breakable objects

defineprojectile GREENLEAF PROJ_WORKSLIKE 6274
defineprojectile GREENLEAF PROJ_HITRADIUS 0
defineprojectile GREENLEAF PROJ_VEL 64
defineprojectile GREENLEAF PROJ_DROP -256
defineprojectile GREENLEAF PROJ_BSOUND -1
defineprojectile GREENLEAF PROJ_XREPEAT 32
defineprojectile GREENLEAF PROJ_YREPEAT 32
defineprojectile GREENLEAF PROJ_SPAWNS GREENLEAFFLOOR

defineprojectile YELLOWLEAF PROJ_WORKSLIKE 6274
defineprojectile YELLOWLEAF PROJ_HITRADIUS 0
defineprojectile YELLOWLEAF PROJ_VEL 64
defineprojectile YELLOWLEAF PROJ_DROP -256
defineprojectile YELLOWLEAF PROJ_BSOUND -1
defineprojectile YELLOWLEAF PROJ_XREPEAT 32
defineprojectile YELLOWLEAF PROJ_YREPEAT 32
defineprojectile YELLOWLEAF PROJ_SPAWNS YELLOWLEAFFLOOR

state random_param

/*
	getprojectile[JIBS7].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS7].vel tmp
	getprojectile[JIBS8].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS8].vel tmp
	getprojectile[JIBS9].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS9].vel tmp
	getprojectile[JIBS10].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS10].vel tmp
	getprojectile[JIBS11].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS11].vel tmp
	getprojectile[JIBS12].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS12].vel tmp
	getactor[RETURN].ang ang
	randvar tmp 2048
	ifrnd 128 mulvar tmp -1
	addvarvar ang tmp
	setactor[RETURN].ang ang
*/
	
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	setvarvar x2 x
	mulvar xrepeat 2
	addvarvar x2 xrepeat
	randvar ang 2048
	ifrnd 128 mulvar ang -1
	rotatepoint x y x2 y ang x3 y3
	setactor[RETURN].x x3
	setactor[RETURN].y y3
	getactor[RETURN].z z
	randvar tmp3 4092
	addvarvar z tmp3
	setactor[RETURN].z z
	
ends

state randomleafstate

	randvar zdist 1024
	ifrnd 128 mulvar zdist -1
	subvar zdist 4096
	ifrnd 128 ezshootvar zdist GREENLEAF else ezshootvar zdist YELLOWLEAF
	state random_param

ends

state leafs_state
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
ends

state drippercode
fall cstator 257
ifvare obj_statnum 0  {
ifhitweapon { state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
state randomleafstate
setvar in1 15
setvar in2 SPARK7
state spawn_multiply
setvar in1 15
setvar in2 SPARK1
state spawn_multiply
sound POTTERY killit }
}
ends

state bottlecode cstator 257
ifvare obj_statnum 0  {
	ifhitweapon {
	setvar in1 15
	setvar in2 GLASS_PART
	state spawn_multiply
	sound POTTERY
	killit }
}
ends

state vasecode fall cstator 257
ifvare obj_statnum 0  {
ifhitweapon {
	setvar in1 16
	setvar in2 SCRAP2_PART
	state spawn_multiply
	sound POTTERY
	killit }
}
ends

state rackcode fall cstator 257 sizeat 32 32
ifhitweapon 
{ 	ifactor RACK2
	{	
	setactorvar[THISACTOR].newscrap_pal 9
		setvar in1 10
		setvar in2 JIBS9
		state spawn_multiply
	}
	randvar in1 10
	addvar in1 10
	setvar in2 SCRAP2_PART
	state spawn_multiply
	setvar in1 10
	setvar in2 GLASS_PART
	state spawn_multiply
	sound VENT_BUST killit }
ifp palive ifp pfacing ifpdistl 1048 ifhitspace soundonce DRINK
ends

state rackcode2 cstator 273
ifvare obj_statnum 0  {
	ifhitweapon { 
	setvar in1 10
	setvar in2 SPARK5
	state spawn_multiply 
	setvar in1 5
	setvar in2 SCRAP2_PART
	state spawn_multiply
	sound SPLNTWOD killit }
}
ends

state skeletondestr cstator 257
ifvare obj_statnum 0  {
	ifhitweapon { 
	setvar in1 10
	setvar in2 SCRAP2_PART
	state spawn_multiply
	setvar in1 6
	setvar in2 SPARK7
	state spawn_multiply
	sound SHATSTON killit }
}
ends

state pancode cstator 257
ifvare obj_statnum 0  {
ifhitweapon { setvar in1 15
setvar in2 SCRAP_PART
state spawn_multiply
sound VENT_BUST
killit }
}
ends

state rockcode cstator 257
ifvare obj_statnum 0  {
ifhitweapon { setvar in1 8
	setvar in2 SPARK4
	state spawn_multiply 
	setvar in1 8
	setvar in2 SCRAP_PART
	state spawn_multiply 	
	sound SHATSTON
	killit }
}
ends

actor 7617 cstator 256
ifvare obj_statnum 0  {
	ifhitweapon { sound SPLNTWOD
	setvar in1 15
	setvar in2 SCRAP_PART
	state spawn_multiply
	killit }
}
enda

actor 7618 cstator 256
ifvare obj_statnum 0  {
	ifhitweapon { sound SPLNTWOD
	setvar in1 15
	setvar in2 SCRAP_PART
	state spawn_multiply
	killit }
}
enda

actor ROCK1 state rockcode enda
actor 5752 state rockcode enda
actor 5925 state rockcode enda
actor 5926 state rockcode enda
actor 5928 state rockcode enda
actor 7614 state rockcode enda

actor DROPPER1 state drippercode enda
actor DROPPER2 state drippercode enda
actor DROPPER3 state drippercode enda

actor BEERBOTTLE cstator 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 GLASSVASE state bottlecode enda

eventloadactor VASE2
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
enda

useractor notenemy VASE2
cstator 257
ifvare LOTAGSAVED 0
{
	ifspritepal 0 
	{ 
		setactorvar[THISACTOR].active 1
		espawn BLOODFIRE1
		getactor[THISACTOR].xrepeat xrepeat
		getactor[THISACTOR].yrepeat yrepeat
		setactor[RETURN].xrepeat xrepeat
		setvarvar tmp xrepeat
		divvar tmp 2
		setactor[RETURN].yrepeat tmp
		getactor[THISACTOR].z emz
		getactor[THISACTOR].cstat acstat
		ifvarand acstat 128 mulvarvar yrepeat 52 else mulvarvar yrepeat 108
		subvarvar emz yrepeat
		setactor[RETURN].z emz
		spritepal 30
	}
}
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 cstator 257
ifhitweapon { sound VENT_BUST
setvar in1 15
setvar in2 SCRAP2_PART
state spawn_multiply
state leafs_state
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 
ifvarn obj_statnum 15 
{ 
	cstator 273
	ifhitweapon 
	{ 
		setvar in1 10
		setvar in2 SCRAP2_PART
		state spawn_multiply
		sound VENT_BUST killit 
	} 
} 
enda

actor RACK11 cstator 273
ifhitweapon { setvar in1 4
setvar in2 SCRAP2_PART
state spawn_multiply
sound VENT_BUST killit }
enda

actor RACK12 state rackcode2 enda
 
actor BL_ANT
cstator 256
ifhitweapon 
{ 
setvar in1 8
setvar in2 SCRAP2_PART
state spawn_multiply
sound VENT_BUST killit 
}
enda

actor BL_ELANT1
cstator 256
ifhitweapon 
{ 
	setactorvar[THISACTOR].newscrap_pal 10
	setactorvar[THISACTOR].setspark_phis 1
	setvar in1 8
	setvar in2 SPARK1
	state spawn_multiply 

	setvar in1 8
	setvar in2 SCRAP2_PART
	state spawn_multiply
	sound VENT_BUST killit 
}
enda

actor BL_ELANT2
cstator 256
ifhitweapon 
{ 
	setactorvar[THISACTOR].newscrap_pal 10
	setactorvar[THISACTOR].setspark_phis 1
	setvar in1 8
	setvar in2 SPARK1
	state spawn_multiply  
	setvar in1 8
	setvar in2 SCRAP2_PART
	state spawn_multiply
	sound VENT_BUST killit 
}
enda

actor JECK TOUGH fall cstator 257
ifhitweapon { setvar in1 20
	setvar in2 JIBS9
	state spawn_multiply
	setvar in1 20
	setvar in2 SCRAP_PART
	state spawn_multiply
	sound SPLNTWOD killit }
enda

actor VASE6 fall cstator 257
ifhitweapon { setvar in1 10
	setvar in2 SCRAP2_PART
	state spawn_multiply
	setactorvar[THISACTOR].newscrap_pal 10
	setactorvar[THISACTOR].setspark_phis 1
	setvar in1 16
	setvar in2 SPARK1
	state spawn_multiply 
	sound POTTERY 
	killit } 
enda

/*
actor BVASE cstator 257
ifhitweapon { sound POTTERY killit }
enda
*/

actor MEAT1 cstator 257
state deadman_state
enda

actor MEAT2 cstator 257
state deadman_state
enda

state spawn_airball
setvarvar utl_tmp1 in1
whilevarn utl_tmp1 0
{
	espawnvar in2
	setactor[RETURN].xrepeat 14
	setactor[RETURN].yrepeat 14
	subvar utl_tmp1 1
}
ends

//!!!!осколки вылетают из низа спрайта
move AIRBALLSPEED 10 -100
actor AIRBALL cstator 256
ifhitweapon 
{ 
	setvarvar in1 2
	setvar in2 GLASS_PART2
	state spawn_airball
	setvarvar in1 2
	setvar in2 GLASS_PART2
	state spawn_airball
	setvarvar in1 2
	setvar in2 GLASS_PART3
	state spawn_airball
	setvarvar in1 2
	setvar in2 GLASS_PART4
	state spawn_airball
	setvarvar in1 2
	setvar in2 GLASS_PART5
	state spawn_airball
soundonce BALLNPOP killit 
}

ifpdistl 1280 ifcansee ifhitspace { move AIRBALLSPEED geth }
ifceilingdistl 10 { debris SCRAP3 8 soundonce BALLNPOP killit } 
enda

actor DEADMAN1 fall cstator 256
state jibs_state
enda

actor DEADMAN2 fall cstator 256
state jibs_state
enda

actor DEADMAN3 fall cstator 256
state jibs_state
enda

actor DEADMAN4 TOUGH cstator 273
state jibs_state
enda

useractor 4 DEADMAN5 TOUGH cstator 273
state jibs_state
enda

actor DEADMAN6 TOUGH cstator 256
ifhitweapon 
{
	setvar in1 10
	setvar in2 JIBS9
	setvarvar utl_tmp1 in1
	whilevarn utl_tmp1 0
	{
		espawnvar in2
		setactorvar[RETURN].setspark_phis 2
		getactor[THISACTOR].z z
		addvar z 10000
		setactor[RETURN].z z
		subvar utl_tmp1 1
	}
	ifrnd 64 { sound FLSHDOR1 } else ifrnd 64 { sound FLSHDOR2 }
	ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
	state bloodspraystate
	killit
}
enda

actor DEADMAN7 TOUGH cstator 256 fall
state jibs_state
enda

actor DEADMAN8 TOUGH state skeletondestr enda
actor 5808 TOUGH state skeletondestr enda
actor 5811 TOUGH state skeletondestr enda
actor 5816 TOUGH state skeletondestr enda

eventloadactor DEADMAN9
	getactor[THISACTOR].x coorx1
	getactor[THISACTOR].y coory1
	espawn WATERDRIP3
	getactor[THISACTOR].z z
	addvar z 13000
	setactor[RETURN].z z
	setactorvar[RETURN].coorx1 coorx1 
	setactorvar[RETURN].coory1 coory1 
	setactorvar[RETURN].coorz1 coorz1 
	setactorvar[RETURN].active 1
	setactorvar[RETURN].prop_id THISACTOR
enda

actor DEADMAN9 TOUGH cstator 256
ifhitweapon 
{
	setvar in1 10
	setvar in2 JIBS9
	setvarvar utl_tmp1 in1
	whilevarn utl_tmp1 0
	{
		espawnvar in2
		setactorvar[RETURN].setspark_phis 2
		getactor[THISACTOR].z z
		addvar z 10000
		setactor[RETURN].z z
		subvar utl_tmp1 1
	}
	ifrnd 64 { sound FLSHDOR1 } else ifrnd 64 { sound FLSHDOR2 }
	ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
	state bloodspraystate
	killit
}

enda

actor DEADMAN10 TOUGH cstator 256 fall
state jibs_state
enda

//!!!! Труп культиста должен дергать ногой, а потом исчезать с анимацией
actor DEADMAN11 TOUGH cstator 256 fall
state jibs_state
enda

actor DEADMAN12 TOUGH cstator 257
state jibs_state
enda

actor DEADWOMAN2 TOUGH cstator 257
state jibs_state
enda

actor DEADWOMAN cstator 256
state jibs_state
enda

actor DEADLEG TOUGH cstator 256 fall sizeat 30 30
ifhitweapon
	{
		getactor[THISACTOR].htang htang
		setvar in1 3
		setvar in2 JIBS9
		state spawn_multiply
		
		ifrnd 64 { sound FLSHDOR1 } else ifrnd 64 { sound FLSHDOR2 }
		ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
		state bloodspraystate
		killit
	}
enda

actor DEADDOG cstator 256
ifhitweapon { 
        setactorvar[THISACTOR].setspark_phis 2
		setvar in1 15
		setvar in2 JIBS9
		state spawn_multiply
		sound 604
 killit }
enda

actor MANHEAD fall cstator 256
ifhitweapon { 
        setactorvar[THISACTOR].setspark_phis 2
		setvar in1 8
		setvar in2 JIBS9
		state spawn_multiply
 killit }
enda

actor BRAIN1 fall cstator 257
ifhitweapon { sound POTTERY
		setvar in1 15
		setvar in2 JIBS9
		state spawn_multiply
		setvar in1 15
		setvar in2 GLASS_PART
		state spawn_multiply
		killit }
enda

actor BRAIN2
fall cstator 257
ifhitweapon { sound POTTERY
		setvar in1 15
		setvar in2 JIBS9
		state spawn_multiply
		setvar in1 15
		setvar in2 GLASS_PART
		state spawn_multiply
		killit }
enda

actor TOXICBARREL fall cstator 257
ifhitweapon { setvar in1 15
		setvar in2 SCRAP2_PART
		state spawn_multiply 
		sound VENT_BUST
		killit }
enda

actor WINEGLASS1
cstator 257
ifhitweapon { sound POTTERY
		setvar in1 15
		setvar in2 JIBS9
		state spawn_multiply
		setvar in1 15
		setvar in2 GLASS_PART
		state spawn_multiply
		killit }
enda

actor WINEGLASS2 state bottlecode enda
actor WINEGLASS3 state bottlecode enda
actor WINEGLASS4 state vasecode enda
 
actor COOKER state pancode enda
actor 7415 state pancode enda
actor 7424 state pancode enda
actor 7425 state pancode enda

actor EWER state vasecode enda

actor MAETBARREL1 fall cstator 257
ifhitweapon { setvar in1 15
		setvar in2 JIBS9
		state spawn_multiply
		setvar in1 15
		setvar in2 SCRAP2_PART
		state spawn_multiply
		sound VENT_BUST
		killit }
enda

actor MAETBARREL2 fall cstator 257
ifhitweapon { setvar in1 13
		setvar in2 JIBS9
		state spawn_multiply
		setvar in1 10
		setvar in2 GLASS_PART
		state spawn_multiply
		setvar in1 10
		setvar in2 SCRAP2_PART
		state spawn_multiply
		ifrnd 32 spawn ZHEADFLOOR
		sound VENT_BUST 
		killit }
enda

actor 7393 fall cstator 257
ifhitweapon { setvar in1 10
		setvar in2 GLASS_PART
		state spawn_multiply
		setvar in1 10
		setvar in2 SPARK1
		state spawn_multiply
		setvar in1 15
		setvar in2 SCRAP2_PART
		state spawn_multiply
		sound SHATSTON
		killit }
enda

actor 7497 fall cstator 257
ifhitweapon { setvar in1 10
		setvar in2 SPARK7
		state spawn_multiply
		setvar in1 10
		setvar in2 SPARK1
		state spawn_multiply
		setvar in1 15
		setvar in2 SCRAP_PART
		state spawn_multiply
		sound SPLNTWOD
		killit }
enda

actor SKULL1
fall //cstator 257
//ifhitweapon { lotsofglass 20 sound POTTERY killit }
enda

actor BARREL
fall cstator 257
enda

action GRIDA1 0 0 0 0 0
action BGRIDA1 1 0 0 0 0

useractor notenemy GRID1
ifaction 0 action GRIDA1 
ifvarn obj_statnum 15 { ifhitweapon ifaction GRIDA1 { getactor[THISACTOR].htpicnum enemy_htpic getactor[THISACTOR].cstat acstat xorvar acstat 257 setactor[THISACTOR].cstat acstat action BGRIDA1 debris SCRAP3 20 sound VENT_BUST } }

enda

action GRIDA2 0 0 0 0 0
action BGRIDA2 1 0 0 0 0
actor GRID2 
ifaction 0 action GRIDA2 

ifaction GRIDA2 ifhitweapon { getactor[THISACTOR].htpicnum enemy_htpic getactor[THISACTOR].cstat acstat xorvar acstat 257 setactor[THISACTOR].cstat acstat action BGRIDA2 setvar in1 16
	setvar in2 SCRAP2_PART
	state spawn_multiply  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 
	setvar in1 10
	setvar in2 GLASS_PART
	state spawn_multiply
	getactor[THISACTOR].htpicnum enemy_htpic
	sound GLASS_BREAKING }
enda

action FANA2 0 0 0 0 0
action BFANA2 3 0 0 0 0
actor FAN01 

ifaction 0 { getactor[THISACTOR].cstat acstat orvar acstat 256 setactor[THISACTOR].cstat acstat action FANA2 } 
ifaction FANA2 ifhitweapon { getactor[THISACTOR].htpicnum enemy_htpic getactor[THISACTOR].cstat acstat xorvar acstat 257 setactor[THISACTOR].cstat acstat action BFANA2 debris SCRAP3 20 sound VENT_BUST }
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
	setvar in1 10
	setactorvar[THISACTOR].setspark_phis 1
	setvar in2 SPARK1
	state spawn_multiply
	setvar in1 20
	setvar in2 SCRAP_PART
	state spawn_multiply
	getactor[THISACTOR].htpicnum enemy_htpic
	sound POTTERY }
enda

state pailkick
	setactorvar[THISACTOR].zheadkick spriteid
	setvar pspeed 512
	setprojectile[PAILMOVE].vel pspeed
    ezshoot pspeed PAILMOVE
	getactor[spriteid].ang tmp
	setactor[RETURN].ang tmp
	sound PUNT
	getactor[THISACTOR].z z
	setactor[RETURN].z z
	killit 
ends

defineprojectile PAILMOVE PROJ_WORKSLIKE 6150
defineprojectile PAILMOVE PROJ_HITRADIUS 0
defineprojectile PAILMOVE PROJ_BOUNCES 5
defineprojectile PAILMOVE PROJ_VEL 300
defineprojectile PAILMOVE PROJ_DROP -120
defineprojectile PAILMOVE PROJ_CSTAT 0
defineprojectile PAILMOVE PROJ_BSOUND PAILKICK
defineprojectile PAILMOVE PROJ_XREPEAT 32
defineprojectile PAILMOVE PROJ_YREPEAT 32
defineprojectile PAILMOVE PROJ_EXTRA 0
defineprojectile PAILMOVE PROJ_SPAWNS PAIL

actor PAILMOVE 0 NO enda

actor PAIL TOUGH
cstator 257 sizeat 32 32 fall

ifpdistl 812 
ifvarg pspeed 0
{ 
	getplayer[THISACTOR].i PLAYERID
	setactorvar[THISACTOR].zheadkick PLAYERID
	mulvar pspeed 4
	setprojectile[PAILMOVE].vel pspeed ifvarg pspeed 256 
	{ mulvar pspeed 6 ezshoot pspeed PAILMOVE } else 
	eshoot PAILMOVE sound PUNT
	getplayer[THISACTOR].ang tmp
	setactor[RETURN].ang tmp
	getactor[THISACTOR].z z
	setactor[RETURN].z z
	killit 
}

findnearactor ZOMBIE 512 spriteid
ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 state pailkick }
findnearactor HERETIC 512 spriteid
ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 state pailkick }

ifhitweapon { ifdead { setvarvar in1 10 setvar in2 SCRAP_PART state spawn_multiply sound VENT_BUST killit } }
enda

actor MIM TOUGH
fall cstator 257
ifhitweapon 
{ 
	ifwasweapon RADIUSEXPLOSION 
	{ setvar in1 30
		setvar in2 JIBS9
		state spawn_multiply
		ifrnd 64 { sound FLSHDOR1 } else ifrnd 64 { sound FLSHDOR2 }
		ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
		state bloodspraystate
		soundonce 469
		killit
	} else 
	ifdead
	{ 
	state bloodspraystate
	state bloodspraystate
	setvar in1 1
	setvar in2 MIMJIB1
	state spawn_multiply
	setvar in1 2
	setvar in2 MIMJIB2
	state spawn_multiply
	setvar in1 5
	setvar in2 JIBS9
	state spawn_multiply
	setvar in1 1
	ifrnd 92 setvar in2 JIBS8 else ifrnd 92 setvar in2 JIBS7 else setvar in2 JIBS12
	state spawn_multiply
	soundonce 469
	killit 
	}
	soundonce 469
}
enda

//------------------------------Scripts

useractor notenemy TNTFLOOR TOUGH
fall sizeat 24 24 cstat 256
getactor[THISACTOR].pal pal
ifvare pal 0
{
	ifspawnedby TNTBUNDLE2
	{
		randvar COUNTER 16
		ifvare COUNTER 1 {
			iffloordistl 8 { spawn EXPLOSION3 } else { spawn EXPLOSION4 ifvare QUAKETIME 0 { setvar QUAKETIME 26 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } }
			hitradius 1536 50 100 125 200
			soundonce EXPLODCM
			killit
		}
	} else
	{
		iffloordistl 8  { spawn EXPLOSION3 } else 
		{ spawn EXPLOSION4 ifvare QUAKETIME 0 { setvar QUAKETIME 26 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } }
		hitradius 1536 50 100 125 200
		soundonce EXPLODCM
		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 EXPLOSION4 ifvare QUAKETIME 0 { setvar QUAKETIME 26 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } }
		hitradius 1536 50 100 125 200
		soundonce EXPLODCM
		setvar TNTFLOORALT 0
		setvar detonatecount 0
		killit
	}
}

ifhitweapon
{
	spawn EXPLOSION3
	hitradius 1536 50 100 125 200
	soundonce EXPLODCM
	setvar TNTFLOORALT 0
	setvar detonatecount 0
	killit
}

ifvare sector[sprite[THISACTOR].sectnum].hitag 40 iffloordistl 8 {
	spawn EXPLOSION3
	hitradius 1536 50 100 125 200
	soundonce EXPLODCM
	setvar TNTFLOORALT 0
	setvar detonatecount 0
	killit
}
enda

useractor notenemy ENEMYTNTFLOOR TOUGH
	fall sizeat 32 32 cstat 256
	iffloordistl 8 { spawn EXPLOSION3 } else { spawn EXPLOSION4 ifvare QUAKETIME 0 { setvar QUAKETIME 26 setvar QUAKEACTIVE 1 } else { setvar QUAKETIME 36 setvar QUAKEACTIVE 2 } }
	hitradius 1200 20 30 40 50
	soundonce EXPLODCM
	killit
enda

useractor notenemy REMOTEFLOOR TOUGH
fall sizeat 32 32 cstat 256
getplayer[remoteplayer].hbomb_on hbomb_on
ifvare hbomb_on 0 { state MINEEXPLODE }
ifhitweapon { state MINEEXPLODE }

ifvare sector[sprite[THISACTOR].sectnum].hitag 40 iffloordistl 8 {
	spawn EXPLOSION3
	hitradius 1536 50 100 125 200
	soundonce EXPLODCM
	setvar TNTFLOORALT 0
	setvar detonatecount 0
	killit
}

ifvare peractor 0
{
	espawn SMALLSMOKE
	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
}

ifvare sector[sprite[THISACTOR].sectnum].hitag 40 iffloordistl 8 {
	spawn EXPLOSION3
	hitradius 1536 50 100 125 200
	soundonce EXPLODCM
	setvar TNTFLOORALT 0
	setvar detonatecount 0
	killit
}
enda

useractor notenemy PROXIMITYFLOOR TOUGH
fall sizeat 32 32 cstat 256
ifcount 52
{
	ifspritepal 0 { sound PROXARM spritepal 30 }
	findnearactor ZOMBIE 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor HERETIC 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor EVILHAND 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor FATRAT 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor BUTCHER 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor SPIDER 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor HELLDOG 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor GILLBEAST 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor CIVILIAN 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	findnearactor BURNINGGUY 1280 tmp
	ifvarn tmp -1 ifvarg sprite[tmp].extra 0 { state MINEEXPLODE } else
	ifpdistl 1536 ifvarg sprite[PLAYERID].extra 0 { state MINEEXPLODE }
}
ifhitweapon { state MINEEXPLODE }


ifvare sector[sprite[THISACTOR].sectnum].hitag 40 iffloordistl 8 {
	spawn EXPLOSION3
	hitradius 1536 50 100 125 200
	soundonce EXPLODCM
	setvar TNTFLOORALT 0
	setvar detonatecount 0
	killit
}

ifvare peractor 0
{
	espawn SMALLSMOKE
	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
}
enda

spritenoshade SPRAYFLOOR
useractor notenemy SPRAYFLOOR TOUGH
fall sizeat 32 32 cstat 256
getactor[THISACTOR].pal pal
ifvare pal 0
{
espawn EXPLOSION6
setactor[RETURN].xrepeat 86
setactor[RETURN].yrepeat 86
setactor[RETURN].cstat 0
soundonce EXPLODFM
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 86
	setactor[RETURN].yrepeat 86
	setactor[RETURN].cstat 0
	soundonce EXPLODFS
	setvar detonatecount 0
	setvar SPRAYFLOORALT 0
	killit
	}
}
ifhitweapon
{
espawn EXPLOSION6
setactor[RETURN].xrepeat 86
setactor[RETURN].yrepeat 86
setactor[RETURN].cstat 0
soundonce EXPLODFS
setvar detonatecount 0
setvar SPRAYFLOORALT 0
killit
}
ifvare sector[sprite[THISACTOR].sectnum].hitag 40 iffloordistl 8 {
	espawn EXPLOSION6
	setactor[RETURN].xrepeat 86
	setactor[RETURN].yrepeat 86
	setactor[RETURN].cstat 0
	soundonce EXPLODFS
	setvar detonatecount 0
	setvar SPRAYFLOORALT 0
	killit
}


findnearactor EXPLOSION6 2048 spriteid 
ifvarn spriteid -1 {
	espawn EXPLOSION6
	setactor[RETURN].xrepeat 86
	setactor[RETURN].yrepeat 86
	setactor[RETURN].cstat 0
	soundonce EXPLODFS
	setvar detonatecount 0
	setvar SPRAYFLOORALT 0
	killit
}

enda


useractor notenemy CALEBLYINGDEAD
sizeat 32 32 fall cstat 256
ifhitweapon { state jibs_state killit }
enda
 
useractor notenemy PDEAD_FATALITY1
sizeat 32 32 fall cstat 256
ifhitweapon { state jibs_state killit }
enda
 
useractor notenemy PDEAD_FATALITY2
sizeat 32 32 fall cstat 256
ifhitweapon { state jibs_state killit }
enda

useractor notenemy BL_TELEP
ifspritepal 1 { ifmultiplayer nullop else killit }
enda

eventloadactor TORCH01 //факел, создает огонь BLOODFIRE1 над собой
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
ifvare LOTAGSAVED 0
{
	espawn BLOODFIRE1
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	divvar xrepeat 2
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat xrepeat
	getactor[THISACTOR].z emz
	getactor[THISACTOR].cstat acstat
	ifvarand acstat 128 mulvarvar yrepeat 46 else mulvarvar yrepeat 92
	subvarvar emz yrepeat
	setactor[RETURN].z emz
}
enda

eventloadactor TORCH02 //факел, создает огонь BLOODFIRE1 над собой
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
ifvare LOTAGSAVED 0
{
	espawn BLOODFIRE1
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	divvar xrepeat 3
	mulvar xrepeat 2
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat xrepeat
	getactor[THISACTOR].z emz
	getactor[THISACTOR].cstat acstat
	ifvarand acstat 128 mulvarvar yrepeat 120 else mulvarvar yrepeat 240
	subvarvar emz yrepeat
	setactor[RETURN].z emz
}
enda

useractor notenemy TORCH02
ifvare LOTAGSAVED 0 ifaction NO action ONE
enda

eventloadactor TORCH03 //факел, создает огонь BLOODFIRE1 над собой
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
ifvare LOTAGSAVED 0
{
	espawn BLOODFIRE1
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	divvar xrepeat 2
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat xrepeat
	getactor[THISACTOR].z emz
	getactor[THISACTOR].cstat acstat
	ifvarand acstat 128 mulvarvar yrepeat 28 else mulvarvar yrepeat 56
	subvarvar emz yrepeat
	setactor[RETURN].z emz
}
enda

eventloadactor LIGHT4
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
ifvare LOTAGSAVED 0
{
	espawn 5744
	setvarvar obj_owner RETURN
	changespritestat RETURN 1
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	divvar xrepeat 2
	setactor[RETURN].xrepeat xrepeat
	setactor[RETURN].yrepeat xrepeat
	getactor[THISACTOR].z emz
	getactor[THISACTOR].cstat acstat
	ifvarand acstat 128 mulvarvar yrepeat 120 else mulvarvar yrepeat 240
	divvar yrepeat 5
	setvarvar coorz1 yrepeat
	subvarvar emz yrepeat
	setactor[RETURN].z emz
	setactor[RETURN].pal 8
	setactor[RETURN].cstat 514
}
enda

useractor notenemy LIGHT4 //свечка, создает ауру на огне
fall 
ifvare LOTAGSAVED 0 ifvare obj_statnum 0 {
	setactor[obj_owner].x sprite[THISACTOR].x
	setactor[obj_owner].y sprite[THISACTOR].y
	getactor[THISACTOR].z z
	subvarvar z coorz1
	setactor[obj_owner].z  z
}
enda

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

action ACHAIN_01 0
action ACHAIN_02 1
action ACHAIN_03 2
action ACHAIN_04 3
action ACHAIN_05 4
action ACHAIN_06 3
action ACHAIN_07 2
action ACHAIN_08 1


actor CHAIN
ifpdistl 6144 soundonce 618
ifspritepal 0
{
randvar chain_var 7
ifvare chain_var 0 action ACHAIN_01 else
ifvare chain_var 1 action ACHAIN_02 else
ifvare chain_var 2 action ACHAIN_03 else
ifvare chain_var 3 action ACHAIN_04 else
ifvare chain_var 4 action ACHAIN_05 else
ifvare chain_var 5 action ACHAIN_06 else
ifvare chain_var 6 action ACHAIN_07 else
ifvare chain_var 7 action ACHAIN_08
spritepal 30
}

addvar COUNTER 1
ifvare COUNTER 7
{
setvar COUNTER 0
ifaction ACHAIN_01 action ACHAIN_02 else
ifaction ACHAIN_02 action ACHAIN_03 else
ifaction ACHAIN_03 action ACHAIN_04 else
ifaction ACHAIN_04 action ACHAIN_05 else
ifaction ACHAIN_05 action ACHAIN_06 else
ifaction ACHAIN_06 action ACHAIN_07 else
ifaction ACHAIN_07 action ACHAIN_08 else
ifaction ACHAIN_08 action ACHAIN_01
}
enda




action AFLAVOR_01 0
action AFLAVOR_02 1
action AFLAVOR_03 2
action AFLAVOR_04 1


actor FLAVOR
ifspritepal 0
{
randvar flavor_var 3
ifvare flavor_var 0 action AFLAVOR_01 else
ifvare flavor_var 1 action AFLAVOR_02 else
ifvare flavor_var 2 action AFLAVOR_03 else
ifvare flavor_var 3 action AFLAVOR_04
spritepal 30
}

addvar COUNTER 1
ifvare COUNTER 5
{
setvar COUNTER 0
ifaction AFLAVOR_01 action AFLAVOR_02 else
ifaction AFLAVOR_02 action AFLAVOR_03 else
ifaction AFLAVOR_03 action AFLAVOR_04 else
ifaction AFLAVOR_04 action AFLAVOR_01
}
enda

action WATERSPLASH 0 4 1 1 7

eventloadactor WATERDRIP2
getactor[THISACTOR].zvel tr_bits
getactor[THISACTOR].x coorx1
getactor[THISACTOR].y coory1
getactor[THISACTOR].z coorz1
ifvare tr_bits 0 setactorvar[THISACTOR].active 1
enda

actor WATERDRIP2
sizeat 18 18 fall
getactorvar[THISACTOR].active active
ifaction WATERSPLASH
{ 
	ifactioncount 4	
	{ 
		cstat 32768
		ifvare active 1 addvar peractor 1 else setvar peractor 0
		ifvarg peractor 96
		{
			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 
			getactorvar[THISACTOR].se_xvel tmp
			setactorvar[RETURN].se_xvel tmp
			setactorvar[RETURN].active 1
			killit 
		}			
	}
}
ifaction NO iffloordistl 1 { action WATERSPLASH ifpdistl 4096 ifcansee soundonce DRIP1 }
enda

action WATERSPLASH_2 -11 4 1 1 7

eventloadactor WATERDRIP3
getactor[THISACTOR].zvel tr_bits
getactor[THISACTOR].x coorx1
getactor[THISACTOR].y coory1
getactor[THISACTOR].z coorz1
ifvare tr_bits 0 setactorvar[THISACTOR].active 1
getactor[THISACTOR].hitag hitag
setactorvar[THISACTOR].prop_id hitag
enda

actor WATERDRIP3
sizeat 24 24 fall
getactorvar[THISACTOR].active active
ifaction WATERSPLASH_2
{ 
	ifactioncount 4	
	{ 
		cstat 32768
		ifvare active 1 addvar peractor 1 else setvar peractor 0
		ifvarg peractor 96
		{
			getactorvar[THISACTOR].prop_id tmp
			ifvarg tmp 0
			{
				getactor[tmp].statnum astatnum
				ifvare astatnum 1024 killit
			}
			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 
			getactorvar[THISACTOR].se_xvel tmp
			setactorvar[RETURN].se_xvel tmp
			getactorvar[THISACTOR].prop_id tmp
			setactorvar[RETURN].prop_id tmp
			setactorvar[RETURN].active 1
			killit 
		}			
	}
}
ifaction NO iffloordistl 1 { action WATERSPLASH_2 ifpdistl 4096 ifcansee soundonce DRIP1 }
enda

action WATERSPLASH_3 0 4 1 1 7

eventloadactor WATERDRIP4
cstat 32768
getactor[THISACTOR].zvel tr_bits
getactor[THISACTOR].z coorz1
getactor[THISACTOR].sectnum sectnum
ifvare tr_bits 0 setvar active 1
getactor[THISACTOR].hitag hitag
setvarvar prop_id hitag
enda

actor WATERDRIP4
ifvarg active 1 setvar active 0
ifvare mov_tmp 1 {
	fall
	ifaction WATERSPLASH_3 { 
		ifactioncount 4 { 
			killit
		}
	}
	ifaction NO iffloordistl 1 { action WATERSPLASH_3 ifpdistl 4096 ifcansee soundonce DRIP1 }
} else {

	ifvare active 1 {
		randvar peractor 30
	} else setvar peractor 0
	
	ifvare peractor 1 {
		espawn WATERDRIP4 
		setactor[RETURN].xrepeat sprite[THISACTOR].xrepeat 
		setactor[RETURN].yrepeat sprite[THISACTOR].yrepeat  
		setactor[RETURN].cstat 128
		setactorvar[RETURN].mov_tmp 1 
	}
}
enda


action RENTOFF 0 1 1 1 1
action RENTON 1 1 1 1 1

state rentactivation
	getactor[spriteid].x mx
	getactor[spriteid].y my
	getactor[spriteid].z mz
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].z z
	getactor[spriteid].extra extra
	subvarvar mx x
	subvarvar my y
	getangle mang mx my
	getactor[THISACTOR].ang ang
	getincangle mang mang ang
	ifvarg extra 0
	ifvarg mang -384 ifvarl mang 384
	{ action RENTON } else action RENTOFF
ends

actor RENTDISP 0 RENTOFF cstat 19
getactor[THISACTOR].xoffset xoffset
findnearactorvar ZOMBIE 768 spriteid
ifvarn spriteid -1 { state rentactivation } else
findnearactorvar CIVILIAN 768 spriteid
ifvarn spriteid -1 { state rentactivation } else
findnearactorvar HERETIC 768 spriteid
ifvarn spriteid -1 { state rentactivation } else
findnearactorvar BUTCHER 768 spriteid
ifvarn spriteid -1 { state rentactivation } else
findnearactorvar GILLBEAST 768 spriteid
ifvarn spriteid -1 { state rentactivation } else
findnearspritevar APLAYER 768 spriteid
ifvarn spriteid -1 { state rentactivation } else action RENTOFF
enda

action OSCILON 0 1 1 1 1
action OSCILOFF 5 1 1 1 1
//action OSCILALARM 4 1 1 1 1

eventloadactor OSCILOSCOPE
getactor[THISACTOR].hitag HITAGSAVED
setactor[THISACTOR].hitag 0
ifvare HITAGSAVED 1 setactorvar[THISACTOR].active 1
enda

actor OSCILOSCOPE  0 OSCILOFF cstat 19
getactorvar[THISACTOR].active active
ifvarg active 1 setactorvar[THISACTOR].active 0
ifvare active 1 action OSCILON else action OSCILOFF
enda


eventloadactor LIGHT3
 getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
enda

actor LIGHT3 //мигалка
getactorvar[THISACTOR].active active
ifvarg active 1 setactorvar[THISACTOR].active 0
ifvare active 1 
{ 
ifvare peractor 0 { action ONE setvar peractor 1 } 
ifaction ONE ifvarg LOTAGSAVED 0 { addvar peractor 1 ifvarvare peractor LOTAGSAVED { action NULL setactorvar[THISACTOR].active 0 setvar peractor 0 } } 
} 
else ifvarg peractor 0 { action NULL setvar peractor 0 }
enda


eventloadactor LIGHTING //молния в e1m5
getactor[THISACTOR].zvel tr_bits
ifvare tr_bits 1 cstat 32768
enda
 
spritenoshade LIGHTING
actor LIGHTING
ifvare tr_bits 1 {
	ifvare active 1 {
		addvar COUNTER 1
		ifvare COUNTER 2 { spawn EXPLOSION4 soundonce EXPLODCM hitradius 2048 60 100 160 300 setactor[THISACTOR].cstat 4 }
		ifvare COUNTER 4 setactor[THISACTOR].cstat 8
		ifvare COUNTER 6 setactor[THISACTOR].cstat 12
		ifvare COUNTER 8 setactor[THISACTOR].cstat 0
		ifvare COUNTER 10 setactor[THISACTOR].cstat 8
		ifvare COUNTER 12 killit
	}
}
enda

spritenoshade BLOODFIRE1
eventloadactor BLOODFIRE1
state expanding_sprite
enda

actor BLOODFIRE1
state game_expandingspr
enda


spritenoshade BLOODFIRE2
eventloadactor BLOODFIRE2
state expanding_sprite
enda

actor BLOODFIRE2
state game_expandingspr
enda

action AAXE_01 0
action AAXE_02 1
action AAXE_03 2
action AAXE_04 3
action AAXE_05 4
action AAXE_06 5
action AAXE_07 6
action AAXE_08 5
action AAXE_09 4
action AAXE_10 3
action AAXE_11 2
action AAXE_12 1

actor BIGAXE 0 AAXE_01
addvar COUNTER 1
ifvare COUNTER 4
{
setvar COUNTER 0
ifaction AAXE_01 action AAXE_02 else
ifaction AAXE_02 action AAXE_03 else
ifaction AAXE_03 action AAXE_04 else
ifaction AAXE_04 { soundonce AZOMSWIP action AAXE_05 } else
ifaction AAXE_05 action AAXE_06 else
ifaction AAXE_06 action AAXE_07 else
ifaction AAXE_07 action AAXE_08 else
ifaction AAXE_08 action AAXE_09 else
ifaction AAXE_09 action AAXE_10 else
ifaction AAXE_10 { soundonce AZOMSWIP action AAXE_11 } else
ifaction AAXE_11 action AAXE_12 else
ifaction AAXE_12 action AAXE_01
}
enda

eventloadactor AEARTHQUAKE
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
getactor[THISACTOR].hitag HITAGSAVED
setactor[THISACTOR].hitag 0
cstat 32768
enda

actor AEARTHQUAKE
getactorvar[THISACTOR].active active
ifvare active 1
{
addvarvar COUNTER 1
ifvarvarl COUNTER LOTAGSAVED setvar QUAKEACTIVE 1 else { setactorvar[THISACTOR].active 0 setvar QUAKEACTIVE 0 setvar COUNTER 0 }
}
enda

eventloadactor WATERBUBBLES
state expanding_sprite
enda

actor WATERBUBBLES
state game_expandingspr
enda

actor CYLINDERSAW
getactor[THISACTOR].ang ang
addvar ang 48
setactor[THISACTOR].ang ang
enda

action ALAVASPARK 0 7 1 1 10

actor LAVASPARK fall
sizeat 32 32
ifaction NO action ALAVASPARK
ifactioncount 7 killit
enda