//subweapon chest

actor subweaponchest 
{
	health 150
	radius 20
	height 38
	+notimefreeze
	+shootable
	+noblood
	+dontrip
	+BRIGHT
	+noradiusdmg
	mass 900
	scale 1.5
	damagefactor "telefrag", 0.0
	dropitem "chestloot"
	states
	{
	spawn:
		CHST A 0
		CHST A 0 a_jumpifhealthlower (75, "cracked")
		CHST A 0 a_giveinventory ("dontpullme",1)
		CHST A 1 a_jumpifhealthlower (75, "cracked")
		CHST A 0 a_giveinventory ("dontpullme",1)
		loop
	cracked:
		CHST B 0
		CHST A 0 a_giveinventory ("dontpullme",1)
		CHST B 1
		CHST B 0 a_giveinventory ("dontpullme",1)
		loop
	death:
		CBRK ABC 4
		CBRK D 1 a_noblocking
		stop
	}
}


actor lilchest
{ 
	Radius 8
	Height 10
	Speed 40
	+FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+MISSILE
	+DROPOFF
	+CANBOUNCEWATER
	+bounceonceilings
	+bounceonwalls
	+DONTBLAST
	+BRIGHT
	+thruactors
	damagefactor "telefrag", 0.0
	states
	{
	spawn:
		CHS1 D 150
		goto death
	death:
		CHS1 D 40
		TNT1 A 0 a_playsound ("subitems/portaexpand",0)
		CHS1 D 1 
		CHS1 C 1 
		CHS1 B 1 
		CHS1 A 1 
		TNT1 A 0 a_spawnitem ("subweaponchest",0,0,0)
		stop
	}
}

//spell cube

actor spellcube
{
	health 150
	radius 20
	height 60
	+notimefreeze
	+shootable
	+floatbob
	+noblood
	+dontrip
	+BRIGHT
	damagefactor "telefrag", 0.0
	mass 900
	scale 1
	+noradiusdmg
	dropitem "spellcubeloot"
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 a_giveinventory ("dontpullme",1)
		SCBE ABCDEF 3 bright a_jumpifhealthlower (75, "cubecracked")
		loop
	cubecracked:
		TNT1 A 0
		TNT1 A 0 a_giveinventory ("dontpullme",1)
		SCRK ABCDEF 3 bright
		TNT1 A 0 a_giveinventory ("dontpullme",1)
		loop
	death:
		SBRK ABC 4
		SBRK D 1 a_noblocking
		stop
	}
}


actor lilcube : lilchest
{
	states
	{
	spawn:
		SCB1 ABCDEF 4
		SCB1 ABCDEF 4
		SCB1 ABCDEF 4
		SCB1 ABCDEF 4
		SCB1 ABCDEF 4
		SCB1 ABCDEF 4
		goto death
	death:
		SCB1 ABCDEF 4 
		SCB1 ABCDEF 4 
		TNT1 A 0 a_playsound ("subitems/portaexpand",0)
		SCB1 G 1
		SCB1 H 1
		SCB1 I 1	
		TNT1 A 0 a_spawnitem ("spellcube",0,0,0)
		stop
	}
}

//Special chests

actor permasubchest
{
	health 9999999
	radius 20
	height 38
	Painchance "grappler", 0
	+notimefreeze
	+shootable
	+noblood
	+dontrip
	+noradiusdmg
	+DONTBLAST
	mass 9999999
	painchance 256
	scale 1.5
	damagefactor "telefrag", 0.0
	states
	{
	spawn:
		RCST A 1 a_giveinventory ("health",9999)
		loop
	pain:
		TNT1 A 0
		TNT1 A 0 a_changeflag ("shootable",0)
		RCST BB 2 
		RCST A 2 
		RCST CC 2 
		RCST BB 2 
		RCST A 2 
		RCST CC 2 
		RCST BB 2 
		RCST A 2 
		RCST CC 2 
		RCST A 2
		RCST D 4
		RCST E 1 a_dropitem ("permasubchestloot",1,256)
		RCST E 15
		RCST DDDAAA 3
		TNT1 A 0 a_changeflag ("shootable",1)
		goto spawn
	}
}

actor permaspellchest : permasubchest
{
	states
	{
	spawn:
		BCST A 1 a_giveinventory ("health",9999)
		loop
	pain:
		TNT1 A 0
		TNT1 A 0 a_changeflag ("shootable",0)
		BCST BB 2 
		BCST A 2 
		BCST CC 2 
		BCST BB 2 
		BCST A 2 
		BCST CC 2 
		BCST BB 2 
		BCST A 2 
		BCST CC 2 
		BCST A 2
		BCST D 4
		BCST E 1 a_dropitem ("permaspellchestloot",1,256)
		BCST E 15
		BCST DDDAAA 3
		TNT1 A 0 a_changeflag ("shootable",1)
		goto spawn
	}
}

actor wildcardchest : permasubchest
{
	states
	{
	spawn:
		CCST A 1 a_giveinventory ("health",9999)
		loop
	pain:
		TNT1 A 0
		TNT1 A 0 a_changeflag ("shootable",0)
		CCST BB 2 
		CCST A 2 
		CCST CC 2 
		CCST BB 2 
		CCST A 2 
		CCST CC 2 
		CCST BB 2 
		CCST A 2 
		CCST CC 2 
		CCST A 2
		CCST D 4
		TNT1 A 0 a_facetarget
		CCST E 1 a_spawnitemex ("permasubchestloot",0,0,0,0,frandom(3,4),5)
		CCST E 1 a_spawnitemex ("permaspellchestloot",0,0,0,0,frandom(-6,-3),5)
		CCST E 15
		CCST DDDAAA 3
		TNT1 A 0 a_changeflag ("shootable",1)
		goto spawn
	}
}

//Shade ring
ACTOR ShadeRing : PowerupGiver replaces blursphere
{
	+INVENTORY.PICKUPFLASH
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	+INVENTORY.BIGPOWERUP
	Inventory.MaxAmount 0
	Powerup.Type PowerShade
	Inventory.PickupMessage "Shade ring! Limited invisibility and immunity to physical projectiles!"
	inventory.pickupsound "powerups/shadering"
	States
	{
	Spawn:
		IRNG A 15 Bright
		IRNG A 10 
		Loop
	}
}

ACTOR PowerShade : PowerInvisibility
{
	+GHOST
	Powerup.Duration -60
	Powerup.Strength 60
	Powerup.Mode "translucent"
    inventory.icon "IRGICN"
}

//yashichi
actor yashichi : custominventory
{
	inventory.pickupmessage "Yashichi! How did -THAT- get here?"
	inventory.pickupsound "powerups/special"
	+notimefreeze
	+floatbob
	scale 0.60
	states
	{
	spawn:
		YASH A 6
		YASH A 6 bright
		loop
	pickup:
		TNT1 A 0 a_giveinventory ("soulsphere", 2)
		TNT1 A 0 a_giveinventory ("goldarmor", 2)
		TNT1 A 0 a_giveinventory ("arcaneforce", 40)
		stop
	}
}

//SUPER Burger

actor superburger : soulsphere replaces soulsphere
{
	inventory.pickupmessage "Superburger, big HP!"
	inventory.pickupsound "powerups/burger"
	+floatbob
	states
	{
	spawn:
		BURG A 10
		BURG A 6 bright
		loop
	}
}

actor superburgerdrop : superburger
{
	+dropped
}

//crystal ball
actor crystalball: CustomInventory
{
	+notimefreeze
	+floatbob
	+INVENTORY.ALWAYSPICKUP
	scale 0.40
	Inventory.MaxAmount 0
	Inventory.PickupSound "powerups/smallpower"
	Inventory.PickupMessage "The Crystal Ball reveals all on your map!"
	states
	{
	Spawn:
		CBAL A 6 
		CBAL A 6 BRIGHT
		Loop
	Pickup:
		TNT1 A 1 A_GiveInventory ("Allmap")
		TNT1 A 0 A_GiveInventory ("crystalballreveal")
		stop
	}
}

actor crystalballreveal : PowerupGiver
{
	powerup.type "Scanner"
	powerup.duration 0x7FFFFFFF
	+notimefreeze
	+INVENTORY.AUTOACTIVATE
	states
	{
	Spawn:
		TNT1 A 1
		stop
	}
}


	
//==Ring of might==

//This ring enhances the hero's melee abilities, (primary weapon)
//granting them new attacks and boosting pre-existing ones

actor mightring : custominventory replaces berserk
{
	Inventory.PickupMessage "Ring of Might! Melee power enhanced!"
	inventory.pickupsound "subitems/upgradeitem"
	Inventory.Amount 1
	Inventory.MaxAmount 1
	+FLOORCLIP
	+floatbob
	States
	{
	Spawn:
		MIRN A 10 bright
		MIRN A 4 
		Loop
	pickup:
		TNT1 A 0 a_giveinventory ("ATKringpowerup", 1)
		TNT1 A 0 a_giveinventory ("healthbonus", 50)
		TNT1 A 1
		stop
	} 
}

actor ATKringpowerup : inventory
{inventory.maxamount 1}


//==Magic Boots==

//Enchanted boots that allows the hero to pass
//through damage floors safely

actor magicboots : custominventory replaces radsuit
{
	Inventory.PickupMessage "Seven League Boots, hazard immunity!"
	inventory.pickupsound "subitems/upgradeitem"
	Inventory.Amount 1
	Inventory.MaxAmount 1
	Inventory.InterHubAmount 1
	+FLOORCLIP
	+floatbob
	States
	{
	Spawn:
		BOOT A 10 bright
		BOOT A 4 
		Loop
	pickup:
		TNT1 A 0 a_giveinventory ("Bootprotection", 1)
		stop
	} 
}

actor bootprotection : powerironfeet
{
	Powerup.Duration -80
	Powerup.Color 0, 0, 0, 0
    inventory.maxamount 1
    inventory.icon "BOTICN"
    +INVENTORY.AUTOACTIVATE
}	


//Knight vision visor
ACTOR Knightvision : PowerupGiver replaces infrared
{
	+COUNTITEM
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	+bright
	Inventory.MaxAmount 0
	inventory.pickupsound "subitems/upgradeitem"
	Powerup.Type "PowerKnightVision"
	Inventory.PickupMessage "Light Amplification scope!"
	States
	{
	Spawn:
		KNVS A 10
		KNVS B 10
		Loop
	}
}

actor PowerKnightVision : powerup
{
	Powerup.color greenmap
	Powerup.Duration -120
}	
	


//Invuln Helmet

actor powershield : powerupgiver
{
	Inventory.PickupMessage "Helmet of Invulnerability!"
    Inventory.PickupSound "powerups/superpower"
    Powerup.Type "shieldprotection"
    Powerup.Duration -30
    inventory.maxamount 0
	Powerup.Color blue2 0.10
    +notimefreeze
    +floatbob
    +bright
	+INVENTORY.AUTOACTIVATE
    states
    {
    spawn:
		IHLM A 4
		IHLM ABCD 6
		IHLM D 12 
		IHLM DCBA 6
		loop
    }
}

actor powershieldprotection : powerprotection
{
    DamageFactor "Normal", 0.0
    +noradiusdmg
    +nopain
}
	


//--random spawners--//

actor treatspawner : randomspawner
{
	dropitem "icecreamcone", 255, 3
	dropitem "strawberrycone", 255, 3
	dropitem "sundae", 255, 3
	dropitem "popsicle", 255, 3
}

actor chestloot : randomspawner
{
	dropitem "arthurslance", 255, 3
	dropitem "arthursdagger", 255, 3
	dropitem "arthurshatchet", 255, 3
	dropitem "wardingshield", 255, 3
	dropitem "arthurstorch", 255, 3
	dropitem "crystalbomb", 255, 3
	dropitem "splitstaff", 255, 3
	dropitem "boomerangweapon", 255, 3
	dropitem "goldenboner", 255, 1
	dropitem "haelinsgift", 255, 2
}

actor permasubchestloot : randomspawner
{
	dropitem "arthurslance", 255, 3
	dropitem "arthursdagger", 255, 3
	dropitem "arthurshatchet", 255, 3
	dropitem "wardingshield", 255, 3
	dropitem "arthurstorch", 255, 3
}


	
actor spellcubeloot : randomspawner
{
	dropitem "scattershotspell", 255, 3
	dropitem "crushmissilespell", 255, 3
	dropitem "rollingbombspell", 255, 3
	dropitem "heavymacerspell", 255, 3
	dropitem "spikevulcanspell", 255, 3
	dropitem "heatbeamspell", 255, 3
	dropitem "goldenboner", 255, 1
}

actor permaspellchestloot : randomspawner
{
	dropitem "scattershotspell", 255, 3
	dropitem "crushmissilespell", 255, 3
	dropitem "rollingbombspell", 255, 3
	dropitem "heavymacerspell", 255, 3
	dropitem "spikevulcanspell", 255, 3
	dropitem "heatbeamspell", 255, 3
}


actor mapspawner : randomspawner replaces allmap
{
	dropitem "crystalball", 255, 1
}

actor randommegaspherespawner : randomspawner replaces megasphere
{
	dropitem "yashichi", 255, 1
}

actor shieldspherespawner : randomspawner replaces InvulnerabilitySphere
{
	dropitem "powershield", 255,1
}