///Code for the new items

ACTOR DefenderW: CustomInventory replaces ArtiInvulnerability 23880
{
  +FLOATBOB
  +COUNTITEM
  +INVENTORY.PICKUPFLASH
  +INVENTORY.BIGPOWERUP
  +INVENTORY.INVBAR
  //+INVENTORY.FANCYPICKUPSOUND
  Inventory.PickupSound "PickupArtifact"
  Inventory.PickupMessage "\c[white]A mighty \c[green]Icon of the \c[purple]Defender\c[white]!! [\c[green]Invulnerability\c[white]]" 
  Inventory.UseSound "artiuse"
  Tag "Gain 50% Damage Reduction & a special power!"
  Inventory.Icon ARTIDEFN
  FloatBobStrength 0.5
  Inventory.InterHubAmount 3
  Inventory.MaxAmount 3
  States
  {
	Spawn:
		1K0N ABCDEFGHIJKLMNOP 3 A_SpawnItemEx("PurpleSparklies2",random(-4,4),random(-4,4),20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.7))
		Loop
	Use:
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer"),"IsCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer"),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer"),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer"),"IsDrui")
		Stop
//Myrmidon Icon: Gives 0.5x DR, Quad Damage, Drain.
	IsMyrm:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("MyrmPower1", 1)
		TNT1 A 0 A_GiveInventory("MyrmPower2", 1)
		TNT1 A 0 A_GiveInventory("MyrmPower3", 1)
		TNT1 A 0 A_SpawnItemEx("IconMusicBox",0,0,0,0,0,0,0,SXF_SETMASTER)
		TNT1 A 0 A_SetBlend("00 00 00",1,35)
		TNT1 A 0 A_StartSound("MyrmIconGo",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE)
		Stop
//Crusader Icon: Gives 0.5x DR, 2x Firespeed, Reflection.
	IsCrus:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("CrusPower1", 1)
		TNT1 A 0 A_GiveInventory("CrusPower2", 1)
		TNT1 A 0 A_GiveInventory("CrusPower3", 1)
		TNT1 A 0 A_SpawnItemEx("IconMusicBox",0,0,0,0,0,0,0,SXF_SETMASTER)
		TNT1 A 0 A_SetBlend("FF FF FF",1,20)
		TNT1 A 0 A_StartSound("CrusIconGo",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE)
		Stop
//Magister Icon: Gives 0.5x DR, Time-Stop.	
	IsMagi:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("MagiPower1", 1) 
		TNT1 A 0 A_GiveInventory("MagiPower2", 1)
		TNT1 A 0 A_SpawnItemEx("IconMusicBox",0,0,0,0,0,0,0,SXF_SETMASTER)
		TNT1 A 0 A_SetBlend("00 00 00",1,20)
		TNT1 A 0 A_StartSound("MagiIconGo",CHAN_ITEM,CHANF_OVERLAP|CHANF_UI,1.6,false,ATTN_NONE) //We pretend its a UI sound so that it still plays in timestop!
		Stop
//Druid Icon: Gives 0.5x DR, 45 HP/sec Regeneration.	
	IsDrui:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("DruiPower1", 1) 
		TNT1 A 0 A_GiveInventory("DruiPower2", 1)
		TNT1 A 0 A_SpawnItemEx("IconMusicBox",0,0,0,0,0,0,0,SXF_SETMASTER)
		TNT1 A 0 A_SetBlend("00 00 00",1,20)
		TNT1 A 0 A_StartSound("DruiIconGo",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE) 
		Stop
  }
}

ACTOR DefenderW2: DefenderW replaces ArtiInvulnerability2 
{
  Inventory.PickupMessage "\c[white]A mighty \c[green]Icon of the \c[purple]Defender\c[white]!! [\c[green]Invulnerability\c[white]]"
}

ACTOR IconMusicBox //This follows the player using an Icon and provides visual and audible FX.
{
+NOCLIP
+INVISIBLE
+NOTIMEFREEZE
  States
  {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_MASTER),"CrusLoop")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_MASTER),"MyrmLoop")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_MASTER),"MagiLoop")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_MASTER),"DruiLoop")
		Stop
//////////////////////////////////////////////////////	
	MyrmLoop:
		TNT1 A 0 A_QuakeEx(1,1,1,100,0,0,"None",QF_RELATIVE|QF_SCALEDOWN|QF_SCALEUP)
		Goto MyrmLoop1
	MyrmLoop1:		
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",100,"MyrmLoopX")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
				A_Warp(AAPTR_MASTER);}
		Loop
	MyrmLoopX:
		TNT1 A 0 A_StartSound("MyrmIconA",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE)
		TNT1 A 0 A_QuakeEx(1,1,1,760,0,3,"None",QF_RELATIVE|QF_SCALEDOWN|QF_SCALEUP)
		Goto MyrmLoop2
	MyrmLoop2:
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",765,"MyrmEndLoop")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
				A_Warp(AAPTR_MASTER);}
		Loop
	MyrmEndLoop:
		TNT1 A 1 A_Stopsound(3)
		TNT1 A 0 A_Playsound("MyrmIconNo",CHAN_ITEM,1,false,ATTN_NONE)
		TNT1 A 0 A_TakeInventory("ICONCOUNTER")
		TNT1 A 0 A_Remove(AAPTR_DEFAULT,RMVF_EVERYTHING)
		Stop
//////////////////////////////////////////////////////		
	CrusLoop:		
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",40,"CrusLoopX")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
				A_Warp(AAPTR_MASTER);	
				A_SpawnItemEx("YellowSparklies",random(30,40),random(8,20),1,random(2,5),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",random(75,120),random(8,20),1,random(2,5),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",random(-30,-40),random(8,20),1,random(0,-2),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",0,random(-40,-20),1,random(8,20),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",0,random(20,40),1,random(8,20),random(-3,3),random(3,7));}
		Loop
	CrusLoopX:
		TNT1 A 0 A_StartSound("CrusIconA",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto CrusLoop2
	CrusLoop2:
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",765,"CrusEndLoop")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
				A_Warp(AAPTR_MASTER);	
				A_SpawnItemEx("YellowSparklies",random(30,40),random(8,20),1,random(2,5),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",random(75,120),random(8,20),1,random(2,5),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",random(-30,-40),random(8,20),1,random(0,-2),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",0,random(-40,-20),1,random(8,20),random(-3,3),random(3,7));
				A_SpawnItemEx("YellowSparklies",0,random(20,40),1,random(8,20),random(-3,3),random(3,7));}
		Loop
	CrusEndLoop:
		TNT1 A 1 A_Stopsound(3)
		TNT1 A 0 A_Playsound("CrusIconNo",CHAN_ITEM,1,false,ATTN_NONE)
		TNT1 A 0 A_TakeInventory("ICONCOUNTER")
		TNT1 A 0 A_Remove(AAPTR_DEFAULT,RMVF_EVERYTHING)
		Stop
//////////////////////////////////////////////////////			
	MagiLoop:		
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",55,"MagiLoopX")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
				A_Warp(AAPTR_MASTER);	
				A_SpawnItemEx("MageMirage",-24,random(-1,1),0);}
		Loop
	MagiLoopX:
		TNT1 A 0 A_StartSound("MagiIconA",CHAN_ITEM,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE)
		Goto MagiLoop2
	MagiLoop2:
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",745,"MagiEndLoop")
		TNT1 A 1 A_GiveInventory("ICONCOUNTER",1)
		TNT1 A 0 {A_Warp(AAPTR_MASTER);	
				A_SpawnItemEx("MageMirage",-24,random(-1,1),0);}
		Loop
	MagiEndLoop:
		TNT1 A 1 A_Stopsound(3)
		TNT1 A 0 A_StartSound("MagiIconNo",CHAN_ITEM,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE)
		TNT1 A 0 A_TakeInventory("ICONCOUNTER")
		TNT1 A 0 A_Remove(AAPTR_DEFAULT,RMVF_EVERYTHING)
		Stop
//////////////////////////////////////////////////////			
	DruiLoop:		
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",25,"DruiLoopX")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
				A_Warp(AAPTR_MASTER);	
				A_SpawnItemEx("DecorativeLeaf",random(30,36),random(-28,28),random(40,66));}
		Loop
	DruiLoopX:
		TNT1 A 0 A_StartSound("DruiIconA",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto DruiLoop2
	DruiLoop2:
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",780,"DruiEndLoop")
		TNT1 A 1 A_GiveInventory("ICONCOUNTER",1)
		TNT1 A 0 {A_Warp(AAPTR_MASTER);	
					if (random(1,3) >= 2) // randomly spits leaves out
					{ A_SpawnItemEx("DecorativeLeaf",random(30,36),random(-28,28),random(40,66));}
				}
		Loop
	DruiEndLoop:
		TNT1 A 1 A_Stopsound(3)
		TNT1 A 0 A_StartSound("DruiIconNo",CHAN_ITEM,CHANF_OVERLAP,1,false,ATTN_NONE)
		TNT1 A 0 A_TakeInventory("ICONCOUNTER")
		TNT1 A 0 A_Remove(AAPTR_DEFAULT,RMVF_EVERYTHING)
		Stop
  }
}

ACTOR MageMirage //ghostly magister for timestop
{
+NOINTERACTION
+NOCLIP
+NOGRAVITY
+NOTIMEFREEZE
Alpha 0.4
Renderstyle Translucent
Translation Ice
	States
	{
	Spawn:
		MAGE ABCD 2 A_Fadeout(0.005)
		Loop
	}
}

ACTOR DecorativeLeaf : DecorativeSparks
{
	+ROLLSPRITE
	+ROLLCENTER
	-NOCLIP
	+NOINTERACTION
	Scale 0.3
	Alpha 1
	Deathsound "None"
	States
	{
	Spawn:
		TNT1 A 0 Nodelay A_Setroll(random(0,180))
		TNT1 A 0 {if (random(1,2) == 1) // randomly flips 
			{ A_Changeflag("SPRITEFLIP",TRUE);}}
		TNT1 A 0 A_Jump(128,"GreenLeaf")
	YellowLeaf:
		L34F B 9 Bright 
		{	
			A_Setroll(roll-(random(20,40)),SPF_INTERPOLATE);
			A_ChangeVelocity(random(-5,5),random(-5,5),random(0,-2),CVF_RELATIVE|CVF_REPLACE);
			A_GiveInventory("ChainBolt",1);
		}
		L3AF B 0 A_JumpifInventory("Chainbolt",60,"DeathYellow")
		L3AF B 0 A_CheckFloor("DeathYellow")
		Loop
	GreenLeaf:
		L34F A 9 Bright 
		{	
			A_Setroll(roll-(random(20,40)),SPF_INTERPOLATE);
			A_ChangeVelocity(random(-5,5),random(-5,5),random(0,-2),CVF_RELATIVE|CVF_REPLACE);
			A_GiveInventory("ChainBolt",1);
		}
		L3AF A 0 A_JumpifInventory("Chainbolt",60,"DeathGreen")
		L3AF A 0 A_CheckFloor("DeathGreen")
		Loop
	DeathYellow:
		L3AF B 2 A_Fadeout(0.05)
		Loop
	DeathGreen:
		L3AF B 2 A_Fadeout(0.05)
		Loop
	Death:
		TNT1 A 0 A_Stop
		stop
	}
}

/*
ACTOR DefenderArtiW: ArtiInvulnerability2 replaces ArtiInvulnerability
{
  +FLOATBOB
  FloatBobStrength 0.5
  Inventory.PickupSound "Pickup/UseTeamHeal"
  Inventory.PickupMessage "A mighty Icon of the Defender!! Marvellous!" 
  Inventory.UseSound "artiuse"
  Inventory.InterHubAmount 3
  Inventory.MaxAmount 3
  States
  {
  Spawn:
    DEFN A 3
    Loop
  }
}
*/

////DRUID_DOGMODE///
ACTOR PowerDog : Powerup
{
	Powerup.Duration 0x7FFFFFFD
}

ACTOR PowerDogEnd : Powerup
{
	Powerup.Duration 1
}

ACTOR DruidDog1 : PowerupGiver //default
{
	Powerup.Type "Dog"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 0x7FFFFFFD 
	Powerup.Colormap 0.0, 0.0, 0.0, 0.6, 0.6, 0.6
}

ACTOR DruidDog6 : PowerupGiver 		//6- colourvision
{
	Powerup.Type "Dog"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 0x7FFFFFFD 
	Powerup.Color None
}

ACTOR DruidDog9 : PowerupGiver 		//9- sepia (wut?)
{
	Powerup.Type "Dog"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 1
	Powerup.Duration 0x7FFFFFFD
	//Powerup.Color GreenMap, 0.2
	Powerup.Colormap 0.2, 0.1, 0.0, 0.4, 0.4, 0.4
}

////ALL ICONS////
ACTOR PowerAllIcons : PowerProtection
{
  DamageFactor "Normal", 0.5
  DamageFactor "Ice", 0.5
  DamageFactor "Fire", 0.5
  DamageFactor "Acid", 0.5
  Powerup.Duration -25
}

////MYRM///

ACTOR PowerMyrmIconA : PowerDamage
{
  DamageFactor "Normal", 4
  DamageFactor "Fire", 4
  DamageFactor "Electric", 4
  Powerup.Duration -25
}

ACTOR PowerMyrmIconB : PowerDrain
{
  Powerup.Strength 0.3
}

ACTOR MyrmPower1 : PowerupGiver
{
	Powerup.Type "AllIcons"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
}

ACTOR MyrmPower2 : PowerupGiver
{
	Powerup.Type "MyrmIconA"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
	Powerup.Color RedMap
}

ACTOR MyrmPower3 : PowerupGiver
{
	Powerup.Type "MyrmIconB"
	+INVENTORY.AUTOACTIVATE
	Powerup.Duration -25
	Inventory.MaxAmount 0
}

////CRUS///

ACTOR PowerCrusIconA : PowerReflection
{
  Powerup.Strength 1.0
  Powerup.Duration -25
  DamageFactor 5.0
}

ACTOR PowerCrusIconB : PowerDoubleFiringSpeed
{
  Powerup.Duration -25
}

ACTOR CrusPower1 : PowerupGiver
{
	Powerup.Type "AllIcons"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
}

ACTOR CrusPower2 : PowerupGiver
{
	Powerup.Type "CrusIconA"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
	Powerup.Color GoldMap
}

ACTOR CrusPower3 : PowerupGiver
{
	Powerup.Type "CrusIconB"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
}

////MAGI///

ACTOR PowerMagiIcon : PowerTimeFreezer
{
  Powerup.Duration -25
}

ACTOR MagiPower1 : PowerupGiver
{
	Powerup.Type "AllIcons"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
}

ACTOR MagiPower2 : PowerupGiver
{
	Powerup.Type "MagiIcon"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
	Powerup.Colormap 0.0, 0.0, 0.0, 1.0, 1.0, 1.0
	Powerup.Type TimeFreezer
}

////DRUID///

ACTOR PowerDruiIconA : PowerRegeneration
{
  Powerup.Strength 45
  Powerup.Duration -25
}

ACTOR DruiPower1 : PowerupGiver
{
	Powerup.Type "AllIcons"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
}

ACTOR DruiPower2 : PowerupGiver
{
	Powerup.Type "DruiIconA"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -25
	Powerup.Colormap 0.1, 0.1, 0.1, 0.1, 0.7, 0.0
	//Powerup.Color GreenMap
}

ACTOR PowerFocusBreath : PowerTimeFreezer
{
  +INVENTORY.ADDITIVETIME
  Powerup.Duration 6
}

ACTOR PowerFocusBreathEnd : PowerTimeFreezer
{
  -INVENTORY.ADDITIVETIME
  Powerup.Duration 1
}

ACTOR IchivalPower : PowerupGiver
{
	Powerup.Type "FocusBreath"
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ADDITIVETIME
	Inventory.MaxAmount 0
	Powerup.Duration 7
	Powerup.Type TimeFreezer
}

ACTOR IchivalPowerEnd : PowerupGiver
{
	Powerup.Type "FocusBreathEnd"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 1
	Powerup.Type TimeFreezer
}

////These two powers are given when upgrading////

ACTOR PowerUpgraderPause : PowerTimeFreezer
{
  Powerup.Duration 0x7FFFFFFD
}

ACTOR UpgraderPause : PowerupGiver
{
	Powerup.Type "UpgraderPause"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 0x7FFFFFFD
	Powerup.Color "None"
	Powerup.Type TimeFreezer
}

ACTOR PowerUpgraderHalt : PowerSpeed
{
  Speed 0
  Powerup.Duration 0x7FFFFFFD
}

ACTOR HaltNao : PowerupGiver //stops the magister hitting his own lightning
{
	Powerup.Type "UpgraderHalt"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 0x7FFFFFFD
	Powerup.Color "None"
}

/// DEBUFFS ///

ACTOR PowerSnekGaze : PowerSpeed
{
  Speed 0
  Powerup.Duration 30
}

ACTOR SnekGazeAffect : PowerupGiver //used by Medusa Gaze Attack 
{
	Powerup.Type "SnekGaze"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 30
	Powerup.Color GoldMap
}

ACTOR PowerSlowTheFuckDown : PowerSpeed
{
  Speed 0.5
  Powerup.Duration 0x7FFFFFFD
}

ACTOR SlowTheFuckDownBitch : PowerupGiver //stops the magister hitting his own lightning
{
	Powerup.Type "SlowTheFuckDown"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration 0x7FFFFFFD
	Powerup.Color "None"
}


//// Rewritten Mystic Ambit Incant ////

ACTOR AmbitW : CustomInventory replaces ArtiHealingRadius 23881
{
  Inventory.PickupSound "Pickup/Scroll"
  Inventory.UseSound "Pickup/UseAmbit"
  Inventory.PickupMessage "\c[white]A \c[LightBlue]Mystic Ambit Incant\c[white]? I wonder if I can use it? [\c[blue]Infinite Mana\c[white]]"
  Tag "Infinite Mana for 10 secs + a special effect!"
  Inventory.InterHubAmount 3
  Inventory.MaxAmount 3
  +COUNTITEM
  +FLOATBOB
  +INVENTORY.INVBAR 
  +INVENTORY.PICKUPFLASH
  +INVENTORY.FANCYPICKUPSOUND
  Inventory.Icon "ARTIHRAD"
  States
  {
	Spawn:
		HRAD ABCDEFGHIJKLMNOP 4 Bright
		Loop
	Use:
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer"),"IsCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer"),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer"),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer"),"IsDrui")
		Stop
//Myrmidon Ambit; gives 100 HP (exceeding maximums like soulsphere, not normally possible!)
	IsMyrm:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("AmbitHP", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitHP", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitHP", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitHP", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_SetBlend("FF FF FF",1,35)
		Stop
//Crusader Ambit; gives Free 2x Bracers to all (+8 AC)
	IsCrus:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AutoBracers", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_SetBlend("55 FF 55",1,35)
		Stop
//Magister Ambit; gives 75 of both mana to all & 15 secs of infinite mana
	IsMagi:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("AmbitPower2", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitPower2", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitPower2", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitPower2", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_GiveInventory("AmbitMana", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitMana", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitMana", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitMana", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_SetBlend("00 00 FF",1,35)
		Stop 
//Druid Ambit; increases Druids HP Maximum.
	IsDrui:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitPower1", 1,AAPTR_PLAYER4)
		TNT1 A 0 A_GiveInventory("AmbitMaxHP", 10,AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AmbitMaxHP", 10,AAPTR_PLAYER2)
		TNT1 A 0 A_GiveInventory("AmbitMaxHP", 10,AAPTR_PLAYER3)
		TNT1 A 0 A_GiveInventory("AmbitMaxHP", 10,AAPTR_PLAYER4)
		TNT1 A 0 A_SetBlend("00 00 FF",1,35)
		Stop 
  }
}

//// Ambit things ////

ACTOR AutoBracers : ArtiBoostArmorW 
{
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 0
  Inventory.PickupMessage "None"
  Inventory.PickupSound "None"
}

ACTOR AmbitHP : Health
{
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.Amount 100
  Inventory.MaxAmount 250
  Inventory.PickupMessage "None"
  Inventory.PickupSound "None"
}

ACTOR AmbitMaxHP : UpgradeStamina 
{
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.Amount 10
  Inventory.MaxAmount 30
  Inventory.PickupMessage "None"
  Inventory.PickupSound "None"
}

ACTOR AmbitMana: Mana3W
{
  Inventory.PickupMessage "None"
  Inventory.PickupSound "None"
  States
	{
    Pickup:
    TNT1 A 0 A_GiveInventory("Mana1W", 75)
    TNT1 A 0 A_GiveInventory("Mana2W", 75)
    Stop
	}
}

ACTOR PowerAmbitMana : PowerInfiniteAmmo
{
  Powerup.Duration -10
}

ACTOR PowerAmbitManaEx : PowerInfiniteAmmo
{
  Powerup.Duration -15
}

ACTOR AmbitPower1 : PowerupGiver
{
	Powerup.Type "AmbitMana"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -10
	Powerup.Color BlueMap
}

ACTOR AmbitPower2 : PowerupGiver
{
	Powerup.Type "AmbitManaEx"
	+INVENTORY.AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Duration -15
	Powerup.Color BlueMap
}

ACTOR Philter : CustomInventory
{
		+INVENTORY.ISHEALTH
		+INVENTORY.INVBAR
		+FLOATBOB
		Inventory.Amount 75 //100
		Inventory.MaxAmount 200
		Inventory.InterHubAmount 0x7FFFFFFF
		Inventory.PickupMessage "\c[white]A \c[orange]Philter of Vitality\c[white]. Prized by Physicians, this stuff! [\c[brick]Heals To Max\c[white]]"
		Inventory.PickupSound "Pickup/Potion"
		Inventory.Icon "ARTIPHIL"
		Tag "Spends 1:1 to heal you to max HP."
	States
	{
		Spawn:
			V1TA EFG 1 Bright A_SpawnItemEx("BSSparklies",0,0,30,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.7))
			Loop
		Use:
			TNT1 A 0 A_JumpIf(Health >= GetSpawnHealth, "UseEnd")
			TNT1 A 0 { While ((Health < GetSpawnHealth) && CountInv("Philter")>0)
						{
						A_TakeInventory("Philter", 1);
						A_GiveInventory("Health", 1);
						}
					   If (Health = GetSpawnHealth)
						{
						A_Log("\c[white]Drunk from the \c[orange]Philter\c[white]. It has \c[gold]restored my wounds\c[white]!", true);
						}
					   Else
						{
						A_Log("\c[white]Drunk from the \c[orange]Philter\c[white]. There \c[brick]wasn't enough\c[white] to fully heal me...", true);
						}
					 }
			TNT1 A 0 A_StartSound("Pickup/Drink", 5, ChanF_Maybe_Local)
		UseEnd:
			TNT1 A 0
			Fail
	}
}

ACTOR EstusFlask : Philter
{
	Inventory.Amount 1
	Inventory.MaxAmount 500
	Inventory.Icon "ARTIK3ST"
	Tag "Spends 1:1 to heal you to max HP. Limited!"
	States
	{
		Use:
			TNT1 A 0 A_JumpIf(Health >= GetSpawnHealth, "UseEnd")
			TNT1 A 0 { While ((Health < GetSpawnHealth) && CountInv("EstusFlask")>0)
						{
						A_TakeInventory("EstusFlask", 1);
						A_GiveInventory("Health", 1);
						}
					   If (Health = GetSpawnHealth)
						{
						A_Log("\c[white]Drunk from the \c[orange]Kestus Flask\c[white]. It has \c[gold]restored my wounds\c[white]!", true);
						}
					   Else
						{
						A_Log("\c[white]Drunk from the \c[orange]Kestus Flask\c[white]. There \c[brick]wasn't enough\c[white] to fully heal me...", true);
						}
					 }
			TNT1 A 0 A_StartSound("Pickup/Drink", 5, ChanF_Maybe_Local)
	}
}

ACTOR KestusPickup : CustomInventory 
{
  Scale 0.9
  Radius 18
  Height 18
  RenderStyle Translucent
  +FLOATBOB
  +VISIBILITYPULSE
  Inventory.PickupMessage "\c[white]A refill for my \c[orange]Kestus Flask\c[white]."
  Inventory.PickupSound "Pickup/ManaBig"
  States
  {
  Spawn:
    V1TA EFG 1 Bright
		{A_SpawnItemEx("BSSparklies",0,0,30,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.7));}
    Loop
  Pickup:
    TNT1 A 0 A_GiveInventory("EstusFlask", 75)
    Stop
  }
}

ACTOR Pnakotic : CustomInventory 
{
  Inventory.PickupSound "Pickup/Scroll"
  Inventory.UseSound "PnakoticUse"
  Inventory.PickupMessage "\c[white]A \c[Red]Pnakotic Manuscript\c[white]!! It will certainly help!! [\c[blue]ALL Upgrades when Active\c[white]]"
  Tag "For 30 seconds, all weapons are fully upgraded!"
  Inventory.InterHubAmount 3
  Inventory.MaxAmount 3
  +COUNTITEM
  +FLOATBOB
  +INVENTORY.INVBAR 
  +INVENTORY.PICKUPFLASH
  +INVENTORY.FANCYPICKUPSOUND
  Inventory.Icon "PN4KOTIC"
  States
  {
	Spawn:
		PN4K A 0 Bright A_Jump(255,random(0,6))
		PN4K A 4 Bright
		PN4K B 4 Bright
		PN4K C 4 Bright
		PN4K D 4 Bright
		PN4K E 4 Bright
		PN4K F 4 Bright
		PN4K G 4 Bright
		PN4K H 4 Bright
		Loop
	Use:
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer"),"IsCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer"),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer"),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer"),"IsDrui")
		Stop
	IsMyrm:
		TNT1 A 0 A_QuakeEx(0,9,5,30,0,3,"None",QF_RELATIVE|QF_SCALEDOWN|QF_SCALEUP)
		TNT1 A 0 A_GiveInventory("GladiusUpgrade", 9)
		TNT1 A 0 A_GiveInventory("FistsUpgrade", 9)
		TNT1 A 0 A_GiveInventory("HammerUpgrade", 9)
		TNT1 A 0 A_GiveInventory("AxeUpgrade", 9)
		TNT1 A 0 A_GiveInventory("QuietusUpgrade", 9)
		TNT1 A 0 A_GiveInventory("PnakoticPowerGiver", 1)
		TNT1 A 0 A_SetBlend("FF FF FF",1,35)
		TNT1 A 0 A_SpawnItemEx("PnakoticMonitorMyrm",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_SETTARGET)
		Stop
	IsCrus:
		TNT1 A 0 A_QuakeEx(0,9,5,30,0,3,"None",QF_RELATIVE|QF_SCALEDOWN|QF_SCALEUP)
		TNT1 A 0 A_GiveInventory("MaceUpgrade", 9)
		TNT1 A 0 A_GiveInventory("LightUpgrade", 9)
		TNT1 A 0 A_GiveInventory("SpearUpgrade", 9)
		TNT1 A 0 A_GiveInventory("FiresUpgrade", 9)
		TNT1 A 0 A_GiveInventory("CruxUpgrade", 9)
		TNT1 A 0 A_GiveInventory("PnakoticPowerGiver", 1)
		TNT1 A 0 A_SetBlend("FF FF FF",1,35)
		TNT1 A 0 A_SpawnItemEx("PnakoticMonitorCrus",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_SETTARGET )
		Stop
	IsMagi:
		TNT1 A 0 A_QuakeEx(0,9,5,30,0,3,"None",QF_RELATIVE|QF_SCALEDOWN|QF_SCALEUP)
		TNT1 A 0 A_GiveInventory("VisUpgrade", 9)
		TNT1 A 0 A_GiveInventory("AlgorUpgrade", 9)
		TNT1 A 0 A_GiveInventory("AestusUpgrade", 9)
		TNT1 A 0 A_GiveInventory("FulgurUpgrade", 9)
		TNT1 A 0 A_GiveInventory("AgnusUpgrade", 9)
		TNT1 A 0 A_GiveInventory("PnakoticPowerGiver", 1)
		TNT1 A 0 A_SetBlend("FF FF FF",1,35)
		TNT1 A 0 A_SpawnItemEx("PnakoticMonitorMagi",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_SETTARGET)
		Stop 
	IsDrui:
		TNT1 A 0 A_QuakeEx(0,9,5,30,0,3,"None",QF_RELATIVE|QF_SCALEDOWN|QF_SCALEUP)
		TNT1 A 0 A_GiveInventory("BaselardUpgrade", 9)
		TNT1 A 0 A_GiveInventory("DogUpgrade", 9)
		TNT1 A 0 A_GiveInventory("DagonUpgrade", 9)
		TNT1 A 0 A_GiveInventory("HebikoUpgrade", 9)
		TNT1 A 0 A_GiveInventory("IchivalUpgrade", 9)
		TNT1 A 0 A_GiveInventory("PnakoticPowerGiver", 1)
		TNT1 A 0 A_SetBlend("FF FF FF",1,35)
		TNT1 A 0 A_SpawnItemEx("PnakoticMonitorDrui",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_SETTARGET)
		Stop 
  }
}

ACTOR PnakoticPowerGiver : PowerupGiver
{
	Powerup.Duration -30
	Powerup.Type "Pnakotic"
	Powerup.Color "None", 0.0
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	+INVENTORY.ADDITIVETIME
}

ACTOR PowerPnakotic : Powerup
{
	Powerup.Duration -30
}

ACTOR PnakoticMonitorDrui //This ensures the Pnakotic effect ends after 30 secs. 
{
+NOCLIP
+INVISIBLE
+NOTIMEFREEZE
+NOINTERACTION
+FRIENDLY
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_StartSound("PnakoticLoop",CHAN_6,CHANF_LOOP|CHANF_OVERLAP,0.85,ATTN_NONE)
		TNT1 A 1 A_SpawnItemEx("CorvusB",20,0,40,0,0,0,0,SXF_SETMASTER)
		Goto FollowIt
	FollowIt:		
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",1000,"EndThisYouMongrel")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
					A_Warp(AAPTR_MASTER);
					A_SpawnItemEx("YellowSparklies2",random(20,40),random(-20,20),1,random(2,5),random(-3,3),random(3,7));
					A_SpawnItemEx("QuietSparklies",random(25,40),random(-20,20),1,random(2,5),random(-3,3),random(3,7));
					A_SpawnItemEx("BlueSparklies",random(20,40),random(-20,20),1,random(1,4),random(-3,3),random(3,7));
					A_SpawnItemEx("PurpleSparklies2",random(20,40),random(-20,20),1,random(8,20),random(-3,3),random(3,7));
					A_SpawnItemEx("BSSparklies",0,random(20,40),random(-20,20),1,random(1,3),random(3,7));
					}
		Loop
	EndThisYouMongrel:
		TNT1 A 0 A_StartSound("CrusIconNo",CHAN_7,CHANF_OVERLAP,1,ATTN_NONE,1.1)
	ISaidEndIt:
		TNT1 A 0 A_JumpifInventory("ICONCOUNTER",1050,"ItsAllOver")
		TNT1 A 1 {	A_GiveInventory("ICONCOUNTER",1);
					A_Warp(AAPTR_MASTER);
					A_SpawnItemEx("YellowSparklies2",random(20,40),random(-20,20),1,random(2,5),random(-3,3),random(3,7));
					A_SpawnItemEx("QuietSparklies",random(25,40),random(-20,20),1,random(2,5),random(-3,3),random(3,7));
					A_SpawnItemEx("BlueSparklies",random(20,40),random(-20,20),1,random(0,5),random(-3,3),random(3,7));
					A_SpawnItemEx("PurpleSparklies2",random(20,40),random(-20,20),1,random(8,20),random(-3,3),random(3,7));
					A_SpawnItemEx("BSSparklies",0,random(20,40),random(-20,20),1,random(1,3),random(3,7));
					}
		Loop
	ItsAllOver:
		TNT1 A 0 A_Stopsound(6)
		TNT1 A 1 { 
		A_TakeFromTarget("BaselardUpgrade");
		A_TakeFromTarget("DogUpgrade");
		A_TakeFromTarget("DagonUpgrade");
		A_TakeFromTarget("HebikoUpgrade");
		A_TakeFromTarget("IchivalUpgrade");
		A_GiveToChildren("LightningCheck",1);
		A_StartSound("PnakoticEnd",CHAN_5,CHANF_OVERLAP,1,ATTN_NONE);
				 }
		Stop
  }
}

ACTOR PnakoticMonitorCrus : PnakoticMonitorDrui
{
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_StartSound("PnakoticLoop",CHAN_6,CHANF_LOOP|CHANF_OVERLAP,0.85,ATTN_NONE)
		Goto FollowIt
	ItsAllOver:
		TNT1 A 0 A_Stop
		TNT1 A 1 { 
		A_TakeFromTarget("MaceUpgrade");
		A_TakeFromTarget("LightUpgrade");
		A_TakeFromTarget("FiresUpgrade");
		A_TakeFromTarget("SpearUpgrade");
		A_TakeFromTarget("CruxUpgrade");
		A_StartSound("PnakoticEnd",CHAN_6,CHANF_OVERLAP|CHANF_LOCAL,1,ATTN_NONE);
				 }
		Stop
  }
}

ACTOR PnakoticMonitorMyrm : PnakoticMonitorDrui
{
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_StartSound("PnakoticLoop",CHAN_6,CHANF_LOOP|CHANF_OVERLAP,0.85,ATTN_NONE)
		Goto FollowIt
	ItsAllOver:
		TNT1 A 0 A_Stop
		TNT1 A 1 { 
		A_TakeFromTarget("FistsUpgrade");
		A_TakeFromTarget("AxeUpgrade");
		A_TakeFromTarget("HammerUpgrade");
		A_TakeFromTarget("GladiusUpgrade");
		A_TakeFromTarget("QuietusUpgrade");
		A_StartSound("PnakoticEnd",CHAN_6,CHANF_OVERLAP|CHANF_LOCAL,1,ATTN_NONE);
				 }
		Stop
  }
}

ACTOR PnakoticMonitorMagi : PnakoticMonitorDrui
{
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_StartSound("PnakoticLoop",CHAN_6,CHANF_LOOP|CHANF_OVERLAP,0.85,ATTN_NONE)
		Goto FollowIt
	ItsAllOver:
		TNT1 A 0 A_Stop
		TNT1 A 1 { 
		A_TakeFromTarget("VisUpgrade");
		A_TakeFromTarget("AlgorUpgrade");
		A_TakeFromTarget("AestusUpgrade");
		A_TakeFromTarget("FulgurUpgrade");
		A_TakeFromTarget("AgnusUpgrade");
		A_StartSound("PnakoticEnd",CHAN_6,CHANF_OVERLAP|CHANF_LOCAL,1,ATTN_NONE);
				 }
		Stop
  }
}
//Upgrade Items

ACTOR WhetStone: CustomInventory 
{
  +FLOATBOB
  +COUNTITEM
  +INVENTORY.PICKUPFLASH
  +INVENTORY.BIGPOWERUP
  +INVENTORY.INVBAR
  +INVENTORY.FANCYPICKUPSOUND
  Inventory.PickupSound "Pickup/UseTeamHeal"
  Inventory.PickupMessage "\c[white]A \c[ice]Mystic Whetstone\c[white]! I should use it to enchant my weapons! [\c[gold]!Weapon Upgrader!\c[white]]" 
  Inventory.UseSound "artiuse"
  Inventory.Icon WHTSTN1
  FloatBobStrength 0.5
  Scale 0.8
  Inventory.InterHubAmount 3
  Inventory.MaxAmount 3
  Tag "Upgrade the Myrmidon's Weapons!"
  States
  {
	Spawn:
		WHTS Z 3
		Loop
	Use:
		TNT1 A 0 A_GiveInventory("UpgraderPause", 1) 
		TNT1 A 0 SetPlayerProperty(1,1,PROP_TOTALLYFROZEN)
		TNT1 A 0 A_Overlay(256,"UpgradeBar")
		TNT1 A 0 A_Overlay(257,"UpgradingTitle")
		TNT1 A 0 A_Overlay(258,"UpgradingNote")
		TNT1 A 0 {if(CountInv("WhetStone") == 1)
				{
				A_GiveInventory("WhetStone", 1);
				A_GiveInventory("UpgradeFreezePrevention", 1); 
				}
				else
				{A_TakeInventory("UpgradeFreezePrevention");}} 
		//TNT1 A 0 A_GiveInventory("WhetStone", 1) //Extra one is briefly given to prevent freezes.
		Stop	
	UpgradingTitle:
		UPG9 ABCDEFGH 3 A_JumpIfInventory("UpgradeBarKill",1,"TitleKill")
		Loop
	UpgradingNote:
		UPTX T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",1,"UpgradingNote2")
		Loop
	UpgradingNote2:
		UPTX UUUUUUUUUUUUUUUUUUUU 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		UPTX UUUUZZZZZZZZZZZZZZZZ 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		Loop
	TitleKill:
		UPG9 "#" 1
		Stop
	UpgradeBar: //
		UPG8 VU 2 A_Stop
	UpgradeBarLoop:
		UPG8 T 1 
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"DoNothing")
		UPG8 T 0 A_JumpIfInventory("UpgradeBarKill",1,"UpgradeKill")
		Loop
	CancelUpgrader1:
		UPG8 T 20
		UPG8 T 0 A_Print("", 1)
		UPG8 T 0 A_TakeInventory("UpgradeTimer")
		UPG8 T 0 A_TakeInventory("IAMTHEGREATUPGRADER")
		UPG8 T 1 A_Overlay(258,"UpgradingNote")
		Goto UpgradeBarLoop
	UpgradePrimary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("FistsInHand",1,"UpgradePrimaryFists")
		UPG8 T 0 A_JumpIfInventory("HammerInHand",1,"UpgradePrimaryHammer")
		UPG8 T 0 A_JumpIfInventory("AxeInHand",1,"UpgradePrimaryAxe")
		UPG8 T 0 A_JumpIfInventory("GladiusInHand",1,"UpgradePrimaryGladius")
		UPG8 T 0 A_JumpIfInventory("QuietusInHand",1,"UpgradePrimaryQuietus")
		Goto DoNothing //sanity check
	UpgradeSecondary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("FistsInHand",1,"UpgradeSecondaryFists")
		UPG8 T 0 A_JumpIfInventory("HammerInHand",1,"UpgradeSecondaryHammer")
		UPG8 T 0 A_JumpIfInventory("AxeInHand",1,"UpgradeSecondaryAxe")
		UPG8 T 0 A_JumpIfInventory("GladiusInHand",1,"UpgradeSecondaryGladius")
		UPG8 T 0 A_JumpIfInventory("QuietusInHand",1,"UpgradeSecondaryQuietus")
		Goto DoNothing //sanity check
	UpgradeTertiary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("FistsInHand",1,"UpgradeTertiaryFists")
		UPG8 T 0 A_JumpIfInventory("HammerInHand",1,"UpgradeTertiaryHammer")
		UPG8 T 0 A_JumpIfInventory("AxeInHand",1,"UpgradeTertiaryAxe")
		UPG8 T 0 A_JumpIfInventory("GladiusInHand",1,"UpgradeTertiaryGladius")
		UPG8 T 0 A_JumpIfInventory("QuietusInHand",1,"UpgradeTertiaryQuietus")
		Goto DoNothing //sanity check
	UpgradePrimaryAxe:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("AxeUpgrade") == 0 || CountInv("AxeUpgrade") == 3 || CountInv("AxeUpgrade") == 5 || CountInv("AxeUpgrade") == 8)
				{
				A_Print("$MYRMAXE1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryAxeWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryAxe2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryAxe2:
		UPG8 T 1 {A_GiveInventory("AxeUpgrade",1); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryAxe:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AxeUpgrade") == 0 || CountInv("AxeUpgrade") == 1 || CountInv("AxeUpgrade") == 5 || CountInv("AxeUpgrade") == 6)
				{
				A_Print("$MYRMAXE2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryAxeWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryAxe2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryAxe2:
		UPG8 T 1 {A_GiveInventory("AxeUpgrade",3); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryAxe:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AxeUpgrade") == 0 || CountInv("AxeUpgrade") == 1 || CountInv("AxeUpgrade") == 3 || CountInv("AxeUpgrade") == 4)
				{
				A_Print("$MYRMAXE3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryAxeWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryAxe2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryAxe2:
		UPG8 T 1 {A_GiveInventory("AxeUpgrade",5); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////
	UpgradePrimaryFists:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("FistsUpgrade") == 0 || CountInv("FistsUpgrade") == 3 || CountInv("FistsUpgrade") == 5 || CountInv("FistsUpgrade") == 8)
				{
				A_Print("$MYRMFIST4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryFistsWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryFists2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryFists2:
		UPG8 T 1 {A_GiveInventory("FistsUpgrade",9); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryFists:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("FistsUpgrade") == 0 || CountInv("FistsUpgrade") == 1 || CountInv("FistsUpgrade") == 5 || CountInv("FistsUpgrade") == 6)
				{
				A_Print("$MYRMFIST4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryFistsWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryFists2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryFists2:
		UPG8 T 1 {A_GiveInventory("FistsUpgrade",9); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryFists:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("FistsUpgrade") == 0 || CountInv("FistsUpgrade") == 1 || CountInv("FistsUpgrade") == 3 || CountInv("FistsUpgrade") == 4)
				{
				A_Print("$MYRMFIST4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryFistsWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryFists2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryFists2:
		UPG8 T 1 {A_GiveInventory("FistsUpgrade",9); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryGladius:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("GladiusUpgrade") == 0 || CountInv("GladiusUpgrade") == 3 || CountInv("GladiusUpgrade") == 5 || CountInv("GladiusUpgrade") == 8)
				{
				A_Print("$MYRMGLA1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryGladiusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryGladius2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryGladius2:
		UPG8 T 1 {A_GiveInventory("GladiusUpgrade",1); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryGladius:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("GladiusUpgrade") == 0 || CountInv("GladiusUpgrade") == 1 || CountInv("GladiusUpgrade") == 5 || CountInv("GladiusUpgrade") == 6)
				{
				A_Print("$MYRMGLA2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryGladiusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryGladius2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryGladius2:
		UPG8 T 1 {A_GiveInventory("GladiusUpgrade",3); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryGladius:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("GladiusUpgrade") == 0 || CountInv("GladiusUpgrade") == 1 || CountInv("GladiusUpgrade") == 3 || CountInv("GladiusUpgrade") == 4)
				{
				A_Print("$MYRMGLA3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryGladiusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryGladius2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryGladius2:
		UPG8 T 1 {A_GiveInventory("GladiusUpgrade",5); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryHammer:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("HammerUpgrade") == 0 || CountInv("HammerUpgrade") == 3 || CountInv("HammerUpgrade") == 5 || CountInv("HammerUpgrade") == 8)
				{
				A_Print("$MYRMHAM1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryHammerWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryHammer2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryHammer2:
		UPG8 T 1 {A_GiveInventory("HammerUpgrade",1); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryHammer:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("HammerUpgrade") == 0 || CountInv("HammerUpgrade") == 1 || CountInv("HammerUpgrade") == 5 || CountInv("HammerUpgrade") == 6)
				{
				A_Print("$MYRMHAM2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryHammerWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryHammer2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryHammer2:
		UPG8 T 1 {A_GiveInventory("HammerUpgrade",3); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryHammer:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("HammerUpgrade") == 0 || CountInv("HammerUpgrade") == 1 || CountInv("HammerUpgrade") == 3 || CountInv("HammerUpgrade") == 4)
				{
				A_Print("$MYRMHAM3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryHammerWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryHammer2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryHammer2:
		UPG8 T 1 {A_GiveInventory("HammerUpgrade",5); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryQuietus:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("QuietusUpgrade") == 0 || CountInv("QuietusUpgrade") == 3 || CountInv("QuietusUpgrade") == 5 || CountInv("QuietusUpgrade") == 8)
				{
				A_Print("$MYRMQUI1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryQuietusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryQuietus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryQuietus2:
		UPG8 T 1 {A_GiveInventory("QuietusUpgrade",1); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryQuietus:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("QuietusUpgrade") == 0 || CountInv("QuietusUpgrade") == 1 || CountInv("QuietusUpgrade") == 5 || CountInv("QuietusUpgrade") == 6)
				{
				A_Print("$MYRMQUI2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryQuietusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryQuietus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryQuietus2:
		UPG8 T 1 {A_GiveInventory("QuietusUpgrade",3); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryQuietus:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("QuietusUpgrade") == 0 || CountInv("QuietusUpgrade") == 1 || CountInv("QuietusUpgrade") == 3 || CountInv("QuietusUpgrade") == 4)
				{
				A_Print("$MYRMQUI3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryQuietusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryQuietus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryQuietus2:
		UPG8 T 1 {A_GiveInventory("QuietusUpgrade",5); A_StartSound("EnchantMyrm",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	DoNothing: //If aborted, the item is refunded.
		UPG8 T 1 {A_Print("Upgrading Aborted!", 3, "UPGFNT"); A_GiveInventory("IAMTHEGREATUPGRADER",2);}
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1)
				{A_TakeInventory("UpgradeFreezePrevention", 1);}
				else
				{A_GiveInventory("WhetStone", 1);}
				}
		Stop
	PostProcessing:
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1) //If a bonus was given earlier, remove it.
				{
				A_TakeInventory("UpgradeFreezePrevention", 1); 
				A_TakeInventory("WhetStone", 1);
				}}
		Stop
  }
}

ACTOR BlessedCharm : WhetStone
{
  Inventory.Icon BLSCHM1
  Inventory.PickupMessage "\c[white]A \c[gold]Blessed Charm\c[white]! I should use it to enhance my artefacts! [\c[gold]!Weapon Upgrader!\c[white]]" 
  Tag "Upgrade the Crusader's Weapons & Artifacts!"
  States
  {
	Spawn:
		CHRM Z 3 
		Loop
	Use:
		TNT1 A 0 A_GiveInventory("UpgraderPause", 1) 
		TNT1 A 0 SetPlayerProperty(1,1,PROP_TOTALLYFROZEN)
		TNT1 A 0 A_Overlay(256,"UpgradeBar")
		TNT1 A 0 A_Overlay(257,"UpgradingTitle")
		TNT1 A 0 A_Overlay(258,"UpgradingNote")
		TNT1 A 0 {if(CountInv("BlessedCharm") == 1)
				{
				A_GiveInventory("BlessedCharm", 1);
				A_GiveInventory("UpgradeFreezePrevention", 1); 
				}
				else
				{A_TakeInventory("UpgradeFreezePrevention");}} 
		//TNT1 A 0 A_GiveInventory("BlessedCharm", 1) //Extra one is briefly given to prevent freezes.
		Stop	
	UpgradingTitle:
		UPG9 ABCDEFGH 3 A_JumpIfInventory("UpgradeBarKill",1,"TitleKill")
		Loop
	UpgradingNote:
		UPTX T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",1,"UpgradingNote2")
		Loop
	UpgradingNote2:
		UPTX UUUUUUUUUUUUUUUUUUUU 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		UPTX UUUUZZZZZZZZZZZZZZZZ 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		Loop
	TitleKill:
		UPG9 "#" 1
		Stop
	UpgradeBar: //
		UPG8 VU 2 A_Stop
	UpgradeBarLoop:
		UPG8 T 1 
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"DoNothing")
		UPG8 T 0 A_JumpIfInventory("UpgradeBarKill",1,"UpgradeKill")
		Loop
	CancelUpgrader1:
		UPG8 T 20
		UPG8 T 0 A_Print("", 1)
		UPG8 T 0 A_TakeInventory("UpgradeTimer")
		UPG8 T 0 A_TakeInventory("IAMTHEGREATUPGRADER")
		UPG8 T 1 A_Overlay(258,"UpgradingNote")
		Goto UpgradeBarLoop
	UpgradePrimary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("MaceInHand",1,"UpgradePrimaryMace")
		UPG8 T 0 A_JumpIfInventory("LightInHand",1,"UpgradePrimaryLight")
		UPG8 T 0 A_JumpIfInventory("SpearInHand",1,"UpgradePrimarySpear")
		UPG8 T 0 A_JumpIfInventory("FiresInHand",1,"UpgradePrimaryFires")
		UPG8 T 0 A_JumpIfInventory("CruxInHand",1,"UpgradePrimaryCrux")
		Goto DoNothing //sanity check
	UpgradeSecondary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("MaceInHand",1,"UpgradeSecondaryMace")
		UPG8 T 0 A_JumpIfInventory("LightInHand",1,"UpgradeSecondaryLight")
		UPG8 T 0 A_JumpIfInventory("SpearInHand",1,"UpgradeSecondarySpear")
		UPG8 T 0 A_JumpIfInventory("FiresInHand",1,"UpgradeSecondaryFires")
		UPG8 T 0 A_JumpIfInventory("CruxInHand",1,"UpgradeSecondaryCrux")
		Goto DoNothing //sanity check
	UpgradeTertiary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("MaceInHand",1,"UpgradeTertiaryMace")
		UPG8 T 0 A_JumpIfInventory("LightInHand",1,"UpgradeTertiaryLight")
		UPG8 T 0 A_JumpIfInventory("SpearInHand",1,"UpgradeTertiarySpear")
		UPG8 T 0 A_JumpIfInventory("FiresInHand",1,"UpgradeTertiaryFires")
		UPG8 T 0 A_JumpIfInventory("CruxInHand",1,"UpgradeTertiaryCrux")
		Goto DoNothing //sanity check
	/////////////////////////////////////////////////////////////////////////////////////
	UpgradePrimarySpear:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("SpearUpgrade") == 0 || CountInv("SpearUpgrade") == 3 || CountInv("SpearUpgrade") == 5 || CountInv("SpearUpgrade") == 8)
				{
				A_Print("$CRUSSPR1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimarySpearWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimarySpear2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimarySpear2:
		UPG8 T 1 {A_GiveInventory("SpearUpgrade",1); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondarySpear:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("SpearUpgrade") == 0 || CountInv("SpearUpgrade") == 1 || CountInv("SpearUpgrade") == 5 || CountInv("SpearUpgrade") == 6)
				{
				A_Print("$CRUSSPR2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondarySpearWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondarySpear2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondarySpear2:
		UPG8 T 1 {A_GiveInventory("SpearUpgrade",3); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiarySpear:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("SpearUpgrade") == 0 || CountInv("SpearUpgrade") == 1 || CountInv("SpearUpgrade") == 3 || CountInv("SpearUpgrade") == 4)
				{
				A_Print("$CRUSSPR3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiarySpearWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiarySpear2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiarySpear2:
		UPG8 T 1 {A_GiveInventory("SpearUpgrade",5); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
	/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryLight:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("LightUpgrade") == 0 || CountInv("LightUpgrade") == 3 || CountInv("LightUpgrade") == 5 || CountInv("LightUpgrade") == 8)
				{
				A_Print("$CRUSLIT1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryLightWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryLight2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryLight2:
		UPG8 T 1 {A_GiveInventory("LightUpgrade",1); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryLight:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("LightUpgrade") == 0 || CountInv("LightUpgrade") == 1 || CountInv("LightUpgrade") == 5 || CountInv("LightUpgrade") == 6)
				{
				A_Print("$CRUSLIT2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryLightWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryLight2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryLight2:
		UPG8 T 1 {A_GiveInventory("LightUpgrade",3); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryLight:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("LightUpgrade") == 0 || CountInv("LightUpgrade") == 1 || CountInv("LightUpgrade") == 3 || CountInv("LightUpgrade") == 4)
				{
				A_Print("$CRUSLIT3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryLightWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryLight2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryLight2:
		UPG8 T 1 {A_GiveInventory("LightUpgrade",5); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
	/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryFires:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("FiresUpgrade") == 0 || CountInv("FiresUpgrade") == 3 || CountInv("FiresUpgrade") == 5 || CountInv("FiresUpgrade") == 8)
				{
				A_Print("$CRUSFIR1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryFiresWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryFires2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryFires2:
		UPG8 T 1 {A_GiveInventory("FiresUpgrade",1); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1); A_GiveInventory("MaceChargeCheck2",1);}
		Goto PostProcessing 	
	UpgradeSecondaryFires:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("FiresUpgrade") == 0 || CountInv("FiresUpgrade") == 1 || CountInv("FiresUpgrade") == 5 || CountInv("FiresUpgrade") == 6)
				{
				A_Print("$CRUSFIR2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryFiresWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryFires2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryFires2:
		UPG8 T 1 {A_GiveInventory("FiresUpgrade",3); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryFires:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("FiresUpgrade") == 0 || CountInv("FiresUpgrade") == 1 || CountInv("FiresUpgrade") == 3 || CountInv("FiresUpgrade") == 4)
				{
				A_Print("$CRUSFIR3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryFiresWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryFires2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryFires2:
		UPG8 T 1 {A_GiveInventory("FiresUpgrade",5); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
	/////////////////////////////////////////////////////////////////////////////////////		
	UpgradePrimaryCrux:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("CruxUpgrade") == 0 || CountInv("CruxUpgrade") == 3 || CountInv("CruxUpgrade") == 5 || CountInv("CruxUpgrade") == 8)
				{
				A_Print("$CRUSCRU1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryCruxWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryCrux2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryCrux2:
		UPG8 T 1 {A_GiveInventory("CruxUpgrade",1); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryCrux:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("CruxUpgrade") == 0 || CountInv("CruxUpgrade") == 1 || CountInv("CruxUpgrade") == 5 || CountInv("CruxUpgrade") == 6)
				{
				A_Print("$CRUSCRU2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryCruxWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryCrux2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryCrux2:
		UPG8 T 1 {A_GiveInventory("CruxUpgrade",3); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryCrux:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("CruxUpgrade") == 0 || CountInv("CruxUpgrade") == 1 || CountInv("CruxUpgrade") == 3 || CountInv("CruxUpgrade") == 4)
				{
				A_Print("$CRUSCRU3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryCruxWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryCrux2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryCrux2:
		UPG8 T 1 {A_GiveInventory("CruxUpgrade",5); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
	/////////////////////////////////////////////////////////////////////////////////////		
	UpgradePrimaryMace:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("MaceUpgrade") == 0 || CountInv("MaceUpgrade") == 3 || CountInv("MaceUpgrade") == 5 || CountInv("MaceUpgrade") == 8)
				{
				A_Print("$CRUSMAC4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryMaceWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryMace2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryMace2:
		UPG8 T 1 {A_GiveInventory("MaceUpgrade",9); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryMace:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("MaceUpgrade") == 0 || CountInv("MaceUpgrade") == 1 || CountInv("MaceUpgrade") == 5 || CountInv("MaceUpgrade") == 6)
				{
				A_Print("$CRUSMAC4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryMaceWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryMace2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryMace2:
		UPG8 T 1 {A_GiveInventory("MaceUpgrade",9); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryMace:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("MaceUpgrade") == 0 || CountInv("MaceUpgrade") == 1 || CountInv("MaceUpgrade") == 3 || CountInv("MaceUpgrade") == 4)
				{
				A_Print("$CRUSMAC4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryMaceWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryMace2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryMace2:
		UPG8 T 1 {A_GiveInventory("MaceUpgrade",9); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
	/////////////////////////////////////////////////////////////////////////////////////		
	DoNothing: //If aborted, the item is refunded.
		UPG8 T 1 {A_Print("Upgrading Aborted!", 3, "UPGFNT"); A_GiveInventory("IAMTHEGREATUPGRADER",2);}
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1)
				{A_TakeInventory("UpgradeFreezePrevention", 1);}
				else
				{A_GiveInventory("BlessedCharm", 1);}
				}
		Stop
	PostProcessing:
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1) //If a bonus was given earlier, remove it.
				{
				A_TakeInventory("UpgradeFreezePrevention", 1); 
				A_TakeInventory("BlessedCharm", 1);
				}}
		Stop
  }
}

ACTOR AncientGrimoire : WhetStone
{
  Inventory.Icon ANCGRIM
  Inventory.PickupMessage "\c[white]An \c[brick]Ancient Grimoire\c[white]? I should read it to further my knowledge of spells! [\c[gold]!Weapon Upgrader!\c[white]]" 
  Tag "Upgrade the Magister's Spells!"
  States
  {
	Spawn:
		GR8K Y 3 
		Loop
	Use:
		TNT1 A 0 A_GiveInventory("UpgraderPause", 1) 
		TNT1 A 0 SetPlayerProperty(1,1,PROP_TOTALLYFROZEN)
		TNT1 A 0 A_Overlay(256,"UpgradeBar")
		TNT1 A 0 A_Overlay(257,"UpgradingTitle")
		TNT1 A 0 A_Overlay(258,"UpgradingNote")
		TNT1 A 0 {if(CountInv("AncientGrimoire") == 1)
				{
				A_GiveInventory("AncientGrimoire", 1);
				A_GiveInventory("UpgradeFreezePrevention", 1); 
				}
				else
				{A_TakeInventory("UpgradeFreezePrevention");}} 
		//TNT1 A 0 A_GiveInventory("AncientGrimoire", 1) //Extra one is briefly given to prevent freezes.
		Stop	
	UpgradingTitle:
		UPG9 ABCDEFGH 3 A_JumpIfInventory("UpgradeBarKill",1,"TitleKill")
		Loop
	UpgradingNote:
		UPTX T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",1,"UpgradingNote2")
		Loop
	UpgradingNote2:
		UPTX UUUUUUUUUUUUUUUUUUUU 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		UPTX UUUUZZZZZZZZZZZZZZZZ 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		Loop
	TitleKill:
		UPG9 "#" 1
		Stop
	UpgradeBar: //
		UPG8 VU 2 A_Stop
	UpgradeBarLoop:
		UPG8 T 1 
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"DoNothing")
		UPG8 T 0 A_JumpIfInventory("UpgradeBarKill",1,"UpgradeKill")
		Loop
	CancelUpgrader1:
		UPG8 T 20
		UPG8 T 0 A_Print("", 1)
		UPG8 T 0 A_TakeInventory("UpgradeTimer")
		UPG8 T 0 A_TakeInventory("IAMTHEGREATUPGRADER")
		UPG8 T 1 A_Overlay(258,"UpgradingNote")
		Goto UpgradeBarLoop
	UpgradePrimary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("VisInHand",1,"UpgradePrimaryVis")
		UPG8 T 0 A_JumpIfInventory("AestusInHand",1,"UpgradePrimaryAestus")
		UPG8 T 0 A_JumpIfInventory("AlgorInHand",1,"UpgradePrimaryAlgor")
		UPG8 T 0 A_JumpIfInventory("FulgurInHand",1,"UpgradePrimaryFulgur")
		UPG8 T 0 A_JumpIfInventory("AgnusInHand",1,"UpgradePrimaryAgnus")
		Goto DoNothing //sanity check
	UpgradeSecondary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("VisInHand",1,"UpgradeSecondaryVis")
		UPG8 T 0 A_JumpIfInventory("AestusInHand",1,"UpgradeSecondaryAestus")
		UPG8 T 0 A_JumpIfInventory("AlgorInHand",1,"UpgradeSecondaryAlgor")
		UPG8 T 0 A_JumpIfInventory("FulgurInHand",1,"UpgradeSecondaryFulgur")
		UPG8 T 0 A_JumpIfInventory("AgnusInHand",1,"UpgradeSecondaryAgnus")
		Goto DoNothing //sanity check
	UpgradeTertiary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("VisInHand",1,"UpgradeTertiaryVis")
		UPG8 T 0 A_JumpIfInventory("AestusInHand",1,"UpgradeTertiaryAestus")
		UPG8 T 0 A_JumpIfInventory("AlgorInHand",1,"UpgradeTertiaryAlgor")
		UPG8 T 0 A_JumpIfInventory("FulgurInHand",1,"UpgradeTertiaryFulgur")
		UPG8 T 0 A_JumpIfInventory("AgnusInHand",1,"UpgradeTertiaryAgnus")
		Goto DoNothing //sanity check
	UpgradePrimaryAlgor:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("AlgorUpgrade") == 0 || CountInv("AlgorUpgrade") == 3 || CountInv("AlgorUpgrade") == 5 || CountInv("AlgorUpgrade") == 8)
				{
				A_Print("$MAGIALG1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryAlgorWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryAlgor2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryAlgor2:
		UPG8 T 1 {A_GiveInventory("AlgorUpgrade",1); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryAlgor:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AlgorUpgrade") == 0 || CountInv("AlgorUpgrade") == 1 || CountInv("AlgorUpgrade") == 5 || CountInv("AlgorUpgrade") == 6)
				{
				A_Print("$MAGIALG2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryAlgorWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryAlgor2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryAlgor2:
		UPG8 T 1 {A_GiveInventory("AlgorUpgrade",3); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryAlgor:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AlgorUpgrade") == 0 || CountInv("AlgorUpgrade") == 1 || CountInv("AlgorUpgrade") == 3 || CountInv("AlgorUpgrade") == 4)
				{
				A_Print("$MAGIALG3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryAlgorWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryAlgor2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryAlgor2:
		UPG8 T 1 {A_GiveInventory("AlgorUpgrade",5); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////
	UpgradePrimaryVis:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("VisUpgrade") == 0 || CountInv("VisUpgrade") == 3 || CountInv("VisUpgrade") == 5 || CountInv("VisUpgrade") == 8)
				{
				A_Print("$MAGIVIS4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryVisWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryVis2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryVis2:
		UPG8 T 1 {A_GiveInventory("VisUpgrade",9); A_StartSound("EnchantCrus",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryVis:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("VisUpgrade") == 0 || CountInv("VisUpgrade") == 1 || CountInv("VisUpgrade") == 5 || CountInv("VisUpgrade") == 6)
				{
				A_Print("$MAGIVIS4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryVisWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryVis2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryVis2:
		UPG8 T 1 {A_GiveInventory("VisUpgrade",9); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryVis:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("VisUpgrade") == 0 || CountInv("VisUpgrade") == 1 || CountInv("VisUpgrade") == 3 || CountInv("VisUpgrade") == 4)
				{
				A_Print("$MAGIVIS4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryVisWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryVis2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryVis2:
		UPG8 T 1 {A_GiveInventory("VisUpgrade",9); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryAestus:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("AestusUpgrade") == 0 || CountInv("AestusUpgrade") == 3 || CountInv("AestusUpgrade") == 5 || CountInv("AestusUpgrade") == 8)
				{
				A_Print("$MAGIAES1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryAestusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryAestus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryAestus2:
		UPG8 T 1 {A_GiveInventory("AestusUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryAestus:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AestusUpgrade") == 0 || CountInv("AestusUpgrade") == 1 || CountInv("AestusUpgrade") == 5 || CountInv("AestusUpgrade") == 6)
				{
				A_Print("$MAGIAES2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryAestusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryAestus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryAestus2:
		UPG8 T 1 {A_GiveInventory("AestusUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryAestus:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AestusUpgrade") == 0 || CountInv("AestusUpgrade") == 1 || CountInv("AestusUpgrade") == 3 || CountInv("AestusUpgrade") == 4)
				{
				A_Print("$MAGIAES3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryAestusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryAestus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryAestus2:
		UPG8 T 1 {A_GiveInventory("AestusUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryFulgur:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("FulgurUpgrade") == 0 || CountInv("FulgurUpgrade") == 3 || CountInv("FulgurUpgrade") == 5 || CountInv("FulgurUpgrade") == 8)
				{
				A_Print("$MAGIFUL1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryFulgurWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryFulgur2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryFulgur2:
		UPG8 T 1 {A_GiveInventory("FulgurUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryFulgur:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("FulgurUpgrade") == 0 || CountInv("FulgurUpgrade") == 1 || CountInv("FulgurUpgrade") == 5 || CountInv("FulgurUpgrade") == 6)
				{
				A_Print("$MAGIFUL2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryFulgurWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryFulgur2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryFulgur2:
		UPG8 T 1 {A_GiveInventory("FulgurUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryFulgur:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("FulgurUpgrade") == 0 || CountInv("FulgurUpgrade") == 1 || CountInv("FulgurUpgrade") == 3 || CountInv("FulgurUpgrade") == 4)
				{
				A_Print("$MAGIFUL3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryFulgurWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryFulgur2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryFulgur2:
		UPG8 T 1 {A_GiveInventory("FulgurUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryAgnus:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("AgnusUpgrade") == 0 || CountInv("AgnusUpgrade") == 3 || CountInv("AgnusUpgrade") == 5 || CountInv("AgnusUpgrade") == 8)
				{
				A_Print("$MAGIAGN1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryAgnusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryAgnus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryAgnus2:
		UPG8 T 1 {A_GiveInventory("AgnusUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryAgnus:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AgnusUpgrade") == 0 || CountInv("AgnusUpgrade") == 1 || CountInv("AgnusUpgrade") == 5 || CountInv("AgnusUpgrade") == 6)
				{
				A_Print("$MAGIAGN2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryAgnusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryAgnus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryAgnus2:
		UPG8 T 1 {A_GiveInventory("AgnusUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryAgnus:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("AgnusUpgrade") == 0 || CountInv("AgnusUpgrade") == 1 || CountInv("AgnusUpgrade") == 3 || CountInv("AgnusUpgrade") == 4)
				{
				A_Print("$MAGIAGN3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryAgnusWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryAgnus2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryAgnus2:
		UPG8 T 1 {A_GiveInventory("AgnusUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	DoNothing: //If aborted, the item is refunded.
		UPG8 T 1 {A_Print("Upgrading Aborted!", 3, "UPGFNT"); A_GiveInventory("IAMTHEGREATUPGRADER",2);}
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1)
				{A_TakeInventory("UpgradeFreezePrevention", 1);}
				else
				{A_GiveInventory("AncientGrimoire", 1);}
				}
		Stop
	PostProcessing:
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1) //If a bonus was given earlier, remove it.
				{
				A_TakeInventory("UpgradeFreezePrevention", 1); 
				A_TakeInventory("AncientGrimoire", 1);
				}}
		Stop
  }
}

ACTOR BluuTriiFruit : WhetStone
{
  Inventory.Icon BLUETRII
  Inventory.PickupMessage "\c[white]An \c[blue]Azurinthine\c[white]? This fruit's power will help improve my attunement with nature. [\c[gold]!Weapon Upgrader!\c[white]]" 
  Tag "Upgrade the Druid's Weapons & Artifacts!"
  States
  {
	Spawn:
		BLUT R 3 //changeme
		Loop
	Use:
		TNT1 A 0 A_GiveInventory("UpgraderPause", 1) 
		TNT1 A 0 SetPlayerProperty(1,1,PROP_TOTALLYFROZEN)
		TNT1 A 0 A_Overlay(256,"UpgradeBar")
		TNT1 A 0 A_Overlay(257,"UpgradingTitle")
		TNT1 A 0 A_Overlay(258,"UpgradingNote")
		TNT1 A 0 {if(CountInv("BluuTriiFruit") == 1)
				{
				A_GiveInventory("BluuTriiFruit", 1);
				A_GiveInventory("UpgradeFreezePrevention", 1); 
				}
				else
				{A_TakeInventory("UpgradeFreezePrevention");}} 
		//TNT1 A 0 A_GiveInventory("BluuTriiFruit", 1) //Extra one is briefly given to prevent freezes.
		Stop	
	UpgradingTitle:
		UPG9 ABCDEFGH 3 A_JumpIfInventory("UpgradeBarKill",1,"TitleKill")
		Loop
	UpgradingNote:
		UPTX T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",1,"UpgradingNote2")
		Loop
	UpgradingNote2:
		UPTX UUUUUUUUUUUUUUUUUUUU 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		UPTX UUUUZZZZZZZZZZZZZZZZ 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"TitleKill")
		Loop
	TitleKill:
		UPG9 "#" 1
		Stop
	UpgradeBar: //
		UPG8 VU 2 A_Stop
	UpgradeBarLoop:
		UPG8 T 1 
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiary")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"DoNothing")
		UPG8 T 0 A_JumpIfInventory("UpgradeBarKill",1,"UpgradeKill")
		Loop
	CancelUpgrader1:
		UPG8 T 20
		UPG8 T 0 A_Print("", 1)
		UPG8 T 0 A_TakeInventory("UpgradeTimer")
		UPG8 T 0 A_TakeInventory("IAMTHEGREATUPGRADER")
		UPG8 T 1 A_Overlay(258,"UpgradingNote")
		Goto UpgradeBarLoop
	UpgradePrimary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("BaselardInHand",1,"UpgradePrimaryBaselard")
		UPG8 T 0 A_JumpIfInventory("DagonInHand",1,"UpgradePrimaryDagon")
		UPG8 T 0 A_JumpIfInventory("DogInHand",1,"UpgradePrimaryDog")
		UPG8 T 0 A_JumpIfInventory("HebikoInHand",1,"UpgradePrimaryHebiko")
		UPG8 T 0 A_JumpIfInventory("IchivalInHand",1,"UpgradePrimaryIchival")
		Goto DoNothing //sanity check
	UpgradeSecondary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("BaselardInHand",1,"UpgradeSecondaryBaselard")
		UPG8 T 0 A_JumpIfInventory("DagonInHand",1,"UpgradeSecondaryDagon")
		UPG8 T 0 A_JumpIfInventory("DogInHand",1,"UpgradeSecondaryDog")
		UPG8 T 0 A_JumpIfInventory("HebikoInHand",1,"UpgradeSecondaryHebiko")
		UPG8 T 0 A_JumpIfInventory("IchivalInHand",1,"UpgradeSecondaryIchival")
		Goto DoNothing //sanity check
	UpgradeTertiary:
		UPG8 T 0 A_GiveInventory("IAMTHEGREATUPGRADER",1) //tracks current state
		UPG8 T 0 A_JumpIfInventory("BaselardInHand",1,"UpgradeTertiaryBaselard")
		UPG8 T 0 A_JumpIfInventory("DagonInHand",1,"UpgradeTertiaryDagon")
		UPG8 T 0 A_JumpIfInventory("DogInHand",1,"UpgradeTertiaryDog")
		UPG8 T 0 A_JumpIfInventory("HebikoInHand",1,"UpgradeTertiaryHebiko")
		UPG8 T 0 A_JumpIfInventory("IchivalInHand",1,"UpgradeTertiaryIchival")
		Goto DoNothing //sanity check
/////////////////////////////////////////////////////////////////////////////////
	UpgradePrimaryBaselard:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("BaselardUpgrade") == 0 || CountInv("BaselardUpgrade") == 3 || CountInv("BaselardUpgrade") == 5 || CountInv("BaselardUpgrade") == 8)
				{
				A_Print("$DRUIBAS4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryBaselardWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryBaselard2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryBaselard2:
		UPG8 T 1 {	A_GiveInventory("BaselardUpgrade",9); 
					A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); 
					A_GiveInventory("IAMTHEGREATUPGRADER",1);
					A_GiveInventory("ChainHook",1);
					A_SpawnItemEx("CorvusB",20,0,40,0,0,0,0,SXF_SETMASTER);}
		Goto PostProcessing 	
	UpgradeSecondaryBaselard:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("BaselardUpgrade") == 0 || CountInv("BaselardUpgrade") == 1 || CountInv("BaselardUpgrade") == 5 || CountInv("BaselardUpgrade") == 6)
				{
				A_Print("$DRUIBAS4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryBaselardWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryBaselard2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryBaselard2:
		UPG8 T 1 {	A_GiveInventory("BaselardUpgrade",9); 
					A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); 
					A_GiveInventory("IAMTHEGREATUPGRADER",1);
					A_GiveInventory("ChainHook",1);
					A_SpawnItemEx("CorvusB",20,0,40,0,0,0,0,SXF_SETMASTER);}
		Goto PostProcessing 	
	UpgradeTertiaryBaselard:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("BaselardUpgrade") == 0 || CountInv("BaselardUpgrade") == 1 || CountInv("BaselardUpgrade") == 3 || CountInv("BaselardUpgrade") == 4)
				{
				A_Print("$DRUIBAS4", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryBaselardWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryBaselard2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryBaselard2:
		UPG8 T 1 {	A_GiveInventory("BaselardUpgrade",9); 
					A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); 
					A_GiveInventory("IAMTHEGREATUPGRADER",1);
					A_GiveInventory("ChainHook",1);
					A_SpawnItemEx("CorvusB",20,0,40,0,0,0,0,SXF_SETMASTER);}
		Goto PostProcessing
/////////////////////////////////////////////////////////////////////////////////
	UpgradePrimaryDog:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("DogUpgrade") == 0 || CountInv("DogUpgrade") == 3 || CountInv("DogUpgrade") == 5 || CountInv("DogUpgrade") == 8)
				{
				A_Print("$DRUIDOG1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryDogWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryDog2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryDog2:
		UPG8 T 1 {A_GiveInventory("DogUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryDog:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("DogUpgrade") == 0 || CountInv("DogUpgrade") == 1 || CountInv("DogUpgrade") == 5 || CountInv("DogUpgrade") == 6)
				{
				A_Print("$DRUIDOG2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryDogWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryDog2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryDog2:
		UPG8 T 1 {A_GiveInventory("DogUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryDog:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("DogUpgrade") == 0 || CountInv("DogUpgrade") == 1 || CountInv("DogUpgrade") == 3 || CountInv("DogUpgrade") == 4)
				{
				A_Print("$DRUIDOG3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryDogWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryDog2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryDog2:
		UPG8 T 1 {A_GiveInventory("DogUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////
	UpgradePrimaryDagon:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("DagonUpgrade") == 0 || CountInv("DagonUpgrade") == 3 || CountInv("DagonUpgrade") == 5 || CountInv("DagonUpgrade") == 8)
				{
				A_Print("$DRUIDAG1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryDagonWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryDagon2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryDagon2:
		UPG8 T 1 {A_GiveInventory("DagonUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryDagon:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("DagonUpgrade") == 0 || CountInv("DagonUpgrade") == 1 || CountInv("DagonUpgrade") == 5 || CountInv("DagonUpgrade") == 6)
				{
				A_Print("$DRUIDAG2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryDagonWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryDagon2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryDagon2:
		UPG8 T 1 {A_GiveInventory("DagonUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryDagon:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("DagonUpgrade") == 0 || CountInv("DagonUpgrade") == 1 || CountInv("DagonUpgrade") == 3 || CountInv("DagonUpgrade") == 4)
				{
				A_Print("$DRUIDAG3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryDagonWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryDagon2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryDagon2:
		UPG8 T 1 {A_GiveInventory("DagonUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryHebiko:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("HebikoUpgrade") == 0 || CountInv("HebikoUpgrade") == 3 || CountInv("HebikoUpgrade") == 5 || CountInv("HebikoUpgrade") == 8)
				{
				A_Print("$DRUIHEB1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryHebikoWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryHebiko2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryHebiko2:
		UPG8 T 1 {A_GiveInventory("HebikoUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryHebiko:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("HebikoUpgrade") == 0 || CountInv("HebikoUpgrade") == 1 || CountInv("HebikoUpgrade") == 5 || CountInv("HebikoUpgrade") == 6)
				{
				A_Print("$DRUIHEB2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryHebikoWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryHebiko2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryHebiko2:
		UPG8 T 1 {A_GiveInventory("HebikoUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryHebiko:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("HebikoUpgrade") == 0 || CountInv("HebikoUpgrade") == 1 || CountInv("HebikoUpgrade") == 3 || CountInv("HebikoUpgrade") == 4)
				{
				A_Print("$DRUIHEB3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryHebikoWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryHebiko2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryHebiko2:
		UPG8 T 1 {A_GiveInventory("HebikoUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	UpgradePrimaryIchival:	
		UPG8 T 1 
		UPG8 T 1 
		{
			if(CountInv("IchivalUpgrade") == 0 || CountInv("IchivalUpgrade") == 3 || CountInv("IchivalUpgrade") == 5 || CountInv("IchivalUpgrade") == 8)
				{
				A_Print("$DRUIICH1", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradePrimaryIchivalWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK),"UpgradePrimaryIchival2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradePrimaryIchival2:
		UPG8 T 1 {A_GiveInventory("IchivalUpgrade",1); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeSecondaryIchival:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("IchivalUpgrade") == 0 || CountInv("IchivalUpgrade") == 1 || CountInv("IchivalUpgrade") == 5 || CountInv("IchivalUpgrade") == 6)
				{
				A_Print("$DRUIICH2", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeSecondaryIchivalWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK),"UpgradeSecondaryIchival2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeSecondaryIchival2:
		UPG8 T 1 {A_GiveInventory("IchivalUpgrade",3); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
	UpgradeTertiaryIchival:
		UPG8 T 1
		UPG8 T 1 
		{
			if(CountInv("IchivalUpgrade") == 0 || CountInv("IchivalUpgrade") == 1 || CountInv("IchivalUpgrade") == 3 || CountInv("IchivalUpgrade") == 4)
				{
				A_Print("$DRUIICH3", 6, "UPGFNT");
				}
			else
				{
				A_Print("This mode cannot be upgraded further!", 3, "UPGFNT");
				A_GiveInventory("IAMTHEGREATUPGRADER",1);		
				}
		}
		UPG8 T 1 A_JumpIfInventory("IAMTHEGREATUPGRADER",2,"CancelUpgrader1")
		UPG8 T 20
	UpgradeTertiaryIchivalWait:
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_RELOAD),"UpgradeTertiaryIchival2")
		UPG8 T 0 A_JumpIf((GetPlayerInput(INPUT_BUTTONS) & BT_USE),"CancelUpgrader1")
		UPG8 T 1 A_GiveInventory("UpgradeTimer",1)
		UPG8 T 0 A_JumpIfInventory("UpgradeTimer",174,"CancelUpgrader1")
		Loop
	UpgradeTertiaryIchival2:
		UPG8 T 1 {A_GiveInventory("IchivalUpgrade",5); A_StartSound("EnchantMagi",CHAN_7,CHANF_OVERLAP|CHANF_UI,1,false,ATTN_NONE); A_GiveInventory("IAMTHEGREATUPGRADER",1);}
		Goto PostProcessing 	
/////////////////////////////////////////////////////////////////////////////////////	
	DoNothing: //If aborted, the item is refunded.
		UPG8 T 1 {A_Print("Upgrading Aborted!", 3, "UPGFNT"); A_GiveInventory("IAMTHEGREATUPGRADER",2);}
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1)
				{A_TakeInventory("UpgradeFreezePrevention", 1);}
				else
				{A_GiveInventory("BluuTriiFruit", 1);}
				}
		Stop
	PostProcessing:
		UPG8 U 1 A_GiveInventory("UpgradeBarKill",1)
		UPG8 U 1 A_TakeInventory("PowerTimeFreezer")
		UPG8 U 1 A_TakeInventory("UpgraderPause")	
		UPG8 V 1 SetPlayerProperty(1,0,PROP_TOTALLYFROZEN)
		UPG8 V 1 A_TakeInventory("UpgradeBarKill")
		TNT1 A 1 A_TakeInventory("IAMTHEGREATUPGRADER")
		TNT1 A 1 {if(CountInv("UpgradeFreezePrevention") == 1) //If a bonus was given earlier, remove it.
				{
				A_TakeInventory("UpgradeFreezePrevention", 1); 
				A_TakeInventory("BluuTriiFruit", 1);
				}}
		Stop
  }
}

ACTOR WandofHitScan: CustomInventory 23890
{
  +FLOATBOB
  +COUNTITEM
  +INVENTORY.INVBAR
  +INVENTORY.FANCYPICKUPSOUND
  +INVENTORY.UNDROPPABLE
  +INVENTORY.KEEPDEPLETED
  Inventory.PickupSound "misc/p_pkup"
  Inventory.PickupSound "Pickup/UseTeamHeal"
  Inventory.PickupMessage "\c[white]The \c[gold]Wand of Hitscan\c[white]? Seems useless, but who knows...?" 
  Tag "Toggles distant switches."
  Inventory.UseSound "artiuse"
  Inventory.Icon WANDSCAN
  FloatBobStrength 0.5
  Scale 0.8
  Inventory.InterHubAmount 2
  Inventory.MaxAmount 2
  Decal "BulletChip"
  States
  {
	Spawn:
		TNT1 A 0
		Loop
	Use:
		TNT1 A 0 A_Playsound("MageWandFire",CHAN_ITEM,1,false,ATTN_NONE)
		TNT1 A 0 A_FireBullets(0,0,1,1,"HitscanShot",FBF_NOFLASH|FBF_EXPLICITANGLE,4092)
		Goto Giveback
	Giveback:
		TNT1 A 0 A_GiveInventory("WandofHitScan",1) 
		Stop
  }
}

Actor HitscanShot //For Wand, above
{
	Height 2
	Radius 10
	Damage 0
	Speed 0
	RenderStyle Add
	Alpha 0.9
	Scale 1
	Gravity 0.05
	Mass 10
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	+NOINTERACTION
	+DROPOFF
	+PAINLESS //precaution measure for wand of hitscan which uses this.
	States
	{
	Spawn:
		HT5C A 0
	Spawn2:
		HT5C ABCD 3 Bright 
		Stop
	}
}

ACTOR LoveAndPieceMyrm : CustomInventory //New 0.87 ult spawners part II
{
	+FLOATBOB
	Inventory.PickupSound "Pickup/WeaponBlade"
	+INVENTORY.QUIET
	//Inventory.PickupMessage "\c[white]This must be \c[brick]a piece of\c[white] the Greatsword of \c[green]Duke Aurelius Quietus\c[white]!!"
	States
	{
	Spawn:
		TNT1 A 0 A_JumpIfInventory("QuietusX", 1, "OnlyMana",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "IsMyrm2",AAPTR_PLAYER1)
		Goto Hilt
	IsMyrm2:
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Goto Blade
	Hilt:
		WFR3 A 1 Bright A_SpawnItemEx("QuietSparklies",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WFR3 A 0 A_JumpIfInventory("WeaponHolder", 1, "Blade",AAPTR_PLAYER1)
		Loop
	Blade:
		WFR1 A 1 Bright A_SpawnItemEx("QuietSparklies",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WFR1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Loop
	Pommel:
		WFR2 A 1 Bright A_SpawnItemEx("QuietSparklies",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WFR2 A 0 A_JumpIfInventory("QuietusX", 1, "OnlyMana",AAPTR_PLAYER1)
		Loop
	OnlyMana:
		TNT1 A 0 A_ChangeFlag("INVENTORY.QUIET", TRUE)    
		Goto OnlyMana3
	OnlyMana3:
		KR4T AB 1
		Loop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("QuietusX", 1, "ManaGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "PommelGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "BladeGet",AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("QuietusXPiece3", 1)
		TNT1 A 0 A_Log("\c[white]A hilt and pommel, \c[green]etched with strange runes I can't read\c[white]. It feels important...")
		TNT1 A 0 A_Playsound("Pickup/WeaponBlade",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	PommelGet:
		TNT1 A 0 A_GiveInventory("QuietusXPiece2", 1)
		TNT1 A 0 A_Log("\c[white]Ah yes! This \c[green]ornate crossguard\c[white] is the last part I need!")
		TNT1 A 0 A_Log("\c[white]Assembled the artefact \c[brick]Greatsword\c[white] once used by \c[green]Duke Aurelius Quietus\c[white]!!")
		TNT1 A 0 A_Playsound("WeaponBuild",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	BladeGet:
		TNT1 A 0 A_GiveInventory("QuietusXPiece1", 1)
		TNT1 A 0 A_GiveInventory("CollectPieces", 1)
		TNT1 A 0 A_Log("\c[white]This \c[gold]greatsword blade\c[white] must be an antique! But it \c[green]glows with magic\c[white]... does it match the pommel I have?")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	ManaGet:
		TNT1 A 0 A_GiveInventory("KraterW", 1)
		TNT1 A 0 A_Log("\c[white]Wow... A \c[purple]Krater of Might\c[white]!! Begone Mana woes!")
		TNT1 A 0 A_Playsound("PickupArtifact",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	}
}

ACTOR LoveAndPieceCrus : CustomInventory
{
	+FLOATBOB
	+INVENTORY.QUIET
	Inventory.PickupSound "Pickup/WeaponStaff"
	//Inventory.PickupMessage "\c[white]I am blessed, this is \c[brick]a piece of\c[white] a truly \c[gold]Holy Artifact\c[white]!!"
	States
	{
	Spawn:
		TNT1 A 0 A_JumpIfInventory("CruxCalicus", 1, "OnlyMana",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "IsMyrm2",AAPTR_PLAYER1)
		Goto Hilt
	IsMyrm2:
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Goto Blade
	Hilt:
		WCH2 A 1 Bright A_SpawnItemEx("BlueSparklies",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WCH2 A 0 A_JumpIfInventory("WeaponHolder", 1, "Blade",AAPTR_PLAYER1)
		Loop
	Blade:
		WCH1 A 1 Bright A_SpawnItemEx("BlueSparklies",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WCH1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Loop
	Pommel:
		WCH3 A 1 Bright A_SpawnItemEx("BlueSparklies",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WCH3 A 0 A_JumpIfInventory("CruxCalicus", 1, "OnlyMana",AAPTR_PLAYER1)
		Loop
	OnlyMana:
		TNT1 A 0 A_ChangeFlag("INVENTORY.QUIET", TRUE)    
		Goto OnlyMana3
	OnlyMana3:
		KR4T AB 1
		Loop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("CruxCalicus", 1, "ManaGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "PommelGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "BladeGet",AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("CruxCalicusPiece2", 1)
		TNT1 A 0 A_Log("\c[white]Found a strange \c[green]piece of a Crucifix\c[white]... I feel as though it is holy.")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	PommelGet:
		TNT1 A 0 A_GiveInventory("CruxCalicusPiece3", 1)
		TNT1 A 0 A_Log("\c[white]This \c[ice]stave of Cold Iron \c[white]is the missing part... it is merging with the others!")
		TNT1 A 0 A_Log("\c[white]Praise \c[gold]The Shining One\c[white]! The \c[ice]Holy Artifact 'Crux Calicus'\c[white] has chosen me!")
		TNT1 A 0 A_Playsound("WeaponBuild",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	BladeGet:
		TNT1 A 0 A_GiveInventory("CruxCalicusPiece1", 1)
		TNT1 A 0 A_GiveInventory("CollectPieces", 1)
		TNT1 A 0 A_Log("\c[white]This is a \c[purple]very ornate sculpture\c[white] depicting the \c[gold]Shining One\c[white]. Perhaps this is an omen?")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	ManaGet:
		TNT1 A 0 A_GiveInventory("KraterW", 1)
		TNT1 A 0 A_Log("\c[white]Wow... A \c[purple]Krater of Might\c[white]!! Begone Mana woes!")
		TNT1 A 0 A_Playsound("PickupArtifact",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	}
}

ACTOR LoveAndPieceMagi : CustomInventory
{
	+FLOATBOB
	Inventory.PickupSound "Pickup/WeaponStaff"
	+INVENTORY.QUIET
	//Inventory.PickupMessage "\c[white]Hmm, this is a \c[brick]very magical item\c[white]... perhaps I can create \c[purple]a powerful stave with it\c[white]?"
	States
	{
	Spawn:
		TNT1 A 0 A_JumpIfInventory("Agnus", 1, "OnlyMana",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "IsMyrm2",AAPTR_PLAYER1)
		Goto Hilt
	IsMyrm2:
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Goto Blade
	Hilt:
		WMS2 A 1 Bright A_SpawnItemEx("PurpleSparklies2",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WMS2 A 0 A_JumpIfInventory("WeaponHolder", 1, "Blade",AAPTR_PLAYER1)
		Loop
	Blade:
		WMS3 A 1 Bright A_SpawnItemEx("PurpleSparklies2",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WMS3 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Loop
	Pommel:
		WMS1 A 1 Bright A_SpawnItemEx("PurpleSparklies2",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WMS1 A 0 A_JumpIfInventory("Agnus", 1, "OnlyMana",AAPTR_PLAYER1)
		Loop
	OnlyMana:
		TNT1 A 0 A_ChangeFlag("INVENTORY.QUIET", TRUE)    
		Goto OnlyMana3
	OnlyMana3:
		KR4T AB 1
		Loop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("Agnus", 1, "ManaGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "PommelGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "BladeGet",AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("AgnusPiece2", 1)
		TNT1 A 0 A_Log("\c[white]An impressive \c[brown]length of Ironwood\c[white], glowing with power. I can use it to make a stave!")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	PommelGet:
		TNT1 A 0 A_GiveInventory("AgnusPiece1", 1)
		TNT1 A 0 A_Log("\c[white]An Amethyst sphere with a bust of \c[purple]Agnus Dei\c[white]? It seems full of power...")
		TNT1 A 0 A_Log("\c[white]Assembled my own Archmage Staff! It has named itself... \c[purple]Agnus Abyssus\c[white]?")
		TNT1 A 0 A_Playsound("WeaponBuild",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	BladeGet:
		TNT1 A 0 A_GiveInventory("AgnusPiece3", 1)
		TNT1 A 0 A_GiveInventory("CollectPieces", 1)
		TNT1 A 0 A_Log("\c[white]Another \c[brown]shaft of Ironwood\c[white] and \c[ice]Cold Steel\c[white]. Now I need a focus...")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	ManaGet:
		TNT1 A 0 A_GiveInventory("KraterW", 1)
		TNT1 A 0 A_Log("\c[white]Wow... A \c[purple]Krater of Might\c[white]!! Begone Mana woes!")
		TNT1 A 0 A_Playsound("PickupArtifact",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	}
}

ACTOR LoveAndPieceDrui : CustomInventory
{
	+FLOATBOB
	+INVENTORY.QUIET
	Inventory.PickupSound "Pickup/WeaponStaff"
	Scale 0.8
	//Inventory.PickupMessage "\c[white]Hmm, this is a \c[brick]very magical item\c[white]... perhaps I can create \c[purple]a powerful stave with it\c[white]?"
	States
	{
	Spawn:
		TNT1 A 0 A_JumpIfInventory("Ichival", 1, "OnlyMana",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "IsMyrm2",AAPTR_PLAYER1)
		Goto Hilt
	IsMyrm2:
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Goto Blade
	Hilt:
		WDR2 A 1 Bright A_SpawnItemEx("YellowSparklies2",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WDR2 A 0 A_JumpIfInventory("WeaponHolder", 1, "Blade",AAPTR_PLAYER1)
		Loop
	Blade:
		WDR1 A 1 Bright A_SpawnItemEx("YellowSparklies2",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WDR1 A 0 A_JumpIfInventory("CollectPieces", 1, "Pommel",AAPTR_PLAYER1)
		Loop
	Pommel:
		WDR3 A 1 Bright A_SpawnItemEx("YellowSparklies2",0,0,20,frandom(-0.6,0.6),frandom(-0.6,0.6),frandom(0,0.8))
		WDR3 A 0 A_JumpIfInventory("Ichival", 1, "OnlyMana",AAPTR_PLAYER1)
		Loop
	OnlyMana:
		TNT1 A 0 A_ChangeFlag("INVENTORY.QUIET", TRUE)    
		Goto OnlyMana3
	OnlyMana3:
		KR4T AB 1
		Loop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("Ichival", 1, "ManaGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("CollectPieces", 1, "PommelGet",AAPTR_PLAYER1)
		TNT1 A 0 A_JumpIfInventory("WeaponHolder", 1, "BladeGet",AAPTR_PLAYER1)
		TNT1 A 0 A_GiveInventory("IchivalPiece2", 1)
		TNT1 A 0 A_Log("\c[white]Antlers from a Corusdeer? They thrum with \c[red]fiery power\c[white]... perhaps they'll be of use?")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	PommelGet:
		TNT1 A 0 A_Log("\c[white]A spool of \c[gold]gold, made into thread\c[white]. I can make it into a bowstring, which is the last part I need!")
		TNT1 A 0 A_Log("\c[white]Created The \c[gold]'Ichival'\c[white]: the Bow of the Brightest Butterfly!")
		TNT1 A 0 A_GiveInventory("IchivalPiece3", 1)
		TNT1 A 0 A_Playsound("WeaponBuild",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	BladeGet:
		TNT1 A 0 A_Log("\c[white]An unfinished shaft of a bow, with a carving of the \c[gold]Brightest Butterfly\c[white]... I'll keep this...")
		TNT1 A 0 A_Playsound("Pickup/WeaponStaff",CHAN_ITEM,1,false,ATTN_NONE)
		TNT1 A 0 A_GiveInventory("IchivalPiece1", 1)
		TNT1 A 0 A_GiveInventory("CollectPieces", 1)
		Stop
	ManaGet:
		TNT1 A 0 A_GiveInventory("KraterW", 1)
		TNT1 A 0 A_Log("\c[white]Wow... A \c[purple]Krater of Might\c[white]!! Begone Mana woes!")
		TNT1 A 0 A_Playsound("PickupArtifact",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	}
}

/// 0.91 New Armour Routine

ACTOR ArmourSuperWalp : CustomInventory 23891
{
  +INVENTORY.QUIET
  +INVENTORY.PICKUPFLASH
  +INVENTORY.AUTOACTIVATE
  Inventory.MaxAmount 0
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_PLAYER1),"SpawnCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_PLAYER1),"SpawnMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_PLAYER1),"SpawnMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_PLAYER1),"SpawnDrui")
		Stop
	SpawnMyrm:
		ARMM X -1
		Stop
	SpawnCrus:
		ARMC X -1
		Stop
	SpawnMagi:
		ARMG X -1
		Stop
	SpawnDrui:
		ARMD X -1
		Stop
	Pickup:
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_PLAYER1),"IsCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_PLAYER1),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_PLAYER1),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_PLAYER1),"IsDrui")
		Stop
//MeshArmourW DrakeBoots PlatinumHelmW AmuletOfWardingW
	IsMyrm:
		TNT1 A 0
		TNT1 A 1 A_SpawnItemEx("ArmourSilent")
		TNT1 A 1 A_SpawnItemEx("HelmSilent")
		TNT1 A 0 A_Log("\c[white]A set of \c[red]Legion Armour\c[white]! In good repair too... It will be a \c[gold]precious bulwark\c[white] against evil.")
		TNT1 A 0 A_Playsound("Pickup/ArmourHeavy",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	IsCrus:
		TNT1 A 0
		TNT1 A 1 A_SpawnItemEx("ArmourSilent")
		TNT1 A 1 A_SpawnItemEx("HelmSilent")
		TNT1 A 0 A_Log("\c[white]A set of \c[sapphire]Questing Plate\c[white]! I have missed it so... It will be a \c[gold]precious bulwark\c[white] against evil.")
		TNT1 A 0 A_Playsound("Pickup/ArmourHeavy",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	IsMagi:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("AmuletSilent")
		TNT1 A 0 A_SpawnItemEx("BootsSilent")
		TNT1 A 0 A_Log("\c[white]A \c[red]Spellweavers Robe!\c[white] It is weaved with protective charms and will be a \c[gold]precious bulwark\c[white] against evil.")
		TNT1 A 0 A_Playsound("Pickup/ArmourLight",CHAN_ITEM,1,false,ATTN_NONE)
		Stop 
	IsDrui:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("AmuletSilent")
		TNT1 A 0 A_SpawnItemEx("BootsSilent")
		TNT1 A 0 A_Log("\c[white]A set of \c[green]Mountain Ranger's Gear\c[white]? Strange... nevertheless it will be a \c[gold]precious bulwark\c[white] against evil.")
		TNT1 A 0 A_Playsound("Pickup/ArmourLight",CHAN_ITEM,1,false,ATTN_NONE)
		Stop 
  }
}

ACTOR ArmourLesserWalp : CustomInventory 23892
{
  +INVENTORY.QUIET
  +INVENTORY.PICKUPFLASH
  +INVENTORY.AUTOACTIVATE
  Inventory.MaxAmount 0
  States
  {
	Spawn:
		TNT1 A 0 Nodelay A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_PLAYER1),"SpawnCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_PLAYER1),"SpawnMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_PLAYER1),"SpawnMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_PLAYER1),"SpawnDrui")
		Stop
	SpawnMyrm:
		ARMM M -1
		Stop
	SpawnCrus:
		ARMC M -1
		Stop
	SpawnMagi:
		ARMG M -1
		Stop
	SpawnDrui:
		ARMD M -1
		Stop
	Pickup:
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer",AAPTR_PLAYER1),"IsCrus")
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer",AAPTR_PLAYER1),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer",AAPTR_PLAYER1),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer",AAPTR_PLAYER1),"IsDrui")
		Stop
	IsMyrm:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("AmuletSilent") //A_GiveInventory("AmuletOfWardingW", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_SpawnItemEx("BootsSilent") //A_GiveInventory("DrakeBoots", 1,AAPTR_PLAYER1)
		TNT1 A 0 A_Log("\c[white]Fresh sets of \c[red]Gauntlets\c[white] and \c[green]Boots\c[white]! They should help \c[gold]protect\c[white] me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourMed",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	IsCrus:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("AmuletSilent")
		TNT1 A 0 A_SpawnItemEx("BootsSilent")
		TNT1 A 0 A_Log("\c[white]Excellent, a new \c[red]Shield\c[white] and \c[gold]Rosary\c[white]! They should help \c[gold]protect\c[white] me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourMed",CHAN_ITEM,1,false,ATTN_NONE)
		Stop
	IsMagi:
		TNT1 A 0
		TNT1 A 1 A_SpawnItemEx("ArmourSilent")
		TNT1 A 1 A_SpawnItemEx("HelmSilent")
		TNT1 A 0 A_Log("\c[white]A pristine \c[red]Tunic\c[white] and a \c[sapphire]Focusing Stone\c[white]! They should help \c[gold]protect\c[white] me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourClothing",CHAN_ITEM,1,false,ATTN_NONE)
		Stop 
	IsDrui:
		TNT1 A 0
		TNT1 A 1 A_SpawnItemEx("ArmourSilent")
		TNT1 A 1 A_SpawnItemEx("HelmSilent")
		TNT1 A 0 A_Log("\c[white]A hard-wearing \c[green]Tunic\c[white] and a \c[purple]Wolf Fetish\c[white]! They should help \c[gold]protect\c[white] me.")
		TNT1 A 0 A_Playsound("Pickup/ArmourCloaks",CHAN_ITEM,1,false,ATTN_NONE)
		Stop 
  }
}

ACTOR ActiveTauntSystem : CustomInventory
{
	Inventory.MaxAmount 0
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP	
	States
	{
	Use:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(CountInv("PowerShutItWilson") >= 1,"ReallyEndTaunt") //stops taunts if one happened in last 3 secs
		TNT1 A 0 A_JumpIfInventory("StopTalkingMax",1,"PreventRepeatings") //stops taunts if happened less than 3 kills ago
		TNT1 A 0 A_JumpIf(CheckClass("CrusaderPlayer"),"IsCrus") 
		TNT1 A 0 A_JumpIf(CheckClass("MyrmidonPlayer"),"IsMyrm")
		TNT1 A 0 A_JumpIf(CheckClass("MagisterPlayer"),"IsMagi")
		TNT1 A 0 A_JumpIf(CheckClass("DruidPlayer"),"IsDrui")
		Stop
	IsDrui: 
		TNT1 A 0 A_JumpIf(random(0,110) <= GetCvar("walp_tauntchance"),"DruidTaunt") 
		Stop
	IsMyrm:
		TNT1 A 0 A_JumpIf(random(0,110) <= GetCvar("walp_tauntchance"),"MyrmTaunt")
		Stop
	IsCrus:
		TNT1 A 0 A_JumpIf(random(0,110) <= GetCvar("walp_tauntchance"),"CrusTaunt")
		Stop
	IsMagi:
		TNT1 A 0 A_JumpIf(random(0,110) <= GetCvar("walp_tauntchance"),"MagiTaunt")
		Stop
	//The chance is actually somewhat lower than the player thinks; (i.e. 15% is actually 13%, 40% is actually 36%)
	//this is due to people (including me) having funny ideas about how RNG works, lol. 
	DruidTaunt:
		TNT1 A 0 A_JumpIfInventory("DogInHand",1,"DruidWolfTaunt")
		TNT1 A 0 A_StartSound("DruiTaunts",CHAN_AUTO,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto EndTaunt
	DruidWolfTaunt:
		TNT1 A 0 A_StartSound("DruiDogTaunts",CHAN_AUTO,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto EndTaunt
	MyrmTaunt:
		TNT1 A 0 A_StartSound("MyrmTaunts",CHAN_AUTO,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto EndTaunt
	CrusTaunt:
		TNT1 A 0 A_StartSound("CrusTaunts",CHAN_AUTO,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto EndTaunt
	MagiTaunt:
		TNT1 A 0 A_StartSound("MagiTaunts",CHAN_AUTO,CHANF_OVERLAP,1,false,ATTN_NONE)
		Goto EndTaunt
	PreventRepeatings:
		TNT1 A 0 A_TakeInventory("StopTalkingMax",1)
		Stop
	EndTaunt:
		TNT1 A 0 A_GiveInventory("StopTalkingMax",2)
		TNT1 A 0 A_GiveInventory("DontPlayItAgainSam",1)
	ReallyEndTaunt:
		TNT1 A 0 
		Stop
	}
}

ACTOR DontPlayItAgainSam : PowerupGiver
{
	Powerup.Duration -3
	Powerup.Type "ShutItWilson"
	Powerup.Color "None", 0.0
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	+INVENTORY.ADDITIVETIME
}

ACTOR PowerShutItWilson : Powerup
{
	Powerup.Duration -3
	+INVENTORY.ADDITIVETIME
}