ACTOR SnotfolusPlayer : PlayerPawn
{
  Health 1200
  Height 110
  Radius 60
  Mass 1000
  Player.forwardmove 0.75
  Player.MaxHealth 24000
  Player.sidemove 0.75
  Player.Jumpz 8
  maxStepHeight 44
  Player.ViewHeight 100
  Player.DisplayName "Snotfolus"
  Player.SoundClass "Snotfolus"
  Player.MorphWeapon "SnotfolusWeapon0"
  Player.StartItem "Mana", 100
  DamageFactor "Boss", 0
  DamageFactor "Slime", 0
  limitedtoteam 1
  painchance 0
  PainSound "Snotfolus/Pain"
  SEESOUND "Snotfolus/Sight"
  DEATHSOUND "Snotfolus/Death"
  Species "Boss"
  +THRUSPECIES
  +NOSKIN
  +NORADIUSDMG
  +DONTTRANSLATE
  -PICKUP
  states
{
	Spawn:
		SNOT A 8 SetPlayerProperty(0, 1, 1)
		Loop
	See:
		SNOT ABCD 4 SetPlayerProperty(0, 1, 1)
		Loop
	Pain:
		TNT1 A 0 A_Pain
		SNOT A 4
	    Goto Spawn
	  Missile:
		SNOT EF 8 bright
		Goto Spawn
	  Death:
	    TNT1 A 0 a_givetotarget("BOSSKILLEDSTAT", 1)
		TNT1 A 0 a_givetotarget("reward", 1)
    	SNOT H 10
    	SNOT IIIIIIIIIIIIIII 1 A_SpawnItemEx("ChexExplosionEffect",0,0,0,random(-10,10),random(-10,10),random(5,10), 0, 128)
    	SNOT JJJJJJJJJJJJJJJ 1 A_SpawnItemEx("ChexExplosionEffect",0,0,0,random(-10,10),random(-10,10),random(5,10), 0, 128)
    	SNOT LLLLLLLLLLLLLLL 1 A_SpawnItemEx("ChexExplosionEffect",0,0,0,random(-10,10),random(-10,10),random(5,10), 0, 128)
    	SNOT M 0 A_Scream
		SNOT MMMMMMMMMMMMMMM 1 A_SpawnItemEx("ChexExplosionEffect",0,0,0,random(-10,10),random(-10,10),random(5,10), 0, 128)
    	SNOT N 10 A_NoBlocking
    	SNOT O 10
    	SNOT P 10
		TNT1 A -1
    	Stop
	}
}

Actor SnotfolusMode1 : Inventory
{
	inventory.maxamount 1
}

Actor SnotfolusMode2 : Inventory
{
	inventory.maxamount 1
}

Actor SnotfolusMode3 : Inventory
{
	inventory.maxamount 1
}

Actor SnotfolusMode4 : Inventory
{
	inventory.maxamount 1
}

ACTOR SnotfolusWeapon0 : Weapon 
{
 Weapon.SelectionOrder 800
 Obituary "%o was raped by %k"
 Inventory.PickupMessage ""
 Inventory.PickupSound "misc/pk_up"
 Weapon.AmmoUse 0
 Weapon.AmmoGive 0
 Weapon.AmmoType "Mana"
 +WEAPON.NOAUTOAIM
  States
 {
  Spawn:
       TNT1 A -1
       Loop
  Ready:
       TNT1 A 1 A_WeaponReady
       goto AltFire
  Fire:
  TNT1 A 1
  goto AltFire
  Deselect:
       TNT1 A 1 A_Lower
       Loop
  Select:
       TNT1 A 0 A_Raise
       Loop
  AltFire:
       TNT1 A 0 A_GiveInventory("SnotfolusWeapon")
       TNT1 A 0 A_SelectWeapon("SnotfolusWeapon")
       TNT1 A 0 
       goto deselect
  Flash:
       SNIF F 3 Bright A_Light2
       SNIF F 3 Bright A_Light1
       SNIF F 0 Bright A_Light0
       Goto LightDone     
       }
}

ACTOR SnotfolusWeapon : Weapon 
{
 Weapon.SelectionOrder 800
 obituary "%o stood no chance against Lord Snotfolus"
 Inventory.PickupMessage ""
 Inventory.PickupSound "misc/pk_up"
 Weapon.AmmoUse 0
 Weapon.AmmoGive 0
 Weapon.AmmoType "Mana"
 +WEAPON.NOAUTOAIM
 +INVENTORY.UNDROPPABLE
  States
 {
  Spawn:
       TNT1 A -1
       Loop
  Ready:
       CLA3 A 1 A_WeaponReady
       goto ready
  Deselect:
       CLA3 A 1 A_Lower
       Loop
  Select:
       CLA3 A 0 A_Raise
       Loop
  Fire:
       TNT1 A 0 A_jumpIfinventory("SnotfolusMode1", 1, "ExpectorationCheck")
       TNT1 A 0 A_jumpIfinventory("SnotfolusMode2", 1, "OutbreakCheck")
       TNT1 A 0 A_jumpIfinventory("SnotfolusMode3", 1, "MineCheck")
	   TNT1 A 0 A_jumpIfinventory("SnotfolusMode4", 1, "SliminessCheck")
	   CLA3 A 1
	   Goto ready
  AltFire:
  	   CLA3 A 1 ACS_execute(812, 0, 13) //812
       CLA3 A 2
       CLA3 A 8
       goto ready
  Expectoration:
       TNT1 A 0 A_Takeinventory("mana", 20)
	   TNT1 A 0 A_PlayWeaponSound("Snotfolus/Attack")
	   CLA3 B 2 Bright A_FireCustomMissile("BigSnotBall", 0, 0, 0, 0)
	   CLA3 B 0 Bright A_FireCustomMissile("SmallSnotBall", random(-10,10), 0, 0, 0)
	   CLA3 B 2 Bright A_FireCustomMissile("BigSnotBall", 0, 0, 0, 0)
	   CLA3 B 0 Bright A_FireCustomMissile("SmallSnotBall", random(-10,10), 0, 0, 0)
	   CLA3 B 2 Bright A_FireCustomMissile("BigSnotBall", 0, 0, 0, 0)
	   CLA3 B 0 Bright A_FireCustomMissile("SmallSnotBall", random(-10,10), 0, 0, 0)
	   CLA3 B 2 Bright A_FireCustomMissile("BigSnotBall", 0, 0, 0, 0)
	   CLA3 B 0 Bright A_FireCustomMissile("SmallSnotBall", random(-10,10), 0, 0, 0)
	   CLA3 BBBB 1 Bright A_FireCustomMissile("SmallSnotBall", random(-10,10), 0, 0, 0)
	   CLA3 A 8
       Goto Ready
   Outbreak:
       TNT1 A 0 A_Takeinventory("mana", 40)
	   TNT1 A 0 A_PlayWeaponSound("Snotfolus/Attack")
	   CLA3 B 8 Bright A_FireCustomMissile("SnotMineBall", 0, 0, 0, 0)
	   CLA3 A 8
       Goto Ready
	Mine:
       TNT1 A 0 A_Takeinventory("mana", 30)
	   TNT1 A 0 A_Giveinventory("SnotMineCooldown", 1)
	   TNT1 A 0 A_PlayWeaponSound("Snotfolus/Attack")
	   CLA3 B 8 Bright A_SpawnItem("ChexQuestFlemMine", 108, 108)
	   CLA3 A 8
       Goto Ready
	Sliminess:
       TNT1 A 0 A_Takeinventory("mana", 25)
	   TNT1 A 0 A_PlayWeaponSound("Snotfolus/Attack")
	   CLA3 B 8 Bright A_FireCustomMissile("SnotfolusSlime", 0, 0, 0, 0)
	   CLA3 A 8
       Goto Ready
  ExpectorationCheck:
       TNT1 A 0 A_jumpIfinventory("mana", 20, "Expectoration")
       Goto Ready
  OutbreakCheck:
       TNT1 A 0 A_jumpIfinventory("mana", 40, "Outbreak")
       Goto Ready
  MineCheck:
       TNT1 A 0 A_jumpIfinventory("SnotMineCooldown", 1, "Ready")
       TNT1 A 0 A_jumpIfinventory("mana", 30, "Mine")
       Goto Ready
  SliminessCheck:
       TNT1 A 0 A_jumpIfinventory("mana", 25, "Sliminess")
       Goto Ready
  Flash:
       SNIF F 3 Bright A_Light2
       SNIF F 3 Bright A_Light1
       SNIF F 0 Bright A_Light0
       Goto LightDone     
       }
}

actor PowerSnotfolus : PowerMorph
{
	powerup.duration 0x7FFFFFFF
	PowerMorph.PlayerClass "SnotfolusPlayer"
}

ACTOR BigSnotBall
{
  Radius 8
  Height 8
  Speed 60
  Damagetype "Boss"
  Damage 15
  SeeSound "Snotfolus/Attack"
  DeathSound "Chex/Splat"
  Projectile
  +RANDOMIZE
  states
  {
  Spawn:
    CQP2 AB 4
    loop
  Death:
    CQP2 CDE 6
    stop
  }
}

ACTOR SmallSnotBall :  BigSnotBall
{
  Radius 5
  Height 5
  Speed 20
  Damage 8
  Damagetype "Boss"
  states
  {
  Spawn:
    CQP1 AB 4
    loop
  Death:
    CQP1 CDE 6
    stop
  }
}

ACTOR SnotMineBall :  BigSnotBall
{
  Radius 15
  Height 15
  Damage 8
  Damagetype "Boss"
  DeathSound "Snotfolus/Death"
  states
  {
  Spawn:
    CQP3 AB 4
    loop
  Death:
    CQP3 C 0 A_Explode(256, 448, 0)
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("ChexExplosionEffect",0,0,0,frandom(-15,15),frandom(-15,15),frandom(-15,15), 0, 128)
    CQP3 CCCCCCDDDDDDEEEEEE 1 A_SpawnItemEx("ChexExplosionEffect",0,0,0,frandom(-15,15),frandom(-15,15),frandom(-15,15), 0, 128)
    stop
  }
}

ACTOR ChexExplosionEffect
{
   Radius 10
   Height 10
   Speed 0
   PROJECTILE
   +CLIENTSIDEONLY
   +NOCLIP
   States
   {
   Spawn:
    CQP4 GH 2 Bright
    CQP4 I 4 Bright
    CQP4 J 6 Bright A_PlaySound ("GGR/DeathBoom")
    CQP4 K 4 Bright
    CQP4 L 2 Bright
    Stop
   }
}

ACTOR ChexQuestCommonFlemoid
{
  Health 70
  Mass 100
  Height 56
  Radius 20
  Speed 10
  Meleerange 64
  Seesound "ChexCommon/Sight"
  Attacksound "Chex/Splat"
  Painsound "ChexCommon/Pain"
  Deathsound "ChexCommon/Death"
  Activesound "ChexCommon/Active"
  Painchance 128
  MONSTER
  +LOOKALLAROUND
  +FLOORCLIP
  -COUNTKILL
  Bloodcolor "Green"
  DamageFactor "Boss", 0
  DamageType "Boss"
  Species "Boss"
  Obituary "%o was slimed by a Lord Snotfolus Flemoid."
  states
  {
  Spawn:
    CQF1 AB 10 A_Look
    Loop
  See:
    CQF1 AABBCCDD 3 A_Chase
    loop
  Clear:
    CQF1 A 0 A_ClearTarget
    goto See
  Melee:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF1 E 6 A_FaceTarget
    CQF1 F 6 A_CustomMeleeAttack (8, "Chex/Splat")
    goto See
  Pain:
    CQF1 G 2
    CQF1 G 2 A_Pain
    goto See
  Death:
    CQF1 H 5 
    CQF1 I 5 A_Scream
    CQF1 J 5 A_NoBlocking
    CQF1 K 5
	TNT1 A -1
	stop
  }
}

ACTOR ChexQuestCyclops : ChexQuestCommonFlemoid
{
  Health 200
  Height 48
  Radius 25
  Speed 14
  Seesound "ChexLarva/See"
  Attacksound "ChexLarva/Attack"
  Painsound "ChexLarva/Pain"
  Deathsound "ChexLarva/Death"
  Activesound "ChexLarva/Active"
  states
  {
  Spawn:
    CQF2 AB 10 A_Look
    Loop
  See:
    CQF2 AABBCCDD 3 A_Chase
    loop
  Clear:
    CQF2 A 0 A_ClearTarget
    goto See
  Melee:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF2 EF 4 A_FaceTarget
    CQF2 G 4 A_CustomMeleeAttack (12, "Chex/Splat")
    goto See
  Pain:
    CQF2 H 2
    CQF2 H 2 A_Pain
    goto See
  Death:
    CQF2 I 4 A_Scream
    CQF2 J 4 A_NoBlocking
    CQF2 KLMN 4
	TNT1 A -1
	stop
  }
}

ACTOR ChexQuestLarva : ChexQuestCyclops
{
  Health 175
  Speed 15
  states
  {
  Spawn:
    CQF3 AB 10 A_Look
    Loop
  See:
    CQF3 AABBCCDD 3 A_Chase
    loop
  Clear:
    CQF3 A 0 A_ClearTarget
    goto See
  Melee:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF3 EF 4 A_FaceTarget
    CQF3 G 4 A_CustomMeleeAttack (12, "Chex/Splat")
    goto See
  Pain:
    CQF3 H 2
    CQF3 H 2 A_Pain
    goto See
  Death:
    CQF3 I 4 A_Scream
    CQF3 J 4 A_NoBlocking
    CQF3 KLMN 4
	TNT1 A -1
	stop
  }
}

ACTOR ChexQuestQuadrumpus : ChexQuestCommonFlemoid
{
  Health 300
  Speed 6
  Seesound "ChexQuadrumpus/Sight"
  Deathsound "ChexQuadrumpus/Death"
  Activesound "ChexQuadrumpus/Active"
  states
  {
  Spawn:
    CQF4 AB 10 A_Look
    Loop
  See:
    CQF4 AABBCCDD 3 A_Chase
    loop
  Clear:
    CQF4 A 0 A_ClearTarget
    goto See
  Melee:
    Goto See
  Missile:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF4 EF 5 A_FaceTarget
    CQF4 GGGG 5 A_Custommissile ("ChexReallySmolBall", 32, 0, 0)
    goto See
  Pain:
    CQF4 H 2
    CQF4 H 2 A_Pain
    goto See
  Death: 
    CQF4 I 4 A_Scream
    CQF4 J 4 A_NoBlocking
    CQF4 KLM 4
	TNT1 A -1
	stop
  }
}

ACTOR ChexQuestArmoredFlemoid : ChexQuestQuadrumpus
{
  Health 70
  Speed 10
  Deathsound "ChexArmored/Death"
  states
  {
  Spawn:
    CQF6 AB 10 A_Look
    Loop
  See:
    CQF6 AABBCCDD 3 A_Chase
    loop
  Clear:
    CQF6 A 0 A_ClearTarget
    goto See
  Melee:
    Goto See
  Missile:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF6 EF 4 A_FaceTarget
    CQF6 G 4 A_Custommissile ("ChexReallySmolBall", 32, 0, 0)
    goto See
  Pain:
    CQF6 H 2
    CQF6 H 2 A_Pain
    goto See
  Death: 
    CQF6 I 4 A_Scream
    CQF6 J 4 A_NoBlocking
    CQF6 KLM 4
	TNT1 A -1
	stop
  }
}

ACTOR ChexQuestStridictus : ChexQuestCyclops
{
  Health 450
  Speed 30
  SeeSound "ChexStridictus/See"
  states
  {
  Spawn:
    CQF5 AB 10 A_Look
    Loop
  See:
    CQF5 AABBCCDD 2 A_Chase
    loop
  Clear:
    CQF5 A 0 A_ClearTarget
    goto See
  Melee:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF5 E 4 A_FaceTarget
    CQF5 F 4 A_CustomMeleeAttack (20, "Chex/Splat")
	CQF5 G 4 A_FaceTarget
    goto See
  Pain:
    CQF5 H 2
    CQF5 H 2 A_Pain
    goto See
  Death:
    CQF5 I 4 A_Scream
    CQF5 J 4 A_NoBlocking
    CQF5 KLMN 4
	TNT1 A -1
	stop
  }
}

ACTOR ChexQuestFlemMine
{
  Health 150
  Radius 16
  Height 56
  Mass 50
  Speed 6
  Damage 0
  PainChance 0
  DamageType "Boss"
  Species "Boss"
  MeleeRange 64
  Monster
  +FLOAT
  +NOGRAVITY
  +MISSILEMORE
  +DONTFALL
  +NOICEDEATH
  AttackSound "Snotfolus/Mine"
  DeathSound "Snotfolus/Death"
  ActiveSound "Snotfolus/Mine"
  States
  {
  Spawn:
    CQF7 AA 0 A_ChangeFlag("FRIENDLY",0)
    CQF7 AB 10 Bright A_Look
    Loop
  See:
    CQF7 A 0 A_ChangeFlag("FRIENDLY",0)
    CQF7 ABABAB 6 Bright A_Chase
	CQF7 A 0 Bright A_PlaySound("Snotfolus/Mine")
    Loop
  Clear:
    CQF7 A 0 A_ClearTarget
    goto See
  Melee:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF7 E 1 A_Die
    Goto Death
  Missile:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF7 C 4 Bright A_FaceTarget
	CQF7 C 0 Bright A_PlaySound("Snotfolus/Mine")
	CQF7 D 4 Bright A_FaceTarget
	CQF7 D 0 Bright A_PlaySound("Snotfolus/Mine")
    CQF7 C 4 Bright A_FaceTarget
	CQF7 C 0 Bright A_PlaySound("Snotfolus/Mine")
	CQF7 D 4 Bright A_FaceTarget
	CQF7 D 0 Bright A_PlaySound("Snotfolus/Mine")
	CQF7 C 4 Bright A_FaceTarget
	CQF7 C 0 Bright A_PlaySound("Snotfolus/Mine")
	CQF7 D 4 Bright A_FaceTarget
	CQF7 D 0 Bright A_PlaySound("Snotfolus/Mine")
	Goto Doomed
  Doomed:
    TNT1 A 0 A_JumpIfInTargetInventory("SnotfolusWeapon",1,"Clear")
    CQF7 D 4 Bright A_SkullAttack(25)
    CQF7 C 4 Bright
    Loop
  Death:
    CQF7 F 0 A_Explode(256, 448, 0)
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("ChexExplosionEffect",0,0,0,frandom(-15,15),frandom(-15,15),frandom(-15,15), 0, 128)
    CQF7 FFFFFF 1 Bright A_SpawnItemEx("ChexExplosionEffect",0,0,0,frandom(-15,15),frandom(-15,15),frandom(-15,15), 0, 128)
    CQF7 G 0 Bright A_Scream
	CQF7 GGGGGGHHHHHH 1 Bright A_SpawnItemEx("ChexExplosionEffect",0,0,0,frandom(-15,15),frandom(-15,15),frandom(-15,15), 0, 128)
    CQF7 I 0 Bright A_NoBlocking
	CQF7 IIIIIIJJJJJJKKKKKK 1 Bright A_SpawnItemEx("ChexExplosionEffect",0,0,0,frandom(-15,15),frandom(-15,15),frandom(-15,15), 0, 128)
	TNT1 A -1
    Stop
  }
}

actor RandomChexMonsterSpawner : RandomSpawner 
{
    DropItem "ChexQuestCommonFlemoid"
    DropItem "ChexQuestCyclops"
    DropItem "ChexQuestLarva"
    DropItem "ChexQuestQuadrumpus"
	DropItem "ChexQuestArmoredFlemoid"
	DropItem "ChexQuestStridictus"
}

ACTOR ChexReallySmolBall :  SmallSnotBall
{
  Speed 20
  Damage 5
}

Actor SnotMineCooldown : PowerDamage
{
	DamageFactor "Nothing", 1.0
	PowerUp.Duration -15
}

Actor SnotfolusSlime : FastProjectile
{
    Radius 11
	Height 8
    Speed 150
	Damage (50)
	Species "Boss"
	+DONTHARMSPECIES
	+THRUSPECIES
	var int user_fire;
	MissileHeight 8
	MissileType "SnotfolusSlimeParticle"
	SeeSound "Snotfolus/Attack"
	DeathSound "Slimer/Tracer3"
	states
	{
	Spawn:
	    CQP2 AB 4
		loop
	Death:
		TNT1 A 0 A_SetUserVar(user_fire,user_fire+1)
		TNT1 A 0 A_SpawnItemEx("SnotfolusSlimeParticle",frandom(-160,160),0,floorz-z+1,0,0,frandom(0,10),random(1,360))
		TNT1 A 1 A_RadiusGive("SnotfolusSlimeSlow",160,RGF_PLAYERS,1)
		TNT1 A 0 A_SpawnItemEx("SnotfolusSlimeParticle",frandom(-160,160),0,floorz-z+1,0,0,frandom(0,10),random(1,360))
		TNT1 A 1 A_RadiusGive("SnotfolusSlimeSlow",160,RGF_PLAYERS,1)
		TNT1 A 0 A_SpawnItemEx("SnotfolusSlimeParticle",frandom(-160,160),0,floorz-z+1,0,0,frandom(0,10),random(1,360))
		TNT1 A 1 A_RadiusGive("SnotfolusSlimeSlow",160,RGF_PLAYERS,1)
		TNT1 A 0 A_SpawnItemEx("SnotfolusSlimeParticle",frandom(-160,160),0,floorz-z+1,0,0,frandom(0,10),random(1,360))
		TNT1 A 1 A_RadiusGive("SnotfolusSlimeSlow",160,RGF_PLAYERS,1)
		TNT1 A 0 A_JumpIf(user_fire>90,"Stoping")
		Loop
	Stoping:
	    TNT1 A 1
		Stop
	}
}

Actor SnotfolusSlimeParticle
{
	Projectile
	Damage 0
	+NoBlockMap
	+BloodLessImpact
	+ClientSideOnly 
    -BloodSplatter
    +DontSplash
    +ForceXYBillBoard
	Translation "192:207=112:127"
	Speed 0
	Radius 1
	Height 1
	RenderStyle Add
	States
	{
  Spawn:
  Death:
    SWET F 1 Bright A_FadeOut(0.04)
    Loop
	}
}

Actor SnotfolusSlimeSlow : PowerSpeed
{
    Speed 0.33
	Powerup.Duration -2
	Powerup.Color "00 FF 51", 0.4
	+INVENTORY.ALWAYSPICKUP
}