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

          }
          else
            globalsound JIBBED_ACTOR7
        }
      }
    }
  }
ends

state random_wall_jibs
  ifrnd 96
    {
    shoot BLOODSPLAT1
    //shoot NBPROJ1
    }
  ifrnd 96
    {
    shoot BLOODSPLAT2
    //shoot NBPROJ2
    }
  ifrnd 96
    {
    shoot BLOODSPLAT3
    //shoot NBPROJ3
    }
  ifrnd 96
    {
    shoot BLOODSPLAT4
    //shoot NBPROJ4
    }
  ifrnd 96
    {
    shoot BLOODSPLAT1
    //shoot NBPROJ5
    }
ends

action ATROOPFROZEN    0  1  5

state troop_body_jibs
ifvare gore 0
 {
  ifrnd 64
    guts HEADJIB1 1
  ifrnd 64
    guts LEGJIB1 2
  ifrnd 64
    guts ARMJIB1 1
  ifrnd 48
    spawn BLOODPOOL
 }
else
{
espawn TROOPJIBSHOOTER
  //ifspritepal 22 setactor[RETURN].pal 22
ifaction ATROOPFROZEN setactor[RETURN].pal 22
}

ends

state liz_body_jibs

ifvare gore 0
{
  ifrnd 64
    guts LIZMANHEAD1 1
  ifrnd 64
    guts LIZMANLEG1 2
  ifrnd 64
    guts LIZMANARM1 1
  ifrnd 48
    spawn BLOODPOOL
 }
else
{
espawn LIZJIBSHOOTER
  ifspritepal 22 setactor[RETURN].pal 22
}

ends

state pig_body_jibs
ifvare gore 0 break
espawn PIGJIBSHOOTER
  ifspritepal 22 setactor[RETURN].pal 22

ends


state standard_jibs

ifvarg gore 0 ifvarg framerate 20
{
  state jib_sounds
  
  ifactor LIZMAN { state liz_body_jibs break }
  ifactor LIZTROOP { state troop_body_jibs break }
  ifactor PIGCOP { state pig_body_jibs break }
  ifactor PIGCOPDIVE { state pig_body_jibs break }

 ifactor EGG espawn SMALLJIBSHOOTER
   else ifactor INVISEGG  espawn SMALLJIBSHOOTER
      else espawn JIBSHOOTER
 ifspritepal 22 setactor[RETURN].pal 22
}

else // classic jibs
 {
  ifvare temp APLAYER state jib_sounds

  guts JIBS2 1
  guts JIBS3 2
  guts JIBS4 3
  guts JIBS5 2
  guts JIBS6 3


  ifrnd 12
   {
    guts JIBS1 1
    spawn BLOODPOOL
   }         // a badly drawn spine
 }


 
ends

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

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

 ends

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

useractor notenemy SMALLJIBSHOOTER 0

getactor[THISACTOR].z z
  subvar z 4096
  setactor[THISACTOR].z z
  state brainshoot
  state flesh1shoot
  state flesh1shoot
  state flesh2shoot
  state flesh3shoot
  killit
enda

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

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

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

addvar countvar 1
ifvarg countvar 2 killit
enda

state lizheadshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist LIZHEAD
   ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state lizarmshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist LIZARM
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state lizlegshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist LIZLEG
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state troopheadshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist TROOPHEAD
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state trooparmshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist TROOPARM
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state trooplegshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist TROOPLEG
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state pigheadshoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist PIGHEAD
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state piguppershoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist PIGUPPER
  ifspritepal 22 setthisprojectile[RETURN].pal 22
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist PIGUPPER2
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

state piglowershoot
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist PIGLOWER
  ifspritepal 22 setthisprojectile[RETURN].pal 22
  randvar angvar 2048
  setactor[THISACTOR].ang angvar
  randvar zdist 4096
  mulvar zdist -1
  ezshoot zdist PIGLOWER2
  ifspritepal 22 setthisprojectile[RETURN].pal 22
 ends

useractor notenemy LIZJIBSHOOTER 0
ifvare countvar 0
{
  getactor[THISACTOR].z z
  subvar z 9216
  setactor[THISACTOR].z z
  state lizheadshoot
}

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

ifvare countvar 2
{
 addvar z 4096
 setactor[THISACTOR].z z
 state lizlegshoot
 state lizlegshoot
 state flesh1shoot
}

addvar countvar 1
ifvarg countvar 2 killit
enda

useractor notenemy TROOPJIBSHOOTER 0
ifvare countvar 0
{
  getactor[THISACTOR].z z
  subvar z 9216
  setactor[THISACTOR].z z
  state troopheadshoot
}

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

ifvare countvar 2
{
 addvar z 4096
 setactor[THISACTOR].z z
 state trooplegshoot
 state trooplegshoot
 state flesh1shoot
}

addvar countvar 1
ifvarg countvar 2 killit
enda

useractor notenemy PIGJIBSHOOTER 0
ifvare countvar 0
{
  getactor[THISACTOR].z z
  subvar z 9216
  setactor[THISACTOR].z z
  state pigheadshoot
}

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

ifvare countvar 2
{
 addvar z 4096
 setactor[THISACTOR].z z
 state piglowershoot
 state flesh1shoot
}

addvar countvar 1
ifvarg countvar 2 killit
enda

state newbloodstate

ifspawnedby SHOTSPARK1 nullop else fall
ifvarl framerate 30 ifrnd 96 killit

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

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

iffloordistl 4
{
   cstator 32
	
   getsector[THISACTOR].floorstat temp
   ifvarand temp 1 killit
   ifvarand temp 2 killit
   ifvare mtype 0
   {
	   
	   setvar mtype 1
		setvar holoweap 0
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		getactor[THISACTOR].z z
		getactor[THISACTOR].sectnum mysector
		setvarvar mx x
		addvar mx 480
		setvar angvar 0
		whilevarn angvar 2048
		{
			rotatepoint x y mx y angvar hitx hity
			updatesectorz hitx hity z temp
			ifvarvarn temp mysector ifvarn temp -1
			{
				getflorzofslope temp hitx hity mz
				subvarvar mz z
				ifvarg mz 256
					setvar holoweap 1 // killit
				
			}
			addvar angvar 512
			ifvare holoweap 1 setvar angvar 2048
		}
		ifvare holoweap 1 { killit break }
  }
}
ifcount 1560 sizeto 0 0
ends

move BLOODMOVED

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

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